]> www.vanbest.org Git - motioneye-debian/commitdiff
the reboot function is back
authorCalin Crisan <ccrisan@gmail.com>
Sat, 27 Dec 2014 14:57:30 +0000 (16:57 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 27 Dec 2014 14:57:30 +0000 (16:57 +0200)
motioneye.py
src/handlers.py
src/server.py
static/css/main.css
static/js/main.js
templates/main.html

index 46784db003bc4e6babd126845556f19a380f6f7e..6b28b8e39e58145707ff55f569fa5054bdb1d9ae 100755 (executable)
@@ -150,9 +150,9 @@ def _test_requirements():
             print('SMB_SHARES require root privileges')
             return False
 
-        if settings.ENABLE_REBOOT:
-            print('reboot requires root privileges')
-            return False
+        if settings.ENABLE_REBOOT:
+            print('reboot requires root privileges')
+            return False
 
     try:
         import tornado  # @UnusedImport
index 3396bfefa93c47c7ca485484ed7564fd5ffb09b5..9bf912af3da7a52c1cbd22158a711168a63afcc3 100644 (file)
@@ -1224,10 +1224,16 @@ class PowerHandler(BaseHandler):
     def post(self, op):
         if op == 'shutdown':
             self.shut_down()
+            
+        elif op == 'reboot':
+            self.reboot()
     
     def shut_down(self):
         IOLoop.instance().add_timeout(datetime.timedelta(seconds=2), powerctl.shut_down)
 
+    def reboot(self):
+        IOLoop.instance().add_timeout(datetime.timedelta(seconds=2), powerctl.reboot)
+
 
 class VersionHandler(BaseHandler):
     def get(self):
index 50414192c2d7fc0ef96b987591654e0e26c24857..19b3d4ac8cf593af298831e52854cb16bb38de61 100644 (file)
@@ -51,7 +51,7 @@ application = Application(
         (r'^/movie/(?P<camera_id>\d+)/(?P<op>download|preview|delete)/(?P<filename>.+?)/?$', handlers.MovieHandler),
         (r'^/movie/(?P<camera_id>\d+)/(?P<op>delete_all)/(?P<group>.+?)/?$', handlers.MovieHandler),
         (r'^/update/?$', handlers.UpdateHandler),
-        (r'^/power/(?P<op>shutdown)/?$', handlers.PowerHandler),
+        (r'^/power/(?P<op>shutdown|reboot)/?$', handlers.PowerHandler),
         (r'^/version/?$', handlers.VersionHandler),
         (r'^/login/?$', handlers.LoginHandler),
         (r'^.*$', handlers.NotFoundHandler),
index 69025bc3d7a0ebbaab0c3b7150fb0699f5327263..a50f1ec7e7f02328044e88c04214816d3730c1a1 100644 (file)
@@ -359,7 +359,8 @@ img.apply-progress {
 }
 
 div.update-button,
-div.shut-down-button {
+div.shut-down-button,
+div.reboot-button {
     position: relative;
     height: 1.5em;
     line-height: 1.5em;
@@ -376,7 +377,8 @@ div.update-button {
     background: #317CAD;
 }
 
-div.shut-down-button {
+div.shut-down-button,
+div.reboot-button {
     background: #c0392b;
 }
 
@@ -384,7 +386,8 @@ div.update-button:HOVER {
     background: #3498db;
 }
 
-div.shut-down-button:HOVER {
+div.shut-down-button:HOVER,
+div.reboot-button:HOVER {
     background: #D43F2F;
 }
 
@@ -392,7 +395,8 @@ div.update-button:ACTIVE {
     background: #317CAD;
 }
 
-div.shut-down-button:ACTIVE {
+div.shut-down-button:ACTIVE,
+div.reboot-button:ACTIVE {
     background: #B03427;
 }
 
index c06fdd8256bdcd33bbc12149ed79b7ff5c199591..3088acae06b2af59fe21a7351a0eccd1d89335b9 100644 (file)
@@ -587,6 +587,11 @@ function initUI() {
         doShutDown();
     });
     
+    /* reboot button */
+    $('#rebootButton').click(function () {
+        doReboot();
+    });
+    
     /* whenever the window is resized,
      * if a modal dialog is visible, it should be repositioned */
     $(window).resize(updateModalDialogPosition);
@@ -1458,6 +1463,37 @@ function doShutDown() {
     });
 }
 
+function doReboot() {
+    runConfirmDialog('Really reboot?', function () {
+        ajax('POST', '/power/reboot/');
+        setTimeout(function () {
+            refreshInterval = 1000000;
+            showModalDialog('<div class="modal-progress"></div>');
+            var shutDown = false;
+            
+            function checkServer() {
+                ajax('GET', '/', null, 
+                    function () {
+                        if (!shutDown) {
+                            setTimeout(checkServer, 1000);
+                        }
+                        else {
+                            runAlertDialog('The system has been rebooted!', function () {
+                                window.location.reload(true);
+                            });
+                        }
+                    },
+                    function () {
+                        shutDown = true; /* the first error indicates the system was shut down */
+                    }
+                );
+            }
+            
+            checkServer();
+        }, 10);
+    });
+}
+
 function doRemCamera() {
     if (Object.keys(pushConfigs).length) {
         return runAlertDialog('Please apply the modified settings first!');
index 8534a7594f33fb4afa12d39ead43efa4ff47a25d..1be6446304bccf4b7596c652b146d55b7759c034 100644 (file)
                         <td class="settings-item-value"><div class="button shut-down-button" id="shutDownButton">Shut Down</div></td>
                         <td><span class="help-mark" title="shuts down the system">?</span></td>
                     </tr>
+                    <tr class="settings-item advanced-setting{% if not enable_reboot %} hidden{% endif %}">
+                        <td class="settings-item-label"><span class="settings-item-label"></span></td>
+                        <td class="settings-item-value"><div class="button reboot-button" id="rebootButton">Reboot</div></td>
+                        <td><span class="help-mark" title="reboots the system">?</span></td>
+                    </tr>
                 </table>
                 
                 <div class="settings-section-title advanced-setting{% if not wpa_supplicant %} hidden{% endif %}"><input type="checkbox" class="styled section wifi" id="wifiSwitch">Wireless Network</div>