diff --git a/i18n/messages.xlf b/i18n/messages.xlf
index aee53642cd8f..d34db6c334ac 100644
--- a/i18n/messages.xlf
+++ b/i18n/messages.xlf
@@ -279,6 +279,129 @@
21
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 20
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 37
+
+
+ ../src/app/frontend/common/components/resourcelist/cronjob/template.html
+ 21
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 52
+
+
+ ../src/app/frontend/common/components/resourcelist/daemonset/template.html
+ 21
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 67
+
+
+ ../src/app/frontend/common/components/resourcelist/deployment/template.html
+ 21
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 82
+
+
+ ../src/app/frontend/common/components/resourcelist/job/template.html
+ 23
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 97
+
+
+ ../src/app/frontend/common/components/creator/template.html
+ 64
+
+
+ ../src/app/frontend/common/components/resourcelist/daemonset/template.html
+ 84
+
+
+ ../src/app/frontend/common/components/resourcelist/deployment/template.html
+ 84
+
+
+ ../src/app/frontend/common/components/resourcelist/job/template.html
+ 87
+
+
+ ../src/app/frontend/common/components/resourcelist/pod/template.html
+ 21
+
+
+ ../src/app/frontend/common/components/resourcelist/replicaset/template.html
+ 87
+
+
+ ../src/app/frontend/common/components/resourcelist/replicationcontroller/template.html
+ 84
+
+
+ ../src/app/frontend/common/components/resourcelist/statefulset/template.html
+ 84
+
+
+ ../src/app/frontend/resource/workloads/deployment/detail/template.html
+ 247
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 112
+
+
+ ../src/app/frontend/common/components/resourcelist/replicaset/template.html
+ 23
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 127
+
+
+
+
+
+ ../src/app/frontend/common/components/workloadstatus/template.html
+ 142
+
+
+ ../src/app/frontend/common/components/resourcelist/statefulset/template.html
+ 21
+
+
@@ -460,17 +583,6 @@
38
-
-
-
- ../src/app/frontend/common/components/resourcelist/cronjob/template.html
- 21
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 37
-
-
@@ -1166,49 +1278,6 @@
58
-
-
-
- ../src/app/frontend/common/components/creator/template.html
- 64
-
-
- ../src/app/frontend/common/components/resourcelist/daemonset/template.html
- 84
-
-
- ../src/app/frontend/common/components/resourcelist/deployment/template.html
- 84
-
-
- ../src/app/frontend/common/components/resourcelist/job/template.html
- 87
-
-
- ../src/app/frontend/common/components/resourcelist/pod/template.html
- 21
-
-
- ../src/app/frontend/common/components/resourcelist/replicaset/template.html
- 87
-
-
- ../src/app/frontend/common/components/resourcelist/replicationcontroller/template.html
- 84
-
-
- ../src/app/frontend/common/components/resourcelist/statefulset/template.html
- 84
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 97
-
-
- ../src/app/frontend/resource/workloads/deployment/detail/template.html
- 247
-
-
@@ -1276,28 +1345,6 @@
38
-
-
-
- ../src/app/frontend/common/components/resourcelist/daemonset/template.html
- 21
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 52
-
-
-
-
-
- ../src/app/frontend/common/components/resourcelist/deployment/template.html
- 21
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 67
-
-
@@ -1398,17 +1445,6 @@
21
-
-
-
- ../src/app/frontend/common/components/resourcelist/job/template.html
- 23
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 82
-
-
@@ -1851,17 +1887,6 @@
52
-
-
-
- ../src/app/frontend/common/components/resourcelist/replicaset/template.html
- 23
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 112
-
-
@@ -1894,17 +1919,6 @@
58
-
-
-
- ../src/app/frontend/common/components/resourcelist/statefulset/template.html
- 21
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 142
-
-
@@ -3342,20 +3356,6 @@
151
-
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 20
-
-
-
-
-
- ../src/app/frontend/overview/workloadstatus/template.html
- 127
-
-
diff --git a/src/app/frontend/common/components/module.ts b/src/app/frontend/common/components/module.ts
index 01d56f4e9c6a..30b2ec7dbd63 100644
--- a/src/app/frontend/common/components/module.ts
+++ b/src/app/frontend/common/components/module.ts
@@ -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 = [
@@ -171,6 +172,7 @@ const components = [
UploadFileComponent,
ZeroStateComponent,
+ WorkloadStatusComponent
];
@NgModule({
diff --git a/src/app/frontend/overview/workloadstatus/component.spec.ts b/src/app/frontend/common/components/workloadstatus/component.spec.ts
similarity index 95%
rename from src/app/frontend/overview/workloadstatus/component.spec.ts
rename to src/app/frontend/common/components/workloadstatus/component.spec.ts
index d96f349fd973..ff321b867887 100644
--- a/src/app/frontend/overview/workloadstatus/component.spec.ts
+++ b/src/app/frontend/common/components/workloadstatus/component.spec.ts
@@ -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';
diff --git a/src/app/frontend/overview/workloadstatus/component.ts b/src/app/frontend/common/components/workloadstatus/component.ts
similarity index 100%
rename from src/app/frontend/overview/workloadstatus/component.ts
rename to src/app/frontend/common/components/workloadstatus/component.ts
diff --git a/src/app/frontend/overview/workloadstatus/style.scss b/src/app/frontend/common/components/workloadstatus/style.scss
similarity index 96%
rename from src/app/frontend/overview/workloadstatus/style.scss
rename to src/app/frontend/common/components/workloadstatus/style.scss
index 0eff3058e866..12ff5c86ee44 100644
--- a/src/app/frontend/overview/workloadstatus/style.scss
+++ b/src/app/frontend/common/components/workloadstatus/style.scss
@@ -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;
diff --git a/src/app/frontend/overview/workloadstatus/template.html b/src/app/frontend/common/components/workloadstatus/template.html
similarity index 100%
rename from src/app/frontend/overview/workloadstatus/template.html
rename to src/app/frontend/common/components/workloadstatus/template.html
diff --git a/src/app/frontend/overview/component.spec.ts b/src/app/frontend/overview/component.spec.ts
index 0bafd2655a5f..3b713461e67c 100644
--- a/src/app/frontend/overview/component.spec.ts
+++ b/src/app/frontend/overview/component.spec.ts
@@ -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},
diff --git a/src/app/frontend/overview/component.ts b/src/app/frontend/overview/component.ts
index 0e69d10d2750..f9c67e712cb3 100644
--- a/src/app/frontend/overview/component.ts
+++ b/src/app/frontend/overview/component.ts
@@ -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',
diff --git a/src/app/frontend/overview/module.ts b/src/app/frontend/overview/module.ts
index 5c731c56f4b6..871d64af4ada 100644
--- a/src/app/frontend/overview/module.ts
+++ b/src/app/frontend/overview/module.ts
@@ -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 {
}
diff --git a/src/app/frontend/resource/workloads/component.ts b/src/app/frontend/resource/workloads/component.ts
index 09c55eecf140..5cccf7b5039c 100644
--- a/src/app/frontend/resource/workloads/component.ts
+++ b/src/app/frontend/resource/workloads/component.ts
@@ -13,8 +13,12 @@
// 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({
@@ -22,4 +26,85 @@ import {GroupedResourceList} from '../../common/resources/groupedlist';
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 {
+ return this.cumulativeMetrics.every(
+ metrics => metrics.dataPoints && metrics.dataPoints.length > 1);
+ }
}
diff --git a/src/app/frontend/resource/workloads/template.html b/src/app/frontend/resource/workloads/template.html
index 4e97e80510f8..c998cdc79961 100644
--- a/src/app/frontend/resource/workloads/template.html
+++ b/src/app/frontend/resource/workloads/template.html
@@ -15,6 +15,8 @@
-->
+