@@ -40,14 +40,29 @@ qx.Class.define("osparc.file.TreeFolderView", {
40
40
_createChildControlImpl : function ( id ) {
41
41
let control ;
42
42
switch ( id ) {
43
+ case "header-layout" :
44
+ control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( ) ) . set ( {
45
+ marginLeft : 8
46
+ } ) ;
47
+ this . _addAt ( control , 0 ) ;
48
+ break ;
43
49
case "reload-button" :
44
50
control = new qx . ui . form . Button ( ) . set ( {
45
51
label : this . tr ( "Reload" ) ,
46
52
font : "text-14" ,
47
53
icon : "@FontAwesome5Solid/sync-alt/14" ,
48
54
allowGrowX : false
49
55
} ) ;
50
- this . _add ( control ) ;
56
+ this . getChildControl ( "header-layout" ) . add ( control ) ;
57
+ break ;
58
+ case "total-size-label" :
59
+ control = new qx . ui . basic . Atom ( ) . set ( {
60
+ label : this . tr ( "Calculating Size" ) ,
61
+ font : "text-14" ,
62
+ icon : "@FontAwesome5Solid/spinner/14" ,
63
+ allowGrowX : false
64
+ } ) ;
65
+ this . getChildControl ( "header-layout" ) . add ( control ) ;
51
66
break ;
52
67
case "tree-folder-layout" :
53
68
control = new qx . ui . splitpane . Pane ( "horizontal" ) ;
@@ -80,7 +95,6 @@ qx.Class.define("osparc.file.TreeFolderView", {
80
95
} ,
81
96
82
97
__buildLayout : function ( ) {
83
- this . getChildControl ( "reload-button" ) ;
84
98
const folderTree = this . getChildControl ( "folder-tree" ) ;
85
99
const folderViewer = this . getChildControl ( "folder-viewer" ) ;
86
100
@@ -146,6 +160,33 @@ qx.Class.define("osparc.file.TreeFolderView", {
146
160
} else {
147
161
folderViewer . resetFolder ( ) ;
148
162
}
163
+ } ,
164
+
165
+ requestSize : function ( pathId ) {
166
+ const totalSize = this . getChildControl ( "total-size-label" ) ;
167
+ totalSize . getChildControl ( "icon" ) . getContentElement ( ) . addClass ( "rotate" ) ;
168
+
169
+ osparc . data . Resources . fetch ( "storagePaths" , "requestSize" , { url : { pathId } } )
170
+ . then ( resp => {
171
+ const jobId = resp [ "job_id" ] ;
172
+ if ( jobId ) {
173
+ const asyncJob = new osparc . file . StorageAsyncJob ( jobId ) ;
174
+ asyncJob . addListener ( "resultReceived" , e => {
175
+ const size = e . getData ( ) ;
176
+ totalSize . set ( {
177
+ icon : null ,
178
+ label : this . tr ( "Total size: " ) + osparc . utils . Utils . bytesToSize ( size ) ,
179
+ } ) ;
180
+ } ) ;
181
+ asyncJob . addListener ( "pollingError" , e => {
182
+ totalSize . hide ( ) ;
183
+ } ) ;
184
+ }
185
+ } )
186
+ . catch ( err => {
187
+ console . error ( err ) ;
188
+ totalSize . hide ( ) ;
189
+ } ) ;
149
190
}
150
191
}
151
192
} ) ;
0 commit comments