Skip to content

Commit

Permalink
www: add a "Power" button
Browse files Browse the repository at this point in the history
Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
  • Loading branch information
chombourger committed Feb 8, 2022
1 parent f602254 commit 06095e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mtda/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
<body>
<span style="font-size: 1.4em">Multi-Tenant Device Access</span>
<div style="width: 80%; height: calc(100% - 50px)" id="console"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<a href=# id=power-toggle><button class='btn btn-default'>Power</button></a>
<script type=text/javascript>
$(function() {
$('a#power-toggle').bind('click', function() {
$.getJSON('/power-toggle',
function(data) {
// do nothing
});
return false;
});
});
</script>
<span style="font-size: small">status:
<span style="font-size: small" id="status">connecting...</span>
</span>
Expand Down
9 changes: 9 additions & 0 deletions mtda/www.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def console_input(data):
mtda.console_send(data['input'], raw=False, session=sid)


@app.route('/power-toggle')
def power_toggle():
sid = session_id()
mtda = app.config['mtda']
if mtda is not None:
return mtda.target_toggle(session=sid)
return ''


def session_id():
sid = None
if 'id' in session:
Expand Down

0 comments on commit 06095e6

Please sign in to comment.