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

Workload Summary Pod/Container Ring Chart Fixes #387

Merged
merged 27 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
48ae0df
Merge remote-tracking branch 'upstream/master' into merge-upstream
richard-cox May 5, 2020
872d34d
Fixes following merge
richard-cox May 5, 2020
8124add
Merge remote-tracking branch 'upstream/improve-entity-access-clean' i…
richard-cox May 7, 2020
5651d91
Fix entity-catalog.service --> entity-catalog file change
richard-cox May 7, 2020
cca5f7b
WIP
richard-cox May 7, 2020
9d199ed
WIP
richard-cox May 11, 2020
557deb2
WIP
richard-cox May 12, 2020
aae429e
Started to apply
richard-cox May 12, 2020
1b9ce7b
WIP
richard-cox May 13, 2020
0bcb711
WIP
richard-cox May 13, 2020
c1bc891
Merge remote-tracking branch 'upstream/improve-entity-access-clean' i…
richard-cox May 15, 2020
57ff95c
Fix most todo's
richard-cox May 15, 2020
54534a9
WIP
richard-cox May 15, 2020
81db83c
Final TODO's
richard-cox May 15, 2020
68b96b2
Merge remote-tracking branch 'origin/merge-upstream' into merge-upstr…
richard-cox May 29, 2020
61ab1be
Merge remote-tracking branch 'origin/merge-upstream' into merge-upstr…
richard-cox Jun 1, 2020
cfaadc0
Fix left padding on expander rows
richard-cox Jun 1, 2020
bcf5088
Merge remote-tracking branch 'origin/merge-upstream' into merge-upstr…
richard-cox Jun 9, 2020
e688046
Fix unit tests
richard-cox Jun 10, 2020
2e3d6ef
Merge remote-tracking branch 'origin/master' into merge-upstream-enti…
richard-cox Jun 11, 2020
955c6ff
Improve unit tests
richard-cox Jun 11, 2020
fc197cd
Changes following review
richard-cox Jun 12, 2020
da6eb12
Workload Summary Pod/Container Ring Chart Fixes
richard-cox Jun 12, 2020
a9d76f0
Fix ring chart legend/ring colour missmatch
richard-cox Jun 15, 2020
1c0d2a7
Merge remote-tracking branch 'origin/master' into worklow-summary-fixes
richard-cox Jun 16, 2020
ac7753f
Fix compile
richard-cox Jun 16, 2020
d835710
Minor changes following review
richard-cox Jun 16, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ export class KubernetesPodExpandedStatusHelper {
reason = state.waiting.reason;
} else if (!!state.terminated) {
reason = state.terminated.reason;
} else if (!!state.terminated) {
if (state.terminated.signal !== 0) {
if (!!state.terminated.signal && state.terminated.signal !== 0) {
reason = `Signal:${state.terminated.signal}`;
} else {
} else if (!!state.terminated.exitCode && state.terminated.exitCode !== 0) {
reason = `ExitCode:${state.terminated.exitCode}`;
}
} else if (!!container.ready && !!state.running) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

import { kubeEntityCatalog } from '../../../kubernetes-entity-catalog';
import { KubernetesPod } from '../../../store/kube.types';
import { ContainerStateCollection, KubernetesPod } from '../../../store/kube.types';
import { getHelmReleaseDetailsFromGuid } from '../../store/workloads-entity-factory';
import {
HelmRelease,
Expand Down Expand Up @@ -85,7 +85,7 @@ export class HelmReleaseHelperService {
this.releaseTitle
).currentPage$.pipe(
filter(pods => !!pods),
map(this.mapPods)
map(pods => this.mapPods(pods))
);
}

Expand All @@ -110,11 +110,13 @@ export class HelmReleaseHelperService {
} else {
podPhases[status]++;
}

if (pod.status.containerStatuses) {
pod.status.containerStatuses.forEach(containerStatus => {
if (containerStatus.state.running) {
const isReady = this.isContainerReady(containerStatus.state);
if (isReady === true) {
containers.ready.value++;
} else {
} else if (isReady === false) {
containers.notReady.value++;
}
});
Expand All @@ -129,4 +131,17 @@ export class HelmReleaseHelperService {
containersChartData: Object.values(containers)
};
}

private isContainerReady(state: ContainerStateCollection = {}): Boolean {
console.log(state);
richard-cox marked this conversation as resolved.
Show resolved Hide resolved
if (state.running) {
return true;
} else if (!!state.waiting) {
return false;
} else if (!!state.terminated) {
// Assume a failed state is not ready (covers completed init states), discard success state
return state.terminated.exitCode === 0 ? null : false
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RouterNav } from 'frontend/packages/store/src/actions/router.actions';
import { HideSnackBar, ShowSnackBar } from 'frontend/packages/store/src/actions/snackBar.actions';
import { AppState } from 'frontend/packages/store/src/app-state';
import { combineLatest, Observable, ReplaySubject } from 'rxjs';
import { filter, first, map, publishReplay, refCount, startWith } from 'rxjs/operators';
import { distinctUntilChanged, filter, first, map, publishReplay, refCount, startWith } from 'rxjs/operators';

import { endpointsEntityRequestDataSelector } from '../../../../../../../../store/src/selectors/endpoint.selectors';
import { HelmReleaseChartData, HelmReleaseResource } from '../../../workload.types';
Expand All @@ -36,12 +36,17 @@ export class HelmReleaseSummaryTabComponent implements OnDestroy {
public containersChartData = [];

private successChartColor = '#4DD3A7';
private completedChartColour = '#7aa3e5';

public podChartColors = [
{
name: 'Running',
value: this.successChartColor
},
{
name: 'Completed',
value: this.completedChartColour
},
];

public containersChartColors = [
Expand Down Expand Up @@ -103,7 +108,15 @@ export class HelmReleaseSummaryTabComponent implements OnDestroy {
startWith(true)
);

this.chartData$ = this.helmReleaseHelper.fetchReleaseChartStats();
this.chartData$ = this.helmReleaseHelper.fetchReleaseChartStats().pipe(
distinctUntilChanged(),
map(chartData => ({
...chartData,
containersChartData: chartData.containersChartData.sort((a, b) => a.name.localeCompare(b.name)),
podsChartData: chartData.podsChartData.sort((a, b) => a.name.localeCompare(b.name))
})
)
);

this.resources$ = this.helmReleaseHelper.fetchReleaseGraph().pipe(
map((graph: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<div class="app-ring-chart">
<div class="pie">
<ngx-charts-pie-chart [customColors]="customColors" [view]="[120,120]" [animations]="true" [doughnut]="true" [results]="data" [gradient]="false">
<ngx-charts-pie-chart [customColors]="customColors" [view]="[120,120]" [animations]="true" [doughnut]="true"
[results]="data" [gradient]="false">
</ngx-charts-pie-chart>
</div>
<div class="legend">
<div class="advanced-pie-legend">
<div class="total-value" ngx-charts-count-up [countTo]="getTotal()"></div>
<div class="total-label">{{ label }}</div>
</div>
<ngx-charts-advanced-legend [data]="data" [label]="label" [colors]="colors" [animations]="true" [valueFormatting]="valueFormatting" [labelFormatting]="nameFormatting" [percentageFormatting]="percentageFormatting" (select)="onClick($event)" (activate)="onActivate($event)"
<ngx-charts-advanced-legend [data]="data" [label]="label" [colors]="colors" [animations]="true"
[valueFormatting]="valueFormatting" [labelFormatting]="nameFormatting"
[percentageFormatting]="percentageFormatting" (select)="onClick($event)" (activate)="onActivate($event)"
(deactivate)="onDeactivate($event)">
</ngx-charts-advanced-legend>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
import { ColorHelper } from '@swimlane/ngx-charts';
import { Component, Input, OnChanges, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { AdvancedLegendComponent, ColorHelper } from '@swimlane/ngx-charts';

@Component({
selector: 'app-ring-chart',
templateUrl: './ring-chart.component.html',
styleUrls: ['./ring-chart.component.scss'],
encapsulation: ViewEncapsulation.None,
})
export class RingChartComponent implements OnInit {
export class RingChartComponent implements OnInit, OnChanges {

domain: any[];
colors: ColorHelper;
Expand All @@ -24,17 +24,30 @@ export class RingChartComponent implements OnInit {
@Input() nameFormatting: (value: string) => any = label => label;
@Input() percentageFormatting: (value: number) => any = percentage => percentage;

@ViewChild(AdvancedLegendComponent) lineSeriesComponent: AdvancedLegendComponent;
richard-cox marked this conversation as resolved.
Show resolved Hide resolved

constructor() { }

ngOnInit() {
if (!this.data) {
this.data = [];
}
}

ngOnChanges() {
this.update();
}

update() {
this.domain = this.getDomain();
this.setColors();
}

setColors(): void {
if (!this.domain) {
// Not set yet, can't set colour without it
return;
}
this.colors = new ColorHelper(this.scheme, 'ordinal', this.domain, this.customColors || []);
}

Expand Down