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/07/12 10:47:33 UTC

[incubator-dlab] branch feature/projects updated: [DLAB-854]: added project name as request parameter to start/stop resources

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

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


The following commit(s) were added to refs/heads/feature/projects by this push:
     new 1e0b249  [DLAB-854]: added project name as request parameter to start/stop resources
1e0b249 is described below

commit 1e0b2496522fda9261da1ae1246c99fcea81efac
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Fri Jul 12 13:47:23 2019 +0300

    [DLAB-854]: added project name as request parameter to start/stop resources
---
 .../src/app/core/services/userResource.service.ts  |  8 +--
 .../computational-resources-list.component.html    | 65 +++++++++++-----------
 .../computational-resources-list.component.ts      | 40 ++++++-------
 3 files changed, 54 insertions(+), 59 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts
index b07c2f1..9c9d96e 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts
@@ -29,7 +29,7 @@ export class UserResourceService {
   constructor(private applicationServiceFacade: ApplicationServiceFacade) { }
 
   public getExploratoryTemplates(project): Observable<any> {
-    const url = `/${ project }/exploratory_templates`;
+    const url = `/${project}/exploratory_templates`;
     return this.applicationServiceFacade
       .buildGetTemplatesRequest(url)
       .pipe(
@@ -38,7 +38,7 @@ export class UserResourceService {
   }
 
   public getComputationalTemplates(project): Observable<any> {
-    const url = `/${ project }/computational_templates`;
+    const url = `/${project}/computational_templates`;
     return this.applicationServiceFacade
       .buildGetTemplatesRequest(url)
       .pipe(
@@ -109,8 +109,8 @@ export class UserResourceService {
         catchError(ErrorUtils.handleServiceError));
   }
 
-  public toggleStopStartAction(notebook: string, resource: string, action): Observable<{}> {
-    const url = `/${notebook}/${resource}/${action}`;
+  public toggleStopStartAction(project, notebook: string, resource: string, action): Observable<{}> {
+    const url = `/${project}/${notebook}/${resource}/${action}`;
     if (action === 'stop') {
       return this.applicationServiceFacade
         .buildStopSparkClusterAction(JSON.stringify(url))
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.html
index d4cac2c..1b0a139 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.html
@@ -19,40 +19,41 @@
 
 <div class="source">
 
-    <div *ngIf="!resources?.length">
-      <span *ngIf="!resources.length" class="no-details">no details</span>
-    </div>
-    <div *ngIf="resources?.length">
-      <div *ngFor="let resource of resources" class="resource-wrap">
-        <div class="resource-name">
-          <a class="detailed-link" (click)="detailComputationalResources(environment, resource)">
-            {{resource.computational_name}}
-          </a>
-        </div>
-        <span ngClass="{{resource.status.toLowerCase() || ''}}" class="resource-status">{{resource.status}}</span>
-  
-        <div class="resource-actions">
-          <a class="schedule" [ngClass]="{'active': resource.scheduler_data,
+  <div *ngIf="!resources?.length">
+    <span *ngIf="!resources.length" class="no-details">no details</span>
+  </div>
+  <div *ngIf="resources?.length">
+    <div *ngFor="let resource of resources" class="resource-wrap">
+      <div class="resource-name">
+        <a class="detailed-link" (click)="detailComputationalResources(environment, resource)">
+          {{resource.computational_name}}
+        </a>
+      </div>
+      <span ngClass="{{resource.status.toLowerCase() || ''}}" class="resource-status">{{resource.status}}</span>
+
+      <div class="resource-actions">
+        <a class="schedule" [ngClass]="{'active': resource.scheduler_data,
               'not-allowed': environment.status !== 'running' && environment.status !== 'stopped'
               || resource.status !== 'running' && resource.status !== 'stopped' }">
-            <i class="material-icons" (click)="openScheduleDialog(resource)">schedule</i>
-          </a>
-  
-          <a class="start-stop-action" *ngIf="resource.image === 'docker.dlab-dataengine' && environment.status === 'running'">
-            <i class="material-icons" *ngIf="resource.status === 'running' || resource.status === 'stopping'" (click)="toggleResourceAction(resource, 'stop')"
-              [ngClass]="{'not-allowed' : resource.status === 'stopping' }">pause_circle_outline</i>
-            <i class="material-icons" *ngIf="resource.status === 'stopped' || resource.status === 'starting'" (click)="toggleResourceAction(resource, 'start')"
-              [ngClass]="{'not-allowed' : resource.status === 'starting' }">play_circle_outline</i>
-          </a>
-  
-          <a class="remove_butt" [ngClass]="{'disabled' : environment.status !== 'running' || environment.status !== 'stopped'
-              && resource.status != 'running' && resource.status != 'failed' && resource.status != 'stopped' }" (click)="toggleResourceAction(resource, 'terminate')">
-            <i class="material-icons">highlight_off</i>
-          </a>
-        </div>
+          <i class="material-icons" (click)="openScheduleDialog(resource)">schedule</i>
+        </a>
+
+        <a class="start-stop-action"
+          *ngIf="resource.image === 'docker.dlab-dataengine' && environment.status === 'running'">
+          <i class="material-icons" *ngIf="resource.status === 'running' || resource.status === 'stopping'"
+            (click)="toggleResourceAction(resource, 'stop')"
+            [ngClass]="{'not-allowed' : resource.status === 'stopping' }">pause_circle_outline</i>
+          <i class="material-icons" *ngIf="resource.status === 'stopped' || resource.status === 'starting'"
+            (click)="toggleResourceAction(resource, 'start')"
+            [ngClass]="{'not-allowed' : resource.status === 'starting' }">play_circle_outline</i>
+        </a>
+
+        <a class="remove_butt" [ngClass]="{'disabled' : environment.status !== 'running' || environment.status !== 'stopped'
+              && resource.status != 'running' && resource.status != 'failed' && resource.status != 'stopped' }"
+          (click)="toggleResourceAction(resource, 'terminate')">
+          <i class="material-icons">highlight_off</i>
+        </a>
       </div>
     </div>
   </div>
-  
-  <!-- <dlab-cluster-details #detailComputationalResource (buildGrid)="rebuildGrid()"></dlab-cluster-details> -->
-  <!-- <dlab-scheduler #clusterScheduler (buildGrid)="rebuildGrid()"></dlab-scheduler> -->
+</div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.ts
index 02ede96..6ab3022 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resources-list/computational-resources-list.component.ts
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import { Component, EventEmitter, Input, Output, ViewChild, Inject } from '@angular/core';
+import { Component, EventEmitter, Input, Output, Inject } from '@angular/core';
 import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
 import { ToastrService } from 'ngx-toastr';
 
@@ -32,12 +32,8 @@ import { SchedulerComponent } from '../../scheduler';
 })
 
 export class ComputationalResourcesListComponent {
-  @ViewChild('confirmationDialog') confirmationDialog;
-  @ViewChild('detailComputationalResource') detailComputationalResource;
-  @ViewChild('clusterScheduler') clusterScheduler;
-
   @Input() resources: any[];
-  @Input() environment: any[];
+  @Input() environment: any;
 
   @Output() buildGrid: EventEmitter<{}> = new EventEmitter();
 
@@ -47,20 +43,24 @@ export class ComputationalResourcesListComponent {
     private userResourceService: UserResourceService
   ) { }
 
-  toggleResourceAction(resource, action: string) {
+  rebuildGrid(): void {
+    this.buildGrid.emit();
+  }
+
+  public toggleResourceAction(resource, action: string): void {
     if (action === 'stop' || action === 'terminate') {
       const dialogRef: MatDialogRef<ConfirmationDialogComponent> = this.dialog.open(ConfirmationDialogComponent,
-        { data: {action, resource}, width: '550px', panelClass: 'error-modalbox' });
+        { data: { action, resource }, width: '550px', panelClass: 'error-modalbox' });
       dialogRef.afterClosed().subscribe(result => {
         if (result && action === 'stop') {
           this.userResourceService
-            .toggleStopStartAction(this.environment['name'], resource.computational_name, action)
+            .toggleStopStartAction(this.environment.project, this.environment.name, resource.computational_name, action)
             .subscribe(() => {
               this.rebuildGrid();
             });
         } else if (result && action === 'terminate') {
           this.userResourceService
-            .suspendComputationalResource(this.environment['name'], resource.computational_name)
+            .suspendComputationalResource(this.environment.name, resource.computational_name)
             .subscribe(() => {
               this.rebuildGrid();
             });
@@ -68,27 +68,21 @@ export class ComputationalResourcesListComponent {
       });
     } else if (action === 'start') {
       this.userResourceService
-        .toggleStopStartAction(this.environment['name'], resource.computational_name, 'start')
+        .toggleStopStartAction(this.environment.project, this.environment.name, resource.computational_name, 'start')
         .subscribe(
           () => this.rebuildGrid(),
           error => this.toastr.error(error.message || 'Computational resource starting failed!', 'Oops!'));
     }
   }
 
-  rebuildGrid(): void {
-    this.buildGrid.emit();
-  }
-
-  detailComputationalResources(environment, resource): void {
-    // this.detailComputationalResource.open({ isFooter: false }, environment, resource);
-    this.dialog.open(DetailComputationalResourcesComponent, { data: { environment, resource }, panelClass: 'modal-sm'})
-               .afterClosed().subscribe(() => this.rebuildGrid());
+  public detailComputationalResources(environment, resource): void {
+    this.dialog.open(DetailComputationalResourcesComponent, { data: { environment, resource }, panelClass: 'modal-sm' })
+      .afterClosed().subscribe(() => this.rebuildGrid());
   };
 
-  openScheduleDialog(resource) {
-    // this.clusterScheduler.open({ isFooter: false }, this.environment, 'СOMPUTATIONAL', resource);
-    this.dialog.open(SchedulerComponent, { data: {notebook: this.environment, type: 'СOMPUTATIONAL', resource}, panelClass: 'modal-xl-s' })
-               .afterClosed().subscribe(() => this.rebuildGrid());
+  public openScheduleDialog(resource) {
+    this.dialog.open(SchedulerComponent, { data: { notebook: this.environment, type: 'СOMPUTATIONAL', resource }, panelClass: 'modal-xl-s' })
+      .afterClosed().subscribe(() => this.rebuildGrid());
   }
 }
 


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