Skip to content
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
12 changes: 11 additions & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ module.exports = new Vue({
latestVersion: '',
showError: false,
showPopup: true,
webGLSupported: util.webgl_supported()
webGLSupported: util.webgl_supported(),
confirmShutdown: false,
}
},

Expand Down Expand Up @@ -282,6 +283,15 @@ module.exports = new Vue({
}.bind(this))
},

shutdown : function() {
this.confirmShutdown = false;
api.put('shutdown');
},

reboot : function() {
this.confirmShutdown = false;
api.put('reboot');
},

connect: function () {
this.sock = new Sock('//' + window.location.host + '/sockjs');
Expand Down
8 changes: 8 additions & 0 deletions src/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ module.exports = {


methods: {

shutdown: function() {
api.put('shutdown');
},
reboot: function() {
api.put('reboot');
},

backup: function () {
document.getElementById('download-target').src = '/api/config/download';
},
Expand Down
10 changes: 10 additions & 0 deletions src/pug/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ html(lang="en")

li.pure-menu-heading
a.pure-menu-link(href="#docs") Docs

button.pure-button.pure-button-primary(@click="confirmShutdown = true", style="width: 100%")
.fa.fa-power-off
message(:show.sync="confirmShutdown")
h3(slot="header") Confirm shutdown?
p(slot="body") Please wait for black screen before switching off power.
div(slot="footer")
button.pure-button(@click="confirmShutdown = false") Cancel
button.pure-button.button-success(@click="shutdown") Shutdown
button.pure-button.button-success(@click="reboot") Restart

#main
.header
Expand Down
6 changes: 6 additions & 0 deletions src/py/bbctrl/Web.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def put_ok(self):
self.get_ctrl().lcd.goodbye('Rebooting...')
subprocess.Popen('reboot')

class ShutdownHandler(bbctrl.APIHandler):
def put_ok(self):
self.get_ctrl().lcd.goodbye('Shutting down...')
subprocess.Popen(['shutdown','-h','now'])


class StateHandler(bbctrl.APIHandler):
def get(self, path):
Expand Down Expand Up @@ -571,6 +576,7 @@ def __init__(self, args, ioloop):
(r'/api/message/(\d+)/ack', MessageAckHandler),
(r'/api/bugreport', BugReportHandler),
(r'/api/reboot', RebootHandler),
(r'/api/shutdown', ShutdownHandler),
(r'/api/hostname', HostnameHandler),
(r'/api/wifi', WifiHandler),
(r'/api/remote/username', UsernameHandler),
Expand Down