@@ -121,35 +121,38 @@ qx.Class.define("osparc.task.TaskUI", {
121121 } ,
122122
123123 __applyTask : function ( task ) {
124- task . addListener ( "updateReceived" , e => {
125- const data = e . getData ( ) ;
126- if ( data [ "task_progress" ] ) {
127- if ( "message" in data [ "task_progress" ] && ! this . getChildControl ( "subtitle" ) . getValue ( ) ) {
128- this . getChildControl ( "subtitle" ) . setValue ( data [ "task_progress" ] [ "message" ] ) ;
129- }
130- this . getChildControl ( "progress" ) . setValue ( ( osparc . data . PollTask . extractProgress ( data ) * 100 ) + "%" ) ;
131- }
132- } , this ) ;
124+ task . addListener ( "updateReceived" , e => this . _updateHandler ( e . getData ( ) ) , this ) ;
133125
134126 const stopButton = this . getChildControl ( "stop" ) ;
135127 task . bind ( "abortHref" , stopButton , "visibility" , {
136128 converter : abortHref => abortHref ? "visible" : "excluded"
137129 } ) ;
138- stopButton . addListener ( "tap" , ( ) => {
139- const msg = this . tr ( "Are you sure you want to cancel the task?" ) ;
140- const win = new osparc . ui . window . Confirmation ( msg ) . set ( {
141- caption : this . tr ( "Cancel Task" ) ,
142- confirmText : this . tr ( "Cancel" ) ,
143- confirmAction : "delete"
144- } ) ;
145- win . getCancelButton ( ) . setLabel ( this . tr ( "Ignore" ) ) ;
146- win . center ( ) ;
147- win . open ( ) ;
148- win . addListener ( "close" , ( ) => {
149- if ( win . getConfirmed ( ) ) {
150- task . abortRequested ( ) ;
151- }
152- } , this ) ;
130+ stopButton . addListener ( "tap" , ( ) => this . _abortHandler ( ) , this ) ;
131+ } ,
132+
133+ _updateHandler : function ( data ) {
134+ if ( data [ "task_progress" ] ) {
135+ if ( "message" in data [ "task_progress" ] && ! this . getChildControl ( "subtitle" ) . getValue ( ) ) {
136+ this . getChildControl ( "subtitle" ) . setValue ( data [ "task_progress" ] [ "message" ] ) ;
137+ }
138+ this . getChildControl ( "progress" ) . setValue ( ( osparc . data . PollTask . extractProgress ( data ) * 100 ) + "%" ) ;
139+ }
140+ } ,
141+
142+ _abortHandler : function ( ) {
143+ const msg = this . tr ( "Are you sure you want to cancel the task?" ) ;
144+ const win = new osparc . ui . window . Confirmation ( msg ) . set ( {
145+ caption : this . tr ( "Cancel Task" ) ,
146+ confirmText : this . tr ( "Cancel" ) ,
147+ confirmAction : "delete"
148+ } ) ;
149+ win . getCancelButton ( ) . setLabel ( this . tr ( "Ignore" ) ) ;
150+ win . center ( ) ;
151+ win . open ( ) ;
152+ win . addListener ( "close" , ( ) => {
153+ if ( win . getConfirmed ( ) ) {
154+ this . getTask ( ) . abortRequested ( ) ;
155+ }
153156 } , this ) ;
154157 } ,
155158
0 commit comments