Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: showing label chart upon focusing from request stats #383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/_directives/role.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export class RoleDirective {
private viewContainer: ViewContainerRef) { }

@Input() set userRole(inputRole: UserRole) {
const { role } = JSON.parse(localStorage.getItem("currentUser"));
const user = localStorage.getItem("currentUser")
if (!user) {
this.viewContainer.clear()
return
}
const { role } = JSON.parse(user);
const minRole = roleMap.get(inputRole);
const currentRole = roleMap.get(role);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ <h6 class="card-header bg-transparent">
<span class="float-end">
<div display="dynamic" [placement]="['bottom-right', 'bottom-left']" class="btn-group" ngbDropdown role="group"
aria-label="">
<app-reload-custom-chart *ngIf=isTemporaryChart (chartUpdate)="loadSavedCustomChart($event)"></app-reload-custom-chart>
<app-add-metric *ngIf=!isTemporaryChart [chartLines]="chartLines" [preloadedSeries]="preloadedSeries" (chartUpdate)="chartUpdated($event)"></app-add-metric>
<app-reload-custom-chart *ngIf="isTemporaryChart && !isAnonymous" (chartUpdate)="loadSavedCustomChart($event)"></app-reload-custom-chart>
<app-add-metric *ngIf="!isTemporaryChart || isAnonymous" [chartLines]="chartLines" [preloadedSeries]="preloadedSeries" (chartUpdate)="chartUpdated($event)"></app-add-metric>
</div>
</span>
</h6>
Expand Down
39 changes: 11 additions & 28 deletions src/app/item-detail/analyze-charts/analyze-charts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ export class AnalyzeChartsComponent implements OnInit {
}

ngOnInit() {
if (this.isAnonymous) {
return;
}
this.itemApiService
.fetchItemChartSettings(this.params.projectName, this.params.scenarioName, this.params.id)
.subscribe(_ => {
this.updateChart(_);
this.preloadedSeries = _;
});
// this needs to be initialized for both anonymous and logged-in user
this.analyzeChartService.currentData.subscribe(data => {
let chartLines;
if (data) {
Expand All @@ -74,27 +66,18 @@ export class AnalyzeChartsComponent implements OnInit {
}
});

// exit onInit if user is anonymous, the code that's after is only for valid for logged-in user
if (this.isAnonymous) {
return;
}

this.itemChartService.selectedPlot$.subscribe(plot => {
const currentChartSeries = this.customChartsOptions.series;

if (Array.isArray(currentChartSeries) && currentChartSeries.length > 0) {
this.chartLines = plot.chartLines;

const updatedChartSeries = currentChartSeries.map(series => {
const labelChart = series.label;
const name = labelChart
? labelChart
: "overall";
this.itemApiService
.fetchItemChartSettings(this.params.projectName, this.params.scenarioName, this.params.id)
.subscribe(_ => {
this.updateChart(_);
this.preloadedSeries = _;
});

return {
name,
metric: series.metric
};
});
this.updateChart(updatedChartSeries);
}
});

}

Expand Down
Loading