[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - 6 commits - loleaflet/css loleaflet/images loleaflet/js loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 3 09:22:52 UTC 2019


 loleaflet/css/toolbar.css        |    2 
 loleaflet/images/vereign.png     |binary
 loleaflet/js/toolbar.js          |   15 -
 loleaflet/src/control/Signing.js |  435 +++++++++++++++++++++------------------
 4 files changed, 252 insertions(+), 200 deletions(-)

New commits:
commit 66f56572628083a3c55cba79e5c463c8743ea818
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Jan 3 09:10:34 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:22:14 2019 +0100

    signing toolbar - current logged in identity improvements
    
    Change-Id: I2d03111a932b2a95a6c4518bb096b94418cb48ba
    (cherry picked from commit f8b09e0f42624ef5846f805a96007198a265ae66)

diff --git a/loleaflet/images/vereign.png b/loleaflet/images/vereign.png
index 5ec556aeb..fb3ff261d 100644
Binary files a/loleaflet/images/vereign.png and b/loleaflet/images/vereign.png differ
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 492ca3bb7..60bb3ad37 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1092,18 +1092,16 @@ function initNormalToolbar(toolItems) {
 			items: [
 				{type: 'html',  id: 'left'},
 				{type: 'html',  id: 'logo', html: '<img src="images/vereign.png" style="padding-right: 16px; padding-left: 6px; height: 32px"/>' },
-				{type: 'button',  id: 'sign-upload',  caption: _('Sign & Upload'), img: '', hint: _('Sign and upload document')},
-				{type: 'break', id: 'identity-break' },
-				{type: 'html', id: 'identity-label', html: '<b>' + _('Identity:') + ' </b>'},
-				{type: 'html', id: 'identity', html: _('N/A')},
-				{type: 'break', id: 'passport-break' },
 				{type: 'menu', id: 'passport', caption: _('Select passport'), items: []},
 				{type: 'html', id: 'current-passport', html: _('Passport: N/A')},
-				{type: 'break', id: 'current-document-status-break' },
+				{type: 'break', id: 'passport-break' },
+				{type: 'button',  id: 'sign-upload',  caption: _('Sign & Upload'), img: '', hint: _('Sign and upload document')},
+				{type: 'break', id: 'sign-upload-break' },
 				{type: 'html', id: 'current-document-status-label', html: '<p><b>' + _('Status:') + ' </b></p>'},
 				{type: 'html', id: 'current-document-status', html: _('N/A')},
 				{type: 'spacer'},
-				{type: 'button',  id: 'logout',  caption: _('Logout'), img: '', hint: _('Logout')},
+				{type: 'html', id: 'identity', html: ''},
+                {type: 'button',  id: 'logout',  caption: _('Logout'), img: '', hint: _('Logout')},
 				{type: 'button',  id: 'login',  caption: _('Login'), img: '', hint: _('Login')},
 				{type: 'button',  id: 'close-document-signing-bar', img: 'closetoolbar', hint: _('Close')},
 			],
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index e375e9cba..46167f0c1 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -54,7 +54,8 @@ function updateIndentity() {
 	if (library && identity) {
 		library.getIdentityProfile(identity.authentication.publicKey).then(function(result) {
 			var initials = result.data.initials;
-			w2ui['document-signing-bar'].get('identity').html = '<p>' + initials + '</p>';
+			var color = result.data.identityColor;
+			w2ui['document-signing-bar'].get('identity').html = '<p style="background-color: ' + color + '; border: none; color: white; padding: 8px; text-align: center; text-decoration: none; display: inline-block; font-size: 12px; margin: 4px 2px; border-radius: 50%;">' + initials + '</p>';
 			w2ui['document-signing-bar'].refresh();
 		});
 	}
@@ -140,60 +141,63 @@ function adjustUIState() {
 		return;
 
 	if (library && identity) {
-		w2ui['document-signing-bar'].hide('login');
-		w2ui['document-signing-bar'].show('logout');
-		w2ui['document-signing-bar'].show('identity-label');
-		w2ui['document-signing-bar'].show('identity');
-		w2ui['document-signing-bar'].show('identity-break');
+		w2ui['document-signing-bar'].show('passport');
+		w2ui['document-signing-bar'].show('passport-break');
+
 		if (currentPassport) {
-			w2ui['document-signing-bar'].show('passport-break');
-			w2ui['document-signing-bar'].show('passport');
 			w2ui['document-signing-bar'].show('current-passport');
 			w2ui['document-signing-bar'].show('sign-upload');
+			w2ui['document-signing-bar'].show('sign-upload-break');
 		}
 		else {
-			w2ui['document-signing-bar'].show('passport-break');
-			w2ui['document-signing-bar'].show('passport');
 			w2ui['document-signing-bar'].hide('current-passport');
-			w2ui['document-signing-bar'].hide('sign');
-			w2ui['document-signing-bar'].hide('upload');
+			w2ui['document-signing-bar'].hide('sign-upload');
+			w2ui['document-signing-bar'].hide('sign-upload-break');
 		}
+
+		w2ui['document-signing-bar'].show('identity');
+		w2ui['document-signing-bar'].hide('login');
+		w2ui['document-signing-bar'].show('logout');
 	}
 	else {
+		w2ui['document-signing-bar'].hide('passport');
+		w2ui['document-signing-bar'].hide('current-passport');
+		w2ui['document-signing-bar'].hide('passport-break');
+		w2ui['document-signing-bar'].hide('sign-upload-break');
+		w2ui['document-signing-bar'].hide('sign-upload');
+
+		w2ui['document-signing-bar'].hide('identity');
 		if (library)
 			w2ui['document-signing-bar'].show('login');
 		else
 			w2ui['document-signing-bar'].hide('login');
-
 		w2ui['document-signing-bar'].hide('logout');
-		w2ui['document-signing-bar'].hide('identity-break');
-		w2ui['document-signing-bar'].hide('identity-label');
-		w2ui['document-signing-bar'].hide('identity');
-		w2ui['document-signing-bar'].hide('sign-upload');
-		w2ui['document-signing-bar'].hide('passport-break');
-		w2ui['document-signing-bar'].hide('passport');
-		w2ui['document-signing-bar'].hide('current-passport');
 	}
 
 	w2ui['document-signing-bar'].get('current-document-status').html = '<p>' + currentDocumentSigningStatus + '</p>';
 	w2ui['document-signing-bar'].refresh();
 }
 
+function vereignLoadIdentity(selectedIdentityKey, pincode) {
+	library.loadIdentity(selectedIdentityKey, pincode).then(function(result) {
+		if (isSuccess(result)) {
+			identity = result.data;
+			vereignLogin();
+		}
+		else {
+			identity = null;
+			vereignPinCodeDialog(selectedIdentityKey);
+		}
+	});
+}
+
 function vereignPinCodeDialog(selectedIdentityKey) {
 	vex.dialog.open({
 		message: _('Please enter the PIN Code'),
 		input: '<input name="pincode" type="password" value="" required />',
 		callback: function(data) {
-			if (data.pincode != null && data.pincode != '' && library) {
-				return library.loadIdentity(selectedIdentityKey, data.pincode).then(function(result) {
-					if (isSuccess(result)) {
-						identity = result.data;
-						vereignLogin();
-					}
-					else {
-						identity = null;
-					}
-				});
+			if (library && data.pincode != null && data.pincode != '') {
+				vereignLoadIdentity(selectedIdentityKey, data.pincode);
 			}
 		}
 	});
@@ -203,11 +207,15 @@ function vereignLogin() {
 	if (library && identity) {
 		library.login(identity, 'previousaddeddevice', '', '').then(function(result) {
 			if (isSuccess(result)) {
-				console.log(result);
+				updatePassportList();
+				updateIndentity();
+				adjustUIState();
+			}
+			else {
+				vex.dialog.alert(_('Error at login.'));
+				console.log('Login Error: ' + result);
+				identity = null;
 			}
-			updateIndentity();
-			updatePassportList();
-			adjustUIState();
 		});
 	}
 }
@@ -216,7 +224,7 @@ function verignNewIdentity(newIdentity) {
 	library.login(newIdentity, 'newdevice', '', '').then(function(result) {
 		if (isSuccess(result)) {
 			vex.open({
-				content: '<p>Please scan the code</p><p><div id="image-container"></div></p>',
+				content: '<p>' + _('Please scan the code') + '</p><p><div id="image-container"></div></p>',
 				showCloseButton: true,
 				escapeButtonCloses: true,
 				overlayClosesOnClick: true,
@@ -494,7 +502,7 @@ L.Map.include({
 						console.log('event ActionConfirmedAndExecuted');
 						break;
 					case 'IdentityNotLoaded':
-						vereignPinCodeDialog(event.payloads[0]);
+						vereignLoadIdentity(event.payloads[0], '00000000');
 						break;
 					case 'Authenticated':
 						console.log('event Authenticated');
commit d1032dd4cf35d2c7697db02e96134b03d29c9bb1
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 23:38:51 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:22:05 2019 +0100

    Vereign: improve dialogs
    
    Change-Id: I1452570cae76b8a0680dda8ccbd78f1d6c19005a
    Reviewed-on: https://gerrit.libreoffice.org/65794
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 4866ec47bfcd7768e74ea093fb8bdc36463ad9ca)

diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 762248dc9..e375e9cba 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -181,7 +181,7 @@ function adjustUIState() {
 
 function vereignPinCodeDialog(selectedIdentityKey) {
 	vex.dialog.open({
-		message: _('PIN Code'),
+		message: _('Please enter the PIN Code'),
 		input: '<input name="pincode" type="password" value="" required />',
 		callback: function(data) {
 			if (data.pincode != null && data.pincode != '' && library) {
@@ -216,7 +216,7 @@ function verignNewIdentity(newIdentity) {
 	library.login(newIdentity, 'newdevice', '', '').then(function(result) {
 		if (isSuccess(result)) {
 			vex.open({
-				content: '<div id="image-container"></div>',
+				content: '<p>Please scan the code</p><p><div id="image-container"></div></p>',
 				showCloseButton: true,
 				escapeButtonCloses: true,
 				overlayClosesOnClick: true,
@@ -238,16 +238,44 @@ function verignNewIdentity(newIdentity) {
 }
 
 function verignQrDialog() {
-	if (library) {
-		library.createIdentity('00000000').then(function(result) {
+	if (library == null) {
+		return;
+	}
+	library.createIdentity('00000000').then(function(result) {
+		if (isSuccess(result)) {
+			verignNewIdentity(result.data);
+		}
+	});
+}
+
+function vereignRecoverFromEmail(emailOrSMS) {
+	library.createIdentity('00000000').then(function(result) {
+		if (!isSuccess(result)) {
+			return;
+		}
+		var createdIdentity = result.data;
+		library.identityRestoreAccess(result.data, emailOrSMS).then(function(result) {
 			if (isSuccess(result)) {
-				verignNewIdentity(result.data);
+				return;
 			}
+			vex.dialog.open({
+				message: _('PIN Code'),
+				input: '<p>' + _('Please enter the PIN code from the EMail or SMS') + '</p><input name="pincode" type="password" value="" required />',
+				callback: function(data) {
+					if (data.pincode) {
+						library.login(createdIdentity, 'sms', data.pincode, '').then(function(result) {
+							if (isSuccess(result)) {
+								vereignRestoreIdentity();
+							}
+						});
+					}
+				}
+			});
 		});
-	}
+	});
 }
 
-function vereignRecoverFromEmail() {
+function vereignRecoverFromEmailDialog() {
 	if (library == null) {
 		return;
 	}
@@ -256,31 +284,7 @@ function vereignRecoverFromEmail() {
 		input: '<input name="emailOrMobileNumber" type="text" value="" required />',
 		callback: function(data) {
 			if (data.emailOrMobileNumber) {
-				library.createIdentity('00000000').then(function(result) {
-					if (isSuccess(result)) {
-						var createdIdentity = result.data;
-						library.identityRestoreAccess(result.data, data.emailOrMobileNumber).then(function(result) {
-							if (isSuccess(result)) {
-								vex.dialog.open({
-									message: _('PIN Code'),
-									input: '<p>' + _('Check your email') + '</p><input name="pincode" type="text" value="" required />',
-									callback: function(data) {
-										console.log(data.pincode);
-										if (data.pincode) {
-											if (library) {
-												library.login(createdIdentity, 'sms', data.pincode).then(function(result) {
-													if (isSuccess(result)) {
-														vereignRestoreIdentity();
-													}
-												});
-											}
-										}
-									}
-								});
-							}
-						});
-					}
-				});
+				vereignRecoverFromEmail(data.emailOrMobileNumber);
 			}
 		}
 	});
@@ -467,7 +471,7 @@ L.Map.include({
 						verignQrDialog();
 					}
 					else if (recoverFromEmail) {
-						vereignRecoverFromEmail();
+						vereignRecoverFromEmailDialog();
 					}
 					else if (selectedIdentityKey) {
 						vereignPinCodeDialog(selectedIdentityKey);
commit 581a35ccba7824bde55af98eb8c4b227bdda2800
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 23:24:26 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:21:56 2019 +0100

    improve signing toolbar, add vereign image
    
    Change-Id: Ia18355e4afa1c07083298888528efda75a5aee5f
    Reviewed-on: https://gerrit.libreoffice.org/65793
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit dc282c15bd1730c6c0a413219bab7a033c333427)

diff --git a/loleaflet/css/toolbar.css b/loleaflet/css/toolbar.css
index 59aa34953..00c50a3df 100644
--- a/loleaflet/css/toolbar.css
+++ b/loleaflet/css/toolbar.css
@@ -612,6 +612,8 @@ button.leaflet-control-search-next
 .w2ui-icon.closemobile{ background: url('images/lc_closedocmobile.svg') no-repeat center !important; }
 .w2ui-icon.closetoolbar{ background: url('images/close_toolbar.svg') no-repeat center !important; }
 
+.w2ui-icon.vereign{ background: url('images/vereign.png') no-repeat center !important; }
+
 .inserttable-pop {
     z-index: 1000;
     box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
diff --git a/loleaflet/images/vereign.png b/loleaflet/images/vereign.png
new file mode 100644
index 000000000..5ec556aeb
Binary files /dev/null and b/loleaflet/images/vereign.png differ
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 58113609f..492ca3bb7 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1091,15 +1091,15 @@ function initNormalToolbar(toolItems) {
 			tooltip: 'bottom',
 			items: [
 				{type: 'html',  id: 'left'},
-				{type: 'html', id: 'logo', html: '<p><b>Vereign</b></p>'},
+				{type: 'html',  id: 'logo', html: '<img src="images/vereign.png" style="padding-right: 16px; padding-left: 6px; height: 32px"/>' },
 				{type: 'button',  id: 'sign-upload',  caption: _('Sign & Upload'), img: '', hint: _('Sign and upload document')},
-				{type: 'break' },
+				{type: 'break', id: 'identity-break' },
 				{type: 'html', id: 'identity-label', html: '<b>' + _('Identity:') + ' </b>'},
 				{type: 'html', id: 'identity', html: _('N/A')},
-				{type: 'break' },
+				{type: 'break', id: 'passport-break' },
 				{type: 'menu', id: 'passport', caption: _('Select passport'), items: []},
 				{type: 'html', id: 'current-passport', html: _('Passport: N/A')},
-				{type: 'break' },
+				{type: 'break', id: 'current-document-status-break' },
 				{type: 'html', id: 'current-document-status-label', html: '<p><b>' + _('Status:') + ' </b></p>'},
 				{type: 'html', id: 'current-document-status', html: _('N/A')},
 				{type: 'spacer'},
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 0db2390db..762248dc9 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -144,12 +144,15 @@ function adjustUIState() {
 		w2ui['document-signing-bar'].show('logout');
 		w2ui['document-signing-bar'].show('identity-label');
 		w2ui['document-signing-bar'].show('identity');
+		w2ui['document-signing-bar'].show('identity-break');
 		if (currentPassport) {
+			w2ui['document-signing-bar'].show('passport-break');
 			w2ui['document-signing-bar'].show('passport');
 			w2ui['document-signing-bar'].show('current-passport');
 			w2ui['document-signing-bar'].show('sign-upload');
 		}
 		else {
+			w2ui['document-signing-bar'].show('passport-break');
 			w2ui['document-signing-bar'].show('passport');
 			w2ui['document-signing-bar'].hide('current-passport');
 			w2ui['document-signing-bar'].hide('sign');
@@ -163,10 +166,11 @@ function adjustUIState() {
 			w2ui['document-signing-bar'].hide('login');
 
 		w2ui['document-signing-bar'].hide('logout');
+		w2ui['document-signing-bar'].hide('identity-break');
 		w2ui['document-signing-bar'].hide('identity-label');
 		w2ui['document-signing-bar'].hide('identity');
-		w2ui['document-signing-bar'].hide('sign');
-		w2ui['document-signing-bar'].hide('upload');
+		w2ui['document-signing-bar'].hide('sign-upload');
+		w2ui['document-signing-bar'].hide('passport-break');
 		w2ui['document-signing-bar'].hide('passport');
 		w2ui['document-signing-bar'].hide('current-passport');
 	}
@@ -385,7 +389,7 @@ L.Map.include({
 		this.initializeLibrary();
 		oldtoolbarSize = $('#document-container').css('top');
 
-		$('#document-container').css('top', '110px');
+		$('#document-container').css('top', '116px');
 
 		// Avoid scroll button ">>"
 		var el = w2ui['document-signing-bar'];
commit d238a3a0bec3c2f217e13ecf432e8f72b68a9d4c
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 22:10:28 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:21:48 2019 +0100

    Multiple fixes to Vereign siging code
    
    - unify signing sttaus messages
    - extract new identity creation (verignNewIdentity) to a new func.
    - handle 'IdentityNotLoaded' event
    - remove unneded calls on 'Authenticated' event
    -
    
    Change-Id: Ib70e1893f966adb29e8de4e396c08260021755e1
    Reviewed-on: https://gerrit.libreoffice.org/65786
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 35986764eb22d8a877fb8e6b07bc64aa5823b37b)

diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 5f2bc61b8..0db2390db 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -51,18 +51,16 @@ function getCurrentDocumentFilename(documentType) {
 }
 
 function updateIndentity() {
-	if (library) {
-		if (identity) {
-			library.getIdentityProfile(identity.authentication.publicKey).then(function(result) {
-				var initials = result.data.initials;
-				w2ui['document-signing-bar'].get('identity').html = '<p>' + initials + '</p>';
-				w2ui['document-signing-bar'].refresh();
-			});
-		}
-		else {
-			w2ui['document-signing-bar'].get('identity').html = '';
+	if (library && identity) {
+		library.getIdentityProfile(identity.authentication.publicKey).then(function(result) {
+			var initials = result.data.initials;
+			w2ui['document-signing-bar'].get('identity').html = '<p>' + initials + '</p>';
 			w2ui['document-signing-bar'].refresh();
-		}
+		});
+	}
+	else {
+		w2ui['document-signing-bar'].get('identity').html = '';
+		w2ui['document-signing-bar'].refresh();
 	}
 }
 
@@ -174,7 +172,6 @@ function adjustUIState() {
 	}
 
 	w2ui['document-signing-bar'].get('current-document-status').html = '<p>' + currentDocumentSigningStatus + '</p>';
-
 	w2ui['document-signing-bar'].refresh();
 }
 
@@ -183,19 +180,16 @@ function vereignPinCodeDialog(selectedIdentityKey) {
 		message: _('PIN Code'),
 		input: '<input name="pincode" type="password" value="" required />',
 		callback: function(data) {
-			console.log(data.pincode);
-			if (data.pincode) {
-				if (library) {
-					return library.loadIdentity(selectedIdentityKey, data.pincode).then(function(result) {
-						if (isSuccess(result)) {
-							identity = result.data;
-							vereignLogin();
-						}
-						else {
-							identity = null;
-						}
-					});
-				}
+			if (data.pincode != null && data.pincode != '' && library) {
+				return library.loadIdentity(selectedIdentityKey, data.pincode).then(function(result) {
+					if (isSuccess(result)) {
+						identity = result.data;
+						vereignLogin();
+					}
+					else {
+						identity = null;
+					}
+				});
 			}
 		}
 	});
@@ -203,36 +197,47 @@ function vereignPinCodeDialog(selectedIdentityKey) {
 
 function vereignLogin() {
 	if (library && identity) {
-		library.login(identity, 'previousaddeddevice').then(function(result) {
-			console.log(result);
+		library.login(identity, 'previousaddeddevice', '', '').then(function(result) {
 			if (isSuccess(result)) {
-				updateIndentity();
-				updatePassportList();
-				adjustUIState();
+				console.log(result);
 			}
+			updateIndentity();
+			updatePassportList();
+			adjustUIState();
 		});
 	}
 }
 
+function verignNewIdentity(newIdentity) {
+	library.login(newIdentity, 'newdevice', '', '').then(function(result) {
+		if (isSuccess(result)) {
+			vex.open({
+				content: '<div id="image-container"></div>',
+				showCloseButton: true,
+				escapeButtonCloses: true,
+				overlayClosesOnClick: true,
+				buttons: {},
+				afterOpen: function($vexContent) {
+					var container = $vexContent.find('#image-container');
+					var image = $('<img style="display: block; margin-left: auto; margin-right: auto"/>');
+					image.attr('src', result.data.image);
+					container.append(image);
+				}
+			});
+		}
+		else {
+			vex.dialog.alert(_('Couldn\'t get the QR code image.'));
+			console.log('Login Error: ' + result);
+			library.clearIdentities();
+		}
+	});
+}
+
 function verignQrDialog() {
 	if (library) {
 		library.createIdentity('00000000').then(function(result) {
 			if (isSuccess(result)) {
-				library.login(result.data, 'newdevice').then(function(result) {
-					vex.open({
-						content: '<div id="image-container"></div>',
-						showCloseButton: true,
-						escapeButtonCloses: true,
-						overlayClosesOnClick: true,
-						buttons: {},
-						afterOpen: function($vexContent) {
-							var container = $vexContent.find('#image-container');
-							var image = $('<img style="display: block; margin-left: auto; margin-right: auto"/>');
-							image.attr('src', result.data.image);
-							container.append(image);
-						},
-					});
-				});
+				verignNewIdentity(result.data);
 			}
 		});
 	}
@@ -283,8 +288,8 @@ function vereignRestoreIdentity() {
 	}
 	library.getCurrentlyAuthenticatedIdentity().then(function(result) {
 		if (isSuccess(result)) {
-			vex.closeAll();
 			identity = result.data;
+			vex.closeAll();
 			updateIndentity();
 			updatePassportList();
 			adjustUIState();
@@ -480,17 +485,12 @@ L.Map.include({
 					case 'ActionConfirmedAndExecuted':
 						console.log('event ActionConfirmedAndExecuted');
 						break;
+					case 'IdentityNotLoaded':
+						vereignPinCodeDialog(event.payloads[0]);
+						break;
 					case 'Authenticated':
 						console.log('event Authenticated');
-						library.hasSession().then(function(result) {
-							if (isSuccess(result)) {
-								library.listIdentities().then(function(result) {
-									if (isSuccess(result)) {
-										vereignRestoreIdentity();
-									}
-								});
-							}
-						});
+						vereignRestoreIdentity();
 						break;
 					case 'Logout':
 						console.log('event Logout');
@@ -518,7 +518,7 @@ L.Map.include({
 			currentPassport = { uuid: uuid, text: text };
 			updateCurrentPassport();
 			library.passportGetAvatarByPassport(uuid).then(function(result) {
-				console.log(result);
+				console.log(result); // TODO
 			});
 			adjustUIState();
 		}
@@ -550,23 +550,23 @@ L.Map.include({
 			currentDocumentSigningStatus = _('Not Signed');
 			break;
 		case '1':
-			statusText = _('Document signed and validated.');
+			statusText = _('This document is digitally signed and the signature is valid.');
 			currentDocumentSigningStatus = _('Signed and validated');
 			break;
 		case '2':
-			statusText = _('Document signed but signature is broken.');
+			statusText = _('This document has an invalid signature.');
 			currentDocumentSigningStatus = _('Signature broken');
 			break;
 		case '3':
-			statusText = _('Document signed but the document is already modified.');
+			statusText = _('The signature was valid, but the document has been modified');
 			currentDocumentSigningStatus = _('Signed but document modified');
 			break;
 		case '4':
-			statusText = _('Document signed but can not be validated.');
+			statusText = _('The signature is OK, but the certificate could not be validated.');
 			currentDocumentSigningStatus = _('Signed but not validated');
 			break;
 		case '5':
-			statusText = _('Document signed but not all files are signed.');
+			statusText = _('The signature is OK, but the document is only partially signed');
 			currentDocumentSigningStatus = _('Signed but not all files are signed');
 			break;
 		}
commit e055d1ea360cef0a755dd2ad1762fe1541553d70
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 22:00:52 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:21:27 2019 +0100

    add functions to get API, iframe and WOPI URL for Vereign
    
    Change-Id: Ib97b696f5a3965c4bdf6ddc79aa4cab196630ce2
    Reviewed-on: https://gerrit.libreoffice.org/65785
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 8ddfbead3ca62146a316f1e7959a0c11b4a65075)

diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 7c308c482..5f2bc61b8 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -29,6 +29,16 @@ function getVereignWopiURL() {
 	return vereignURL + '/wopi/';
 }
 
+function getVereignApiURL() {
+	var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL;
+	return vereignURL + '/api/';
+}
+
+function getVereignIFrameURL() {
+	var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL;
+	return vereignURL + '/vcl/js/iframe';
+}
+
 function randomName() {
 	return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
 }
@@ -495,8 +505,8 @@ L.Map.include({
 					}
 				}
 			},
-			vereignURL + '/vcl/js/iframe',
-			vereignURL + '/api/',
+			getVereignIFrameURL(),
+			getVereignApiURL(),
 			getVereignWopiURL()
 		).then(function(lib) {
 			library = lib;
commit 69dc5a58c99a56f86c2caa80cb2b3928d44cb595
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 21:58:28 2019 +0100
Commit:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Thu Jan 3 10:21:12 2019 +0100

    Combine Sign and Upload to one action
    
    First the document is signed, then when the signature status is
    returned, upload to Vereign.
    
    Change-Id: I02a3a3d401cffa295751483ba85bd45c22c7950f
    Reviewed-on: https://gerrit.libreoffice.org/65784
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 4656bdcb38fef68410d4ce62517ccc9732cddba6)

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index e1050d2f3..58113609f 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1092,8 +1092,7 @@ function initNormalToolbar(toolItems) {
 			items: [
 				{type: 'html',  id: 'left'},
 				{type: 'html', id: 'logo', html: '<p><b>Vereign</b></p>'},
-				{type: 'button',  id: 'sign',  caption: _('Sign'), img: '', hint: _('Sign document')},
-				{type: 'button',  id: 'upload',  caption: _('Upload'), img: '', hint: _('Upload document')},
+				{type: 'button',  id: 'sign-upload',  caption: _('Sign & Upload'), img: '', hint: _('Sign and upload document')},
 				{type: 'break' },
 				{type: 'html', id: 'identity-label', html: '<b>' + _('Identity:') + ' </b>'},
 				{type: 'html', id: 'identity', html: _('N/A')},
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 1450d2615..7c308c482 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -14,6 +14,8 @@ var oldtoolbarSize = null;
 var _map = null;
 var currentDocumentSigningStatus = 'N/A'
 
+var awaitForDocumentStatusToUpload = false;
+
 function isSuccess(result) {
 	return result.code == '200';
 }
@@ -22,6 +24,22 @@ function haveIdentity() {
 	return identity != null;
 }
 
+function getVereignWopiURL() {
+	var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL;
+	return vereignURL + '/wopi/';
+}
+
+function randomName() {
+	return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
+}
+
+function getCurrentDocumentFilename(documentType) {
+	var filename = _map['wopi'].BaseFileName;
+	if (!filename)
+		filename = randomName() + '.' + documentType;
+	return filename;
+}
+
 function updateIndentity() {
 	if (library) {
 		if (identity) {
@@ -121,8 +139,7 @@ function adjustUIState() {
 		if (currentPassport) {
 			w2ui['document-signing-bar'].show('passport');
 			w2ui['document-signing-bar'].show('current-passport');
-			w2ui['document-signing-bar'].show('sign');
-			w2ui['document-signing-bar'].show('upload');
+			w2ui['document-signing-bar'].show('sign-upload');
 		}
 		else {
 			w2ui['document-signing-bar'].show('passport');
@@ -265,8 +282,86 @@ function vereignRestoreIdentity() {
 	});
 }
 
-function randomName() {
-	return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36);
+function vereignSign() {
+	if (library == null) {
+		return;
+	}
+	if (currentPassport == null) {
+		return;
+	}
+	library.getOneTimeCertificateByPassport(currentPassport.uuid).then(function(result) {
+		if (isSuccess(result)) {
+			var otp = result.data;
+			var blob = new Blob(['signdocument\n', JSON.stringify(otp)]);
+			_map._socket.sendMessage(blob);
+			awaitForDocumentStatusToUpload = true;
+			checkCurrentDocument();
+		}
+	});
+}
+
+function vereignUploadForType(uploadDocType) {
+	var vereignWopiUrl = getVereignWopiURL();
+	if (vereignWopiUrl == null || vereignWopiUrl == '')
+		return;
+
+	var documentType = null;
+
+	switch (uploadDocType) {
+	case 'ODT':
+		documentType = 'odt';
+		break;
+	case 'DOCX':
+		documentType = 'docx';
+		break;
+	case 'PDF':
+		documentType = 'pdf';
+		break;
+	}
+
+	if (documentType == null)
+		return;
+
+	var filename = getCurrentDocumentFilename(documentType);
+
+	library.getPassports(filename).then(function(result) {
+		if (!isSuccess(result)) {
+			return;
+		}
+		var resultArray = result.data;
+		for (var i = 0; i < resultArray.length; i++) {
+			if (currentPassport.uuid == resultArray[i].PassportUUID) {
+				var jsonRequest = {
+					filename: filename,
+					wopiUrl: vereignWopiUrl + 'files/',
+					token: resultArray[i].AccessToken,
+					type: documentType
+				};
+				var blob = new Blob(['uploadsigneddocument\n', JSON.stringify(jsonRequest)]);
+				_map._socket.sendMessage(blob);
+				// Let the user know that we're done.
+				_map.fire('infobar', {
+					msg: _('Document uploaded.') + '\n\n' + filename,
+					action: null,
+					actionLabel: null
+				});
+			}
+		}
+	});
+}
+
+function vereignUploadDialog() {
+	if (library == null) {
+		return;
+	}
+
+	vex.dialog.open({
+		message: _('Select document type to upload'),
+		input: _('Type:') + '<select name="selection"><option value="ODT">ODT</option><option value="DOCX">DOCX</option><option value="PDF">PDF</option></select>',
+		callback: function(data) {
+			vereignUploadForType(data.selection);
+		}
+	});
 }
 
 L.Map.include({
@@ -293,79 +388,8 @@ L.Map.include({
 		$('#document-signing-bar').hide();
 		adjustUIState();
 	},
-	signDocument: function() {
-		if (library) {
-			var map = this;
-			if (currentPassport) {
-				library.getOneTimeCertificateByPassport(currentPassport.uuid).then(function(result) {
-					if (isSuccess(result)) {
-						var otp = result.data;
-						var blob = new Blob(['signdocument\n', JSON.stringify(otp)]);
-						map._socket.sendMessage(blob);
-						checkCurrentDocument();
-					}
-				});
-			}
-		}
-	},
-	uploadToVereign: function() {
-		if (library == null) {
-			return;
-		}
-
-		var map = this;
-
-		vex.dialog.open({
-			message: _('Select document type to upload'),
-			input: _('Type:') + '<select name="selection"><option value="ODT">ODT</option><option value="DOCX">DOCX</option><option value="PDF">PDF</option></select>',
-			callback: function(data) {
-				var documentType = null;
-
-				switch (data.selection) {
-				case 'ODT':
-					documentType = 'odt';
-					break;
-				case 'DOCX':
-					documentType = 'docx';
-					break;
-				case 'PDF':
-					documentType = 'pdf';
-					break;
-				}
-
-				if (documentType == null)
-					return;
-
-				var filename = map['wopi'].BaseFileName;
-				if (!filename)
-					filename = randomName() + '.' + documentType;
-
-				library.getPassports(filename).then(function(result) {
-					var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL;
-					if (isSuccess(result)) {
-						var resultArray = result.data;
-						for (var i = 0; i < resultArray.length; i++) {
-							if (currentPassport.uuid == resultArray[i].PassportUUID) {
-								var jsonRequest = {
-									filename: filename,
-									wopiUrl: vereignURL + '/wopi/files',
-									token: resultArray[i].AccessToken,
-									type: documentType
-								};
-								var blob = new Blob(['uploadsigneddocument\n', JSON.stringify(jsonRequest)]);
-								map._socket.sendMessage(blob);
-								// Let the user know that we're done.
-								map.fire('infobar', {
-									msg: _('Document uploaded.') + '\n\n' + filename,
-									action: null,
-									actionLabel: null
-								});
-							}
-						}
-					}
-				});
-			}
-		});
+	signAndUploadDocument: function() {
+		vereignSign();
 	},
 	signingLogout: function() {
 		if (library) {
@@ -473,7 +497,7 @@ L.Map.include({
 			},
 			vereignURL + '/vcl/js/iframe',
 			vereignURL + '/api/',
-			vereignURL + '/wopi/'
+			getVereignWopiURL()
 		).then(function(lib) {
 			library = lib;
 			adjustUIState();
@@ -499,11 +523,8 @@ L.Map.include({
 		else if (id === 'logout') {
 			this.signingLogout();
 		}
-		else if (id === 'sign') {
-			this.signDocument();
-		}
-		else if (id === 'upload') {
-			this.uploadToVereign();
+		else if (id === 'sign-upload') {
+			this.signAndUploadDocument();
 		}
 		else if (id.startsWith('passport:')) {
 			this.setCurrentPassport(item.value, item.text);
@@ -549,5 +570,11 @@ L.Map.include({
 		}
 
 		adjustUIState();
+
+		if (awaitForDocumentStatusToUpload) {
+			awaitForDocumentStatusToUpload = false;
+			vereignUploadDialog();
+		}
+		awaitForDocumentStatusToUpload = false;
 	}
 });


More information about the Libreoffice-commits mailing list