Skip to content
Snippets Groups Projects
Verified Commit 3b4a8fc5 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #8879 TIME 1 import sign front

parent 399429b7
No related branches found
No related tags found
No related merge requests found
...@@ -249,6 +249,7 @@ ...@@ -249,6 +249,7 @@
"addUser" : "Add user", "addUser" : "Add user",
"privileges" : "Privileges", "privileges" : "Privileges",
"groupWarnMsg" : "You may no longer be able to access this page!", "groupWarnMsg" : "You may no longer be able to access this page!",
"groupDeleted" : "Group deleted" "groupDeleted" : "Group deleted",
"importNewSignature" : "Import a new signature"
} }
} }
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
"addUser" : "Ajouter un utilisateur", "addUser" : "Ajouter un utilisateur",
"privileges" : "Privilèges", "privileges" : "Privilèges",
"groupWarnMsg" : "Vous risquez de ne plus pouvoir accéder à cette page !", "groupWarnMsg" : "Vous risquez de ne plus pouvoir accéder à cette page !",
"groupDeleted" : "Groupe supprimé" "groupDeleted" : "Groupe supprimé",
"importNewSignature" : "Importer une signature"
} }
} }
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
{{'lang.doubletapSignatureToAddDocument' | translate}} {{'lang.doubletapSignatureToAddDocument' | translate}}
</div> </div>
<section class="list"> <section class="list">
<div class="list-item create" (click)="uploadFile.click()">
<i class="fas fa-upload fa-2x"></i>
{{'lang.importNewSignature' | translate}}
</div>
<input #uploadFile type="file" style="display:none;" (change)="handleFileInput($event.target.files)">
<div class="list-item create" (click)="openPad()"> <div class="list-item create" (click)="openPad()">
<i class="fas fa-pen-nib fa-2x"></i> <i class="fas fa-pen-nib fa-2x"></i>
{{'lang.createNewSignature' | translate}} {{'lang.createNewSignature' | translate}}
......
...@@ -117,4 +117,46 @@ export class SignaturesComponent implements OnInit { ...@@ -117,4 +117,46 @@ export class SignaturesComponent implements OnInit {
} }
}, 250); }, 250);
} }
handleFileInput(files: FileList) {
const fileToUpload = files.item(0);
if (fileToUpload.size <= 2000000) {
if (['image/png', 'image/jpg', 'image/jpeg', 'image/gif'].indexOf(fileToUpload.type) !== -1) {
console.log(fileToUpload.type);
const myReader: FileReader = new FileReader();
myReader.onloadend = (e) => {
console.log(myReader.result.toString());
const newEncodedSign = myReader.result.toString().replace('data:' + fileToUpload.type + ';base64,', '');
localStorage.setItem('signature', JSON.stringify(newEncodedSign));
// Save signature in BDD
const newSign = {
'id': 0,
'encodedSignature': newEncodedSign,
'format': 'png'
};
this.http.post('../rest/users/' + this.signaturesService.userLogged.id + '/signatures', newSign)
.subscribe((data: any) => {
newSign.id = data.signatureId;
this.signaturesService.newSign = newSign;
this.reloadSignatures();
this.notificationService.success('lang.signatureRegistered');
this.bottomSheetRef.dismiss();
const config: MatBottomSheetConfig = {
disableClose: false,
direction: 'ltr'
};
this.bottomSheetRef.open(SignaturesComponent, config);
});
};
myReader.readAsDataURL(fileToUpload);
} else {
this.notificationService.error('lang.notAnImage');
}
} else {
this.notificationService.error('lang.imageTooBig');
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment