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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 1 22:40:57 UTC 2019


 loleaflet/css/toolbar.css        |    2 
 loleaflet/images/vereign.png     |binary
 loleaflet/js/toolbar.js          |    8 +-
 loleaflet/src/control/Signing.js |  132 ++++++++++++++++++++-------------------
 4 files changed, 74 insertions(+), 68 deletions(-)

New commits:
commit dc282c15bd1730c6c0a413219bab7a033c333427
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 23:24:26 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jan 1 23:40:49 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>

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 7b42ae28a..60d17953c 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1095,15 +1095,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 35986764eb22d8a877fb8e6b07bc64aa5823b37b
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Jan 1 22:10:28 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jan 1 23:40:37 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>

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;
 		}


More information about the Libreoffice-commits mailing list