Hi Stefan.
At first in your sign up page you need to make next modifications(assign your sustem user to User_info row):
1 add to your "Users" system collection new field with name "userInfoId" type string. http://prntscr.com/3q12g8/direct
2 On signUp click - you need to create item in "User_info" collection with empty or default values. This create service return "_id" store this id in "currentUserInfoId" LSV.
3 Open your signUp service. Navigate to request tab and add "userInfoId" parameter. http://prntscr.com/3q0tvi/direct
4 Open signUp datasource and click "Edit mapping". Add new mapping from LSV "currentUserInfoId" to "userInfoId" request parameter. http://prntscr.com/3q0w44/direct
5 Then on success even on create service invoke signUP service.
So after these steps you will get new empty ROW in your "User_info" collection and new row in system User collection with correct filled "userInfoId" field.
Please don't go ahead until you get this work.
After you have these new two rows in your DB you need to do following steps(to update photo):
1 Open your "Account" page.
2 Navigate to "Data" page.
3 Find datasource for "User_Info_update_service" and click "Edit Mapping".
4 Open "Request" tab and find "photo" request parameter. Click on "Add JS". And populate it with following code:
precode
return localStorage.getItem("fileDataUrl");
/code/pre
5 Find "_id" parameter. Click on "Add JS" button and populate it with following code:
precode
return localStorage.getItem("currentUserInfoId");
/code/pre
5 Open your JavaScript1 file and populate it with following code:
precode
var file;
function fileSelectHandler(e) {
var files = e.target.files || e.dataTransfer.files;
file = files[0];
previewFile();
}
function previewFile() {
var previewContainer = $('table[dsid=preview]');
var fileName = $('[name=fileName]');
var fileContentType = $('[name=fileContentType]');
// make the preview container visible once a file was selected
previewContainer.toggle();
// set the file name
fileName.text(file.name);
fileContentType.text(file.type);
var reader = new FileReader();
reader.onloadend = function(e) {
var fileDataUrl = e.target.result;
localStorage.setItem("fileDataUrl", fileDataUrl);
Code: Select all
//Set current avatar to the image component
Apperyio("profile_pic").attr("src", fileDataUrl);
//It will invoke your "restservice4" dataSource of "User_Info_update_service" service.
restservice4.execute();
};
//reader.readAsText(file);
//reader.readAsBinaryString(file);
//reader.readAsArrayBuffer(file);
reader.readAsDataURL(file);
}
/code/pre
After these steps you will update your "photo" collumn in current user row.
Regards.