Skip to content

Commit

Permalink
resource limits view in namespace detail
Browse files Browse the repository at this point in the history
  • Loading branch information
urcan committed Sep 28, 2016
1 parent 1768e1f commit 720bda0
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions i18n/messages-en.xtb
Original file line number Diff line number Diff line change
Expand Up @@ -820,4 +820,5 @@
<translation id="4598945348959438653" key="MSG_LIMIT_RANGE_LIST_NAMESPACE_LABEL" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Limit range list header: namespace.">Namespace</translation>
<translation id="391138217811387226" key="MSG_LIMIT_RANGE_LIST_HEADER_AGE" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Limit range list header: age.">Age</translation>
<translation id="7449277386438313026" key="MSG_BREADCRUMBS_LIMIT_RANGES_LABEL" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Label 'Limit Ranges' that appears as a breadcrumbs on the action bar.">Limit Ranges</translation>
<translation id="4427523950335685235" key="MSG_NAMESPACE_DETAIL_RESOURCE_LIMITS_TITLE" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="header name for the resource limits on the namespace details page.">Resource Limits</translation>
</translationbundle>
1 change: 1 addition & 0 deletions i18n/messages-ja.xtb
Original file line number Diff line number Diff line change
Expand Up @@ -1022,4 +1022,5 @@
<translation id="4598945348959438653" key="MSG_LIMIT_RANGE_LIST_NAMESPACE_LABEL" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Limit range list header: namespace.">Namespace</translation>
<translation id="391138217811387226" key="MSG_LIMIT_RANGE_LIST_HEADER_AGE" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Limit range list header: age.">Age</translation>
<translation id="7449277386438313026" key="MSG_BREADCRUMBS_LIMIT_RANGES_LABEL" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="Label 'Limit Ranges' that appears as a breadcrumbs on the action bar.">Limit Ranges</translation>
<translation id="4427523950335685235" key="MSG_NAMESPACE_DETAIL_RESOURCE_LIMITS_TITLE" source="/home/urcan/wlm/dashboard/.tmp/serve/app-dev.js" desc="header name for the resource limits on the namespace details page.">Resource Limits</translation>
</translationbundle>
12 changes: 6 additions & 6 deletions src/app/backend/resource/namespace/namespacedetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type NamespaceDetail struct {
EventList common.EventList `json:"eventList"`

// ResourceLimits is list of limit ranges associated to the namespace
ResourceLimits []limitrange.LimitRangeItem `json:"limitRanges"`
ResourceLimits []limitrange.LimitRangeItem `json:"resourceLimits"`
}

