Refactoring info panel

Change-Id: Ifa94fb885714b7ab051d2e3089fe564f70eab072
This commit is contained in:
flavien peyre 2015-08-13 16:10:14 -04:00 committed by Vincent Fournier
parent 90957f83e9
commit 6b94e92be3
10 changed files with 56 additions and 59 deletions

View File

@ -10,7 +10,7 @@
"type": "tabpanel",
"attributes": {
"navigation": {
"openProblems" : {
"openProblems": {
"title": "Open problems",
"provider": "nbServicesHostsOpenProblems"
},
@ -639,12 +639,16 @@
"attributes": {}
},
{
"type": "host-info",
"type": "host-services-list",
"attributes": {}
},
{
"type": "host-services-list",
"attributes": {}
"type": "info",
"attributes": {
"datamodel": {
"Configuration": "configHost"
}
}
}
]
}

View File

@ -4,6 +4,7 @@ angular.module('bansho.directive', [
'bansho.actionbar',
'bansho.host',
'bansho.hostTree',
'bansho.info',
'bansho.service',
'bansho.table',
'bansho.tabpanel',

View File

@ -9,13 +9,19 @@ angular.module('bansho.host', ['bansho.datasource'])
options: '='
},
templateUrl: 'components/directive/host/host.html',
controller: ['$scope', 'templateManager', 'surveilStatus', 'iframeUrl',
function ($scope, templateManager, surveilStatus, iframeUrl) {
controller: ['$scope', 'templateManager', 'surveilStatus', 'surveilConfig', 'iframeUrl',
function ($scope, templateManager, surveilStatus, surveilConfig, iframeUrl) {
var hostname = templateManager.getPageParam('hostname');
$scope.param = {
host: {}
host: {},
configHost: {}
};
surveilConfig.getHost(hostname).then(function (data) {
$scope.param.configHost = data[0];
});
surveilStatus.getHost(hostname).then(function (data) {
surveilStatus.getService(hostname).then(function(services) {
$scope.param.host = data[0];
@ -43,8 +49,6 @@ angular.module('bansho.host', ['bansho.datasource'])
});
});
$scope.components = $scope.options.components;
}]
};

View File

@ -1,35 +0,0 @@
<div class="subcomponent__live">
<h2>Info</h2>
<table class="data-table">
<tbody>
<tr>
<td>Last check</td>
<td>{{param.host.host_last_check | timeElapsed}}</td>
</tr>
<tr>
<td>Check period</td>
<td>{{param.host.config_host_check_period}}</td>
</tr>
<tr>
<td>Notification period</td>
<td>{{param.host.config_host_notification_period}}</td>
</tr>
<tr>
<td>Active checks</td>
<td>{{param.host.config_host_active_checks}}</td>
</tr>
<tr>
<td>Notifications</td>
<td>{{param.host.config_host_notifications_enabled}}</td>
</tr>
<tr>
<td>Event Handler</td>
<td>{{param.host.config_host_event_handler_enabled}}</td>
</tr>
<tr>
<td>Flap detection</td>
<td>{{param.host.config_host_flap_detection_enabled}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,12 +0,0 @@
'use strict';
angular.module('bansho.host')
.directive('banshoHostInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/directive/host/host_info/host_info.html',
link: function (scope) {
scope.param = scope.$parent.param;
}
};
});

View File

@ -0,0 +1,11 @@
<div class="subcomponent__live" data-ng-repeat="(key, datamodel) in datamodels">
<h2>{{key}}</h2>
<table class="data-table" >
<tbody data-ng-repeat="(key, value) in param[datamodel]">
<tr>
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,17 @@
'use strict';
angular.module('bansho.info', [])
.directive('banshoInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/directive/info/info.html',
link: function (scope) {
scope.param = scope.$parent.param;
angular.forEach(scope.components, function(component) {
if (component.type === 'info') {
scope.datamodels = component.attributes.datamodel;
}
});
}
};
});

View File

@ -50,6 +50,14 @@ angular.module('bansho.surveil')
return {
getData: getData
getData: getData,
getHost: function (hostname) {
var promise = $q.defer(), query = {"hosts": {"is": {"host_name": [ hostname ] } } };
getData([], query, "hosts")
.then(function (data) {
promise.resolve(data);
});
return promise.promise;
},
};
}]);

View File

@ -79,6 +79,7 @@
<script src="components/directive/actionbar/component_more/more.js"></script>
<script src="components/directive/actionbar/component_recheck/recheck.js"></script>
<script src="components/directive/actionbar/component_search_filter/search_filter.js"></script>
<script src="components/directive/info/info.js"></script>
<script src="components/directive/table/table.js"></script>
<script src="components/directive/table/pagingbar/pagingbar.js"></script>
<script src="components/directive/table/cell_status_duration/cell_status_duration.js"></script>
@ -106,7 +107,6 @@
<script src="components/directive/host/host.js"></script>
<script src="components/directive/host/host_cpu/host_cpu.js"></script>
<script src="components/directive/host/host_info/host_info.js"></script>
<script src="components/directive/host/host_load/host_load.js"></script>
<script src="components/directive/host/host_main/host_main.js"></script>
<script src="components/directive/host/host_live/host_live.js"></script>

View File

@ -7,7 +7,6 @@ angular.module('bansho.view.host', ['bansho.datasource'])
var hostname = $routeParams.host_name;
$scope.components = configManager.getConfigData($scope.viewName).components;
if (!hostname) {
throw new Error("ERROR :'host_name' GET parameter must be set");
} else {