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/04/28 09:34:57 UTC

[incubator-dlab] branch develop updated: [DLAB-1659]: Applied new name limitation from UI side

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 8543ed9  [DLAB-1659]: Applied new name limitation from UI side
8543ed9 is described below

commit 8543ed9b2d43dffa0cf71cdf1bc99167e468d6d7
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Tue Apr 28 12:34:22 2020 +0300

    [DLAB-1659]: Applied new name limitation from UI side
---
 .../management/endpoints/endpoints.component.html        | 13 ++++++++++---
 .../management/endpoints/endpoints.component.ts          |  9 ++++++++-
 .../computational-resource-create-dialog.component.html  |  2 +-
 .../computational-resource-create-dialog.component.ts    | 16 ++++++++++------
 .../create-environment/create-environment.component.html |  2 +-
 .../create-environment/create-environment.component.ts   | 10 ++++++++--
 6 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.html
index 08b030f..222ee47 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.html
@@ -35,7 +35,11 @@
                   <input type="text" formControlName="name" placeholder="Enter endpoint name"
                     (blur)="generateEndpointTag($event)">
                   <span class="error"
-                    *ngIf="!createEndpointForm?.controls.name.valid && createEndpointForm?.controls.name.touched && !createEndpointForm?.controls['name'].hasError('isDuplicate')">
+                    *ngIf="!createEndpointForm?.controls.name.valid
+                    && createEndpointForm?.controls.name.touched
+                    && !createEndpointForm?.controls['name'].hasError('isDuplicate')
+                    && !createEndpointForm?.controls['name'].hasError('limit')"
+                  >
                     Endpoint name can only contain letters, numbers, hyphens and '_' but can not end with special
                     characters
                   </span>
@@ -43,6 +47,10 @@
                         *ngIf="createEndpointForm?.controls['name'].hasError('isDuplicate')">
                     This endpoint name already exists.
                   </span>
+                  <span class="error"
+                        *ngIf="createEndpointForm?.controls['name'].hasError('limit')">
+                     Endpoint name cannot be longer than {{ maxEndpointNameLength }} characters
+                  </span>
                 </div>
               </div>
               <div class="control-group">
@@ -145,8 +153,7 @@
                 <div class="content">
                   <p>Looks like you don't have any endpoints</p>
 
-                  <button mat-raised-button class="butt" (click)="tabGroup.selectedIndex = 0"
-                    [disabled]="creatingBackup">
+                  <button mat-raised-button class="butt" (click)="tabGroup.selectedIndex = 0">
                     <i class="material-icons">settings_system_daydream</i>New endpoint
                   </button>
                 </div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.ts
index 45c6a23..4c4b656 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/endpoints/endpoints.component.ts
@@ -40,6 +40,7 @@ export interface Endpoint {
 })
 export class EndpointsComponent implements OnInit {
   public createEndpointForm: FormGroup;
+  private maxEndpointNameLength: number = 6;
   endpoints: Endpoint[] = [];
   displayedColumns: string[] = ['name', 'url', 'account', 'endpoint_tag', 'actions'];
 
@@ -102,7 +103,9 @@ export class EndpointsComponent implements OnInit {
 
   private initFormModel(): void {
     this.createEndpointForm = this._fb.group({
-      name: ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.namePattern), this.validateName.bind(this)])],
+      name: ['', Validators.compose([
+        Validators.required, Validators.pattern(PATTERNS.namePattern), this.validateName.bind(this), this.providerMaxLength.bind(this)
+      ])],
       url: ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.fullUrl), this.validateUrl.bind(this)])],
       account: ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.namePattern)])],
       endpoint_tag: ['', Validators.compose([Validators.required, Validators.pattern(PATTERNS.namePattern)])]
@@ -133,6 +136,10 @@ export class EndpointsComponent implements OnInit {
       return isDublicat ? { isDuplicate: true } : null;
     }
   }
