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

commit 7c6011bb94eb240546d1d359f3a93f51674fe866
Author: Andriana Kovalyshyn <andriana_kovalys...@epam.com>
AuthorDate: Thu Jun 13 16:41:14 2019 +0300

    [DLAB-805]: replaced cluster type selector; add default option
---
 ...utational-resource-create-dialog.component.html |  58 +++--
 ...mputational-resource-create-dialog.component.ts | 233 +++++++++++----------
 .../computational-resource-create.model.ts         |   4 +-
 3 files changed, 159 insertions(+), 136 deletions(-)

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 6120083..b8232cd 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
@@ -22,30 +22,44 @@
     <h4 class="modal-title">Add computational resources</h4>
     <button type="button" class="close" 
(click)="dialogRef.close()">&times;</button>
   </header>
-  <div class="dialog-content">
-    <div class="content-box">
-      <form [formGroup]="resourceForm"
-            (submit)="createComputationalResource($event, resourceForm.value, 
shapes.master_shape, shapes.slave_shape)"
-            *ngIf="model.availableTemplates && resourceForm">
+  <div class="dialog-content selection">
+    <div class="content-box mat-reset">
+      <form [formGroup]="resourceForm" *ngIf="templates.length && 
resourceForm; else empty">
 
-        <div class="form-wrapper" [ngClass]="{ compress: 
model.selectedImage?.image === 'docker.dlab-dataengine' }">
+        <div class="form-wrapper" [ngClass]="{ compress: selectedImage.image 
=== 'docker.dlab-dataengine' }">
           <div class="col">
 
-              <div class="control-group" *ngIf="PROVIDER !== 'azure'" 
[hidden]="model.resourceImages.length === 1">
+              <!-- <div class="control-group" *ngIf="PROVIDER !== 'azure'" 
[hidden]="model.resourceImages.length === 1">
                 <label class="label">Select cluster type</label>
                 <div class="control">
                   <dropdown-list #clusterType 
(selectedItem)="onUpdate($event)"></dropdown-list>
                 </div>
+              </div> -->
+
+              <div class="control-group" *ngIf="PROVIDER !== 'azure'" 
[hidden]="templates.length === 1">
+                <label class="label">Select cluster type</label>
+                <div class="control selector-wrapper">
+                  <mat-form-field>
+                    <mat-label>Select project</mat-label>
+                    <mat-select formControlName="template_name" 
disableOptionCentering>
+                      <mat-option *ngFor="let template of templates" 
[value]="template.template_name" (click)="selectedImage = template">{{ 
template.template_name }}</mat-option>
+                      <mat-option *ngIf="!templates.length" 
class="multiple-select ml-10" disabled>Templates list is empty</mat-option>
+                    </mat-select>
+                    <button class="caret">
+                      <i class="material-icons">keyboard_arrow_down</i>
+                    </button>
+                  </mat-form-field>
+                </div>
               </div>
 
-              <div class="control-group" *ngIf="PROVIDER !== 'azure'" 
[hidden]="!model.templates.length">
+              <div class="control-group" *ngIf="PROVIDER !== 'azure'" 
[hidden]="!selectedImage.templates.length">
                 <label class="label">Select template</label>
                 <div class="control">
                   <dropdown-list #templatesList 
(selectedItem)="onUpdate($event)"></dropdown-list>
                 </div>
               </div>
 
-              <div class="control-group alias-name" 
*ngIf="model.selectedImage?.image">
+              <div class="control-group alias-name" 
*ngIf="selectedImage?.image">
                 <label class="label">Cluster alias</label>
                 <div class="control">
                     <input [class.danger_field]="computationalResourceExist || 
!resourceForm?.controls['cluster_alias_name'].valid
@@ -61,9 +75,10 @@
               </div>
 
           </div>
+
           <div class="col">
-            <div class="control-group" *ngIf="model.selectedImage?.image">
-              <label class="label">{{ 
DICTIONARY[model.selectedImage.image].instance_number }}</label>
+            <div class="control-group" *ngIf="selectedImage?.image">
+              <label class="label">{{ 
DICTIONARY[selectedImage.image].instance_number }}</label>
               <div class="control">
                 <input type="number" class="form-control" 
