loleaflet/js/toolbar.js          |    3 ++
 loleaflet/src/control/Signing.js |   44 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 40442bfaa6da0730422ba7e057a3ef2ecde88ffc
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Nov 9 08:42:15 2018 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Nov 9 09:06:41 2018 +0100

    show current logged-in identity in signing infobar
    
    Change-Id: I3d43d1b999de5d850fd5f6a21cc59931a299b874
    Reviewed-on: https://gerrit.libreoffice.org/63155
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 2ceb076fe..53a3a1b7b 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -768,6 +768,9 @@ function createToolbar() {
                        {type: 'html',  id: 'left'},
                        {type: 'html', id: 'logo', html: 
'<p><b>Vereign</b></p>'},
                        {type: 'break' },
+                       {type: 'html', id: 'user-label', html: '<p>User:</p>'},
+                       {type: 'html', id: 'user', html: '<none>'},
+                       {type: 'break' },
                        {type: 'button',  id: 'logout',  caption: 'Logout', 
img: '', hint: _('Logout')},
                ],
                onClick: function (e) {
diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js
index f12392705..58191aa4d 100644
--- a/loleaflet/src/control/Signing.js
+++ b/loleaflet/src/control/Signing.js
@@ -3,9 +3,32 @@
  * Document Signing
  */
 
-/* global window setupViamAPI */
+/* global window setupViamAPI w2ui */
 
 var library = null;
+var identity = null;
+
+function isSuccess(result) {
+       return result.code == '200';
+}
+
+function updateIndentity() {
+       if (library) {
+               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'].refresh();
+                       });
+               }
+               else {
+                       w2ui['document-signing-bar'].get('user').html = '';
+                       w2ui['document-signing-bar'].refresh();
+               }
+       }
+}
 
 L.Map.include({
        showSignDocument: function() {
@@ -13,7 +36,12 @@ L.Map.include({
        },
        signingLogout: function() {
                if (library) {
-                       library.logout();
+                       library.logout().then(function(result) {
+                               if (isSuccess(result)) {
+                                       identity = null;
+                                       updateIndentity();
+                               }
+                       });
                }
        },
        signingLogin: function() {
@@ -21,7 +49,17 @@ L.Map.include({
                        'signdocument-iframe-content',
                        {
                                onEvent: function(event) {
-                                       alert(event.type);
+                                       switch (event.type) {
+                                       case 'Authenticated':
+                                               
library.getCurrentlyAuthenticatedIdentity().then(function(result) {
+                                                       identity = result.data;
+                                                       updateIndentity();
+                                               });
+                                               break;
+                                       default:
+                                               alert(event.type);
+                                               break;
+                                       }
                                }
                        },
                        'https://dev.vereign.com/api/js/iframe'
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to