Skip to content

Commit

Permalink
add enter key process for rest
Browse files Browse the repository at this point in the history
  • Loading branch information
xjsender committed Mar 29, 2015
1 parent 9cf2069 commit 7c5a7f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 0 additions & 3 deletions controller/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ var jsforce = require("jsforce")
, util = require("./util");

exports.login = function(req, res, next) {
console.log(req.hostname);
console.log(req.hostname === "localhost");
console.log(req.hostname == "localhost");
oauth2 = req.hostname === "localhost" ? config.test : config.heroku;
oauth2.loginUrl = req.body.login_url;
req.session.oauth2 = oauth2;
Expand Down
2 changes: 2 additions & 0 deletions controller/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ exports.executeRest = function(req, res, next) {
}
}

console.log(_request);

var conn = new jsforce.Connection({
accessToken: req.session.accessToken,
instanceUrl: req.session.instanceUrl
Expand Down
24 changes: 19 additions & 5 deletions views/rest.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h2>Execute Rest</h2>
<% if (notLogin) { %>
<% include ./template/notLogin.html %>
<%} else { %>
<form name="form" method="post" action="/rest">
<form name="form">
<div class="form-group col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
Expand Down Expand Up @@ -44,13 +44,13 @@ <h3 class="panel-title">Place HTTP method, REST URI and Body here: </h3>

<div class="row">
<div class="col-sm-8" style="margin-top: 5px;">
<textarea class="form-control" rows="1" cols="25" id="rest_uri" name="rest_uri"
required="true"><%- rest_uri %></textarea>
<input type="text" class="form-control" id="rest_uri" name="rest_uri"
required="true" value="<%- rest_uri %>"></textarea>
</div>

<div class="col-sm-4">
<div class="btn-group" style="margin-top: 5px;">
<button type="button" id="executeRest" class="btn btn-primary connect">
<button type="button" id="executeRest" tabindex="0" class="btn btn-primary connect">
<span class="glyphicon glyphicon-ok"></span> Execute
</button>
</div>
Expand Down Expand Up @@ -148,6 +148,15 @@ <h3 class="panel-title">Execution Result:</h3>
}
})

$("#rest_uri").keydown(function(e) {
if (e.keyCode == 13) {
executeRest();
return false;
}

return true;
})

$("#executeRest").on("click", function() {
if ($("#rest_body").is(":visible") && !$("#rest_body").val()) {
$("#rest_body_div").addClass("has-error");
Expand All @@ -156,6 +165,11 @@ <h3 class="panel-title">Execution Result:</h3>
else {
$("#rest_body_div").removeClass("has-error");
}

executeRest();
})

function executeRest() {
rest_method = $(".radioBtn.active").children().val();
rest_url = $("#rest_uri").val();
rest_body = $("#rest_body").val();
Expand All @@ -177,7 +191,7 @@ <h3 class="panel-title">Execution Result:</h3>
$("#RawJson").val(JSON.stringify(resp, null, " "));
process();
});
});
}
});
</script>

Expand Down

0 comments on commit 7c5a7f5

Please sign in to comment.