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 @@
module.exports = function ($scope, application) {
$scope.application = application;
application.getActiviti()
.success(function (activiti){
.then(function (activiti){
$scope.summary = [];
$scope.summary.push({
key: 'Completed Task Count Today',
......@@ -56,7 +56,7 @@ module.exports = function ($scope, application) {
});
}
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......@@ -18,11 +18,11 @@
module.exports = function ($scope, application) {
$scope.application = application;
application.getEnv()
.success(function (env) {
.then(function (env) {
var separator = env.systemProperties['path.separator'];
$scope.classpath = env.systemProperties['java.class.path'].split(separator);
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......@@ -23,7 +23,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) {
$scope.showRichGauges = false;
application.getMetrics()
.success(function (metrics) {
.then(function (metrics) {
function merge(array, obj) {
for (var i = 0; i < array.length; i++) {
if (array[i].name === obj.name) {
......@@ -77,7 +77,7 @@ module.exports = function ($scope, application, Abbreviator, MetricsHelper) {
]);
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......@@ -24,18 +24,18 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
}, 1000);
application.getInfo()
.success(function (info) {
.then(function (info) {
$scope.info = info;
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
application.getHealth()
.success(function (health) {
.then(function (health) {
$scope.health = health;
})
.error(function (health) {
.catch(function (health) {
$scope.health = health;
});
......@@ -48,7 +48,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
};
application.getMetrics()
.success(function (metrics) {
.then(function (metrics) {
$scope.metrics = metrics;
$scope.metrics['mem.used'] = $scope.metrics.mem - $scope.metrics['mem.free'];
......@@ -105,7 +105,7 @@ module.exports = function ($scope, $interval, application, MetricsHelper) {
}
]);
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......@@ -48,12 +48,12 @@ module.exports = function ($scope, application) {
$scope.allKeys = [];
application.getEnv()
.success(function (env) {
.then(function (env) {
$scope.env = env;
$scope.envArray = toArray(env);
$scope.allKeys = collectKeys($scope.envArray);
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......@@ -62,7 +62,7 @@ module.exports = function ($scope, application) {
var getValue = function(item) {
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;
});
}
......@@ -85,11 +85,11 @@ module.exports = function ($scope, application) {
}
$scope.overrides.error = null;
application.setEnv(map).success(function () {
application.setEnv(map).then(function () {
$scope.overrides = { values: [{key: '', value: '' }], error: null, changes: null};
$scope.reload();
})
.error(function (error) {
.catch(function (error) {
$scope.overrides.error = error;
$scope.overrides.changes = null;
$scope.reload();
......@@ -99,10 +99,10 @@ module.exports = function ($scope, application) {
$scope.reset = function() {
$scope.overrides.error = null;
$scope.overrides.changes = null;
application.resetEnv().success(function () {
application.resetEnv().then(function () {
$scope.reload();
})
.error(function (error) {
.catch(function (error) {
$scope.overrides.error = error;
$scope.reload();
});
......@@ -112,11 +112,11 @@ module.exports = function ($scope, application) {
$scope.refresh = function() {
$scope.overrides.error = null;
$scope.overrides.changes = null;
application.refresh().success(function (changes) {
application.refresh().then(function (changes) {
$scope.overrides.changes = changes;
$scope.reload();
})
.error(function (error) {
.catch(function (error) {
$scope.overrides.error = error;
$scope.reload();
});
......
......@@ -18,7 +18,7 @@
module.exports = function ($scope, application) {
$scope.dumpThreads = function () {
application.getThreadDump()
.success(function (dump) {
.then(function (dump) {
$scope.dump = dump;
var threadStats = {
......@@ -35,7 +35,7 @@ module.exports = function ($scope, application) {
threadStats.total = dump.length;
$scope.threadStats = threadStats;
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......
......@@ -23,7 +23,7 @@ module.exports = function ($scope, application, $interval) {
$scope.refresh = function () {
application.getTraces()
.success(function (traces) {
.then(function (traces) {
for (var i = 0; i < traces.length; i++) {
if (traces[i].timestamp > $scope.lastTraceTime) {
$scope.traces.push(traces[i]);
......@@ -34,7 +34,7 @@ module.exports = function ($scope, application, $interval) {
}
})
.error(function (error) {
.catch(function (error) {
$scope.error = error;
});
};
......
......@@ -15,7 +15,7 @@
*/
'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 title = app.name + (app.statusInfo.status === 'UP' ? ' is back ' : ' went ') + app.statusInfo.status;
var options = { tag: app.id,
......@@ -45,7 +45,7 @@ module.exports = function ($scope, $location, $interval, $q, $state, $filter, Ap
break;
}
}
app.getInfo().success(function(info) {
app.getInfo().then(function(info) {
app.version = info.version;
app.infoDetails = null;
app.infoShort = '';
......
......@@ -16,7 +16,7 @@
'use strict';
var angular = require('angular');
module.exports = function ($resource, $http) {
module.exports = function ($resource, $http, $q) {
var isEndpointPresent = function(endpoint, configprops) {
if (configprops[endpoint]) {
......@@ -62,44 +62,61 @@ module.exports = function ($resource, $http) {
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 () {
return $http.get('api/applications/' + this.id + '/health');
return convert($http.get('api/applications/' + this.id + '/health'));
};
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 () {
return $http.get('api/applications/' + this.id + '/metrics');
return convert($http.get('api/applications/' + this.id + '/metrics'));
};
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) {
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 () {
return $http.post('api/applications/' + this.id + '/env/reset');
return convert($http.post('api/applications/' + this.id + '/env/reset'));
};
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 () {
return $http.get('api/applications/' + this.id + '/dump');
return convert($http.get('api/applications/' + this.id + '/dump'), true);
};
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 () {
return $http.get('api/applications/' + this.id + '/activiti');
return convert($http.get('api/applications/' + this.id + '/activiti'));
};
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