This is an automated email from the ASF dual-hosted git repository. dgnatyshyn pushed a commit to branch DLAB-1579 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 01c10cb3056f2ce72cfe40cde8f6f1463bab5fcf Author: Dmytro Gnatyshyn <[email protected]> AuthorDate: Tue Mar 3 11:15:25 2020 +0200 [DLAB-1579]: Added confirmation dialog with information about termination users instances --- .../app/administration/roles/roles.component.ts | 51 ++++++++++++++++++---- .../reporting-grid/reporting-grid.component.html | 1 - .../src/app/reporting/reporting.component.ts | 4 +- .../resources-grid/resources-grid.component.scss | 1 + .../confirmation-dialog-type.enum.ts | 21 ++++++++- .../confirmation-dialog.component.html | 9 ++-- .../webapp/src/assets/styles/_dialogs.scss | 6 +++ .../webapp/src/dictionary/azure.dictionary.ts | 4 +- 8 files changed, 78 insertions(+), 19 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts index cf2f086..53a3a67 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts @@ -25,7 +25,8 @@ import { ToastrService } from 'ngx-toastr'; import { RolesGroupsService, HealthStatusService } from '../../core/services'; import { CheckUtils } from '../../core/util'; import { DICTIONARY } from '../../../dictionary/global.dictionary'; -import {ProgressBarService} from "../../core/services/progress-bar.service"; +import {ProgressBarService} from '../../core/services/progress-bar.service'; +import {ConfirmationDialogComponent, ConfirmationDialogType} from '../../shared/modal-dialog/confirmation-dialog'; @Component({ selector: 'dlab-roles', @@ -46,10 +47,12 @@ export class RolesComponent implements OnInit { public healthStatus: any; public delimitersRegex = /[-_]?/g; public groupnamePattern = new RegExp(/^[a-zA-Z0-9_\-]+$/); + public deletedUsers = []; stepperView: boolean = false; displayedColumns: string[] = ['name', 'roles', 'users', 'actions']; @Output() manageRolesGroupAction: EventEmitter<{}> = new EventEmitter(); + private startedGroups; constructor( public toastr: ToastrService, @@ -65,18 +68,18 @@ export class RolesComponent implements OnInit { } openManageRolesDialog() { - setTimeout(() => {this.progressBarService.startProgressBar()} , 0); + setTimeout(() => {this.progressBarService.startProgressBar(); } , 0); this.rolesService.getGroupsData().subscribe(groups => { this.rolesService.getRolesData().subscribe( (roles: any) => { this.roles = roles; this.rolesList = roles.map(role => role.description); this.updateGroupData(groups); - + this.getGroupsListCopy(); this.stepperView = false; }, error => this.toastr.error(error.message, 'Oops!')); - this.progressBarService.stopProgressBar() + this.progressBarService.stopProgressBar(); }, error => { this.toastr.error(error.message, 'Oops!'); @@ -142,10 +145,29 @@ export class RolesComponent implements OnInit { }, () => this.toastr.error('Group creation failed!', 'Oops!')); break; case 'update': - this.rolesService.updateGroup($event.value).subscribe(res => { - this.toastr.success('Group data successfully updated!', 'Success!'); - this.getGroupsData(); - }, () => this.toastr.error('Failed group data updating!', 'Oops!')); + const currGroup = this.startedGroups.filter(group => group.group === $event.value.name); + const deletedUsers = currGroup[0].users.filter(user => { + if ($event.value.users.includes(user)) { + return false; + } else { + return true; + } + }); + if (deletedUsers.length) { + this.dialog.open(ConfirmationDialogComponent, { data: + { notebook: deletedUsers, type: ConfirmationDialogType.deleteUser }, panelClass: 'modal-sm' }) + .afterClosed().subscribe((res) => { + if (!res) { + $event.value.users = $event.value.users.concat(deletedUsers); + this.updateGroup($event.value, ', but users did\'t delete from group'); + } else { + this.updateGroup($event.value, ''); + } + }); + } else { + this.updateGroup($event.value, ''); + } + break; case 'delete': if ($event.type === 'users') { @@ -171,13 +193,24 @@ export class RolesComponent implements OnInit { }, []); } + public updateGroup(value, extraMesssage){ + this.rolesService.updateGroup(value).subscribe(res => { + this.toastr.success(`Group data successfully updated${extraMesssage}!`, 'Success!'); + this.getGroupsData(); + }, () => this.toastr.error('Failed group data updating!', 'Oops!')); + } + public updateGroupData(groups) { - this.groupsData = groups.map(v=>v).sort((a,b) => (a.group > b.group) ? 1 : ((b.group > a.group) ? -1 : 0)); + this.groupsData = groups.map(v => v).sort((a, b) => (a.group > b.group) ? 1 : ((b.group > a.group) ? -1 : 0)); this.groupsData.forEach(item => { item.selected_roles = item.roles.map(role => role.description); }); } + private getGroupsListCopy() { + this.startedGroups = this.groupsData.map(env => JSON.parse(JSON.stringify(env))); + } + public groupValidarion(): ValidatorFn { const duplicateList: any = this.groupsData.map(item => item.group.toLowerCase()); return <ValidatorFn>((control: FormControl) => { diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html index 1f5513d..f812780 100644 --- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html @@ -209,7 +209,6 @@ </td> </ng-container> - <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true" class="header-row"></tr> <tr [hidden]="!collapseFilterRow || !PROVIDER" mat-header-row *matHeaderRowDef="displayedFilterColumns; sticky: true" diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts index 2737ea7..51cca06 100644 --- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts @@ -100,13 +100,13 @@ export class ReportingComponent implements OnInit, OnDestroy { } } }, e => { - this.PROVIDER = 'gcp'; + this.PROVIDER = 'azure'; if (this.PROVIDER) { this.rebuildBillingReport(); } }) ; } else { - this.PROVIDER = 'gcp'; + this.PROVIDER = 'azure'; if (this.PROVIDER) { this.rebuildBillingReport(); } diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.scss b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.scss index 86ec9bf..57abbc1 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.scss +++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.scss @@ -227,6 +227,7 @@ tr.detail-row { .filter-row .actions { text-align: right; display: flex; + justify-content: flex-end; } .filter-row .actions button { diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog-type.enum.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog-type.enum.ts index 701f03f..fe5068a 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog-type.enum.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog-type.enum.ts @@ -17,9 +17,28 @@ * under the License. */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ export enum ConfirmationDialogType { StopExploratory = 0, TerminateExploratory = 1, TerminateComputationalResources = 2, - StopEdgeNode = 3 + StopEdgeNode = 3, + deleteUser = 4, } 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 30155fe..b1fd8ba 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 @@ -23,7 +23,7 @@ <span *ngIf="model.notebook.name && model.notebook.name !== 'edge node'"> <span>{{ confirmationType ? 'Terminate' : 'Stop' }} notebook: {{ model.notebook.name }}</span> </span> - <span *ngIf="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node'"> + <span *ngIf="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node' || data.type === 4"> <i class="material-icons">priority_high</i>Warning </span> </h4> @@ -31,8 +31,8 @@ </header> <div class="dialog-content"> <div class="content-box"> - <p class="info text-center">{{ model.title }}</p> - + <p *ngIf="data.type !== 4" class="info text-center">{{ model.title }}</p> + <p *ngIf="data.type === 4" class="text-center delete-user">User<span *ngIf="data.notebook.length>1">s</span> <span class="strong"> {{data.notebook.join(', ')}} </span>will be deleted from this group. All <span *ngIf="data.notebook.length===1">his</span><span *ngIf="data.notebook.length>1">their</span> resources authorized within this group will be terminated.</p> <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"> @@ -58,7 +58,8 @@ </div> <div class="text-center m-top-20"> <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> + <button *ngIf="data.type !== 4" mat-raised-button type="button" class="butt butt-success action" (click)="confirm()">Yes</button> + <button *ngIf="data.type === 4" mat-raised-button type="button" class="butt butt-success action" (click)="dialogRef.close(true)">Yes</button> </div> </div> </div> diff --git a/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss b/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss index f1fa89f..fb144a6 100644 --- a/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss +++ b/services/self-service/src/main/resources/webapp/src/assets/styles/_dialogs.scss @@ -335,6 +335,12 @@ mat-dialog-container { top: 49%; } +.confirmation-dialog p.delete-user{ + font-weight: 500; + max-height: 200px; + overflow: auto; +} + @media screen and (max-width: 1280px) { .modal-fullscreen { max-width: 100vw !important; diff --git a/services/self-service/src/main/resources/webapp/src/dictionary/azure.dictionary.ts b/services/self-service/src/main/resources/webapp/src/dictionary/azure.dictionary.ts index be25a2c..8abbb01 100644 --- a/services/self-service/src/main/resources/webapp/src/dictionary/azure.dictionary.ts +++ b/services/self-service/src/main/resources/webapp/src/dictionary/azure.dictionary.ts @@ -34,9 +34,9 @@ export const NAMING_CONVENTION_AZURE = { 'max_cluster_name_length': 10, 'billing': { 'resourceName': 'resourceName', - 'cost': 'costString', + 'cost': 'cost', 'costTotal': 'cost_total', - 'currencyCode': 'currencyCode', + 'currencyCode': 'currency_code', 'dateFrom': 'from', 'dateTo': 'to', 'service': 'meterCategory', --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