min="{{minInstanceNumber}}" max="{{maxInstanceNumber}}"
                       formControlName="instance_number" 
(keypress)="CheckUtils.isNumberKey($event)" />
@@ -72,15 +87,15 @@
                 </span>
               </div>
             </div>
-            <div class="control-group" *ngIf="model.selectedImage?.image">
-              <label class="label" *ngIf="model.selectedImage">{{ 
DICTIONARY[model.selectedImage.image].data_engine_master_instance_size}}</label>
+            <div class="control-group" *ngIf="selectedImage?.image">
+              <label class="label" *ngIf="selectedImage">{{ 
DICTIONARY[selectedImage.image].data_engine_master_instance_size}}</label>
               <div class="control">
                 <dropdown-list #masterShapesList 
(selectedItem)="onUpdate($event)"></dropdown-list>
               </div>
             </div>
 
-            <div class="control-group" *ngIf="model.selectedImage?.image" 
[hidden]="model.selectedImage?.image === 'docker.dlab-dataengine'">
-              <label class="label">{{ 
DICTIONARY[model.selectedImage.image].data_engine_slave_instance_size }}</label>
+            <div class="control-group" *ngIf="selectedImage?.image" 
[hidden]="selectedImage?.image === 'docker.dlab-dataengine'">
+              <label class="label">{{ 
DICTIONARY[selectedImage.image].data_engine_slave_instance_size }}</label>
               <div class="control">
                 <dropdown-list #shapesSlaveList 
(selectedItem)="onUpdate($event)"></dropdown-list>
               </div>
@@ -88,7 +103,7 @@
           </div>
         </div>
 
-        <div class="preemptible checkbox-group control-group m-top-30 
m-bott-10" *ngIf="PROVIDER === 'gcp' && model.selectedImage?.image === 
'docker.dlab-dataengine-service'">
+        <div class="preemptible checkbox-group control-group m-top-30 
m-bott-10" *ngIf="PROVIDER === 'gcp' && selectedImage?.image === 
'docker.dlab-dataengine-service'">
           <label class="label">
             <input #preemptibleNode type="checkbox" 
(change)="selectPreemptibleNodes($event)" />
             <span>Preemptible node</span>
@@ -128,13 +143,13 @@
         </div>
 
 
-        <div class="checkbox-group" [hidden]="PROVIDER === 'gcp' && 
model.selectedImage?.image === 'docker.dlab-dataengine-service'"
+        <div class="checkbox-group" [hidden]="PROVIDER === 'gcp' && 
selectedImage?.image === 'docker.dlab-dataengine-service'"
              *ngIf="notebook_instance?.image !== 'docker.dlab-zeppelin'">
           <label>
             <input #configurationNode type="checkbox" 
(change)="selectConfiguration()"/> Cluster configurations
           </label>
           <div class="config-link" 
*ngIf="(configuration?.nativeElement['checked'] || false)
-            && model.selectedImage?.image === 'docker.dlab-dataengine-service'
+            && selectedImage?.image === 'docker.dlab-dataengine-service'
             && DICTIONARY.cloud_provider === 'aws'">
             To view example JSON of configurations refer for <a 
href="https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-configure-apps.html";
 target="_blank">AWS official documentation</a>
           </div>
@@ -152,12 +167,15 @@
         </div>
         <div class="text-center m-top-30">
           <button mat-raised-button type="button" (click)="dialogRef.close()" 
class="butt action">Cancel</button>
-          <button mat-raised-button type="submit" 
[disabled]="!resourceForm?.valid"
+          <button mat-raised-button type="button" 
[disabled]="!resourceForm?.valid"
+                  (click)="createComputationalResource(resourceForm.value, 
shapes.master_shape, shapes.slave_shape)"
                   class="butt butt-success action" [ngClass]="{'not-allowed': 
!resourceForm?.valid}">Create</button>
         </div>
       </form>
 
