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

Add workload statuses to workloads view #3989

Merged
merged 1 commit into from
Jul 4, 2019
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
246 changes: 123 additions & 123 deletions i18n/messages.xlf

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/app/frontend/common/components/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import {CpuSparklineComponent} from './sparkline/cpu/component';
import {MemorySparklineComponent} from './sparkline/memory/component';
import {TextInputComponent} from './textinput/component';
import {UploadFileComponent} from './uploadfile/component';
import {WorkloadStatusComponent} from './workloadstatus/component';
import {ZeroStateComponent} from './zerostate/component';

const components = [
Expand Down Expand Up @@ -171,6 +172,7 @@ const components = [
UploadFileComponent,

ZeroStateComponent,
WorkloadStatusComponent
];

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {AppConfig} from '@api/backendapi';
import {ResourcesRatio} from '@api/frontendapi';

import {AllocationChartComponent} from '../../common/components/allocationchart/component';
import {CardComponent} from '../../common/components/card/component';
import {ConfigService} from '../../common/services/global/config';
import {ConfigService} from '../../services/global/config';
import {AllocationChartComponent} from '../allocationchart/component';
import {CardComponent} from '../card/component';

import {WorkloadStatusComponent} from './component';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

@import '../../variables';
@import '../../../variables';

.kd-graph-container {
flex: auto;
Expand Down
2 changes: 1 addition & 1 deletion src/app/frontend/overview/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import {AppConfig, CronJobList, DaemonSetList, PodList,} from '@api/backendapi';
import {AllocationChartComponent} from '../common/components/allocationchart/component';
import {CardComponent} from '../common/components/card/component';
import {ListGroupIdentifiers, ListIdentifiers,} from '../common/components/resourcelist/groupids';
import {emptyResourcesRatio, WorkloadStatusComponent,} from '../common/components/workloadstatus/component';
import {ConfigService} from '../common/services/global/config';
import {NotificationsService} from '../common/services/global/notifications';

import {OverviewComponent} from './component';
import {Helper, ResourceRatioModes} from './helper';
import {emptyResourcesRatio, WorkloadStatusComponent,} from './workloadstatus/component';

const mockDaemonSetData: DaemonSetList = {
listMeta: {totalItems: 1},
Expand Down
2 changes: 1 addition & 1 deletion src/app/frontend/overview/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {CronJobList, DaemonSetList, DeploymentList, JobList, Metric, PodList, Re
import {OnListChangeEvent, ResourcesRatio} from '@api/frontendapi';

import {ListGroupIdentifiers, ListIdentifiers,} from '../common/components/resourcelist/groupids';
import {emptyResourcesRatio} from '../common/components/workloadstatus/component';
import {GroupedResourceList} from '../common/resources/groupedlist';

import {Helper, ResourceRatioModes} from './helper';
import {emptyResourcesRatio} from './workloadstatus/component';

@Component({
selector: 'kd-overview',
Expand Down
5 changes: 3 additions & 2 deletions src/app/frontend/overview/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import {NgModule} from '@angular/core';

import {ComponentsModule} from '../common/components/module';
import {WorkloadStatusComponent} from '../common/components/workloadstatus/component';
import {SharedModule} from '../shared.module';

import {OverviewComponent} from './component';
import {OverviewRoutingModule} from './routing';
import {WorkloadStatusComponent} from './workloadstatus/component';

@NgModule({
imports: [SharedModule, ComponentsModule, OverviewRoutingModule],
declarations: [OverviewComponent, WorkloadStatusComponent],
declarations: [OverviewComponent],
})
export class OverviewModule {
}
89 changes: 87 additions & 2 deletions src/app/frontend/resource/workloads/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,98 @@
// limitations under the License.

import {Component} from '@angular/core';
import {OnListChangeEvent} from '@api/frontendapi';
import {ListGroupIdentifiers} from '../../common/components/resourcelist/groupids';
import {CronJobList, DaemonSetList, DeploymentList, JobList, Metric, PodList, ReplicaSetList, ReplicationControllerList, StatefulSetList,} from '@api/backendapi';
import {OnListChangeEvent, ResourcesRatio} from '@api/frontendapi';
import {emptyResourcesRatio} from 'common/components/workloadstatus/component';
import {Helper, ResourceRatioModes} from 'overview/helper';

import {ListGroupIdentifiers, ListIdentifiers} from '../../common/components/resourcelist/groupids';
import {GroupedResourceList} from '../../common/resources/groupedlist';

@Component({
selector: 'kd-workloads',
templateUrl: './template.html',
})
export class WorkloadsComponent extends GroupedResourceList {
resourcesRatio: ResourcesRatio = emptyResourcesRatio;
cumulativeMetrics: Metric[] = [];

hasWorkloads(): boolean {
return this.isGroupVisible(ListGroupIdentifiers.workloads);
}

hasDiscovery(): boolean {
return this.isGroupVisible(ListGroupIdentifiers.discovery);
}

hasConfig(): boolean {
return this.isGroupVisible(ListGroupIdentifiers.config);
}

updateResourcesRatio(event: OnListChangeEvent) {
switch (event.id) {
case ListIdentifiers.cronJob: {
const cronJobs = event.resourceList as CronJobList;
this.resourcesRatio.cronJobRatio = Helper.getResourceRatio(
cronJobs.status, cronJobs.listMeta.totalItems, ResourceRatioModes.Suspendable);
break;
}
case ListIdentifiers.daemonSet: {
const daemonSets = event.resourceList as DaemonSetList;
this.resourcesRatio.daemonSetRatio =
Helper.getResourceRatio(daemonSets.status, daemonSets.listMeta.totalItems);
break;
}
case ListIdentifiers.deployment: {
const deployments = event.resourceList as DeploymentList;
this.resourcesRatio.deploymentRatio =
Helper.getResourceRatio(deployments.status, deployments.listMeta.totalItems);
break;
}
case ListIdentifiers.job: {
const jobs = event.resourceList as JobList;
this.resourcesRatio.jobRatio = Helper.getResourceRatio(
jobs.status, jobs.listMeta.totalItems, ResourceRatioModes.Completable);
break;
}
case ListIdentifiers.pod: {
const pods = event.resourceList as PodList;
this.resourcesRatio.podRatio = Helper.getResourceRatio(
pods.status, pods.listMeta.totalItems, ResourceRatioModes.Completable);
this.cumulativeMetrics = pods.cumulativeMetrics;
break;
}
case ListIdentifiers.replicaSet: {
const replicaSets = event.resourceList as ReplicaSetList;
this.resourcesRatio.replicaSetRatio =
Helper.getResourceRatio(replicaSets.status, replicaSets.listMeta.totalItems);
break;
}
case ListIdentifiers.replicationController: {
const replicationControllers = event.resourceList as ReplicationControllerList;
this.resourcesRatio.replicationControllerRatio = Helper.getResourceRatio(
replicationControllers.status, replicationControllers.listMeta.totalItems);
break;
}
case ListIdentifiers.statefulSet: {
const statefulSets = event.resourceList as StatefulSetList;
this.resourcesRatio.statefulSetRatio =
Helper.getResourceRatio(statefulSets.status, statefulSets.listMeta.totalItems);
break;
}
default:
break;
}
}

showWorkloadStatuses(): boolean {
return (
Object.values(this.resourcesRatio)
.reduce((sum, ratioItems) => sum + ratioItems.length, 0) !== 0);
}

showGraphs(): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be not used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i will

return this.cumulativeMetrics.every(
metrics => metrics.dataPoints && metrics.dataPoints.length > 1);
}
}
2 changes: 2 additions & 0 deletions src/app/frontend/resource/workloads/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
-->

<div [hidden]="shouldShowZeroState()">
<kd-workload-statuses *ngIf="showWorkloadStatuses()"
[resourcesRatio]="resourcesRatio"></kd-workload-statuses>
<kd-cron-job-list (onchange)="onListUpdate($event)"
[hideable]="true"></kd-cron-job-list>
<kd-daemon-set-list (onchange)="onListUpdate($event)"
Expand Down