Group redis services and have them collapsed
This commit is contained in:
@@ -10,6 +10,8 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
$scope.config = Client.getConfig();
|
||||
$scope.servicesReady = false;
|
||||
$scope.services = [];
|
||||
$scope.hasRedisServices = false;
|
||||
$scope.redisServicesExpanded = false;
|
||||
$scope.memory = null;
|
||||
|
||||
// http://stackoverflow.com/questions/1484506/random-color-generator-in-javascript
|
||||
@@ -36,7 +38,7 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
if (error) return console.log('Error getting status of ' + serviceName + ':' + error.message);
|
||||
|
||||
var service = $scope.services.find(function (s) { return s.name === serviceName; });
|
||||
if (!service) $scope.services.push(result);
|
||||
if (!service) $scope.services.find(function (s) { return s.name === serviceName; });
|
||||
|
||||
service.status = result.status;
|
||||
service.config = result.config;
|
||||
@@ -269,12 +271,27 @@ angular.module('Application').controller('SystemController', ['$scope', '$locati
|
||||
Client.getServices(function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.services = result.map(function (serviceName) { return { name: serviceName }; });
|
||||
$scope.services = result.map(function (name) {
|
||||
var displayName = name;
|
||||
var isRedis = false;
|
||||
|
||||
if (name.indexOf('redis') === 0) {
|
||||
isRedis = true;
|
||||
var app = Client.getCachedAppSync(name.slice('redis:'.length));
|
||||
displayName = 'redis for ';
|
||||
if (app) displayName += app.label || app.location || app.fqdn;
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
displayName: displayName,
|
||||
isRedis: isRedis
|
||||
};
|
||||
});
|
||||
$scope.hasRedisServices = !!$scope.services.find(function (service) { return service.isRedis; });
|
||||
|
||||
// just kick off the status fetching
|
||||
$scope.services.forEach(function (s) {
|
||||
refresh(s.name);
|
||||
});
|
||||
$scope.services.forEach(function (s) { refresh(s.name); });
|
||||
|
||||
$scope.servicesReady = true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user