-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Markdown documentation for tasks/projects (#6191)
<!-- Raise an issue to propose your change (https://github.com/opencv/cvat/issues). It helps to avoid duplication of efforts from multiple independent contributors. Discuss your ideas with maintainers to be sure that changes will be approved and merged. Read the [Contribution guide](https://opencv.github.io/cvat/docs/contributing/). --> <!-- Provide a general summary of your changes in the Title above --> ### Motivation and context <img width="1130" alt="image" src="https://github.com/opencv/cvat/assets/40690378/3c1b767d-2aa2-474b-af1e-1fc02d8c359d"> <img width="1133" alt="image" src="https://github.com/opencv/cvat/assets/40690378/fdf6115a-e88d-4da6-83fb-c9fddd871e49"> <img width="1920" alt="image" src="https://github.com/opencv/cvat/assets/40690378/f6e97db5-84cb-4c1e-9b2a-82eca633a79c"> Resolved #287 Resolved #3680 Resolved #5580 ### How has this been tested? <!-- Please describe in detail how you tested your changes. Include details of your testing environment, and the tests you ran to see how your change affects other areas of the code, etc. --> ### Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. If an item isn't applicable for some reason, then ~~explicitly strikethrough~~ the whole line. If you don't do that, GitHub will show incorrect progress for the pull request. If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I submit my changes into the `develop` branch - [x] I have added a description of my changes into the [CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md) file - [ ] I have updated the documentation accordingly - [ ] I have added tests to cover my changes - [x] I have linked related issues (see [GitHub docs]( https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)) - [x] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning), [cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning)) ### License - [x] I submit _my code changes_ under the same [MIT License]( https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern.
- Loading branch information
Showing
63 changed files
with
2,862 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (C) 2023 CVAT.ai Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { SerializedGuide } from './server-response-types'; | ||
import { ArgumentError, DataError } from './exceptions'; | ||
import PluginRegistry from './plugins'; | ||
import serverProxy from './server-proxy'; | ||
|
||
class AnnotationGuide { | ||
#id: AnnotationGuide['id']; | ||
#taskId: AnnotationGuide['taskId']; | ||
#projectId: AnnotationGuide['projectId']; | ||
#createdDate?: AnnotationGuide['createdDate']; | ||
#updatedDate?: AnnotationGuide['updatedDate']; | ||
#markdown: AnnotationGuide['markdown']; | ||
|
||
constructor(initialData: Partial<SerializedGuide>) { | ||
this.#id = initialData.id; | ||
this.#taskId = initialData.task_id || null; | ||
this.#projectId = initialData.project_id || null; | ||
this.#createdDate = initialData.created_date; | ||
this.#updatedDate = initialData.updated_date; | ||
this.#markdown = initialData.markdown || ''; | ||
} | ||
|
||
public get id(): number | undefined { | ||
return this.#id; | ||
} | ||
|
||
public get taskId(): number | null { | ||
return this.#taskId; | ||
} | ||
|
||
public get projectId(): number | null { | ||
return this.#projectId; | ||
} | ||
|
||
public get createdDate(): string | undefined { | ||
return this.#createdDate; | ||
} | ||
|
||
public get updatedDate(): string | undefined { | ||
return this.#updatedDate; | ||
} | ||
|
||
public get markdown(): string { | ||
return this.#markdown; | ||
} | ||
|
||
public set markdown(value: string) { | ||
if (typeof value !== 'string') { | ||
throw new ArgumentError(`Markdown value must be a string, ${typeof value} received`); | ||
} | ||
this.#markdown = value; | ||
} | ||
|
||
async save(): Promise<AnnotationGuide> { | ||
const result = await PluginRegistry.apiWrapper.call(this, AnnotationGuide.prototype.save); | ||
return result; | ||
} | ||
} | ||
|
||
Object.defineProperties(AnnotationGuide.prototype.save, { | ||
implementation: { | ||
writable: false, | ||
enumerable: false, | ||
value: async function implementation(this: AnnotationGuide) { | ||
if (Number.isInteger(this.id)) { | ||
const result = await serverProxy.guides.update(this.id, { markdown: this.markdown }); | ||
return new AnnotationGuide(result); | ||
} | ||
|
||
if (this.projectId === null && this.taskId === null) { | ||
throw new DataError('One of projectId or taskId must be specified for a guide'); | ||
} | ||
|
||
if (this.projectId !== null && this.taskId !== null) { | ||
throw new DataError('Both projectId and taskId must not be presented for a guide'); | ||
} | ||
|
||
const result = await serverProxy.guides.create({ | ||
task_id: this.taskId, | ||
project_id: this.projectId, | ||
markdown: this.markdown, | ||
}); | ||
return new AnnotationGuide(result); | ||
}, | ||
}, | ||
}); | ||
|
||
export default AnnotationGuide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.