Skip to content

Commit

Permalink
feat(provider/kubernetes): V2 server group details
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Wander committed Oct 13, 2017
1 parent 346348f commit 3bebafb
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/scripts/modules/kubernetes/v2/kubernetes.v2.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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$/);
Expand All @@ -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,
Expand All @@ -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',
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IServerGroup } from '@spinnaker/core';

export interface IKubernetesServerGroup extends IServerGroup {
kind: string;
displayName: string;
apiVersion: string;
disabled: boolean;
}
Original file line number Diff line number Diff line change
@@ -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<void> {
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);
90 changes: 90 additions & 0 deletions app/scripts/modules/kubernetes/v2/serverGroup/details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<div class="details-panel"
ng-class="{disabled: ctrl.serverGroup.isDisabled || ctrl.serverGroup.disabled}">
<div class="header" ng-if="ctrl.state.loading">
<div class="close-button">
<a class="btn btn-link"
ui-sref="^">
<span class="glyphicon glyphicon-remove"></span>
</a>
</div>
<h4 class="text-center">
<span us-spinner="{radius:20, width:6, length: 12}"></span>
</h4>
</div>

<div class="header" ng-if="!ctrl.state.loading">
<div class="close-button">
<a class="btn btn-link"
ui-sref="^">
<span class="glyphicon glyphicon-remove"></span>
</a>
</div>
<div class="header-text">
<cloud-provider-logo provider="ctrl.serverGroup.cloudProvider" height="'36px'" width="'36px'"></cloud-provider-logo>
<h3 select-on-dbl-click>
{{ctrl.serverGroup.displayName}}
</h3>
</div>
<div class="actions">
<div class="dropdown" uib-dropdown dropdown-append-to-body>
<button type="button" class="btn btn-sm btn-primary dropdown-toggle" uib-dropdown-toggle>
Server Group Actions <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li ng-if="ctrl.canResizeServerGroup()">
<a href ng-click="ctrl.resizeServerGroup()">
Resize
</a>
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</div>

<div class="content" ng-if="!ctrl.state.loading">
<div class="band band-info" ng-if="ctrl.serverGroup.isDisabled || ctrl.serverGroup.disabled">Disabled</div>
<server-group-running-tasks-details server-group="ctrl.serverGroup" application="ctrl.serverGroup.moniker.app"></server-group-running-tasks-details>
<collapsible-section heading="Information" expanded="true">
<dl class="dl-horizontal dl-flex">
<dt>Created</dt>
<dd>{{ctrl.serverGroup.createdTime | timestamp}}</dd>
<dt>Account</dt>
<dd><account-tag account="ctrl.serverGroup.accountName"></account-tag></dd>
<dt>Namespace</dt>
<dd>{{ctrl.serverGroup.region}}</dd>
<dt>Api Version</dt>
<dd>{{ctrl.serverGroup.apiVersion}}</dd>
<dt>Kind</dt>
<dd>{{ctrl.serverGroup.kind}}</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Size" expanded="true">
<dl class="dl-horizontal dl-flex"
ng-if="ctrl.serverGroup.capacity.min === ctrl.serverGroup.capacity.max">
<dt>Min/Max</dt>
<dd>{{ctrl.serverGroup.capacity.min}}</dd>
<dt>Current</dt>
<dd>{{ctrl.serverGroup.instances.length}}</dd>
</dl>
<dl class="dl-horizontal dl-flex"
ng-if="ctrl.serverGroup.capacity.min !== ctrl.serverGroup.capacity.max">
<dt>Min</dt>
<dd>{{ctrl.serverGroup.capacity.min}}</dd>
<dt>Max</dt>
<dd>{{ctrl.serverGroup.capacity.max}}</dd>
<dt>Current</dt>
<dd>{{ctrl.serverGroup.instances.length}}</dd>
</dl>
</collapsible-section>
<collapsible-section heading="Health" expanded="true">
<dl class="dl-horizontal dl-flex"
ng-if="ctrl.serverGroup">
<dt>Instances</dt>
<dd>
<health-counts container="ctrl.serverGroup.instanceCounts" class="pull-left"></health-counts>
</dd>
</dl>
</collapsible-section>
</div>
</div>

0 comments on commit 3bebafb

Please sign in to comment.