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/05/26 11:33:26 UTC

[incubator-dlab] 02/02: [DLAB-1744]: Conveyed Notebook links of other users to administrator

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

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

commit b9dc531b01467dab5ea68ca2bbf85ba4457749bf
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Tue May 26 14:32:37 2020 +0300

    [DLAB-1744]: Conveyed Notebook links of other users to administrator
---
 .../management-grid/management-grid.component.html |  5 +++-
 .../management-grid/management-grid.component.scss |  4 ++++
 .../management-grid/management-grid.component.ts   | 28 +++++++++++++++-------
 .../administration/management/management.model.ts  |  6 +++--
 .../detail-dialog/detail-dialog.component.html     | 23 ++++++++++++++----
 .../detail-dialog/detail-dialog.component.ts       |  3 ++-
 6 files changed, 52 insertions(+), 17 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 b4f726c..8b7e459 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
@@ -60,7 +60,10 @@
             <span [hidden]="filtering && filterForm.type.length > 0 && !collapsedFilterRow">more_vert</span>
           </i>
         </button> </th>
-      <td type mat-cell *matCellDef="let element">{{ element.name || element.type }}</td>
+      <td type mat-cell *matCellDef="let element">
+        <span *ngIf="element.name"  class="computation" (click)="openNotebookDetails(element)">{{element.name}}</span>
+        <span *ngIf="!element.name">{{element.type}}</span>
+      </td>
     </ng-container>
 
     <ng-container matColumnDef="shape">
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
index 30c082d..37f127d 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-grid/management-grid.component.scss
@@ -119,3 +119,7 @@ table.management {
     background: inherit;
   }
 }
+
+.computation{
+  cursor: pointer;
+}
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 d0ab9dc..8153f26 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
@@ -28,6 +28,7 @@ import { ConfirmationDialogComponent } from '../../../shared/modal-dialog/confir
 import { EnvironmentsDataService } from '../management-data.service';
 import { EnvironmentModel, ManagementConfigModel } from '../management.model';
 import {ProgressBarService} from '../../../core/services/progress-bar.service';
+import {DetailDialogComponent} from '../../../resources/exploratory/detail-dialog';
 
 export interface ManageAction {
   action: string;
@@ -112,7 +113,9 @@ export class ManagementGridComponent implements OnInit {
     let filteredData = this.getEnvironmentDataCopy();
 
     const containsStatus = (list, selectedItems) => {
-      return list.filter((item: any) => { if (selectedItems.indexOf(item.status) !== -1) return item; });
+      if (list){
+        return list.filter((item: any) => { if (selectedItems.indexOf(item.status) !== -1) return item; });
+      }
     };
 
     if (filteredData.length) this.filtering = true;
@@ -131,8 +134,8 @@ export class ManagementGridComponent implements OnInit {
 
         if (config.resources.length > 0 && modifiedResources.length > 0) { item.resources = modifiedResources; }
 
-        if (config.resources.length === 0 && config.type === 'active' ||
-          modifiedResources.length >= 0 && config.resources.length > 0 && config.type === 'active') {
+        if (config.resources && config.resources.length === 0 && config.type === 'active' ||
+          modifiedResources && modifiedResources.length >= 0 && config.resources.length > 0 && config.type === 'active') {
           item.resources = modifiedResources;
           isResources = true;
         }
@@ -216,15 +219,24 @@ export class ManagementGridComponent implements OnInit {
       if (item.status && statuses.indexOf(item.status.toLowerCase()) === -1) statuses.push(item.status.toLowerCase());
       if (item.project && projects.indexOf(item.project) === -1) projects.push(item.project);
       if (item.shape && shapes.indexOf(item.shape) === -1) shapes.push(item.shape);
-
-      item.computational_resources.map((resource: any) => {
-        if (resources.indexOf(resource.status) === -1) resources.push(resource.status);
-        resources.sort(SortUtils.statusSort);
-      });
+      if (item.computational_resources) {
+         item.computational_resources.map((resource: any) => {
+              if (resources.indexOf(resource.status) === -1) resources.push(resource.status);
+              resources.sort(SortUtils.statusSort);
+            });
+      }
     });
 
     this.filterConfiguration = new ManagementConfigModel(users, '', projects, shapes, statuses, resources);
   }
+
+  openNotebookDetails(data) {
+    this.dialog.open(DetailDialogComponent, { data:
+        {notebook: data, bucketStatus: {view: true, upload: true, download: true, delete: true},  buckets: [], type: 'environment'},
+      panelClass: 'modal-lg'
+    })
+      .afterClosed().subscribe(() => {});
+  }
 }
 
 
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
index 2b2fdf3..6b0f600 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management.model.ts
@@ -27,7 +27,8 @@ export class EnvironmentModel {
     public ip: string,
     public type?: string,
     public project?: string,
-    public cloud_provider?: string
+    public cloud_provider?: string,
+    public exploratory_urls?: Array<any>
   ) { }
 
   public static loadEnvironments(data: Array<any>) {
@@ -41,7 +42,8 @@ export class EnvironmentModel {
         value.public_ip,
         value.resource_type,
         value.project,
-        value.cloud_provider
+        value.cloud_provider,
+        value.exploratory_urls
       ));
     }
   }
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
index 75712d4..6b67c40 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.html
@@ -22,10 +22,10 @@
     <button type="button" class="close" (click)="dialogRef.close()">&times;</button>
   </header>
   <div class="dialog-content">
