This is an automated email from the ASF dual-hosted git repository. ytykhun pushed a commit to branch DATALAB-2382 in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit 97490f87e1dba90bbc9f43736756eca3b45b87bf Author: Yurii Tykhun <[email protected]> AuthorDate: Wed May 5 13:21:17 2021 +0300 [DATALAB-2382] checked the resources of all users which are in processing stage --- .../configuration/configuration.component.ts | 74 +++++++++++----------- .../management/management-data.service.ts | 2 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts index 23063c6..b4437ef 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts @@ -19,7 +19,7 @@ import {Component, OnInit, Inject, HostListener, OnDestroy} from '@angular/core'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import {HealthStatusService, AppRoutingService, EndpointService, UserResourceService} from '../../core/services'; +import {HealthStatusService, AppRoutingService, EndpointService} from '../../core/services'; import {MatTabChangeEvent} from '@angular/material/tabs'; import {Router} from '@angular/router'; import {ConfigurationService} from '../../core/services/configutration.service'; @@ -28,8 +28,8 @@ import 'brace/mode/yaml'; import {ToastrService} from 'ngx-toastr'; import {Observable, Subject} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; -import {Endpoint} from '../management/endpoints/endpoints.component'; -import { ExploratoryModel } from '../../resources/resources-grid/resources-grid.model'; +import { EnvironmentsDataService } from '../management/management-data.service'; +import { EnvironmentModel } from '../management/management.model'; @Component({ selector: 'datalab-configuration', @@ -52,7 +52,8 @@ export class ConfigurationComponent implements OnInit, OnDestroy { error: [] }; - public processingStatuses = []; + public environmentStatuses = {}; + public environments = []; public ingStatuses = ['creating', 'configuring', 'reconfiguring', 'creating image', 'stopping', 'starting', 'terminating']; private confirmMessages = { @@ -81,32 +82,13 @@ export class ConfigurationComponent implements OnInit, OnDestroy { private appRoutingService: AppRoutingService, private endpointService: EndpointService, private configurationService: ConfigurationService, - private userResourceService: UserResourceService, + private environmentsDataService: EnvironmentsDataService, private router: Router, public dialog: MatDialog, public toastr: ToastrService, ) { } ngOnInit() { - this.userResourceService.getUserProvisionedResources().subscribe(data => { - let environments = ExploratoryModel.loadEnvironments(data); - - environments.map(environment => { - environment.exploratory.map(item => { - this.checkResource(item.status); - if(item.resources?.length > 0) { - item.resources.map(resource => { - this.checkResource(resource.status); - }); - } - }); - - for(const key in environment.projectEndpoints) { - this.checkResource(environment.projectEndpoints[key].status); - } - }); - }); - this.getEnvironmentHealthStatus(); this.getEndpoints() .subscribe(endpoints => { @@ -117,6 +99,18 @@ export class ConfigurationComponent implements OnInit, OnDestroy { this.activeEndpoint = this.endpoints[0].name; this.getServicesConfig(this.activeEndpoint); }); + + this.environmentsDataService.getEnvironmentDataDirect().subscribe((data: any) => { + this.environments = EnvironmentModel.loadEnvironments(data); + this.environments.map((env,index) => { + this.checkResource(env.status, env.endpoint); + if(env.resources?.length > 0) { + env.resources.map(resource => { + this.checkResource(resource.status, env.endpoint); + }) + } + }); + }); } ngOnDestroy() { @@ -124,9 +118,14 @@ export class ConfigurationComponent implements OnInit, OnDestroy { this.unsubscribe$.complete(); } - public checkResource(resourceStatus: string) { - if(this.ingStatuses.includes(resourceStatus)) { - this.processingStatuses.push(resourceStatus); + public checkResource(resourceStatus: string, endpoint: string) { + if( this.ingStatuses.includes(resourceStatus) ) { + if(!this.environmentStatuses[endpoint]) { + this.environmentStatuses[endpoint] = []; + this.environmentStatuses[endpoint].push(resourceStatus); + } else { + this.environmentStatuses[endpoint].push(resourceStatus); + } } } @@ -259,15 +258,16 @@ export class ConfigurationComponent implements OnInit, OnDestroy { { data: { action: 'restart', - services: selectedServices, - statuses: this.processingStatuses + services: selectedServices, + environmentStatuses: this.environmentStatuses, + activeEndpoint: this.activeEndpoint }, panelClass: 'modal-sm' }) .afterClosed().subscribe(result => { if (result) { - - if(this.processingStatuses.length && this.services['provisioning'].selected) { + + if(this.environmentStatuses[this.activeEndpoint] && this.services['provisioning'].selected) { this.services['provisioning'].selected = false; } @@ -328,19 +328,19 @@ export class ConfigurationComponent implements OnInit, OnDestroy { </div> <div mat-dialog-content class="content"> - <ng-template [ngIf]="data.action === 'restart' && !data.statuses.length" ]> + <ng-template [ngIf]="data.action === 'restart' && !data.environmentStatuses[data.activeEndpoint]?.length" ]> <span class="strong">{{data.services.join(', ') | titlecase}}</span> <span class="strong" *ngIf="data.services.length > 1 || (data.services.length === 1 && data.services[0] !== 'self-service')"> service</span> <span class="strong" [hidden]="(data.services.length < 2) || data.services.length === 2 && data.services[0] === 'self-service'">s</span>: restarting will make DataLab unavailable for some time. </ng-template> - <ng-template [ngIf]="data.action === 'restart' && data.statuses.length && filterProvisioning.length" ]> + <ng-template [ngIf]="data.action === 'restart' && data.environmentStatuses[data.activeEndpoint]?.length && filterProvisioning.length" ]> <span class="strong" >{{filterProvisioning.join(', ') | titlecase}}</span> <span class="strong" *ngIf="filterProvisioning.length > 1 || (filterProvisioning.length === 1 && filterProvisioning[0] !== 'self-service')"> service</span> <span [hidden]="(filterProvisioning.length < 2) || filterProvisioning.length === 2 && filterProvisioning[0] === 'self-service'">s</span>: restarting will make DataLab unavailable for some time. </ng-template> - <ng-template [ngIf]="data.action === 'restart' && data.statuses.length && (data.services.includes('provisioning') || !filterProvisioning.length)"> + <ng-template [ngIf]="data.action === 'restart' && data.environmentStatuses[data.activeEndpoint]?.length && (data.services.includes('provisioning') || !filterProvisioning.length)"> <div class="warning" [ngStyle]="data.services.includes('provisioning') && data.services?.length > 1 && {'margin-top': '10px'}"> <span>Provisioning service: </span>can not be restarted because one of resources is in processing stage. Please try again later. </div> @@ -349,14 +349,14 @@ export class ConfigurationComponent implements OnInit, OnDestroy { <ng-template [ngIf]="data.action === 'discard'" ]>Discard all unsaved changes.</ng-template> <ng-template [ngIf]="data.action === 'save'" ]>After you save changes you need to restart service.</ng-template> </div> - <div class="text-center " *ngIf="!data.statuses?.length || (data.statuses?.length && (!data.services.includes('provisioning') || filterProvisioning?.length))"> + <div class="text-center " *ngIf="!data.environmentStatuses[data.activeEndpoint]?.length || (data.environmentStatuses[data.activeEndpoint]?.length && (!data.services.includes('provisioning') || filterProvisioning?.length))"> <p class="strong">Do you want to proceed?</p> </div> - <div class="text-center m-top-20 pb-25" *ngIf="!data.statuses?.length || (data.statuses?.length && (!data.services.includes('provisioning') || filterProvisioning.length))"> + <div class="text-center m-top-20 pb-25" *ngIf="!data.environmentStatuses[data.activeEndpoint]?.length || (data.environmentStatuses[data.activeEndpoint]?.length && (!data.services.includes('provisioning') || filterProvisioning.length))"> <button type="button" class="butt" mat-raised-button (click)="dialogRef.close()">No</button> <button type="button" class="butt butt-success" mat-raised-button (click)="dialogRef.close(true)">Yes</button> </div> - <div class="text-center m-top-20 pb-25" *ngIf="data.action === 'restart' && data.statuses.length && data.services.includes('provisioning') && data.services.length === 1"> + <div class="text-center m-top-20 pb-25" *ngIf="data.action === 'restart' && data.environmentStatuses[data.activeEndpoint]?.length && data.services.includes('provisioning') && data.services.length === 1"> <button type="button" class="butt" mat-raised-button (click)="dialogRef.close()">Close</button> </div> </div> diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-data.service.ts b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-data.service.ts index 3078ad9..a3aa218 100644 --- a/services/self-service/src/main/resources/webapp/src/app/administration/management/management-data.service.ts +++ b/services/self-service/src/main/resources/webapp/src/app/administration/management/management-data.service.ts @@ -36,7 +36,7 @@ export class EnvironmentsDataService { } public getEnvironmentDataDirect() { - return this.manageEnvironmentsService.getAllEnvironmentData().subscribe(response => response); + return this.manageEnvironmentsService.getAllEnvironmentData(); } private getAllEnvironmentData() { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
