From 1035f2fc22318aff2886186d4982e482d1115363 Mon Sep 17 00:00:00 2001 From: Nobody Date: Thu, 28 Nov 2019 14:33:35 +0000 Subject: [PATCH 01/10] Initial commit From ee1fbb4555bd49b88d98a2ff0465bf715dfc00bd Mon Sep 17 00:00:00 2001 From: Nobody Date: Thu, 28 Nov 2019 14:34:06 +0000 Subject: [PATCH 02/10] Initial commit From 7055c1a0780632ea83b530a13d9fad917e15f7ec Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 11:48:22 +0300 Subject: [PATCH 03/10] Configurable environment --- Dockerfile.ui | 4 +++- cvat-ui/.env | 9 --------- cvat-ui/.env.production | 9 --------- cvat-ui/src/core.ts | 6 +++--- cvat-ui/webpack.config.js | 4 +++- docker-compose.yml | 8 ++++---- 6 files changed, 13 insertions(+), 27 deletions(-) delete mode 100644 cvat-ui/.env delete mode 100644 cvat-ui/.env.production diff --git a/Dockerfile.ui b/Dockerfile.ui index c5939296849e..6681bd701b12 100644 --- a/Dockerfile.ui +++ b/Dockerfile.ui @@ -4,6 +4,9 @@ ARG http_proxy ARG https_proxy ARG no_proxy ARG socks_proxy +ARG REACT_APP_API_PORT +ARG REACT_APP_API_PROTOCOL +ARG REACT_APP_API_HOST ENV TERM=xterm \ http_proxy=${http_proxy} \ @@ -36,7 +39,6 @@ RUN npm install # Build source code COPY cvat-core/ /tmp/cvat-core/ COPY cvat-ui/ /tmp/cvat-ui/ -RUN mv .env.production .env && npm run build FROM nginx # Replace default.conf configuration to remove unnecessary rules diff --git a/cvat-ui/.env b/cvat-ui/.env deleted file mode 100644 index ac71a0911007..000000000000 --- a/cvat-ui/.env +++ /dev/null @@ -1,9 +0,0 @@ -REACT_APP_VERSION=${npm_package_version} - -REACT_APP_API_PROTOCOL=http -REACT_APP_API_HOST=localhost -REACT_APP_API_PORT=7000 -REACT_APP_API_HOST_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT} -REACT_APP_API_FULL_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT}/api/v1 - -SKIP_PREFLIGHT_CHECK=true diff --git a/cvat-ui/.env.production b/cvat-ui/.env.production deleted file mode 100644 index d5af5e40249b..000000000000 --- a/cvat-ui/.env.production +++ /dev/null @@ -1,9 +0,0 @@ -REACT_APP_VERSION=${npm_package_version} - -REACT_APP_API_PROTOCOL=http -REACT_APP_API_HOST=localhost -REACT_APP_API_PORT=8080 -REACT_APP_API_HOST_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT} -REACT_APP_API_FULL_URL=${REACT_APP_API_PROTOCOL}://${REACT_APP_API_HOST}:${REACT_APP_API_PORT}/api/v1 - -SKIP_PREFLIGHT_CHECK=true diff --git a/cvat-ui/src/core.ts b/cvat-ui/src/core.ts index 29187c105392..8f5b95163852 100644 --- a/cvat-ui/src/core.ts +++ b/cvat-ui/src/core.ts @@ -2,9 +2,9 @@ import _cvat from '../../cvat-core/src/api'; const cvat: any = _cvat; -const protocol = process.env.REACT_APP_API_PROTOCOL; -const host = process.env.REACT_APP_API_HOST; -const port = process.env.REACT_APP_API_PORT; +const protocol = process.env.REACT_APP_API_PROTOCOL || 'http'; +const host = process.env.REACT_APP_API_HOST || 'localhost'; +const port = process.env.REACT_APP_API_PORT || '7000'; cvat.config.backendAPI = `${protocol}://${host}:${port}/api/v1`; diff --git a/cvat-ui/webpack.config.js b/cvat-ui/webpack.config.js index ae5688976a17..6f9ae26296b3 100644 --- a/cvat-ui/webpack.config.js +++ b/cvat-ui/webpack.config.js @@ -59,7 +59,9 @@ module.exports = { template: "./src/index.html", inject: false, }), - new Dotenv(), + new Dotenv({ + systemvars: true, + }), ], node: { fs: 'empty' }, }; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 82dfa352e5a0..a3f7c56f0be9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,11 +73,11 @@ services: https_proxy: no_proxy: socks_proxy: + REACT_APP_API_PROTOCOL: http + REACT_APP_API_HOST: localhost + REACT_APP_API_PORT: 8080 dockerfile: Dockerfile.ui - environment: - REACT_APP_API_PROTOCOL: http - REACT_APP_API_HOST: localhost - REACT_APP_API_PORT: 8080 + networks: default: aliases: From 7201d1a425bb39f291e9a151bd6551cc69237110 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 11:52:01 +0300 Subject: [PATCH 04/10] Build cvat-ui --- Dockerfile.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile.ui b/Dockerfile.ui index 6681bd701b12..a1010edfc784 100644 --- a/Dockerfile.ui +++ b/Dockerfile.ui @@ -39,6 +39,7 @@ RUN npm install # Build source code COPY cvat-core/ /tmp/cvat-core/ COPY cvat-ui/ /tmp/cvat-ui/ +RUN npm run build FROM nginx # Replace default.conf configuration to remove unnecessary rules From 2696f5ba86d19d1ec511fed24352bebe62585c0c Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 13:18:07 +0300 Subject: [PATCH 05/10] UI Improvements --- cvat-ui/src/actions/auth-actions.ts | 18 +++++++++ cvat-ui/src/actions/models-actions.ts | 19 +++++++-- cvat-ui/src/components/cvat-app.tsx | 3 ++ cvat-ui/src/components/header/header.tsx | 9 ++++- .../src/components/login-page/login-form.tsx | 9 ++++- .../src/components/login-page/login-page.tsx | 3 +- .../register-page/register-form.tsx | 9 ++++- .../register-page/register-page.tsx | 4 +- cvat-ui/src/containers/header/header.tsx | 3 ++ .../src/containers/login-page/login-page.tsx | 14 +++++-- .../register-page/register-page.tsx | 12 ++++-- cvat-ui/src/reducers/auth-reducer.ts | 40 +++++++++++++++++++ cvat-ui/src/reducers/interfaces.ts | 4 +- cvat-ui/src/reducers/notifications-reducer.ts | 15 ++++++- 14 files changed, 143 insertions(+), 19 deletions(-) diff --git a/cvat-ui/src/actions/auth-actions.ts b/cvat-ui/src/actions/auth-actions.ts index 0d2a26fa7d43..a8b9748f03bb 100644 --- a/cvat-ui/src/actions/auth-actions.ts +++ b/cvat-ui/src/actions/auth-actions.ts @@ -8,10 +8,13 @@ const cvat = getCore(); export enum AuthActionTypes { AUTHORIZED_SUCCESS = 'AUTHORIZED_SUCCESS', AUTHORIZED_FAILED = 'AUTHORIZED_FAILED', + LOGIN = 'LOGIN', LOGIN_SUCCESS = 'LOGIN_SUCCESS', LOGIN_FAILED = 'LOGIN_FAILED', + REGISTER = 'REGISTER', REGISTER_SUCCESS = 'REGISTER_SUCCESS', REGISTER_FAILED = 'REGISTER_FAILED', + LOGOUT = 'LOGOUT', LOGOUT_SUCCESS = 'LOGOUT_SUCCESS', LOGOUT_FAILED = 'LOGOUT_FAILED', } @@ -95,6 +98,11 @@ export function registerAsync( password2: string, ): ThunkAction, {}, {}, AnyAction> { return async (dispatch: ActionCreator): Promise => { + dispatch({ + type: AuthActionTypes.REGISTER, + payload: {}, + }); + let users = null; try { await cvat.server.register(username, firstName, lastName, @@ -112,6 +120,11 @@ export function registerAsync( export function loginAsync(username: string, password: string): ThunkAction, {}, {}, AnyAction> { return async (dispatch: ActionCreator): Promise => { + dispatch({ + type: AuthActionTypes.LOGIN, + payload: {}, + }); + let users = null; try { await cvat.server.login(username, password); @@ -127,6 +140,11 @@ ThunkAction, {}, {}, AnyAction> { export function logoutAsync(): ThunkAction, {}, {}, AnyAction> { return async (dispatch: ActionCreator): Promise => { + dispatch({ + type: AuthActionTypes.LOGOUT, + payload: {}, + }); + try { await cvat.server.logout(); } catch (error) { diff --git a/cvat-ui/src/actions/models-actions.ts b/cvat-ui/src/actions/models-actions.ts index c2745195f42d..da51548b8770 100644 --- a/cvat-ui/src/actions/models-actions.ts +++ b/cvat-ui/src/actions/models-actions.ts @@ -24,6 +24,7 @@ export enum ModelsActionTypes { INFER_MODEL = 'INFER_MODEL', INFER_MODEL_SUCCESS = 'INFER_MODEL_SUCCESS', INFER_MODEL_FAILED = 'INFER_MODEL_FAILED', + FETCH_META_FAILED = 'FETCH_META_FAILED', GET_INFERENCE_STATUS = 'GET_INFERENCE_STATUS', GET_INFERENCE_STATUS_SUCCESS = 'GET_INFERENCE_STATUS_SUCCESS', GET_INFERENCE_STATUS_FAILED = 'GET_INFERENCE_STATUS_FAILED', @@ -329,6 +330,16 @@ ThunkAction, {}, {}, AnyAction> { }; } +function fetchMetaFailed(error: any): AnyAction { + const action = { + type: ModelsActionTypes.FETCH_META_FAILED, + payload: { + error, + }, + }; + + return action; +} function getInferenceStatusSuccess( taskID: number, @@ -419,7 +430,9 @@ async function timeoutCallback( dispatch(getInferenceStatusSuccess(taskID, activeInference)); } catch (error) { - dispatch(getInferenceStatusFailed(taskID, error)); + dispatch(getInferenceStatusFailed(taskID, new Error( + `Server request for the task ${taskID} was failed` + ))); } } @@ -514,9 +527,7 @@ ThunkAction, {}, {}, AnyAction> { }); } } catch (error) { - tasks.forEach((task: number): void => { - dispatch(getInferenceStatusFailed(task, error)); - }); + dispatch(fetchMetaFailed(error)); } }; } diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index ba9c40d7c494..6d139b7c24a3 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -156,6 +156,9 @@ export default class CVATApplication extends React.PureComponent { if (models.deleting) { showError('Could not delete model from the server', models.deleting); } + if (models.metaFetching) { + showError('Could not fetch models meta information from the server', models.metaFetching); + } if (models.inferenceStatusFetching) { showError('Could not fetch inference status from the server', models.inferenceStatusFetching); } diff --git a/cvat-ui/src/components/header/header.tsx b/cvat-ui/src/components/header/header.tsx index 0efeb86b117f..451d93fd9333 100644 --- a/cvat-ui/src/components/header/header.tsx +++ b/cvat-ui/src/components/header/header.tsx @@ -18,6 +18,7 @@ const core = getCore(); interface HeaderContainerProps { onLogout: () => void; + logoutFetching: boolean; installedAnalytics: boolean; installedAutoAnnotation: boolean; installedTFAnnotation: boolean; @@ -81,7 +82,13 @@ function HeaderContainer(props: Props) { }> - Logout + + {props.logoutFetching && } Logout + diff --git a/cvat-ui/src/components/login-page/login-form.tsx b/cvat-ui/src/components/login-page/login-form.tsx index 1a0733baba19..b3536797b94c 100644 --- a/cvat-ui/src/components/login-page/login-form.tsx +++ b/cvat-ui/src/components/login-page/login-form.tsx @@ -13,6 +13,7 @@ export interface LoginData { } type LoginFormProps = { + fetching: boolean; onSubmit(loginData: LoginData): void; } & FormComponentProps; @@ -80,7 +81,13 @@ class LoginFormComponent extends React.PureComponent { {this.renderPasswordField()} - diff --git a/cvat-ui/src/components/login-page/login-page.tsx b/cvat-ui/src/components/login-page/login-page.tsx index fb2befa0b2b2..90113b463bf4 100644 --- a/cvat-ui/src/components/login-page/login-page.tsx +++ b/cvat-ui/src/components/login-page/login-page.tsx @@ -13,6 +13,7 @@ import { import LoginForm, { LoginData } from './login-form'; interface LoginPageComponentProps { + fetching: boolean; onLogin: (username: string, password: string) => void; } @@ -29,7 +30,7 @@ function LoginPageComponent(props: LoginPageComponentProps & RouteComponentProps Login - { + { props.onLogin(loginData.username, loginData.password); }}/> diff --git a/cvat-ui/src/components/register-page/register-form.tsx b/cvat-ui/src/components/register-page/register-form.tsx index 7e671564b4cb..2122aec4b962 100644 --- a/cvat-ui/src/components/register-page/register-form.tsx +++ b/cvat-ui/src/components/register-page/register-form.tsx @@ -19,6 +19,7 @@ export interface RegisterData { import patterns from '../../utils/validation-patterns'; type RegisterFormProps = { + fetching: boolean; onSubmit(registerData: RegisterData): void; } & FormComponentProps; @@ -212,7 +213,13 @@ class RegisterFormComponent extends React.PureComponent { {this.renderPasswordConfirmationField()} - diff --git a/cvat-ui/src/components/register-page/register-page.tsx b/cvat-ui/src/components/register-page/register-page.tsx index d38c023478c4..5fd4025e63ad 100644 --- a/cvat-ui/src/components/register-page/register-page.tsx +++ b/cvat-ui/src/components/register-page/register-page.tsx @@ -8,12 +8,12 @@ import Text from 'antd/lib/typography/Text'; import { Col, Row, - Modal, } from 'antd'; import RegisterForm, { RegisterData } from '../../components/register-page/register-form'; interface RegisterPageComponentProps { + fetching: boolean; onRegister: (username: string, firstName: string, lastName: string, email: string, password1: string, password2: string) => void; @@ -32,7 +32,7 @@ function RegisterPageComponent(props: RegisterPageComponentProps & RouteComponen Create an account - { + { props.onRegister( registerData.username, registerData.firstName, diff --git a/cvat-ui/src/containers/header/header.tsx b/cvat-ui/src/containers/header/header.tsx index e8ba4c1e8b2c..f3ec07fbe633 100644 --- a/cvat-ui/src/containers/header/header.tsx +++ b/cvat-ui/src/containers/header/header.tsx @@ -10,6 +10,7 @@ import { import HeaderComponent from '../../components/header/header'; interface StateToProps { + logoutFetching: boolean; installedAnalytics: boolean; installedAutoAnnotation: boolean; installedTFSegmentation: boolean; @@ -25,6 +26,7 @@ function mapStateToProps(state: CombinedState): StateToProps { const { auth } = state; const { plugins } = state.plugins; return { + logoutFetching: state.auth.fetching, installedAnalytics: plugins[SupportedPlugins.ANALYTICS], installedAutoAnnotation: plugins[SupportedPlugins.AUTO_ANNOTATION], installedTFSegmentation: plugins[SupportedPlugins.TF_SEGMENTATION], @@ -42,6 +44,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps { function HeaderContainer(props: StateToProps & DispatchToProps) { return ( ); diff --git a/cvat-ui/src/containers/register-page/register-page.tsx b/cvat-ui/src/containers/register-page/register-page.tsx index b4e8a3054e36..f989ece22bc2 100644 --- a/cvat-ui/src/containers/register-page/register-page.tsx +++ b/cvat-ui/src/containers/register-page/register-page.tsx @@ -2,8 +2,11 @@ import React from 'react'; import { connect } from 'react-redux'; import { registerAsync } from '../../actions/auth-actions'; import RegisterPageComponent from '../../components/register-page/register-page'; +import { CombinedState } from '../../reducers/interfaces'; -interface StateToProps {} +interface StateToProps { + fetching: boolean; +} interface DispatchToProps { register: (username: string, firstName: string, @@ -11,8 +14,10 @@ interface DispatchToProps { password1: string, password2: string) => void; } -function mapStateToProps(): StateToProps { - return {}; +function mapStateToProps(state: CombinedState): StateToProps { + return { + fetching: state.auth.fetching, + }; } function mapDispatchToProps(dispatch: any): DispatchToProps { @@ -24,6 +29,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps { function RegisterPageContainer(props: StateToProps & DispatchToProps) { return ( ); diff --git a/cvat-ui/src/reducers/auth-reducer.ts b/cvat-ui/src/reducers/auth-reducer.ts index b4cf915a1670..023aad82cf9d 100644 --- a/cvat-ui/src/reducers/auth-reducer.ts +++ b/cvat-ui/src/reducers/auth-reducer.ts @@ -5,6 +5,7 @@ import { AuthState } from './interfaces'; const defaultState: AuthState = { initialized: false, + fetching: false, user: null, }; @@ -16,21 +17,60 @@ export default (state = defaultState, action: AnyAction): AuthState => { initialized: true, user: action.payload.user, }; + case AuthActionTypes.AUTHORIZED_FAILED: + return { + ...state, + initialized: true, + }; + case AuthActionTypes.LOGIN: + return { + ...state, + fetching: true, + } case AuthActionTypes.LOGIN_SUCCESS: return { ...state, + fetching: false, user: action.payload.user, }; + case AuthActionTypes.LOGIN_FAILED: + return { + ...state, + fetching: false, + }; + case AuthActionTypes.LOGOUT: + return { + ...state, + fetching: true, + }; case AuthActionTypes.LOGOUT_SUCCESS: return { ...state, + fetching: false, user: null, }; + case AuthActionTypes.LOGIN_FAILED: + return { + ...state, + fetching: false, + }; + case AuthActionTypes.REGISTER: + return { + ...state, + fetching: true, + user: action.payload.user, + }; case AuthActionTypes.REGISTER_SUCCESS: return { ...state, + fetching: false, user: action.payload.user, }; + case AuthActionTypes.REGISTER_FAILED: + return { + ...state, + fetching: false, + }; default: return state; } diff --git a/cvat-ui/src/reducers/interfaces.ts b/cvat-ui/src/reducers/interfaces.ts index 4f107fee8f1f..7a2e20fa6a68 100644 --- a/cvat-ui/src/reducers/interfaces.ts +++ b/cvat-ui/src/reducers/interfaces.ts @@ -1,5 +1,6 @@ export interface AuthState { initialized: boolean; + fetching: boolean; user: any; } @@ -174,8 +175,9 @@ export interface NotificationsState { models: { creating: any; starting: any; - fetching: any; deleting: any; + fetching: any; + metaFetching: any; inferenceStatusFetching: any; }; }; diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts index c4291e71cee7..e35a6cf0e5ce 100644 --- a/cvat-ui/src/reducers/notifications-reducer.ts +++ b/cvat-ui/src/reducers/notifications-reducer.ts @@ -39,8 +39,9 @@ const defaultState: NotificationsState = { models: { creating: null, starting: null, - fetching: null, deleting: null, + fetching: null, + metaFetching: null, inferenceStatusFetching: null, }, }, @@ -279,6 +280,18 @@ export default function (state = defaultState, action: AnyAction): Notifications ...state, }; } + case ModelsActionTypes.FETCH_META_FAILED: { + return { + ...state, + errors: { + ...state.errors, + models: { + ...state.errors.models, + metaFetching: action.payload.error, + }, + }, + }; + } case ModelsActionTypes.GET_INFERENCE_STATUS_FAILED: { return { ...state, From 59d587915823545f22ae83e286cddb1f2bf05342 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 13:29:41 +0300 Subject: [PATCH 06/10] Better check for env variables --- cvat-ui/src/core.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cvat-ui/src/core.ts b/cvat-ui/src/core.ts index 8f5b95163852..02e92a3d77f9 100644 --- a/cvat-ui/src/core.ts +++ b/cvat-ui/src/core.ts @@ -2,9 +2,12 @@ import _cvat from '../../cvat-core/src/api'; const cvat: any = _cvat; -const protocol = process.env.REACT_APP_API_PROTOCOL || 'http'; -const host = process.env.REACT_APP_API_HOST || 'localhost'; -const port = process.env.REACT_APP_API_PORT || '7000'; +const protocol = 'REACT_APP_API_PROTOCOL' in process.env + ? process.env.REACT_APP_API_PROTOCOL : 'http'; +const host = 'REACT_APP_API_HOST' in process.env + ? process.env.REACT_APP_API_HOST : 'localhost'; +const port = 'REACT_APP_API_PORT' in process.env + ? process.env.REACT_APP_API_PORT : '7000'; cvat.config.backendAPI = `${protocol}://${host}:${port}/api/v1`; From 7f672e6fc9977224cb5fabde400dd4987649bebd Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 13:39:13 +0300 Subject: [PATCH 07/10] Better check for env variables --- cvat-ui/src/core.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cvat-ui/src/core.ts b/cvat-ui/src/core.ts index 02e92a3d77f9..4395bd87ed83 100644 --- a/cvat-ui/src/core.ts +++ b/cvat-ui/src/core.ts @@ -2,12 +2,12 @@ import _cvat from '../../cvat-core/src/api'; const cvat: any = _cvat; -const protocol = 'REACT_APP_API_PROTOCOL' in process.env - ? process.env.REACT_APP_API_PROTOCOL : 'http'; -const host = 'REACT_APP_API_HOST' in process.env - ? process.env.REACT_APP_API_HOST : 'localhost'; -const port = 'REACT_APP_API_PORT' in process.env - ? process.env.REACT_APP_API_PORT : '7000'; +const protocol = typeof (process.env.REACT_APP_API_PROTOCOL) === 'undefined' + ? 'http' : process.env.REACT_APP_API_PROTOCOL; +const host = typeof (process.env.REACT_APP_API_HOST) === 'undefined' + ? 'http' : process.env.REACT_APP_API_HOST; +const port = typeof (process.env.REACT_APP_API_PORT) === 'undefined' + ? 'http' : process.env.REACT_APP_API_PORT; cvat.config.backendAPI = `${protocol}://${host}:${port}/api/v1`; From d3a10dfb0a6198e66105bf6a693dd1bfdb61d539 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 13:46:20 +0300 Subject: [PATCH 08/10] Reset state after showing --- cvat-ui/src/components/cvat-app.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 6d139b7c24a3..0639dd7101a6 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -100,7 +100,8 @@ export default class CVATApplication extends React.PureComponent { || !!tasks.fetching || !!tasks.updating || !!tasks.dumping || !!tasks.loading || !!tasks.exporting || !!tasks.deleting || !!tasks.creating || !!formats.fetching || !!users.fetching || !!share.fetching || !!models.creating || !!models.starting - || !!models.fetching || !!models.deleting || !!models.inferenceStatusFetching; + || !!models.fetching || !!models.deleting || !!models.inferenceStatusFetching + || !!models.metaFetching; if (auth.authorized) { showError('Could not check authorization on the server', auth.authorized); From adbbb203920e26bcfa69caadc19b8a975a6154da Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 13:59:13 +0300 Subject: [PATCH 09/10] Reset all state on logout --- cvat-ui/src/reducers/formats-reducer.ts | 6 ++++++ cvat-ui/src/reducers/models-reducer.ts | 6 ++++++ cvat-ui/src/reducers/notifications-reducer.ts | 5 +++++ cvat-ui/src/reducers/plugins-reducer.ts | 6 ++++++ cvat-ui/src/reducers/share-reducer.ts | 12 +++++++++++- cvat-ui/src/reducers/tasks-reducer.ts | 6 ++++++ cvat-ui/src/reducers/users-reducer.ts | 10 ++++++++-- 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/cvat-ui/src/reducers/formats-reducer.ts b/cvat-ui/src/reducers/formats-reducer.ts index 8eedb90acb35..01fa6e43d716 100644 --- a/cvat-ui/src/reducers/formats-reducer.ts +++ b/cvat-ui/src/reducers/formats-reducer.ts @@ -1,5 +1,6 @@ import { AnyAction } from 'redux'; import { FormatsActionTypes } from '../actions/formats-actions'; +import { AuthActionTypes } from '../actions/auth-actions'; import { FormatsState } from './interfaces'; @@ -33,6 +34,11 @@ export default (state = defaultState, action: AnyAction): FormatsState => { initialized: true, fetching: false, }; + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: return state; } diff --git a/cvat-ui/src/reducers/models-reducer.ts b/cvat-ui/src/reducers/models-reducer.ts index 8372c01f9643..8636b224ab5f 100644 --- a/cvat-ui/src/reducers/models-reducer.ts +++ b/cvat-ui/src/reducers/models-reducer.ts @@ -1,6 +1,7 @@ import { AnyAction } from 'redux'; import { ModelsActionTypes } from '../actions/models-actions'; +import { AuthActionTypes } from '../actions/auth-actions'; import { ModelsState } from './interfaces'; const defaultState: ModelsState = { @@ -106,6 +107,11 @@ export default function (state = defaultState, action: AnyAction): ModelsState { inferences, }; } + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: { return { ...state, diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts index e35a6cf0e5ce..30e9a11798b7 100644 --- a/cvat-ui/src/reducers/notifications-reducer.ts +++ b/cvat-ui/src/reducers/notifications-reducer.ts @@ -344,6 +344,11 @@ export default function (state = defaultState, action: AnyAction): Notifications }, }; } + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: { return { ...state, diff --git a/cvat-ui/src/reducers/plugins-reducer.ts b/cvat-ui/src/reducers/plugins-reducer.ts index 27913b9629ef..29290e18d456 100644 --- a/cvat-ui/src/reducers/plugins-reducer.ts +++ b/cvat-ui/src/reducers/plugins-reducer.ts @@ -1,6 +1,7 @@ import { AnyAction } from 'redux'; import { PluginsActionTypes } from '../actions/plugins-actions'; +import { AuthActionTypes } from '../actions/auth-actions'; import { registerGitPlugin } from '../utils/git-utils'; import { PluginsState, @@ -41,6 +42,11 @@ export default function (state = defaultState, action: AnyAction): PluginsState plugins, }; } + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: return { ...state }; } diff --git a/cvat-ui/src/reducers/share-reducer.ts b/cvat-ui/src/reducers/share-reducer.ts index b85ce5622d03..66a989f1970c 100644 --- a/cvat-ui/src/reducers/share-reducer.ts +++ b/cvat-ui/src/reducers/share-reducer.ts @@ -1,7 +1,12 @@ import { AnyAction } from 'redux'; import { ShareActionTypes } from '../actions/share-actions'; -import { ShareState, ShareFileInfo, ShareItem } from './interfaces'; +import { AuthActionTypes } from '../actions/auth-actions'; +import { + ShareState, + ShareFileInfo, + ShareItem, +} from './interfaces'; const defaultState: ShareState = { root: { @@ -38,6 +43,11 @@ export default function (state = defaultState, action: AnyAction): ShareState { ...state, }; } + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: return { ...state, diff --git a/cvat-ui/src/reducers/tasks-reducer.ts b/cvat-ui/src/reducers/tasks-reducer.ts index 4b1be0648728..0dc48fa64f69 100644 --- a/cvat-ui/src/reducers/tasks-reducer.ts +++ b/cvat-ui/src/reducers/tasks-reducer.ts @@ -1,5 +1,6 @@ import { AnyAction } from 'redux'; import { TasksActionTypes } from '../actions/tasks-actions'; +import { AuthActionTypes } from '../actions/auth-actions'; import { TasksState, Task } from './interfaces'; @@ -404,6 +405,11 @@ export default (state: TasksState = defaultState, action: AnyAction): TasksState }), }; } + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: return state; } diff --git a/cvat-ui/src/reducers/users-reducer.ts b/cvat-ui/src/reducers/users-reducer.ts index f86755a19ea6..b1f10d427427 100644 --- a/cvat-ui/src/reducers/users-reducer.ts +++ b/cvat-ui/src/reducers/users-reducer.ts @@ -1,15 +1,16 @@ import { AnyAction } from 'redux'; import { UsersState } from './interfaces'; +import { AuthActionTypes } from '../actions/auth-actions'; import { UsersActionTypes } from '../actions/users-actions'; -const initialState: UsersState = { +const defaultState: UsersState = { users: [], fetching: false, initialized: false, }; -export default function (state: UsersState = initialState, action: AnyAction): UsersState { +export default function (state: UsersState = defaultState, action: AnyAction): UsersState { switch (action.type) { case UsersActionTypes.GET_USERS: { return { @@ -31,6 +32,11 @@ export default function (state: UsersState = initialState, action: AnyAction): U fetching: false, initialized: true, }; + case AuthActionTypes.LOGOUT_SUCCESS: { + return { + ...defaultState, + } + } default: return { ...state, From 4ad58b33433a890598f2a3fce32df34d49dfc496 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 29 Nov 2019 14:49:23 +0300 Subject: [PATCH 10/10] Fixed default variables --- cvat-ui/src/core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cvat-ui/src/core.ts b/cvat-ui/src/core.ts index 4395bd87ed83..b1d987493ab0 100644 --- a/cvat-ui/src/core.ts +++ b/cvat-ui/src/core.ts @@ -5,9 +5,9 @@ const cvat: any = _cvat; const protocol = typeof (process.env.REACT_APP_API_PROTOCOL) === 'undefined' ? 'http' : process.env.REACT_APP_API_PROTOCOL; const host = typeof (process.env.REACT_APP_API_HOST) === 'undefined' - ? 'http' : process.env.REACT_APP_API_HOST; + ? 'localhost' : process.env.REACT_APP_API_HOST; const port = typeof (process.env.REACT_APP_API_PORT) === 'undefined' - ? 'http' : process.env.REACT_APP_API_PORT; + ? '7000' : process.env.REACT_APP_API_PORT; cvat.config.backendAPI = `${protocol}://${host}:${port}/api/v1`;