-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add basic KV REST html UI #224
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9da282d
Add basic KV REST html UI and embedfile tool
1d25902
more appropriate naming
43830c6
use local checkout path for embedfile
0f89301
use go install instead of go get
a91c44a
fix Docker build
tbg 7b6578a
no more embedding. Move to AngularJS
de3b37e
Merge branch 'andybons/restui' of github.com:cockroachdb/cockroach in…
f3eea52
remove embedfile stuff
e641127
remove original rest UI file
e272a30
rename to rest explorer. add todo
e32cc92
adjust Dockerfiles
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:latest | ||
FROM golang:1.4.0 | ||
|
||
MAINTAINER Tobias Schottdorf <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
Copyright 2014 The Cockroach Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing | ||
permissions and limitations under the License. See the AUTHORS file | ||
for names of contributors. | ||
|
||
Author: Andrew Bonventre ([email protected]) | ||
*/ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
-moz-box-sizing: border-box; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
html, | ||
body { | ||
height: 100%; | ||
} | ||
body { | ||
background-color: #f1f2f3; | ||
color: #333; | ||
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, sans-serif; | ||
font-weight: 400; | ||
font-size: 14px; | ||
} | ||
.fullHeightContainer { | ||
height: calc(100% - 50px); /* Keep in line with height of .appNav */ | ||
} | ||
.appNav { | ||
height: 50px; | ||
background-color: #fff; | ||
border-bottom: 1px solid #ddd; | ||
padding: 10px 20px; | ||
} | ||
.appNav-link:link, | ||
.appNav-link:visited { | ||
text-decoration: none; | ||
text-transform: uppercase; | ||
color: #333; | ||
display: inline-block; | ||
margin-right: 20px; | ||
} | ||
.appNav-link.appNav-homeName { | ||
font-weight: 800; | ||
font-size: 22px; | ||
text-transform: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
Copyright 2014 The Cockroach Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing | ||
permissions and limitations under the License. See the AUTHORS file | ||
for names of contributors. | ||
|
||
Author: Andrew Bonventre ([email protected]) | ||
*/ | ||
.restExplorer, | ||
.restExplorerControls, | ||
.restExplorerLog { | ||
height: 100%; | ||
} | ||
.restExplorerControls, | ||
.restExplorerLog { | ||
float: left; | ||
padding: 10px 20px; | ||
width: 50%; | ||
} | ||
.restExplorerControls { | ||
background-color: #fff; | ||
} | ||
.restExplorerControls-control { | ||
margin-bottom: 20px; | ||
} | ||
.restExplorerControls-control > h3 { | ||
font-weight: normal; | ||
text-transform: uppercase; | ||
margin-bottom: 3px; | ||
} | ||
.restExplorerControls-control input { | ||
font: inherit; | ||
} | ||
.restExplorerLog { | ||
position: relative; | ||
font-family: 'Source Code Pro', 'Courier New', Courier, monospace; | ||
} | ||
.restExplorerLog-clearButton { | ||
position: absolute; | ||
right: 20px; | ||
top: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
Copyright 2014 The Cockroach Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing | ||
permissions and limitations under the License. See the AUTHORS file | ||
for names of contributors. | ||
|
||
Author: Andrew Bonventre ([email protected]) | ||
--> | ||
<!doctype html> | ||
<html ng-app="cockroach"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,900|Source+Code+Pro' rel='stylesheet' type='text/css'> | ||
<link rel="stylesheet" href="/css/main.css"> | ||
<link rel="stylesheet" href="/css/rest_explorer.css"> <!-- TODO(andybons): @import-like behavior --> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.7/angular.min.js"></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.7/angular-route.min.js"></script> | ||
<script src="/js/main.js"></script> | ||
<script src="/js/controllers/rest_explorer.js"></script> <!-- TODO(andybons): goog.require-like behavior --> | ||
<title>Cockroach</title> | ||
</head> | ||
<body> | ||
<header class="appNav"> | ||
<a href="#/" class="appNav-link appNav-homeName">Cockroach</a> | ||
<a href="#/rest-explorer" class="appNav-link">REST Explorer</a> | ||
</header> | ||
<div class="fullHeightContainer" ng-view></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2014 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. See the AUTHORS file | ||
// for names of contributors. | ||
// | ||
// Author: Andrew Bonventre ([email protected]) | ||
|
||
var crApp = angular.module('cockroach'); | ||
crApp.controller('RestExplorerCtrl', ['$scope', '$http', | ||
function(scope, http) { | ||
scope.responseLog = []; | ||
scope.clearResponseLog = function(e) { | ||
scope.responseLog = []; | ||
}; | ||
scope.requestPending = false; | ||
scope.handleClick = function(e) { | ||
e.preventDefault(); | ||
var method = e.target.getAttribute('data-method'); | ||
var endpoint = e.target.getAttribute('data-endpoint'); | ||
var rangeMethod = endpoint == '/kv/rest/range'; | ||
if (rangeMethod) { | ||
endpoint += '?start=' + encodeURIComponent(scope.kvRangeStart); | ||
if (!!scope.kvRangeEnd) { | ||
endpoint += '&end=' + encodeURIComponent(scope.kvRangeEnd); | ||
} | ||
} else if (!!scope.kvKey) { | ||
endpoint += scope.kvKey; | ||
} | ||
var data = {}; | ||
if (!!scope.kvValue) { | ||
data['value'] = scope.kvValue; | ||
} | ||
var req = { | ||
method: method, | ||
url: endpoint, | ||
data: data, | ||
}; | ||
var responseFn = function(data, status, headers, config) { | ||
if (typeof data == 'object') { | ||
data = JSON.stringify(data); | ||
} | ||
var response = data.length > 0 ? data : '(no response body)'; | ||
var msg = ['[', method, '] ', status, ' ', endpoint, ': ', response].join(''); | ||
scope.responseLog.push(msg); | ||
}; | ||
http(req).success(responseFn).error(responseFn); | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2014 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. See the AUTHORS file | ||
// for names of contributors. | ||
// | ||
// Author: Andrew Bonventre ([email protected]) | ||
|
||
var crApp = angular.module('cockroach', ['ngRoute']); | ||
crApp.config(['$routeProvider', function(routeProvider) { | ||
routeProvider.when('/rest-explorer', { | ||
controller:'RestExplorerCtrl', | ||
templateUrl:'/templates/rest_explorer.html' | ||
}).otherwise({ | ||
redirectTo:'/' | ||
}); | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!-- | ||
Copyright 2014 The Cockroach Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing | ||
permissions and limitations under the License. See the AUTHORS file | ||
for names of contributors. | ||
|
||
Author: Andrew Bonventre ([email protected]) | ||
|
||
TODO(andybons): Add support for kv/rest/counter. | ||
--> | ||
<div class="restExplorer"> | ||
<div class="restExplorerControls"> | ||
<section class="restExplorerControls-control"> | ||
<h3>Put K/V Pair</h3> | ||
<form> | ||
<input type="text" ng-model="kvKey" ng-disabled="responsePending" placeholder="Key"> | ||
→ | ||
<input type="text" ng-model="kvValue" ng-disabled="responsePending" placeholder="Value"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Put" data-endpoint="/kv/rest/entry/" data-method="PUT"> | ||
</form> | ||
</section> | ||
<section class="restExplorerControls-control"> | ||
<h3>Get/Head/Delete K/V Pair</h3> | ||
<form> | ||
<input type="text" ng-model="kvKey" ng-disabled="responsePending" placeholder="Key"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Get" data-endpoint="/kv/rest/entry/" data-method="GET"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Head" data-endpoint="/kv/rest/entry/" data-method="HEAD"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Delete" data-endpoint="/kv/rest/entry/" data-method="DELETE"> | ||
</form> | ||
</section> | ||
<section class="restExplorerControls-control"> | ||
<h3>K/V Range</h3> | ||
<form> | ||
<input type="text" ng-model="kvRangeStart" ng-disabled="responsePending" placeholder="Start"> | ||
→ | ||
<input type="text" ng-model="kvRangeEnd" ng-disabled="responsePending" placeholder="End"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Get" data-endpoint="/kv/rest/range" data-method="GET"> | ||
<input type="button" ng-click="handleClick($event)" ng-disabled="responsePending" value="Delete" data-endpoint="/kv/rest/range" data-method="DELETE"> | ||
</form> | ||
</section> | ||
</div> | ||
<div class="restExplorerLog"> | ||
<h3>Console</h3> | ||
<input type="button" class="restExplorerLog-clearButton" value="Clear" ng-click="clearResponseLog($event)"> | ||
<div ng-repeat="log in responseLog track by $id($index)">{{log}}</div> | ||
</div> | ||
</div> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see playground as being an ancillary feature. I think index.html should be immediately at the status page for the cluster as a whole.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it's just a blank page. The only UI that actually exists is the rest explorer.