You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.2 KiB

  1. export interface CurrentUsersRole {
  2. is_project_admin: boolean;
  3. is_annotator: boolean;
  4. is_annotation_approver: boolean;
  5. }
  6. export type ProjectType = 'DocumentClassification' | 'SequenceLabeling' | 'Seq2seq'
  7. export class ProjectReadItem {
  8. constructor(
  9. public id: number,
  10. public name: string,
  11. public description: string,
  12. public guideline: string,
  13. public users: number[],
  14. public current_users_role: CurrentUsersRole,
  15. public project_type: ProjectType,
  16. public updated_at: string,
  17. public randomize_document_order: boolean,
  18. public collaborative_annotation: boolean,
  19. public single_class_classification: boolean,
  20. public resourcetype: string,
  21. ) {}
  22. static valueOf(
  23. {
  24. id,
  25. name,
  26. description,
  27. guideline,
  28. users,
  29. current_users_role,
  30. project_type,
  31. updated_at,
  32. randomize_document_order,
  33. collaborative_annotation,
  34. single_class_classification,
  35. resourcetype
  36. }:
  37. {
  38. id: number,
  39. name: string,
  40. description: string,
  41. guideline: string,
  42. users: number[],
  43. current_users_role: CurrentUsersRole,
  44. project_type: ProjectType,
  45. updated_at: string,
  46. randomize_document_order: boolean,
  47. collaborative_annotation: boolean,
  48. single_class_classification: boolean,
  49. resourcetype: string
  50. }
  51. ): ProjectReadItem {
  52. return new ProjectReadItem(
  53. id,
  54. name,
  55. description,
  56. guideline,
  57. users,
  58. current_users_role,
  59. project_type,
  60. updated_at,
  61. randomize_document_order,
  62. collaborative_annotation,
  63. single_class_classification,
  64. resourcetype
  65. )
  66. }
  67. toObject(): Object {
  68. return {
  69. id: this.id,
  70. name: this.name,
  71. description: this.description,
  72. guideline: this.guideline,
  73. users: this.users,
  74. current_users_role: this.current_users_role,
  75. project_type: this.project_type,
  76. updated_at: this.updated_at,
  77. randomize_document_order: this.randomize_document_order,
  78. collaborative_annotation: this.collaborative_annotation,
  79. single_class_classification: this.single_class_classification,
  80. resourcetype: this.resourcetype
  81. }
  82. }
  83. }
  84. export class ProjectWriteItem {
  85. constructor(
  86. public id: number,
  87. public name: string,
  88. public description: string,
  89. public guideline: string,
  90. public project_type: ProjectType,
  91. public randomize_document_order: boolean,
  92. public collaborative_annotation: boolean
  93. ) {}
  94. static valueOf(
  95. {
  96. id,
  97. name,
  98. description,
  99. guideline,
  100. project_type,
  101. randomize_document_order,
  102. collaborative_annotation,
  103. }:
  104. {
  105. id: number,
  106. name: string,
  107. description: string,
  108. guideline: string,
  109. project_type: ProjectType,
  110. randomize_document_order: boolean,
  111. collaborative_annotation: boolean
  112. }
  113. ): ProjectWriteItem {
  114. return new ProjectWriteItem(
  115. id,
  116. name,
  117. description,
  118. guideline,
  119. project_type,
  120. randomize_document_order,
  121. collaborative_annotation,
  122. )
  123. }
  124. get resourceType(): string {
  125. const mapping = {
  126. DocumentClassification: 'TextClassificationProject',
  127. SequenceLabeling : 'SequenceLabelingProject',
  128. Seq2seq : 'Seq2seqProject'
  129. }
  130. return mapping[this.project_type]
  131. }
  132. toObject(): Object {
  133. return {
  134. id: this.id,
  135. name: this.name,
  136. description: this.description,
  137. guideline: this.guideline,
  138. project_type: this.project_type,
  139. randomize_document_order: this.randomize_document_order,
  140. collaborative_annotation: this.collaborative_annotation,
  141. resourcetype: this.resourceType
  142. }
  143. }
  144. }