Add detail view for container

This patch adds detail view for container into container panel.
Detail view is linked from container table view and other panel.

Partially Implements: blueprint container-detail-view

Change-Id: I3fe55e522f25c43f75e93c0e355ce14661ade41b
This commit is contained in:
shu-mutou 2015-11-19 19:28:44 +09:00
parent e6b5dfb165
commit d6a970b6e9
6 changed files with 195 additions and 6 deletions

View File

@ -14,5 +14,5 @@
{% endblock %}
{% block main %}
<ng-include src="'{{ STATIC_URL }}dashboard/containers/containers/table/table.html'"></ng-include>
<div ng-view></div>
{% endblock %}

View File

@ -12,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import patterns
from django.conf.urls import url
from magnum_ui.containers import views
from magnum_ui.containers.views import IndexView
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
]
urlpatterns = patterns(
'',
url(r'^[0-9a-f\-]{36}$', IndexView.as_view(), name='detail'),
url(r'^$', IndexView.as_view(), name='index'),
)

View File

@ -46,6 +46,12 @@
$provide.constant('horizon.dashboard.containers.basePath', path);
$routeProvider
.when('/containers', {
templateUrl: path + 'containers/table/table.html'
})
.when('/containers/:containerId', {
templateUrl: path + 'containers/detail/detail.html'
})
.when('/baymodel', {
templateUrl: path + 'baymodel/table/table.html'
})

View File

@ -0,0 +1,75 @@
/*
* Copyright 2015 NEC Corporation
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
"use strict";
angular
.module('horizon.dashboard.containers')
.controller('ContainerDetailController', ContainerDetailController);
ContainerDetailController.$inject = [
'$window',
'horizon.app.core.openstack-service-api.magnum',
'$routeParams'
];
function ContainerDetailController($window, magnum, $routeParams) {
var ctrl = this;
ctrl.container = {};
ctrl.bay = {};
ctrl.baymodel = {};
ctrl.memoryunits = { "b": gettext("bytes"),
"k": gettext("KB"),
"m": gettext("MB"),
"g": gettext("GB")};
var containerId = $routeParams.containerId;
init();
function init() {
// Load the elements that are used in the overview.
magnum.getContainer(containerId).success(onGetContainer);
}
function onGetContainer(container) {
ctrl.container = container;
magnum.getBay(ctrl.container.bay_uuid).success(onGetBay);
ctrl.container.memorysize = "";
ctrl.container.memoryunit = "";
if(ctrl.container.memory !== null){
// separate number and unit, then using gettext() to unit.
var regex = /(\d+)([bkmg]?)/;
var match = regex.exec(ctrl.container.memory);
ctrl.container.memorysize = match[1];
if(match[2]){
ctrl.container.memoryunit = ctrl.memoryunits[match[2]];
}
}
}
function onGetBay(bay) {
ctrl.bay = bay;
magnum.getBayModel(ctrl.bay.baymodel_id).success(onGetBayModel);
}
function onGetBayModel(baymodel) {
ctrl.baymodel = baymodel;
}
}
})();

View File

@ -0,0 +1,104 @@
<div class="content" ng-controller="ContainerDetailController as ctrl">
<div class="page-header">
<ol class="breadcrumb">
<li><a href="./containers" translate>Containers</a></li>
<li class="active">{$ ctrl.container.name $}</li>
</ol>
</div>
<tabset>
<tab heading="{$ 'Overview' | translate $}">
<div class="row">
<div class="col-md-6">
<h3 translate>Spec</h3>
<hr class="header-rule">
<dl class="dl-horizontal">
<div class="{$ propertyClasses $}">
<dt translate>Image</dt>
<dd>{$ ctrl.container.image $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Memory</dt>
<dd>{$ ctrl.container.memorysize $} {$ ctrl.container.memoryunit $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Command</dt>
<dd>{$ ctrl.container.command $}</dd>
</div>
</dl>
</div>
<div class="col-md-6">
<h3 translate>Bay</h3>
<hr class="header-rule">
<dl class="dl-horizontal">
<div class="{$ propertyClasses $}">
<dt translate>Name</dt>
<dd><a ng-href="{$ ctrl.bay.uuid $}">{$ ctrl.bay.name $}</a></dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>ID</dt>
<dd>{$ ctrl.bay.uuid $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Status</dt>
<dd>{$ ctrl.bay.status $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Master Count</dt>
<dd>{$ ctrl.bay.master_count $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Node Count</dt>
<dd>{$ ctrl.bay.node_count $}</dd>
</div>
</dl>
</div>
</div>
<div class="row">
<div class="col-md-6">
<h3 translate>Bay Model</h3>
<hr class="header-rule">
<dl class="dl-horizontal">
<div class="{$ propertyClasses $}">
<dt translate>Name</dt>
<dd><a ng-href="baymodel/{$ ctrl.baymodel.uuid $}">{$ ctrl.baymodel.name $}</a></dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>ID</dt>
<dd>{$ ctrl.baymodel.uuid $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>COE</dt>
<dd>{$ ctrl.baymodel.coe $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Image ID</dt>
<dd>{$ ctrl.baymodel.image_id $}</dd>
</div>
</dl>
</div>
<div class="col-md-6">
<h3 translate>Record Properties</h3>
<hr class="header-rule">
<dl class="dl-horizontal">
<div class="{$ propertyClasses $}">
<dt translate>Created</dt>
<dd>{$ ctrl.container.created_at | date:'short' $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Updated</dt>
<dd>{$ ctrl.container.updated_at | date:'short' $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>ID</dt>
<dd>{$ ctrl.container.uuid $}</dd>
</div>
<div class="{$ propertyClasses $}">
<dt translate>Status</dt>
<dd>{$ ctrl.container.status $}</dd>
</div>
</dl>
</div>
</div>
</tab>
</tabset>
</div>

View File

@ -141,7 +141,7 @@
<dl class=dl-horizontal>
<dt><translate>Name</translate></dt>
<dd>{$ c.name $}</dd>
<dd><a ng-href="containers/{$ c.id $}">{$ c.name $}</a></dd>
<dt><translate>UUID</translate></dt>
<dd>{$ c.id $}</dd>