[Libreoffice-commits] online.git: loleaflet/images loleaflet/js loleaflet/src

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 3 08:36:24 UTC 2019


 loleaflet/images/vereign.png     |binary
 loleaflet/js/toolbar.js          |   12 ++---
 loleaflet/src/control/Signing.js |   80 +++++++++++++++++++++------------------
 3 files changed, 49 insertions(+), 43 deletions(-)

New commits:
commit f8b09e0f42624ef5846f805a96007198a265ae66
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 09:35:49 2019 +0100

    signing toolbar - current logged in identity improvements
    
    Change-Id: I2d03111a932b2a95a6c4518bb096b94418cb48ba

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 ab49ed1f6..1c2f266f8 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1096,18 +1096,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');


More information about the Libreoffice-commits mailing list