@@ -112,8 +112,7 @@ qx.Class.define("osparc.notification.NotificationUI", {
112112 return control || this . base ( arguments , id ) ;
113113 } ,
114114
115- __applyNotification : async function ( notification ) {
116- console . log ( "notification" , notification ) ;
115+ __applyNotification : function ( notification ) {
117116 let resourceId = null ;
118117 if ( notification . getResourceId ( ) ) {
119118 resourceId = notification . getResourceId ( ) ;
@@ -124,90 +123,88 @@ qx.Class.define("osparc.notification.NotificationUI", {
124123 }
125124 const userFromId = notification . getUserFromId ( ) ;
126125
127- let source = "" ;
128- let title = "" ;
129- let description = "" ;
126+ const icon = this . getChildControl ( "icon" ) ;
127+ const titleLabel = this . getChildControl ( "title" ) ;
128+ titleLabel . setValue ( notification . getTitle ( ) ) ;
129+ const descriptionLabel = this . getChildControl ( "text" ) ;
130+ descriptionLabel . setValue ( notification . getText ( ) ) ;
131+
130132 switch ( notification . getCategory ( ) ) {
131133 case "NEW_ORGANIZATION" :
132- source = "@FontAwesome5Solid/users/14" ;
134+ icon . setSource ( "@FontAwesome5Solid/users/14" ) ;
133135 if ( resourceId ) {
134- const group = await osparc . store . Store . getInstance ( ) . getGroup ( resourceId ) ;
135- description = "You're now member of '" + group [ "name" ] + "'" ;
136+ osparc . store . Store . getInstance ( ) . getGroup ( resourceId )
137+ . then ( group => descriptionLabel . setValue ( "You're now member of '" + group [ "label" ] + "'" ) )
138+ . catch ( ( ) => this . setEnabled ( false ) ) ;
136139 }
137140 break ;
138141 case "STUDY_SHARED" :
139- source = "@FontAwesome5Solid/file/14" ;
142+ icon . setSource ( "@FontAwesome5Solid/file/14" ) ;
140143 if ( resourceId ) {
141144 const params = {
142145 url : {
143146 "studyId" : resourceId
144147 }
145148 } ;
146- const study = await osparc . data . Resources . getOne ( "studies" , params ) ;
147- const studyAlias = osparc . product . Utils . getStudyAlias ( {
148- firstUpperCase : true
149- } ) ;
150- if ( study ) {
151- title = `${ studyAlias } '${ study [ "name" ] } '` ;
152- }
149+ osparc . data . Resources . getOne ( "studies" , params )
150+ . then ( study => {
151+ const studyAlias = osparc . product . Utils . getStudyAlias ( {
152+ firstUpperCase : true
153+ } ) ;
154+ titleLabel . setValue ( `${ studyAlias } '${ study [ "name" ] } '` ) ;
155+ } )
156+ . catch ( ( ) => this . setEnabled ( false ) ) ;
153157 }
154158 if ( userFromId ) {
155159 const user = osparc . store . Store . getInstance ( ) . getUser ( userFromId ) ;
156160 if ( user ) {
157- description = "was shared by " + user [ "label" ] ;
161+ descriptionLabel . setValue ( "was shared by " + user [ "label" ] ) ;
158162 }
159163 }
160164 break ;
161165 case "TEMPLATE_SHARED" :
162- source = "@FontAwesome5Solid/copy/14" ;
166+ icon . setSource ( "@FontAwesome5Solid/copy/14" ) ;
163167 if ( resourceId ) {
164168 const template = osparc . store . Store . getInstance ( ) . getTemplate ( resourceId ) ;
165- const templateAlias = osparc . product . Utils . getTemplateAlias ( {
166- firstUpperCase : true
167- } ) ;
168169 if ( template ) {
169- title = `${ templateAlias } '${ template [ "name" ] } '` ;
170+ const templateAlias = osparc . product . Utils . getTemplateAlias ( {
171+ firstUpperCase : true
172+ } ) ;
173+ titleLabel . setValue ( `${ templateAlias } '${ template [ "name" ] } '` ) ;
174+ } else {
175+ this . setEnabled ( false ) ;
170176 }
171177 }
172178 if ( userFromId ) {
173179 const user = osparc . store . Store . getInstance ( ) . getUser ( userFromId ) ;
174180 if ( user ) {
175- description = "was shared by " + user [ "label" ] ;
181+ descriptionLabel . setValue ( "was shared by " + user [ "label" ] ) ;
176182 }
177183 }
178184 break ;
179185 case "ANNOTATION_NOTE" :
180- source = "@FontAwesome5Solid/file/14" ;
186+ icon . setSource ( "@FontAwesome5Solid/file/14" ) ;
181187 if ( resourceId ) {
182188 const params = {
183189 url : {
184190 "studyId" : resourceId
185191 }
186192 } ;
187- const study = await osparc . data . Resources . getOne ( "studies" , params ) ;
188- if ( study ) {
189- title = `Note added in '${ study [ "name" ] } '` ;
190- }
193+ osparc . data . Resources . getOne ( "studies" , params )
194+ . then ( study => titleLabel . setValue ( `Note added in '${ study [ "name" ] } '` ) )
195+ . catch ( ( ) => this . setEnabled ( false ) ) ;
191196 }
192197 if ( userFromId ) {
193198 const user = osparc . store . Store . getInstance ( ) . getUser ( userFromId ) ;
194199 if ( user ) {
195- description = "was added by " + user [ "label" ] ;
200+ descriptionLabel . setValue ( "was added by " + user [ "label" ] ) ;
196201 }
197202 }
198203 break ;
199204 case "WALLET_SHARED" :
200- source = "@MaterialIcons/account_balance_wallet/14" ;
205+ icon . setSource ( "@MaterialIcons/account_balance_wallet/14" ) ;
201206 break ;
202207 }
203- const icon = this . getChildControl ( "icon" ) ;
204- icon . setSource ( source ) ;
205-
206- const titleLabel = this . getChildControl ( "title" ) ;
207- titleLabel . setValue ( title ? title : notification . getTitle ( ) ) ;
208-
209- const descriptionLabel = this . getChildControl ( "text" ) ;
210- descriptionLabel . setValue ( description ? description : notification . getText ( ) ) ;
211208
212209 const date = this . getChildControl ( "date" ) ;
213210 notification . bind ( "date" , date , "value" , {
0 commit comments