Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add about CVAT #1024

Merged
merged 9 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions cvat-ui/src/actions/about-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { AnyAction, Dispatch, ActionCreator } from 'redux';
import { ThunkAction } from 'redux-thunk';

import getCore from '../core';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module was renamed in the latest patch.
So, it should be

 import getCore from 'cvat-core'; 

It's a reason why UI doesn't work in your patch.


const core = getCore();

export enum AboutActionTypes {
GET_ABOUT = 'GET_ABOUT',
GET_ABOUT_SUCCESS = 'GET_ABOUT_SUCCESS',
GET_ABOUT_FAILED = 'GET_ABOUT_FAILED',
}

function getAbout(): AnyAction {
const action = {
type: AboutActionTypes.GET_ABOUT,
payload: {},
};

return action;
}

function getAboutSuccess(about: any): AnyAction {
const action = {
type: AboutActionTypes.GET_ABOUT_SUCCESS,
payload: { about },
};

return action;
}

function getAboutFailed(error: any): AnyAction {
const action = {
type: AboutActionTypes.GET_ABOUT_FAILED,
payload: { error },
};

return action;
}

export function getAboutAsync():
ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
dispatch(getAbout());

try {
const about = await core.server.about();
dispatch(
getAboutSuccess(about),
);
} catch (error) {
dispatch(getAboutFailed(error));
}
};
}
55 changes: 55 additions & 0 deletions cvat-ui/src/actions/serverInfo-actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { AnyAction, Dispatch, ActionCreator } from 'redux';
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
LiSa20120 marked this conversation as resolved.
Show resolved Hide resolved
import { ThunkAction } from 'redux-thunk';

import getCore from '../core';

const core = getCore();

export enum ServerInfoActionTypes {
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
GET_SERVER_INFO = 'GET_SERVER_INFO',
GET_SERVER_INFO_SUCCESS = 'GET_SERVER_INFO_SUCCESS',
GET_SERVER_INFO_FAILED = 'GET_SERVER_INFO_FAILED',
}

function getServerInfo(): AnyAction {
const action = {
type: ServerInfoActionTypes.GET_SERVER_INFO,
payload: {},
};

return action;
}

function getServerInfoSuccess(serverInfo: string): AnyAction {
const action = {
type: ServerInfoActionTypes.GET_SERVER_INFO_SUCCESS,
payload: { serverInfo },
};

return action;
}

function getServerInfoFailed(error: any): AnyAction {
const action = {
type: ServerInfoActionTypes.GET_SERVER_INFO_FAILED,
payload: { error },
};

return action;
}

export function getServerInfoAsync():
ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
dispatch(getServerInfo());

try {
const about = await core.server.about();
dispatch(
getServerInfoSuccess(about),
);
} catch (error) {
dispatch(getServerInfoFailed(error));
}
};
}
20 changes: 18 additions & 2 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { NotificationsState } from '../reducers/interfaces';
type CVATAppProps = {
loadFormats: () => void;
loadUsers: () => void;
loadAbout: () => void;
verifyAuthorized: () => void;
initPlugins: () => void;
resetErrors: () => void;
Expand All @@ -39,11 +40,14 @@ type CVATAppProps = {
formatsFetching: boolean;
usersInitialized: boolean;
usersFetching: boolean;
aboutInitialized: boolean;
aboutFetching: boolean;
installedAutoAnnotation: boolean;
installedTFAnnotation: boolean;
installedTFSegmentation: boolean;
notifications: NotificationsState;
user: any;
about: any;
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
};

export default class CVATApplication extends React.PureComponent<CVATAppProps> {
Expand All @@ -56,12 +60,15 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
const {
loadFormats,
loadUsers,
loadAbout,
initPlugins,
userInitialized,
formatsInitialized,
formatsFetching,
usersInitialized,
usersFetching,
aboutInitialized,
aboutFetching,
pluginsInitialized,
pluginsFetching,
user,
Expand All @@ -83,6 +90,10 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
loadUsers();
}

if (!aboutInitialized && !aboutFetching) {
loadAbout();
}

if (!pluginsInitialized && !pluginsFetching) {
initPlugins();
}
Expand Down Expand Up @@ -152,13 +163,14 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
const { tasks } = notifications.errors;
const { formats } = notifications.errors;
const { users } = notifications.errors;
const { about } = notifications.errors;
const { share } = notifications.errors;
const { models } = notifications.errors;

const shown = !!auth.authorized || !!auth.login || !!auth.logout || !!auth.register
|| !!tasks.fetching || !!tasks.updating || !!tasks.dumping || !!tasks.loading
|| !!tasks.exporting || !!tasks.deleting || !!tasks.creating || !!formats.fetching
|| !!users.fetching || !!share.fetching || !!models.creating || !!models.starting
|| !!users.fetching || !!about.fetching || !!share.fetching || !!models.creating || !!models.starting
|| !!models.fetching || !!models.deleting || !!models.inferenceStatusFetching
|| !!models.metaFetching;

Expand Down Expand Up @@ -201,6 +213,9 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
if (users.fetching) {
showError(users.fetching.message, users.fetching.reason);
}
if (about.fetching) {
showError(about.fetching.message, about.fetching.reason);
}
if (share.fetching) {
showError(share.fetching.message, share.fetching.reason);
}
Expand Down Expand Up @@ -236,6 +251,7 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {
const {
userInitialized,
usersInitialized,
aboutInitialized,
pluginsInitialized,
formatsInitialized,
installedAutoAnnotation,
Expand All @@ -246,7 +262,7 @@ export default class CVATApplication extends React.PureComponent<CVATAppProps> {

const readyForRender = (userInitialized && user == null)
|| (userInitialized && formatsInitialized
&& pluginsInitialized && usersInitialized);
&& pluginsInitialized && usersInitialized && aboutInitialized);

const withModels = installedAutoAnnotation
|| installedTFAnnotation || installedTFSegmentation;
Expand Down
55 changes: 54 additions & 1 deletion cvat-ui/src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ import React from 'react';

import { RouteComponentProps } from 'react-router';
import { withRouter } from 'react-router-dom';
import {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need this import, right?

BrowserRouter as Router,
Link,
Switch,
Route,
} from "react-router-dom";
LiSa20120 marked this conversation as resolved.
Show resolved Hide resolved


import {
Layout,
Icon,
Button,
Menu,
Dropdown,
Modal,
Row,
Col,
} from 'antd';

import Text from 'antd/lib/typography/Text';
Expand All @@ -31,6 +41,7 @@ interface HeaderContainerProps {
installedTFAnnotation: boolean;
installedTFSegmentation: boolean;
username: string;
about: any;
}

type Props = HeaderContainerProps & RouteComponentProps;
Expand All @@ -42,6 +53,7 @@ function HeaderContainer(props: Props): JSX.Element {
installedTFAnnotation,
installedAnalytics,
username,
about,
onLogout,
logoutFetching,
} = props;
Expand All @@ -50,13 +62,54 @@ function HeaderContainer(props: Props): JSX.Element {
|| installedTFAnnotation
|| installedTFSegmentation;

function aboutModal() {
Modal.info({
title: `${about.name}`,
content: (
<div>
<p>
{`${about.description}`}
</p>
<p>
<Text strong>
Server version:
</Text>
<Text type='secondary'>
{` ${about.version}`}
</Text>
</p>
<p>
<Text strong>
Client version:
</Text>
<Text type='secondary'>
{` ${core.client.version}`}
</Text>
</p>
<Row type='flex' justify='space-around'>
<Col span={4}><a href= 'https://github.com/opencv/cvat/blob/develop/CHANGELOG.md' target='_blank' rel="noopener noreferrer" >What's new?</a></Col>
<Col span={4}><a href='https://github.com/opencv/cvat/blob/develop/LICENSE' target='_blank' rel="noopener noreferrer" >License</a></Col>
<Col span={4}><a href='https://gitter.im/opencv-cvat' target='_blank' rel="noopener noreferrer" >Need help?</a></Col>
<Col span={4}><a href='https://software.intel.com/en-us/forums/intel-distribution-of-openvino-toolkit' target='_blank' rel="noopener noreferrer" >Forum on Intel Developer Zone</a></Col>
LiSa20120 marked this conversation as resolved.
Show resolved Hide resolved
</Row>
</div>
),
width : 800,
okButtonProps: {
style: {
width: '100px',
},
},
})
}

const menu = (
<Menu className='cvat-header-menu' mode='vertical'>
<Menu.Item>
<Icon type='setting' />
Settings
</Menu.Item>
<Menu.Item>
<Menu.Item onClick={() => aboutModal()}>
<Icon type='info-circle' />
About
</Menu.Item>
Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/containers/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface StateToProps {
installedTFSegmentation: boolean;
installedTFAnnotation: boolean;
username: string;
about: any;
}

interface DispatchToProps {
Expand All @@ -25,13 +26,15 @@ interface DispatchToProps {
function mapStateToProps(state: CombinedState): StateToProps {
const { auth } = state;
const { plugins } = state.plugins;
const { about } = state.about;
return {
logoutFetching: state.auth.fetching,
installedAnalytics: plugins[SupportedPlugins.ANALYTICS],
installedAutoAnnotation: plugins[SupportedPlugins.AUTO_ANNOTATION],
installedTFSegmentation: plugins[SupportedPlugins.TF_SEGMENTATION],
installedTFAnnotation: plugins[SupportedPlugins.TF_ANNOTATION],
username: auth.user.username,
about: about,
};
}

Expand Down
10 changes: 10 additions & 0 deletions cvat-ui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { authorizedAsync } from './actions/auth-actions';
import { getFormatsAsync } from './actions/formats-actions';
import { checkPluginsAsync } from './actions/plugins-actions';
import { getUsersAsync } from './actions/users-actions';
import { getAboutAsync } from './actions/about-actions';
import {
resetErrors,
resetMessages,
Expand All @@ -30,19 +31,23 @@ interface StateToProps {
userInitialized: boolean;
usersInitialized: boolean;
usersFetching: boolean;
aboutInitialized: boolean;
aboutFetching: boolean;
formatsInitialized: boolean;
formatsFetching: boolean;
installedAutoAnnotation: boolean;
installedTFSegmentation: boolean;
installedTFAnnotation: boolean;
notifications: NotificationsState;
user: any;
about: any;
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
}

interface DispatchToProps {
loadFormats: () => void;
verifyAuthorized: () => void;
loadUsers: () => void;
loadAbout: () => void;
initPlugins: () => void;
resetErrors: () => void;
resetMessages: () => void;
Expand All @@ -53,20 +58,24 @@ function mapStateToProps(state: CombinedState): StateToProps {
const { auth } = state;
const { formats } = state;
const { users } = state;
const { about } = state;

return {
userInitialized: auth.initialized,
pluginsInitialized: plugins.initialized,
pluginsFetching: plugins.fetching,
usersInitialized: users.initialized,
usersFetching: users.fetching,
aboutInitialized: about.initialized,
aboutFetching: about.fetching,
formatsInitialized: formats.initialized,
formatsFetching: formats.fetching,
installedAutoAnnotation: plugins.plugins.AUTO_ANNOTATION,
installedTFSegmentation: plugins.plugins.TF_SEGMENTATION,
installedTFAnnotation: plugins.plugins.TF_ANNOTATION,
notifications: { ...state.notifications },
user: auth.user,
about: state.about,
};
}

Expand All @@ -76,6 +85,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps {
verifyAuthorized: (): void => dispatch(authorizedAsync()),
initPlugins: (): void => dispatch(checkPluginsAsync()),
loadUsers: (): void => dispatch(getUsersAsync()),
loadAbout: (): void => dispatch(getAboutAsync()),
resetErrors: (): void => dispatch(resetErrors()),
resetMessages: (): void => dispatch(resetMessages()),
};
Expand Down
Loading