1
1
<script lang="ts">
2
2
import {
3
3
defineComponent , ref , reactive , watch , toRefs ,
4
+ Ref ,
5
+ computed ,
4
6
} from ' vue' ;
5
7
import type { DataOptions } from ' vuetify' ;
6
- import { GirderModel , mixins } from ' @girder/components/src' ;
8
+ import {
9
+ GirderModel ,
10
+ mixins ,
11
+ GirderDataBrowser ,
12
+ GirderDataTable ,
13
+ } from ' @girder/components/src' ;
7
14
import { clientSettings } from ' dive-common/store/settings' ;
8
15
import { itemsPerPageOptions } from ' dive-common/constants' ;
9
- import { getDatasetList } from ' ../api' ;
10
- import { useStore , LocationType } from ' ../store/types' ;
16
+ import { getSharedWithMeFolders } from ' ../api' ;
17
+ import {
18
+ useStore , LocationState , RootlessLocationType ,
19
+ } from ' ../store/types' ;
20
+ import DataSharedBreadCrumb from ' ./DataSharedBreadCrumb.vue' ;
11
21
12
22
export default defineComponent ({
13
23
name: ' DataShared' ,
24
+ components: {
25
+ GirderDataBrowser ,
26
+ GirderDataTable ,
27
+ DataSharedBreadCrumb ,
28
+ },
14
29
setup() {
15
- const total = ref ();
30
+ const total = ref (0 );
31
+ const path: Ref <RootlessLocationType []> = ref ([]);
32
+
16
33
const dataList = ref ([] as GirderModel []);
17
34
const tableOptions = reactive ({
18
35
page: 1 ,
@@ -21,14 +38,8 @@ export default defineComponent({
21
38
} as DataOptions );
22
39
const store = useStore ();
23
40
const { getters } = store ;
24
- const locationStore = store .state .Location ;
25
-
26
- const headers = [
27
- { text: ' File Name' , value: ' name' },
28
- { text: ' ' , value: ' annotator' , sortable: false },
29
- { text: ' File Size' , value: ' formattedSize' },
30
- { text: ' Shared By' , value: ' ownerLogin' },
31
- ];
41
+ const locationStore: LocationState = store .state .Location ;
42
+ const localLocation = ref ();
32
43
33
44
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
45
const fixSize: any = mixins .sizeFormatter .methods ;
@@ -41,8 +52,8 @@ export default defineComponent({
41
52
const offset = (page - 1 ) * clientSettings .rowsPerPage ;
42
53
const sort = sortBy [0 ] || ' created' ;
43
54
const sortDir = sortDesc [0 ] === false ? 1 : - 1 ;
44
- const shared = true ;
45
- const response = await getDatasetList (limit , offset , sort , sortDir , shared );
55
+
56
+ const response = await getSharedWithMeFolders (limit , offset , sort , sortDir );
46
57
dataList .value = response .data ;
47
58
total .value = Number .parseInt (response .headers [' girder-total-count' ], 10 );
48
59
dataList .value .forEach ((element ) => {
@@ -51,14 +62,36 @@ export default defineComponent({
51
62
});
52
63
};
53
64
54
- function setLocation(location : LocationType ) {
55
- store .dispatch (' Location/setRouteFromLocation' , location );
65
+ function setLocation(location : RootlessLocationType ) {
66
+ localLocation .value = location ;
67
+ for (let i = 0 ; i < path .value .length ; i += 1 ) {
68
+ if (path .value [i ]._id === location ._id ) {
69
+ path .value = path .value .slice (0 , i + 1 );
70
+ return ;
71
+ }
72
+ }
73
+ path .value .push (location );
74
+ }
75
+
76
+ function resetLocation() {
77
+ path .value = [];
56
78
}
57
79
58
80
function isAnnotationFolder(item : GirderModel ) {
59
81
return item ._modelType === ' folder' && item .meta .annotate ;
60
82
}
61
83
84
+ const rows = computed (() => dataList .value .map ((item ) => ({
85
+ ... item ,
86
+ humanSize: fixSize .formatSize (item .size ),
87
+ icon: item .public ? ' folder' : ' folderNonPublic' ,
88
+ })));
89
+
90
+ const options = ref ({
91
+ itemsPerPage: clientSettings .rowsPerPage ,
92
+ page: 1 ,
93
+ });
94
+
62
95
watch (tableOptions , updateOptions , {
63
96
deep: true ,
64
97
});
@@ -67,42 +100,124 @@ export default defineComponent({
67
100
updateOptions ();
68
101
return {
69
102
isAnnotationFolder ,
70
- dataList ,
71
103
getters ,
72
- updateOptions ,
73
104
setLocation ,
105
+ resetLocation ,
106
+ rows ,
74
107
total ,
75
108
locationStore ,
76
109
clientSettings ,
77
110
itemsPerPageOptions ,
111
+ options ,
112
+ notSharedLocation: localLocation ,
78
113
... toRefs (tableOptions ),
79
- headers ,
114
+ path ,
80
115
};
81
116
},
82
117
});
83
118
84
119
</script >
85
120
86
121
<template >
87
- <v-data-table
122
+ <v-card v-if =" rows.length === 0" >
123
+ <div class =" no-shared" >
124
+ <span class =" pr-4" >No datasets have been shared with you yet.</span >
125
+ <a href =" https://kitware.github.io/dive/Web-Version/#sharing-data-with-teams" >Learn more about sharing</a >
126
+ </div >
127
+ </v-card >
128
+ <girder-data-table
129
+ v-else-if =" path.length === 0"
130
+ @rowclick =" setLocation"
88
131
v-model =" locationStore.selected"
89
132
:selectable =" !getters['Location/locationIsViameFolder']"
90
- :location =" locationStore.location"
91
- :headers =" headers"
92
- :page.sync =" page"
93
- :items-per-page.sync =" clientSettings.rowsPerPage"
94
- :sort-by.sync =" sortBy"
95
- :sort-desc.sync =" sortDesc"
96
133
:server-items-length =" total"
97
- :items =" dataList"
98
- :footer-props =" { itemsPerPageOptions }"
134
+ :items-per-page-options =" itemsPerPageOptions"
135
+ :options =" options"
136
+ :loading =" false"
99
137
item-key =" _id"
100
138
show-select
101
- @input =" $emit('input', $event)"
102
- @update:location =" setLocation"
139
+ :rows =" rows" >
140
+ <template #header =" { props , on } " >
141
+ <thead >
142
+ <tr
143
+ :class =" $vuetify.theme.dark ? 'darken-2' : 'lighten-5'"
144
+ class =" secondary"
145
+ >
146
+ <th class =" pl-3 pr-0" width =" 1%" >
147
+ <v-checkbox
148
+ :input-value =" props.everyItem"
149
+ class =" pr-2"
150
+ color =" accent"
151
+ hide-details =" hide-details"
152
+ @click.native =" on['toggle-select-all'](!props.everyItem)"
153
+ />
154
+ </th >
155
+ <th
156
+ class =" pl-3"
157
+ colspan =" 10"
158
+ width =" 99%"
159
+ >
160
+ <v-row class =" ma-1" >
161
+ <data-shared-bread-crumb
162
+ :path =" path"
163
+ :location =" notSharedLocation"
164
+ @folder-click =" setLocation"
165
+ @shared-click =" resetLocation" />
166
+ <v-spacer />
167
+ </v-row >
168
+ </th >
169
+ </tr >
170
+ </thead >
171
+ </template >
172
+ <template #row =" { item } " >
173
+ <span class =" row-content" >
174
+ <span >{{ item.name }}</span >
175
+ <v-icon
176
+ v-if =" getters['Jobs/datasetRunningState'](item._id)"
177
+ color =" warning"
178
+ class =" rotate"
179
+ >
180
+ mdi-autorenew
181
+ </v-icon >
182
+ <v-btn
183
+ v-if =" isAnnotationFolder(item)"
184
+ class =" ml-2"
185
+ x-small
186
+ color =" primary"
187
+ depressed
188
+ :to =" { name: 'viewer', params: { id: item._id } }"
189
+ >
190
+ Launch Annotator
191
+ </v-btn >
192
+ <span class =" owner-text" >Shared by {{ item.ownerLogin }}</span >
193
+ </span >
194
+ </template >
195
+ </girder-data-table >
196
+ <girder-data-browser
197
+ v-else
198
+ v-model =" locationStore.selected"
199
+ :selectable =" !getters['Location/locationIsViameFolder']"
200
+ :location =" notSharedLocation"
201
+ :items-per-page-options =" itemsPerPageOptions"
202
+ :options =" options"
203
+ @update:location =" setLocation($event)"
103
204
>
104
- <!-- eslint-disable-next-line -->
105
- <template v-slot :item .annotator =" {item } " >
205
+ <template #breadcrumb >
206
+ <data-shared-bread-crumb
207
+ :path =" path"
208
+ :location =" notSharedLocation"
209
+ @folder-click =" setLocation"
210
+ @shared-click =" resetLocation" />
211
+ </template >
212
+ <template #row =" { item } " >
213
+ <span >{{ item.name }}</span >
214
+ <v-icon
215
+ v-if =" getters['Jobs/datasetRunningState'](item._id)"
216
+ color =" warning"
217
+ class =" rotate"
218
+ >
219
+ mdi-autorenew
220
+ </v-icon >
106
221
<v-btn
107
222
v-if =" isAnnotationFolder(item)"
108
223
class =" ml-2"
@@ -114,9 +229,20 @@ export default defineComponent({
114
229
Launch Annotator
115
230
</v-btn >
116
231
</template >
117
- <template #no-data >
118
- <span class =" pr-4" >No datasets have been shared with you yet.</span >
119
- <a href =" https://kitware.github.io/dive/Web-Version/#sharing-data-with-teams" >Learn more about sharing</a >
120
- </template >
121
- </v-data-table >
232
+ </girder-data-browser >
122
233
</template >
234
+
235
+ <style lang="scss" scoped>
236
+ .row-content {
237
+ display : inline-block ;
238
+ width : 81% ;
239
+
240
+ .owner-text {
241
+ float : right ;
242
+ }
243
+ }
244
+
245
+ .no-shared {
246
+ padding : 20px ;
247
+ }
248
+ </style >
0 commit comments