From 73dd1b4316f03ce2d56099e5eb12ececf77b76d5 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 31 Aug 2014 17:59:10 +0300 Subject: [PATCH] snapshot, streaming and embed urls are displayed now under video streaming in the config menu --- src/handlers.py | 8 +++--- static/js/main.js | 66 ++++++++++++++++++++++++++++++--------------- templates/main.html | 17 +++++++++++- 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/src/handlers.py b/src/handlers.py index 6603367..1b9782e 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -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 diff --git a/static/js/main.js b/static/js/main.js index 7cabcd0..df6a741 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -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(''); - $('#addCameraSelect').val(data.id).change(); + var cameraOption = $('#cameraSelect').find('option[value=add]'); + cameraOption.before(''); + $('#cameraSelect').val(data.id).change(); recreateCameraFrames(); }); } diff --git a/templates/main.html b/templates/main.html index e9431d3..2a2697c 100644 --- a/templates/main.html +++ b/templates/main.html @@ -65,7 +65,7 @@ Surveillance Password - ? + ? Time Zone @@ -293,6 +293,21 @@ ? + + Snapshot URL + + ? + + + Streaming URL + + ? + + + Embed URL + + ? +
Still Images
-- 2.39.5