-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added page for viewing model statistics #610
this will consume the GET/get-model-statistics/:mid web service end point and display it for consumption
- Loading branch information
Matthew Letter
committed
Mar 25, 2016
1 parent
a449577
commit 021647e
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
web-server/plugins/slycat-model-statistics/slycat-model-statistics.py
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,20 @@ | ||
# coding=utf-8 | ||
def register_slycat_plugin(context): | ||
import os | ||
|
||
def page_html(database, model): | ||
import pystache | ||
context = dict() | ||
return pystache.render(open(os.path.join(os.path.dirname(__file__), "ui.html"), "r").read(), context) | ||
|
||
''' | ||
Register a custom page | ||
Running this example code: | ||
- Configure your web server to load the slycat-login plugin by adding it to the /etc/slycat/web-server-config.ini for the developer image | ||
- Point a browser to https://your-slycat-server/pages/model-statistics | ||
''' | ||
context.register_page("model-statistics", page_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,64 @@ | ||
<div class="bootstrap-styles" style="-webkit-flex:1;flex:1;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;padding:12px;"> | ||
TODO add ui, add json | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
require(["slycat-server-root", "jquery", "URI"], function(server_root, $, URI) | ||
{ | ||
function login() | ||
{ | ||
user_name = document.getElementById("Username").value | ||
password = document.getElementById("Password").value | ||
//TODO: add post call for username and password | ||
console.log("calling webservice with") | ||
console.log("login " + user_name + " " + password); | ||
console.log(server_root + "login/") | ||
var sendInfo = JSON.stringify( | ||
{ | ||
"user_name": user_name, | ||
"password": password | ||
} | ||
); | ||
|
||
$.ajax( | ||
{ | ||
contentType: "application/json", | ||
type: "POST", | ||
url: URI(server_root + "login"), | ||
success: function(result) | ||
{ | ||
window.alert("success " + result); | ||
console.log("success " + result); | ||
}, | ||
error: function(request, status, reason_phrase) | ||
{ | ||
window.alert("error request:" + request.responseJSON +" status: "+ status + " reason: " + reason_phrase); | ||
console.log("error request:" + request.responseJSON +" status: "+ status + " reason: " + reason_phrase); | ||
}, | ||
data: sendInfo | ||
}); | ||
|
||
console.log("done") | ||
} | ||
|
||
function logout() | ||
{ | ||
console.log("logging out"); | ||
$.ajax( | ||
{ | ||
type: "DELETE", | ||
url: server_root + "logout", | ||
success: function() | ||
{ | ||
console.log("success") | ||
}, | ||
error: function(request, status, reason_phrase) | ||
{ | ||
console.log("fail") | ||
}, | ||
}); | ||
} | ||
document.getElementById("go").addEventListener("click", login, false); | ||
document.getElementById("logout").addEventListener("click", logout, false); | ||
}); | ||
</script> |