camera_config['@enabled'] = ui_config['enabled']
config.set_camera(camera_id, camera_config)
- # remove the fields that should not get to the remote side
- del ui_config['device']
- del ui_config['proto']
- del ui_config['enabled']
-
- try:
- remote.set_config(
- camera_config.get('@host'),
- camera_config.get('@port'),
- camera_config.get('@username'),
- camera_config.get('@password'),
- camera_config.get('@remote_camera_id'),
- ui_config)
-
- except Exception as e:
- logging.error('failed to set remote camera config: %(msg)s' % {'msg': unicode(e)})
+ # when the camera_config supplied has only the enabled state,
+ # the camera was probably disabled due to errors
+
+ if camera_config.has_key('device'):
+ # remove the fields that should not get to the remote side
+ del ui_config['device']
+ del ui_config['proto']
+ del ui_config['enabled']
- if not no_finish:
- return self.finish_json({'error': unicode(e)})
+ try:
+ remote.set_config(
+ camera_config.get('@host'),
+ camera_config.get('@port'),
+ camera_config.get('@username'),
+ camera_config.get('@password'),
+ camera_config.get('@remote_camera_id'),
+ ui_config)
+
+ except Exception as e:
+ logging.error('failed to set remote camera config: %(msg)s' % {'msg': unicode(e)})
+
+ if not no_finish:
+ return self.finish_json({'error': unicode(e)})
+
+ elif not no_finish:
+ return self.finish_json({'error': unicode(e)})
else:
logging.debug('setting main config')
+++ /dev/null
-
-
- /* basic */
-
-* {
- padding: 0px;
- border: 0px solid black;
- margin: 0px;
- outline: 0px;
- border-spacing: 0px;
- border-collapse: separate;
-}
-
-html {
- height: 100%;
-}
-
-body {
- height: 100%;
- color: #dddddd;
- font-size: 22px;
- background-color: #212121;
-}
-
+ /* basic */
+
+* {
+ padding: 0px;
+ border: 0px solid black;
+ margin: 0px;
+ outline: 0px;
+ border-spacing: 0px;
+ border-collapse: separate;
+}
+
+html {
+ height: 100%;
+}
+
+body {
+ height: 100%;
+ color: #dddddd;
+ font-size: 22px;
+ background-color: #212121;
+}
+
+
/* fonts */
@font-face {
objs.not($('#motionEyeSwitch').parents('div').get(0)).each(markHide);
}
- if (($('#videoDeviceSelect').find('option').length < 2) /* no camera configured */ ||
- $('#videoDeviceSwitch')[0].disabled /* device disabled for some reason (config error) */) {
-
+ if ($('#videoDeviceSelect').find('option').length < 2) { /* no camera configured */
$('#videoDeviceSwitch').parent().each(markHide);
$('#videoDeviceSwitch').parent().nextAll('div.settings-section-title, table.settings').each(markHide);
}
+ if ($('#videoDeviceSwitch')[0].error) { /* config error */
+ $('#videoDeviceSwitch').parent().nextAll('div.settings-section-title, table.settings').each(markHide);
+ }
+
/* advanced settings */
var showAdvanced = $('#showAdvancedSwitch').get(0).checked;
if (!showAdvanced) {
}
function cameraUi2Dict() {
+ if ($('#videoDeviceSwitch')[0].error) { /* config error */
+ return {
+ 'enabled': $('#videoDeviceSwitch')[0].checked,
+ };
+ }
+
var dict = {
/* video device */
'enabled': $('#videoDeviceSwitch')[0].checked,
function dict2CameraUi(dict) {
if (dict == null) {
- $('#videoDeviceSwitch')[0].disabled = true;
+ /* errors while getting the configuration */
+
+ $('#videoDeviceSwitch')[0].error = true;
+ $('#videoDeviceSwitch')[0].checked = true;
updateConfigUi();
return;
}
else {
- $('#videoDeviceSwitch')[0].disabled = false;
+ $('#videoDeviceSwitch')[0].error = false;
}
/* video device */
}
videoDeviceSelect.append('<option value="add">add camera...</option>');
- if (cameras.length > 0) {
- videoDeviceSelect[0].selectedIndex = 0;
+ var enabledCameras = cameras.filter(function (camera) {return camera['enabled'];});
+ if (enabledCameras.length > 0) {
+ videoDeviceSelect[0].selectedIndex = cameras.indexOf(enabledCameras[0]);
fetchCurrentCameraConfig();
}
else {
<title>{% block title %}{% endblock %}</title>
{% block style %}
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}css/jquery.timepicker.css" />
- <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}css/base.css" />
<link rel="shortcut icon" href="/static/img/favicon.ico" />
{% endblock %}
{% block script %}
<script type="text/javascript" src="{{STATIC_URL}}js/jquery.min.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery.timepicker.min.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery.mousewheel.js"></script>
- <script type="text/javascript" src="{{STATIC_URL}}js/base.js"></script>
<script type="text/javascript">
var staticUrl = '{{STATIC_URL}}';