This is an automated email from the ASF dual-hosted git repository. dgnatyshyn pushed a commit to branch DLAB-1357 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit e4158214a3f2c610cef7deacde1621e8789163a9 Author: Dmytro Gnatyshyn <[email protected]> AuthorDate: Wed Jan 29 13:04:30 2020 +0200 [DLAB-1357]: Fixed terminate action, added validation --- .../create-legion-cluster.component.html | 9 ++++-- .../create-legion-cluster.component.ts | 29 +++++++++++------ .../legion-deployment.component.ts | 2 +- .../legion-list/legion-list.component.ts | 3 +- .../project/project-form/project-form.component.ts | 6 ++-- .../project/project-list/project-list.component.ts | 36 +++++++++++----------- .../edge-action-dialog.component.ts | 3 -- .../modal-dialog/edge-action-dialog/index.ts | 2 +- .../modal-dialog/odahu-action-dialog/index.ts | 15 +++++++++ .../odahu-action-dialog.component.ts} | 7 ++--- .../webapp/src/app/shared/navbar/index.ts | 4 ++- 11 files changed, 71 insertions(+), 45 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.html index 74714aa..8703c21 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.html +++ b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.html @@ -15,7 +15,7 @@ <mat-option *ngFor="let project of projects" [value]="project.name" (click)="setEndpoints(project)"> {{ project.name }}</mat-option> <mat-option *ngIf="!projects.length" class="multiple-select ml-10" disabled> - Projects list is empty + No projects for creating Odahu clusters </mat-option> </mat-select> <button class="caret"> @@ -35,8 +35,7 @@ <mat-option *ngFor="let endpoint of endpoints" [value]="endpoint"> {{ endpoint }} </mat-option> - <mat-option *ngIf="!endpoints.length" class="multiple-select ml-10" disabled>Endpoints list is empty - </mat-option> + <mat-option *ngIf="!endpoints.length" class="multiple-select ml-10" disabled>Endpoints list is empty</mat-option> </mat-select> <button class="caret"> <i class="material-icons">keyboard_arrow_down</i> @@ -49,6 +48,10 @@ <label class="label">Name</label> <div class="control"> <input type="text" class="form-control" placeholder="Enter Name" formControlName="name"> + <span class="error" *ngIf="!createLegionClusterForm.controls.name.valid && createLegionClusterForm.controls.name.dirty && !createLegionClusterForm.controls.name.hasError('duplication')"> + Odahu cluster name can only contain letters and numbers + </span> + <span class="error" *ngIf="createLegionClusterForm.controls.name.hasError('duplication')">This Odahu cluster name already exists.</span> </div> </div> diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.ts index fecd3af..435ec52 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/create-legion-claster/create-legion-cluster.component.ts @@ -23,10 +23,10 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; import { Project } from '../../../administration/project/project.component'; -import { UserResourceService, ProjectService, LegionDeploymentService } from '../../../core/services'; +import { ProjectService, LegionDeploymentService } from '../../../core/services'; import { DICTIONARY } from '../../../../dictionary/global.dictionary'; -import {PATTERNS} from "../../../core/util"; +import {CheckUtils, PATTERNS} from '../../../core/util'; @Component({ @@ -59,35 +59,46 @@ export class CreateLegionClusterComponent implements OnInit { this.initFormModel(); } - public getProjects(): void{ + public getProjects(): void { this.projectService.getProjectsList().subscribe((projects: any) => this.projects = projects); } public getUserProjects(): void { this.projectService.getUserProjectsList(true).subscribe((projects: any) => { - this.projects = projects; + console.log(projects) + this.projects = projects.filter(project => project.endpoints.length > project.odahu.length); }); } public setEndpoints(project): void { this.endpoints = project.endpoints - .filter(e => e.status === 'RUNNING') + .filter(e => e.status === 'RUNNING' && !this.data.some(odahu => odahu.endpoint === e.name && odahu.project === project.name)) .map(e => e.name); + console.log(this.endpoints); } private initFormModel(): void { this.createLegionClusterForm = this._fb.group({ - name: ['', Validators.required], + name: ['', [Validators.required, Validators.pattern(PATTERNS.namePattern), this.checkDuplication.bind(this)]], project: ['', Validators.required], - endpoint: ['', Validators.required], + endpoint: ['', [Validators.required]], }); } - private createOdahuCluster(value): void{ + private createOdahuCluster(value): void { this.dialogRef.close(); this.legionDeploymentService.createOdahuNewCluster(value).subscribe(val => { this.toastr.success('Odahu cluster creation is processing!', 'Success!'); - },error => this.toastr.error(error.message || 'Odahu cluster creation failed!', 'Oops!') + }, error => this.toastr.error(error.message || 'Odahu cluster creation failed!', 'Oops!') ); } + + private checkDuplication(control) { + if (control && control.value) { + for (let index = 0; index < this.data.length; index++) { + if (CheckUtils.delimitersFiltering(control.value) === CheckUtils.delimitersFiltering(this.data[index].name)) + return { duplication: true }; + } + } + } } diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-deployment.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-deployment.component.ts index f6fffe0..76de123 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-deployment.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-deployment.component.ts @@ -39,7 +39,7 @@ export class LegionDeploymentComponent implements OnInit { } public createLegionCluster(): void { - this.dialog.open(CreateLegionClusterComponent, { panelClass: 'modal-lg' }) + this.dialog.open(CreateLegionClusterComponent, { data: this.legionClastersList, panelClass: 'modal-lg' }) .afterClosed().subscribe((result) => { result && this.getEnvironmentHealthStatus(); this.refreshGrid(); diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-list/legion-list.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-list/legion-list.component.ts index 106fc7c..8f1931b 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-list/legion-list.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/legion-deployment/legion-list/legion-list.component.ts @@ -13,7 +13,7 @@ export class LegionListComponent implements OnInit { private legionClustersList: any[]; private subscriptions: Subscription = new Subscription(); public dataSource: MatTableDataSource<any>; - displayedColumns: string[] = ['project', 'endpoint-url', 'legion-name', 'legion-status', 'actions']; + displayedColumns: string[] = [ 'legion-name', 'project', 'endpoint-url', 'legion-status', 'actions']; constructor( private legionDeploymentDataService: LegionDeploymentDataService, @@ -35,4 +35,5 @@ export class LegionListComponent implements OnInit { this.legionDeploymentDataService.updateClasters() ); } + } diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts index 5eb522a..8a8dc4b 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-form/project-form.component.ts @@ -29,7 +29,7 @@ import { CheckUtils, FileUtils, PATTERNS } from '../../../core/util'; import { Project } from '../project.component'; import { DICTIONARY } from '../../../../dictionary/global.dictionary'; -export interface GenerateKey { privateKey: string, publicKey: string }; +export interface GenerateKey { privateKey: string; publicKey: string; } @Component({ selector: 'project-form', @@ -138,7 +138,7 @@ export class ProjectFormComponent implements OnInit { } public selectOptions(list, key, select?) { - let filter = key === 'endpoints' ? list.map(el => el.name) : list; + const filter = key === 'endpoints' ? list.map(el => el.name) : list; this.projectForm.controls[key].setValue(select ? filter : []); } @@ -155,7 +155,7 @@ export class ProjectFormComponent implements OnInit { } public editSpecificProject(item) { - let endpoints = item.endpoints.map((item: any) => item.name); + const endpoints = item.endpoints.map((item: any) => item.name); this.projectForm = this._fb.group({ 'key': [''], diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts index 146e99e..2b6d19e 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts @@ -26,9 +26,9 @@ import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dial import { ProjectDataService } from '../project-data.service'; import { Project, Endpoint } from '../project.component'; import { CheckUtils } from '../../../core/util'; -import {ProgressBarService} from "../../../core/services/progress-bar.service"; -import {EdgeActionDialogComponent} from "../../../shared/modal-dialog/edge-action-dialog"; -import {EndpointService} from "../../../core/services"; +import {ProgressBarService} from '../../../core/services/progress-bar.service'; +import {EdgeActionDialogComponent} from '../../../shared/modal-dialog/edge-action-dialog'; +import {EndpointService} from '../../../core/services'; @Component({ selector: 'project-list', @@ -66,20 +66,20 @@ export class ProjectListComponent implements OnInit, OnDestroy { this.subscriptions.unsubscribe(); } - private getProjectList(){ - setTimeout(() => {this.progressBarService.startProgressBar()} , 0); + private getProjectList() { + setTimeout(() => {this.progressBarService.startProgressBar(); } , 0); this.subscriptions.add(this.projectDataService._projects.subscribe((value: Project[]) => { this.projectList = value; this.endpointService.getEndpointsData().subscribe((endpoints: any) => { - if(this.projectList){ + if (this.projectList) { this.projectList.forEach(project => project.endpoints.forEach(endpoint => { const filtredEndpoints = endpoints.filter(v => v.name === endpoint.name); - if(filtredEndpoints.length){ + if (filtredEndpoints.length) { endpoint.endpointStatus = endpoints.filter(v => v.name === endpoint.name)[0].status; - }else{ - endpoint.endpointStatus = "N/A" + } else { + endpoint.endpointStatus = 'N/A'; } - })) + })); } }); if (value) this.dataSource = new MatTableDataSource(value); @@ -110,7 +110,7 @@ export class ProjectListComponent implements OnInit, OnDestroy { public isInProgress(project) { if (project) - return project.endpoints.some(e => e.status !== 'RUNNING' && e.status !== 'STOPPED' && e.status !== 'TERMINATED' && e.status !== 'FAILED') + return project.endpoints.some(e => e.status !== 'RUNNING' && e.status !== 'STOPPED' && e.status !== 'TERMINATED' && e.status !== 'FAILED'); } public isActiveEndpoint(project) { @@ -124,19 +124,19 @@ export class ProjectListComponent implements OnInit, OnDestroy { public openEdgeDialog(action, project) { const endpoints = project.endpoints.filter(endpoint => { - if(action === "stop"){ - return endpoint.status == 'RUNNING' + if (action === 'stop') { + return endpoint.status === 'RUNNING'; } - if(action === "start"){ - return endpoint.status == 'STOPPED' + if (action === 'start') { + return endpoint.status === 'STOPPED'; } - if(action === "terminate"){ - return endpoint.status == 'RUNNING' || endpoint.status == 'STOPPED' + if (action === 'terminate') { + return endpoint.status === 'RUNNING' || endpoint.status == 'STOPPED'; } }); this.dialog.open(EdgeActionDialogComponent, {data: {type: action, item: endpoints}, panelClass: 'modal-sm'}) .afterClosed().subscribe(endpoint => { - if(endpoint && endpoint.length){ + if (endpoint && endpoint.length) { this.toggleStatus.emit({project, endpoint, action}); } }, error => this.toastr.error(error.message || `Endpoint ${action} failed!`, 'Oops!') diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts index 9f75c8f..470724c 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts @@ -64,9 +64,6 @@ export class EdgeActionDialogComponent { @Inject(MAT_DIALOG_DATA) public data: any) { } - ngOnInit() { - } - public endpointAction() { this.endpointsNewStatus = this.data.item.filter(endpoint => endpoint.checked); } diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/index.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/index.ts index fd6e98a..c91d503 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/index.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/index.ts @@ -21,7 +21,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { EdgeActionDialogComponent } from './edge-action-dialog.component'; import { MaterialModule } from '../../material.module'; -import {FormsModule} from "@angular/forms"; +import {FormsModule} from '@angular/forms'; export * from './edge-action-dialog.component'; diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/index.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/index.ts new file mode 100644 index 0000000..bfc5420 --- /dev/null +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/index.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { OdahuActionDialogComponent } from './odahu-action-dialog.component'; +import { MaterialModule } from '../../material.module'; +import {FormsModule} from '@angular/forms'; + +export * from './odahu-action-dialog.component'; + +@NgModule({ + imports: [CommonModule, MaterialModule, FormsModule], + declarations: [OdahuActionDialogComponent], + entryComponents: [OdahuActionDialogComponent], + exports: [OdahuActionDialogComponent] +}) +export class OdahuActionDialogModule {} diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/odahu-action-dialog.component.ts similarity index 95% copy from services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts copy to services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/odahu-action-dialog.component.ts index 9f75c8f..a5923f0 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/edge-action-dialog/edge-action-dialog.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/modal-dialog/odahu-action-dialog/odahu-action-dialog.component.ts @@ -57,16 +57,13 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; `] }) -export class EdgeActionDialogComponent { +export class OdahuActionDialogComponent { public endpointsNewStatus: Array<object> = []; constructor( - public dialogRef: MatDialogRef<EdgeActionDialogComponent>, + public dialogRef: MatDialogRef<OdahuActionDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { } - ngOnInit() { - } - public endpointAction() { this.endpointsNewStatus = this.data.item.filter(endpoint => endpoint.checked); } diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts index 7a6f2d4..2796b61 100644 --- a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts +++ b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/index.ts @@ -25,7 +25,8 @@ import { ProgressDialogModule, BubbleModule } from '../index'; import { NavbarComponent } from './navbar.component'; import { NotificationDialogModule } from '../modal-dialog/notification-dialog'; -import {EdgeActionDialogModule} from "../modal-dialog/edge-action-dialog"; +import {EdgeActionDialogModule} from '../modal-dialog/edge-action-dialog'; +import {OdahuActionDialogModule} from '../modal-dialog/odahu-action-dialog'; export * from './navbar.component'; @@ -36,6 +37,7 @@ export * from './navbar.component'; MaterialModule, NotificationDialogModule, EdgeActionDialogModule, + OdahuActionDialogModule, ProgressDialogModule, BubbleModule, ], --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