-    <div *ngIf="data">
+    <div *ngIf="data ">
       <table class="detail-header">
         <tr>
-          <td>{{notebook.template_name}}</td>
+          <td>{{notebook.template_name || notebook.name}}</td>
           <td>
             <span class="status" ngClass="{{notebook.status || ''}}">
               {{notebook.status}}
@@ -34,12 +34,24 @@
           <td>{{notebook.shape}}</td>
         </tr>
       </table>
+
       <div class="content-box">
         <div class="detail-info" *ngIf="notebook.error_message">
           <p class="failed">{{ notebook.error_message }}</p>
         </div>
-
-        <div class="scroll-box" id="scrolling">
+        <div *ngIf="data.type === 'environment'" class="detail-info">
+          <p>Open following URL(s) in your browser to access this box:</p>
+          <div class="links_block">
+            <p *ngFor="let item of notebook.exploratory_urls">
+              <span class="description">{{item.description}}: &nbsp;</span>
+              <a class="ellipsis" matTooltip="{{item.url}}" matTooltipPosition="above" href="{{item.url}}"
+                 target="_blank">
+                &nbsp;{{item.url}}
+              </a>
+            </p>
+          </div>
+        </div>
+        <div class="scroll-box" id="scrolling" *ngIf="data.type === 'resource'">
           <div class="detail-info" *ngIf="!notebook.error_message">
             <p>Edge Node IP Address {{notebook.node_ip}}</p>
             <p *ngIf="notebook.status === 'running'">Up time {{upTimeInHours}} hour(s) since
@@ -59,7 +71,7 @@
             <p class="flex" *ngIf="notebook.password">Password: &nbsp;<span
                 class="strong">{{ notebook.password }}</span></p>
 
-            <p class="m-top-30">{{ DICTIONARY[PROVIDER].personal_storage }}: &nbsp;</p>
+            <p class="m-top-30">{{ 'Project bucket' }}: &nbsp;</p>
             <!--                 (click)="bucketBrowser(notebook.bucket_name, notebook.endpoint, this.bucketStatus.view)"-->
             <div class="links_block" (mouseleave)="hideCopyIcon()">
                 <p *ngIf="PROVIDER === 'azure' && notebook.account_name">
@@ -203,5 +215,6 @@
         </div>
       </div>
     </div>
+
   </div>
 </div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
index c6748e2..9468157 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/detail-dialog/detail-dialog.component.ts
@@ -37,7 +37,7 @@ import {CopyPathUtils} from '../../../core/util/copyPathUtils';
 
 export class DetailDialogComponent implements OnInit {
   readonly DICTIONARY = DICTIONARY;
-  readonly PROVIDER = this.data.notebook.cloud_provider;
+  readonly PROVIDER = this.data.notebook.cloud_provider.toLowerCase();
   private isCopied: boolean = true;
   notebook: any;
   upTimeInHours: number;
@@ -65,6 +65,7 @@ export class DetailDialogComponent implements OnInit {
   }
 
   ngOnInit() {
+    console.log(this.data.notebook);
     this.bucketStatus = this.data.bucketStatus;
     this.notebook = this.data.notebook;
     if (this.notebook) {


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