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/03/30 07:03:30 UTC

[incubator-dlab] 01/01: [DLAB-1672]: Provided mandatory field for library installation

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

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

commit 1b26b2cd2bd6d130da93b7f1be9c26f760385366
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Sun Mar 29 19:39:02 2020 +0300

    [DLAB-1672]: Provided mandatory field for library installation
---
 .../management/endpoints/endpoints.component.ts    | 31 +++++++++++++---------
 .../ami-create-dialog.component.ts                 |  5 ++--
 .../install-libraries.component.html               | 18 +++++++++----
 .../install-libraries.component.scss               |  8 ++++++
 .../install-libraries.component.ts                 | 23 +++++++++-------
 .../install-libraries/install-libraries.model.ts   |  1 -
 6 files changed, 54 insertions(+), 32 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 d29a5d0..45c6a23 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
@@ -25,7 +25,7 @@ import { ToastrService } from 'ngx-toastr';
 import { EndpointService } from '../../../core/services';
 import { NotificationDialogComponent } from '../../../shared/modal-dialog/notification-dialog';
 import { PATTERNS } from '../../../core/util';
-import { map } from "rxjs/operators";
+import { map } from 'rxjs/operators';
 
 export interface Endpoint {
   name: string;
@@ -76,9 +76,14 @@ export class EndpointsComponent implements OnInit {
             project.name,
             resource.exploratories.filter(notebook => notebook.project === project.name),
             project.endpoints.filter(endpoint => endpoint.name === data.name)[0].status))
