bansho/app/components/service/service.js
Thibault Cohen 9f483b442a Add css on service status page and add light theme
Change-Id: Iaa6af5b5aafb97a058ab03ae3e02c653252e68c5
2015-06-02 09:19:13 -04:00

50 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
angular.module('bansho.service', ['bansho.surveil',
'bansho.service.main',
'bansho.service.live',
'bansho.service.info',
'bansho.service.metrics',
'bansho.table.state_icon'])
.value('serviceConfig', {})
.controller('ServiceCtrl', ['$scope', 'serviceConfig', 'surveilStatus',
function ($scope, serviceConfig, surveilStatus) {
var hostName = serviceConfig.hostName,
description = serviceConfig.description;
surveilStatus.getService(hostName, description).success(function (data) {
$scope.service = data[0];
});
}])
.directive('banshoService', ['$http', '$compile', 'serviceConfig',
function ($http, $compile, serviceConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/service/service.html';
if (!attrs.hostName && !!attrs.description) {
throw new Error('<bansho-service> "host-name" and "description" attributes must be defined');
}
serviceConfig.hostName = '';
serviceConfig.hostName = attrs.hostName;
serviceConfig.description = '';
serviceConfig.description = attrs.description;
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}]);