From 3bebafbcee1c77a31e2eb7e96a710ca12c087816 Mon Sep 17 00:00:00 2001 From: Lars Wander Date: Fri, 13 Oct 2017 09:30:12 -0400 Subject: [PATCH] feat(provider/kubernetes): V2 server group details --- .../kubernetes/v2/kubernetes.v2.module.ts | 4 + .../v2/serverGroup/IKubernetesServerGroup.ts | 8 ++ .../v2/serverGroup/details.controller.ts | 71 +++++++++++++++ .../kubernetes/v2/serverGroup/details.html | 90 +++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 app/scripts/modules/kubernetes/v2/serverGroup/IKubernetesServerGroup.ts create mode 100644 app/scripts/modules/kubernetes/v2/serverGroup/details.controller.ts create mode 100644 app/scripts/modules/kubernetes/v2/serverGroup/details.html diff --git a/app/scripts/modules/kubernetes/v2/kubernetes.v2.module.ts b/app/scripts/modules/kubernetes/v2/kubernetes.v2.module.ts index afcfafb5d64..4b6ba0d3f95 100644 --- a/app/scripts/modules/kubernetes/v2/kubernetes.v2.module.ts +++ b/app/scripts/modules/kubernetes/v2/kubernetes.v2.module.ts @@ -9,6 +9,7 @@ import { KUBERNETES_V2_SERVER_GROUP_COMMAND_BUILDER } from './serverGroup/server import { KUBERNETES_MANIFEST_CTRL } from './manifest/wizard/manifestWizard.controller'; import { KUBERNETES_MANIFEST_ENTRY } from './manifest/wizard/manifestEntry.component'; import { KUBERNETES_V2_SERVER_GROUP_TRANSFORMER } from './serverGroup/serverGroupTransformer.service'; +import { KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL} from './serverGroup/details.controller'; // load all templates into the $templateCache const templates = require.context('kubernetes', true, /\.html$/); @@ -22,6 +23,7 @@ module(KUBERNETES_V2_MODULE, [ CLOUD_PROVIDER_REGISTRY, KUBERNETES_V2_SERVER_GROUP_COMMAND_BUILDER, KUBERNETES_V2_SERVER_GROUP_TRANSFORMER, + KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL, KUBERNETES_MANIFEST_BASIC_SETTINGS, KUBERNETES_MANIFEST_COMMAND_BUILDER, KUBERNETES_MANIFEST_CTRL, @@ -38,6 +40,8 @@ module(KUBERNETES_V2_MODULE, [ cloneServerGroupController: 'kubernetesManifestWizardCtrl', cloneServerGroupTemplateUrl: require('./manifest/wizard/manifestWizard.html'), transformer: 'kubernetesV2ServerGroupTransformer', + detailsTemplateUrl: require('./serverGroup/details.html'), + detailsController: 'kubernetesV2ServerGroupDetailsCtrl', } }); }); diff --git a/app/scripts/modules/kubernetes/v2/serverGroup/IKubernetesServerGroup.ts b/app/scripts/modules/kubernetes/v2/serverGroup/IKubernetesServerGroup.ts new file mode 100644 index 00000000000..19949f7fa23 --- /dev/null +++ b/app/scripts/modules/kubernetes/v2/serverGroup/IKubernetesServerGroup.ts @@ -0,0 +1,8 @@ +import { IServerGroup } from '@spinnaker/core'; + +export interface IKubernetesServerGroup extends IServerGroup { + kind: string; + displayName: string; + apiVersion: string; + disabled: boolean; +} diff --git a/app/scripts/modules/kubernetes/v2/serverGroup/details.controller.ts b/app/scripts/modules/kubernetes/v2/serverGroup/details.controller.ts new file mode 100644 index 00000000000..013d8f8d881 --- /dev/null +++ b/app/scripts/modules/kubernetes/v2/serverGroup/details.controller.ts @@ -0,0 +1,71 @@ +import { IController, module } from 'angular'; + +import { + Application, + CONFIRMATION_MODAL_SERVICE, + IServerGroup, + SERVER_GROUP_READER, + SERVER_GROUP_WARNING_MESSAGE_SERVICE, + SERVER_GROUP_WRITER, + ServerGroupReader +} from '@spinnaker/core'; + +import { IKubernetesServerGroup } from './IKubernetesServerGroup'; + +interface IServerGroupFromStateParams { + accountId: string; + region: string; + name: string; +} + +class KubernetesServerGroupDetailsController implements IController { + public state = { loading: true }; + public serverGroup: IKubernetesServerGroup; + + constructor(serverGroup: IServerGroupFromStateParams, + public app: Application, + private serverGroupReader: ServerGroupReader) { + 'ngInject'; + + this.app + .ready() + .then(() => this.extractServerGroup(serverGroup)) + .catch(() => this.autoClose()); + } + + public canResizeServerGroup(): boolean { + return false; // will change with daemon set + } + + private autoClose(): void { + return; + } + + private transformServerGroup(serverGroupDetails: IServerGroup): IKubernetesServerGroup { + const serverGroup: IKubernetesServerGroup = Object.assign(serverGroupDetails); + const [apiVersion, kind, name] = serverGroup.name.split('|'); + serverGroup.displayName = name; + serverGroup.kind = kind; + serverGroup.apiVersion = apiVersion.replace('.', '/'); + return serverGroup; + } + + private extractServerGroup(fromParams: IServerGroupFromStateParams): ng.IPromise { + return this.serverGroupReader + .getServerGroup(this.app.name, fromParams.accountId, fromParams.region, encodeURIComponent(fromParams.name)) + .then((serverGroupDetails: IServerGroup) => { + this.serverGroup = this.transformServerGroup(serverGroupDetails); + this.state.loading = false; + }); + } +} + +export const KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL = 'spinnaker.kubernetes.v2.serverGroup.details.controller'; + +module(KUBERNETES_V2_SERVER_GROUP_DETAILS_CTRL, [ + CONFIRMATION_MODAL_SERVICE, + SERVER_GROUP_WARNING_MESSAGE_SERVICE, + SERVER_GROUP_READER, + SERVER_GROUP_WRITER, + ]) + .controller('kubernetesV2ServerGroupDetailsCtrl', KubernetesServerGroupDetailsController); diff --git a/app/scripts/modules/kubernetes/v2/serverGroup/details.html b/app/scripts/modules/kubernetes/v2/serverGroup/details.html new file mode 100644 index 00000000000..983c77ef74d --- /dev/null +++ b/app/scripts/modules/kubernetes/v2/serverGroup/details.html @@ -0,0 +1,90 @@ +
+
+
+ + + +
+

+ +

+
+ +
+
+ + + +
+
+ +

+ {{ctrl.serverGroup.displayName}} +

+
+
+ +
+
+
+ +
+
Disabled
+ + +
+
Created
+
{{ctrl.serverGroup.createdTime | timestamp}}
+
Account
+
+
Namespace
+
{{ctrl.serverGroup.region}}
+
Api Version
+
{{ctrl.serverGroup.apiVersion}}
+
Kind
+
{{ctrl.serverGroup.kind}}
+
+
+ +
+
Min/Max
+
{{ctrl.serverGroup.capacity.min}}
+
Current
+
{{ctrl.serverGroup.instances.length}}
+
+
+
Min
+
{{ctrl.serverGroup.capacity.min}}
+
Max
+
{{ctrl.serverGroup.capacity.max}}
+
Current
+
{{ctrl.serverGroup.instances.length}}
+
+
+ +
+
Instances
+
+ +
+
+
+
+