This is an automated email from the ASF dual-hosted git repository. ankovalyshyn pushed a commit to branch feature/projects in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 17a9e7d52bc823a00d70ef465cacb9dac66b415b Author: Andriana Kovalyshyn <andriana_kovalys...@epam.com> AuthorDate: Thu May 30 15:58:16 2019 +0300 [DLAB-631]: replaced confirmation dialog component --- .../src/app/administration/management/index.ts | 6 ++-- .../management-grid/management-grid.component.html | 1 - .../management-grid/management-grid.component.ts | 25 ++++++------- .../detail-dialog/detail-dialog.component.ts | 1 - .../resources-grid/resources-grid.component.html | 9 ----- .../resources-grid/resources-grid.component.ts | 21 ++++------- .../confirmation-dialog.component.html | 26 +++++++------- .../confirmation-dialog.component.ts | 42 ++++++++-------------- .../modal-dialog/confirmation-dialog/index.ts | 1 + .../progress-dialog/progress-dialog.component.ts | 8 ++++- 10 files changed, 59 insertions(+), 81 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/index.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/index.ts index 88b0e44..329f1c2 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/index.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/index.ts @@ -30,7 +30,7 @@ import { import { MaterialModule } from '../../shared/material.module'; import { ManagementComponent } from './management.component'; -import { ManagementGridComponent, ConfirmationDialogComponent } from './management-grid/management-grid.component'; +import { ManagementGridComponent, ReconfirmationDialogComponent } from './management-grid/management-grid.component'; import { ComputationalResourcesModule } from '../../resources/computational/computational-resources-list'; import { FormControlsModule } from '../../shared/form-controls'; @@ -65,13 +65,13 @@ export * from './management.component'; ManagementGridComponent, BackupDilogComponent, ManageEnvironmentComponent, - ConfirmationDialogComponent, + ReconfirmationDialogComponent, ConfirmActionDialogComponent, SsnMonitorComponent, EndpointsComponent ], entryComponents: [ - ConfirmationDialogComponent, + ReconfirmationDialogComponent, ConfirmActionDialogComponent, BackupDilogComponent, SsnMonitorComponent, diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html index 6b8bb95..8694e96 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.html @@ -155,7 +155,6 @@ </table> </ng-template> -<confirmation-dialog #confirmationDialog [manageAction]="isAdmin" (buildGrid)="buildGrid()"></confirmation-dialog> <key-upload-dialog #keyReuploadDialog [primaryUploading]="false" (checkInfrastructureCreationProgress)="buildGrid()" (generateUserKey)="generateUserKey()"> </key-upload-dialog> \ No newline at end of file diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts index 7cc28e8..0c630df 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.ts @@ -24,6 +24,7 @@ import { ToastrService } from 'ngx-toastr'; import { HealthStatusService, UserAccessKeyService } from '../../../core/services'; import { ConfirmationDialogType } from '../../../shared'; import { FileUtils } from '../../../core/util'; +import { ConfirmationDialogComponent } from '../../../shared/modal-dialog/confirmation-dialog/confirmation-dialog.component'; export interface ManageAction { action: string; @@ -51,7 +52,6 @@ export class ManagementGridComponent implements OnInit { @Output() refreshGrid: EventEmitter<{}> = new EventEmitter(); @Output() actionToggle: EventEmitter<ManageAction> = new EventEmitter(); - @ViewChild('confirmationDialog') confirmationDialog; @ViewChild('keyReuploadDialog') keyReuploadDialog; constructor( @@ -71,7 +71,7 @@ export class ManagementGridComponent implements OnInit { toggleResourceAction(environment, action: string, resource?) { if (resource) { const resource_name = resource ? resource.computational_name : environment.name; - const dialogRef: MatDialogRef<ConfirmationDialogComponent> = this.dialog.open(ConfirmationDialogComponent, { + const dialogRef: MatDialogRef<ReconfirmationDialogComponent> = this.dialog.open(ReconfirmationDialogComponent, { data: { action, resource_name, user: environment.user }, width: '550px', panelClass: 'error-modalbox' @@ -80,16 +80,17 @@ export class ManagementGridComponent implements OnInit { result && this.actionToggle.emit({ action, environment, resource }); }); } else { + const type = (environment.name === 'edge node' || environment.type.toLowerCase() === 'edge node') + ? ConfirmationDialogType.StopEdgeNode : ConfirmationDialogType.StopExploratory; + if (action === 'stop') { - this.confirmationDialog.open( - { isFooter: false }, - environment, - (environment.name === 'edge node' || environment.type.toLowerCase() === 'edge node') - ? ConfirmationDialogType.StopEdgeNode - : ConfirmationDialogType.StopExploratory, - ); + this.dialog.open(ConfirmationDialogComponent, { + data: { notebook: environment, type: type, manageAction: this.isAdmin }, panelClass: 'modal-md' + }); } else if (action === 'terminate') { - this.confirmationDialog.open({ isFooter: false }, environment, ConfirmationDialogType.TerminateExploratory); + this.dialog.open(ConfirmationDialogComponent, { + data: { notebook: environment, type: ConfirmationDialogType.TerminateExploratory, manageAction: this.isAdmin } + }); } else if (action === 'run') { this.healthStatusService .runEdgeNode() @@ -164,9 +165,9 @@ export class ManagementGridComponent implements OnInit { styles: [ ] }) -export class ConfirmationDialogComponent { +export class ReconfirmationDialogComponent { constructor( - public dialogRef: MatDialogRef<ConfirmationDialogComponent>, + public dialogRef: MatDialogRef<ReconfirmationDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any ) {} } diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts index 8f75eea..81bffe3 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts @@ -56,7 +56,6 @@ export class DetailDialogComponent implements OnInit { } ngOnInit() { - // this.dialogRef.beforeClosed().subscribe(() => this.resetDialog()); this.notebook; if (this.notebook) { diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html index 4126a52..2c4e497 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.html @@ -152,12 +152,3 @@ </td> </tr> </table> - -<!-- <detail-dialog #detailDialog (buildGrid)="buildGrid()"></detail-dialog> --> - -<!-- <computational-resource-create-dialog #computationalResourceModal (buildGrid)="buildGrid()"></computational-resource-create-dialog> --> -<confirmation-dialog #confirmationDialog (buildGrid)="buildGrid()"></confirmation-dialog> -<!-- <cost-details-dialog #costDetailsDialog></cost-details-dialog> --> -<!-- <install-libraries #installLibs (buildGrid)="buildGrid()"></install-libraries> --> -<!-- <dlab-scheduler #envScheduler (buildGrid)="buildGrid()"></dlab-scheduler> --> -<!-- <dlab-ami-create-dialog #createAmi (buildGrid)="buildGrid()"></dlab-ami-create-dialog> --> diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts index aa76c91..6bf5402 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts @@ -18,7 +18,7 @@ */ /* tslint:disable:no-empty */ -import { Component, ViewChild, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ToastrService } from 'ngx-toastr'; import { MatDialog } from '@angular/material'; @@ -34,6 +34,7 @@ import { AmiCreateDialogComponent } from '../exploratory/ami-create-dialog'; import { InstallLibrariesComponent } from '../exploratory/install-libraries'; import { ComputationalResourceCreateDialogComponent } from '../computational/computational-resource-create-dialog/computational-resource-create-dialog.component'; import { CostDetailsDialogComponent } from '../exploratory/cost-details-dialog'; +import { ConfirmationDialogComponent } from '../../shared/modal-dialog/confirmation-dialog'; import { SchedulerComponent } from '../scheduler'; import { DICTIONARY } from '../../../dictionary/global.dictionary'; @@ -52,7 +53,6 @@ export class ResourcesGridComponent implements OnInit { filterConfiguration: FilterConfigurationModel; filterForm: FilterConfigurationModel = new FilterConfigurationModel('', [], [], [], ''); model = new CreateResourceModel('', ''); - notebookName: string; isOutscreenDropdown: boolean; collapseFilterRow: boolean = false; filtering: boolean = false; @@ -60,12 +60,6 @@ export class ResourcesGridComponent implements OnInit { healthStatus: GeneralEnvironmentStatus; delimitersRegex = /[-_]?/g; - // @ViewChild('computationalResourceModal') computationalResourceModal; - @ViewChild('confirmationDialog') confirmationDialog; - @ViewChild('detailDialog') detailDialog; - @ViewChild('costDetailsDialog') costDetailsDialog; - // @ViewChild('envScheduler') scheduler; - public filteringColumns: Array<any> = [ { title: 'Environment name', name: 'name', className: 'th_name', filtering: {} }, { title: 'Status', name: 'statuses', className: 'th_status', filtering: {} }, @@ -281,7 +275,6 @@ export class ResourcesGridComponent implements OnInit { } printDetailEnvironmentModal(data): void { - // this.detailDialog.open({ isFooter: false }, data); this.dialog.open(DetailDialogComponent, { data: data, panelClass: 'modal-lg' }) .afterClosed().subscribe(() => this.buildGrid()); } @@ -293,9 +286,6 @@ export class ResourcesGridComponent implements OnInit { exploratoryAction(data, action: string) { if (action === 'deploy') { - this.notebookName = data.name; - // this.computationalResourceModal.open({ isFooter: false }, data, this.environments); - this.dialog.open(ComputationalResourceCreateDialogComponent, { data: { notebook: data, full_list: this.environments}, panelClass: 'modal-xxl'}) .afterClosed().subscribe(() => this.buildGrid()); } else if (action === 'run') { @@ -305,14 +295,15 @@ export class ResourcesGridComponent implements OnInit { () => this.buildGrid(), error => this.toastr.error(error.message || 'Exploratory starting failed!', 'Oops!')); } else if (action === 'stop') { - this.confirmationDialog.open({ isFooter: false }, data, ConfirmationDialogType.StopExploratory); + this.dialog.open(ConfirmationDialogComponent, { data: { notebook: data, type: ConfirmationDialogType.StopExploratory }, panelClass: 'modal-sm'}) + .afterClosed().subscribe(() => this.buildGrid()); } else if (action === 'terminate') { - this.confirmationDialog.open({ isFooter: false }, data, ConfirmationDialogType.TerminateExploratory); + this.dialog.open(ConfirmationDialogComponent, {data: { notebook: data, type: ConfirmationDialogType.TerminateExploratory }, panelClass: 'modal-sm'}) + .afterClosed().subscribe(() => this.buildGrid()); } else if (action === 'install') { this.dialog.open(InstallLibrariesComponent, { data: data, panelClass: 'modal-fullscreen' }) .afterClosed().subscribe(() => this.buildGrid()); } else if (action === 'schedule') { - // this.scheduler.open({ isFooter: false }, data, 'EXPLORATORY'); this.dialog.open(SchedulerComponent, { data: {notebook: data, type: 'EXPLORATORY'}, panelClass: 'modal-xl-s' }) .afterClosed().subscribe(() => this.buildGrid()); } else if (action === 'ami') { diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.html b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.html index d9ba880..a19d773 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.html @@ -17,8 +17,8 @@ ~ under the License. --> -<modal-dialog #bindDialog modalClass="confirmation-dialog modal-md"> - <modal-header> +<div id="dialog-box" class="confirmation-dialog"> + <header class="dialog-header"> <h4 class="modal-title"> <span *ngIf="model.notebook.name && model.notebook.name !== 'edge node'"> <span>{{ confirmationType ? 'Terminate' : 'Stop' }} notebook: {{ model.notebook.name }}</span> @@ -27,12 +27,14 @@ <i class="material-icons">priority_high</i>Warning </span> </h4> - </modal-header> - <modal-content> + <button type="button" class="close" (click)="dialogRef.close()">×</button> + </header> + <div class="dialog-content"> <div class="content-box"> <p class="info text-center">{{ model.title }}</p> - <mat-list class="resources" [hidden]="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node' + <mat-list class="resources" + [hidden]="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node' || !model.notebook.resources || model.notebook.resources.length === 0 || (!isAliveResources && !confirmationType) || onlyKilled"> <mat-list-item class="list-header"> <div class="cluster">Cluster</div> @@ -41,23 +43,23 @@ </mat-list-item> <div class="scrolling-content" id="scrolling"> <mat-list-item *ngFor="let resource of model.notebook.resources" - [hidden]="resource.status === 'failed' || resource.status === 'terminated' || resource.status === 'terminating' || (resource.status === 'stopped' && !confirmationType)"> + [hidden]="resource.status === 'failed' || resource.status === 'terminated' || resource.status === 'terminating' || (resource.status === 'stopped' && !confirmationType)"> <div class="cluster ellipsis">{{ resource.computational_name }}</div> <div class="status" [ngClass]="{ 'stopped': !confirmationType && resource.image === 'docker.dlab-dataengine', - 'terminated': resource.image === 'docker.dlab-dataengine-service' || confirmationType }">{{ (!confirmationType && resource.image === 'docker.dlab-dataengine') ? 'Stopped' : 'Terminated' }}</div> + 'terminated': resource.image === 'docker.dlab-dataengine-service' || confirmationType }"> + {{ (!confirmationType && resource.image === 'docker.dlab-dataengine') ? 'Stopped' : 'Terminated' }}</div> <div class="size">{{ resource[DICTIONARY[resource.image].master_node_shape] }}</div> </mat-list-item> </div> </mat-list> <div class="text-center m-top-20"> - <p *ngIf="model.notebook.name">Do you want to proceed?</p> - <p *ngIf="model.notebook.type">Are you sure you want to continue?</p> + <p>Do you want to proceed?</p> </div> <div class="text-center m-top-20"> - <button mat-raised-button type="button" class="butt action" (click)="bindDialog.close()">No</button> + <button mat-raised-button type="button" class="butt action" (click)="dialogRef.close()">No</button> <button mat-raised-button type="button" class="butt butt-success action" (click)="confirm()">Yes</button> </div> </div> - </modal-content> -</modal-dialog> + </div> +</div> \ No newline at end of file diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.ts index c1fe712..fda9525 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.ts @@ -17,8 +17,9 @@ * under the License. */ -import { Component, OnInit, ViewChild, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core'; +import { Component, OnInit, Inject, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core'; import { ToastrService } from 'ngx-toastr'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; import { ConfirmationDialogModel } from './confirmation-dialog.model'; import { ConfirmationDialogType } from './confirmation-dialog-type.enum'; @@ -35,19 +36,22 @@ import { DICTIONARY } from '../../../../dictionary/global.dictionary'; export class ConfirmationDialogComponent implements OnInit { readonly DICTIONARY = DICTIONARY; + model: ConfirmationDialogModel; isAliveResources: boolean; onlyKilled: boolean = false; + notebook: any; dataengines: Array<any> = []; dataengineServices: Array<any> = []; confirmationType: number = 0; - @ViewChild('bindDialog') bindDialog; @Input() manageAction: boolean = false; @Output() buildGrid: EventEmitter<{}> = new EventEmitter(); constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef<ConfirmationDialogComponent>, private userResourceService: UserResourceService, private healthStatusService: HealthStatusService, private manageEnvironmentsService: ManageEnvironmentsService, @@ -57,38 +61,27 @@ export class ConfirmationDialogComponent implements OnInit { } ngOnInit() { - this.bindDialog.onClosing = () => this.resetDialog(); - } - - public open(param, notebook: any, type: ConfirmationDialogType) { - this.confirmationType = type; - - this.model = new ConfirmationDialogModel(type, notebook, + this.confirmationType = this.data.type; + this.notebook = this.data.notebook; + this.model = new ConfirmationDialogModel(this.confirmationType, this.notebook, response => { - if (response.status === HTTP_STATUS_CODES.OK) { - this.close(); - this.buildGrid.emit(); - } + if (response.status === HTTP_STATUS_CODES.OK) this.dialogRef.close(); }, error => this.toastr.error(error.message || 'Action failed!', 'Oops'), - this.manageAction, + this.data.manageAction, this.userResourceService, this.healthStatusService, this.manageEnvironmentsService); - this.bindDialog.open(param); - if (!this.confirmationType) this.filterResourcesByType(notebook.resources); - this.isAliveResources = this.model.isAliveResources(notebook.resources); - this.onlyKilled = notebook.resources ? !notebook.resources.some(el => el.status !== 'terminated') : false; + if (!this.confirmationType) this.filterResourcesByType(this.notebook.resources); + this.isAliveResources = this.model.isAliveResources(this.notebook.resources); + this.onlyKilled = this.notebook.resources ? !this.notebook.resources.some(el => el.status !== 'terminated') : false; } + public confirm() { this.model.confirmAction(); } - public close() { - this.bindDialog.close(); - } - private filterResourcesByType(resources) { resources .filter(resource => @@ -97,9 +90,4 @@ export class ConfirmationDialogComponent implements OnInit { .forEach(resource => { (resource.image === 'docker.dlab-dataengine') ? this.dataengines.push(resource) : this.dataengineServices.push(resource); }); } - - private resetDialog(): void { - this.dataengines = []; - this.dataengineServices = []; - } } diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/index.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/index.ts index 2790f28..331a072 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/index.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/index.ts @@ -30,6 +30,7 @@ export * from './confirmation-dialog-type.enum'; @NgModule({ imports: [CommonModule, ModalModule, MaterialModule], declarations: [ConfirmationDialogComponent], + entryComponents: [ConfirmationDialogComponent], exports: [ConfirmationDialogComponent] }) export class ConfirmationDialogModule {} diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/progress-dialog/progress-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/progress-dialog/progress-dialog.component.ts index 48f6cb5..9e2c7ad 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/progress-dialog/progress-dialog.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/progress-dialog/progress-dialog.component.ts @@ -17,7 +17,8 @@ * under the License. */ -import { Component, OnInit, ViewChild, Input } from '@angular/core'; +import { Component, OnInit, Input, Inject } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; @Component({ selector: 'progress-dialog', @@ -27,6 +28,11 @@ import { Component, OnInit, ViewChild, Input } from '@angular/core'; export class ProgressDialogComponent implements OnInit { @Input() theBoundCallback: Function; + constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef<ProgressDialogComponent>, + ) { } + ngOnInit() { if (this.theBoundCallback) this.theBoundCallback(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org