You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dg...@apache.org on 2020/06/09 12:55:07 UTC

[incubator-dlab] branch DLAB-1579 created (now a123d68)

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a change to branch DLAB-1579
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


      at a123d68  [DLAB-1737]: Alter information messages if remove user from group and if remove group from the project

This branch includes the following new commits:

     new a123d68  [DLAB-1737]: Alter information messages if remove user from group and if remove group from the project

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 01/01: [DLAB-1737]: Alter information messages if remove user from group and if remove group from the project

Posted by dg...@apache.org.
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 a123d68d31598c958b2d90f2235f046a3b52e503
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Tue Jun 9 15:53:16 2020 +0300

    [DLAB-1737]: Alter information messages if remove user from group and if remove group from the project
---
 .../project/project-form/project-form.component.ts | 50 +++++++++++++++++-----
 .../app/administration/roles/roles.component.ts    |  4 +-
 .../confirmation-dialog-type.enum.ts               |  1 +
 .../confirmation-dialog.component.html             | 14 +++---
 .../confirmation-dialog.component.ts               | 30 +++++++------
 .../confirmation-dialog.model.ts                   |  3 ++
 6 files changed, 71 insertions(+), 31 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
index 683e7d7..cfa8f98 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts
@@ -28,8 +28,10 @@ import { ProjectDataService } from '../project-data.service';
 import { CheckUtils, FileUtils, PATTERNS } from '../../../core/util';
 import { Project } from '../project.component';
 import { DICTIONARY } from '../../../../dictionary/global.dictionary';
+import {ConfirmationDialogComponent} from '../../../shared/modal-dialog/confirmation-dialog';
+import {MatDialog} from '@angular/material/dialog';
 
-export interface GenerateKey { privateKey: string, publicKey: string };
+export interface GenerateKey { privateKey: string; publicKey: string; }
 
 @Component({
   selector: 'project-form',
@@ -62,7 +64,8 @@ export class ProjectFormComponent implements OnInit {
     private rolesService: RolesGroupsService,
     private endpointService: EndpointService,
     private userAccessKeyService: UserAccessKeyService,
-    private cd: ChangeDetectorRef
+    private cd: ChangeDetectorRef,
+    public dialog: MatDialog,
   ) { }
 
   ngOnInit() {
@@ -79,12 +82,34 @@ export class ProjectFormComponent implements OnInit {
     }
   }
 
+  private updateProject(data: any) {
+    this.projectService.updateProject(data).subscribe(() => {
+      this.toastr.success('Project updated successfully!', 'Success!');
+      this.update.emit();
+    }, error => this.toastr.error(error.message || 'Project update failed!', 'Oops!'));
+  }
+
   public confirm(data) {
     if (this.item) {
-      this.projectService.updateProject(data).subscribe(() => {
-        this.toastr.success('Project updated successfully!', 'Success!');
-        this.update.emit();
-      }, error => this.toastr.error(error.message || 'Project update failed!', 'Oops!'));
+      const deletedGroups = this.item.groups.filter((v) => !(this.projectForm.value.groups.includes(v)));
+      if (deletedGroups.length) {
+        this.dialog.open(ConfirmationDialogComponent, {
+          data: {notebook: deletedGroups, type: 5, manageAction: true}, panelClass: 'modal-md'
+        }).afterClosed().subscribe((res) => {
+            if (!res) {
+              this.projectForm.patchValue({
+                groups: this.item.groups
+              });
+              return;
+            } else {
+              this.updateProject(data);
+            }
+          }
+        );
+      } else {
+        this.updateProject(data);
+      }
+
     } else {
       this.projectService.createProject(data).subscribe(() => {
         this.toastr.success('Project creation is processing!', 'Success!');
@@ -138,16 +163,19 @@ export class ProjectFormComponent implements OnInit {
     });
   }
 
+
   public selectOptions(list, key, select?) {
-    let filter = key === 'endpoints' ? list.map(el => el.name) : list;
+    const filter = key === 'endpoints' ? list.map(el => el.name) : list;
     this.projectForm.controls[key].setValue(select ? filter : []);
   }
 
-
   private initFormModel(): void {
     this.projectForm = this._fb.group({
       'key': ['', Validators.required],
-      'name': ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.projectName), this.checkDuplication.bind(this), this.providerMaxLength.bind(this)])],
+      'name': ['', Validators.compose([Validators.required,
+        Validators.pattern(PATTERNS.projectName),
+        this.checkDuplication.bind(this),
+        this.providerMaxLength.bind(this)])],
       'endpoints': [[], Validators.required],
       'tag': ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.projectName)])],
       'groups': [[], Validators.required],
