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/04/02 17:52:58 UTC
[incubator-dlab] 01/03: [DLAB-1491]: Fix page refresh
This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch DLAB-1571
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit ce458a15a24833714565ea425e9b3dcce4c5f77c
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Thu Apr 2 11:51:43 2020 +0300
[DLAB-1491]: Fix page refresh
---
.../src/app/reporting/reporting.component.ts | 40 ++++++++++------------
.../src/app/resources/resources.component.ts | 14 ++++++--
2 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
index 3d04931..872c3a5 100644
--- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
@@ -20,8 +20,7 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
-
-import {BillingReportService, HealthStatusService} from '../core/services';
+import {ApplicationSecurityService, BillingReportService, HealthStatusService} from '../core/services';
import { ReportingGridComponent } from './reporting-grid/reporting-grid.component';
import { ToolbarComponent } from './toolbar/toolbar.component';
@@ -29,7 +28,6 @@ import { FileUtils } from '../core/util';
import { DICTIONARY, ReportingConfigModel } from '../../dictionary/global.dictionary';
import {ProgressBarService} from '../core/services/progress-bar.service';
-
@Component({
selector: 'dlab-reporting',
template: `
@@ -75,16 +73,24 @@ export class ReportingComponent implements OnInit, OnDestroy {
private healthStatusService: HealthStatusService,
public toastr: ToastrService,
private progressBarService: ProgressBarService,
+ private applicationSecurityService: ApplicationSecurityService,
) { }
ngOnInit() {
- this.getEnvironmentHealthStatus();
+ this.rebuildBillingReport();
}
ngOnDestroy() {
this.clearStorage();
}
+ initBilling() {
+ this.getEnvironmentHealthStatus();
+ if (this.admin) {
+ this.rebuildBillingReport();
+ }
+ }
+
getGeneralBillingData() {
setTimeout(() => {this.progressBarService.startProgressBar(); } , 0);
this.billingReportService.getGeneralBillingData(this.reportData)
@@ -113,12 +119,20 @@ export class ReportingComponent implements OnInit, OnDestroy {
}
rebuildBillingReport(): void {
+ this.checkAutorize();
this.clearStorage();
this.resetRangePicker();
this.reportData.defaultConfigurations();
this.getGeneralBillingData();
}
+ private checkAutorize() {
+ this.applicationSecurityService.isLoggedIn().subscribe( () => {
+ this.getEnvironmentHealthStatus();
+ }
+ );
+ }
+
exportBillingReport(): void {
this.billingReportService.downloadReport(this.reportData)
.subscribe(
@@ -145,23 +159,6 @@ export class ReportingComponent implements OnInit, OnDestroy {
if (item.shape && types.indexOf(item.shape)) {
shapes.push(item.shape);
}
- // if (item.shapes.indexOf('Master') > -1) {
- // for (let shape of item.shapes.split('\n')) {
- // shape = shape.replace('Master: ', '');
- // shape = shape.replace(/Slave:\s+\d+ x /, '');
- // shape = shape.replace(/\s+/g, '');
- //
- // shapes.indexOf(shape) === -1 && shapes.push(shape);
- // }
- // } else if (item.shapes.match(/\d x \S+/)) {
- // const parsedShape = item.shapes.match(/\d x \S+/)[0].split(' x ')[1];
- // if (shapes.indexOf(parsedShape) === -1) {
- // shapes.push(parsedShape);
- // }
- // } else {
- // shapes.indexOf(item.shapes) === -1 && shapes.push(item.shapes);
- // }
- // }
if (item.product && services.indexOf(item.product) === -1)
services.push(item.product);
@@ -199,7 +196,6 @@ export class ReportingComponent implements OnInit, OnDestroy {
.subscribe((result: any) => {
this.billingEnabled = result.billingEnabled;
this.admin = result.admin;
- this.rebuildBillingReport();
});
}
}
diff --git a/services/self-service/src/main/resources/webapp/src/app/resources/resources.component.ts b/services/self-service/src/main/resources/webapp/src/app/resources/resources.component.ts
index bab05a7..c619ada 100644
--- a/services/self-service/src/main/resources/webapp/src/app/resources/resources.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/resources/resources.component.ts
@@ -24,7 +24,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ResourcesGridComponent } from './resources-grid/resources-grid.component';
import { ExploratoryEnvironmentCreateComponent } from './exploratory/create-environment';
import { Exploratory } from './resources-grid/resources-grid.model';
-import { HealthStatusService, ProjectService } from '../core/services';
+import {ApplicationSecurityService, HealthStatusService, ProjectService} from '../core/services';
import { ManageUngitComponent } from './manage-ungit/manage-ungit.component';
import { Project } from './../administration/project/project.component';
@@ -45,7 +45,8 @@ export class ResourcesComponent implements OnInit {
public toastr: ToastrService,
private healthStatusService: HealthStatusService,
private dialog: MatDialog,
- private projectService: ProjectService
+ private projectService: ProjectService,
+ private applicationSecurityService: ApplicationSecurityService
) { }
ngOnInit() {
@@ -62,7 +63,7 @@ export class ResourcesComponent implements OnInit {
public refreshGrid(): void {
this.resourcesGrid.buildGrid();
this.getProjects();
- this.getEnvironmentHealthStatus();
+ this.checkAutorize();
this.exploratoryEnvironments = this.resourcesGrid.environments;
}
@@ -93,6 +94,13 @@ export class ResourcesComponent implements OnInit {
this.projectService.getUserProjectsList().subscribe((projects: any) => this.projects = projects);
}
+ private checkAutorize() {
+ this.applicationSecurityService.isLoggedIn().subscribe( () => {
+ this.getEnvironmentHealthStatus();
+ }
+ );
+ }
+
private getEnvironmentHealthStatus() {
this.healthStatusService.getEnvironmentHealthStatus().subscribe(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org