1
1
import { css , html , QwcHotReloadElement } from 'qwc-hot-reload-element' ;
2
- import { RouterController } from 'router-controller' ;
3
2
import { JsonRpc } from 'jsonrpc' ;
4
3
import { StorageController } from 'storage-controller' ;
5
4
import '@vaadin/icon' ;
@@ -10,15 +9,13 @@ import '@vaadin/text-area';
10
9
import '@vaadin/progress-bar' ;
11
10
import '@vaadin/tabs' ;
12
11
import '@vaadin/tabsheet' ;
13
- import { notifier } from 'notifier' ;
14
12
import { assistantState } from 'assistant-state' ;
15
13
import 'qui-assistant-warning' ;
16
14
import { observeState } from 'lit-element-state' ;
17
15
18
16
export class HibernateOrmHqlConsoleComponent extends observeState ( QwcHotReloadElement ) {
19
17
jsonRpc = new JsonRpc ( this ) ;
20
18
configJsonRpc = new JsonRpc ( "devui-configuration" ) ;
21
- routerController = new RouterController ( this ) ;
22
19
storageControl = new StorageController ( this ) ;
23
20
24
21
static styles = css `
@@ -281,28 +278,29 @@ export class HibernateOrmHqlConsoleComponent extends observeState(QwcHotReloadEl
281
278
282
279
connectedCallback ( ) {
283
280
super . connectedCallback ( ) ;
284
-
285
- const page = this . routerController . getCurrentPage ( ) ;
286
- if ( page && page . metadata ) {
287
- this . _allowHql = ( page . metadata . allowHql === "true" ) ;
288
- } else {
289
- this . _allowHql = false ;
290
- }
291
-
292
281
this . hotReload ( ) ;
293
282
}
294
283
295
284
hotReload ( ) {
296
285
this . _loading = true ;
297
- this . jsonRpc . getInfo ( ) . then ( response => {
298
- this . _persistenceUnits = response . result . persistenceUnits ;
299
- this . _selectPersistenceUnit ( this . _persistenceUnits [ 0 ] ) ;
300
- this . _loading = false ;
286
+ const configPromise = this . configJsonRpc . getAllValues ( ) ;
287
+ const infoPromise = this . jsonRpc . getInfo ( ) ;
288
+ Promise . all ( [ configPromise , infoPromise ] ) . then ( responses => {
289
+ const configResponse = responses [ 0 ] ;
290
+ const infoResponse = responses [ 1 ] ;
291
+ if ( configResponse && configResponse . result ) {
292
+ const allowHqlConfig = configResponse . result [ 'quarkus.hibernate-orm.dev-ui.allow-hql' ] ;
293
+ this . _allowHql = allowHqlConfig && allowHqlConfig === 'true' ;
294
+ }
295
+ if ( infoResponse && infoResponse . result ) {
296
+ this . _persistenceUnits = infoResponse . result . persistenceUnits ;
297
+ this . _selectPersistenceUnit ( this . _persistenceUnits [ 0 ] ) ;
298
+ }
301
299
} ) . catch ( error => {
302
- console . error ( "Failed to fetch persistence units:" , error ) ;
303
- this . _persistenceUnits = [ ] ;
300
+ console . error ( "Failed to fetch configuration or persistence units:" , error ) ;
301
+ this . _addErrorMessage ( "Failed to fetch configuration or persistence units: " + error ) ;
302
+ } ) . finally ( ( ) => {
304
303
this . _loading = false ;
305
- notifier . showErrorMessage ( "Failed to fetch persistence units: " + error , "bottom-start" , 30 ) ;
306
304
} ) ;
307
305
}
308
306
@@ -735,7 +733,7 @@ export class HibernateOrmHqlConsoleComponent extends observeState(QwcHotReloadEl
735
733
}
736
734
737
735
_handleKeyDown ( event ) {
738
- if ( event . key === 'Enter' && ( event . ctrlKey || event . metaKey ) ) {
736
+ if ( event . key === 'Enter' ) {
739
737
event . preventDefault ( ) ;
740
738
this . _sendQuery ( ) ;
741
739
}
0 commit comments