Host view uses /view endpoint
This commit is contained in:
parent
c23de1cc45
commit
5e974cb532
@ -112,7 +112,7 @@ module.exports = function (grunt) {
|
||||
'<%= project.app %>/routing_view/routing_view.js',
|
||||
'<%= project.app %>/templates/dashboard/dashboard.js',
|
||||
'<%= project.app %>/templates/single_table/single_table.js',
|
||||
'<%= project.app %>/object_view/object_view.js'
|
||||
'<%= project.app %>/templates/host/host.js',
|
||||
]
|
||||
}],
|
||||
options: {
|
||||
@ -147,7 +147,7 @@ module.exports = function (grunt) {
|
||||
'<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js',
|
||||
'<%= project.build %>/templates/dashboard/dashboard.js': '<%= project.app %>/templates/dashboard/dashboard.js',
|
||||
'<%= project.build %>/templates/single_table/single_table.js' : '<%= project.app %>/templates/single_table/single_table.js',
|
||||
'<%= project.build %>/object_view/object_view.js' : '<%= project.app %>/object_view/object_view.js'
|
||||
'<%= project.build %>/templates/host/host.js' : '<%= project.app %>/templates/host/host.js',
|
||||
},
|
||||
{
|
||||
'<%= project.build %>/js/adagios.min.js' : [
|
||||
@ -176,7 +176,7 @@ module.exports = function (grunt) {
|
||||
'<%= project.build %>/routing_view/routing_view.js',
|
||||
'<%= project.build %>/templates/dashboard/dashboard.js',
|
||||
'<%= project.build %>/templates/single_table/single_table.js',
|
||||
'<%= project.build %>/object_view/object_view.js'
|
||||
'<%= project.build %>/templates/host/host.js',
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -18,10 +18,10 @@ angular.module('adagios', [
|
||||
'adagios.sidebar',
|
||||
'adagios.topbar',
|
||||
'adagios.config',
|
||||
'adagios.view',
|
||||
'adagios.view.dashboard',
|
||||
'adagios.view.singleTable',
|
||||
'adagios.view.object_view',
|
||||
'adagios.view'
|
||||
'adagios.view.host'
|
||||
])
|
||||
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
|
@ -205,5 +205,10 @@
|
||||
"noRepeatCell" : "host"
|
||||
}
|
||||
}]
|
||||
},
|
||||
"host": {
|
||||
"title": "Host",
|
||||
"refreshInterval": 0,
|
||||
"template": "host"
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ angular.module('adagios.live')
|
||||
});
|
||||
}])
|
||||
|
||||
.factory('getObjectId', ['$http', function ($http) {
|
||||
.service('getObjectId', ['$http', function ($http) {
|
||||
return function (objectType, objectIdentifier) {
|
||||
|
||||
var postString, req;
|
||||
@ -138,7 +138,7 @@ angular.module('adagios.live')
|
||||
};
|
||||
}])
|
||||
|
||||
.factory('getObjectById', ['$http', function ($http) {
|
||||
.service('getObjectById', ['$http', function ($http) {
|
||||
return function (objectId) {
|
||||
|
||||
var postString, req;
|
||||
@ -160,4 +160,51 @@ angular.module('adagios.live')
|
||||
throw new Error('getHostById : POST Request failed');
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
// Add object of specified type to $scope.data
|
||||
.service('addObjectToScope', ['$http', 'getObjectId', 'getObjectById', function ($http, getObjectId, getObjectById) {
|
||||
return function (objectType, objectIdentifier, scope) {
|
||||
var objectData = {},
|
||||
url = "/rest/status/json/",
|
||||
firstParameter = true,
|
||||
endpoints = {
|
||||
"host" : "hosts",
|
||||
"service" : "services"
|
||||
};
|
||||
|
||||
if (objectType === "host") {
|
||||
objectIdentifier.host_name = objectIdentifier.host_name;
|
||||
} else if (objectType === "service") {
|
||||
objectIdentifier.host_name = objectIdentifier.host_name;
|
||||
objectIdentifier.description = objectIdentifier.description;
|
||||
}
|
||||
|
||||
url += endpoints[objectType];
|
||||
url += "/?";
|
||||
|
||||
angular.forEach(objectIdentifier, function (value, key){
|
||||
if(!firstParameter){
|
||||
url += "&";
|
||||
}
|
||||
url += key + "=" + value;
|
||||
firstParameter = false;
|
||||
|
||||
});
|
||||
|
||||
$http.get(url)
|
||||
.success(function (data) {
|
||||
objectData.live = data[0];
|
||||
getObjectId(objectType, objectIdentifier)
|
||||
.success(function (data) {
|
||||
var objectId = data[0].id;
|
||||
scope.data.id = objectId;
|
||||
getObjectById(objectId)
|
||||
.success(function (data) {
|
||||
objectData.config = data;
|
||||
scope.data = objectData;
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
@ -1,3 +1,3 @@
|
||||
<td class="data-table__host {{entry[cell_name + '_additionnalClass']}} {{state}}" ng-controller="CellHostCtrl">
|
||||
<a class="data-table__data" href="#/object_view?object_type=host&host_name={{entry.host_name}}">{{entry.host_name}}</a>
|
||||
<a class="data-table__data" href="#/view?view=host&host_name={{entry.host_name}}">{{entry.host_name}}</a>
|
||||
</td>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<td class="data-table__hosts_host {{state}}" ng-controller="CellHostsHostCtrl">
|
||||
<a class="data-table__data" href="#/object_view?object_type=host&host_name={{entry.name}}">{{entry.name}}</a>
|
||||
<a class="data-table__data" href="#/view?view=host&host_name={{entry.name}}">{{entry.name}}</a>
|
||||
</td>
|
||||
|
@ -1,74 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('adagios.view.object_view', ['ngRoute',
|
||||
'adagios.live'
|
||||
])
|
||||
|
||||
.config(['$routeProvider', function ($routeProvider) {
|
||||
$routeProvider.when('/object_view', {
|
||||
templateUrl: 'object_view/object_view.html',
|
||||
controller: 'ObjectViewCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('ObjectViewCtrl', ['$http', '$scope', '$routeParams', 'getObjectId', 'getObjectById',
|
||||
function ($http, $scope, $routeParams, getObjectId, getObjectById) {
|
||||
|
||||
var objectIdentifier = {},
|
||||
objectType = $routeParams.object_type,
|
||||
endpoints = {
|
||||
"host" : "hosts",
|
||||
"service" : "services"
|
||||
};
|
||||
|
||||
var getIdentifier = function () {
|
||||
if (objectType === "host") {
|
||||
objectIdentifier.host_name = $routeParams.host_name;
|
||||
} else if (objectType === "service") {
|
||||
objectIdentifier.host_name = $routeParams.host_name;
|
||||
objectIdentifier.description = $routeParams.description;
|
||||
} else {
|
||||
throw new Error("ERROR : 'view' GET parameter must be the host");
|
||||
}
|
||||
};
|
||||
|
||||
$scope.data = {};
|
||||
|
||||
var getData = function () {
|
||||
|
||||
var objectData = {},
|
||||
url = "/rest/status/json/",
|
||||
firstParameter = true;
|
||||
|
||||
url += endpoints[objectType];
|
||||
url += "/?";
|
||||
angular.forEach(objectIdentifier, function (value, key){
|
||||
if(!firstParameter){
|
||||
url += "&";
|
||||
}
|
||||
url += key + "=" + objectIdentifier[key];
|
||||
firstParameter = false;
|
||||
|
||||
});
|
||||
|
||||
$http.get(url)
|
||||
.success(function (data) {
|
||||
objectData.live = data[0];
|
||||
getObjectId(objectType, objectIdentifier)
|
||||
.success(function (data) {
|
||||
var objectId = data[0].id;
|
||||
$scope.data.id = objectId;
|
||||
getObjectById(objectId)
|
||||
.success(function (data) {
|
||||
objectData.config = data;
|
||||
$scope.data = objectData;
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
getIdentifier();
|
||||
getData(objectIdentifier);
|
||||
|
||||
}]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<article>
|
||||
<article ng-controller="HostViewCtrl">
|
||||
<section class="main__content tabpanel">
|
||||
<h2 class="main__overview__title">{{hostName}}</h2>
|
||||
<table class="data-table">
|
20
app/templates/host/host.js
Normal file
20
app/templates/host/host.js
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
angular.module('adagios.view.host', ['adagios.live'])
|
||||
|
||||
.controller('HostViewCtrl', ['$http', '$scope', '$routeParams', 'getObjectId', 'getObjectById', 'addObjectToScope',
|
||||
function ($http, $scope, $routeParams, getObjectId, getObjectById, addObjectToScope) {
|
||||
|
||||
var objectIdentifier = {},
|
||||
objectType = 'host';
|
||||
|
||||
if (!!$routeParams.host_name) {
|
||||
objectIdentifier.host_name = $routeParams.host_name;
|
||||
} else {
|
||||
throw new Error("ERROR :'host_name' GET parameter must be set");
|
||||
}
|
||||
|
||||
$scope.data = {};
|
||||
addObjectToScope(objectType, objectIdentifier, $scope);
|
||||
}]);
|
Loading…
x
Reference in New Issue
Block a user