@@ -185,7 +213,9 @@ export class ProjectFormComponent implements OnInit {
 
   private getGroupsData() {
     this.rolesService.getGroupsData().subscribe(
-      (list: any) => this.groupsList = list.map(el => el.group),
+      (list: any) => {
+        this.groupsList = list.map(el => el.group);
+      },
       error => this.toastr.error(error.message, 'Oops!'));
   }
 
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 c3fa1a6..0efcb44 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
@@ -297,7 +297,9 @@ export class RolesComponent implements OnInit {
     <button type="button" class="close" (click)="dialogRef.close()">&times;</button>
   </div>
   <div mat-dialog-content class="content">
-    <p *ngIf="data.user">User <span class="strong">{{ data.user }}</span> will be deleted from <span class="strong">{{ data.group }}</span> group.</p>
+
+    <p *ngIf="data.user">User <span class="strong">{{ data.user }}</span> will be deleted from <span class="strong">{{ data.group }}</span> group.
+    </p>
     <p *ngIf="data.id">Group <span class="ellipsis group-name strong">{{ data.group }}</span> will be decommissioned.</p>
     <p class="m-top-20"><span class="strong">Do you want to proceed?</span></p>
   </div>
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 ca05251..d6207c2 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
@@ -23,4 +23,5 @@ export enum ConfirmationDialogType {
   TerminateComputationalResources = 2,
   StopEdgeNode = 3,
   deleteUser = 4,
+  deleteGroup
 }
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 b80443a..b865840 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
@@ -20,10 +20,11 @@
 <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 *ngIf="data.type !== 5 && 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 && data.notebook.length">
+      <span *ngIf="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node' || data.type === 4 && data.notebook.length || data.type === 5 ">
         <i class="material-icons">priority_high</i>Warning
       </span>
       <span *ngIf="data.type === 4 && !data.notebook.length">
@@ -34,11 +35,12 @@
   </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 && data.type !== 5" class="info text-center">{{ model.title }}</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.</p>
+      <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 removed from this group. Removing may prevent the user<span *ngIf="data.notebook.length>1">s</span> to access {{data.notebook.length>1 ? 'their' : 'his/her'}} resources</p>
+      <p *ngIf="data.type === 5" class="text-center delete-user">Removing the group<span *ngIf="data.notebook.length>1">s</span> <span class="strong">{{' ' + data.notebook}}</span> from the project may prevent the users from this group<span *ngIf="data.notebook.length>1">s</span> to access their resources</p>
 <!--        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.-->
       <mat-list class="resources"
         [hidden]="model.notebook.type === 'Edge Node' || model.notebook.name === 'edge node'
@@ -65,8 +67,8 @@
       </div>
       <div class="text-center m-top-20">
         <button mat-raised-button type="button" class="butt action" (click)="dialogRef.close()">No</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>
+        <button *ngIf="data.type !== 4 && data.type !== 5" mat-raised-button type="button" class="butt butt-success action" (click)="confirm()">Yes</button>
+        <button *ngIf="data.type === 4 || data.type === 5" 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/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 d0b5c9b..b8a2cff 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
@@ -60,21 +60,23 @@ export class ConfirmationDialogComponent implements OnInit {
   }
 
   ngOnInit() {
-    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.dialogRef.close();
-      },
-      error => this.toastr.error(error.message || 'Action failed!', 'Oops'),
-      this.data.manageAction,
-      this.userResourceService,
-      this.healthStatusService,
-      this.manageEnvironmentsService);
+    if(this.data.type !== 5){
+      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.dialogRef.close();
+        },
+        error => this.toastr.error(error.message || 'Action failed!', 'Oops'),
+        this.data.manageAction,
+        this.userResourceService,
+        this.healthStatusService,
+        this.manageEnvironmentsService);
 
-    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' && el.status !== 'failed') : 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' && el.status !== 'failed') : false;
+    }
   }
 
   public confirm() {
diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.model.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.model.ts
index 79b0512..71abde3 100644
--- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.model.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/confirmation-dialog/confirmation-dialog.model.ts
@@ -124,6 +124,9 @@ export class ConfirmationDialogModel {
             error => fnProcessErrors(error));
       }
         break;
+      case ConfirmationDialogType.deleteGroup: {
+      }
+        break;
       default: {
         this.title = this.isAliveResources(notebook.resources) ? containRunningResourcesTerminateMessage : defaultTerminateMessage;
         this.notebook = notebook;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org