-          .filter(project => project.nodeStatus !== "TERMINATED" && project.nodeStatus !== "TERMINATING" && project.nodeStatus !== "FAILED")))
+          .filter(project => project.nodeStatus !== 'TERMINATED'
+            && project.nodeStatus !== 'TERMINATING'
+            && project.nodeStatus !== 'FAILED'
+          )))
       .subscribe((resource: any) => {
-         this.dialog.open(NotificationDialogComponent, { data: { type: 'confirmation', item: data, list:  resource }, panelClass: 'modal-sm' })
+         this.dialog.open(NotificationDialogComponent, { data: {
+           type: 'confirmation', item: data, list:  resource
+           }, panelClass: 'modal-sm' })
          .afterClosed().subscribe(result => {
          result === 'noTerminate' && this.deleteEndpointOption(data, false);
          result === 'terminate' && this.deleteEndpointOption(data, true);
@@ -86,13 +91,13 @@ export class EndpointsComponent implements OnInit {
     });
   }
 
-  public getEndpoinConnectionStatus(url){
-    let getStatus = this.endpointService.getEndpoinConnectionStatus(encodeURIComponent(url));
+  public getEndpoinConnectionStatus(url) {
+    const getStatus = this.endpointService.getEndpoinConnectionStatus(encodeURIComponent(url));
     this.dialog.open(EndpointTestResultDialogComponent, { data: {url: url, getStatus}, panelClass: 'modal-sm' });
   }
 
   private static createResourceList(name: string, resource: Array<any>, nodeStatus: string): Object {
-    return {name, resource, nodeStatus}
+    return {name, resource, nodeStatus};
   }
 
   private initFormModel(): void {
@@ -104,26 +109,26 @@ export class EndpointsComponent implements OnInit {
     });
   }
 
-  private deleteEndpointOption(data, option): void{
+  private deleteEndpointOption(data, option): void {
     this.endpointService.deleteEndpoint(`${data.name}?with-resources=${option}`).subscribe(() => {
       this.toastr.success(option ? 'Endpoint successfully disconnected. All related resources are terminating!' : 'Endpoint successfully disconnected!' , 'Success!');
       this.getEndpointList();
     }, error => this.toastr.error(error.message || 'Endpoint creation failed!', 'Oops!'));
   }
 
-  private getEndpointList() : void{
+  private getEndpointList(): void {
     this.endpointService.getEndpointsData().subscribe((endpoints: any) => this.endpoints = endpoints);
   }
 
   private validateUrl(control) {
-    if (control && control.value){
+    if (control && control.value) {
       const isDublicat = this.endpoints.some(endpoint => endpoint['url'].toLocaleLowerCase() === control.value.toLowerCase());
       return isDublicat ? { isDuplicate: true } : null;
     }
   }
 
   private validateName(control) {
-    if (control && control.value){
+    if (control && control.value) {
       const isDublicat = this.endpoints.some(endpoint => endpoint['name'].toLocaleLowerCase() === control.value.toLowerCase());
       return isDublicat ? { isDuplicate: true } : null;
     }
@@ -212,14 +217,14 @@ export class EndpointTestResultDialogComponent {
         this.response = true;
         return;
       },
-      ()=> {
+      () => {
         this.isConnected = false;
         this.response = true;
         return;
-      })
+      });
   }
   private cutToLongUrl(url) {
-    return url.length > 25 ? url.slice(0,25) + '...' : url
+    return url.length > 25 ? url.slice(0, 25) + '...' : url;
   }
 
 }
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/ami-create-dialog/ami-create-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/ami-create-dialog/ami-create-dialog.component.ts
index 0ec266e..e783951 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/ami-create-dialog/ami-create-dialog.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/ami-create-dialog/ami-create-dialog.component.ts
@@ -23,7 +23,7 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
 import { ToastrService } from 'ngx-toastr';
 
 import { UserResourceService } from '../../../core/services';
-import { HTTP_STATUS_CODES } from '../../../core/util';
+import {HTTP_STATUS_CODES, PATTERNS} from '../../../core/util';
 import { DICTIONARY } from '../../../../dictionary/global.dictionary';
 
 @Component({
@@ -36,7 +36,6 @@ export class AmiCreateDialogComponent implements OnInit {
   public notebook: any;
   public createAMIForm: FormGroup;
   public provider: string;
-  namePattern = '[-_a-zA-Z0-9]+';
   delimitersRegex = /[-_]?/g;
   imagesList: any;
 
@@ -64,7 +63,7 @@ export class AmiCreateDialogComponent implements OnInit {
 
   private initFormModel(): void {
     this.createAMIForm = this._fb.group({
-      name: ['', [Validators.required, Validators.pattern(this.namePattern), this.providerMaxLength, this.checkDuplication.bind(this)]],
+      name: ['', [Validators.required, Validators.pattern(PATTERNS.namePattern), this.providerMaxLength, this.checkDuplication.bind(this)]],
       description: [''],
       exploratory_name: [this.notebook.name],
       project_name: [this.notebook.project]
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 b0c2092..968f1a3 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
@@ -28,7 +28,7 @@
       <p class=" message">Cannot install libraries: Exploratory
         <strong>{{ notebook?.name }}</strong> is not running</p>
     </div>
-    <div class="loading-block" *ngIf="!libs_uploaded && uploading && notebook?.status === 'running'">
+    <div class="loading-block" *ngIf="!libs_uploaded && uploading && data.status === 'running'">
       <div class="uploading">
         <p>Please wait until DLab loads full list of available libraries for you...</p>
         <img src="assets/img/gif-spinner.gif" alt="loading">
@@ -48,12 +48,20 @@
               <label class="label">Select group</label>
               <div class="control">
                 <dropdown-list #groupSelect (selectedItem)="onUpdate($event)"></dropdown-list>
+                <span class="error-message" *ngIf="!group && libSearch.value">Group field is required. Please choose appropriate group.</span>
               </div>
             </div>
           </div>
           <div class="search">
             <mat-form-field class="chip-list">
-              <input type="text" [placeholder]="group === 'java' ? 'Enter library name in <groupId>:<artifactId>:<versionId> format' : 'Enter library name'" matInput [formControl]="libSearch" [value]="query" [matAutocomplete]="auto">
+              <input
+                type="text"
+                [placeholder]="group === 'java' ? 'Enter library name in <groupId>:<artifactId>:<versionId> format' : 'Enter library name'"
+                matInput
+                [formControl]="libSearch"
+                [value]="query"
+                [matAutocomplete]="auto"
+              >
               <mat-icon matSuffix>search</mat-icon>
               <mat-autocomplete #auto="matAutocomplete" class="suggestions">
                 <ng-template ngFor let-item [ngForOf]="filteredList" let-i="index">
@@ -84,7 +92,7 @@
                 </mat-option>
               </mat-autocomplete>
             </mat-form-field>
-            <div class="list-selected list-container" id="scrolling">
+            <div class="list-selected list-container" id='scrolling'>
               <mat-chip-list *ngIf="model.selectedLibs.length && libs_uploaded">
                 <mat-chip *ngFor="let item of model.selectedLibs">
                   {{ item.name }}
@@ -140,7 +148,7 @@
         <ng-container *ngIf="filtered" >
          <mat-list-item class="lib-col filter-row">
           <th class="lib-name lib-input">
-            <input placeholder="Filter by library name" [value]="filterModel.name" (input)="filterModel.name = $event.target.value" type="text" class="form-control filter-field "/>
+            <input placeholder="Filter by library name" [value]="filterModel.name" (input)="filterModel.name = $event.target['value']" type="text" class="form-control filter-field "/>
           </th>
           <th class="lib-group lib-col">
               <multi-select-dropdown
@@ -185,7 +193,7 @@
                  </button>
 
                  <button mat-icon-button class="btn apply" (click)="filterLibs()">
-                   <i class="material-icons"  [ngClass]="{'not-allowed': filterModel.length == 0}">done</i>
+                   <i class="material-icons"  [ngClass]="{'not-allowed': filterModel.length === 0}">done</i>
                  </button>
                </div>
              </th>
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 8ff7918..a6b7070 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
@@ -444,6 +444,14 @@ mat-chip.mat-chip:not(.mat-basic-chip) {
   }
 }
 
+.error-message{
+  position: absolute;
+  left: 20%;
+  top: 40px;
+  font-size: 11px;
+  color: red;
+}
+
 @media screen and (min-width: 1281px) {
   .libs-info {
     height: 60%;
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 ebe8281..839bc46 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
@@ -89,14 +89,15 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
   }
 
   ngOnInit() {
-    this.libSearch.disable();
+    this.open(this.data);
+    this.uploadLibGroups();
     this.libSearch.valueChanges.pipe(
       debounceTime(1000))
       .subscribe(newValue => {
         this.query = newValue || '';
         this.filterList();
       });
-    this.open(this.data);
+    this.getInstalledLibsByResource();
   }
 
   ngOnDestroy() {
@@ -105,6 +106,8 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
   }
 
   uploadLibGroups(): void {
+    this.libs_uploaded = false;
+    this.uploading = true;
     this.librariesInstallationService.getGroupsList(this.notebook.project, this.notebook.name, this.model.computational_name)
       .subscribe(
         response => {
@@ -153,13 +156,11 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
       this.group = $event.model.value;
     } else if ($event.model.type === 'destination') {
       this.resetDialog();
-
       this.destination = $event.model.value;
       this.destination && this.destination.type === 'СOMPUTATIONAL'
         ? this.model.computational_name = this.destination.name
         : this.model.computational_name = null;
 
-      this.libSearch.enable();
       this.uploadLibGroups();
       this.getInstalledLibsByResource();
     }
@@ -199,6 +200,7 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
 
   public open(notebook): void {
     this.notebook = notebook;
+    this.destination = this.getResourcesList()[0];
     this.model = new InstallLibrariesModel(notebook,
       response => {
         if (response.status === HTTP_STATUS_CODES.OK) {
@@ -213,7 +215,7 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
         this.selectorsReset();
       },
       this.librariesInstallationService);
-  }
+ }
 
   public showErrorMessage(item): void {
     const dialogRef: MatDialogRef<ErrorMessageDialogComponent> = this.dialog.open(
@@ -307,9 +309,11 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
   }
 
   private selectorsReset(): void {
-    this.resource_select && this.resource_select.setDefaultOptions(this.getResourcesList(),
-      'Select resource', 'destination', 'title', 'array');
-    this.group_select && this.group_select.setDefaultOptions([], '', 'group_lib', null, 'array');
+    if( this.destination.name === this.getResourcesList()[0].name) {
+      return;
+    }
+    this.destination = this.getResourcesList()[0];
+    this.uploadLibGroups();
   }
 
   private resetDialog(): void {
@@ -321,10 +325,9 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
     this.uploading = false;
     this.model.selectedLibs = [];
     this.filteredList = null;
-    this.destination = null;
+    // this.destination = null;
     this.groupsList = [];
 
-    this.libSearch.disable();
     clearTimeout(this.clear);
     clearTimeout(this.loadLibsTimer);
     this.selectorsReset();
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.model.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.model.ts
index c47673b..b201904 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.model.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/install-libraries/install-libraries.model.ts
@@ -81,7 +81,6 @@ export class InstallLibrariesModel {
   }
 
   private installLibraries(retry?: Library, item?): Observable<{}> {
-    console.log(this.notebook.project);
     const lib_list: any = {
       project_name: this.notebook.project,
       exploratory_name: this.notebook.name,


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