flutter_thingsboard_pe_app
flutter_thingsboard_pe_app copied to clipboard
photo/image not saved as serverAttribute using mobile action - take photo
Hi trying to use mobile action -> take photo
the camera opens, takes picture, picture is displayed, but not saved as serverAttribute on the device.
using default code
`// Function body to process image obtained as a result of mobile action (take photo, take image from gallery, etc.).
// - imageUrl - image URL in base64 data format
showImageDialog('Photo', imageUrl);
//saveEntityImageAttribute('image', imageUrl);
function showImageDialog(title, imageUrl) {
setTimeout(function() {
widgetContext.customDialog.customDialog(imageDialogTemplate, ImageDialogController, {imageUrl: imageUrl, title: title}).subscribe();
}, 100);
}
function saveEntityImageAttribute(attributeName, imageUrl) {
if (entityId) {
let attributes = [{
key: attributeName, value: imageUrl
}];
widgetContext.attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributes).subscribe(
function() {
widgetContext.showSuccessToast('Image attribute saved!');
},
function(error) {
widgetContext.dialogs.alert('Image attribute save failed', JSON.stringify(error));
}
);
}
}
var
imageDialogTemplate =
'<div aria-label="Image">' +
'<form #theForm="ngForm">' +
'<mat-toolbar fxLayout="row" color="primary">' +
'<h2>{{title}}</h2>' +
'<span fxFlex></span>' +
'<button mat-icon-button (click)="close()">' +
'<mat-icon>close</mat-icon>' +
'</button>' +
'</mat-toolbar>' +
'<div mat-dialog-content>' +
'<div class="mat-content mat-padding">' +
'<div fxLayout="column" fxFlex>' +
'<div style="padding-top: 20px;">' +
'<img [src]="imageUrl" style="height: 300px;"/>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div mat-dialog-actions fxLayout="row">' +
'<span fxFlex></span>' +
'<button mat-button (click)="close()" style="margin-right:20px;">Close</button>' +
'</div>' +
'</form>' +
'</div>';
function ImageDialogController(instance) {
let vm = instance;
vm.title = vm.data.title;
vm.imageUrl = vm.data.imageUrl;
vm.close = function ()
{
vm.dialogRef.close(null);
}
}
`