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 9c78057246c60630c39a01e3f0a8ee4e8c67c461
Author: Andriana Kovalyshyn <andriana_kovalys...@epam.com>
AuthorDate: Mon Jun 3 13:42:30 2019 +0300

    [DLAB-655]: added endpoints to env creation;
---
 .../resources/webapp/src/app/core/util/index.ts    |   1 +
 .../resources/webapp/src/app/core/util/patterns.ts |   2 +-
 .../create-environment.component.scss              |   5 +
 ...ratory-environment-create-dialog.component.html |  21 ++-
 ...loratory-environment-create-dialog.component.ts |  18 +--
 .../exploratory-environment-create.model.ts        | 156 ---------------------
 .../webapp/src/assets/styles/_general.scss         |   2 +-
 .../resources/webapp/src/assets/styles/_theme.scss |   3 +-
 8 files changed, 38 insertions(+), 170 deletions(-)

diff --git 
a/services/self-service/src/main/resources/webapp/src/app/core/util/index.ts 
b/services/self-service/src/main/resources/webapp/src/app/core/util/index.ts
index 6dccb52..35462c0 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/util/index.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/index.ts
@@ -23,3 +23,4 @@ export * from './errorUtils';
 export * from './dateUtils';
 export * from './fileUtils';
 export * from './checkUtils';
+export * from './patterns';
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 3cb9b12..071bb84 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
@@ -18,5 +18,5 @@
  */
 
 export const PATTERNS = {
-  
+  namePattern: '[-_a-zA-Z0-9]*[_-]*[a-zA-Z0-9]+',
 }
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/create-environment.component.scss
 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/create-environment.component.scss
index f5b20c8..c63436c 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/create-environment.component.scss
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/create-environment.component.scss
@@ -54,4 +54,9 @@
     right: 0;
     bottom: 3px;
   }
+}
+
+.content-box {
+  max-height: 560px;
+  overflow-y: auto;
 }
\ No newline at end of file
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.html
index 0ff5bbd..7f0d440 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.html
@@ -30,8 +30,23 @@
           <div class="control selector-wrapper">
             <mat-form-field>
               <mat-label>Select project</mat-label>
-              <mat-select (selectionChange)="getTemplates($event)" 
formControlName="project" disableOptionCentering>
-                <mat-option *ngFor="let project of projects" 
[value]="project.name">{{ project.name }}</mat-option>
+              <mat-select formControlName="project" disableOptionCentering>
+                <mat-option *ngFor="let project of projects" 
[value]="project.name" (click)="getTemplates($event, project)">{{ project.name 
}}</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">
+          <label class="label">Select endpoint</label>
+          <div class="control selector-wrapper" [ngClass]="{ 'not-active' : 
!endpoints.length }">
+            <mat-form-field>
+              <mat-label>Select endpoint</mat-label>
+              <mat-select formControlName="endpoint" disableOptionCentering>
+                <mat-option *ngFor="let endpoint of endpoints" 
[value]="endpoint">{{ endpoint }}</mat-option>
               </mat-select>
               <button class="caret">
                 <i class="material-icons">keyboard_arrow_down</i>
@@ -42,7 +57,7 @@
 
         <div class="control-group">
           <label class="label">Select template</label>
-          <div class="control selector-wrapper"  [ngClass]="{ 'not-active' : 
!templates.length }">
+          <div class="control selector-wrapper" [ngClass]="{ 'not-active' : 
!templates.length }">
             <mat-form-field>
               <mat-label>Select template</mat-label>
               <mat-select formControlName="version" disableOptionCentering 
[disabled]="!templates.length">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.ts
index 54e22de..adab1b1 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create-dialog.component.ts
@@ -17,15 +17,14 @@
  * under the License.
  */
 
-import { Component, OnInit, ViewChild, ChangeDetectorRef, Inject } from 
'@angular/core';
+import { Component, OnInit, ViewChild, Inject } from '@angular/core';
 import { FormGroup, FormBuilder, Validators } from '@angular/forms';
 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
 import { ToastrService } from 'ngx-toastr';
 
 import { Project } from '../../../administration/project/project.component';
-
 import { UserResourceService, ProjectService } from '../../../core/services';
-import { CheckUtils, HTTP_STATUS_CODES } from '../../../core/util';
+import { CheckUtils, HTTP_STATUS_CODES, PATTERNS } from '../../../core/util';
 import { DICTIONARY } from '../../../../dictionary/global.dictionary';
 import { CLUSTER_CONFIGURATION } from 
'../../computational/computational-resource-create-dialog/cluster-configuration-templates';
 