-      <div *ngIf="!model.availableTemplates" class="info 
message">Computational resource creations are not available.<br>Please, check 
your permissions.</div>
+      <ng-template #empty>
+        <div class="info message">Computational resource creations are not 
available.<br>Please, check your permissions.</div>
+      </ng-template>
     </div>
   </div>
 </div>
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
index f6b1334..727e44b 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create-dialog.component.ts
@@ -41,10 +41,13 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
   readonly CLUSTER_CONFIGURATION = CLUSTER_CONFIGURATION;
   readonly CheckUtils = CheckUtils;
 
-  model: ComputationalResourceCreateModel;
+  // model: ComputationalResourceCreateModel;
   notebook_instance: any;
   full_list: any;
-  template_description: string;
+
+  templates = [];
+  selectedImage: any;
+
   shapes: any;
   spotInstance: boolean = true;
   clusterNamePattern: string = '[-_a-zA-Z0-9]*[_-]*[a-zA-Z0-9]+';
@@ -60,7 +63,6 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
   public maxSpotPrice: number = 0;
   public resourceForm: FormGroup;
 
-  // @ViewChild('bindDialog') bindDialog;
   @ViewChild('name') name;
   @ViewChild('clusterType') cluster_type;
   @ViewChild('templatesList') templates_list;
@@ -80,62 +82,60 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
     private ref: ChangeDetectorRef,
     public dialogRef: MatDialogRef<ComputationalResourceCreateDialogComponent>,
   ) {
-    this.model = 
ComputationalResourceCreateModel.getDefault(userResourceService);
+    // this.model = 
ComputationalResourceCreateModel.getDefault(userResourceService);
   }
 
   ngOnInit() {
     this.initFormModel();
-    // this.bindDialog.onClosing = () => this.resetDialog();
     this.open(this.data.notebook, this.data.full_list);
   }
 
-  // public isNumberKey($event): boolean {
-  //   const charCode = ($event.which) ? $event.which : $event.keyCode;
-  //   if (charCode !== 46 && charCode > 31 && (charCode < 48 || charCode > 
57)) {
-  //     $event.preventDefault();
-  //     return false;
-  //   }
-  //   return true;
-  // }
 
-  public onUpdate($event): void {
-    if ($event.model.type === 'template') {
-      this.model.setSelectedTemplate($event.model.index);
-      
this.master_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
-        
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'master_shape', 'description', 'json');
-      
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
-        
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
 
-      this.shapes.master_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
-      this.shapes.slave_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
-    }
-    if ($event.model.type === 'cluster_type') {
-      this.model.setSelectedClusterType($event.model.index);
-      this.setDefaultParams();
-      this.getComputationalResourceLimits();
-      this.selectConfiguration();
-    }
 
-    if (this.shapes[$event.model.type])
-      this.shapes[$event.model.type] = $event.model.value.type;
 
-    if (DICTIONARY.cloud_provider === 'aws')
-      if ($event.model.type === 'slave_shape' && 
this.spotInstancesSelect.nativeElement['checked']) {
-        this.spotInstance = $event.model.value.spot;
-      }
-  }
 
-  public createComputationalResource($event, data, shape_master: string, 
shape_slave: string) {
-    this.model.setCreatingParams(
-      data.cluster_alias_name,
-      data.instance_number,
-      shape_master, shape_slave,
-      this.spotInstance,
-      data.instance_price,
-      data.preemptible_instance_number,
-      data.configuration_parameters ? 
JSON.parse(data.configuration_parameters) : null);
-    this.model.confirmAction();
-    $event.preventDefault();
+  // public onUpdate($event): void {
+  //   if ($event.model.type === 'template') {
+  //     this.model.setSelectedTemplate($event.model.index);
+  //     
this.master_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
+  //       
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'master_shape', 'description', 'json');
+  //     
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
+  //       
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
+
+  //     this.shapes.master_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
+  //     this.shapes.slave_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
+  //   }
+  //   if ($event.model.type === 'cluster_type') {
+  //     this.model.setSelectedClusterType($event.model.index);
+  //     this.setDefaultParams();
+  //     this.getComputationalResourceLimits();
+  //     this.selectConfiguration();
+  //   }
+
+  //   if (this.shapes[$event.model.type])
+  //     this.shapes[$event.model.type] = $event.model.value.type;
+
+  //   if (DICTIONARY.cloud_provider === 'aws')
+  //     if ($event.model.type === 'slave_shape' && 
this.spotInstancesSelect.nativeElement['checked']) {
+  //       this.spotInstance = $event.model.value.spot;
+  //     }
+  // }
+
+  public createComputationalResource(data, shape_master: string, shape_slave: 
string) {
+    // this.model.setCreatingParams(
+    //   data.cluster_alias_name,
+    //   data.instance_number,
+    //   shape_master, shape_slave,
+    //   this.spotInstance,
+    //   data.instance_price,
+    //   data.preemptible_instance_number,
+    //   data.configuration_parameters ? 
JSON.parse(data.configuration_parameters) : null);
+    // this.model.confirmAction();
+    // $event.preventDefault();
+
+    console.log(data);
+    
     return false;
   }
 
