Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

K8s add support for more resources #4780

Merged
merged 21 commits into from
Dec 4, 2020
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
Component,
ComponentFactoryResolver,
ComponentRef,
Injector,
Input,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core';
import { Component, ComponentFactoryResolver, ComponentRef, Injector, Input, OnDestroy, ViewChild } from '@angular/core';

import { ListComponent } from '../../list.component';
import { IListConfig, ListConfig } from '../../list.component.types';
Expand All @@ -22,9 +13,13 @@ import { ListConfigProvider } from '../list-config-provider.types';
ListComponent
]
})
export class ListViewComponent<T> implements OnInit, OnDestroy {
export class ListViewComponent<T> implements OnDestroy {

@Input() config: ListConfigProvider<T>;
@Input() set config(config: ListConfigProvider<T>) {
if (config) {
this.create(config);
}
}

@ViewChild(ListHostDirective, { static: true })
public listHost: ListHostDirective;
Expand All @@ -36,13 +31,22 @@ export class ListViewComponent<T> implements OnInit, OnDestroy {
private injector: Injector
) { }

ngOnInit() {
ngOnDestroy() {
if (this.componentRef) {
this.componentRef.destroy();
}
}

create(listConfig: ListConfigProvider<T>) {
// Clean up old component
this.ngOnDestroy();

const componentFactory = this.componentFactoryResolver.resolveComponentFactory(ListComponent);
const viewContainerRef = this.listHost.viewContainerRef;
this.componentRef = viewContainerRef.createComponent(
componentFactory,
null,
this.makeCustomConfigInjector(this.config.getListConfig())
this.makeCustomConfigInjector(listConfig.getListConfig())
);
}

Expand All @@ -52,10 +56,4 @@ export class ListViewComponent<T> implements OnInit, OnDestroy {
parent: this.injector
});
}

ngOnDestroy() {
if (this.componentRef) {
this.componentRef.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
</span>

<ng-template let-value="value" #valueTemplate>
<span *ngIf="value">{{ value }}</span>
<span class="default-cell__no-value" *ngIf="!value">-</span>
<span *ngIf="value !== 'undefined' && value !== 'null'">{{ value }}</span>
<span class="default-cell__no-value" *ngIf="value === 'undefined' || value === 'null'">-</span>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export interface IListConfig<T> {
customTimeInitialValue?: string;
}

// Simple list config does not need getDataSource
export type ISimpleListConfig<T> = Omit<IListConfig<T>, 'getDataSource'>;

export interface IListMultiFilterConfig {
key: string;
label: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { first, map } from 'rxjs/operators';
import { HomePageCardLayout } from '../../../../core/src/features/home/home.types';
import { HomeCardShortcut } from '../../../../store/src/entity-catalog/entity-catalog.types';
import { EndpointModel } from '../../../../store/src/public-api';
import { kubeEntityCatalog } from '../kubernetes-entity-catalog';
import { kubeEntityCatalog } from '../kubernetes-entity-generator';
import { KubernetesEndpointService } from '../services/kubernetes-endpoint.service';

@Component({
Expand Down Expand Up @@ -37,7 +37,7 @@ export class KubernetesHomeCardComponent implements OnInit {
public nodeCount$: Observable<number>;
public namespaceCount$: Observable<number>;

constructor(private store: Store<AppState>) { }
constructor(private store: Store<AppState>) { }

ngOnInit() {
const guid = this.endpoint.guid;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ import { getAPIResourceGuid } from '../../../cloud-foundry/src/store/selectors/a
import { EntitySchema } from '../../../store/src/helpers/entity-schema';
import { metricEntityType } from '../../../store/src/helpers/stratos-entity-factory';
import {
getGuidFromKubeDashboardObj,
getGuidFromKubeDeploymentObj,
getGuidFromKubeNamespaceObj,
getGuidFromKubeNodeObj,
getGuidFromKubePodObj,
getGuidFromKubeServiceObj,
getGuidFromKubeStatefulSetObj,
getGuidFromResource,
} from './store/kube.getIds';
import { KubernetesApp } from './store/kube.types';

export const kubernetesEntityType = 'kubernetesInfo';
export const kubernetesNodesEntityType = 'kubernetesNode';
export const kubernetesPodsEntityType = 'kubernetesPod';
export const kubernetesNamespacesEntityType = 'kubernetesNamespace';
export const kubernetesServicesEntityType = 'kubernetesService';
export const kubernetesStatefulSetsEntityType = 'kubernetesStatefulSet';
export const kubernetesDeploymentsEntityType = 'kubernetesDeployment';
export const kubernetesDashboardEntityType = 'kubernetesDashboard';
export const kubernetesEntityType = 'info';
export const kubernetesNodesEntityType = 'node';
export const kubernetesPodsEntityType = 'pod';
export const kubernetesNamespacesEntityType = 'namespace';
export const kubernetesServicesEntityType = 'service';
export const kubernetesStatefulSetsEntityType = 'statefulSet';
export const kubernetesDeploymentsEntityType = 'deployment';
export const kubernetesDashboardEntityType = 'dashboard';
export const analysisReportEntityType = 'analysisReport';
export const kubernetesConfigMapEntityType = 'configMap';

export const getKubeAppId = (object: KubernetesApp) => object.name;

Expand Down Expand Up @@ -102,7 +103,7 @@ entityCache[kubernetesServicesEntityType] = new KubernetesEntitySchema(
entityCache[kubernetesDashboardEntityType] = new KubernetesEntitySchema(
kubernetesDashboardEntityType,
{},
{ idAttribute: getGuidFromKubeDashboardObj }
{ idAttribute: getGuidFromResource }
);

// Analysis Reports - should not be bound to an endpoint
Expand Down
Loading