You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/09/13 11:30:34 UTC

[incubator-dlab] 04/04: [DLAB-1103]: added endpoints start/stop/terminate actions

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

ankovalyshyn pushed a commit to branch DLAB-927
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit f8eac3e46fce4a2eac4b995dfbd850b500f75613
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Fri Sep 13 14:30:20 2019 +0300

    [DLAB-1103]: added endpoints start/stop/terminate actions
---
 .../project/project-list/project-list.component.html   |  5 +++--
 .../project/project-list/project-list.component.ts     |  5 +++++
 .../app/administration/project/project.component.ts    | 18 ++++++------------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.html
index 3d7ffcb..ef74416 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.html
@@ -53,7 +53,8 @@
           <div class="resource-actions">
             <a class="start-stop-action">
               <i class="material-icons" (click)="toggleEndpointAction(element, 'stop', endpoint)"
-                *ngIf="endpoint.status === 'RUNNING'">pause_circle_outline</i>
+                *ngIf="endpoint.status === 'RUNNING' || endpoint.status === 'STOPPING'"
+                [ngClass]="{'not-active' : endpoint.status === 'STOPPING'}">pause_circle_outline</i>
             </a>
             <a class="start-stop-action">
               <i class="material-icons" (click)="toggleEndpointAction(element, 'start', endpoint)"
@@ -83,7 +84,7 @@
       <span>
         <!-- [ngClass]="{'not-active' : element.status !== 'ACTIVE' && element.status !== 'NOT_ACTIVE' && element.status !== 'FAILED' }" -->
         <!-- [ngClass]="{'not-allowed' : element.status !== 'ACTIVE' && element.status !== 'NOT_ACTIVE' && element.status !== 'FAILED' }" -->
-        <a (click)="deleteProject(element)">
+        <a (click)="deleteProject(element)" [ngClass]="{'not-allowed' : isInProgress(element)}">
           <mat-icon>delete_forever</mat-icon>
         </a>
       </span>
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
index a6e5768..3792e96 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
@@ -69,4 +69,9 @@ export class ProjectListComponent implements OnInit, OnDestroy {
   public deleteProject(item: Project[]) {
     this.deleteItem.emit(item);
   }
+
+  public isInProgress(project) {
+    if (project)
+      return project.endpoints.some(e => e.status !== 'RUNNING' && e.status !== 'STOPPED' && e.status !== 'TERMINATED' && e.status !== 'FAILED')
+  }
 }
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project.component.ts
index 0e1642e..fde4615 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project.component.ts
@@ -94,20 +94,17 @@ export class ProjectComponent implements OnInit, OnDestroy {
   }
 
   public toggleStatus($event) {
-    // project, endpoint, action
-    const data = { 'project_name': $event.project.name };
+    const data = { 'project_name': $event.project.name, endpoint: $event.endpoint.name };
 
-    if ($event.action === 'stop' || $event.action === 'terminated') {
+    if ($event.action === 'stop' || $event.action === 'terminate') {
       this.dialog.open(NotificationDialogComponent, {
         data: {
           type: 'confirmation',
-          item: $event.project, action: $event.action === 'stop' ? 'stopped' : 'terminated'
+          item: $event.endpoint, action: $event.action === 'stop' ? 'stopped' : 'terminated'
         }, panelClass: 'modal-sm'
       })
         .afterClosed().subscribe(result => {
-          // result && this.toggleStatusRequest(data, $event.action);
-
-          debugger;
+          result && this.toggleStatusRequest(data, $event.action);
         }, error => this.toastr.error(error.message, 'Oops!'));
     } else {
       this.toggleStatusRequest(data, $event.action);
@@ -115,11 +112,8 @@ export class ProjectComponent implements OnInit, OnDestroy {
   }
 
   private toggleStatusRequest(data, action) {
-    // this.projectService.toggleProjectStatus(data, action).subscribe(() => this.refreshGrid(),
-    //   error => this.toastr.error(error.message, 'Oops!'));
-
-
-    debugger;
+    this.projectService.toggleProjectStatus(data, action).subscribe(() => this.refreshGrid(),
+      error => this.toastr.error(error.message, 'Oops!'));
   }
 
   private getEnvironmentHealthStatus() {


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