diff --git a/Gruntfile.js b/Gruntfile.js index 0ce1a93..e989bff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -56,6 +56,7 @@ module.exports = function (grunt) { unparam: true, // TEMPORARY: Ignore unused params nomen: true, predef: [ // Global variables + 'document', '$', '$get', 'angular', 'inject', 'JustGage', 'describe', 'beforeEach', 'it', 'expect', 'moment' diff --git a/app/app.js b/app/app.js index 6271c4e..53c8332 100644 --- a/app/app.js +++ b/app/app.js @@ -1,12 +1,28 @@ 'use strict'; +angular.element(document).ready(function () { + + $.get('components/config/config.json', function (data) { + + angular.module('adagios.config').config(['readConfigProvider', function (readConfigProvider) { + readConfigProvider.setDashboardConfig(data.dashboardConfig); + readConfigProvider.setHostsConfig(data.hostsConfig); + }]); + + angular.bootstrap(document, ['adagios']); + }, "json"); + +}); + angular.module('adagios', [ 'ngRoute', 'adagios.sidebar', 'adagios.topbar', 'adagios.tactical', 'adagios.table', - 'adagios.filters' + 'adagios.filters', + 'adagios.config', + 'adagios.view.hosts' ]) .config(['$routeProvider', function ($routeProvider) { diff --git a/app/assets/sass/app.scss b/app/assets/sass/app.scss index 71aa6a3..90c89d2 100644 --- a/app/assets/sass/app.scss +++ b/app/assets/sass/app.scss @@ -57,9 +57,9 @@ $fa-font-path: '../../bower_components/fontawesome/fonts' !default; //----------------------------------*\ // INTERFACE MODULES //----------------------------------*/ -@import '../../topbar/topbar'; -@import '../../sidebar/sidebar'; -@import '../../tactical/tactical'; +@import '../../components/topbar/topbar'; +@import '../../components/sidebar/sidebar'; +@import '../../components/tactical/tactical'; /* body:before { */ /* display:none; */ diff --git a/app/components/config/config.js b/app/components/config/config.js new file mode 100644 index 0000000..b5a753f --- /dev/null +++ b/app/components/config/config.js @@ -0,0 +1,27 @@ +'use strict'; + + +function AdagiosConfig(dashboardConfig, hostsConfig) { + this.dashboardConfig = dashboardConfig; + this.hostsConfig = hostsConfig; +} + +angular.module('adagios.config', []) + + .provider('readConfig', function ReadConfigProvider() { + + var dashboardConfig = {}, + hostsConfig = {}; + + this.setDashboardConfig = function (value) { + dashboardConfig = value; + }; + + this.setHostsConfig = function (value) { + hostsConfig = value; + }; + + this.$get = [function getConfigFactory() { + return new AdagiosConfig(dashboardConfig, hostsConfig); + }]; + }); diff --git a/app/components/config/config.json b/app/components/config/config.json new file mode 100644 index 0000000..54aa364 --- /dev/null +++ b/app/components/config/config.json @@ -0,0 +1,12 @@ +{ + "dashboardConfig": { + "cells": ["host", "service_check", "duration", "last_check"], + "apiName": "services", + "filters": { "isnot": { "host_state": ["0"]} } + }, + "hostsConfig": { + "cells": ["hosts_host", "host_address", "duration", "last_check", "host_status"], + "apiName": "hosts", + "filters": {} + } +} diff --git a/app/components/live/get_services.js b/app/components/live/get_services.js index 95d1941..3375a8d 100644 --- a/app/components/live/get_services.js +++ b/app/components/live/get_services.js @@ -8,12 +8,13 @@ angular.module('adagios.live') endswith: '__endswith', exists: '__exists', in: '__in', + isnot: '__isnot', regex: '__regex' }) .factory('getServices', ['$http', 'filterSuffixes', - function ($http, filterSuffixes, columns, filters) { - return function (columns, filters) { + function ($http, filterSuffixes, columns, filters, apiName) { + return function (columns, filters, apiName) { var filtersQuery = ''; function createFiltersQuery(filters) { @@ -34,7 +35,7 @@ angular.module('adagios.live') filtersQuery = createFiltersQuery(filters); - return $http.get('/rest/status/json/services/?fields=' + columns + filtersQuery) + return $http.get('/rest/status/json/' + apiName + '/?fields=' + columns + filtersQuery) .error(function (data, status, headers, config) { console.error('getServices : GET Request failed'); }); diff --git a/app/components/live/get_services_test.js b/app/components/live/get_services_test.js index ce557e5..fefb0be 100644 --- a/app/components/live/get_services_test.js +++ b/app/components/live/get_services_test.js @@ -14,9 +14,10 @@ describe('In Adagios Live', function () { it('should send the proper GET request', inject(function (getServices) { var fields = ['host_name', 'host_state', 'description'], filters = { contains: { host_name: ['srv', 'a'], plugin_output: ['SWAP'] }, - startswith: { host_name: ['srv'] } }; + startswith: { host_name: ['srv'] } }, + apiName = 'services'; - getServices(fields, filters); + getServices(fields, filters, apiName); $httpBackend.expectGET('/rest/status/json/services/?fields=host_name,host_state,description&host_name__contains=srv&host_name__contains=a&plugin_output__contains=SWAP&host_name__startswith=srv').respond(''); $httpBackend.flush(); })); diff --git a/app/sidebar/_sidebar.scss b/app/components/sidebar/_sidebar.scss similarity index 100% rename from app/sidebar/_sidebar.scss rename to app/components/sidebar/_sidebar.scss diff --git a/app/sidebar/sidebar.html b/app/components/sidebar/sidebar.html similarity index 96% rename from app/sidebar/sidebar.html rename to app/components/sidebar/sidebar.html index 5522d50..c397797 100644 --- a/app/sidebar/sidebar.html +++ b/app/components/sidebar/sidebar.html @@ -6,7 +6,7 @@