[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/dist loleaflet/src wsd/DocumentBroker.cpp

2017-11-03 Thread Jan Holesovsky
 loleaflet/dist/loleaflet.html |2 +
 loleaflet/dist/toolbar.css|   25 ++
 loleaflet/dist/toolbar/toolbar.js |   37 ++
 loleaflet/src/map/handler/Map.WOPI.js |2 +
 wsd/DocumentBroker.cpp|1 
 5 files changed, 67 insertions(+)

New commits:
commit 41dfc1ab2c4006c5c38dfa10550e218442154e54
Author: Jan Holesovsky 
Date:   Tue Oct 31 17:58:58 2017 +0100

Save As: UI for changing the document name.

Change-Id: I23aba95ff0f8d867b021ba3cf0a6bc5eb4754f9d
Reviewed-on: https://gerrit.libreoffice.org/44282
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index 13e60e54..5d3ccd8a 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -53,6 +53,8 @@
   
 
 
+
+
 
   
 
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index 0b65e88f..6564ae95 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -72,6 +72,31 @@
 width: 700px;
 }
 
+#document-name-input {
+position: fixed;
+z-index: 1050;
+right: 35px;
+top: 2px;
+width: 200px;
+font-size: 16px;
+//font-weight: bold;
+border: 1px solid transparent;
+background-color: transparent;
+}
+
+#document-name-input.editable:focus {
+border: 1px solid #bb;
+background-color: white;
+}
+
+#document-name-input.editable:hover {
+border: 1px solid #bb;
+background-color: white;
+background-image: url('../images/lc_editdoc.svg');
+background-position: right;
+background-repeat: no-repeat;
+}
+
 #closebuttonwrapper {
 position: fixed;
 z-index: 1050;
diff --git a/loleaflet/dist/toolbar/toolbar.js 
b/loleaflet/dist/toolbar/toolbar.js
index ea7e567b..1e1a89f5 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -774,6 +774,27 @@ function onSearchKeyPress(e) {
}
 }
 