+
+  private providerMaxLength(control) {
+    return control.value.length <= this.maxEndpointNameLength ? null : { limit: true };
+  }
 }
 
 @Component({
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 ec3c3ac..1591221 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
@@ -79,7 +79,7 @@
                                             && resourceForm?.controls['cluster_alias_name'].dirty
                                             && !resourceForm?.controls['cluster_alias_name'].hasError('user-duplication')
                                             && !resourceForm?.controls['cluster_alias_name'].hasError('other-user-duplication')">
-                  Cluster name cannot be longer than {{DICTIONARY[PROVIDER].max_cluster_name_length}} characters
+                  Cluster name cannot be longer than {{maxClusterNameLength}} characters
                   and can only contain letters, numbers, hyphens and '_' but can not end with special
                   characters
                 </span>
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 0c867f9..414f483 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
@@ -48,7 +48,7 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   projectComputations = [];
   selectedImage: any;
   spotInstance: boolean = true;
-
+  maxClusterNameLength: number = 14;
   loading: boolean = false;
 
   public minInstanceNumber: number;
@@ -143,8 +143,11 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
       version: [''],
       shape_master: ['', Validators.required],
       shape_slave: [''],
-      cluster_alias_name: ['', [Validators.required, Validators.pattern(PATTERNS.namePattern), Validators.maxLength(DICTIONARY[this.PROVIDER].max_cluster_name_length),
-      this.checkDuplication.bind(this)]],
+      cluster_alias_name: ['', [
+        Validators.required, Validators.pattern(PATTERNS.namePattern),
+        Validators.maxLength(this.maxClusterNameLength),
+      this.checkDuplication.bind(this)
+      ]],
       instance_number: ['', [Validators.required, Validators.pattern(PATTERNS.nodeCountPattern), this.validInstanceNumberRange.bind(this)]],
       preemptible_instance_number: [0,
         Validators.compose([Validators.pattern(PATTERNS.integerRegex),
@@ -231,11 +234,11 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
   }
 
   private checkDuplication(control) {
-    if (this.containsComputationalResource(control.value, this.userComputations)){
+    if (this.containsComputationalResource(control.value, this.userComputations)) {
       return { 'user-duplication': true };
     }
 
-    if (this.containsComputationalResource(control.value, this.projectComputations)){
+    if (this.containsComputationalResource(control.value, this.projectComputations)) {
       return { 'other-user-duplication': true };
     }
   }
@@ -247,7 +250,8 @@ export class ComputationalResourceCreateDialogComponent implements OnInit {
         this.userComputations = clusterTypes.user_computations;
         this.projectComputations = clusterTypes.project_computations;
 
-        this.clusterTypes.forEach((cluster, index) => this.clusterTypes[index].computation_resources_shapes = SortUtils.shapesSort(cluster.computation_resources_shapes));
+        this.clusterTypes.forEach((cluster, index) => this.clusterTypes[index].computation_resources_shapes =
+          SortUtils.shapesSort(cluster.computation_resources_shapes));
         this.selectedImage = clusterTypes.templates[0];
 
         if (this.selectedImage) {
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 43b3c71..1fd27d6 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
@@ -110,7 +110,7 @@
             <span class="error" *ngIf="!createExploratoryForm?.controls.name.valid
                                         && createExploratoryForm?.controls['name'].dirty
                                         && !createExploratoryForm?.controls['name'].hasError('duplication')">Name
-             cannot be longer than 10 characters and can only
+             cannot be longer than {{maxNotebookLength}} characters and can only
               contain letters, numbers, hyphens and '_' but can not end with special characters
             </span>
           </div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts
index b9fc3f0..d23d7a4 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts
@@ -47,6 +47,7 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit {
   shapes = [] || {};
   resourceGrid: any;
   images: Array<any>;
+  maxNotebookLength: number = 14;
 
   @ViewChild('configurationNode', { static: false }) configuration;
 
@@ -147,7 +148,12 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit {
       version: ['', Validators.required],
       notebook_image_name: [''],
       shape: ['', Validators.required],
-      name: ['', [Validators.required, Validators.pattern(PATTERNS.namePattern), this.providerMaxLength, this.checkDuplication.bind(this)]],
+      name: ['', [
+        Validators.required,
+        Validators.pattern(PATTERNS.namePattern),
+        this.providerMaxLength.bind(this),
+        this.checkDuplication.bind(this)
+      ]],
       cluster_config: ['', [this.validConfiguration.bind(this)]],
       custom_tag: ['', [Validators.pattern(PATTERNS.namePattern)]]
     });
@@ -169,7 +175,7 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit {
 
   private providerMaxLength(control) {
     if (control && control.value)
-      return control.value.length <= 10 ? null : { valid: false };
+      return control.value.length <= this.maxNotebookLength ? null : { valid: false };
   }
 
   private validConfiguration(control) {


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