Merge with master
This commit is contained in:
commit
c9e3a62f6e
@ -280,6 +280,7 @@ public class DefaultMailService implements MailService {
|
|||||||
} else {
|
} else {
|
||||||
message = exception.getMessage();
|
message = exception.getMessage();
|
||||||
}
|
}
|
||||||
|
log.warn("Unable to send mail: {}", message);
|
||||||
return new ThingsboardException(String.format("Unable to send mail: %s", message),
|
return new ThingsboardException(String.format("Unable to send mail: %s", message),
|
||||||
ThingsboardErrorCode.GENERAL);
|
ThingsboardErrorCode.GENERAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,11 @@ function WebCameraWidgetController($element, $scope, $window, types, utils, attr
|
|||||||
let canvas = null;
|
let canvas = null;
|
||||||
let photoCamera = null;
|
let photoCamera = null;
|
||||||
let dataKeyType = "";
|
let dataKeyType = "";
|
||||||
|
let width = 640;
|
||||||
|
let height = 480;
|
||||||
|
|
||||||
|
const DEFAULT_IMAGE_TYPE = 'image/jpeg';
|
||||||
|
const DEFAULT_IMAGE_QUALITY = 0.92;
|
||||||
|
|
||||||
vm.getStream = getStream;
|
vm.getStream = getStream;
|
||||||
vm.createPhoto = createPhoto;
|
vm.createPhoto = createPhoto;
|
||||||
@ -79,6 +84,8 @@ function WebCameraWidgetController($element, $scope, $window, types, utils, attr
|
|||||||
vm.isEntityDetected = true;
|
vm.isEntityDetected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
width = vm.ctx.settings.maxWidth ? vm.ctx.settings.maxWidth : 640;
|
||||||
|
height = vm.ctx.settings.maxHeight ? vm.ctx.settings.maxWidth : 480;
|
||||||
if (datasource.dataKeys.length) {
|
if (datasource.dataKeys.length) {
|
||||||
$scope.currentKey = datasource.dataKeys[0].name;
|
$scope.currentKey = datasource.dataKeys[0].name;
|
||||||
dataKeyType = datasource.dataKeys[0].type;
|
dataKeyType = datasource.dataKeys[0].type;
|
||||||
@ -93,6 +100,24 @@ function WebCameraWidgetController($element, $scope, $window, types, utils, attr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getVideoAspectRatio() {
|
||||||
|
if (videoElement.videoWidth && videoElement.videoWidth > 0 &&
|
||||||
|
videoElement.videoHeight && videoElement.videoHeight > 0) {
|
||||||
|
return videoElement.videoWidth / videoElement.videoHeight;
|
||||||
|
}
|
||||||
|
return width / height;
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.videoWidth = function() {
|
||||||
|
const videoRatio = getVideoAspectRatio();
|
||||||
|
return Math.min(width, height * videoRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.videoHeight = function() {
|
||||||
|
const videoRatio = getVideoAspectRatio();
|
||||||
|
return Math.min(height, width / videoRatio);
|
||||||
|
}
|
||||||
|
|
||||||
function hasGetUserMedia() {
|
function hasGetUserMedia() {
|
||||||
return !!($window.navigator.mediaDevices && $window.navigator.mediaDevices.getUserMedia);
|
return !!($window.navigator.mediaDevices && $window.navigator.mediaDevices.getUserMedia);
|
||||||
}
|
}
|
||||||
@ -157,10 +182,12 @@ function WebCameraWidgetController($element, $scope, $window, types, utils, attr
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createPhoto() {
|
function createPhoto() {
|
||||||
canvas.width = videoElement.videoWidth;
|
canvas.width = vm.videoWidth();
|
||||||
canvas.height = videoElement.videoHeight;
|
canvas.height = vm.videoHeight();
|
||||||
canvas.getContext('2d').drawImage(videoElement, 0, 0);
|
canvas.getContext('2d').drawImage(videoElement, 0, 0, vm.videoWidth(), vm.videoHeight());
|
||||||
vm.previewPhoto = canvas.toDataURL('image/png');
|
const mimeType = vm.ctx.settings.imageFormat ? vm.ctx.settings.imageFormat : DEFAULT_IMAGE_TYPE;
|
||||||
|
const quality = vm.ctx.settings.imageQuality ? vm.ctx.settings.imageQuality : DEFAULT_IMAGE_QUALITY;
|
||||||
|
vm.previewPhoto = canvas.toDataURL(mimeType, quality);
|
||||||
vm.isPreviewPhoto = true;
|
vm.isPreviewPhoto = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user