diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-07 20:46:02 +0100 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-12-29 03:09:52 +0100 |
commit | 7c588e919e959f32b33235b4a44da257d8f4a964 (patch) | |
tree | 91db85ddbffd6989d14f7843e6ec5dd004935893 /src/leap/bitmask/core/web/static | |
parent | e50a442c6f03ba09a800f9999e29e9340b1d45c7 (diff) |
[refactor] move web service to its own submodule
Diffstat (limited to 'src/leap/bitmask/core/web/static')
-rw-r--r-- | src/leap/bitmask/core/web/static/README | 14 | ||||
-rw-r--r-- | src/leap/bitmask/core/web/static/__init__.py | 0 | ||||
-rw-r--r-- | src/leap/bitmask/core/web/static/index.html | 131 |
3 files changed, 145 insertions, 0 deletions
diff --git a/src/leap/bitmask/core/web/static/README b/src/leap/bitmask/core/web/static/README new file mode 100644 index 00000000..2b99926c --- /dev/null +++ b/src/leap/bitmask/core/web/static/README @@ -0,0 +1,14 @@ +This is a simple html based console that uses the bitmask.js library, which +uses the REST api exposed by the HTTPRequestDispatcher. This html should be +served when leap.bitmask_js package is not found on the import path from where +bitmask.core is executed. + +The development of bitmask_js is in the ui/ folder in this bitmask-dev repo. + +A pre-compiled version of the whole html+js ui can be found in the +leap.bitmask_js package. To have it served from the same endpoint than the REST +api, just install leap.bitmask_js in your environment. + +This 'web console' remains here to be able to develop against the REST api +without the need of installing the full-fledged bitmask_js package. However, +it's only going to work when running from the git repository. diff --git a/src/leap/bitmask/core/web/static/__init__.py b/src/leap/bitmask/core/web/static/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/leap/bitmask/core/web/static/__init__.py diff --git a/src/leap/bitmask/core/web/static/index.html b/src/leap/bitmask/core/web/static/index.html new file mode 100644 index 00000000..9951a9b2 --- /dev/null +++ b/src/leap/bitmask/core/web/static/index.html @@ -0,0 +1,131 @@ +<!DOCTYPE html> +<html> + <head> + <title>Bitmask.js example</title> + <script src="bitmask.js"></script> + <script type="text/javascript"> + var ellog = null; + + window.onload = function() { + ellog = document.getElementById('log'); + + bitmask.events.register("KEYMANAGER_KEY_FOUND", event_handler); + }; + + function configure() { + var domain = document.getElementById('domain').value; + bitmask.bonafide.provider.create(domain).then(function(response) { + log("Provider configured: "); + for (k in response) { + log(" " + k + ": " + response[k]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function read() { + var domain = document.getElementById('domain').value; + bitmask.bonafide.provider.read(domain).then(function(response) { + log("Provider configuration: "); + for (k in response) { + log(" " + k + ": " + response[k]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function del() { + var domain = document.getElementById('domain').value; + bitmask.bonafide.provider.delete(domain).then(function(response) { + log("Provider deleted: "); + for (k in response) { + log(" " + k + ": " + response[k]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function list() { + bitmask.bonafide.provider.list().then(function(response) { + log("List providers: "); + for (k in response) { + log(" domain: " + response[k]["domain"]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function login() { + var email = document.getElementById('email').value; + var password = document.getElementById('password').value; + bitmask.bonafide.user.auth(email, password).then(function(response) { + log("We are logged in: "); + for (k in response) { + log(" " + k + ": " + response[k]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function logout() { + bitmask.bonafide.user.logout().then(function(response) { + log("We are logged out: "); + for (k in response) { + log(" " + k + ": " + response[k]); + } + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function user() { + bitmask.bonafide.user.active().then(function(response) { + log("The active user is: " + response); + }, function(error) { + log("Some error ocurred: " + error); + }); + bitmask.mail.get_token().then(function(response) { + log("The token is: " + response); + }, function(error) { + log("Some error ocurred: " + error); + }); + }; + + function event_handler(evnt, content) { + log("Event: " + evnt); + for (i in content) { + log(" " + content[i]); + } + }; + + function log(m) { + ellog.innerHTML += m + '\n'; + ellog.scrollTop = ellog.scrollHeight; + }; + </script> + </head> + <body> + <h1>Bitmask Control Panel</h1> + <noscript>You must enable JavaScript</noscript> + <form> + <p>Provider: <input id="domain" type="text" size="50" maxlength="50" value="mail.bitmask.net"></p> + </form> + <button onclick='configure();'>Configure provider</button> + <button onclick='read();'>Read providers</button> + <button onclick='del();'>Delete providers</button> + <button onclick='list();'>List providers</button> + <form> + <p>Email address: <input id="email" type="text" size="50" maxlength="50" value="user@mail.bitmask.net"></p> + <p>Password: <input id="password" type="password" size="50" maxlength="50" ></p> + </form> + <button onclick='login();'>Log In</button> + <button onclick='logout();'>Log Out</button> + <button onclick='user();'>User</button> + <pre id="log" style="height: 20em; overflow-y: scroll; background-color: #faa;"></pre> + </body> +</html> |