@@ -174,11 +174,12 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
174174 } ,
175175
176176 __retrieveURLAndDownloadPaths : function ( paths ) {
177- const locationId = 0 ;
178- osparc . store . Data . getInstance ( ) . retrieveURLAndDownload ( locationId , paths )
179- . then ( data => {
180- console . log ( "data" , data ) ;
181- } ) ;
177+ const dataStore = osparc . store . Data . getInstance ( ) ;
178+ const fetchPromise = dataStore . downloadPaths ( paths ) ;
179+ const pollTasks = osparc . store . PollTasks . getInstance ( ) ;
180+ pollTasks . createPollingTask ( fetchPromise )
181+ . then ( task => this . __multiDownloadTaskReceived ( task ) )
182+ . catch ( err => osparc . FlashMessenger . logError ( err , this . tr ( "Unsuccessful files download" ) ) ) ;
182183 } ,
183184
184185 __deleteSelected : function ( ) {
@@ -237,63 +238,114 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
237238 const fetchPromise = dataStore . deleteFiles ( paths ) ;
238239 const pollTasks = osparc . store . PollTasks . getInstance ( ) ;
239240 pollTasks . createPollingTask ( fetchPromise )
240- . then ( task => {
241- const taskUI = new osparc . task . TaskUI ( ) ;
242- taskUI . setIcon ( "@FontAwesome5Solid/trash/14" ) ;
243- taskUI . setTitle ( this . tr ( "Deleting files" ) ) ;
244- taskUI . setTask ( task ) ;
245- osparc . task . TasksContainer . getInstance ( ) . addTaskUI ( taskUI ) ;
246-
247- const progressWindow = new osparc . ui . window . Progress (
248- this . tr ( "Delete files" ) ,
249- "@FontAwesome5Solid/trash/14" ,
250- this . tr ( "Deleting files..." ) ,
251- ) ;
252- if ( task . getAbortHref ( ) ) {
253- const cancelButton = progressWindow . addCancelButton ( ) ;
254- cancelButton . setLabel ( this . tr ( "Ignore" ) ) ;
255- const abortButton = new qx . ui . form . Button ( ) . set ( {
256- label : this . tr ( "Cancel" ) ,
257- center : true ,
258- minWidth : 100 ,
259- } ) ;
260- abortButton . addListener ( "execute" , ( ) => task . abortRequested ( ) ) ;
261- progressWindow . addButton ( abortButton ) ;
262- abortButton . set ( {
263- appearance : "danger-button" ,
264- } ) ;
265- }
266- progressWindow . open ( ) ;
267-
268- const finished = ( ) => {
269- progressWindow . close ( ) ;
270- } ;
271-
272- task . addListener ( "updateReceived" , e => {
273- const data = e . getData ( ) ;
274- if ( data [ "task_progress" ] ) {
275- if ( "message" in data [ "task_progress" ] && data [ "task_progress" ] [ "message" ] ) {
276- progressWindow . setMessage ( data [ "task_progress" ] [ "message" ] ) ;
277- }
278- progressWindow . setProgress ( osparc . data . PollTask . extractProgress ( data ) * 100 ) ;
279- }
280- } , this ) ;
281- task . addListener ( "resultReceived" , e => {
282- finished ( ) ;
283- osparc . FlashMessenger . logAs ( this . tr ( "Items successfully deleted" ) , "INFO" ) ;
284- this . fireDataEvent ( "pathsDeleted" , paths ) ;
285- } ) ;
286- task . addListener ( "taskAborted" , ( ) => {
287- finished ( ) ;
288- osparc . FlashMessenger . logAs ( this . tr ( "Deletion aborted" ) , "WARNING" ) ;
289- } ) ;
290- task . addListener ( "pollingError" , e => {
291- const err = e . getData ( ) ;
292- osparc . FlashMessenger . logError ( err ) ;
293- } ) ;
294- } )
241+ . then ( task => this . __deleteTaskReceived ( task , paths ) )
295242 . catch ( err => osparc . FlashMessenger . logError ( err , this . tr ( "Unsuccessful files deletion" ) ) ) ;
296243 }
297244 } ,
245+
246+ __multiDownloadTaskReceived : function ( task ) {
247+ const taskUI = new osparc . task . TaskUI ( ) ;
248+ taskUI . setIcon ( "@FontAwesome5Solid/download/14" ) ;
249+ taskUI . setTitle ( this . tr ( "Downloading files" ) ) ;
250+ taskUI . setTask ( task ) ;
251+ osparc . task . TasksContainer . getInstance ( ) . addTaskUI ( taskUI ) ;
252+
253+ const progressWindow = new osparc . ui . window . Progress (
254+ this . tr ( "Downloading files" ) ,
255+ "@FontAwesome5Solid/download/14" ,
256+ this . tr ( "Downloading files..." ) ,
257+ ) ;
258+ if ( task . getAbortHref ( ) ) {
259+ const cancelButton = progressWindow . addCancelButton ( ) ;
260+ cancelButton . setLabel ( this . tr ( "Ignore" ) ) ;
261+ const abortButton = new qx . ui . form . Button ( ) . set ( {
262+ label : this . tr ( "Cancel" ) ,
263+ center : true ,
264+ minWidth : 100 ,
265+ } ) ;
266+ abortButton . addListener ( "execute" , ( ) => task . abortRequested ( ) ) ;
267+ progressWindow . addButton ( abortButton ) ;
268+ abortButton . set ( {
269+ appearance : "danger-button" ,
270+ } ) ;
271+ }
272+ progressWindow . open ( ) ;
273+
274+ task . addListener ( "updateReceived" , e => {
275+ const data = e . getData ( ) ;
276+ if ( data [ "task_progress" ] ) {
277+ if ( "message" in data [ "task_progress" ] && data [ "task_progress" ] [ "message" ] ) {
278+ progressWindow . setMessage ( data [ "task_progress" ] [ "message" ] ) ;
279+ }
280+ progressWindow . setProgress ( osparc . data . PollTask . extractProgress ( data ) * 100 ) ;
281+ }
282+ } , this ) ;
283+ task . addListener ( "resultReceived" , e => {
284+ console . log ( e . getData ( ) ) ;
285+ progressWindow . close ( ) ;
286+ } ) ;
287+ task . addListener ( "taskAborted" , ( ) => {
288+ osparc . FlashMessenger . logAs ( this . tr ( "Download aborted" ) , "WARNING" ) ;
289+ progressWindow . close ( ) ;
290+ } ) ;
291+ task . addListener ( "pollingError" , e => {
292+ const err = e . getData ( ) ;
293+ osparc . FlashMessenger . logError ( err ) ;
294+ progressWindow . close ( ) ;
295+ } ) ;
296+ } ,
297+
298+ __deleteTaskReceived : function ( task , paths ) {
299+ const taskUI = new osparc . task . TaskUI ( ) ;
300+ taskUI . setIcon ( "@FontAwesome5Solid/trash/14" ) ;
301+ taskUI . setTitle ( this . tr ( "Deleting files" ) ) ;
302+ taskUI . setTask ( task ) ;
303+ osparc . task . TasksContainer . getInstance ( ) . addTaskUI ( taskUI ) ;
304+
305+ const progressWindow = new osparc . ui . window . Progress (
306+ this . tr ( "Delete files" ) ,
307+ "@FontAwesome5Solid/trash/14" ,
308+ this . tr ( "Deleting files..." ) ,
309+ ) ;
310+ if ( task . getAbortHref ( ) ) {
311+ const cancelButton = progressWindow . addCancelButton ( ) ;
312+ cancelButton . setLabel ( this . tr ( "Ignore" ) ) ;
313+ const abortButton = new qx . ui . form . Button ( ) . set ( {
314+ label : this . tr ( "Cancel" ) ,
315+ center : true ,
316+ minWidth : 100 ,
317+ } ) ;
318+ abortButton . addListener ( "execute" , ( ) => task . abortRequested ( ) ) ;
319+ progressWindow . addButton ( abortButton ) ;
320+ abortButton . set ( {
321+ appearance : "danger-button" ,
322+ } ) ;
323+ }
324+ progressWindow . open ( ) ;
325+
326+ task . addListener ( "updateReceived" , e => {
327+ const data = e . getData ( ) ;
328+ if ( data [ "task_progress" ] ) {
329+ if ( "message" in data [ "task_progress" ] && data [ "task_progress" ] [ "message" ] ) {
330+ progressWindow . setMessage ( data [ "task_progress" ] [ "message" ] ) ;
331+ }
332+ progressWindow . setProgress ( osparc . data . PollTask . extractProgress ( data ) * 100 ) ;
333+ }
334+ } , this ) ;
335+ task . addListener ( "resultReceived" , e => {
336+ osparc . FlashMessenger . logAs ( this . tr ( "Items successfully deleted" ) , "INFO" ) ;
337+ this . fireDataEvent ( "pathsDeleted" , paths ) ;
338+ progressWindow . close ( ) ;
339+ } ) ;
340+ task . addListener ( "taskAborted" , ( ) => {
341+ osparc . FlashMessenger . logAs ( this . tr ( "Deletion aborted" ) , "WARNING" ) ;
342+ progressWindow . close ( ) ;
343+ } ) ;
344+ task . addListener ( "pollingError" , e => {
345+ const err = e . getData ( ) ;
346+ osparc . FlashMessenger . logError ( err ) ;
347+ progressWindow . close ( ) ;
348+ } ) ;
349+ } ,
298350 }
299351} ) ;
0 commit comments