@@ -90,13 +90,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
90
90
}
91
91
} ,
92
92
93
- __reloadUserStudy : function ( studyId ) {
94
- const params = {
95
- url : {
96
- projectId : studyId
97
- }
98
- } ;
99
- osparc . data . Resources . getOne ( "studies" , params )
93
+ __reloadUserStudy : function ( studyId , reload ) {
94
+ osparc . store . Store . getInstance ( ) . getStudyWState ( studyId , reload )
100
95
. then ( studyData => {
101
96
this . __resetStudyItem ( studyData ) ;
102
97
} )
@@ -111,7 +106,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
111
106
*/
112
107
reloadUserStudies : function ( ) {
113
108
if ( osparc . data . Permissions . getInstance ( ) . canDo ( "studies.user.read" ) ) {
114
- osparc . data . Resources . get ( "studies" )
109
+ osparc . store . Store . getInstance ( ) . getStudiesWState ( )
115
110
. then ( studies => {
116
111
this . __resetStudyList ( studies ) ;
117
112
this . resetSelection ( ) ;
@@ -127,14 +122,15 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
127
122
__initResources : function ( ) {
128
123
this . __showLoadingPage ( this . tr ( "Loading Studies" ) ) ;
129
124
130
- const servicesTags = this . __getTags ( ) ;
125
+ this . __userStudies = [ ] ;
126
+ const resourcePromises = [ ] ;
131
127
const store = osparc . store . Store . getInstance ( ) ;
132
- const servicesPromise = store . getServicesDAGs ( true ) ;
133
-
134
- Promise . all ( [
135
- servicesTags ,
136
- servicesPromise
137
- ] )
128
+ resourcePromises . push ( store . getVisibleMembers ( ) ) ;
129
+ resourcePromises . push ( store . getServicesDAGs ( true ) ) ;
130
+ if ( osparc . data . Permissions . getInstance ( ) . canDo ( "study.tag" ) ) {
131
+ resourcePromises . push ( osparc . data . Resources . get ( "tags" ) ) ;
132
+ }
133
+ Promise . all ( resourcePromises )
138
134
. then ( ( ) => {
139
135
this . __hideLoadingPage ( ) ;
140
136
this . __createStudiesLayout ( ) ;
@@ -144,7 +140,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
144
140
if ( loadStudyId ) {
145
141
this . __getStudyAndStart ( loadStudyId ) ;
146
142
}
147
- } ) ;
143
+ } )
144
+ . catch ( console . error ) ;
148
145
} ,
149
146
150
147
__reloadResources : function ( ) {
@@ -171,18 +168,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
171
168
} ) ;
172
169
} ,
173
170
174
- __getTags : function ( ) {
175
- return new Promise ( ( resolve , reject ) => {
176
- if ( osparc . data . Permissions . getInstance ( ) . canDo ( "study.tag" ) ) {
177
- osparc . data . Resources . get ( "tags" )
178
- . catch ( console . error )
179
- . finally ( ( ) => resolve ( ) ) ;
180
- } else {
181
- resolve ( ) ;
182
- }
183
- } ) ;
184
- } ,
185
-
186
171
__createStudiesLayout : function ( ) {
187
172
const studyFilters = this . __studyFilters = new osparc . component . filter . group . StudyFilterGroup ( "studyBrowser" ) . set ( {
188
173
paddingTop : 5
@@ -244,12 +229,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
244
229
} ,
245
230
246
231
__getStudyAndStart : function ( loadStudyId ) {
247
- const params = {
248
- url : {
249
- projectId : loadStudyId
250
- }
251
- } ;
252
- osparc . data . Resources . getOne ( "studies" , params )
232
+ osparc . store . Store . getStudyWState ( loadStudyId , true )
253
233
. then ( studyData => {
254
234
this . __startStudy ( studyData ) ;
255
235
} )
@@ -282,6 +262,23 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
282
262
} ,
283
263
284
264
__attachEventHandlers : function ( ) {
265
+ // Listen to socket
266
+ const socket = osparc . wrapper . WebSocket . getInstance ( ) ;
267
+ // callback for incoming logs
268
+ const slotName = "projectStateUpdated" ;
269
+ socket . removeSlot ( slotName ) ;
270
+ socket . on ( slotName , function ( jsonString ) {
271
+ const data = JSON . parse ( jsonString ) ;
272
+ if ( data ) {
273
+ const studyId = data [ "project_uuid" ] ;
274
+ const state = ( "data" in data ) ? data [ "data" ] : { } ;
275
+ const studyItem = this . __userStudyContainer . getChildren ( ) . find ( card => ( card instanceof osparc . dashboard . StudyBrowserButtonItem ) && ( card . getUuid ( ) === studyId ) ) ;
276
+ if ( studyItem ) {
277
+ studyItem . setState ( state ) ;
278
+ }
279
+ }
280
+ } , this ) ;
281
+
285
282
const textfield = this . __studyFilters . getTextFilter ( ) . getChildControl ( "textfield" ) ;
286
283
textfield . addListener ( "appear" , ( ) => {
287
284
textfield . focus ( ) ;
@@ -347,10 +344,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
347
344
__resetStudyItem : function ( studyData ) {
348
345
const userStudyList = this . __userStudies ;
349
346
const index = userStudyList . findIndex ( userStudy => userStudy [ "uuid" ] === studyData [ "uuid" ] ) ;
350
- if ( index !== - 1 ) {
351
- this . __userStudies [ index ] = studyData ;
352
- this . __resetStudyList ( userStudyList ) ;
347
+ if ( index === - 1 ) {
348
+ userStudyList . push ( studyData ) ;
349
+ } else {
350
+ userStudyList [ index ] = studyData ;
353
351
}
352
+ this . __resetStudyList ( userStudyList ) ;
354
353
} ,
355
354
356
355
__resetStudyList : function ( userStudyList ) {
@@ -400,13 +399,16 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
400
399
accessRights : study . accessRights ? study . accessRights : null ,
401
400
lastChangeDate : study . lastChangeDate ? new Date ( study . lastChangeDate ) : null ,
402
401
icon : study . thumbnail || defaultThumbnail ,
402
+ state : study . state ? study . state : { } ,
403
403
tags
404
404
} ) ;
405
405
const menu = this . __getStudyItemMenu ( item , study ) ;
406
406
item . setMenu ( menu ) ;
407
407
item . subscribeToFilterGroup ( "studyBrowser" ) ;
408
408
item . addListener ( "execute" , ( ) => {
409
- this . __itemClicked ( item ) ;
409
+ if ( ! item . isLocked ( ) ) {
410
+ this . __itemClicked ( item ) ;
411
+ }
410
412
} , this ) ;
411
413
412
414
return item ;
@@ -469,7 +471,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
469
471
const permissionsView = new osparc . component . export . Permissions ( studyData ) ;
470
472
permissionsView . addListener ( "updateStudy" , e => {
471
473
const studyId = e . getData ( ) ;
472
- this . __reloadUserStudy ( studyId ) ;
474
+ this . __reloadUserStudy ( studyId , true ) ;
473
475
} , this ) ;
474
476
const window = permissionsView . createWindow ( ) ;
475
477
permissionsView . addListener ( "finished" , e => {
0 commit comments