Commit 22988fd0 by Johannes Edmeier

Make the ui work with hateoas-style endpoints

But make no use of it. fixes #96
parent cbf5b2e8
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
module.exports = function ($scope, application) { module.exports = function ($scope, application) {
$scope.application = application; $scope.application = application;
application.getActiviti() application.getActiviti()
.success(function (activiti){ .then(function (activiti){
$scope.summary = []; $scope.summary = [];
$scope.summary.push({ $scope.summary.push({
key: 'Completed Task Count Today', key: 'Completed Task Count Today',
...@@ -56,7 +56,7 @@ module.exports = function ($scope, application) { ...@@ -56,7 +56,7 @@ module.exports = function ($scope, application) {
}); });
} }
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
module.exports = function ($scope, application) { module.exports = function ($scope, application) {
$scope.application = application; $scope.application = application;
application.getEnv() application.getEnv()
.success(function (env) { .then(function (env) {
var separator = env.systemProperties['path.separator']; var separator = env.systemProperties['path.separator'];
$scope.classpath = env.systemProperties['java.class.path'].split(separator); $scope.classpath = env.systemProperties['java.class.path'].split(separator);
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
...@@ -23,7 +23,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) { ...@@ -23,7 +23,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) {
$scope.showRichGauges = false; $scope.showRichGauges = false;
application.getMetrics() application.getMetrics()
.success(function (metrics) { .then(function (metrics) {
function merge(array, obj) { function merge(array, obj) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
if (array[i].name === obj.name) { if (array[i].name === obj.name) {
...@@ -77,7 +77,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) { ...@@ -77,7 +77,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) {
]); ]);
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
...@@ -24,18 +24,18 @@ module.exports = function ($scope, $interval, application, MetricsHelper) { ...@@ -24,18 +24,18 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
}, 1000); }, 1000);
application.getInfo() application.getInfo()
.success(function (info) { .then(function (info) {
$scope.info = info; $scope.info = info;
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
application.getHealth() application.getHealth()
.success(function (health) { .then(function (health) {
$scope.health = health; $scope.health = health;
}) })
.error(function (health) { .catch(function (health) {
$scope.health = health; $scope.health = health;
}); });
...@@ -48,7 +48,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) { ...@@ -48,7 +48,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
}; };
application.getMetrics() application.getMetrics()
.success(function (metrics) { .then(function (metrics) {
$scope.metrics = metrics; $scope.metrics = metrics;
$scope.metrics['mem.used'] = $scope.metrics.mem - $scope.metrics['mem.free']; $scope.metrics['mem.used'] = $scope.metrics.mem - $scope.metrics['mem.free'];
...@@ -105,7 +105,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) { ...@@ -105,7 +105,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
} }
]); ]);
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
...@@ -48,12 +48,12 @@ module.exports = function ($scope, application) { ...@@ -48,12 +48,12 @@ module.exports = function ($scope, application) {
$scope.allKeys = []; $scope.allKeys = [];
application.getEnv() application.getEnv()
.success(function (env) { .then(function (env) {
$scope.env = env; $scope.env = env;
$scope.envArray = toArray(env); $scope.envArray = toArray(env);
$scope.allKeys = collectKeys($scope.envArray); $scope.allKeys = collectKeys($scope.envArray);
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
...@@ -62,7 +62,7 @@ module.exports = function ($scope, application) { ...@@ -62,7 +62,7 @@ module.exports = function ($scope, application) {
var getValue = function(item) { var getValue = function(item) {
if (item.key && $scope.allKeys.indexOf(item.key) >= 0) { if (item.key && $scope.allKeys.indexOf(item.key) >= 0) {
application.getEnv(item.key).success(function(value) { application.getEnv(item.key).then(function(value) {
item.value = value; item.value = value;
}); });
} }
...@@ -85,11 +85,11 @@ module.exports = function ($scope, application) { ...@@ -85,11 +85,11 @@ module.exports = function ($scope, application) {
} }
$scope.overrides.error = null; $scope.overrides.error = null;
application.setEnv(map).success(function () { application.setEnv(map).then(function () {
$scope.overrides = { values: [{key: '', value: '' }], error: null, changes: null}; $scope.overrides = { values: [{key: '', value: '' }], error: null, changes: null};
$scope.reload(); $scope.reload();
}) })
.error(function (error) { .catch(function (error) {
$scope.overrides.error = error; $scope.overrides.error = error;
$scope.overrides.changes = null; $scope.overrides.changes = null;
$scope.reload(); $scope.reload();
...@@ -99,10 +99,10 @@ module.exports = function ($scope, application) { ...@@ -99,10 +99,10 @@ module.exports = function ($scope, application) {
$scope.reset = function() { $scope.reset = function() {
$scope.overrides.error = null; $scope.overrides.error = null;
$scope.overrides.changes = null; $scope.overrides.changes = null;
application.resetEnv().success(function () { application.resetEnv().then(function () {
$scope.reload(); $scope.reload();
}) })
.error(function (error) { .catch(function (error) {
$scope.overrides.error = error; $scope.overrides.error = error;
$scope.reload(); $scope.reload();
}); });
...@@ -112,11 +112,11 @@ module.exports = function ($scope, application) { ...@@ -112,11 +112,11 @@ module.exports = function ($scope, application) {
$scope.refresh = function() { $scope.refresh = function() {
$scope.overrides.error = null; $scope.overrides.error = null;
$scope.overrides.changes = null; $scope.overrides.changes = null;
application.refresh().success(function (changes) { application.refresh().then(function (changes) {
$scope.overrides.changes = changes; $scope.overrides.changes = changes;
$scope.reload(); $scope.reload();
}) })
.error(function (error) { .catch(function (error) {
$scope.overrides.error = error; $scope.overrides.error = error;
$scope.reload(); $scope.reload();
}); });
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
module.exports = function ($scope, application) { module.exports = function ($scope, application) {
$scope.dumpThreads = function () { $scope.dumpThreads = function () {
application.getThreadDump() application.getThreadDump()
.success(function (dump) { .then(function (dump) {
$scope.dump = dump; $scope.dump = dump;
var threadStats = { var threadStats = {
...@@ -35,7 +35,7 @@ module.exports = function ($scope, application) { ...@@ -35,7 +35,7 @@ module.exports = function ($scope, application) {
threadStats.total = dump.length; threadStats.total = dump.length;
$scope.threadStats = threadStats; $scope.threadStats = threadStats;
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
......
...@@ -23,7 +23,7 @@ module.exports = function ($scope, application, $interval) { ...@@ -23,7 +23,7 @@ module.exports = function ($scope, application, $interval) {
$scope.refresh = function () { $scope.refresh = function () {
application.getTraces() application.getTraces()
.success(function (traces) { .then(function (traces) {
for (var i = 0; i < traces.length; i++) { for (var i = 0; i < traces.length; i++) {
if (traces[i].timestamp > $scope.lastTraceTime) { if (traces[i].timestamp > $scope.lastTraceTime) {
$scope.traces.push(traces[i]); $scope.traces.push(traces[i]);
...@@ -34,7 +34,7 @@ module.exports = function ($scope, application, $interval) { ...@@ -34,7 +34,7 @@ module.exports = function ($scope, application, $interval) {
} }
}) })
.error(function (error) { .catch(function (error) {
$scope.error = error; $scope.error = error;
}); });
}; };
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
'use strict'; 'use strict';
module.exports = function ($scope, $location, $interval, $q, $state, $filter, Application, Notification) { module.exports = function ($scope, $location, $interval, $state, $filter, Application, Notification) {
var createNote = function(app) { var createNote = function(app) {
var title = app.name + (app.statusInfo.status === 'UP' ? ' is back ' : ' went ') + app.statusInfo.status; var title = app.name + (app.statusInfo.status === 'UP' ? ' is back ' : ' went ') + app.statusInfo.status;
var options = { tag: app.id, var options = { tag: app.id,
...@@ -45,7 +45,7 @@ module.exports = function ($scope, $location, $interval, $q, $state, $filter, Ap ...@@ -45,7 +45,7 @@ module.exports = function ($scope, $location, $interval, $q, $state, $filter, Ap
break; break;
} }
} }
app.getInfo().success(function(info) { app.getInfo().then(function(info) {
app.version = info.version; app.version = info.version;
app.infoDetails = null; app.infoDetails = null;
app.infoShort = ''; app.infoShort = '';
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
'use strict'; 'use strict';
var angular = require('angular'); var angular = require('angular');
module.exports = function ($resource, $http) { module.exports = function ($resource, $http, $q) {
var isEndpointPresent = function(endpoint, configprops) { var isEndpointPresent = function(endpoint, configprops) {
if (configprops[endpoint]) { if (configprops[endpoint]) {
...@@ -62,44 +62,61 @@ module.exports = function ($resource, $http) { ...@@ -62,44 +62,61 @@ module.exports = function ($resource, $http) {
remove: { method: 'DELETE' } remove: { method: 'DELETE' }
}); });
var convert = function (request, isArray) {
isArray = isArray || false;
var deferred = $q.defer();
request.success(function(response) {
var result = response;
delete result['_links'];
if (isArray) {
result = response.content || response;
}
deferred.resolve(result);
}).error(function(response) {
deferred.reject(response);
});
return deferred.promise;
};
Application.prototype.getHealth = function () { Application.prototype.getHealth = function () {
return $http.get('api/applications/' + this.id + '/health'); return convert($http.get('api/applications/' + this.id + '/health'));
}; };
Application.prototype.getInfo = function () { Application.prototype.getInfo = function () {
return $http.get('api/applications/' + this.id + '/info'); return convert($http.get('api/applications/' + this.id + '/info'));
}; };
Application.prototype.getMetrics = function () { Application.prototype.getMetrics = function () {
return $http.get('api/applications/' + this.id + '/metrics'); return convert($http.get('api/applications/' + this.id + '/metrics'));
}; };
Application.prototype.getEnv = function (key) { Application.prototype.getEnv = function (key) {
return $http.get('api/applications/' + this.id + '/env' + (key ? '/' + key : '' )); return convert($http.get('api/applications/' + this.id + '/env' + (key ? '/' + key : '' )));
}; };
Application.prototype.setEnv = function (map) { Application.prototype.setEnv = function (map) {
return $http.post('api/applications/' + this.id + '/env', '', {params: map}); return convert($http.post('api/applications/' + this.id + '/env', '', {params: map}));
}; };
Application.prototype.resetEnv = function () { Application.prototype.resetEnv = function () {
return $http.post('api/applications/' + this.id + '/env/reset'); return convert($http.post('api/applications/' + this.id + '/env/reset'));
}; };
Application.prototype.refresh = function () { Application.prototype.refresh = function () {
return $http.post('api/applications/' + this.id + '/refresh'); return convert($http.post('api/applications/' + this.id + '/refresh'));
}; };
Application.prototype.getThreadDump = function () { Application.prototype.getThreadDump = function () {
return $http.get('api/applications/' + this.id + '/dump'); return convert($http.get('api/applications/' + this.id + '/dump'), true);
}; };
Application.prototype.getTraces = function () { Application.prototype.getTraces = function () {
return $http.get('api/applications/' + this.id + '/trace'); return convert($http.get('api/applications/' + this.id + '/trace'), true);
}; };
Application.prototype.getActiviti = function () { Application.prototype.getActiviti = function () {
return $http.get('api/applications/' + this.id + '/activiti'); return convert($http.get('api/applications/' + this.id + '/activiti'));
}; };
return Application; return Application;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment