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

ytykhun pushed a commit to branch DATALAB-2514
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 064bc9f093d7a4c418fa05fcdbf36ec8b4a7d0e2
Author: Yurii Tykhun <[email protected]>
AuthorDate: Thu Jul 8 17:39:25 2021 +0300

    [DATALAB-2514] extended t-shirt sizes for gpu types
---
 .../webapp/src/app/core/util/helpUtils.ts          | 43 +++++++---------------
 ...utational-resource-create-dialog.component.html | 10 ++---
 .../create-environment.component.html              |  4 +-
 3 files changed, 20 insertions(+), 37 deletions(-)

diff --git 
a/services/self-service/src/main/resources/webapp/src/app/core/util/helpUtils.ts
 
b/services/self-service/src/main/resources/webapp/src/app/core/util/helpUtils.ts
index e078fde..a0eae85 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/core/util/helpUtils.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/core/util/helpUtils.ts
@@ -36,40 +36,23 @@ export class HelpUtils {
     }
   }
 
-  public static addSizeToGpuType(gpuType: string = ''): string {
-    switch (gpuType) {
-      case 'nvidia-tesla-t4':
-        return 'S';
+  public static addSizeToGpuType(index): string {
 
-      case 'nvidia-tesla-p100':
-        return 'M';
+    const sizes = ['S', 'M', 'L', 'XL', 'XXL'];
 
-      case 'nvidia-tesla-v100':
-        return 'L';
-    }
+    return sizes[index];
   }
 
   public static sortGpuTypes(gpuType: Array<string> = []): Array<string> {
-    let sortedTypes = [];
-
-    gpuType?.forEach(type => checkType(type));
-
-    function checkType(type) {
-      switch (type) {
-        case 'nvidia-tesla-t4':
-          sortedTypes[0] = type;
-          return;
-  
-        case 'nvidia-tesla-p100':
-          sortedTypes[1] = type;
-          return;
-  
-        case 'nvidia-tesla-v100':
-          sortedTypes[2] = type;
-          return;
-      }
-    }
-
-    return sortedTypes;
+    
+    const sortedTypes = [
+      'nvidia-tesla-t4', 
+      'nvidia-tesla-k80', 
+      'nvidia-tesla-p4', 
+      'nvidia-tesla-p100', 
+      'nvidia-tesla-v100'
+    ];
+
+    return sortedTypes.filter(el => gpuType.includes(el));;
   }
 }
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
index 461c6ad..7b339f7 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.html
@@ -170,9 +170,9 @@
                     <mat-select formControlName="master_GPU_type" 
disableOptionCentering
                                 placeholder="Select master GPU type"
                                 
[disabled]="!resourceForm.controls['shape_master'].value">
-                      <mat-option *ngFor="let type of 
sortGpuTypes(selectedImage.computationGPU)"
+                      <mat-option *ngFor="let type of 
sortGpuTypes(selectedImage.computationGPU); index as i"
                                   [value]="type" >
-                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(type) }}</strong> {{ type }}
+                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(i) }}</strong> {{ type }}
                       </mat-option>
                       <mat-option 
*ngIf="!selectedImage.computationGPU?.length" class="multiple-select ml-10" 
disabled>
                         Master GPU types list is empty
@@ -223,8 +223,8 @@
                   <mat-form-field>
                     <mat-label>Select slave GPU type</mat-label>
                     <mat-select formControlName="slave_GPU_type" 
disableOptionCentering [disabled]="!resourceForm.controls['shape_slave'].value">
-                      <mat-option *ngFor="let type of 
sortGpuTypes(selectedImage.computationGPU)" [value]="type">
-                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(type) }}</strong> {{ type }}
+                      <mat-option *ngFor="let type of 
sortGpuTypes(selectedImage.computationGPU); index as i" [value]="type">
+                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(i) }}</strong> {{ type }}
                       </mat-option>
                       <mat-option 
*ngIf="!selectedImage.computationGPU?.length" class="multiple-select ml-10" 
disabled>
                         Slave GPU types list is empty
@@ -309,7 +309,7 @@
             rises above your bid price, the Spot instance is reclaimed by AWS 
so that it can be given to another
             customer. Make sure to backup your data on periodic basis.</span>
         </div>
-        <div class="checkbox-group control-group"
+        <div class="checkbox-group control-group m-top-10"
               [hidden]="PROVIDER === 'gcp' && selectedImage?.image === 
'docker.datalab-dataengine-service'"
               *ngIf="notebook_instance?.image !== 'docker.datalab-zeppelin'">
           <div class="d-flex cursor-pointer label" 
(click)="addAdditionalParams('configuration')">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
index aaa633c..28d54f3 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.html
@@ -231,8 +231,8 @@
                   <mat-label>Select GPU type</mat-label>
                   <mat-select formControlName="gpu_type" 
disableOptionCentering 
[disabled]="!createExploratoryForm.controls['shape'].value"
                               panelClass="create-resources-dialog" 
placeholder="GPU type">
-                      <mat-option *ngFor="let list_item of gpuTypes" 
[value]="list_item" (click)="setCount('', list_item)">
-                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(list_item) }}</strong> {{ list_item }}
+                      <mat-option *ngFor="let list_item of gpuTypes; index as 
i" [value]="list_item" (click)="setCount('', list_item)">
+                        <strong class="highlight icon-label">{{ 
addSizeToGpuType(i) }}</strong> {{ list_item }}
                       </mat-option>
                       <mat-option *ngIf="!gpuTypes.length" 
class="multiple-select ml-10" disabled>
                         GPU list is empty

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to