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

Add keyboard shortcut to run the query + default to http method get #280

Open
wants to merge 1 commit into
base: main
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
8 changes: 7 additions & 1 deletion public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ angular.module('cerebro').controller('RestController', ['$scope', '$http',
$scope.mappings = undefined;
$scope.host = undefined;

$scope.method = 'POST';
$scope.method = 'GET';
$scope.path = '';
$scope.options = [];

Expand Down Expand Up @@ -1543,6 +1543,12 @@ angular.module('cerebro').controller('RestController', ['$scope', '$http',
}
};

$scope.sendQuery = function(event) {
if (event.ctrlKey && (event.keyCode === 10 || event.keyCode === 13)) {
$scope.execute();
}
};

$scope.copyAsCURLCommand = function() {
var method = $scope.method;
var path = encodeURI($scope.path);
Expand Down
8 changes: 5 additions & 3 deletions public/rest/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
placeholder="path (eg: indexName/_search)"
ng-change="updateOptions(path)"
typeahead-wait-ms="20"

ng-keypress="sendQuery($event)"
uib-typeahead="url for url in options | startsWith:$viewValue | limitTo:10"
typeahead-popup-template-url="customPopupTemplate.html"
typeahead-template-url="customTemplate.html">
</div>
<div class="col-lg-2 col-md-3 form-group">
<select ng-model="method" class="form-control">
<option value="GET">GET</option>
<option value="GET" selected="selected">GET</option>
<option value="PUT">PUT</option>
<option value="POST" selected="selected">POST</option>
<option value="POST">POST</option>
<option value="DELETE">DELETE</option>
</select>
</div>
Expand All @@ -62,7 +64,7 @@
</div>
<div class="form-group row">
<div class="col-lg-12">
<div id="rest-client-editor" class="ace-cerebro" style="height: 600px;"></div>
<div id="rest-client-editor" class="ace-cerebro" style="height: 600px;" ng-keypress="sendQuery($event)"></div>
</div>
</div>
<div class="form-group row">
Expand Down