-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider/kubernetes): V2 server group details
- Loading branch information
Lars Wander
committed
Oct 13, 2017
1 parent
346348f
commit 3bebafb
Showing
4 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/scripts/modules/kubernetes/v2/serverGroup/IKubernetesServerGroup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
71 changes: 71 additions & 0 deletions
71
app/scripts/modules/kubernetes/v2/serverGroup/details.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
90
app/scripts/modules/kubernetes/v2/serverGroup/details.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |