]> www.vanbest.org Git - motioneye-debian/commitdiff
snapshot, streaming and embed urls are displayed now under video
authorCalin Crisan <ccrisan@gmail.com>
Sun, 31 Aug 2014 14:59:10 +0000 (17:59 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 31 Aug 2014 14:59:10 +0000 (17:59 +0300)
streaming in the config menu

src/handlers.py
static/js/main.js
templates/main.html

index 6603367e1245d8c68d35e97c26644cb278a0339a..1b9782e2773bbcb2426861851dd96e819deff588 100644 (file)
@@ -71,11 +71,12 @@ class BaseHandler(RequestHandler):
         self.finish(json.dumps(data))
 
     def get_current_user(self):
+        main_config = config.get_main()
+        
         try:
             scheme, token = self.request.headers.get('Authorization', '').split()
             if scheme.lower() == 'basic':
                 user, pwd = base64.decodestring(token).split(':')
-                main_config = config.get_main()
                 
                 if user == main_config.get('@admin_username') and pwd == main_config.get('@admin_password'):
                     return 'admin'
@@ -86,8 +87,9 @@ class BaseHandler(RequestHandler):
                 else:
                     logging.error('authentication failed for user %(user)s' % {'user': user})
                 
-        except:
-            pass
+        except: # no authentication info provided
+            if not main_config.get('@normal_password') and not self.get_argument('logout', None):
+                return 'normal'
 
         return None
     
index 7cabcd067251ef3cd79ce5128d0b6feb3e6003a3..df6a741f45c80a2150833b2028d51d92b2afa5f9 100644 (file)
@@ -39,24 +39,24 @@ function showErrorMessage(message) {
 }
 
 function doLogout() {
-    $.ajax({
-        url: '/',
-        username: ' ',
-        password: 'logout' + new Date().getTime(),
-        complete: function () {
-            window.location.href = '/?logout=true';
-        }
-    });
-    
     /* IE is always a breed apart */
-    if (document.execCommand) {
-        try {
-            document.execCommand('ClearAuthenticationCache');
-        }
-        catch (e) {
+    if (window.ActiveXObject && document.execCommand) {
+        if (document.execCommand('ClearAuthenticationCache')) {
+            window.location.href = '/?logout=true';
         }
-
-        window.location.href = '/?logout=true';
+    }
+    else {
+        var username = ' ';
+        var password = 'logout' + new Date().getTime();
+    
+        $.ajax({
+            url: '/?logout=true',
+            username: username,
+            password: password,
+            complete: function () {
+                window.location.href = '/?logout=true';
+            }
+        });
     }
 }
 
@@ -375,6 +375,11 @@ function initUI() {
     
     /* logout button */
     $('div.button.logout-button').click(doLogout);
+    
+    /* read-only entries */
+    $('#streamingSnapshotUrlEntry:text, #streamingMjpgUrlEntry:text, #streamingEmbedUrlEntry:text').click(function () {
+        this.select();
+    });
 }
 
 
@@ -506,12 +511,19 @@ function updateConfigUi() {
         $('#textOverlaySwitch').parent().next('table.settings').find('tr.settings-item').each(markHide);
     }
     
-    /* video streaming switch */
+    /* video streaming */
     if (!$('#videoStreamingSwitch').get(0).checked) {
         $('#videoStreamingSwitch').parent().next('table.settings').find('tr.settings-item').not('.local-streaming').each(markHide);
     }
-    
-    /* streaming server resize switch */
+    if (!$('#streamingSnapshotUrlEntry').val()) {
+        $('#streamingSnapshotUrlEntry').parents('tr:eq(0)').each(markHide);
+    }
+    if (!$('#streamingMjpgUrlEntry').val()) {
+        $('#streamingMjpgUrlEntry').parents('tr:eq(0)').each(markHide);
+    }
+    if (!$('#streamingEmbedUrlEntry').val()) {
+        $('#streamingEmbedUrlEntry').parents('tr:eq(0)').each(markHide);
+    }
     if (!$('#streamingServerResizeSwitch').get(0).checked) {
         $('#streamingResolutionSlider').parents('tr:eq(0)').each(markHide);
     }
@@ -912,6 +924,16 @@ function dict2CameraUi(dict) {
     $('#streamingPortEntry').val(dict['streaming_port']);
     $('#streamingMotion')[0].checked = dict['streaming_motion'];
     
+    var cameraUrl = location.protocol + '//' + location.host + '/picture/' + dict.id + '/';
+    $('#streamingSnapshotUrlEntry').val(cameraUrl + 'current/');
+    if (dict.proto == 'motioneye') {
+        $('#streamingMjpgUrlEntry').val('');
+    }
+    else {
+        $('#streamingMjpgUrlEntry').val(location.protocol + '//' + location.host.split(':')[0] + ':' + dict.streaming_port);
+    }
+    $('#streamingEmbedUrlEntry').val(cameraUrl + 'frame/');
+    
     /* still images */
     $('#stillImagesSwitch')[0].checked = dict['still_images'];
     $('#imageFileNameEntry').val(dict['image_file_name']);
@@ -1795,9 +1817,9 @@ function runAddCameraDialog() {
                     }
                     
                     endProgress();
-                    var addCameraOption = $('#addCameraSelect').find('option[value=add]');
-                    addCameraOption.before('<option value="' + data.id + '">' + data.name + '</option>');
-                    $('#addCameraSelect').val(data.id).change();
+                    var cameraOption = $('#cameraSelect').find('option[value=add]');
+                    cameraOption.before('<option value="' + data.id + '">' + data.name + '</option>');
+                    $('#cameraSelect').val(data.id).change();
                     recreateCameraFrames();
                 });
             }
index e9431d3b97e5906c184556ade9a95988404a88f0..2a2697c8b2b68d43e73b2a6e549a1f22bf803b16 100644 (file)
@@ -65,7 +65,7 @@
                     <tr class="settings-item">
                         <td class="settings-item-label"><span class="settings-item-label">Surveillance Password</span></td>
                         <td class="settings-item-value"><input type="password" class="styled general" id="normalPasswordEntry"></td>
-                        <td><span class="help-mark" title="the password for the surveillance user">?</span></td>
+                        <td><span class="help-mark" title="the password for the surveillance user (leave empty for passwordless surveillance)">?</span></td>
                     </tr>
                     <tr class="settings-item advanced-setting{% if not timezones %} hidden{% endif %}">
                         <td class="settings-item-label"><span class="settings-item-label">Time Zone</span></td>
                         <td class="settings-item-value"><input type="checkbox" class="styled streaming" id="streamingMotion"></td>
                         <td><span class="help-mark" title="enable this if you want a lower frame rate for the live streaming when no motion is detected">?</span></td>
                     </tr>
+                    <tr class="settings-item advanced-setting local-streaming">
+                        <td class="settings-item-label"><span class="settings-item-label">Snapshot URL</span></td>
+                        <td class="settings-item-value"><input type="text" class="styled streaming" id="streamingSnapshotUrlEntry" readonly="readonly"></td>
+                        <td><span class="help-mark" title="a URL that provides a JPEG image with the most recent snapshot of the camera">?</span></td>
+                    </tr>
+                    <tr class="settings-item advanced-setting">
+                        <td class="settings-item-label"><span class="settings-item-label">Streaming URL</span></td>
+                        <td class="settings-item-value"><input type="text" class="styled streaming" id="streamingMjpgUrlEntry" readonly="readonly"></td>
+                        <td><span class="help-mark" title="a URL that provides a MJPEG stream of the camera (there is no password protection for this URL!)">?</span></td>
+                    </tr>
+                    <tr class="settings-item advanced-setting local-streaming">
+                        <td class="settings-item-label"><span class="settings-item-label">Embed URL</span></td>
+                        <td class="settings-item-value"><input type="text" class="styled streaming" id="streamingEmbedUrlEntry" readonly="readonly"></td>
+                        <td><span class="help-mark" title="a URL that provides a minimal HTML document containing the camera frame, ready to be embedded">?</span></td>
+                    </tr>
                 </table>
                 
                 <div class="settings-section-title"><input type="checkbox" class="styled section still-images" id="stillImagesSwitch">Still Images</div>