Browse Source

Add fields to document model

pull/1370/head
Hironsan 4 years ago
parent
commit
9616f60085
5 changed files with 30 additions and 16 deletions
  1. 9
      frontend/components/image/ImageList.vue
  2. 13
      frontend/domain/models/document/document.ts
  3. 4
      frontend/pages/projects/_id/image-classification/index.vue
  4. 2
      frontend/services/application/document/documentApplicationService.ts
  5. 18
      frontend/services/application/document/documentData.ts

9
frontend/components/image/ImageList.vue

@ -29,9 +29,9 @@
filled filled
/> />
</template> </template>
<template v-slot:[`item.filename`]="{ item }">
<template v-slot:[`item.url`]="{ item }">
<v-img <v-img
:src="item.filename"
:src="item.url"
aspect-ratio="1" aspect-ratio="1"
height="150" height="150"
max-height="150" max-height="150"
@ -98,6 +98,11 @@ export default Vue.extend({
return [ return [
{ {
text: 'Image', text: 'Image',
value: 'url',
sortable: false
},
{
text: 'Filename',
value: 'filename', value: 'filename',
sortable: false sortable: false
}, },

13
frontend/domain/models/document/document.ts

@ -48,7 +48,7 @@ export class DocumentItem {
public meta: object, public meta: object,
public annotationApprover: boolean | null, public annotationApprover: boolean | null,
public commentCount: number, public commentCount: number,
public filename: string,
public fileUrl: string,
) {} ) {}
static valueOf( static valueOf(
@ -59,9 +59,14 @@ export class DocumentItem {
} }
get url() { get url() {
const l = this.filename.indexOf('media/')
const r = this.filename.indexOf('media/', l + 1)
return this.filename.slice(0, l) + this.filename.slice(r)
const l = this.fileUrl.indexOf('media/')
const r = this.fileUrl.indexOf('media/', l + 1)
return this.fileUrl.slice(0, l) + this.fileUrl.slice(r)
}
get filename() {
const items = this.fileUrl.split('/')
return items[items.length - 1]
} }
toObject(): Object { toObject(): Object {

4
frontend/pages/projects/_id/image-classification/index.vue

@ -56,7 +56,7 @@
<v-divider /> <v-divider />
<v-img <v-img
contain contain
:src="doc.filename"
:src="doc.url"
:max-height="imageSize.height" :max-height="imageSize.height"
class="grey lighten-2" class="grey lighten-2"
/> />
@ -201,7 +201,7 @@ export default {
self.imageSize.height = this.height self.imageSize.height = this.height
self.imageSize.width = this.width self.imageSize.width = this.width
} }
img.src = val.filename
img.src = val.url
} }
}, },

2
frontend/services/application/document/documentApplicationService.ts

@ -83,7 +83,7 @@ export class DocumentApplicationService {
item.meta, item.meta,
item.annotationApprover, item.annotationApprover,
item.commentCount, item.commentCount,
item.filename
item.fileUrl
) )
} }
} }

18
frontend/services/application/document/documentData.ts

@ -8,16 +8,20 @@ export class DocumentDTO {
annotationApprover: boolean | null; annotationApprover: boolean | null;
commentCount: number; commentCount: number;
isApproved: boolean; isApproved: boolean;
fileUrl: string;
filename: string; filename: string;
url: string;
constructor(item: DocumentItem) { constructor(item: DocumentItem) {
this.id = item.id;
this.text = item.text;
this.meta = item.meta;
this.annotationApprover = item.annotationApprover;
this.commentCount = item.commentCount;
this.isApproved = !!item.annotationApprover;
this.filename = item.url
this.id = item.id
this.text = item.text
this.meta = item.meta
this.annotationApprover = item.annotationApprover
this.commentCount = item.commentCount
this.isApproved = !!item.annotationApprover
this.fileUrl = item.fileUrl
this.filename = item.filename
this.url = item.url
} }
} }

Loading…
Cancel
Save