Commit 4805d54c by Johannes Stelzer

Add support for /refresh endpoint

closes #69
parent 5b709a7f
......@@ -17,7 +17,7 @@
module.exports = function ($scope, application) {
$scope.application = application;
$scope.override = { values: [{key: '', value: '' }], error: null};
$scope.overrides = { values: [{key: '', value: '' }], error: null};
var toArray = function(map) {
var array = [];
......@@ -71,37 +71,53 @@ module.exports = function ($scope, application) {
$scope.onChangeOverrideItem = function(item) {
getValue(item);
if ($scope.override.values[$scope.override.values.length - 1].key) {
$scope.override.values.push({key: '', value: '' });
if ($scope.overrides.values[$scope.overrides.values.length - 1].key) {
$scope.overrides.values.push({key: '', value: '' });
}
};
$scope.overrideValue = function() {
$scope.override = function() {
var map = {};
for (var i = 0; i < $scope.override.values.length; i++) {
if ($scope.override.values[i].key) {
map[$scope.override.values[i].key] = $scope.override.values[i].value;
for (var i = 0; i < $scope.overrides.values.length; i++) {
if ($scope.overrides.values[i].key) {
map[$scope.overrides.values[i].key] = $scope.overrides.values[i].value;
}
}
$scope.override.error = null;
$scope.overrides.error = null;
application.setEnv(map).success(function () {
$scope.override = { values: [{key: '', value: '' }], error: null};
$scope.overrides = { values: [{key: '', value: '' }], error: null, changes: null};
$scope.reload();
})
.error(function (error) {
$scope.override.error = error;
$scope.overrides.error = error;
$scope.overrides.changes = null;
$scope.reload();
});
};
$scope.reset = function() {
$scope.override.error = null;
$scope.overrides.error = null;
$scope.overrides.changes = null;
application.resetEnv().success(function () {
$scope.reload();
})
.error(function (error) {
$scope.override.error = error;
$scope.overrides.error = error;
$scope.reload();
});
};
$scope.refresh = function() {
$scope.overrides.error = null;
$scope.overrides.changes = null;
application.refresh().success(function (changes) {
$scope.overrides.changes = changes;
$scope.reload();
})
.error(function (error) {
$scope.overrides.error = error;
$scope.reload();
});
......
......@@ -84,6 +84,10 @@ module.exports = function ($resource, $http) {
return $http.post('api/applications/' + this.id + '/env/reset');
};
Application.prototype.refresh = function () {
return $http.post('api/applications/' + this.id + '/refresh');
};
Application.prototype.getThreadDump = function () {
return $http.get('api/applications/' + this.id + '/dump');
};
......
......@@ -25,7 +25,7 @@
<td style="word-break: break-all;" >{{ key }}</td>
<td style="word-break: break-all;" >{{ value }}</td>
</tr>
<tr ng-repeat="item in override.values">
<tr ng-repeat="item in overrides.values">
<td >
<input type="text" class="input-xlarge" list="allkeys" placeholder="key" ng-model="item.key" ng-change="onChangeOverrideItem(item)"></input>
<datalist id="allkeys">
......@@ -41,11 +41,17 @@
<tfoot>
<tr>
<td colspan="2">
<div class="control-group pull-left">
<button class="btn btn-info" ng-click="refresh()">Refresh beans</button>
</div>
<div class="control-group pull-right">
<button class="btn btn-warning" ng-click="overrideValue()">Overrride Values!</button>
<button class="btn" ng-click="reset()">Reset Values!</button>
<button class="btn btn-warning" ng-click="override()">Overrride values!</button>
<button class="btn" ng-click="reset()">Reset overrides</button>
</div>
<div class="alert alert-info" ng-if="overrides.changes">
<pre>{{ override.changes }}</pre>
</div>
<div class="alert alert-error" ng-if="override.error">
<div class="alert alert-error" ng-if="overrides.error">
<b>Error:</b> {{ override.error }}
</div>
</td>
......
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