@@ -37,14 +36,15 @@ import { CLUSTER_CONFIGURATION } from 
'../../computational/computational-resourc
 
 export class ExploratoryEnvironmentCreateComponent implements OnInit {
   readonly DICTIONARY = DICTIONARY;
+  public createExploratoryForm: FormGroup;
+
   projects: Project[] = [];
   templates = [];
+  endpoints: Array<String> = [];
   currentTemplate: any;
   shapes: Array<any> = [];
-  namePattern = '[-_a-zA-Z0-9]*[_-]*[a-zA-Z0-9]+';
   resourceGrid: any;
   images: Array<any>;
-  public createExploratoryForm: FormGroup;
 
   @ViewChild('configurationNode') configuration;
 
@@ -54,7 +54,6 @@ export class ExploratoryEnvironmentCreateComponent implements 
OnInit {
     public dialogRef: MatDialogRef<ExploratoryEnvironmentCreateComponent>,
     private userResourceService: UserResourceService,
     private _fb: FormBuilder,
-    private changeDetector: ChangeDetectorRef,
     private projectService: ProjectService
   ) {
     this.resourceGrid = data;
@@ -69,7 +68,8 @@ export class ExploratoryEnvironmentCreateComponent implements 
OnInit {
     this.projectService.getProjectsList().subscribe((projects: any) => 
this.projects = projects);
   }
 
-  public getTemplates($event) {
+  public getTemplates($event, project) {
+    this.endpoints = project.endpoints;
     
this.userResourceService.getExploratoryTemplates($event.value).subscribe(templates
 => this.templates = templates);
   }
 
@@ -96,6 +96,7 @@ export class ExploratoryEnvironmentCreateComponent implements 
OnInit {
     const value = (this.configuration.nativeElement.checked && 
this.createExploratoryForm)
       ? JSON.stringify(CLUSTER_CONFIGURATION.SPARK, undefined, 2) : '';
 
+    document.querySelector('#configurationNode').scrollIntoView({ block: 
'start', behavior: 'smooth' });
     
this.createExploratoryForm.controls['configuration_parameters'].setValue(value);
   }
 
@@ -103,10 +104,11 @@ export class ExploratoryEnvironmentCreateComponent 
implements OnInit {
     
     this.createExploratoryForm = this._fb.group({
       project: ['', Validators.required],
+      endpoint: ['', Validators.required],
       version: ['', Validators.required],
       notebook_image_name: [''],
       shape: ['', Validators.required],
-      name: ['', [Validators.required, Validators.pattern(this.namePattern),
+      name: ['', [Validators.required, 
Validators.pattern(PATTERNS.namePattern),
                               this.providerMaxLength, 
this.checkDuplication.bind(this)]],
       cluster_config: ['', [this.validConfiguration.bind(this)]]
     });
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create.model.ts
 
b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create.model.ts
deleted file mode 100644
index a22262c..0000000
--- 
a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/exploratory-environment-create-dialog/exploratory-environment-create.model.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * 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
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/* tslint:disable:no-empty */
-
-import { Observable } from 'rxjs';
-import { Response } from '@angular/http';
-
-import { ExploratoryEnvironmentVersionModel, ResourceShapeTypesModel } from 
'../../../core/models';
-import { UserResourceService } from '../../../core/services';
-import { SortUtil } from '../../../core/util';
-
-export class ExploratoryEnvironmentCreateModel {
-
-  confirmAction: Function;
-  selectedItemChanged: Function;
-
-  selectedItem: ExploratoryEnvironmentVersionModel = new 
ExploratoryEnvironmentVersionModel('', {}, new ResourceShapeTypesModel({}));
-  exploratoryEnvironmentTemplates: Array<ExploratoryEnvironmentVersionModel> = 
[];
-
-  public notebookImage: any;
-  private environment_image: string;
-  private environment_name: string;
-  private environment_template_name: string;
-  private environment_version: string;
-  private environment_shape: string;
-  private config: any;
-  private userResourceService: UserResourceService;
-  private continueWith: Function;
-
-  static getDefault(userResourceService): ExploratoryEnvironmentCreateModel {
-    return new ExploratoryEnvironmentCreateModel('', '', '', '', '', () => { 
}, () => { }, null, null, userResourceService);
-  }
-
-  constructor(
-    environment_image: string,
-    environment_name: string,
-    environment_template_name: string,
-    environment_version: string,
-    environment_shape: string,
-    fnProcessResults: any,
-    fnProcessErrors: any,
-    selectedItemChanged: Function,
-    continueWith: Function,
-    userResourceService: UserResourceService
-  ) {
-    this.userResourceService = userResourceService;
-    this.selectedItemChanged = selectedItemChanged;
-    this.continueWith = continueWith;
-    this.prepareModel(
-      environment_image,
-      environment_name,
-      environment_template_name,
-      environment_version,
-      environment_shape,
-      fnProcessResults,
-      fnProcessErrors);
-  }
-
-  public setSelectedItem(item: ExploratoryEnvironmentVersionModel): void {
-    this.selectedItem = item;
-  }
-
-  public setSelectedTemplate(index): void {
-    if (this.exploratoryEnvironmentTemplates && 
this.exploratoryEnvironmentTemplates[index]) {
-      this.selectedItem = this.exploratoryEnvironmentTemplates[index];
-      if (this.selectedItemChanged)
-        this.selectedItemChanged();
-    }
-  }
-
-  public setCreatingParams(name, shape, config?): void {
-    this.environment_image = this.selectedItem.image;
-    this.environment_version = this.selectedItem.version;
-    this.environment_template_name = this.selectedItem.template_name;
-    this.environment_name = name;
-    this.environment_shape = shape;
-    this.config = config;
-  }
-
-  // public loadTemplates(): void {
-  //   if (this.exploratoryEnvironmentTemplates.length === 0)
-  //     this.userResourceService.getExploratoryEnvironmentTemplates()
-  //       .subscribe(
-  //       data => {
-  //         for (let parentIndex = 0; parentIndex < data.length; 
parentIndex++) {
-
-  //           const shapeJson = 
data[parentIndex].exploratory_environment_shapes;
-  //           const exploratoryJson = 
data[parentIndex].exploratory_environment_versions;
-  //           const shapeObj: ResourceShapeTypesModel = new 
ResourceShapeTypesModel(SortUtil.shapesSort(shapeJson));
-
-  //           for (let index = 0; index < exploratoryJson.length; index++)
-  //             this.exploratoryEnvironmentTemplates.push(
-  //               new 
ExploratoryEnvironmentVersionModel(data[parentIndex].image, 
exploratoryJson[index], shapeObj));
-  //         }
-  //         if (this.exploratoryEnvironmentTemplates.length > 0) {
-  //           this.exploratoryEnvironmentTemplates.sort(function(t1, t2) {
-  //             return ((t1.template_name < t2.template_name) ? -1 : 
((t1.template_name > t2.template_name) ? 1 : 0));
-  //           });
-  //           this.setSelectedTemplate(0);
-  //         }
-
-  //         if (this.continueWith)
-  //           this.continueWith();
-  //       });
-  // }
-
-  public resetModel(): void {
-    this.setSelectedTemplate(0);
-  }
-
-  private createExploratoryEnvironment(): Observable<{}> {
-    const params: any = {
-      image: this.environment_image,
-      template_name: this.environment_template_name,
-      name: this.environment_name,
-      shape: this.environment_shape,
-      version: this.environment_version
-    };
-    if (this.notebookImage)
-      params.notebook_image_name = this.notebookImage;
-
-    if (this.config) params.cluster_config = this.config;
-    return this.userResourceService.createExploratoryEnvironment(params);
-  }
-
-  private prepareModel(
-    environment_image: string,
-    environment_name: string,
-    environment_template_name: string,
-    environment_version: string,
-    environment_shape: string,
-    fnProcessResults: any, fnProcessErrors: any): void {
-
-    this.setCreatingParams(environment_name, environment_shape, this.config);
-    this.confirmAction = () => this.createExploratoryEnvironment()
-      .subscribe(
-        response => fnProcessResults(response),
-        error => fnProcessErrors(error));
-  }
-}
diff --git 
a/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
 
b/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
index ad9a551..8a3250e 100644
--- 
a/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
+++ 
b/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
@@ -45,7 +45,7 @@ input[type='password']:not(.mat-input-element),
 textarea {
   width: 100%;
   height: 36px;
-  padding: 0 20px;
+  padding: 0 10px;
   color: #455c74;
   color: #6e7ca0;
   border: 1px solid transparent;
diff --git 
a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss 
b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss
index a95efee..03dc54f 100644
--- 
a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss
+++ 
b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss
@@ -260,7 +260,8 @@
   .mat-reset {
     .mat-form-field-type-mat-select:not(.mat-form-field-disabled) {
       .mat-form-field-flex {
-        line-height: 1;
+        // line-height: 1;
+        // padding-top: 2px;
       }
     }
     .mat-form-field {


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

Reply via email to