Test buttons for webcam URLs & extraction into snippet

This commit is contained in:
Gina Häußge 2015-08-17 16:47:40 +02:00
parent 68431770d8
commit edbbc49edd
3 changed files with 87 additions and 12 deletions

View file

@ -185,6 +185,74 @@ $(function() {
self.terminalFilters.remove(filter);
};
self.testWebcamStreamUrl = function() {
if (!self.webcam_streamUrl()) {
return;
}
var text = gettext("If you see your webcam stream below, the entered stream URL is ok.");
showMessageDialog({
title: gettext("Stream test"),
message: '<p>' + text + '</p><p><img src="' + self.webcam_streamUrl() + '" /></p>'
});
};
self.testWebcamSnapshotUrl = function(viewModel, event) {
if (!self.webcam_snapshotUrl()) {
return;
}
var target = $(event.target);
target.prepend('<i class="icon-spinner icon-spin"></i> ');
var errorText = gettext("Could not retrieve snapshot URL, please double check the URL");
var errorTitle = gettext("Snapshot test failed");
$.ajax({
url: API_BASEURL + "util/test",
type: "POST",
dataType: "json",
data: JSON.stringify({
command: "url",
url: self.webcam_snapshotUrl(),
method: "GET",
response: true
}),
contentType: "application/json; charset=UTF-8",
success: function(response) {
$("i.icon-spinner", target).remove();
if (!response.result) {
showMessageDialog({
title: errorTitle,
message: errorText
});
return;
}
var content = response.response.content;
var mimeType = "image/jpeg";
var headers = response.response.headers;
if (headers && headers["mime-type"]) {
mimeType = headers["mime-type"];
}
var text = gettext("If you see your webcam snapshot picture below, the entered snapshot URL is ok.");
showMessageDialog({
title: gettext("Snapshot test"),
message: $('<p>' + text + '</p><p><img src="data:' + mimeType + ';base64,' + content + '" /></p>')
});
},
error: function() {
$("i.icon-spinner", target).remove();
showMessageDialog({
title: errorTitle,
message: errorText
});
}
});
};
self.onSettingsShown = function() {
self.requestData();
};

View file

@ -0,0 +1,18 @@
<div class="control-group" title="{{ _('URL to embed into the UI for live viewing of the webcam stream') }}">
<label class="control-label" for="settings-webcamStreamUrl">{{ _('Stream URL') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level" data-bind="value: webcam_streamUrl" id="settings-webcamStreamUrl">
<button class="btn" type="button" data-bind="click: testWebcamStreamUrl, enable: webcam_streamUrl(), css: {disabled: !webcam_streamUrl()}">{{ _('Test') }}</button>
</div>
</div>
</div>
<div class="control-group" title="{{ _('URL to use for retrieving webcam snapshot images for timelapse creation') }}">
<label class="control-label" for="settings-webcamSnapshotUrl">{{ _('Snapshot URL') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level" data-bind="value: webcam_snapshotUrl" id="settings-webcamSnapshotUrl">
<button class="btn" type="button" data-bind="click: testWebcamSnapshotUrl, enable: webcam_snapshotUrl(), css: {disabled: !webcam_snapshotUrl()}">{{ _('Test') }}</button>
</div>
</div>
</div>

View file

@ -1,16 +1,5 @@
<form class="form-horizontal">
<div class="control-group" title="{{ _('URL to embed into the UI for live viewing of the webcam stream') }}">
<label class="control-label" for="settings-webcamStreamUrl">{{ _('Stream URL') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: webcam_streamUrl" id="settings-webcamStreamUrl">
</div>
</div>
<div class="control-group" title="{{ _('URL to use for retrieving webcam snapshot images for timelapse creation') }}">
<label class="control-label" for="settings-webcamSnapshotUrl">{{ _('Snapshot URL') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: webcam_snapshotUrl" id="settings-webcamSnapshotUrl">
</div>
</div>
{% include "dialogs/_snippets/configurewebcamurls.jinja2" %}
<div class="control-group" title="{{ _('Full path to the FFMPEG binary') }}">
<label class="control-label" for="settings-webcamFfmpegPath">{{ _('Path to FFMPEG') }}</label>
<div class="controls">