+function documentNameConfirm() {
+   var value = $('#document-name-input').val();
+   if (value !== null && value != '') {
+   map.saveAs(value);
+   }
+   map._onGotFocus();
+}
+
+function documentNameCancel() {
+   $('#document-name-input').val(map['wopi'].BaseFileName);
+   map._onGotFocus();
+}
+
+function onDocumentNameKeyPress(e) {
+   if (e.keyCode === 13) { // Enter key
+   documentNameConfirm();
+   } else if (e.keyCode === 27) { // Escape key
+   documentNameCancel();
+   }
+}
+
 function sortFontSizes() {
var oldVal = $('.fontsizes-select').val();
var selectList = $('.fontsizes-select option');
@@ -963,6 +984,22 @@ map.on('wopiprops', function(e) {
evt.preventDefault();
});
}
+   if (e.BaseFileName !== null) {
+   // set the document name into the name field
+   $('#document-name-input').val(e.BaseFileName);
+   }
+   if (e.UserCanNotWriteRelative === false) {
+   // Save As allowed
+   $('#document-name-input').prop('disabled', false);
+   $('#document-name-input').addClass('editable');
+   $('#document-name-input').on('keypress', 
onDocumentNameKeyPress);
+   $('#document-name-input').on('focus', function() { 
map._onLostFocus(); /* hide the caret in the main document */ });
+   $('#document-name-input').on('blur', documentNameCancel);
+   } else {
+   $('#document-name-input').prop('disabled', true);
+   $('#document-name-input').removeClass('editable');
+   $('#document-name-input').off('keypress', 
onDocumentNameKeyPress);
+   }
 });
 
 map.on('doclayerinit', function () {
diff --git a/loleaflet/src/map/handler/Map.WOPI.js 
b/loleaflet/src/map/handler/Map.WOPI.js
index e2a3840d..f06e30fc 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -8,6 +8,7 @@ L.Map.WOPI = L.Handler.extend({
// So use '*' because we still needs to send 'close' message to the 
parent frame which
// wouldn't be possible otherwise.
PostMessageOrigin: '*',
+   BaseFileName: '',
DocumentLoadedTime: false,
HidePrintOption: false,
HideSaveOption: false,
@@ -61,6 +62,7 @@ L.Map.WOPI = L.Handler.extend({
this.PostMessageOrigin = wopiInfo['PostMessageOrigin'];
}
 
+   this.BaseFileName = wopiInfo['BaseFileName'];
this.HidePrintOption = !!wopiInfo['HidePrintOption'];
this.HideSaveOption = !!wopiInfo['HideSaveOption'];
this.HideExportOption = !!wopiInfo['HideExportOption'];
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 966c3184..a6a91c1a 100644
--- 

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - loleaflet/dist loleaflet/src wsd/DocumentBroker.cpp wsd/Storage.cpp wsd/Storage.hpp

2017-05-31 Thread Pranav Kant
 loleaflet/dist/errormessages.js |1 +
 loleaflet/src/core/Socket.js|3 +++
 wsd/DocumentBroker.cpp  |5 +
 wsd/Storage.cpp |4 
 wsd/Storage.hpp |1 +
 5 files changed, 14 insertions(+)

New commits:
commit 43da694acab846eec14b3013da6449d5e24765bf
Author: Pranav Kant 
Date:   Wed May 31 11:51:12 2017 +0530

Handle WOPI PutFile unauthorized access token

Change-Id: I29ee8cc0c9f3ea42f70628eca6f74d161d1a38f9
(cherry picked from commit d840e8720a2ba45ae981b53e5a06b4d28f847314)
Reviewed-on: https://gerrit.libreoffice.org/38259
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/dist/errormessages.js b/loleaflet/dist/errormessages.js
index 89f31fc7..8ea1185c 100644
--- a/loleaflet/dist/errormessages.js
+++ b/loleaflet/dist/errormessages.js
@@ -12,5 +12,6 @@ exports.faileddocloading = _('Failed to load the document. 
Please ensure the fil
 exports.storage = {
loadfailed: _('Failed to read document from storage. Please contact 
your storage server (%storageserver) administrator.'),
savediskfull: _('Save failed due to no disk space left on storage 
server. Document will now be read-only. Please contact the server 
(%storageserver) administrator to continue editing.'),
+   saveunauthorized: _('Document cannot be saved to storage server 
(%storageserver) due to expired or invalid access token. Refresh your session 
to not to lose your work.'),
savefailed: _('Document cannot be saved to storage. Check your 
permissions or contact the storage server (%storageserver) administrator.')
 };
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 25f5f83f..fdce2a54 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -320,6 +320,9 @@ L.Socket = L.Class.extend({
else if (command.errorKind === 'savefailed') {
storageError = errorMessages.storage.savefailed;
}
+   else if (command.errorKind === 'saveunauthorized') {
+   storageError = 
errorMessages.storage.saveunauthorized;
+   }
else if (command.errorKind === 'loadfailed') {
storageError = errorMessages.storage.loadfailed;
// Since this is a document load failure, wsd 
will disconnect the socket anyway,
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 5b15fff1..1e4870e1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -642,6 +642,11 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 sessionIt.second->sendTextFrame("error: cmd=storage 
kind=savediskfull");
 }
 }
+else if (storageSaveResult == StorageBase::SaveResult::UNAUTHORIZED)
+{
+LOG_ERR("Cannot save docKey [" << _docKey << "] to storage URI [" << 
uri << "]. Invalid or expired access token. Notifying client.");
+it->second->sendTextFrame("error: cmd=storage kind=saveunauthorized");
+}
 else if (storageSaveResult == StorageBase::SaveResult::FAILED)
 {
 //TODO: Should we notify all clients?
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index e05641b6..4e6e6567 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -660,6 +660,10 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const std::string& a
 {
 saveResult = StorageBase::SaveResult::DISKFULL;
 }
+else if (response.getStatus() == 
Poco::Net::HTTPResponse::HTTP_UNAUTHORIZED)
+{
+saveResult = StorageBase::SaveResult::UNAUTHORIZED;
+}
 }
 catch(const Poco::Exception& pexc)
 {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 6613fbbc..d0dff593 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -57,6 +57,7 @@ public:
 {
 OK,
 DISKFULL,
+UNAUTHORIZED,
 FAILED
 };
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits