Skip to content

Commit

Permalink
updated implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Feb 13, 2025
1 parent 912721d commit bfe82ab
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 25 deletions.
41 changes: 41 additions & 0 deletions cvat-core/src/about.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import { SerializedAbout } from './server-response-types';

export default class AboutData {
#description: string;
#name: string;
#version: string;
#logoURL: string;
#subtitle: string;

constructor(initialData: SerializedAbout) {
this.#description = initialData.description;
this.#name = initialData.name;
this.#version = initialData.version;
this.#logoURL = initialData.logo_url;
this.#subtitle = initialData.subtitle;
}

get description(): string {
return this.#description;
}

get name(): string {
return this.#name;
}

get version(): string {
return this.#version;
}

get logoURL(): string {
return this.#logoURL;
}

get subtitle(): string {
return this.#subtitle;
}
}
3 changes: 2 additions & 1 deletion cvat-core/src/api-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
QualitySettingsFilter, SerializedAsset,
} from './server-response-types';
import QualityReport from './quality-report';
import AboutData from './about';
import QualityConflict, { ConflictSeverity } from './quality-conflict';
import QualitySettings from './quality-settings';
import { getFramesMeta } from './frames';
Expand Down Expand Up @@ -72,7 +73,7 @@ export default function implementAPI(cvat: CVATCore): CVATCore {

implementationMixin(cvat.server.about, async () => {
const result = await serverProxy.server.about();
return result;
return new AboutData(result);
});
implementationMixin(cvat.server.share, async (directory: string, searchPrefix?: string) => {
const result = await serverProxy.server.share(directory, searchPrefix);
Expand Down
3 changes: 2 additions & 1 deletion cvat-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import AnalyticsReport from './analytics-report';
import AnnotationGuide from './guide';
import { JobValidationLayout, TaskValidationLayout } from './validation-layout';
import { Request } from './request';
import AboutData from './about';
import {
runAction,
callAction,
Expand Down Expand Up @@ -61,7 +62,7 @@ export default interface CVATCore {
requests: typeof lambdaManager.requests;
};
server: {
about: typeof serverProxy.server.about;
about: () => Promise<AboutData>;
share: (dir: string) => Promise<{
mimeType: string;
name: string;
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/src/server-response-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export interface SerializedAbout {
description: string;
name: string;
version: string;
logo: string;
logo_url: string;
subtitle: string;
}

Expand Down
4 changes: 2 additions & 2 deletions cvat-ui/src/actions/about-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT

import { ActionUnion, createAction, ThunkAction } from 'utils/redux';
import { getCore } from 'cvat-core-wrapper';
import { AboutData, getCore } from 'cvat-core-wrapper';

const core = getCore();

Expand All @@ -15,7 +15,7 @@ export enum AboutActionTypes {

const aboutActions = {
getAbout: () => createAction(AboutActionTypes.GET_ABOUT),
getAboutSuccess: (server: any) => createAction(AboutActionTypes.GET_ABOUT_SUCCESS, { server }),
getAboutSuccess: (server: AboutData) => createAction(AboutActionTypes.GET_ABOUT_SUCCESS, { server }),
getAboutFailed: (error: any) => createAction(AboutActionTypes.GET_ABOUT_FAILED, { error }),
};

Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/src/components/common/cvat-logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useSelector } from 'react-redux';
import { CombinedState } from 'reducers';

function CVATLogo(): JSX.Element {
const logo = useSelector((state: CombinedState) => state.about.server.logo);
const logo = useSelector((state: CombinedState) => state.about.server.logoURL);

return (
<div className='cvat-logo-icon'>
Expand Down
2 changes: 2 additions & 0 deletions cvat-ui/src/cvat-core-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { BaseShapesAction } from 'cvat-core/src/annotations-actions/base-shapes-
import { BaseCollectionAction } from 'cvat-core/src/annotations-actions/base-collection-action';
import { ActionParameterType, BaseAction } from 'cvat-core/src/annotations-actions/base-action';
import { Request, RequestOperation } from 'cvat-core/src/request';
import AboutData from 'cvat-core/src/about';

const cvat: CVATCore = _cvat;

Expand Down Expand Up @@ -114,6 +115,7 @@ export {
JobValidationLayout,
TaskValidationLayout,
StorageLocation,
AboutData,
};

export type {
Expand Down
3 changes: 2 additions & 1 deletion cvat-ui/src/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Webhook, MLModel, Organization, Job, Task, Project, Label, User,
QualityConflict, FramesMetaData, RQStatus, Event, Invitation, SerializedAPISchema,
Request, JobValidationLayout, QualitySettings, TaskValidationLayout, ObjectState,
AboutData,
} from 'cvat-core-wrapper';
import { IntelligentScissors } from 'utils/opencv-wrapper/intelligent-scissors';
import { KeyMap, KeyMapItem } from 'utils/mousetrap-react';
Expand Down Expand Up @@ -336,7 +337,7 @@ export interface PluginsState {
}

export interface AboutState {
server: any;
server: AboutData;
packageVersion: {
ui: string;
};
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2627,7 +2627,7 @@ class AboutSerializer(serializers.Serializer):
name = serializers.CharField(max_length=128)
description = serializers.CharField(max_length=2048)
version = serializers.CharField(max_length=64)
logo = serializers.CharField()
logo_url = serializers.CharField()
subtitle = serializers.CharField(max_length=1024)

class FrameMetaSerializer(serializers.Serializer):
Expand Down
16 changes: 10 additions & 6 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
from django_rq.queues import DjangoRQ
from django.core.files.storage import storages
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import (
OpenApiExample,
Expand Down Expand Up @@ -189,9 +190,6 @@
_DATA_UPDATED_DATE_HEADER_NAME = 'X-Updated-Date'
_RETRY_AFTER_TIMEOUT = 10

def get_logo_uri(request) -> str:
return request.build_absolute_uri(f'{settings.STATIC_URL}{settings.LOGO_FILENAME}')

@extend_schema(tags=['server'])
class ServerViewSet(viewsets.ViewSet):
serializer_class = None
Expand All @@ -213,11 +211,17 @@ def get_serializer(self, *args, **kwargs):
def about(request):
from cvat import __version__ as cvat_version
about = {
"name": settings.ABOUT_INFO["name"],
"name": "Computer Vision Annotation Tool",
"subtitle": settings.ABOUT_INFO["subtitle"],
"description": settings.ABOUT_INFO["description"],
"description": "CVAT is completely re-designed and re-implemented " +
"version of Video Annotation Tool from Irvine, California " +
"tool. It is free, online, interactive video and image annotation " +
"tool for computer vision. It is being used by our team to " +
"annotate million of objects with different properties. Many UI " +
"and UX decisions are based on feedbacks from professional data " +
"annotation team.",
"version": cvat_version,
"logo": get_logo_uri(request),
"logo_url": request.build_absolute_uri(storages["staticfiles"].url(settings.LOGO_FILENAME)),
}
serializer = AboutSerializer(data=about)
if serializer.is_valid(raise_exception=True):
Expand Down
4 changes: 2 additions & 2 deletions cvat/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6905,14 +6905,14 @@ components:
version:
type: string
maxLength: 64
logo:
logo_url:
type: string
subtitle:
type: string
maxLength: 1024
required:
- description
- logo
- logo_url
- name
- subtitle
- version
Expand Down
10 changes: 1 addition & 9 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,15 +770,7 @@ class CVAT_QUEUES(Enum):
# Indicates the maximum number of days a file or directory is retained in the temporary directory
TMP_FILE_OR_DIR_RETENTION_DAYS = 3

LOGO_FILENAME = 'logo.png'
LOGO_FILENAME = 'logo.svg'
ABOUT_INFO = {
"name": "Computer Vision Annotation Tool",
"subtitle": "Open Data Annotation Platform",
"description": "CVAT is completely re-designed and re-implemented " +
"version of Video Annotation Tool from Irvine, California " +
"tool. It is free, online, interactive video and image annotation " +
"tool for computer vision. It is being used by our team to " +
"annotate million of objects with different properties. Many UI " +
"and UX decisions are based on feedbacks from professional data " +
"annotation team.",
}

0 comments on commit bfe82ab

Please sign in to comment.