This is an automated email from the ASF dual-hosted git repository. dgnatyshyn pushed a commit to branch DLAB-1618 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 5f9db95f6278bf17bc6a60ada2fe6c2e331a2e7d Author: Dmytro Gnatyshyn <[email protected]> AuthorDate: Wed Mar 11 17:52:33 2020 +0200 [DLAB-1618]: Adjusted role page according to requirements --- .../app/administration/roles/roles.component.html | 20 +++--- .../app/administration/roles/roles.component.scss | 14 +++- .../app/administration/roles/roles.component.ts | 84 +++++++++++++--------- .../confirmation-dialog.component.html | 10 ++- .../confirmation-dialog.component.scss | 3 + 5 files changed, 83 insertions(+), 48 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html index 0a7c8e2..d5496ac 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html @@ -131,15 +131,17 @@ <ng-container matColumnDef="actions"> <th mat-header-cell *matHeaderCellDef class="actions"></th> <td mat-cell *matCellDef="let element" class="actions"> - <span (click)="manageAction('delete', 'group', element)" class="reset ani"> - <mat-icon>delete_forever</mat-icon> - </span> - <span class="apply ani" matTooltip="Group cannot be updated without any selected role" - matTooltipPosition="above" [matTooltipDisabled]="element.selected_roles.length > 0" - [ngClass]="{ 'not-allowed' : !element.selected_roles.length }" - (click)="manageAction('update', 'group', element)"> - <mat-icon>done</mat-icon> - </span> + <div class="actions-wrapper"> + <span (click)="manageAction('delete', 'group', element)" class="reset ani"> + <mat-icon>delete_forever</mat-icon> + </span> + <span class="apply ani big-icon" matTooltip="Group cannot be updated without any selected role" + matTooltipPosition="above" [matTooltipDisabled]="element.selected_roles.length > 0" + [ngClass]="{ 'not-allowed' : !element.selected_roles.length || isGroupChanded(element)}" + (click)="manageAction('update', 'group', element)"> + <mat-icon [ngClass]="{'big-icon': !isGroupChanded(element) && element.selected_roles.length}">done</mat-icon> + </span> + </div> </td> </ng-container> diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.scss b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.scss index f2c10d8..66b1898 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.scss +++ b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.scss @@ -359,14 +359,24 @@ table { color: #607d8b; width: 10%; text-align: center; - + .actions-wrapper{ + height: 41px; + display: flex; + align-items: center; + justify-content: flex-end; + } span { - transition: all .5s ease-in-out; + transition: all .35s ease-in-out; cursor: pointer; .mat-icon { font-size: 18px; padding-top: 12px; + &.big-icon{ + font-size: 25px; + padding-top: 10px; + transition: .25s; + } } &:hover { 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 01ff281..dd584dd 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 @@ -27,6 +27,7 @@ import { CheckUtils } from '../../core/util'; import { DICTIONARY } from '../../../dictionary/global.dictionary'; import {ProgressBarService} from '../../core/services/progress-bar.service'; import {ConfirmationDialogComponent, ConfirmationDialogType} from '../../shared/modal-dialog/confirmation-dialog'; +import {logger} from 'codelyzer/util/logger'; @Component({ @@ -127,12 +128,31 @@ export class RolesComponent implements OnInit { } }); } else if (action === 'update') { - this.manageRolesGroups({ - action, type, value: { - name: item.group, - roleIds: this.extractIds(this.roles, item.selected_roles.map(v => v.role)), - users: item.users || [] + const currGroupSource = this.startedGroups.filter(cur => cur.group === item.group)[0]; + let deletedUsers = currGroupSource.users.filter(user => { + if (item.users.includes(user)) { + return false; } + return true; + }); + this.dialog.open(ConfirmationDialogComponent, { data: + { notebook: deletedUsers, type: ConfirmationDialogType.deleteUser }, panelClass: 'modal-sm' }) + .afterClosed().subscribe((res) => { + if (!res) { + item.users = [...currGroupSource.users]; + item.selected_roles = [...currGroupSource.selected_roles]; + item.roles = [...currGroupSource.roles]; + } else { + this.manageRolesGroups({ + action, type, value: { + name: item.group, + roleIds: this.extractIds(this.roles, item.selected_roles.map(v => v.role)), + users: item.users || [] + } + }); + this.openManageRolesDialog(); + } + deletedUsers = []; }); } this.getEnvironmentHealthStatus(); @@ -142,36 +162,21 @@ export class RolesComponent implements OnInit { public manageRolesGroups($event) { switch ($event.action) { case 'create': + this.rolesService.setupNewGroup($event.value).subscribe(res => { this.toastr.success('Group creation success!', 'Created!'); this.getGroupsData(); }, () => this.toastr.error('Group creation failed!', 'Oops!')); break; + case 'update': - 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, ''); - } + this.rolesService.updateGroup($event.value).subscribe(res => { + this.toastr.success(`Group data is updated successfully!`, 'Success!'); + this.getGroupsData(); + }, () => this.toastr.error('Failed group data updating!', 'Oops!')); break; + case 'delete': if ($event.type === 'users') { this.rolesService.removeUsersForGroup($event.value).subscribe(res => { @@ -185,6 +190,7 @@ export class RolesComponent implements OnInit { }, (error) => this.toastr.error(error.message, 'Oops!')); } break; + default: } } @@ -196,13 +202,6 @@ 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.forEach(item => { @@ -211,7 +210,7 @@ export class RolesComponent implements OnInit { } private getGroupsListCopy() { - this.startedGroups = this.groupsData.map(env => JSON.parse(JSON.stringify(env))); + this.startedGroups = JSON.parse(JSON.stringify(this.groupsData)); } public groupValidarion(): ValidatorFn { @@ -228,6 +227,21 @@ export class RolesComponent implements OnInit { }); } + private isGroupChanded(currGroup) { + const currGroupSource = this.startedGroups.filter(cur => cur.group === currGroup.group)[0]; + if (currGroup.users.length !== currGroupSource.users.length && + currGroup.selected_roles.length !== currGroupSource.selected_roles.length) { + return false; + } + return JSON.stringify(currGroup.users) === JSON.stringify(currGroupSource.users) && + JSON.stringify( + currGroup.selected_roles.map(role => role.role).sort() + ) === JSON + .stringify( + currGroupSource.selected_roles.map(role => role.role).sort() + ); + } + public resetDialog() { this.stepperView = false; this.setupGroup = ''; 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 b1fd8ba..9bb12e7 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,16 +23,22 @@ <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' || data.type === 4"> + <span *ngIf="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node' || data.type === 4 && data.notebook.length"> <i class="material-icons">priority_high</i>Warning </span> + <span *ngIf="data.type === 4 && !data.notebook.length"> + Update group data + </span> </h4> <button type="button" class="close" (click)="dialogRef.close()">×</button> </header> <div class="dialog-content"> <div class="content-box"> <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> + <div *ngIf="data.type === 4" class="text-center m-bot-20"> + <h3 class="strong">Group data will be updated.</h3> + </div> + <p *ngIf="data.type === 4 && data.notebook.length" 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"> diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.scss b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.scss index 305c504..c71e2ed 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.scss +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.component.scss @@ -18,6 +18,9 @@ */ .confirmation-dialog { + h3{ + margin-bottom: 20px; + } color: #718ba6; p { font-size: 14px; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
