This is an automated email from the ASF dual-hosted git repository. dgnatyshyn pushed a commit to branch DLAB-1861 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit d4b1d867c75f5bfd7c730a6f529a789c89fc69a6 Author: Dmytro_Gnatyshyn <[email protected]> AuthorDate: Thu Jun 11 15:28:41 2020 +0300 [DLAB-1861]: Added actions to checkboxes environment management --- .../management-grid/management-grid.component.html | 2 +- .../management-grid/management-grid.component.ts | 38 ++----------- .../management/management.component.html | 35 +++++++++++- .../management/management.component.ts | 64 ++++++++++++++++++++++ .../resources/webapp/src/assets/styles/_theme.scss | 50 +++++++++++++++++ 5 files changed, 155 insertions(+), 34 deletions(-) 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 56fd4c5..a7f217a 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 @@ -23,7 +23,7 @@ <th mat-header-cell *matHeaderCellDef class="checkbox label-header"> </th> <td mat-cell *matCellDef="let element"> - <div *ngIf="element.type !== 'edge node'" class="empty-checkbox" [ngClass]="{'checked': element.isSelected}" (click)="toggleActionForAll(element);$event.stopPropagation()" > + <div *ngIf="element.type !== 'edge node' && (element.status==='running' || element.status==='stopped')" class="empty-checkbox" [ngClass]="{'checked': element.isSelected}" (click)="toggleActionForAll(element);$event.stopPropagation()" > <span class="checked-checkbox" *ngIf="element.isSelected"></span> </div> </td> 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 0403c69..b0295e2 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 @@ -60,9 +60,11 @@ export class ManagementGridComponent implements OnInit { @Input() currentUser: string = ''; @Output() refreshGrid: EventEmitter<{}> = new EventEmitter(); @Output() actionToggle: EventEmitter<ManageAction> = new EventEmitter(); + @Output() emitSelectedList: EventEmitter<ManageAction> = new EventEmitter(); displayedColumns: string[] = [ 'checkbox', 'user', 'type', 'project', 'shape', 'status', 'resources', 'actions']; displayedFilterColumns: string[] = ['checkbox-filter', 'user-filter', 'type-filter', 'project-filter', 'shape-filter', 'status-filter', 'resource-filter', 'actions-filter']; + private selected; constructor( private healthStatusService: HealthStatusService, @@ -151,38 +153,7 @@ export class ManagementGridComponent implements OnInit { } toggleResourceAction(environment: any, action: string, resource?): void { - if (resource) { - const resource_name = resource ? resource.computational_name : environment.name; - this.dialog.open(ReconfirmationDialogComponent, { - data: { action, resource_name, user: environment.user }, - width: '550px', panelClass: 'error-modalbox' - }).afterClosed().subscribe(result => { - result && this.actionToggle.emit({ action, environment, resource }); - }); - } else { - const type = (environment.type.toLowerCase() === 'edge node') - ? ConfirmationDialogType.StopEdgeNode : ConfirmationDialogType.StopExploratory; - - if (action === 'stop') { - this.dialog.open(ConfirmationDialogComponent, { - data: { notebook: environment, type: type, manageAction: true }, panelClass: 'modal-md' - }).afterClosed().subscribe(() => this.buildGrid()); - } else if (action === 'terminate') { - this.dialog.open(ConfirmationDialogComponent, { - data: { notebook: environment, type: ConfirmationDialogType.TerminateExploratory, manageAction: true }, panelClass: 'modal-md' - }).afterClosed().subscribe(() => this.buildGrid()); - } else if (action === 'run') { - this.healthStatusService.runEdgeNode().subscribe(() => { - this.buildGrid(); - this.toastr.success('Edge node is starting!', 'Processing!'); - }, () => this.toastr.error('Edge Node running failed!', 'Oops!')); - } else if (action === 'recreate') { - this.healthStatusService.recreateEdgeNode().subscribe(() => { - this.buildGrid(); - this.toastr.success('Edge Node recreation is processing!', 'Processing!'); - }, () => this.toastr.error('Edge Node recreation failed!', 'Oops!')); - } - } + this.actionToggle.emit({ action, environment, resource }); } isResourcesInProgress(notebook) { @@ -243,6 +214,9 @@ export class ManagementGridComponent implements OnInit { toggleActionForAll(element) { element.isSelected = !element.isSelected; + this.selected = this.allFilteredEnvironmentData.filter(item => !!item.isSelected); + console.log(this.selected); + this.emitSelectedList.emit(this.selected) } } diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.html index 4c4bdae..2509429 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.html @@ -20,6 +20,39 @@ <div class="base-retreat"> <div class="sub-nav"> <div *ngIf="healthStatus?.admin" class="admin-group"> + <div class="action-wrapper admin-group" > + <span class="action-button-wrapper"> + <button + type="button" class="butt actions-btn" + mat-raised-button + [disabled]="!selected.length" + (click)="toogleActions();$event.stopPropagation()" + > + Actions + <i class="material-icons" >{{ !isActionsOpen ? 'expand_more' : 'expand_less' }}</i> + </button> + </span> + <div class="action-menu" *ngIf="isActionsOpen"> + <span> + <button + type="button" class="butt action-menu-item" + [ngClass]="{'disabled': selectedRunning.length === 0 || selectedStopped.length !== 0 }" + mat-raised-button + [disabled]="selectedRunning.length === 0 || selectedStopped.length !== 0" + (click)="resourseAction('stop');$event.stopPropagation()" + > + Stop + </button> + </span> + <button + type="button" class="butt action-menu-item" + mat-raised-button + (click)="resourseAction('terminate');$event.stopPropagation()" + > + Terminate + </button> + </div> + </div> <button mat-raised-button class="butt ssn" (click)="showEndpointsDialog()"> <i class="material-icons"></i>Endpoints </button> @@ -40,6 +73,6 @@ <mat-divider></mat-divider> <management-grid [currentUser]="user.toLowerCase()" [isAdmin]="healthStatus?.admin" [environmentsHealthStatuses]="healthStatus?.list_resources" (refreshGrid)="buildGrid()" - (actionToggle)="manageEnvironmentAction($event)"> + (actionToggle)="toggleResourceAction($event)" (emitSelectedList)="selectedList($event)"> </management-grid> </div> diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts index 87e554d..2c3813a 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.component.ts @@ -39,6 +39,8 @@ import { ExploratoryModel } from '../../resources/resources-grid/resources-grid. import { EnvironmentsDataService } from './management-data.service'; import { ProjectService } from '../../core/services'; +import {ConfirmationDialogComponent, ConfirmationDialogType} from '../../shared/modal-dialog/confirmation-dialog'; +import {ReconfirmationDialogComponent} from './management-grid/management-grid.component'; @Component({ selector: 'environments-management', @@ -50,6 +52,10 @@ export class ManagementComponent implements OnInit { public healthStatus: GeneralEnvironmentStatus; // public anyEnvInProgress: boolean = false; public dialogRef: any; + private selected: any[] = []; + public isActionsOpen: boolean = false; + public selectedRunning: any[]; + public selectedStopped: any[]; constructor( public toastr: ToastrService, @@ -171,4 +177,62 @@ export class ManagementComponent implements OnInit { private getTotalBudgetData() { return this.healthStatusService.getTotalBudgetData(); } + + public selectedList($event) { + this.selected = $event; + if (this.selected.length === 0) { + this.isActionsOpen = false; + } + + this.selectedRunning = this.selected.filter(item => item.status === 'running'); + this.selectedStopped = this.selected.filter(item => item.status === 'stopped'); + + console.log(this.selectedRunning.length, this.selectedStopped.length); + } + + public toogleActions() { + this.isActionsOpen = !this.isActionsOpen; + } + + toggleResourceAction($event): void { + const {environment, action, resource} = $event; + if (resource) { + const resource_name = resource ? resource.computational_name : environment.name; + this.dialog.open(ReconfirmationDialogComponent, { + data: { action, resource_name, user: environment.user }, + width: '550px', panelClass: 'error-modalbox' + }).afterClosed().subscribe(result => { + result && this.manageEnvironmentAction({ action, environment, resource }); + }); + } else { + const type = (environment.type.toLowerCase() === 'edge node') + ? ConfirmationDialogType.StopEdgeNode : ConfirmationDialogType.StopExploratory; + + if (action === 'stop') { + this.dialog.open(ConfirmationDialogComponent, { + data: { notebook: environment, type: type, manageAction: true }, panelClass: 'modal-md' + }).afterClosed().subscribe(() => this.buildGrid()); + } else if (action === 'terminate') { + this.dialog.open(ConfirmationDialogComponent, { + data: { notebook: environment, type: ConfirmationDialogType.TerminateExploratory, manageAction: true }, panelClass: 'modal-md' + }).afterClosed().subscribe(() => this.buildGrid()); + } else if (action === 'run') { + this.healthStatusService.runEdgeNode().subscribe(() => { + this.buildGrid(); + this.toastr.success('Edge node is starting!', 'Processing!'); + }, () => this.toastr.error('Edge Node running failed!', 'Oops!')); + } else if (action === 'recreate') { + this.healthStatusService.recreateEdgeNode().subscribe(() => { + this.buildGrid(); + this.toastr.success('Edge Node recreation is processing!', 'Processing!'); + }, () => this.toastr.error('Edge Node recreation failed!', 'Oops!')); + } + } + } + + public resourseAction(action) { + this.selected.forEach(resource => { + this.toggleResourceAction({environment: resource, action: action}); + }) + } } diff --git a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss index 1f80ef0..9c9963f 100644 --- a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss +++ b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss @@ -458,6 +458,56 @@ span.mat-slide-toggle-content { } } +.action-wrapper{ + position: relative; + display: block !important; + + .action-button-wrapper{ + position: relative; + width: 160px; + } + + .mat-raised-button.butt{ + margin-bottom: 0; + + &.actions-btn{ + padding-right: 38px; + + .material-icons{ + transition: ease-in-out 1s; + font-size: 25px; + position: absolute; + top: 7px; + right: 30px; + } + } + } + + .action-menu{ + position: absolute; + text-align: center; + display: block; + background-color: #fff; + + &-item.mat-raised-button.butt{ + z-index: 101; + margin: 0; + box-shadow: 0 2px 1px -1px rgba(0,0,0,.2), 0 0px 0px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12); + width: 160px; + padding: 0 20px; + border-radius: 0; + font-style: normal; + font-weight: 600; + font-size: 15px; + font-family: 'Open Sans', sans-serif; + color: #577289; + position: relative; + overflow: hidden; + line-height: 36px; + } + } +} + mat-horizontal-stepper { .mat-step-header { .mat-step-icon { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
