From 435c8694f7a0e26129739f474b8272fc9acc4d78 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 29 Sep 2013 23:11:51 +0300 Subject: [PATCH] hell knows what other improvements --- doc/todo.txt | 7 ++++--- motioneye.py | 4 +++- src/config.py | 8 +++++++- src/handlers.py | 23 +++++++++++------------ src/motionctl.py | 2 +- static/css/main.css | 1 + static/js/main.js | 3 ++- 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 0e36e92..e4302cd 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,11 +1,11 @@ -> camera not available background and icon design -> remove current snapshot GET logs --> a nice shadow behind the header -> add a motion running status indicator (and maybe a start/stop button) - +-> add a timeout checker to check the running status of motion -> group @config rules to top -> browser compatibility test -> requirements test +-> style scroll bars -> hint text next to section titles -> clickable hints -> authentication @@ -15,4 +15,5 @@ -> click to zoom on cameras -> add a previewer for movies -> add a previewer for snapshots --> other todos \ No newline at end of file +-> other todos +-> use svg instead of pngs for icons \ No newline at end of file diff --git a/motioneye.py b/motioneye.py index 9eb0d0c..b6a7938 100644 --- a/motioneye.py +++ b/motioneye.py @@ -8,8 +8,10 @@ import sys import tornado.ioloop import settings + sys.path.append(os.path.join(settings.PROJECT_PATH, 'src')) +import config import server @@ -46,7 +48,7 @@ def _start_server(): def _start_motion(): - if not motionctl.running(): + if not motionctl.running() and len(config.get_enabled_cameras()) > 0: motionctl.start() logging.info('motion started') diff --git a/src/config.py b/src/config.py index 262ec4e..4f2fbf6 100644 --- a/src/config.py +++ b/src/config.py @@ -136,6 +136,12 @@ def get_camera_ids(): return camera_ids +def get_enabled_cameras(): + camera_ids = get_camera_ids() + cameras = [get_camera(camera_id) for camera_id in camera_ids] + return [c for c in cameras if c['@enabled']] + + def get_camera(camera_id, as_lines=False): # TODO use a cache @@ -489,7 +495,7 @@ def _set_default_motion_camera(data): data.setdefault('text_left', '') data.setdefault('text_right', '') - data.setdefault('text_double', True) + data.setdefault('text_double', False) data.setdefault('text_changes', False) data.setdefault('locate', False) diff --git a/src/handlers.py b/src/handlers.py index c0cd554..baedcd7 100644 --- a/src/handlers.py +++ b/src/handlers.py @@ -146,7 +146,8 @@ class ConfigHandler(BaseHandler): finally: if restart: - motionctl.start() + if len(config.get_enabled_cameras()) > 0: + motionctl.start() def set_preview(self, camera_id): try: @@ -271,6 +272,7 @@ class ConfigHandler(BaseHandler): # text overlay 'text_left': '', 'text_right': '', + 'text_double': False, # streaming 'webcam_localhost': not ui.get('video_streaming', True), @@ -332,6 +334,9 @@ class ConfigHandler(BaseHandler): else: data['text_right'] = ui.get('custom_right_text', '') + + if data['width'] > 320: + data['text_double'] = True if not ui.get('video_streaming', True): data['webcam_maxrate'] = 5 @@ -344,7 +349,7 @@ class ConfigHandler(BaseHandler): data['jpeg_filename'] = ui.get('image_file_name', '%Y-%m-%d-%H-%M-%S-%q') elif capture_mode == 'interval-snapshots': - data['snapshot_interval'] = int(ui.get('snapshot_interval'), 300) + data['snapshot_interval'] = int(ui.get('snapshot_interval', 300)) data['snapshot_filename'] = ui.get('image_file_name', '%Y-%m-%d-%H-%M-%S-%q') elif capture_mode == 'all-frames': @@ -413,11 +418,11 @@ class ConfigHandler(BaseHandler): 'preserve_images': data['@preserve_images'], # motion movies - 'motion_movies': False, - 'movie_quality': 75, - 'movie_file_name': '%Y-%m-%d-%H-%M-%S-%q', + 'motion_movies': data['motion_movies'], + 'movie_quality': int((max(2, data['ffmpeg_variable_bitrate']) - 2) / 0.29), + 'movie_file_name': data['movie_filename'], 'preserve_movies': data['@preserve_movies'], - + # motion detection 'show_frame_changes': data.get('text_changes') or data.get('locate'), 'frame_change_threshold': data['threshold'], @@ -493,12 +498,6 @@ class ConfigHandler(BaseHandler): ui['image_quality'] = ui.get('quality', 75) - movie_filename = data.get('movie_filename') - if movie_filename: - ui['motion_movies'] = True - ui['movie_quality'] = int((max(2, data['ffmpeg_variable_bitrate']) - 2) / 0.29) - ui['movie_file_name'] = movie_filename - working_schedule = data.get('@working_schedule') if working_schedule: days = working_schedule.split('|') diff --git a/src/motionctl.py b/src/motionctl.py index 6c7cce1..62b0e98 100644 --- a/src/motionctl.py +++ b/src/motionctl.py @@ -19,7 +19,7 @@ def find_program(): def start(): if running(): raise Exception('motion is already running') - + program = find_program() if not program: raise Exception('motion executable could not be found') diff --git a/static/css/main.css b/static/css/main.css index d4b21e0..4d65e15 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -55,6 +55,7 @@ div.page { div.header { background-color: rgba(64, 64, 64, 0.5); + box-shadow: 0px 0px 5px rgba(0,0,0,0.3); top: 0px; width: 100%; height: 50px; diff --git a/static/js/main.js b/static/js/main.js index 70e6ee5..526b9f8 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -252,6 +252,8 @@ function openSettings(cameraId) { } function closeSettings() { + hideApply(); + $('div.settings').removeClass('open'); $('div.page-container').removeClass('stretched'); $('div.settings-top-bar').removeClass('open'); @@ -889,7 +891,6 @@ function recreateCameraFrames(cameras) { else { /* existing, update params */ cameraFrame[0].framerate = camera.streaming_framerate; } - } } -- 2.39.5