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/08/10 16:10:49 UTC

[incubator-dlab] branch DLAB-1986 created (now 34e1019)

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

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


      at 34e1019  [DLAB-1986]: Added validation for library version

This branch includes the following new commits:

     new 34e1019  [DLAB-1986]: Added validation for library version

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-dlab] 01/01: [DLAB-1986]: Added validation for library version

Posted by dg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 34e1019dbcaa5e53a4261c98334f62b776e8d3ea
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Mon Aug 10 19:10:02 2020 +0300

    [DLAB-1986]: Added validation for library version
---
 .../resources/webapp/src/app/core/util/patterns.ts    |  1 +
 .../install-libraries.component.html                  |  7 ++++---
 .../install-libraries.component.scss                  |  5 ++++-
 .../install-libraries/install-libraries.component.ts  | 19 +++++++++++++++----
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/patterns.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/patterns.ts
index 981e661..7201423 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/util/patterns.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/patterns.ts
@@ -25,5 +25,6 @@ export const PATTERNS = {
   nodeCountPattern: '^[1-9]\\d*$',
   integerRegex: '^[0-9]*$',
   folderRegex: /^[a-zA-Z0-9!@$^&*()_+\-=\[\]{};':|,.<>~` ]*$/,
+  libVersion: /^[a-zA-Z0-9_\-:/~.+`]*$/,
   fullUrl: /^(http?|ftp|https):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+([.:])(\d{4}|com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*\/$/
 };
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.html b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.html
index f0f2c93..4eceabf 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.html
@@ -106,14 +106,15 @@
                   [placeholder]="'Enter library version (optional)'"
                   [(ngModel)]="lib.version"
                   [disabled]="!lib.name"
+                  (keyup)="validateVersion(lib.version)"
                   (keydown.enter)="addLibrary(lib)"
                 >
-
+                <span class="error-message version-error" *ngIf="isVersionInvalid">Library version can only contain Latin letters, numbers and special characters -, _, :, /, ~, ., +.</span>
                 <span class="plus-icon"
-                      [ngClass]="{'not-allow': lib.name?.length < 2 || (isAutoComplete && !isLibSelected) || this.selectedLib?.isInSelectedList}"
+                      [ngClass]="{'not-allow': lib.name?.length < 2 || (isAutoComplete && !isLibSelected ) || this.selectedLib?.isInSelectedList || isVersionInvalid}"
                       matTooltip="Library is in selected list" matTooltipPosition="above" [matTooltipDisabled]="!this.selectedLib?.isInSelectedList"
                 >
-                  <mat-icon  (click)="addLibrary(lib)"  [ngClass]="{'not-allowed': lib.name?.length < 2 || (isAutoComplete && !isLibSelected) || this.selectedLib?.isInSelectedList }">add</mat-icon>
+                  <mat-icon  (click)="addLibrary(lib)"  [ngClass]="{'not-allowed': lib.name?.length < 2 || (isAutoComplete && !isLibSelected) || this.selectedLib?.isInSelectedList || isVersionInvalid}">add</mat-icon>
                 </span>
               </div>
             </div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.scss b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.scss
index 2b95c0b..05648e1 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.scss
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.scss
@@ -241,7 +241,7 @@ ul.resources{
       padding-bottom: 0;
       flex-direction: column;
       box-shadow: 0 3px 1px -2px rgba(0, 0, 0, .2), 0 2px 2px 0 rgba(0, 0, 0, .14), 0 1px 5px 0 rgba(0, 0, 0, .12);
-      margin-top: 25px;
+      margin-top: 30px;
 
       .mat-form-field-flex {
         padding-left: 15px;
@@ -565,6 +565,9 @@ mat-chip.mat-chip:not(.mat-basic-chip) {
   top: 40px;
   font-size: 11px;
   color: red;
+  &.version-error{
+    left: 0;
+  }
 }
 
 .info-icon{
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.ts
index 438d95d..5eb86c4 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.component.ts
@@ -26,7 +26,7 @@ import {debounceTime, take, takeUntil} from 'rxjs/operators';
 
 import { InstallLibrariesModel } from './install-libraries.model';
 import { LibrariesInstallationService } from '../../../core/services';
-import { SortUtils, HTTP_STATUS_CODES } from '../../../core/util';
+import {SortUtils, HTTP_STATUS_CODES, PATTERNS} from '../../../core/util';
 import {FilterLibsModel} from './filter-libs.model';
 import {Subject} from 'rxjs';
 
@@ -84,8 +84,9 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
   @ViewChild('resourceSelect', { static: false }) resource_select;
   @ViewChild('trigger', { static: false }) matAutoComplete;
   public lib: Library = {name: '', version: ''};
-  private selectedLib: any = null;
-  private isLibSelected: boolean = false;
+  public selectedLib: any = null;
+  public isLibSelected: boolean = false;
+  public isVersionInvalid: boolean = false;
 
   constructor(
     @Inject(MAT_DIALOG_DATA) public data: any,
@@ -176,6 +177,8 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
         this.libSearch.enable();
       }
       this.lib = {name: '', version: ''};
+      this.isVersionInvalid = false;
+      this.libSearch.setValue('');
     } else if ($event.model.type === 'destination') {
       this.isLibSelected = false;
       this.destination = $event.model.value;
@@ -215,7 +218,7 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
 
   public addLibrary(item): void {
     this.isLibSelected = false;
-    if ( !this.selectedLib.isInSelectedList) {
+    if ( !this.selectedLib.isInSelectedList && !this.isVersionInvalid) {
       if ( this.selectedLib && this.group !== 'java') {
         this.model.selectedLibs.push({ group: this.group, name: item.name, version: item.version || 'N/A' });
       } else {
@@ -469,6 +472,14 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
   public clearLibSelection(event) {
     this.isLibSelected = false;
   }
+
+  private validateVersion(version) {
+    if (version.length) {
+      this.isVersionInvalid = !PATTERNS.libVersion.test(version);
+    } else {
+      this.isVersionInvalid = false;
+    }
+  }
 }
 
 @Component({


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