[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 29 20:47:09 UTC 2018
loleaflet/js/toolbar.js | 12 ++++++++--
loleaflet/src/control/Signing.js | 46 ++++++++++++++++++++++++++++++++-------
2 files changed, 48 insertions(+), 10 deletions(-)
New commits:
commit 77e67f44b968fd91d2e0b97d71f269bc77886cc3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Nov 15 09:47:37 2018 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Nov 29 21:46:57 2018 +0100
separate lib. init. from login, show UI elements on state change
It is needed to separate initialization of the library and login
(the button) as you may already be logged in if you have
credentials in the local storage (already logged in through
vereign website for example). So behaviour now is either you get
logged in immediately or you get a login button.
There is a lot of state changes where various elements of the
infobar are show or hidden. To make it easier to track the changes
it is necessary to have showing/hiding at one function which is
triggered every time a state change may occur.
Change-Id: I0f36f342baaf80dc109f608e294b89a955a6572e
Reviewed-on: https://gerrit.libreoffice.org/63413
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index c4c0ce685..15b91adeb 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -952,8 +952,8 @@ function initNormalToolbar(toolItems) {
{type: 'html', id: 'logo', html: '<p><b>Vereign</b></p>'},
{type: 'button', id: 'sign', caption: 'Sign', img: '', hint: _('Sign document')},
{type: 'break' },
- {type: 'html', id: 'user-label', html: '<p>User:</p>'},
- {type: 'html', id: 'user', html: '<none>'},
+ {type: 'html', id: 'identity-label', html: '<b>Identity:</b>'},
+ {type: 'html', id: 'identity', html: 'N/A'},
{type: 'break' },
{type: 'button', id: 'logout', caption: 'Logout', img: '', hint: _('Logout')},
{type: 'button', id: 'login', caption: 'Login', img: '', hint: _('Login')},
@@ -1471,10 +1471,6 @@ function onDocLayerInit() {
$('#spreadsheet-toolbar').hide();
$('#presentation-toolbar').hide();
- if (L.DomUtil.get('document-signing-bar') !== null) {
- w2ui['document-signing-bar'].hide('logout');
- }
-
break;
case 'presentation':
var presentationToolbar = w2ui['presentation-toolbar'];
@@ -1513,6 +1509,10 @@ function onDocLayerInit() {
break;
}
+ if (L.DomUtil.get('document-signing-bar') !== null) {
+ map.signingInitializeBar();
+ }
+
if (L.Browser.mobile) {
_mobilify();
nUsers = '%n';
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 6ee79bba8..ba656565f 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -17,22 +17,45 @@ function updateIndentity() {
if (identity) {
library.getIdentityProfile(identity.authentication.publicKey).then(function(result) {
var initials = result.data.initials;
- var color = result.data.identityColor;
- console.log(initials + ' ' + color);
- w2ui['document-signing-bar'].get('user').html = '<p>' + initials + '</p>';
+ w2ui['document-signing-bar'].get('identity').html = '<p>' + initials + '</p>';
w2ui['document-signing-bar'].refresh();
});
}
else {
- w2ui['document-signing-bar'].get('user').html = '';
+ w2ui['document-signing-bar'].get('identity').html = '';
w2ui['document-signing-bar'].refresh();
}
}
}
+function adjustUIState() {
+ 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('sign');
+ }
+ else {
+ 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-label');
+ w2ui['document-signing-bar'].hide('identity');
+ w2ui['document-signing-bar'].hide('sign');
+ }
+ w2ui['document-signing-bar'].refresh();
+}
+
L.Map.include({
showSignDocument: function() {
- this.signingLogin();
+ this.initializeLibrary();
+ },
+ signingInitializeBar: function() {
+ adjustUIState();
},
signDocument: function() {
if (library) {
@@ -57,13 +80,14 @@ L.Map.include({
if (isSuccess(result)) {
identity = null;
updateIndentity();
- w2ui['document-signing-bar'].show('login');
- w2ui['document-signing-bar'].hide('logout');
+ adjustUIState();
}
});
}
},
signingLogin: function() {
+ },
+ initializeLibrary: function() {
setupViamAPI(
'signdocument-iframe-content',
{
@@ -71,14 +95,15 @@ L.Map.include({
switch (event.type) {
case 'Authenticated':
library.getCurrentlyAuthenticatedIdentity().then(function(result) {
- identity = result.data;
- updateIndentity();
- w2ui['document-signing-bar'].hide('login');
- w2ui['document-signing-bar'].show('logout');
+ if (isSuccess(result)) {
+ identity = result.data;
+ updateIndentity();
+ adjustUIState();
+ }
});
break;
default:
- alert(event.type);
+ console.log('UNKNOWN EVENT: ' + event.type);
break;
}
}
@@ -87,6 +112,7 @@ L.Map.include({
).then(function(lib)
{
library = lib;
+ adjustUIState();
});
}
});
commit 8c298875d3126cc1a7cb966b000c5921440c0844
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Nov 9 10:01:21 2018 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Nov 29 21:46:48 2018 +0100
add login to vereign into signing infobar
Change-Id: I0904b9cea3d2248e35313d642da4d3805246232d
Reviewed-on: https://gerrit.libreoffice.org/63412
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 5802f42fa..c4c0ce685 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -233,6 +233,9 @@ function onClick(e, id, item, subItem) {
map.sendUnoCommand('.uno:StatusBarFunc', command);
});
}
+ else if (id === 'login') {
+ map.signingLogin();
+ }
else if (id === 'logout') {
map.signingLogout();
}
@@ -953,6 +956,7 @@ function initNormalToolbar(toolItems) {
{type: 'html', id: 'user', html: '<none>'},
{type: 'break' },
{type: 'button', id: 'logout', caption: 'Logout', img: '', hint: _('Logout')},
+ {type: 'button', id: 'login', caption: 'Login', img: '', hint: _('Login')},
],
onClick: function (e) {
onClick(e, e.target);
@@ -1467,6 +1471,10 @@ function onDocLayerInit() {
$('#spreadsheet-toolbar').hide();
$('#presentation-toolbar').hide();
+ if (L.DomUtil.get('document-signing-bar') !== null) {
+ w2ui['document-signing-bar'].hide('logout');
+ }
+
break;
case 'presentation':
var presentationToolbar = w2ui['presentation-toolbar'];
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index 0264d2b0c..6ee79bba8 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -57,6 +57,8 @@ L.Map.include({
if (isSuccess(result)) {
identity = null;
updateIndentity();
+ w2ui['document-signing-bar'].show('login');
+ w2ui['document-signing-bar'].hide('logout');
}
});
}
@@ -71,6 +73,8 @@ L.Map.include({
library.getCurrentlyAuthenticatedIdentity().then(function(result) {
identity = result.data;
updateIndentity();
+ w2ui['document-signing-bar'].hide('login');
+ w2ui['document-signing-bar'].show('logout');
});
break;
default:
More information about the Libreoffice-commits
mailing list