// GetNamespaceDetail gets namespace details.
Expand Down Expand Up @@ -72,10 +72,10 @@ func GetNamespaceDetail(client k8sClient.Interface, heapsterClient client.Heapst
func toNamespaceDetail(namespace api.Namespace, events common.EventList, resourceLimits []limitrange.LimitRangeItem) NamespaceDetail {

return NamespaceDetail{
ObjectMeta: common.NewObjectMeta(namespace.ObjectMeta),
TypeMeta: common.NewTypeMeta(common.ResourceKindNamespace),
Phase: namespace.Status.Phase,
EventList: events,
ObjectMeta: common.NewObjectMeta(namespace.ObjectMeta),
TypeMeta: common.NewTypeMeta(common.ResourceKindNamespace),
Phase: namespace.Status.Phase,
EventList: events,
ResourceLimits: resourceLimits,
}
}
Expand All @@ -87,7 +87,7 @@ func getLimitRanges(client k8sClient.LimitRangesNamespacer, namespace api.Namesp
return nil, err
}

resourceLimits := make([]limitrange.LimitRangeItem,0)
resourceLimits := make([]limitrange.LimitRangeItem, 0)
for _, item := range list.Items {
list := limitrange.ToLimitRanges(&item)
resourceLimits = append(resourceLimits, list...)
Expand Down
3 changes: 2 additions & 1 deletion src/app/externs/backendapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,8 @@ backendApi.NamespaceList;
* objectMeta: !backendApi.ObjectMeta,
* typeMeta: !backendApi.TypeMeta,
* phase: string,
* eventList: !backendApi.EventList
* eventList: !backendApi.EventList,
* resourceLimits: Array<!backendApi.LimitRange>
* }}
*/
backendApi.NamespaceDetail;
Expand Down
4 changes: 2 additions & 2 deletions src/app/frontend/limitrangedetail/resourcelimits_component.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class ResourceLimitsController {
constructor() {
/**
* Resource Limits. Initialized from the scope.
* @export {!Object<string, Object<string, !backendApi.LimitRange>>}
* @export {Array<!backendApi.LimitRange>}
*/
this.resourceLimits;

Expand All @@ -40,7 +40,7 @@ export const resourceLimitsComponent = {
controller: ResourceLimitsController,
templateUrl: 'limitrangedetail/resourcelimits.html',
bindings: {
/** {!Array<!backendApi.LimitRange>} */
/** {Array<!backendApi.LimitRange>} */
'resourceLimits': '=',
},
};
Expand Down
6 changes: 6 additions & 0 deletions src/app/frontend/namespacedetail/namespacedetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
-->

<kd-namespace-info namespace="::ctrl.namespaceDetail"></kd-namespace-info>
<kd-content-card ng-if="ctrl.namespaceDetail.resourceLimits">
<kd-title>{{::ctrl.i18n.MSG_NAMESPACE_DETAIL_RESOURCE_LIMITS_TITLE}}</kd-title>
<kd-content>
<kd-resource-limits resource-limits="ctrl.namespaceDetail.resourceLimits"></kd-resource-limits>
</kd-content>
</kd-content-card>
<kd-event-card-list event-list="::ctrl.namespaceDetail.eventList"
event-list-resource="::ctrl.eventListResource">
</kd-event-card-list>
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@ export class NamespaceDetailController {

/** @export {!angular.Resource} */
this.eventListResource = kdNamespaceEventsResource;

/** @export */
this.i18n = i18n;
}
}

const i18n = {
/** @export {string} @desc header name for the resource limits on the namespace details page.*/
MSG_NAMESPACE_DETAIL_RESOURCE_LIMITS_TITLE: goog.getMsg('Resource Limits'),
};
1 change: 0 additions & 1 deletion src/app/frontend/namespacedetail/namespacedetail_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import eventsModule from 'events/events_module';
import stateConfig from './namespacedetail_stateconfig';
import {namespaceInfoComponent} from './namespaceinfo_component';


/**
* Angular module for the Namespace details view.
*
Expand Down
2 changes: 1 addition & 1 deletion src/test/backend/resource/namespace/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func TestGetNamespaceList(t *testing.T) {
cases := []struct {
namespaces []api.Namespace
expected *NamespaceList
expected *NamespaceList
}{
{nil, &NamespaceList{Namespaces: []Namespace{}}},
{
Expand Down
7 changes: 3 additions & 4 deletions src/test/backend/resource/namespace/namespacedetail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
func TestGetNamespaceDetail(t *testing.T) {
cases := []struct {
namespace api.Namespace
expected *NamespaceDetail
expected *NamespaceDetail
}{
{
api.Namespace{
Expand All @@ -37,13 +37,12 @@ func TestGetNamespaceDetail(t *testing.T) {
&NamespaceDetail{
TypeMeta: common.TypeMeta{Kind: "namespace"},
ObjectMeta: common.ObjectMeta{Name: "foo"},
Phase: api.NamespaceActive,

Phase: api.NamespaceActive,
},
},
}
for _, c := range cases {
actual := toNamespaceDetail(c.namespace, common.EventList{},nil)
actual := toNamespaceDetail(c.namespace, common.EventList{}, nil)
if !reflect.DeepEqual(&actual, c.expected) {
t.Errorf("toNamespaceDetail(%#v) == \n%#v\nexpected \n%#v\n",
c.namespace, actual, c.expected)
Expand Down

0 comments on commit 720bda0

Please sign in to comment.