You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by dy...@apache.org on 2022/02/01 11:19:40 UTC

[incubator-datalab] branch DATALAB-2637 updated: changed validator

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

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


The following commit(s) were added to refs/heads/DATALAB-2637 by this push:
     new 8aa0f67  changed validator
     new 71a318a  Merge pull request #1401 from GennadiyShpak/fix/DATALAB-2637/spot-instance-checkbox
8aa0f67 is described below

commit 8aa0f67e9f1191e67093a603d89797c41e04c1dc
Author: Hennadii_Shpak <bo...@gmail.com>
AuthorDate: Tue Feb 1 13:13:56 2022 +0200

    changed validator
---
 ...mputational-resource-create-dialog.component.ts | 30 +++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

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 1e6ec89..f81f9ba 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
@@ -18,7 +18,7 @@
  */
 
 import { Component, OnInit, Inject, ChangeDetectorRef } from '@angular/core';
-import {FormGroup, FormBuilder, Validators} from '@angular/forms';
+import {FormGroup, FormBuilder, Validators, FormControl, ValidatorFn} from '@angular/forms';
 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
 import { ToastrService } from 'ngx-toastr';
 
@@ -100,11 +100,12 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
     if (!this.instanceSpot) {
       this.spotInstance = true;
       this.resourceForm.controls['emr_slave_instance_spot'].patchValue(true);
+      this.resourceForm.controls['instance_price'].enable();
       this.resourceForm.controls['instance_price'].patchValue(50);
     } else {
       this.spotInstance = false;
       this.resourceForm.controls['emr_slave_instance_spot'].patchValue(false);
-      this.resourceForm.controls['instance_price'].patchValue(0);
+      this.resourceForm.controls['instance_price'].disable();
     }
   }
 
@@ -168,7 +169,7 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
       preemptible_instance_number: [0,
         Validators.compose([Validators.pattern(PATTERNS.integerRegex),
         this.validPreemptibleRange.bind(this)])],
-      instance_price: [0, [this.validInstanceSpotRange.bind(this)]],
+      instance_price: [0, [this.validInstanceSpotRange()]],
       configuration_parameters: ['', [this.validConfiguration.bind(this)]],
       custom_tag: [this.notebook_instance.tags.custom_tag],
       master_GPU_type: [''],
@@ -243,12 +244,16 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
     }
   }
 
-  private validInstanceSpotRange(control) {
-    if (this.isSelected.spotInstances) {
-      return this.isSelected.spotInstances
-        ? (control.value >= this.minSpotPrice && control.value <= this.maxSpotPrice ? null : { valid: false })
-        : control.value;
-    }
+  private validInstanceSpotRange(): ValidatorFn {
+    return (control: FormControl) => {
+      console.log( this.maxSpotPrice, this.minSpotPrice);
+      if (!this.isSelected.spotInstances) {
+        return null;
+      }
+      return control.value >= this.minSpotPrice && control.value <= this.maxSpotPrice
+        ? null
+        : { valid: false };
+    };
   }
 
   private validConfiguration(control) {
@@ -368,11 +373,6 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
     }
 
     console.log('form1', this.resourceForm);
-    console.log('resourceForm.value.shape_slave2', this.resourceForm.value.shape_slave);
-    console.log('selectedImage?.image3', this.selectedImage?.image);
-    console.log('resourceForm.value.version4', this.resourceForm.value.version);
-    console.log('limits.min_emr_spot_instance_bid_pct5', this.selectedImage.limits.min_emr_spot_instance_bid_pct);
-    
   }
 
   public clearGpuType(type) {
@@ -386,6 +386,6 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   }
 
   get instanceSpot() {
-    return this.resourceForm.controls['emr_slave_instance_spot'].value
+    return this.resourceForm.controls['emr_slave_instance_spot'].value;
   }
 }

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