Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to validate value to JSON format #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions frontend/etcdbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,17 @@ app.controller('NodeCtrl', ['$scope','$http','$cookies', function($scope,$http,$
error(errorHandler);
}

$scope.checkboxModel = {
use_json_validation : false
};
$scope.updateNode = function(node,value){
if ($scope.checkboxModel.use_json_validation) {
try {
JSON.parse(value);
} catch (err) {
return 'Not a json';
}
}
$http({method: 'PUT',
url: $scope.getPrefix() + keyPrefix + node.key,
params: {"value": value}}).
Expand Down
7 changes: 5 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<span>{{node.name}}:</span>
</td>
<td style="padding-right: 5px;">
<span class="value" editable-text="node.value" onbeforesave="updateNode(node,$data)">{{node.value || '(empty)'}}</span>
<span class="value" editable-textarea="node.value" onbeforesave="updateNode(node,$data)" e-cols="40">{{node.value || '(empty)'}}</span>
</td>
</tr>
</table>
Expand Down Expand Up @@ -64,7 +64,7 @@
<div class="container-fluid" role="main" ng-controller="NodeCtrl">
<h1 class="warning">etcd browser</h1>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<form ng-submit="submit()">
<div class="input-group" ng-submit="submit()">
<input type="text" class="form-control" ng-model="urlPrefix" placeholder="http://localhost:4001">
Expand All @@ -74,6 +74,9 @@ <h1 class="warning">etcd browser</h1>
</div>
</form>
</div>
<div class="col-md-3" style="margin-top:8px">
<input type="checkbox" ng-model="checkboxModel.use_json_validation"><span style="padding-left:5px">validate values to JSON format</span></input>
</div>
</div>
<div ng-if="error" class="alert alert-danger alert-dismissible" role="alert">{{error}}</div>
<div class="row top-buffer">
Expand Down