This is an automated email from the ASF dual-hosted git repository. dgnatyshyn pushed a commit to branch DLAB-1522 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 943a13ef5378eba6812f94135fdd34c1356d89c0 Author: Dmytro Gnatyshyn <[email protected]> AuthorDate: Tue Feb 11 16:23:14 2020 +0200 [DLAB-1522]: Made notebook name unique per project --- .../services/applicationServiceFacade.service.ts | 7 +++++ .../src/app/core/services/userResource.service.ts | 8 +++++ .../webapp/src/app/core/util/sortUtils.ts | 5 +++ .../create-environment.component.ts | 19 +++++++++--- .../resources-grid/resources-grid.component.ts | 23 ++++++++------ .../resources/webapp/src/assets/styles/_theme.scss | 36 +++++++--------------- 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/applicationServiceFacade.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/applicationServiceFacade.service.ts index 0056039..a8fbdc0 100644 --- a/services/self-service/src/main/resources/webapp/src/app/core/services/applicationServiceFacade.service.ts +++ b/services/self-service/src/main/resources/webapp/src/app/core/services/applicationServiceFacade.service.ts @@ -188,6 +188,13 @@ export class ApplicationServiceFacade { { responseType: 'text', observe: 'response' }); } + public buildGetExploratoryEnvironmentRequest(): Observable<any> { + return this.buildRequest(HTTPMethod.GET, + this.requestRegistry.Item(ApplicationServiceFacade.EXPLORATORY_ENVIRONMENT), + null, + { observe: 'response' }); + } + public buildRunExploratoryEnvironmentRequest(data): Observable<any> { return this.buildRequest(HTTPMethod.POST, this.requestRegistry.Item(ApplicationServiceFacade.EXPLORATORY_ENVIRONMENT), diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts index 04acbb8..a41bd29 100644 --- a/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts +++ b/services/self-service/src/main/resources/webapp/src/app/core/services/userResource.service.ts @@ -72,6 +72,14 @@ export class UserResourceService { catchError(ErrorUtils.handleServiceError)); } + public getProjectByExploratoryEnvironment(): Observable<{}> { + return this.applicationServiceFacade + .buildGetExploratoryEnvironmentRequest() + .pipe( + map(response => response.body.project_exploratories), + catchError(ErrorUtils.handleServiceError)); + } + public suspendExploratoryEnvironment(notebook: any, action): Observable<{}> { const url = '/' + notebook.name + '/' + action; diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/sortUtils.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/sortUtils.ts index fe003f7..0a613ad 100644 --- a/services/self-service/src/main/resources/webapp/src/app/core/util/sortUtils.ts +++ b/services/self-service/src/main/resources/webapp/src/app/core/util/sortUtils.ts @@ -44,4 +44,9 @@ export class SortUtils { return groups.sort((arg1, arg2) => sortOrder.indexOf(arg1) - sortOrder.indexOf(arg2)); } + + public static flatDeep(arr, d = 1) { + return d > 0 ? arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? this.flatDeep(val, d - 1) : val), []) + : arr.slice(); + }; } diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts index 852b242..b9fc3f0 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/resources/exploratory/create-environment/create-environment.component.ts @@ -38,6 +38,7 @@ import {tap} from 'rxjs/operators'; export class ExploratoryEnvironmentCreateComponent implements OnInit { readonly DICTIONARY = DICTIONARY; public createExploratoryForm: FormGroup; + public projectExploratories: {}; projects: Project[] = []; templates = []; @@ -61,11 +62,14 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit { } ngOnInit() { + this.getNamesByProject(); this.getUserProjects(); this.initFormModel(); - this.createExploratoryForm.get('project').valueChanges.subscribe(v => - this.createExploratoryForm.get('name').updateValueAndValidity() - ); + this.createExploratoryForm.get('project').valueChanges.subscribe(v => { + if ( this.createExploratoryForm.controls.name.value) { + this.createExploratoryForm.get('name').updateValueAndValidity(); + } + }); } public getProjects() { @@ -122,6 +126,11 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit { }, error => this.toastr.error(error.message || 'Exploratory creation failed!', 'Oops!')); } + public getNamesByProject() { + this.userResourceService.getProjectByExploratoryEnvironment().subscribe(responce => { + this.projectExploratories = responce; + }); + } public selectConfiguration() { const value = (this.configuration.nativeElement.checked && this.createExploratoryForm) @@ -152,7 +161,9 @@ export class ExploratoryEnvironmentCreateComponent implements OnInit { } private checkDuplication(control) { - if (this.createExploratoryForm && this.resourceGrid.containsNotebook(control.value, this.createExploratoryForm.controls.project.value)) + if (this.createExploratoryForm + && this.createExploratoryForm.controls.project.value + && this.resourceGrid.containsNotebook(control.value, this.projectExploratories[this.createExploratoryForm.controls.project.value])) return { duplication: true }; } diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts index b78e2aa..8ce8836 100644 --- a/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources-grid/resources-grid.component.ts @@ -129,16 +129,14 @@ export class ResourcesGridComponent implements OnInit { this.buildGrid(); } - public containsNotebook(notebook_name: string, project_name: string): boolean { - if (notebook_name && this.environments && this.environments.length ) { - const currentProj = this.environments.filter(project => project.project === project_name); - if (currentProj.length) { - return currentProj[0].exploratory - .some(item => CheckUtils.delimitersFiltering(notebook_name) === CheckUtils.delimitersFiltering(item.name)); + public containsNotebook(notebook_name: string, envoirmentNames: Array<string>): boolean { + if (notebook_name && envoirmentNames.length ) { + return envoirmentNames + .some(item => CheckUtils.delimitersFiltering(notebook_name) === CheckUtils.delimitersFiltering(item)); } return false; - } - } + } + public isResourcesInProgress(notebook) { const env = this.getResourceByName(notebook.name); @@ -277,10 +275,15 @@ export class ResourcesGridComponent implements OnInit { this.updateUserPreferences(config); } - const failedResource = ComputationModel.computationRes(this.getEnvironmentsListCopy()).flat(3).filter(resourse => resourse.status === 'failed'); + + + let failedResource = ComputationModel.computationRes(this.getEnvironmentsListCopy()); + failedResource = SortUtils.flatDeep(failedResource, 3).filter(resourse => resourse.status === 'failed'); if (this.filteredEnvironments.length && this.activeFiltering) { - const creatingResource = ComputationModel.computationRes(this.filteredEnvironments).flat(3).filter(resourse => resourse.status === 'creating'); + let creatingResource = ComputationModel.computationRes(this.filteredEnvironments); + creatingResource = SortUtils.flatDeep(creatingResource, 3).filter(resourse => resourse.status === 'creating'); + const fail = failedResource .filter(v => creatingResource .some(create => create.project === v.project && create.exploratory === v.exploratory && create.resource === v.resource)); 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 abf72ad..380aa75 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 @@ -299,36 +299,22 @@ span.mat-slide-toggle-content { word-break: break-all; } -.project-form, -.create-environment{ - .mat-select:not(.ng-pristine){ - .mat-form-field-label { - line-height: 22px !important; - font-size: 15px !important; - } - .ng-valid .mat-form-field-label { - color: transparent !important; - } - } -} - - +.create-cluster, .project-form, .create-environment, -.create-cluster{ - .mat-select-value{ - overflow: visible; - } -} - -.create-cluster { - .mat-select:not(.ng-pristine) { +.selection, +.manage-roles{ + .mat-select-value{ + overflow: visible; + } .mat-form-field-label { - padding-top: 5px; - line-height: 55px !important; + line-height: 21px !important; font-size: 15px !important; + + &:not(.mat-form-field-empty) { + color: transparent !important; + } } - } } .manage-roles, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