@@ -168,9 +168,9 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
       this.spotInstance = this.shapePlaceholder(filtered, 'spot');
       this.resourceForm.controls['instance_price'].setValue(50);
     } else {
-      
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
-        
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
-      this.shapes.slave_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
+      // 
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
+      //   
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
+      // this.shapes.slave_shape = 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type');
 
       this.spotInstance = false;
       this.resourceForm.controls['instance_price'].setValue(0);
@@ -184,7 +184,7 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
 
   public selectConfiguration() {
     if (this.configuration && this.configuration.nativeElement.checked) {
-      const template = (this.model.selectedImage.image === 
'docker.dlab-dataengine-service')
+      const template = (this.selectedImage.image === 
'docker.dlab-dataengine-service')
         ? CLUSTER_CONFIGURATION.EMR
         : CLUSTER_CONFIGURATION.SPARK;
       
this.resourceForm.controls['configuration_parameters'].setValue(JSON.stringify(template,
 undefined, 2));
@@ -214,25 +214,26 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
   public open(notebook_instance, full_list): void {
     this.notebook_instance = notebook_instance;
     this.full_list = full_list;
-    this.model = new ComputationalResourceCreateModel('', 0, '', '', 
notebook_instance.name,
-      response => {
-        if (response.status === HTTP_STATUS_CODES.OK) {
-          this.dialogRef.close();
-          this.buildGrid.emit();
-        }
-      },
-      error => this.toastr.error(error.message || 'Computational resource 
creation failed!', 'Oops!'),
-      () => this.template_description = this.model.selectedItem.description,
-      () => {
-        // this.bindDialog.modalClass += !this.model.availableTemplates ? 
'reset' : '';
-        // this.dialogRef.updateSize('40%', '80%');
-
-        this.ref.detectChanges();
-
-        this.setDefaultParams();
+    this.getTemplates(this.notebook_instance.project);
+    // this.model = new ComputationalResourceCreateModel('', 0, '', '', 
notebook_instance.name,
+    //   response => {
+    //     if (response.status === HTTP_STATUS_CODES.OK) {
+    //       this.dialogRef.close();
+    //       this.buildGrid.emit();
+    //     }
+    //   },
+    //   error => this.toastr.error(error.message || 'Computational resource 
creation failed!', 'Oops!'),
+    //   () => {},
+    //   () => {
+    //     // this.bindDialog.modalClass += !this.model.availableTemplates ? 
'reset' : '';
+    //     // this.dialogRef.updateSize('40%', '80%');
+
+    //     this.ref.detectChanges();
+
+    //     this.setDefaultParams();
         this.getComputationalResourceLimits();
-      },
-      this.userResourceService);
+    //   },
+    //   this.userResourceService);
   }
 
   public preemptibleCounter($event, action): void {
@@ -245,6 +246,7 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
 
   private initFormModel(): void {
     this.resourceForm = this._fb.group({
+      template_name: ['', [Validators.required]],
       cluster_alias_name: ['', [Validators.required, 
Validators.pattern(this.clusterNamePattern),
                                 this.providerMaxLength, 
this.checkDuplication.bind(this)]],
       instance_number: ['', [Validators.required, 
Validators.pattern(this.nodeCountPattern), 
this.validInstanceNumberRange.bind(this)]],
@@ -259,20 +261,20 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
   }
 
   private getComputationalResourceLimits(): void {
-    if (this.model.availableTemplates && this.model.selectedImage && 
this.model.selectedImage.image) {
-      const activeImage = DICTIONARY[this.model.selectedImage.image];
+    if (this.templates.length && this.selectedImage && 
this.selectedImage.image) {
+      const activeImage = DICTIONARY[this.selectedImage.image];
 
-      this.minInstanceNumber = 
this.model.selectedImage.limits[activeImage.total_instance_number_min];
-      this.maxInstanceNumber = 
this.model.selectedImage.limits[activeImage.total_instance_number_max];
+      this.minInstanceNumber = 
this.selectedImage.limits[activeImage.total_instance_number_min];
+      this.maxInstanceNumber = 
this.selectedImage.limits[activeImage.total_instance_number_max];
 
-      if (DICTIONARY.cloud_provider === 'gcp' && 
this.model.selectedImage.image === 'docker.dlab-dataengine-service') {
-        this.maxInstanceNumber = 
this.model.selectedImage.limits[activeImage.total_instance_number_max] - 1;
-        this.minPreemptibleInstanceNumber = 
this.model.selectedImage.limits.min_dataproc_preemptible_instance_count;
+      if (DICTIONARY.cloud_provider === 'gcp' && this.selectedImage.image === 
'docker.dlab-dataengine-service') {
+        this.maxInstanceNumber = 
this.selectedImage.limits[activeImage.total_instance_number_max] - 1;
+        this.minPreemptibleInstanceNumber = 
this.selectedImage.limits.min_dataproc_preemptible_instance_count;
       }
 
-      if (DICTIONARY.cloud_provider === 'aws' && 
this.model.selectedImage.image === 'docker.dlab-dataengine-service') {
-        this.minSpotPrice = 
this.model.selectedImage.limits.min_emr_spot_instance_bid_pct;
-        this.maxSpotPrice = 
this.model.selectedImage.limits.max_emr_spot_instance_bid_pct;
+      if (DICTIONARY.cloud_provider === 'aws' && this.selectedImage.image === 
'docker.dlab-dataengine-service') {
+        this.minSpotPrice = 
this.selectedImage.limits.min_emr_spot_instance_bid_pct;
+        this.maxSpotPrice = 
this.selectedImage.limits.max_emr_spot_instance_bid_pct;
 
         this.spotInstancesSelect.nativeElement['checked'] = true;
         this.selectSpotInstances();
@@ -285,7 +287,7 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
 
   private validInstanceNumberRange(control) {
     if (control && control.value)
-      if (DICTIONARY.cloud_provider === 'gcp' && 
this.model.selectedImage.image === 'docker.dlab-dataengine-service') {
+      if (DICTIONARY.cloud_provider === 'gcp' && this.selectedImage.image === 
'docker.dlab-dataengine-service') {
         this.validPreemptibleNumberRange();
         return control.value >= this.minInstanceNumber && control.value <= 
this.maxInstanceNumber ? null : { valid: false };
       } else {
@@ -339,56 +341,59 @@ export class ComputationalResourceCreateDialogComponent 
implements OnInit {
   }
 
   private setDefaultParams(): void {
-    if (this.model.selectedImage && this.model.selectedImage.shapes) {
-      this.filterShapes();
-      this.shapes = {
-        master_shape: 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type'),
-        slave_shape: 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type')
-      };
-      if (DICTIONARY.cloud_provider !== 'azure' && this.cluster_type) {
-        this.cluster_type.setDefaultOptions(this.model.resourceImages,
-          this.model.selectedImage.template_name, 'cluster_type', 
'template_name', 'array');
-          if (this.model.selectedImage.image === 
'docker.dlab-dataengine-service')
-            this.templates_list.setDefaultOptions(this.model.templates,
-              this.model.selectedItem.version, 'template', 'version', 'array');
-      }
-      this.master_shapes_list && 
this.master_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
-        
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'master_shape', 'description', 'json');
-        this.slave_shapes_list && 
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
-        
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
-    }
+    // if (this.model.selectedImage && this.model.selectedImage.shapes) {
+    //   this.filterShapes();
+    //   this.shapes = {
+    //     master_shape: 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type'),
+    //     slave_shape: 
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'type')
+    //   };
+    //   if (DICTIONARY.cloud_provider !== 'azure' && this.cluster_type) {
+    //     this.cluster_type.setDefaultOptions(this.model.resourceImages,
+    //       this.model.selectedImage.template_name, 'cluster_type', 
'template_name', 'array');
+    //       // if (this.model.selectedImage.image === 
'docker.dlab-dataengine-service')
+    //       //   this.templates_list.setDefaultOptions(this.model.templates,
+    //       //     this.model.selectedItem.version, 'template', 'version', 
'array');
+    //   }
+    //   this.master_shapes_list && 
this.master_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
+    //     
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'master_shape', 'description', 'json');
+    //     this.slave_shapes_list && 
this.slave_shapes_list.setDefaultOptions(this.model.selectedImage.shapes.resourcesShapeTypes,
+    //     
this.shapePlaceholder(this.model.selectedImage.shapes.resourcesShapeTypes, 
'description'), 'slave_shape', 'description', 'json');
+    // }
   }
 
   private filterShapes(): void {
     if 
(this.notebook_instance.template_name.toLowerCase().indexOf('tensorflow') !== -1
       || this.notebook_instance.template_name.toLowerCase().indexOf('deep 
learning') !== -1) {
       const allowed: any = ['GPU optimized'];
-      const filtered = 
Object.keys(this.model.selectedImage.shapes.resourcesShapeTypes)
+      const filtered = 
Object.keys(this.selectedImage.shapes.resourcesShapeTypes)
         .filter(key => allowed.includes(key))
         .reduce((obj, key) => {
-          obj[key] = this.model.selectedImage.shapes.resourcesShapeTypes[key];
+          obj[key] = this.selectedImage.shapes.resourcesShapeTypes[key];
           return obj;
         }, {});
 
       if (DICTIONARY.cloud_provider !== 'azure') {
-        const images = this.model.resourceImages.filter(image => image.image 
=== 'docker.dlab-dataengine');
-        this.model.resourceImages = images;
-        (images.length > 0) ? this.model.setSelectedClusterType(0) : 
this.model.availableTemplates = false;
+        const images = this.templates.filter(image => image.image === 
'docker.dlab-dataengine');
+        this.templates = images;
+        // (images.length > 0) ? this.model.setSelectedClusterType(0) : 
this.model.availableTemplates = false;
       }
-      this.model.selectedImage.shapes.resourcesShapeTypes = filtered;
+      this.selectedImage.shapes.resourcesShapeTypes = filtered;
     }
   }
 
-  private resetDialog(): void {
-    this.spotInstance = false;
-    this.initFormModel();
-    this.getComputationalResourceLimits();
-    this.model.resetModel();
+  private getTemplates(project) {
+    this.userResourceService.getComputationalTemplates(project).subscribe(
+      templates => {
+        this.templates = templates;
+        this.selectedImage = templates[0];
+        this.filterShapes();
+        
this.resourceForm.get('template_name').setValue(this.selectedImage.template_name)
+      });
+  }
+
+
+
+
 
-    if (this.PROVIDER === 'aws' && this.spotInstancesSelect)
-      this.spotInstancesSelect.nativeElement['checked'] = false;
 
-    if (this.PROVIDER === 'gcp' && this.preemptible)
-      this.preemptible.nativeElement['checked'] = false;
-  }
 }
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create.model.ts
 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create.model.ts
index d53285a..5e7b45d 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create.model.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/computational/computational-resource-create-dialog/computational-resource-create.model.ts
@@ -72,7 +72,7 @@ export class ComputationalResourceCreateModel {
     this.selectedItemChanged = selectedItemChanged;
     this.continueWith = continueWith;
     this.prepareModel(fnProcessResults, fnProcessErrors);
-    this.loadTemplates();
+    // this.loadTemplates();
   }
 
   public setSelectedItem(item: ComputationalResourceApplicationTemplate) {
@@ -101,7 +101,7 @@ export class ComputationalResourceCreateModel {
 
   public loadTemplates(): void {
     if (this.resourceImages.length === 0)
-      this.userResourceService.getComputationalResourcesTemplates()
+      this.userResourceService.getComputationalTemplates('project-2')
         .subscribe(
         data => {
           let computationalResourceImage;


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

Reply via email to