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.

51 lines
1.0 KiB

  1. import "reflect-metadata"
  2. import { Expose, Type } from 'class-transformer'
  3. export class ExampleItem {
  4. id: number;
  5. text: string;
  6. meta: object;
  7. @Expose({ name: 'annotation_approver' })
  8. annotationApprover: boolean | null;
  9. @Expose({ name: 'comment_count' })
  10. commentCount: number;
  11. @Expose({ name: 'filename' })
  12. fileUrl: string;
  13. @Expose({ name: 'is_confirmed' })
  14. isConfirmed: boolean;
  15. get url() {
  16. const l = this.fileUrl.indexOf('media/')
  17. const r = this.fileUrl.indexOf('media/', l + 1)
  18. return this.fileUrl.slice(0, l) + this.fileUrl.slice(r)
  19. }
  20. get filename() {
  21. const items = this.fileUrl.split('/')
  22. return items[items.length - 1]
  23. }
  24. toObject(): Object {
  25. return {
  26. id: this.id,
  27. text: this.text,
  28. meta: this.meta,
  29. annotation_approver: this.annotationApprover,
  30. comment_count: this.commentCount
  31. }
  32. }
  33. }
  34. export class ExampleItemList {
  35. count: number;
  36. next: string | null;
  37. prev: string | null;
  38. @Type(() => ExampleItem)
  39. @Expose({ name: 'results' })
  40. items: ExampleItem[];
  41. }