From 325c067812b885bec3328540cc6bcee1dabb181c Mon Sep 17 00:00:00 2001 From: SeungYoung Oh Date: Sun, 31 Aug 2025 16:40:10 +0900 Subject: [PATCH] [ZEPPELIN-6312] Remove configuration WS usage in frontend --- zeppelin-web-angular/package.json | 4 +- .../interfaces/message-common.interface.ts | 174 +++++++++--------- .../message-data-type-map.interface.ts | 4 +- .../interfaces/message-operator.interface.ts | 13 -- .../projects/zeppelin-sdk/src/message.ts | 4 - zeppelin-web-angular/src/app/app.module.ts | 10 +- .../configuration.component.html | 8 +- .../configuration/configuration.component.ts | 20 +- .../action-bar/action-bar.component.ts | 17 +- .../src/app/services/configuration.service.ts | 15 +- .../src/app/services/message.service.ts | 4 - .../src/app/services/ticket.service.ts | 6 - .../src/app/share/header/header.component.ts | 9 +- .../note-import/note-import.component.ts | 6 +- .../src/app/notebook/notebook.controller.js | 8 +- .../app/notebook/notebook.controller.test.js | 1 - .../components/navbar/navbar.controller.js | 5 - .../note-import/note-import.controller.js | 12 +- .../websocket/websocket-event.factory.js | 2 - .../websocket/websocket-message.service.js | 4 - 20 files changed, 149 insertions(+), 177 deletions(-) diff --git a/zeppelin-web-angular/package.json b/zeppelin-web-angular/package.json index 1a418855e4b..44bc3abf7fd 100644 --- a/zeppelin-web-angular/package.json +++ b/zeppelin-web-angular/package.json @@ -9,8 +9,8 @@ "build:tslint-rules": "tsc tslint-rules/*.ts --types node", "build:projects": "npm run build-project:sdk && npm run build-project:vis && npm run build-project:helium", "build-helium-vis-example": " ng build --project helium-vis-example", - "build-project:sdk": " ng build --project zeppelin-sdk", - "build-project:vis": " ng build --project zeppelin-visualization", + "build-project:sdk": "ng build --project zeppelin-sdk", + "build-project:vis": "ng build --project zeppelin-visualization", "build-project:helium": "ng build --project zeppelin-helium", "test": "ng test", "lint": "ng lint && prettier --check \"src/**/*.{ts,js,css,html}\"", diff --git a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-common.interface.ts b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-common.interface.ts index b8011826f33..58b5f84aa8f 100644 --- a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-common.interface.ts +++ b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-common.interface.ts @@ -28,94 +28,92 @@ export interface Ticket { roles: string; } -export interface ConfigurationsInfo { - configurations: { - 'zeppelin.war.tempdir': string; - 'zeppelin.notebook.azure.user': string; - 'zeppelin.helium.npm.installer.url': string; - 'zeppelin.notebook.git.remote.username': string; - 'zeppelin.interpreter.remoterunner': string; - 'zeppelin.notebook.s3.user': string; - 'zeppelin.server.port': string; - 'zeppelin.plugins.dir': string; - 'zeppelin.notebook.new_format.delete_old': string; - 'zeppelin.ssl.truststore.type': string; - 'zeppelin.ssl.keystore.path': string; - 'zeppelin.notebook.s3.bucket': string; - 'zeppelin.notebook.git.remote.access-token': string; - 'zeppelin.recovery.dir': string; - 'zeppelin.notebook.s3.timeout': string; - 'zeppelin.notebook.cron.enable': string; - 'zeppelin.server.addr': string; - 'zeppelin.username.force.lowercase': string; - 'zeppelin.ssl.keystore.type': string; - 'zeppelin.ssl.truststore.path': string; - 'zeppelin.notebook.dir': string; - 'zeppelin.interpreter.lifecyclemanager.class': string; - 'zeppelin.notebook.gcs.dir': string; - 'zeppelin.notebook.s3.sse': string; - 'zeppelin.websocket.max.text.message.size': string; - 'zeppelin.notebook.git.remote.origin': string; - 'zeppelin.server.authorization.header.clear': string; - 'zeppelin.interpreter.dep.mvnRepo': string; - 'zeppelin.ssl': string; - 'zeppelin.notebook.autoInterpreterBinding': string; - 'zeppelin.config.storage.class': string; - 'zeppelin.helium.node.installer.url': string; - 'zeppelin.notebook.storage': string; - 'zeppelin.notebook.new_format.convert': string; - 'zeppelin.interpreter.dir': string; - 'zeppelin.anonymous.allowed': string; - 'zeppelin.credentials.persist': string; - 'zeppelin.notebook.mongo.uri': string; - 'zeppelin.config.fs.dir': string; - 'zeppelin.server.allowed.origins': string; - 'zeppelin.notebook.mongo.database': string; - 'zeppelin.encoding': string; - 'zeppelin.server.jetty.request.header.size': string; - 'zeppelin.search.temp.path': string; - 'zeppelin.notebook.s3.endpoint': string; - 'zeppelin.notebook.homescreen.hide': string; - 'zeppelin.scheduler.threadpool.size': string; - 'zeppelin.notebook.azure.share': string; - 'zeppelin.helium.yarnpkg.installer.url': string; - 'zeppelin.server.strict.transport': string; - 'zeppelin.interpreter.setting': string; - 'zeppelin.server.xxss.protection': string; - 'zeppelin.server.rpc.portRange': string; - 'zeppelin.war': string; - 'zeppelin.interpreter.output.limit': string; - 'zeppelin.dep.localrepo': string; - 'zeppelin.interpreter.max.poolsize': string; - 'zeppelin.server.ssl.port': string; - 'zeppelin.notebook.mongo.collection': string; - 'zeppelin.notebook.public': string; - 'zeppelin.helium.registry': string; - 'zeppelin.server.kerberos.principal': string; - 'zeppelin.server.default.dir.allowed': string; - 'zeppelin.ssl.client.auth': string; - 'zeppelin.server.context.path': string; - 'zeppelin.recovery.storage.class': string; - 'zeppelin.notebook.default.owner.username': string; - 'zeppelin.home': string; - 'zeppelin.interpreter.lifecyclemanager.timeout.threshold': string; - 'zeppelin.notebook.git.remote.url': string; - 'zeppelin.notebook.mongo.autoimport': string; - 'zeppelin.notebook.one.way.sync': string; - 'zeppelin.notebook.homescreen': string; - 'zeppelin.interpreter.connect.timeout': string; - 'zeppelin.server.xframe.options': string; - 'zeppelin.interpreter.lifecyclemanager.timeout.checkinterval': string; - 'zeppelin.server.kerberos.keytab': string; - 'zeppelin.interpreter.rpc.portRange': string; - 'zeppelin.interpreter.group.default': string; - 'zeppelin.conf.dir': string; - 'zeppelin.interpreter.localRepo': string; - 'zeppelin.notebook.collaborative.mode.enable': string; - 'zeppelin.search.use.disk': string; - 'zeppelin.notebook.s3.cannedAcl': string; - 'zeppelin.notebook.s3.pathStyleAccess': string; - }; +export interface Configuration { + 'zeppelin.war.tempdir': string; + 'zeppelin.notebook.azure.user': string; + 'zeppelin.helium.npm.installer.url': string; + 'zeppelin.notebook.git.remote.username': string; + 'zeppelin.interpreter.remoterunner': string; + 'zeppelin.notebook.s3.user': string; + 'zeppelin.server.port': string; + 'zeppelin.plugins.dir': string; + 'zeppelin.notebook.new_format.delete_old': string; + 'zeppelin.ssl.truststore.type': string; + 'zeppelin.ssl.keystore.path': string; + 'zeppelin.notebook.s3.bucket': string; + 'zeppelin.notebook.git.remote.access-token': string; + 'zeppelin.recovery.dir': string; + 'zeppelin.notebook.s3.timeout': string; + 'zeppelin.notebook.cron.enable': string; + 'zeppelin.server.addr': string; + 'zeppelin.username.force.lowercase': string; + 'zeppelin.ssl.keystore.type': string; + 'zeppelin.ssl.truststore.path': string; + 'zeppelin.notebook.dir': string; + 'zeppelin.interpreter.lifecyclemanager.class': string; + 'zeppelin.notebook.gcs.dir': string; + 'zeppelin.notebook.s3.sse': string; + 'zeppelin.websocket.max.text.message.size': string; + 'zeppelin.notebook.git.remote.origin': string; + 'zeppelin.server.authorization.header.clear': string; + 'zeppelin.interpreter.dep.mvnRepo': string; + 'zeppelin.ssl': string; + 'zeppelin.notebook.autoInterpreterBinding': string; + 'zeppelin.config.storage.class': string; + 'zeppelin.helium.node.installer.url': string; + 'zeppelin.notebook.storage': string; + 'zeppelin.notebook.new_format.convert': string; + 'zeppelin.interpreter.dir': string; + 'zeppelin.anonymous.allowed': string; + 'zeppelin.credentials.persist': string; + 'zeppelin.notebook.mongo.uri': string; + 'zeppelin.config.fs.dir': string; + 'zeppelin.server.allowed.origins': string; + 'zeppelin.notebook.mongo.database': string; + 'zeppelin.encoding': string; + 'zeppelin.server.jetty.request.header.size': string; + 'zeppelin.search.temp.path': string; + 'zeppelin.notebook.s3.endpoint': string; + 'zeppelin.notebook.homescreen.hide': string; + 'zeppelin.scheduler.threadpool.size': string; + 'zeppelin.notebook.azure.share': string; + 'zeppelin.helium.yarnpkg.installer.url': string; + 'zeppelin.server.strict.transport': string; + 'zeppelin.interpreter.setting': string; + 'zeppelin.server.xxss.protection': string; + 'zeppelin.server.rpc.portRange': string; + 'zeppelin.war': string; + 'zeppelin.interpreter.output.limit': string; + 'zeppelin.dep.localrepo': string; + 'zeppelin.interpreter.max.poolsize': string; + 'zeppelin.server.ssl.port': string; + 'zeppelin.notebook.mongo.collection': string; + 'zeppelin.notebook.public': string; + 'zeppelin.helium.registry': string; + 'zeppelin.server.kerberos.principal': string; + 'zeppelin.server.default.dir.allowed': string; + 'zeppelin.ssl.client.auth': string; + 'zeppelin.server.context.path': string; + 'zeppelin.recovery.storage.class': string; + 'zeppelin.notebook.default.owner.username': string; + 'zeppelin.home': string; + 'zeppelin.interpreter.lifecyclemanager.timeout.threshold': string; + 'zeppelin.notebook.git.remote.url': string; + 'zeppelin.notebook.mongo.autoimport': string; + 'zeppelin.notebook.one.way.sync': string; + 'zeppelin.notebook.homescreen': string; + 'zeppelin.interpreter.connect.timeout': string; + 'zeppelin.server.xframe.options': string; + 'zeppelin.interpreter.lifecyclemanager.timeout.checkinterval': string; + 'zeppelin.server.kerberos.keytab': string; + 'zeppelin.interpreter.rpc.portRange': string; + 'zeppelin.interpreter.group.default': string; + 'zeppelin.conf.dir': string; + 'zeppelin.interpreter.localRepo': string; + 'zeppelin.notebook.collaborative.mode.enable': string; + 'zeppelin.search.use.disk': string; + 'zeppelin.notebook.s3.cannedAcl': string; + 'zeppelin.notebook.s3.pathStyleAccess': string; } export interface ErrorInfo { diff --git a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-data-type-map.interface.ts b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-data-type-map.interface.ts index e832a1e8f95..62575168fe7 100644 --- a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-data-type-map.interface.ts +++ b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-data-type-map.interface.ts @@ -10,7 +10,7 @@ * limitations under the License. */ -import { AuthInfo, ConfigurationsInfo, ErrorInfo } from './message-common.interface'; +import { AuthInfo, ErrorInfo } from './message-common.interface'; import { CheckpointNote, CloneNote, @@ -86,7 +86,6 @@ export type MixMessageDataTypeMap = MessageSendDataTypeMap & MessageReceiveDataT export interface MessageReceiveDataTypeMap { [OP.COMPLETION_LIST]: CompletionReceived; [OP.NOTES_INFO]: NotesInfo; - [OP.CONFIGURATIONS_INFO]: ConfigurationsInfo; [OP.NOTE]: Note; [OP.NOTE_REVISION]: NoteRevision; [OP.ERROR_INFO]: ErrorInfo; @@ -118,7 +117,6 @@ export interface MessageReceiveDataTypeMap { export interface MessageSendDataTypeMap { [OP.PING]: undefined; - [OP.LIST_CONFIGURATIONS]: undefined; [OP.LIST_NOTES]: undefined; [OP.GET_HOME_NOTE]: undefined; [OP.RESTORE_ALL]: undefined; diff --git a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-operator.interface.ts b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-operator.interface.ts index cc10753cffc..fb426d39126 100644 --- a/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-operator.interface.ts +++ b/zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-operator.interface.ts @@ -264,19 +264,6 @@ export enum OP { */ ANGULAR_OBJECT_CLIENT_UNBIND = 'ANGULAR_OBJECT_CLIENT_UNBIND', - /** - * [c-s] - * ask all key/value pairs of configurations - */ - LIST_CONFIGURATIONS = 'LIST_CONFIGURATIONS', - - /** - * [s-c] - * all key/value pairs of configurations - * @param settings serialized Map object - */ - CONFIGURATIONS_INFO = 'CONFIGURATIONS_INFO', - /** * [c-s] * checkpoint note to storage repository diff --git a/zeppelin-web-angular/projects/zeppelin-sdk/src/message.ts b/zeppelin-web-angular/projects/zeppelin-sdk/src/message.ts index cd30db598f5..f6af6d81e3f 100644 --- a/zeppelin-web-angular/projects/zeppelin-sdk/src/message.ts +++ b/zeppelin-web-angular/projects/zeppelin-sdk/src/message.ts @@ -546,10 +546,6 @@ export class Message { {noteId: noteId, selectedSettingIds: selectedSettingIds}); } - listConfigurations(): void { - this.send(OP.LIST_CONFIGURATIONS); - } - getInterpreterSettings(): void { this.send(OP.GET_INTERPRETER_SETTINGS); } diff --git a/zeppelin-web-angular/src/app/app.module.ts b/zeppelin-web-angular/src/app/app.module.ts index 61d6dddbd98..70d22be1b48 100644 --- a/zeppelin-web-angular/src/app/app.module.ts +++ b/zeppelin-web-angular/src/app/app.module.ts @@ -13,7 +13,7 @@ import { registerLocaleData } from '@angular/common'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import en from '@angular/common/locales/en'; -import { NgModule } from '@angular/core'; +import { APP_INITIALIZER, NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -26,7 +26,7 @@ import { NzNotificationService } from 'ng-zorro-antd/notification'; import { MESSAGE_INTERCEPTOR, TRASH_FOLDER_ID_TOKEN } from '@zeppelin/interfaces'; import { loadMonacoBefore } from '@zeppelin/languages'; -import { TicketService } from '@zeppelin/services'; +import { ConfigurationService, TicketService } from '@zeppelin/services'; import { ShareModule } from '@zeppelin/share'; import { JoinedEditorOptions, NZ_CODE_EDITOR_CONFIG } from '@zeppelin/share/code-editor'; @@ -66,6 +66,12 @@ registerLocaleData(en); multi: true, deps: [TicketService] }, + { + provide: APP_INITIALIZER, + useFactory: (configService: ConfigurationService) => () => configService.initialize(), + deps: [ConfigurationService], + multi: true + }, { provide: NZ_CODE_EDITOR_CONFIG, useValue: { diff --git a/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.html b/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.html index b1add8b6611..df9a6132317 100644 --- a/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.html +++ b/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.html @@ -17,7 +17,7 @@ Note: For security reasons, some key/value pairs including passwords would not be shown.
- + Name @@ -25,9 +25,9 @@ - - {{ data[0] }} - {{ data[1] }} + + {{ entry.key }} + {{ entry.value }} diff --git a/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.ts b/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.ts index aead174677e..cc663b468ac 100644 --- a/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.ts +++ b/zeppelin-web-angular/src/app/pages/workspace/configuration/configuration.component.ts @@ -9,7 +9,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { Configuration } from '@zeppelin/sdk'; import { ConfigurationService } from '@zeppelin/services'; @Component({ @@ -18,19 +19,10 @@ import { ConfigurationService } from '@zeppelin/services'; styleUrls: ['./configuration.component.less'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class ConfigurationComponent implements OnInit { - configEntries: Array<[string, string]> = []; +export class ConfigurationComponent { + constructor(private configurationService: ConfigurationService) {} - constructor(private configurationService: ConfigurationService, private cdr: ChangeDetectorRef) {} - - ngOnInit() { - this.getAllConfig(); - } - - getAllConfig(): void { - this.configurationService.getAll().subscribe(data => { - this.configEntries = [...Object.entries(data)].sort((a, b) => a[0].localeCompare(b[0])); - this.cdr.markForCheck(); - }); + get configuration(): Configuration | null { + return this.configurationService.configuration ?? null; } } diff --git a/zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.ts b/zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.ts index 3dfa8c58712..8613c123921 100644 --- a/zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.ts +++ b/zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.ts @@ -27,7 +27,13 @@ import { NzModalService } from 'ng-zorro-antd/modal'; import { MessageListener, MessageListenersManager } from '@zeppelin/core'; import { TRASH_FOLDER_ID_TOKEN } from '@zeppelin/interfaces'; import { MessageReceiveDataTypeMap, Note, OP, RevisionListItem } from '@zeppelin/sdk'; -import { MessageService, NoteStatusService, SaveAsService, TicketService } from '@zeppelin/services'; +import { + ConfigurationService, + MessageService, + NoteStatusService, + SaveAsService, + TicketService +} from '@zeppelin/services'; import { NotebookService } from '@zeppelin/services/notebook.service'; import { NoteCreateComponent } from '@zeppelin/share/note-create/note-create.component'; @@ -185,10 +191,10 @@ export class NotebookActionBarComponent extends MessageListenersManager implemen } exportNote() { - if (!this.ticketService.configuration) { + if (!this.configurationService.configuration) { throw new Error('Configuration is not loaded'); } - const sizeLimit = +this.ticketService.configuration['zeppelin.websocket.max.text.message.size']; + const sizeLimit = +this.configurationService.configuration['zeppelin.websocket.max.text.message.size']; const jsonContent = JSON.stringify(this.note); if (jsonContent.length > sizeLimit) { this.nzModalService.confirm({ @@ -296,11 +302,12 @@ export class NotebookActionBarComponent extends MessageListenersManager implemen private noteStatusService: NoteStatusService, private notebookService: NotebookService, private activatedRoute: ActivatedRoute, - private saveAsService: SaveAsService + private saveAsService: SaveAsService, + private configurationService: ConfigurationService ) { super(messageService); this.updateIsNoteParagraphRunning(); - if (!this.ticketService.configuration) { + if (!this.configurationService.configuration) { throw new Error('Configuration is not loaded'); } } diff --git a/zeppelin-web-angular/src/app/services/configuration.service.ts b/zeppelin-web-angular/src/app/services/configuration.service.ts index d409083c068..6cb85bcfb6c 100644 --- a/zeppelin-web-angular/src/app/services/configuration.service.ts +++ b/zeppelin-web-angular/src/app/services/configuration.service.ts @@ -13,6 +13,8 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { Configuration } from '@zeppelin/sdk'; +import { retry } from 'rxjs/operators'; import { BaseRest } from './base-rest'; import { BaseUrlService } from './base-url.service'; @@ -20,11 +22,20 @@ import { BaseUrlService } from './base-url.service'; providedIn: 'root' }) export class ConfigurationService extends BaseRest { + private _configuration?: Configuration; + constructor(private http: HttpClient, baseUrlService: BaseUrlService) { super(baseUrlService); } - getAll() { - return this.http.get<{ [key: string]: string }>(this.restUrl`/configurations/all`); + get configuration() { + return this._configuration; + } + + async initialize(): Promise { + this._configuration = await this.http + .get(this.restUrl`/configurations/all`) + .pipe(retry(3)) + .toPromise(); } } diff --git a/zeppelin-web-angular/src/app/services/message.service.ts b/zeppelin-web-angular/src/app/services/message.service.ts index 675fc7aad19..fda5374dfeb 100644 --- a/zeppelin-web-angular/src/app/services/message.service.ts +++ b/zeppelin-web-angular/src/app/services/message.service.ts @@ -319,10 +319,6 @@ export class MessageService extends Message implements OnDestroy { super.saveInterpreterBindings(noteId, selectedSettingIds); } - listConfigurations(): void { - super.listConfigurations(); - } - getInterpreterSettings(): void { super.getInterpreterSettings(); } diff --git a/zeppelin-web-angular/src/app/services/ticket.service.ts b/zeppelin-web-angular/src/app/services/ticket.service.ts index d12da61120f..41201254f64 100644 --- a/zeppelin-web-angular/src/app/services/ticket.service.ts +++ b/zeppelin-web-angular/src/app/services/ticket.service.ts @@ -19,7 +19,6 @@ import { map, tap } from 'rxjs/operators'; import { NzMessageService } from 'ng-zorro-antd/message'; import { ITicket, ITicketWrapped, IZeppelinVersion } from '@zeppelin/interfaces'; -import { ConfigurationsInfo } from '@zeppelin/sdk'; import { BaseUrlService } from './base-url.service'; @@ -27,17 +26,12 @@ import { BaseUrlService } from './base-url.service'; providedIn: 'root' }) export class TicketService { - configuration?: ConfigurationsInfo['configurations']; ticket = new ITicketWrapped(); originTicket = new ITicket(); ticket$ = new Subject(); logout$ = new BehaviorSubject(false); version?: string; - setConfiguration(conf: ConfigurationsInfo) { - this.configuration = conf.configurations; - } - getTicket() { return forkJoin([ this.httpClient.get(`${this.baseUrlService.getRestApiBase()}/security/ticket`), diff --git a/zeppelin-web-angular/src/app/share/header/header.component.ts b/zeppelin-web-angular/src/app/share/header/header.component.ts index 78a7da185f8..436096c4388 100644 --- a/zeppelin-web-angular/src/app/share/header/header.component.ts +++ b/zeppelin-web-angular/src/app/share/header/header.component.ts @@ -17,8 +17,7 @@ import { NzModalService } from 'ng-zorro-antd/modal'; import { Subject } from 'rxjs'; import { filter, takeUntil } from 'rxjs/operators'; -import { MessageListener, MessageListenersManager } from '@zeppelin/core'; -import { MessageReceiveDataTypeMap, OP } from '@zeppelin/sdk'; +import { MessageListenersManager } from '@zeppelin/core'; import { MessageService, TicketService } from '@zeppelin/services'; import { NotebookService } from '@zeppelin/services/notebook.service'; import { AboutZeppelinComponent } from '@zeppelin/share/about-zeppelin/about-zeppelin.component'; @@ -59,11 +58,6 @@ export class HeaderComponent extends MessageListenersManager implements OnInit, } } - @MessageListener(OP.CONFIGURATIONS_INFO) - getConfiguration(data: MessageReceiveDataTypeMap[OP.CONFIGURATIONS_INFO]) { - this.ticketService.setConfiguration(data); - } - constructor( public ticketService: TicketService, public messageService: MessageService, @@ -77,7 +71,6 @@ export class HeaderComponent extends MessageListenersManager implements OnInit, } ngOnInit() { - this.messageService.listConfigurations(); this.messageService.connectedStatus$.pipe(takeUntil(this.destroy$)).subscribe(status => { this.connectStatus = status ? 'success' : 'error'; this.cdr.markForCheck(); diff --git a/zeppelin-web-angular/src/app/share/note-import/note-import.component.ts b/zeppelin-web-angular/src/app/share/note-import/note-import.component.ts index 32294cb5eee..56f3db345c3 100644 --- a/zeppelin-web-angular/src/app/share/note-import/note-import.component.ts +++ b/zeppelin-web-angular/src/app/share/note-import/note-import.component.ts @@ -19,8 +19,8 @@ import { NzUploadFile } from 'ng-zorro-antd/upload'; import { MessageListener, MessageListenersManager } from '@zeppelin/core'; import { MessageReceiveDataTypeMap, OP, SendNote } from '@zeppelin/sdk'; +import { ConfigurationService } from '@zeppelin/services/configuration.service'; import { MessageService } from '@zeppelin/services/message.service'; -import { TicketService } from '@zeppelin/services/ticket.service'; @Component({ selector: 'zeppelin-note-import', @@ -33,7 +33,7 @@ export class NoteImportComponent extends MessageListenersManager implements OnIn importUrl?: string; errorText?: string; importLoading = false; - maxLimit = get(this.ticketService.configuration, ['zeppelin.websocket.max.text.message.size'], null); + maxLimit = get(this.configurationService.configuration, ['zeppelin.websocket.max.text.message.size'], null); @MessageListener(OP.NOTES_INFO) getNotes(data: MessageReceiveDataTypeMap[OP.NOTES_INFO]) { @@ -102,7 +102,7 @@ export class NoteImportComponent extends MessageListenersManager implements OnIn constructor( public messageService: MessageService, - private ticketService: TicketService, + private configurationService: ConfigurationService, private cdr: ChangeDetectorRef, private nzModalRef: NzModalRef, private httpClient: HttpClient diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index 67a088cd9f1..ce7c5c89a24 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -270,9 +270,11 @@ function NotebookCtrl($scope, $route, $routeParams, $location, $rootScope, // Export notebook let limit = 0; - websocketMsgSrv.listConfigurations(); - $scope.$on('configurationsInfo', function(scope, event) { - limit = event.configurations['zeppelin.websocket.max.text.message.size']; + $http.get(baseUrlSrv.getRestApiBase() + '/configurations/all').then(function(response) { + let configurations = response.data.body; + limit = configurations['zeppelin.websocket.max.text.message.size']; + }).catch(function(err) { + console.debug('Error while fetching configurations', err); }); $scope.exportNote = function() { diff --git a/zeppelin-web/src/app/notebook/notebook.controller.test.js b/zeppelin-web/src/app/notebook/notebook.controller.test.js index e3769daaa9c..6de12ab8131 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.test.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.test.js @@ -9,7 +9,6 @@ describe('Controller: NotebookCtrl', function() { getInterpreterBindings: function() {}, updateNote: function() {}, renameNote: function() {}, - listConfigurations: function() {}, }; let baseUrlSrvMock = { diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js index b35c60eac98..4cbf3ad9fc6 100644 --- a/zeppelin-web/src/components/navbar/navbar.controller.js +++ b/zeppelin-web/src/components/navbar/navbar.controller.js @@ -85,10 +85,6 @@ function NavCtrl($scope, $rootScope, $http, $routeParams, $location, return ($routeParams.noteId === noteId); } - function listConfigurations() { - websocketMsgSrv.listConfigurations(); - } - function loadNotes() { websocketMsgSrv.getNoteList(); } @@ -226,7 +222,6 @@ function NavCtrl($scope, $rootScope, $http, $routeParams, $location, $scope.$on('loginSuccess', function(event, param) { $rootScope.ticket.screenUsername = $rootScope.ticket.principal; - listConfigurations(); loadNotes(); getHomeNote(); }); diff --git a/zeppelin-web/src/components/note-import/note-import.controller.js b/zeppelin-web/src/components/note-import/note-import.controller.js index 61e21c84c74..fee7f7bad26 100644 --- a/zeppelin-web/src/components/note-import/note-import.controller.js +++ b/zeppelin-web/src/components/note-import/note-import.controller.js @@ -16,7 +16,7 @@ import './note-import.css'; angular.module('zeppelinWebApp').controller('NoteImportCtrl', NoteImportCtrl); -function NoteImportCtrl($scope, $timeout, websocketMsgSrv) { +function NoteImportCtrl($scope, $timeout, websocketMsgSrv, $http, baseUrlSrv) { 'ngInject'; let vm = this; @@ -26,12 +26,16 @@ function NoteImportCtrl($scope, $timeout, websocketMsgSrv) { $scope.maxLimit = ''; let limit = 0; - websocketMsgSrv.listConfigurations(); - $scope.$on('configurationsInfo', function(scope, event) { - limit = event.configurations['zeppelin.websocket.max.text.message.size']; + + $http.get(baseUrlSrv.getRestApiBase() + '/configurations/all').then(function(response) { + let configurations = response.data.body; + limit = configurations['zeppelin.websocket.max.text.message.size']; $scope.maxLimit = Math.round(limit / 1048576); + }).catch(function(err) { + console.debug('Error while fetching configurations', err); }); + vm.resetFlags = function() { $scope.note = {}; $scope.note.step1 = true; diff --git a/zeppelin-web/src/components/websocket/websocket-event.factory.js b/zeppelin-web/src/components/websocket/websocket-event.factory.js index ccf941b4a36..97e020dd989 100644 --- a/zeppelin-web/src/components/websocket/websocket-event.factory.js +++ b/zeppelin-web/src/components/websocket/websocket-event.factory.js @@ -185,8 +185,6 @@ function WebsocketEventFactory($rootScope, $websocket, $location, baseUrlSrv, sa }); } else if (op === 'SESSION_LOGOUT') { $rootScope.$broadcast('session_logout', data); - } else if (op === 'CONFIGURATIONS_INFO') { - $rootScope.$broadcast('configurationsInfo', data); } else if (op === 'INTERPRETER_SETTINGS') { $rootScope.$broadcast('interpreterSettings', data); } else if (op === 'PARAGRAPH_ADDED') { diff --git a/zeppelin-web/src/components/websocket/websocket-message.service.js b/zeppelin-web/src/components/websocket/websocket-message.service.js index 49b16aad455..786553b630e 100644 --- a/zeppelin-web/src/components/websocket/websocket-message.service.js +++ b/zeppelin-web/src/components/websocket/websocket-message.service.js @@ -387,10 +387,6 @@ function WebsocketMessageService($rootScope, websocketEvents) { data: {noteId: noteId, selectedSettingIds: selectedSettingIds}}); }, - listConfigurations: function() { - websocketEvents.sendNewEvent({op: 'LIST_CONFIGURATIONS'}); - }, - getInterpreterSettings: function() { websocketEvents.sendNewEvent({op: 'GET_INTERPRETER_SETTINGS'}); },