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/07/13 14:03:29 UTC
[incubator-dlab] 03/03: [DLAB-1750] Added validation for existing
and installed libs
This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch DLAB-1749
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit cdecfd13ebe2d02e5b4880dacc5833046fae2f38
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Mon Jul 13 16:30:02 2020 +0300
[DLAB-1750] Added validation for existing and installed libs
---
.../install-libraries/install-libraries.component.html | 10 +++++++++-
.../install-libraries/install-libraries.component.scss | 7 ++++++-
.../install-libraries/install-libraries.component.ts | 14 ++++++++++----
.../install-libraries/install-libraries.model.ts | 2 +-
4 files changed, 26 insertions(+), 7 deletions(-)
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 285014d..409faeb 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
@@ -62,7 +62,15 @@
[value]="query"
[matAutocomplete]="auto"
>
- <mat-icon matSuffix (click)="addLibrary(query)" class="add-icon">add</mat-icon>
+ <span class="add-icon" [matTooltip]="!isLibExist ? 'Current library dosen\'t exist' : 'You have already added or installed current library'"
+ matTooltipPosition="above"
+ [matTooltipDisabled] = "isLibExist && (isInSelectedList || isInstalled)"
+ >
+ <button mat-icon-button class="btn" [disabled]="!isLibExist || query.length < 1 ||
+ isDuplicated({name: query.slice(0, query.indexOf(':')), version: query.slice(query.indexOf(':') + 1) || 'N/A'})" (click)="addLibrary(query);$event.stopPropagation()">
+ <mat-icon matSuffix >add</mat-icon>
+ </button>
+ </span>
<mat-autocomplete #auto="matAutocomplete" class="suggestions" >
<ng-template ngFor let-item [ngForOf]="filteredList" let-i="index" *ngIf="query.indexOf(':') === -1">
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 b87846d..55b68d8 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
@@ -158,8 +158,13 @@ ul.resources{
}
.add-icon{
- margin-right: 10px;
cursor: pointer;
+ position: absolute;
+ top: -13px;
+ right: 10px;
+ .mat-icon{
+ font-size: 24px;
+ }
}
.search-box {
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 063e406..a3af674 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
@@ -29,6 +29,11 @@ import { LibrariesInstallationService } from '../../../core/services';
import { SortUtils, HTTP_STATUS_CODES } from '../../../core/util';
import {FilterLibsModel} from './filter-libs.model';
+interface Library {
+ name: string;
+ version: string;
+}
+
@Component({
selector: 'install-libraries',
@@ -77,6 +82,7 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
@ViewChild('groupSelect', { static: false }) group_select;
@ViewChild('resourceSelect', { static: false }) resource_select;
public isLibInfoOpened = { };
+ private isLibExist: boolean;
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
@@ -91,14 +97,12 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
ngOnInit() {
this.open(this.data);
- this.uploadLibGroups();
this.libSearch.valueChanges.pipe(
debounceTime(1000))
.subscribe(newValue => {
this.query = newValue || '';
this.filterList();
});
- this.getInstalledLibsByResource();
}
ngOnDestroy() {
@@ -161,7 +165,6 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
this.destination && this.destination.type === 'СOMPUTATIONAL'
? this.model.computational_name = this.destination.name
: this.model.computational_name = null;
-
this.uploadLibGroups();
this.getInstalledLibsByResource();
}
@@ -313,7 +316,10 @@ export class InstallLibrariesComponent implements OnInit, OnDestroy {
});
} else {
this.model.getLibrariesList(this.group, this.query)
- .subscribe(libs => {
+ .subscribe((libs: Library[]) => {
+ console.log('libs', libs);
+ console.log(this.query.slice(0, this.query.indexOf(':')));
+ this.isLibExist = libs.some(v => v.name === this.query.slice(0, this.query.indexOf(':')));
this.filteredList = libs;
});
}
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 b201904..65896d3 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
@@ -60,7 +60,7 @@ export class InstallLibrariesModel {
project_name: this.notebook.project,
exploratory_name: this.notebook.name,
group: group,
- start_with: query
+ start_with: query.slice(0, query.indexOf(':'))
};
if (this.computational_name)
lib_query.computational_name = this.computational_name;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org