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 f774b65bce8cb341398e2f51546a7c1724e531b4
Author: Andriana Kovalyshyn <andriana_kovalys...@epam.com>
AuthorDate: Tue Jun 4 17:26:39 2019 +0300

    [DLAB-735]: added endpoints validation
---
 .../administration/management/endpoints/endpoints.component.ts    | 8 ++++----
 .../project/project-form/project-form.component.html              | 4 ++++
 .../project/project-form/project-form.component.scss              | 2 --
 .../src/main/resources/webapp/src/app/core/util/patterns.ts       | 5 +++--
 services/self-service/src/main/resources/webapp/src/styles.scss   | 2 ++
 5 files changed, 13 insertions(+), 8 deletions(-)

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 da41791..0d44188 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
@@ -24,6 +24,7 @@ import { ToastrService } from 'ngx-toastr';
 
 import { EndpointService } from '../../../core/services';
 import { NotificationDialogComponent } from 
'../../../shared/modal-dialog/notification-dialog';
+import { PATTERNS } from '../../../core/util';
 
 export interface Endpoint {
   name: string;
@@ -38,7 +39,6 @@ export interface Endpoint {
 })
 export class EndpointsComponent implements OnInit {
   public createEndpointForm: FormGroup;
-  namePattern = '[-_a-zA-Z0-9]+';
   endpoints: Endpoint[] = [];
   displayedColumns: string[] = ['name', 'url', 'account', 'actions'];
 
@@ -75,9 +75,9 @@ export class EndpointsComponent implements OnInit {
 
   private initFormModel(): void {
     this.createEndpointForm = this._fb.group({
-      name: ['', Validators.compose([Validators.required, 
Validators.pattern(this.namePattern)])],
-      url: ['', Validators.compose([Validators.required, 
Validators.pattern(this.namePattern)])],
-      account: ['', Validators.compose([Validators.required, 
Validators.pattern(this.namePattern)])]
+      name: ['', Validators.compose([Validators.required, 
Validators.pattern(PATTERNS.namePattern)])],
+      url: ['', Validators.compose([Validators.required, 
Validators.pattern(PATTERNS.url)])],
+      account: ['', Validators.compose([Validators.required, 
Validators.pattern(PATTERNS.namePattern)])]
     });
   }
 
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.html
index b3880fe..92c003e 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.html
@@ -31,6 +31,10 @@
                 <input type="text" formControlName="name" placeholder="Enter 
project name"
                   (blur)="generateProjectTag($event)" [ngClass]="{ 
'not-allowed' : item }">
                 <span class="error" 
*ngIf="projectForm?.controls.name.hasError('duplication')">This project name 
already exists.</span>
+                <span class="error" *ngIf="!projectForm?.controls.name.valid
+                  && !projectForm?.controls.name.hasError('duplication')
+                  && projectForm?.controls.name.dirty">Project name can only 
contain letters, numbers, hyphens and '_' but can not end with special 
characters
+                </span>
               </div>
             </div>
             <div class="control-group">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.scss
 
b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.scss
index 5a7d3e3..4c241e9 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.scss
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.scss
@@ -34,10 +34,8 @@
   }
 
   .error {
-    font-family: 'Open Sans', sans-serif;
     position: absolute;
     right: 0;
     bottom: 2px;
-    font-weight: 300;
   }
 }
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 c68d764..f78e7e6 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
@@ -5,7 +5,7 @@
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * with the License.  You may obtain a copy  of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -19,5 +19,6 @@
 
 export const PATTERNS = {
   namePattern: '[-_a-zA-Z0-9]*[_-]*[a-zA-Z0-9]+',
-  delimitersRegex: '/[-_]?/g'
+  delimitersRegex: '/[-_]?/g',
+  url: 
'^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$'
 }
diff --git a/services/self-service/src/main/resources/webapp/src/styles.scss 
b/services/self-service/src/main/resources/webapp/src/styles.scss
index c765793..1136d98 100644
--- a/services/self-service/src/main/resources/webapp/src/styles.scss
+++ b/services/self-service/src/main/resources/webapp/src/styles.scss
@@ -126,6 +126,8 @@ mat-chip.mat-chip strong {
 .error {
   color: #f1696e;
   font-size: 12px;
+  font-family: 'Open Sans', sans-serif;
+  font-weight: 300;
 }
 .not-allowed {
   cursor: not-allowed !important;


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

Reply via email to