This is an automated email from the ASF dual-hosted git repository. ytykhun pushed a commit to branch DATALAB-2380 in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit 43c4b7a6b11130845ecba308fc60067dd609c6a8 Author: Yurii Tykhun <[email protected]> AuthorDate: Wed May 19 10:35:38 2021 +0300 [DATALAB-2380] fixed bug with updating new values in editor during endpoints switching --- .../configuration/configuration.component.html | 6 ++--- .../configuration/configuration.component.ts | 26 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html index 48b8c1a..25f6c36 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html @@ -117,7 +117,7 @@ > <h4>Edit self-service.yml</h4> <div class="editor-wrap"> - <div ace-editor mode="yaml" [(text)]="services['self-service'].config" (textChange)="configUpdate('self-service')"></div> + <div #selfEditor ace-editor mode="yaml" [(text)]="services['self-service'].config" [autoUpdateContent]="true" (textChange)="configUpdate('self-service')"></div> </div> </mat-tab> @@ -129,7 +129,7 @@ <h4>Edit provisioning.yml</h4> <div class="editor-wrap"> - <div ace-editor [(text)]="services['provisioning'].config" mode="yaml" (textChange)="configUpdate('provisioning')"></div> + <div #provEditor ace-editor [(text)]="services['provisioning'].config" [autoUpdateContent]="true" mode="yaml" (textChange)="configUpdate('provisioning')"></div> </div> </mat-tab> @@ -138,7 +138,7 @@ > <h4>Edit billing.yml</h4> <div class="editor-wrap"> - <div ace-editor [(text)]="services['billing'].config" mode="yaml" (textChange)="configUpdate('billing')"></div> + <div #billingEditor ace-editor mode="yaml" [(text)]="services['billing'].config" [autoUpdateContent]="true" (textChange)="configUpdate('billing')"></div> </div> </mat-tab> diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts index 5801c60..34f0eea 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts @@ -17,7 +17,7 @@ * under the License. */ -import {Component, OnInit, Inject, HostListener, OnDestroy} from '@angular/core'; +import {Component, OnInit, Inject, HostListener, OnDestroy, ViewChild, ElementRef} from '@angular/core'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import {HealthStatusService, AppRoutingService, EndpointService} from '../../core/services'; import {MatTabChangeEvent} from '@angular/material/tabs'; @@ -37,6 +37,9 @@ import { EnvironmentModel } from '../management/management.model'; styleUrls: ['./configuration.component.scss'] }) export class ConfigurationComponent implements OnInit, OnDestroy { + @ViewChild('selfEditor') selfEditor: ElementRef<HTMLElement>; + @ViewChild('provEditor') provEditor: ElementRef<HTMLElement>; + @ViewChild('billingEditor') billingEditor: ElementRef<HTMLElement>; private unsubscribe$ = new Subject(); private healthStatus: any; public activeTab = {index: 0}; @@ -103,7 +106,7 @@ export class ConfigurationComponent implements OnInit, OnDestroy { this.environmentsDataService.getEnvironmentDataDirect().subscribe((data: any) => { this.environments = EnvironmentModel.loadEnvironments(data); - this.environments.map((env,index) => { + this.environments.map(env => { this.checkResource(env.status, env.endpoint); if(env.resources?.length > 0) { env.resources.map(resource => { @@ -152,7 +155,10 @@ export class ConfigurationComponent implements OnInit, OnDestroy { public action(action: string): void { this.dialog.open(SettingsConfirmationDialogComponent, { data: { - action: action, message: action === 'discard' ? this.confirmMessages.discardChanges : this.confirmMessages.saveChanges + action: action, + message: action === 'discard' ? this.confirmMessages.discardChanges : this.confirmMessages.saveChanges, + environmentStatuses: this.environmentStatuses, + activeEndpoint: this.activeEndpoint }, panelClass: 'modal-sm' }) .afterClosed().subscribe(result => { if (result && action === 'save') this.setServiceConfig(this.activeService, this.services[this.activeService].config); @@ -192,17 +198,27 @@ export class ConfigurationComponent implements OnInit, OnDestroy { ); } + refreshServiceEditor(editor: ElementRef<HTMLElement>) { + if(editor) { + editor.nativeElement.children[3].scrollTop = 100; + editor.nativeElement.children[3].scrollTop = 0; + } + } + public tabChanged(tabChangeEvent: MatTabChangeEvent): void { this.activeTab = tabChangeEvent; if (this.activeTab.index === 1 && this.activeEndpoint === 'local') { this.activeService = 'self-service'; + this.refreshServiceEditor(this.selfEditor); } else if ((this.activeEndpoint !== 'local' && this.activeTab.index === 1) || (this.activeTab.index === 2 && this.activeEndpoint === 'local')) { this.activeService = 'provisioning'; + this.refreshServiceEditor(this.provEditor); } else if ((this.activeEndpoint !== 'local' && this.activeTab.index === 2) || (this.activeTab.index === 3 && this.activeEndpoint === 'local')) { this.activeService = 'billing'; + this.refreshServiceEditor(this.billingEditor); } else { this.activeService = ''; } @@ -210,7 +226,9 @@ export class ConfigurationComponent implements OnInit, OnDestroy { if (!!this.activeService) { if (this.services[this.activeService].config !== this.services[this.activeService].serverConfig) { this.dialog.open(SettingsConfirmationDialogComponent, { data: { - action: 'Was changed' + action: 'Was changed', + environmentStatuses: this.environmentStatuses, + activeEndpoint: this.activeEndpoint }, panelClass: 'modal-sm' }) .afterClosed().subscribe(result => { if (result) { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
