|
|
|
@ -1,12 +1,57 @@
|
|
|
|
|
angular.module('swarmVisualizer', [])
|
|
|
|
|
.controller('SwarmVisualizerController', ['$q', '$scope', '$document', 'NodeService', 'ServiceService', 'TaskService', 'Notifications',
|
|
|
|
|
function ($q, $scope, $document, NodeService, ServiceService, TaskService, Notifications) {
|
|
|
|
|
.controller('SwarmVisualizerController', ['$q', '$scope', '$document', '$interval', 'NodeService', 'ServiceService', 'TaskService', 'Notifications',
|
|
|
|
|
function ($q, $scope, $document, $interval, NodeService, ServiceService, TaskService, Notifications) {
|
|
|
|
|
|
|
|
|
|
$scope.state = {
|
|
|
|
|
ShowInformationPanel: true,
|
|
|
|
|
DisplayOnlyRunningTasks: false
|
|
|
|
|
DisplayOnlyRunningTasks: false,
|
|
|
|
|
refreshRate: '5'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.$on('$destroy', function() {
|
|
|
|
|
stopRepeater();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$scope.changeUpdateRepeater = function() {
|
|
|
|
|
stopRepeater();
|
|
|
|
|
setUpdateRepeater();
|
|
|
|
|
$('#refreshRateChange').show();
|
|
|
|
|
$('#refreshRateChange').fadeOut(1500);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function stopRepeater() {
|
|
|
|
|
var repeater = $scope.repeater;
|
|
|
|
|
if (angular.isDefined(repeater)) {
|
|
|
|
|
$interval.cancel(repeater);
|
|
|
|
|
repeater = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setUpdateRepeater() {
|
|
|
|
|
var refreshRate = $scope.state.refreshRate;
|
|
|
|
|
$scope.repeater = $interval(function() {
|
|
|
|
|
$q.all({
|
|
|
|
|
nodes: NodeService.nodes(),
|
|
|
|
|
services: ServiceService.services(),
|
|
|
|
|
tasks: TaskService.tasks()
|
|
|
|
|
})
|
|
|
|
|
.then(function success(data) {
|
|
|
|
|
var nodes = data.nodes;
|
|
|
|
|
$scope.nodes = nodes;
|
|
|
|
|
var services = data.services;
|
|
|
|
|
$scope.services = services;
|
|
|
|
|
var tasks = data.tasks;
|
|
|
|
|
$scope.tasks = tasks;
|
|
|
|
|
prepareVisualizerData(nodes, services, tasks);
|
|
|
|
|
})
|
|
|
|
|
.catch(function error(err) {
|
|
|
|
|
stopRepeater();
|
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve cluster information');
|
|
|
|
|
});
|
|
|
|
|
}, refreshRate * 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function assignServiceName(services, tasks) {
|
|
|
|
|
for (var i = 0; i < services.length; i++) {
|
|
|
|
|
var service = services[i];
|
|
|
|
@ -60,6 +105,7 @@ function ($q, $scope, $document, NodeService, ServiceService, TaskService, Notif
|
|
|
|
|
var tasks = data.tasks;
|
|
|
|
|
$scope.tasks = tasks;
|
|
|
|
|
prepareVisualizerData(nodes, services, tasks);
|
|
|
|
|
setUpdateRepeater();
|
|
|
|
|
})
|
|
|
|
|
.catch(function error(err) {
|
|
|
|
|
Notifications.error('Failure', err, 'Unable to initialize cluster visualizer');
|
|
|
|
|