@@ -77,7 +77,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
7777 const formData = e . getData ( ) ;
7878 const params = {
7979 data : {
80- "display_name " : formData [ "name" ]
80+ "displayName " : formData [ "name" ]
8181 }
8282 } ;
8383 if ( formData [ "expiration" ] ) {
@@ -90,14 +90,17 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
9090 . then ( data => {
9191 this . __rebuildAPIKeysList ( ) ;
9292
93- const key = data [ "api_key" ] ;
94- const secret = data [ "api_secret" ] ;
95- const showAPIKeyWindow = new osparc . desktop . preferences . window . ShowAPIKey ( key , secret ) ;
93+ const key = data [ "apiKey" ] ;
94+ const secret = data [ "apiSecret" ] ;
95+ const baseUrl = data [ "apiBaseUrl" ] ;
96+ const showAPIKeyWindow = new osparc . desktop . preferences . window . ShowAPIKey ( key , secret , baseUrl ) ;
9697 showAPIKeyWindow . center ( ) ;
9798 showAPIKeyWindow . open ( ) ;
9899 } )
99100 . catch ( err => {
100- osparc . FlashMessenger . getInstance ( ) . logAs ( err . message , "ERROR" ) ;
101+ const errorMsg = err . message || this . tr ( "Cannot create API Key" ) ;
102+ osparc . FlashMessenger . getInstance ( ) . logAs ( errorMsg , "ERROR" ) ;
103+ console . error ( err ) ;
101104 } )
102105 . finally ( ( ) => this . __requestAPIKeyBtn . setFetching ( false ) ) ;
103106 } , this ) ;
@@ -109,26 +112,24 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
109112 osparc . data . Resources . get ( "apiKeys" )
110113 . then ( apiKeys => {
111114 apiKeys . forEach ( apiKey => {
112- const apiKeyForm = this . __createValidAPIKeyForm ( apiKey ) ;
115+ const apiKeyForm = this . __createAPIKeyEntry ( apiKey ) ;
113116 this . __apiKeysList . add ( apiKeyForm ) ;
114117 } ) ;
115118 } )
116119 . catch ( err => console . error ( err ) ) ;
117120 } ,
118121
119- __createValidAPIKeyForm : function ( apiKeyLabel ) {
122+ __createAPIKeyEntry : function ( apiKey ) {
120123 const grid = this . __createValidEntryLayout ( ) ;
121124
122- const nameLabel = new qx . ui . basic . Label ( apiKeyLabel ) ;
125+ const nameLabel = new qx . ui . basic . Label ( apiKey [ "displayName" ] ) ;
123126 grid . add ( nameLabel , {
124127 row : 0 ,
125128 column : 0
126129 } ) ;
127130
128131 const delAPIKeyBtn = new qx . ui . form . Button ( null , "@FontAwesome5Solid/trash/14" ) ;
129- delAPIKeyBtn . addListener ( "execute" , e => {
130- this . __deleteAPIKey ( apiKeyLabel ) ;
131- } , this ) ;
132+ delAPIKeyBtn . addListener ( "execute" , ( ) => this . __deleteAPIKey ( apiKey [ "id" ] ) , this ) ;
132133 grid . add ( delAPIKeyBtn , {
133134 row : 0 ,
134135 column : 1
@@ -137,7 +138,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
137138 return grid ;
138139 } ,
139140
140- __deleteAPIKey : function ( apiKeyLabel ) {
141+ __deleteAPIKey : function ( apiKeyId ) {
141142 if ( ! osparc . data . Permissions . getInstance ( ) . canDo ( "user.apikey.delete" , true ) ) {
142143 return ;
143144 }
@@ -153,13 +154,17 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
153154 win . addListener ( "close" , ( ) => {
154155 if ( win . getConfirmed ( ) ) {
155156 const params = {
156- data : {
157- "display_name " : apiKeyLabel
157+ url : {
158+ "apiKeyId " : apiKeyId
158159 }
159160 } ;
160161 osparc . data . Resources . fetch ( "apiKeys" , "delete" , params )
161162 . then ( ( ) => this . __rebuildAPIKeysList ( ) )
162- . catch ( err => console . error ( err ) ) ;
163+ . catch ( err => {
164+ const errorMsg = err . message || this . tr ( "Cannot delete API Key" ) ;
165+ osparc . FlashMessenger . getInstance ( ) . logAs ( errorMsg , "ERROR" ) ;
166+ console . error ( err )
167+ } ) ;
163168 }
164169 } , this ) ;
165170 } ,
@@ -203,7 +208,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
203208 const supportedExternalServices = osparc . utils . Utils . deepCloneObject ( this . __supportedExternalServices ( ) ) ;
204209
205210 tokensList . forEach ( token => {
206- const tokenForm = this . __createValidTokenEntry ( token ) ;
211+ const tokenForm = this . __createTokenEntry ( token ) ;
207212 this . __validTokensGB . add ( tokenForm ) ;
208213 const idx = supportedExternalServices . findIndex ( srv => srv . name === token . service ) ;
209214 if ( idx > - 1 ) {
@@ -244,7 +249,7 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", {
244249 . catch ( err => console . error ( err ) ) ;
245250 } ,
246251
247- __createValidTokenEntry : function ( token ) {
252+ __createTokenEntry : function ( token ) {
248253 const grid = this . __createValidEntryLayout ( ) ;
249254
250255 const service = token [ "service" ] ;
0 commit comments