diff --git a/src/App.tsx b/src/App.tsx index 61f70fb8..a8ce5dbd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -50,7 +50,7 @@ const App: React.FC = ( const isAILoaded = isObjectDetectorLoaded || isPoseDetectionLoaded || isYOLOV5ObjectDetectorLoaded - || (roboflowAPIDetails.model !== '' && roboflowAPIDetails.key !== '') + || (roboflowAPIDetails.model !== '' && roboflowAPIDetails.key !== '' && roboflowAPIDetails.status) return (
{ - store.dispatch(updateRoboflowAPIDetails({model: '', key: ''})); + store.dispatch(updateRoboflowAPIDetails({status: false, model: '', key: ''})); onFailure() } diff --git a/src/logic/actions/AIRoboflowAPIObjectDetectionActions.ts b/src/logic/actions/AIRoboflowAPIObjectDetectionActions.ts index dc53b612..c1c3b2c7 100644 --- a/src/logic/actions/AIRoboflowAPIObjectDetectionActions.ts +++ b/src/logic/actions/AIRoboflowAPIObjectDetectionActions.ts @@ -13,11 +13,6 @@ import { AIActions } from './AIActions'; import { updateSuggestedLabelList } from '../../store/ai/actionCreators'; export class AIRoboflowAPIObjectDetectionActions { - public static detectRectsForActiveImage(): void { - const activeImageData: ImageData = LabelsSelector.getActiveImageData(); - AIRoboflowAPIObjectDetectionActions.detectRects(activeImageData) - } - public static detectRects(imageData: ImageData): void { if (imageData.isVisitedByRoboflowAPI || !AISelector.isRoboflowAPIModelLoaded()) return; diff --git a/src/logic/initializer/AppInitializer.ts b/src/logic/initializer/AppInitializer.ts index 9e75184f..34ac16fc 100644 --- a/src/logic/initializer/AppInitializer.ts +++ b/src/logic/initializer/AppInitializer.ts @@ -1,11 +1,11 @@ -import {updateWindowSize} from "../../store/general/actionCreators"; -import {ContextManager} from "../context/ContextManager"; -import {store} from "../../index"; -import {PlatformUtil} from "../../utils/PlatformUtil"; -import {PlatformModel} from "../../staticModels/PlatformModel"; -import {EventType} from "../../data/enums/EventType"; -import {GeneralSelector} from "../../store/selectors/GeneralSelector"; -import {EnvironmentUtil} from "../../utils/EnvironmentUtil"; +import {updateWindowSize} from '../../store/general/actionCreators'; +import {ContextManager} from '../context/ContextManager'; +import {store} from '../../index'; +import {PlatformUtil} from '../../utils/PlatformUtil'; +import {PlatformModel} from '../../staticModels/PlatformModel'; +import {EventType} from '../../data/enums/EventType'; +import {GeneralSelector} from '../../store/selectors/GeneralSelector'; +import {EnvironmentUtil} from '../../utils/EnvironmentUtil'; export class AppInitializer { public static inti():void { @@ -37,11 +37,7 @@ export class AppInitializer { }; private static disableUnwantedKeyBoardBehaviour = (event: KeyboardEvent) => { - if (PlatformModel.isMac && event.metaKey) { - event.preventDefault(); - } - - if (["=", "+", "-"].includes(event.key)) { + if (['=', '+', '-'].includes(event.key)) { if (event.ctrlKey || (PlatformModel.isMac && event.metaKey)) { event.preventDefault(); } diff --git a/src/store/ai/reducer.ts b/src/store/ai/reducer.ts index f1c1373f..5f61e2ae 100644 --- a/src/store/ai/reducer.ts +++ b/src/store/ai/reducer.ts @@ -8,6 +8,7 @@ const initialState: AIState = { isYOLOV5ObjectDetectorLoaded: false, isPoseDetectorLoaded: false, roboflowAPIDetails: { + status: false, model: '', key: '' }, diff --git a/src/store/ai/types.ts b/src/store/ai/types.ts index 0243e232..bd9a3b32 100644 --- a/src/store/ai/types.ts +++ b/src/store/ai/types.ts @@ -1,6 +1,7 @@ import {Action} from '../Actions'; export type RoboflowAPIDetails = { + status: boolean, model: string, key: string } diff --git a/src/store/selectors/AISelector.ts b/src/store/selectors/AISelector.ts index 4ee376a2..cc8206bf 100644 --- a/src/store/selectors/AISelector.ts +++ b/src/store/selectors/AISelector.ts @@ -25,7 +25,7 @@ export class AISelector { public static isRoboflowAPIModelLoaded(): boolean { const roboflowAPIDetails = store.getState().ai.roboflowAPIDetails; return ( - roboflowAPIDetails.model !== '' && roboflowAPIDetails.key !== '' + roboflowAPIDetails.model !== '' && roboflowAPIDetails.key !== '' && roboflowAPIDetails.status ); } diff --git a/src/views/PopupView/ConnectInferenceServerPopup/ConnectInferenceServerPopup.tsx b/src/views/PopupView/ConnectInferenceServerPopup/ConnectInferenceServerPopup.tsx index f6032c98..67608c82 100644 --- a/src/views/PopupView/ConnectInferenceServerPopup/ConnectInferenceServerPopup.tsx +++ b/src/views/PopupView/ConnectInferenceServerPopup/ConnectInferenceServerPopup.tsx @@ -13,20 +13,27 @@ import { NotificationsDataMap } from '../../../data/info/NotificationsData'; import { Notification } from '../../../data/enums/Notification'; import './ConnectInferenceServerPopup.scss' import { StyledTextField } from '../../Common/StyledTextField/StyledTextField'; -import { RoboflowAPIDetails } from '../../../store/ai/types'; +import { AIActionTypes, RoboflowAPIDetails } from '../../../store/ai/types'; import { RoboflowAPIObjectDetector } from '../../../ai/RoboflowAPIObjectDetector'; import { ClipLoader } from 'react-spinners'; import { CSSHelper } from '../../../logic/helpers/CSSHelper'; +import { updateRoboflowAPIDetails } from '../../../store/ai/actionCreators'; +import { AIActions } from '../../../logic/actions/AIActions'; +import { ImageRepository } from '../../../logic/imageRepository/ImageRepository'; +import { ImageData } from '../../../store/labels/types'; +import { LabelsSelector } from '../../../store/selectors/LabelsSelector'; interface IProps { roboflowAPIDetails: RoboflowAPIDetails; submitNewNotificationAction: (notification: INotification) => NotificationsActionType; + updateRoboflowAPIDetailsAction: (roboflowAPIDetails: RoboflowAPIDetails) => AIActionTypes; } const ConnectInferenceServerPopup: React.FC = ( { roboflowAPIDetails, - submitNewNotificationAction + submitNewNotificationAction, + updateRoboflowAPIDetailsAction } ) => { // general @@ -64,7 +71,15 @@ const ConnectInferenceServerPopup: React.FC = ( if (disableAcceptButton()) return; const onSuccess = () => { + updateRoboflowAPIDetailsAction({ + status: true, + model: roboflowModel, + key: roboflowKey + }) PopupActions.close(); + + const activeImageData: ImageData = LabelsSelector.getActiveImageData(); + AIActions.detect(activeImageData.id, ImageRepository.getById(activeImageData.id)); } const onFailure = () => { @@ -75,6 +90,7 @@ const ConnectInferenceServerPopup: React.FC = ( setModelIsLoadingStatus(true); RoboflowAPIObjectDetector.loadModel({ + status: false, model: roboflowModel, key: roboflowKey }, onSuccess, onFailure) @@ -178,7 +194,8 @@ const ConnectInferenceServerPopup: React.FC = ( } const mapDispatchToProps = { - submitNewNotificationAction: submitNewNotification + submitNewNotificationAction: submitNewNotification, + updateRoboflowAPIDetailsAction: updateRoboflowAPIDetails }; const mapStateToProps = (state: AppState) => ({