diff --git a/i18n/messages.xlf b/i18n/messages.xlf index aee53642cd8f782f3c559839e3cb4d188cf6a63d..d34db6c334ac591cb929a01b76f78baa0fe84fff 100644 --- a/i18n/messages.xlf +++ b/i18n/messages.xlf @@ -279,6 +279,129 @@ 21 + + Workload Status + + ../src/app/frontend/common/components/workloadstatus/template.html + 20 + + + + Cron Jobs + + ../src/app/frontend/common/components/workloadstatus/template.html + 37 + + + ../src/app/frontend/common/components/resourcelist/cronjob/template.html + 21 + + + + Daemon Sets + + ../src/app/frontend/common/components/workloadstatus/template.html + 52 + + + ../src/app/frontend/common/components/resourcelist/daemonset/template.html + 21 + + + + Deployments + + ../src/app/frontend/common/components/workloadstatus/template.html + 67 + + + ../src/app/frontend/common/components/resourcelist/deployment/template.html + 21 + + + + Jobs + + ../src/app/frontend/common/components/workloadstatus/template.html + 82 + + + ../src/app/frontend/common/components/resourcelist/job/template.html + 23 + + + + Pods + + ../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 + + + + Replica Sets + + ../src/app/frontend/common/components/workloadstatus/template.html + 112 + + + ../src/app/frontend/common/components/resourcelist/replicaset/template.html + 23 + + + + Replication Controllers + + ../src/app/frontend/common/components/workloadstatus/template.html + 127 + + + + Stateful Sets + + ../src/app/frontend/common/components/workloadstatus/template.html + 142 + + + ../src/app/frontend/common/components/resourcelist/statefulset/template.html + 21 + + Pod information @@ -460,17 +583,6 @@ 38 - - Cron Jobs - - ../src/app/frontend/common/components/resourcelist/cronjob/template.html - 21 - - - ../src/app/frontend/overview/workloadstatus/template.html - 37 - - Items:  @@ -1166,49 +1278,6 @@ 58 - - Pods - - ../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 - - Age @@ -1276,28 +1345,6 @@ 38 - - Daemon Sets - - ../src/app/frontend/common/components/resourcelist/daemonset/template.html - 21 - - - ../src/app/frontend/overview/workloadstatus/template.html - 52 - - - - Deployments - - ../src/app/frontend/common/components/resourcelist/deployment/template.html - 21 - - - ../src/app/frontend/overview/workloadstatus/template.html - 67 - - Endpoints @@ -1398,17 +1445,6 @@ 21 - - Jobs - - ../src/app/frontend/common/components/resourcelist/job/template.html - 23 - - - ../src/app/frontend/overview/workloadstatus/template.html - 82 - - There is nothing to display here @@ -1851,17 +1887,6 @@ 52 - - Replica Sets - - ../src/app/frontend/common/components/resourcelist/replicaset/template.html - 23 - - - ../src/app/frontend/overview/workloadstatus/template.html - 112 - - Replications Controllers @@ -1894,17 +1919,6 @@ 58 - - Stateful Sets - - ../src/app/frontend/common/components/resourcelist/statefulset/template.html - 21 - - - ../src/app/frontend/overview/workloadstatus/template.html - 142 - - Secrets @@ -3342,20 +3356,6 @@ 151 - - Workload Status - - ../src/app/frontend/overview/workloadstatus/template.html - 20 - - - - Replication Controllers - - ../src/app/frontend/overview/workloadstatus/template.html - 127 - - Namespace information diff --git a/src/app/frontend/common/components/module.ts b/src/app/frontend/common/components/module.ts index 01d56f4e9c6a200004a8811b7f4551ff4e036eb4..30b2ec7dbd6381b3783be8fc2084af42d769550d 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 d96f349fd973a9f3aa0f8187fc240334c5c5f6fb..ff321b867887008800e4c699512226c2f36b7a90 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 0eff3058e8669bbdcc155be4f5218687331cd956..12ff5c86ee441bd8aa73fd040ff2bec62f886e57 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 0bafd2655a5f07a28d151444acb8dc74ec199757..3b713461e67ce8d0a9fff372c83ade4e35289782 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 0e69d10d2750d088f00df96411f49454ee6e796e..f9c67e712cb397be3cc821f7f428c80b04fbfccc 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 5c731c56f4b6e830f7d0ede05bb7d58fcb6dfb1a..871d64af4adaa2dbd64cfedf4fb9cf595f36c223 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 09c55eecf140a8b3577842ab4d7a0bfbbf2d66b9..5cccf7b5039c182bbec450a9eb4063f7848db797 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 4e97e80510f88200bcd22d31560fec88a410535c..c998cdc799615594f02a650509cfb9c18f9b6a2f 100644 --- a/src/app/frontend/resource/workloads/template.html +++ b/src/app/frontend/resource/workloads/template.html @@ -15,6 +15,8 @@ limitations under the License. -->
+