@@ -139,24 +139,36 @@ qx.Class.define("osparc.file.FilePicker", {
139139 }
140140 } ,
141141
142+ getOutputFileMetadata : function ( node ) {
143+ return new Promise ( ( resolve , reject ) => {
144+ const outValue = osparc . file . FilePicker . getOutput ( node . getOutputs ( ) ) ;
145+ const params = {
146+ url : {
147+ locationId : outValue . store ,
148+ datasetId : outValue . dataset
149+ }
150+ } ;
151+ osparc . data . Resources . fetch ( "storageFiles" , "getByLocationAndDataset" , params )
152+ . then ( files => {
153+ const fileMetadata = files . find ( file => file . file_id === outValue . path ) ;
154+ if ( fileMetadata ) {
155+ resolve ( fileMetadata ) ;
156+ } else {
157+ reject ( ) ;
158+ }
159+ } )
160+ . catch ( ( ) => reject ( ) ) ;
161+ } ) ;
162+ } ,
163+
142164 buildFileFromStoreInfoView : function ( node , form ) {
143- const outValue = osparc . file . FilePicker . getOutput ( node . getOutputs ( ) ) ;
144- const params = {
145- url : {
146- locationId : outValue . store ,
147- datasetId : outValue . dataset
148- }
149- } ;
150- osparc . data . Resources . fetch ( "storageFiles" , "getByLocationAndDataset" , params )
151- . then ( files => {
152- const fileMetadata = files . find ( file => file . file_uuid === outValue . path ) ;
153- if ( fileMetadata ) {
154- for ( let [ key , value ] of Object . entries ( fileMetadata ) ) {
155- const entry = new qx . ui . form . TextField ( ) ;
156- form . add ( entry , key , null , key ) ;
157- if ( value ) {
158- entry . setValue ( value . toString ( ) ) ;
159- }
165+ this . self ( ) . getOutputFileMetadata ( node )
166+ . then ( fileMetadata => {
167+ for ( let [ key , value ] of Object . entries ( fileMetadata ) ) {
168+ const entry = new qx . ui . form . TextField ( ) ;
169+ form . add ( entry , key , null , key ) ;
170+ if ( value ) {
171+ entry . setValue ( value . toString ( ) ) ;
160172 }
161173 }
162174 } ) ;
@@ -191,6 +203,17 @@ qx.Class.define("osparc.file.FilePicker", {
191203 return new qx . ui . form . renderer . Single ( form ) ;
192204 } ,
193205
206+ downloadOutput : function ( node ) {
207+ this . self ( ) . getOutputFileMetadata ( node )
208+ . then ( fileMetadata => {
209+ if ( "location_id" in fileMetadata && "file_id" in fileMetadata ) {
210+ const locationId = fileMetadata [ "location_id" ] ;
211+ const fileId = fileMetadata [ "file_id" ] ;
212+ osparc . utils . Utils . retrieveURLAndDownload ( locationId , fileId ) ;
213+ }
214+ } ) ;
215+ } ,
216+
194217 serializeOutput : function ( outputs ) {
195218 let output = { } ;
196219 const outFileValue = osparc . file . FilePicker . getOutput ( outputs ) ;
0 commit comments