self.finish_json(ui_config)
- else:
+ else: # remote camera
def on_response(remote_ui_config=None, error=None):
if error:
return self.finish_json({'error': 'Failed to get remote camera configuration for %(url)s: %(msg)s.' % {
else:
remote_ui_config['id'] = camera_id
-
+
if not remote_ui_config['enabled'] and local_config['@enabled']:
# if a remote camera is disabled, make sure it's disabled locally as well
local_config['@enabled'] = False
check_finished()
else: # remote camera
- if local_config.get('@enabled'):
+ if local_config.get('@enabled') or self.get_argument('force', None) == 'true':
remote.get_config(local_config, on_response_builder(camera_id, local_config))
else: # don't try to reach the remote of the camera is disabled
- on_response_builder(camera_id, local_config)(None)
+ on_response_builder(camera_id, local_config)(error=True)
if length[0] == 0:
self.finish_json({'cameras': []})
/* errors while getting the configuration */
$('#videoDeviceSwitch')[0].error = true;
- $('#videoDeviceSwitch')[0].checked = false;
+ $('#videoDeviceSwitch')[0].checked = true; /* so that the user can explicitly disable the camera */
updateConfigUi();
return;
var enabledCameras = cameras.filter(function (camera) {return camera['enabled'];});
if (enabledCameras.length > 0) { /* prefer the first enabled camera */
cameraSelect[0].selectedIndex = cameras.indexOf(enabledCameras[0]);
- fetchCurrentCameraConfig();
+ fetchCurrentCameraConfig(onFetch);
}
- else if (cameras.length) { /* a disabled camera */
+ else if (cameras.length) { /* only disabled cameras */
cameraSelect[0].selectedIndex = 0;
- fetchCurrentCameraConfig();
+ fetchCurrentCameraConfig(onFetch);
}
else { /* no camera at all */
cameraSelect[0].selectedIndex = -1;
+
+ if (onFetch) {
+ onFetch(data);
+ }
}
updateConfigUi();
/* normal user with no cameras doesn't make too much sense - force login */
doLogout();
}
+
+ if (onFetch) {
+ onFetch(data);
+ }
}
-
+
var mainLoadingProgressImg = $('img.main-loading-progress');
if (mainLoadingProgressImg.length) {
mainLoadingProgressImg.animate({'opacity': 0}, 200, function () {
else {
recreateCameraFrames(cameras);
}
-
- if (onFetch) {
- onFetch(data);
- }
});
}
function fetchCurrentCameraConfig(onFetch) {
var cameraId = $('#cameraSelect').val();
if (cameraId != null) {
- ajax('GET', baseUri + 'config/' + cameraId + '/get/', null, function (data) {
+ ajax('GET', baseUri + 'config/' + cameraId + '/get/?force=true', null, function (data) {
if (data == null || data.error) {
showErrorMessage(data && data.error);
dict2CameraUi(null);
if (onFetch) {
onFetch(null);
}
+
return;
}
}
else {
dict2CameraUi({});
+ if (onFetch) {
+ onFetch({});
+ }
}
}
function updateUi() {
content.find('tr.motioneye, tr.netcam').css('display', 'none');
+ usernameEntry.val('');
+ usernameEntry.removeAttr('readonly');
+
if (deviceSelect.val() == 'motioneye') {
content.find('tr.motioneye').css('display', 'table-row');
addCameraSelect.hide();
+ usernameEntry.val('admin');
+ usernameEntry.attr('readonly', 'readonly');
}
else if (deviceSelect.val() == 'netcam') {
content.find('tr.netcam').css('display', 'table-row');