From d9bc3f74588cf3b19e014de0a19615b74bd991b3 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Fri, 11 Oct 2019 16:15:53 +0100 Subject: [PATCH] Update following design doc - https://xd.adobe.com/spec/dcd4203c-d334-462e-7921-ea6c3ef41151-aae5/screen/a2ea0108-1ae5-418f-8153-bc2a1fe985d5/Filter/ - Include optional labels list component - Fix issue where search term was not capitalised - Improve typing --- .../custom/kubernetes/kubernetes.module.ts | 27 ++++++---- .../kubernetes-labels-cell.component.html | 1 + .../kubernetes-labels-cell.component.scss | 0 .../kubernetes-labels-cell.component.spec.ts | 45 ++++++++++++++++ .../kubernetes-labels-cell.component.ts | 26 ++++++++++ .../condition-cell.component.ts | 17 ------ .../kubernetes-node-ips.component.html | 1 + .../kubernetes-node-ips.component.scss | 5 ++ .../kubernetes-node-ips.component.spec.ts | 46 ++++++++++++++++ .../kubernetes-node-ips.component.ts | 26 ++++++++++ .../kubernetes-node-labels.component.html | 1 + .../kubernetes-node-labels.component.scss | 5 ++ .../kubernetes-node-labels.component.spec.ts | 46 ++++++++++++++++ .../kubernetes-node-labels.component.ts | 25 +++++++++ .../kubernetes-node-link.component.spec.ts | 8 +-- .../kubernetes-node-link.component.ts | 5 +- .../kubernetes-node-pressure.component.html | 9 ++++ .../kubernetes-node-pressure.component.scss | 12 +++++ ...kubernetes-node-pressure.component.spec.ts | 46 ++++++++++++++++ ...ernetes-node-pressure.component.theme.scss | 13 +++++ .../kubernetes-node-pressure.component.ts | 43 +++++++++++++++ .../kubernetes-node-condition.component.ts | 11 ++-- .../kubernetes-nodes-list-config.service.ts | 52 +++++++++++-------- .../app/custom/kubernetes/store/kube.types.ts | 27 +++++++--- 24 files changed, 426 insertions(+), 71 deletions(-) create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.html create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.scss create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.spec.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.html create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.scss create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.html create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.scss create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.html create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.scss create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.theme.scss create mode 100644 custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.ts diff --git a/custom-src/frontend/app/custom/kubernetes/kubernetes.module.ts b/custom-src/frontend/app/custom/kubernetes/kubernetes.module.ts index 6cf7f688ec..e9f7dbfad8 100644 --- a/custom-src/frontend/app/custom/kubernetes/kubernetes.module.ts +++ b/custom-src/frontend/app/custom/kubernetes/kubernetes.module.ts @@ -40,23 +40,27 @@ import { AppLinkComponent } from './list-types/kubernetes-apps/app-link/app-link import { KubeAppcreatedDateComponent, } from './list-types/kubernetes-apps/kube-appcreated-date/kube-appcreated-date.component'; +import { KubernetesLabelsCellComponent } from './list-types/kubernetes-labels-cell/kubernetes-labels-cell.component'; import { KubeNamespacePodCountComponent, } from './list-types/kubernetes-namespaces/kube-namespace-pod-count/kube-namespace-pod-count.component'; import { KubernetesNamespaceLinkComponent, } from './list-types/kubernetes-namespaces/kubernetes-namespace-link/kubernetes-namespace-link.component'; -import { - ConditionCellComponent, - InverseConditionCellComponent, - SubtleConditionCellComponent, -} from './list-types/kubernetes-nodes/condition-cell/condition-cell.component'; +import { ConditionCellComponent } from './list-types/kubernetes-nodes/condition-cell/condition-cell.component'; import { KubernetesNodeCapacityComponent, } from './list-types/kubernetes-nodes/kubernetes-node-capacity/kubernetes-node-capacity.component'; +import { KubernetesNodeIpsComponent } from './list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component'; +import { + KubernetesNodeLabelsComponent, +} from './list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component'; import { KubernetesNodeLinkComponent, } from './list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component'; +import { + KubernetesNodePressureComponent, +} from './list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component'; import { KubernetesNodeConditionCardComponent, } from './list-types/kubernetes-nodes/kubernetes-node-summary/kubernetes-node-condition-card/kubernetes-node-condition-card.component'; @@ -91,6 +95,7 @@ import { KubernetesPodsTabComponent } from './tabs/kubernetes-pods-tab/kubernete import { KubernetesSummaryTabComponent } from './tabs/kubernetes-summary-tab/kubernetes-summary.component'; + /* tslint:enable */ @NgModule({ @@ -120,6 +125,10 @@ import { KubernetesSummaryTabComponent } from './tabs/kubernetes-summary-tab/kub HelmReleaseSummaryCardComponent, PodMetricsComponent, KubernetesNodeLinkComponent, + KubernetesNodeIpsComponent, + KubernetesNodeLabelsComponent, + KubernetesNodePressureComponent, + KubernetesLabelsCellComponent, KubernetesNodeComponent, KubernetesNodeSummaryComponent, KubernetesNodePodsComponent, @@ -134,8 +143,6 @@ import { KubernetesSummaryTabComponent } from './tabs/kubernetes-summary-tab/kub KubernetesNodeMetricStatsCardComponent, KubernetesNodeSimpleMetricComponent, ConditionCellComponent, - InverseConditionCellComponent, - SubtleConditionCellComponent, KubernetesNamespaceLinkComponent, KubernetesNamespaceComponent, KubernetesNamespacePodsComponent, @@ -161,9 +168,11 @@ import { KubernetesSummaryTabComponent } from './tabs/kubernetes-summary-tab/kub KubernetesPodTagsComponent, AppLinkComponent, KubernetesNodeLinkComponent, + KubernetesNodeIpsComponent, + KubernetesNodeLabelsComponent, + KubernetesNodePressureComponent, + KubernetesLabelsCellComponent, ConditionCellComponent, - InverseConditionCellComponent, - SubtleConditionCellComponent, KubernetesNamespaceLinkComponent, KubeAppcreatedDateComponent, KubeNamespacePodCountComponent, diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.html b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.html new file mode 100644 index 0000000000..ba47496e44 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.scss b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.spec.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.spec.ts new file mode 100644 index 0000000000..4c332d1f29 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.spec.ts @@ -0,0 +1,45 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { KubernetesStatus } from '../../../../../../../../../custom-src/frontend/app/custom/kubernetes/store/kube.types'; +import { BaseTestModules } from '../../../../../test-framework/core-test.helper'; +import { KubernetesLabelsCellComponent } from './kubernetes-labels-cell.component'; + +describe('KubernetesLabelsCellComponent', () => { + let component: KubernetesLabelsCellComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [KubernetesLabelsCellComponent], + imports: BaseTestModules + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KubernetesLabelsCellComponent); + component = fixture.componentInstance; + component.row = { + metadata: { + labels: {}, + namespace: 'test', + name: 'test', + uid: 'test' + }, + status: { + phase: KubernetesStatus.ACTIVE + }, + spec: { + containers: [], + nodeName: 'test', + schedulerName: 'test', + initContainers: [] + } + }; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.ts new file mode 100644 index 0000000000..46a6891b28 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-labels-cell/kubernetes-labels-cell.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; + +import { AppChip } from '../../../../shared/components/chips/chips.component'; +import { TableCellCustom } from '../../../../shared/components/list/list.types'; +import { KubeAPIResource } from '../../store/kube.types'; + + +@Component({ + selector: 'app-kubernetes-labels-cell', + templateUrl: './kubernetes-labels-cell.component.html', + styleUrls: ['./kubernetes-labels-cell.component.scss'] +}) +export class KubernetesLabelsCellComponent extends TableCellCustom implements OnInit { + + chipsConfig: AppChip[]; + + constructor() { + super(); + } + + ngOnInit() { + this.chipsConfig = Object.entries(this.row.metadata.labels).map(([key, value]) => ({ + value: `${key}:${value}` + })); + } +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/condition-cell/condition-cell.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/condition-cell/condition-cell.component.ts index 4e90794278..55bb13dee8 100644 --- a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/condition-cell/condition-cell.component.ts +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/condition-cell/condition-cell.component.ts @@ -35,20 +35,3 @@ export class ConditionCellComponent extends TableCellCustom impl } } - -export class SubtleConditionCellComponent extends ConditionCellComponent { - - constructor() { - super(); - this.subtle = true; - } -} - - -export class InverseConditionCellComponent extends ConditionCellComponent { - - constructor() { - super(); - this.inverse = true; - } -} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.html b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.html new file mode 100644 index 0000000000..fb1c936c0a --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.html @@ -0,0 +1 @@ +language \ No newline at end of file diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.scss b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.scss new file mode 100644 index 0000000000..03d64068f2 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.scss @@ -0,0 +1,5 @@ +mat-icon { + font-size: 20px; + height: 20px; + width: 20px; +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts new file mode 100644 index 0000000000..807f5cb307 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.spec.ts @@ -0,0 +1,46 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BaseTestModules } from '../../../../../../test-framework/core-test.helper'; +import { KubernetesNodeIpsComponent } from './kubernetes-node-ips.component'; + +describe('KubernetesNodeIpsComponent', () => { + let component: KubernetesNodeIpsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [KubernetesNodeIpsComponent], + imports: BaseTestModules + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KubernetesNodeIpsComponent); + component = fixture.componentInstance; + component.row = { + metadata: { + labels: {}, + namespace: 'test', + name: 'test', + uid: 'test' + }, + status: { + conditions: [], + addresses: [], + images: [] + }, + spec: { + containers: [], + nodeName: 'test', + schedulerName: 'test', + initContainers: [] + } + }; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.ts new file mode 100644 index 0000000000..456cb420cc --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-ips/kubernetes-node-ips.component.ts @@ -0,0 +1,26 @@ +import { Component, OnInit } from '@angular/core'; + +import { TableCellCustom } from '../../../../../shared/components/list/list.types'; +import { KubernetesAddressExternal, KubernetesAddressInternal, KubernetesNode } from '../../../store/kube.types'; + +@Component({ + selector: 'app-kubernetes-node-ips', + templateUrl: './kubernetes-node-ips.component.html', + styleUrls: ['./kubernetes-node-ips.component.scss'] +}) +export class KubernetesNodeIpsComponent extends TableCellCustom implements OnInit { + + tooltip: string; + + constructor() { + super(); + } + + ngOnInit() { + this.tooltip = this.row.status.addresses + .filter(address => address.type === KubernetesAddressInternal || address.type === KubernetesAddressExternal) + .map(address => address.address) + .join(', '); + } + +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.html b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.html new file mode 100644 index 0000000000..e50abec150 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.html @@ -0,0 +1 @@ +info \ No newline at end of file diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.scss b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.scss new file mode 100644 index 0000000000..03d64068f2 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.scss @@ -0,0 +1,5 @@ +mat-icon { + font-size: 20px; + height: 20px; + width: 20px; +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts new file mode 100644 index 0000000000..3ca174e16f --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.spec.ts @@ -0,0 +1,46 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BaseTestModules } from '../../../../../../test-framework/core-test.helper'; +import { KubernetesNodeLabelsComponent } from './kubernetes-node-labels.component'; + +describe('KubernetesNodeLabelsComponent', () => { + let component: KubernetesNodeLabelsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [KubernetesNodeLabelsComponent], + imports: BaseTestModules + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KubernetesNodeLabelsComponent); + component = fixture.componentInstance; + component.row = { + metadata: { + labels: {}, + namespace: 'test', + name: 'test', + uid: 'test' + }, + status: { + conditions: [], + addresses: [], + images: [] + }, + spec: { + containers: [], + nodeName: 'test', + schedulerName: 'test', + initContainers: [] + } + }; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.ts new file mode 100644 index 0000000000..2ee563db06 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-labels/kubernetes-node-labels.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; + +import { TableCellCustom } from '../../../../../shared/components/list/list.types'; +import { KubernetesNode } from '../../../store/kube.types'; + +@Component({ + selector: 'app-kubernetes-node-labels', + templateUrl: './kubernetes-node-labels.component.html', + styleUrls: ['./kubernetes-node-labels.component.scss'] +}) +export class KubernetesNodeLabelsComponent extends TableCellCustom implements OnInit { + + labels: string; + + constructor() { + super(); + } + + ngOnInit() { + this.labels = Object.entries(this.row.metadata.labels) + .map(([key, value]) => `${key}:${value}`) + .join(', '); + } + +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.spec.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.spec.ts index d84951cb45..4a6acb5d3e 100644 --- a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.spec.ts +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.spec.ts @@ -1,13 +1,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { KubernetesNodeLinkComponent } from './kubernetes-node-link.component'; import { BaseKubeGuid } from '../../../kubernetes-page.types'; -import { KubernetesEndpointService } from '../../../services/kubernetes-endpoint.service'; import { KubernetesBaseTestModules } from '../../../kubernetes.testing.module'; +import { KubernetesEndpointService } from '../../../services/kubernetes-endpoint.service'; +import { KubernetesNodeLinkComponent } from './kubernetes-node-link.component'; describe('KubernetesNodeLinkComponent', () => { - let component: KubernetesNodeLinkComponent; - let fixture: ComponentFixture>; + let component: KubernetesNodeLinkComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.ts index 2d6f5059ca..21d7d00432 100644 --- a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.ts +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-link/kubernetes-node-link.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; -import { KubernetesEndpointService } from '../../../services/kubernetes-endpoint.service'; + import { TableCellCustom } from '../../../../../shared/components/list/list.types'; +import { KubernetesEndpointService } from '../../../services/kubernetes-endpoint.service'; import { KubernetesNode } from '../../../store/kube.types'; @Component({ @@ -8,7 +9,7 @@ import { KubernetesNode } from '../../../store/kube.types'; templateUrl: './kubernetes-node-link.component.html', styleUrls: ['./kubernetes-node-link.component.scss'] }) -export class KubernetesNodeLinkComponent extends TableCellCustom implements OnInit { +export class KubernetesNodeLinkComponent extends TableCellCustom implements OnInit { public nodeLink; constructor( diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.html b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.html new file mode 100644 index 0000000000..aeafa64566 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.html @@ -0,0 +1,9 @@ + +
+ info + {{ error }} +
+
+ + None + \ No newline at end of file diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.scss b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.scss new file mode 100644 index 0000000000..38738ff61b --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.scss @@ -0,0 +1,12 @@ +.pressure { + align-items: center; + display: flex; + + &__icon { + color: red; + font-size: 20px; + height: 20px; + margin-right: 4px; + width: 20px; + } +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts new file mode 100644 index 0000000000..4f543f9596 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.spec.ts @@ -0,0 +1,46 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BaseTestModules } from '../../../../../../test-framework/core-test.helper'; +import { KubernetesNodePressureComponent } from './kubernetes-node-pressure.component'; + +describe('KubernetesNodePressureComponent', () => { + let component: KubernetesNodePressureComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [KubernetesNodePressureComponent], + imports: BaseTestModules + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(KubernetesNodePressureComponent); + component = fixture.componentInstance; + component.row = { + metadata: { + labels: {}, + namespace: 'test', + name: 'test', + uid: 'test' + }, + status: { + conditions: [], + addresses: [], + images: [] + }, + spec: { + containers: [], + nodeName: 'test', + schedulerName: 'test', + initContainers: [] + } + }; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.theme.scss b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.theme.scss new file mode 100644 index 0000000000..5508403ef1 --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.theme.scss @@ -0,0 +1,13 @@ + + +// Not currently used but should be - NJ +@import '~@angular/material/theming'; +@mixin app-kubernetes-node-pressure($theme, $app-theme) { + $status: map-get($app-theme, status); + .pressure { + // color: map-get($status, danger); + &__icon { + color: map-get($status, danger); + } + } +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.ts new file mode 100644 index 0000000000..6fb518536e --- /dev/null +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-pressure/kubernetes-node-pressure.component.ts @@ -0,0 +1,43 @@ +import { Component, OnInit } from '@angular/core'; + +import { TableCellCustom } from '../../../../../shared/components/list/list.types'; +import { ConditionType, ConditionTypeLabels, KubernetesNode } from '../../../store/kube.types'; + +@Component({ + selector: 'app-kubernetes-node-pressure', + templateUrl: './kubernetes-node-pressure.component.html', + styleUrls: ['./kubernetes-node-pressure.component.scss'] +}) +export class KubernetesNodePressureComponent extends TableCellCustom implements OnInit { + + errors: string[] = []; + + constructor() { + super(); + } + + ngOnInit() { + const conditions = this.row.status.conditions; + // const conditions: Condition[] = [{ + // lastHeartbeatTime: new Date(), + // lastTransitionTime: new Date(), + // reason: '', + // status: ConditionStatus.True, + // message: 'Disk', // TODO: RC + // type: ConditionType.DiskPressure + // }, { + // lastHeartbeatTime: new Date(), + // lastTransitionTime: new Date(), + // reason: '', + // status: ConditionStatus.False, + // message: 'Memory', + // type: ConditionType.MemoryPressure + // }]; + this.errors = conditions + .filter(c => c.type !== ConditionType.Ready) + // .filter(c => c.type === ConditionType.DiskPressure || ConditionType.MemoryPressure) + .filter(c => c.status === 'True') + .map(condition => ConditionTypeLabels[condition.type] || condition.type); + } + +} diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-summary/kubernetes-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-summary/kubernetes-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.ts index 5f7baf1d35..6f2e961180 100644 --- a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-summary/kubernetes-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.ts +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-node-summary/kubernetes-node-condition-card/kubernetes-node-condition/kubernetes-node-condition.component.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { KubernetesNodeService } from '../../../../../services/kubernetes-node.service'; -import { Condition, ConditionType } from '../../../../../store/kube.types'; +import { ConditionType, ConditionTypeLabels, KubernetesCondition } from '../../../../../store/kube.types'; @Component({ selector: 'app-kubernetes-node-condition', @@ -23,12 +23,7 @@ export class KubernetesNodeConditionComponent implements OnInit { @Input() subtle = false; - public titles = { - Ready: 'Ready', - OutOfDisk: 'Out of Disk', - MemoryPressure: 'Memory Pressure', - DiskPressure: 'Disk Pressure' - }; + public titles = ConditionTypeLabels; public icons = { Ready: ['done_outline', 'material-icons'], @@ -51,7 +46,7 @@ export class KubernetesNodeConditionComponent implements OnInit { ); } - shouldBeGreen(condition: Condition) { + shouldBeGreen(condition: KubernetesCondition) { if (condition.status === 'True') { if (condition.type === ConditionType.Ready) { return true; diff --git a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-nodes-list-config.service.ts b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-nodes-list-config.service.ts index f86799211d..5d10ab5b48 100644 --- a/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-nodes-list-config.service.ts +++ b/custom-src/frontend/app/custom/kubernetes/list-types/kubernetes-nodes/kubernetes-nodes-list-config.service.ts @@ -7,12 +7,15 @@ import { DataFunction } from '../../../../shared/components/list/data-sources-co import { ITableColumn } from '../../../../shared/components/list/list-table/table.types'; import { IListConfig, IListFilter, ListViewTypes } from '../../../../shared/components/list/list.component.types'; import { BaseKubeGuid } from '../../kubernetes-page.types'; -import { ConditionType, KubernetesNode } from '../../store/kube.types'; +import { ConditionType, KubernetesAddressExternal, KubernetesAddressInternal, KubernetesNode } from '../../store/kube.types'; import { defaultHelmKubeListPageSize } from '../kube-helm-list-types'; import { getConditionSort } from '../kube-sort.helper'; -import { ConditionCellComponent, SubtleConditionCellComponent } from './condition-cell/condition-cell.component'; +import { ConditionCellComponent } from './condition-cell/condition-cell.component'; import { KubernetesNodeCapacityComponent } from './kubernetes-node-capacity/kubernetes-node-capacity.component'; +import { KubernetesNodeIpsComponent } from './kubernetes-node-ips/kubernetes-node-ips.component'; +import { KubernetesNodeLabelsComponent } from './kubernetes-node-labels/kubernetes-node-labels.component'; import { KubernetesNodeLinkComponent } from './kubernetes-node-link/kubernetes-node-link.component'; +import { KubernetesNodePressureComponent } from './kubernetes-node-pressure/kubernetes-node-pressure.component'; import { KubernetesNodesDataSource } from './kubernetes-nodes-data-source'; import { NodePodCountComponent } from './node-pod-count/node-pod-count.component'; @@ -37,6 +40,16 @@ export class KubernetesNodesListConfigService implements IListConfig 'IPs', + cellComponent: KubernetesNodeIpsComponent, + cellFlex: '1', + }, + { + columnId: 'labels', headerCell: () => 'Labels', + cellComponent: KubernetesNodeLabelsComponent, + cellFlex: '1', + }, { columnId: 'ready', headerCell: () => 'Ready', cellConfig: { @@ -48,21 +61,8 @@ export class KubernetesNodesListConfigService implements IListConfig 'Disk Pressure', - cellComponent: SubtleConditionCellComponent, - cellConfig: { - conditionType: ConditionType.DiskPressure - }, - sort: getConditionSort(ConditionType.DiskPressure), - cellFlex: '2', - }, - { - columnId: 'memPressure', headerCell: () => 'Memory Pressure', - cellComponent: SubtleConditionCellComponent, - cellConfig: { - conditionType: ConditionType.MemoryPressure - }, - sort: getConditionSort(ConditionType.MemoryPressure), + columnId: 'condition', headerCell: () => 'Condition', + cellComponent: KubernetesNodePressureComponent, cellFlex: '2', }, { @@ -73,8 +73,14 @@ export class KubernetesNodesListConfigService implements IListConfig 'Capacity', cellComponent: KubernetesNodeCapacityComponent, - cellFlex: '5', + cellFlex: '4', }, + // Display labels as the usual chip list + // { + // columnId: 'labels', headerCell: () => 'Labels', + // cellComponent: KubernetesLabelsCellComponent, + // cellFlex: '6', + // }, ]; filters: IListFilter[] = [ { @@ -118,20 +124,20 @@ export class KubernetesNodesListConfigService implements IListConfig[] = [ (entities: KubernetesNode[], paginationState: PaginationEntityState) => { - const filterString = paginationState.clientPagination.filter.string; - - if (!filterString) { + if (!paginationState.clientPagination.filter.string) { return entities; } + const filterString = paginationState.clientPagination.filter.string.toUpperCase(); + const filterKey = paginationState.clientPagination.filter.filterKey; switch (filterKey) { case KubernetesNodesListFilterKeys.IP_ADDRESS: return entities.filter(node => { const ipAddress = - node.status.addresses.find(address => address.type === 'InternalIP') || - node.status.addresses.find(address => address.type === 'ExternalIP'); + node.status.addresses.find(address => address.type === KubernetesAddressInternal) || + node.status.addresses.find(address => address.type === KubernetesAddressExternal); return ipAddress ? ipAddress.address.toUpperCase().includes(filterString) : false; }); diff --git a/custom-src/frontend/app/custom/kubernetes/store/kube.types.ts b/custom-src/frontend/app/custom/kubernetes/store/kube.types.ts index bf5a26ed0a..db04efe87c 100644 --- a/custom-src/frontend/app/custom/kubernetes/store/kube.types.ts +++ b/custom-src/frontend/app/custom/kubernetes/store/kube.types.ts @@ -98,8 +98,8 @@ export interface KubernetesApp { export interface NodeStatus { capacity?: Capacity; allocatable?: Allocatable; - conditions: Condition[]; - addresses: Address[]; + conditions: KubernetesCondition[]; + addresses: KubernetesAddress[]; daemonEndpoints?: DaemonEndpoints; nodeInfo?: NodeInfo; images: Image[]; @@ -133,8 +133,16 @@ export enum ConditionType { OutOfDisk = 'OutOfDisk', MemoryPressure = 'MemoryPressure', DiskPressure = 'DiskPressure', - Ready = 'Ready' -} + Ready = 'Ready', + PIDPressure = 'PIDPressure' +} +export const ConditionTypeLabels = { + [ConditionType.Ready]: 'Ready', + [ConditionType.OutOfDisk]: 'Out of Disk', + [ConditionType.MemoryPressure]: 'Memory Pressure', + [ConditionType.DiskPressure]: 'Disk Pressure', + [ConditionType.PIDPressure]: 'PID Pressure' +}; export enum ConditionStatus { False = 'False', @@ -142,7 +150,7 @@ export enum ConditionStatus { Unknown = 'Unknown' } -export interface Condition { +export interface KubernetesCondition { type: ConditionType; status: ConditionStatus; lastHeartbeatTime: Date; @@ -151,11 +159,14 @@ export interface Condition { message: string; } -export interface Address { +export interface KubernetesAddress { type: string; address: string; } +export const KubernetesAddressInternal = 'InternalIP'; +export const KubernetesAddressExternal = 'ExternalIP'; + export interface KubeletEndpoint { Port: number; } @@ -208,7 +219,7 @@ export interface BaseStatus { export interface PodStatus { phase: KubernetesStatus; - conditions?: Condition[]; + conditions?: KubernetesCondition[]; message?: string; reason?: string; hostIP?: string; @@ -218,7 +229,7 @@ export interface PodStatus { qosClass?: string; initContainerStatuses?: ContainerStatus[]; } -export interface Condition { +export interface KubernetesCondition { type: ConditionType; status: ConditionStatus; lastProbeTime?: any;