loleaflet/admin.strings.js | 1 + loleaflet/dist/admin/admin.html | 1 + loleaflet/src/admin/AdminSocketOverview.js | 23 +++++++++++++++++++++-- wsd/Admin.cpp | 5 +++++ wsd/Admin.hpp | 1 + wsd/AdminModel.cpp | 19 +++++++++++++++++++ wsd/AdminModel.hpp | 6 ++++++ wsd/DocumentBroker.cpp | 19 ++++++++++++------- wsd/DocumentBroker.hpp | 1 - 9 files changed, 66 insertions(+), 10 deletions(-)
New commits: commit 9db39ce741604b24a43c08d0db6e7e641a42d19d Author: Aditya Dewan <iit2015...@iiita.ac.in> Date: Fri May 12 19:29:01 2017 +0530 tdf#107752 admin console: indicating whether a document is modified. Change-Id: I6055a601c1dd3b5e9700ef75d7c07d7e0b13d663 diff --git a/loleaflet/admin.strings.js b/loleaflet/admin.strings.js index e5116276..a56b5d47 100644 --- a/loleaflet/admin.strings.js +++ b/loleaflet/admin.strings.js @@ -18,6 +18,7 @@ l10nstrings.strDocument = _('Document'); l10nstrings.strNumberOfViews = _('Number of views'); l10nstrings.strElapsedTime = _('Elapsed time'); l10nstrings.strIdleTime = _('Idle time'); +l10nstrings.strModified = _('Modified'); l10nstrings.strKill = _('Kill'); l10nstrings.strGraphs = _('Graphs'); l10nstrings.strSave = _('Save'); diff --git a/loleaflet/dist/admin/admin.html b/loleaflet/dist/admin/admin.html index 1e65699e..f8268565 100644 --- a/loleaflet/dist/admin/admin.html +++ b/loleaflet/dist/admin/admin.html @@ -90,6 +90,7 @@ <th><script>document.write(l10nstrings.strMemoryConsumed)</script></th> <th><script>document.write(l10nstrings.strElapsedTime)</script></th> <th><script>document.write(l10nstrings.strIdleTime)</script></th> + <th><script>document.write(l10nstrings.strModified)</script></th> </tr> </thead> <tbody id="doclist"> diff --git a/loleaflet/src/admin/AdminSocketOverview.js b/loleaflet/src/admin/AdminSocketOverview.js index 96c29a0b..b1070fcd 100644 --- a/loleaflet/src/admin/AdminSocketOverview.js +++ b/loleaflet/src/admin/AdminSocketOverview.js @@ -23,7 +23,7 @@ var AdminSocketOverview = AdminSocketBase.extend({ this.base.call(this); this.socket.send('documents'); - this.socket.send('subscribe adddoc rmdoc resetidle propchange'); + this.socket.send('subscribe adddoc rmdoc resetidle propchange modifications'); this._getBasicStats(); var socketOverview = this; @@ -101,7 +101,8 @@ var AdminSocketOverview = AdminSocketBase.extend({ sMem = docProps['memory']; sDocTime = docProps['elapsedTime']; sDocIdle = docProps['idleTime']; - userListJson = docProps['views'] + modified = docProps['modified']; + userListJson = docProps['views']; $doc = $('#doc' + sPid); $rowContainer = $(document.createElement('tr')).attr('id', 'doc' + sPid); @@ -137,6 +138,11 @@ var AdminSocketOverview = AdminSocketBase.extend({ .val(parseInt(sDocIdle)) .text(Util.humanizeSecs(sDocIdle)); $rowContainer.append($docIdle); + + $mod = $(document.createElement('td')).attr('id', 'mod' + sPid) + .text(modified); + $rowContainer.append($mod); + $('#doclist').append($rowContainer); } } @@ -187,6 +193,10 @@ var AdminSocketOverview = AdminSocketBase.extend({ .text(Util.humanizeSecs(0)); $rowContainer.append($docIdle); + $mod = $(document.createElement('td')).attr('id', 'mod' + sPid) + .text(''); + $rowContainer.append($mod); + $('#doclist').append($rowContainer); $a = $(document.getElementById('active_docs_count')); @@ -255,6 +265,15 @@ var AdminSocketOverview = AdminSocketBase.extend({ } } } + else if (textMsg.startsWith('modifications')) { + textMsg = textMsg.substring('modifications'.length); + docProps = textMsg.trim().split(' '); + sPid = docProps[0]; + value = docProps[1]; + + $mod = $(document.getElementById('mod' + sPid)); + $mod.text(value); + } }, onSocketClose: function() { diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp index 8e899d26..fdea3f9a 100644 --- a/wsd/Admin.cpp +++ b/wsd/Admin.cpp @@ -350,6 +350,11 @@ void Admin::pollingThread() } } +void Admin::modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value){ + addCallback([this, dockey, pid, value] + { _model.modificationAlert(dockey, pid, value); }); +} + void Admin::addDoc(const std::string& docKey, Poco::Process::PID pid, const std::string& filename, const std::string& sessionId, const std::string& userName) { addCallback([this, docKey, pid, filename, sessionId, userName] diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp index d04fa543..f9d8bb6a 100644 --- a/wsd/Admin.hpp +++ b/wsd/Admin.hpp @@ -71,6 +71,7 @@ public: unsigned getTotalMemoryUsage(); + void modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value); /// Update the Admin Model. void update(const std::string& message); diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp index 1af98871..51b314ef 100644 --- a/wsd/AdminModel.cpp +++ b/wsd/AdminModel.cpp @@ -373,6 +373,24 @@ void AdminModel::notify(const std::string& message) } } +void AdminModel::modificationAlert(const std::string& docKey, Poco::Process::PID pid, bool value) +{ + assertCorrectThread(); + + auto doc = _documents.find(docKey); + if(doc != _documents.end()) + { + doc->second.setModified(value); + } + + std::ostringstream oss; + oss << "modifications " + << pid << ' ' + << (value?"Yes":"No"); + + notify(oss.str()); +} + void AdminModel::addDocument(const std::string& docKey, Poco::Process::PID pid, const std::string& filename, const std::string& sessionId, const std::string& userName) @@ -532,6 +550,7 @@ std::string AdminModel::getDocuments() const << "\"memory\"" << ':' << it.second.getMemoryDirty() << ',' << "\"elapsedTime\"" << ':' << it.second.getElapsedTime() << ',' << "\"idleTime\"" << ':' << it.second.getIdleTime() << ',' + << "\"modified\"" << ':' << '"' << (it.second.getModifiedStatus() ? "Yes" : "No") << '"' << ',' << "\"views\"" << ':' << '['; viewers = it.second.getViews(); std::string separator; diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp index aad075eb..1d86e827 100644 --- a/wsd/AdminModel.hpp +++ b/wsd/AdminModel.hpp @@ -85,9 +85,13 @@ public: const std::string getHistory() const; void takeSnapshot(); + void setModified(bool value) { _isModified = value; } + bool getModifiedStatus() const { return _isModified; } + std::string to_string() const; private: + bool _isModified; const std::string _docKey; const Poco::Process::PID _pid; /// SessionId mapping to View object @@ -175,6 +179,8 @@ public: void unsubscribe(int sessionId, const std::string& command); + void modificationAlert(const std::string& docKey, Poco::Process::PID pid, bool value); + void clearMemStats() { _memStats.clear(); } void clearCpuStats() { _cpuStats.clear(); } diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 66a103b4..ee89e56f 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -605,8 +605,7 @@ bool DocumentBroker::saveToStorageInternal(const std::string& sessionId, StorageBase::SaveResult storageSaveResult = _storage->saveLocalFileToStorage(accessToken); if (storageSaveResult == StorageBase::SaveResult::OK) { - _isModified = false; - _tileCache->setUnsavedChanges(false); + setModified(false); _lastFileModifiedTime = newFileModifiedTime; _tileCache->saveLastModified(_lastFileModifiedTime); _lastSaveTime = std::chrono::steady_clock::now(); @@ -1238,8 +1237,13 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id) void DocumentBroker::setModified(const bool value) { + if(_isModified != value) + { + _isModified = value; + Admin::instance().modificationAlert(_docKey, getPid(), value); + } + _tileCache->setUnsavedChanges(value); - _isModified = value; } bool DocumentBroker::forwardToChild(const std::string& viewId, const std::string& message) diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 23b699e4..27d525c0 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -241,7 +241,6 @@ public: bool saveToStorage(const std::string& sesionId, bool success, const std::string& result = ""); bool isModified() const { return _isModified; } void setModified(const bool value); - /// Save the document if the document is modified. /// @param force when true, will force saving if there /// has been any recent activity after the last save. commit c05aec945d2f33c73dba5910f94010b607e5822b Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue May 23 17:05:07 2017 +0530 Revert "wsd: Use hostname and port in doc key too" This reverts commit e8ff26899203b6994579afacdd5f89aa68c8a696. To have support for both multitenancy - several WOPI hosts using same wsd - and WOPI host aliases, using a ID unique across a WOPI host instance as part of the WOPI URL is a better approach that handles both of above mentioned issues cleanly. diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 17ce1be2..66a103b4 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -104,13 +104,14 @@ Poco::URI DocumentBroker::sanitizeURI(const std::string& uri) std::string DocumentBroker::getDocKey(const Poco::URI& uri) { // If multiple host-names are used to access us, then - // we force same document (when opened from + // they must be aliases. Permission to access aliased hosts + // is checked at the point of accepting incoming connections. + // At this point storing the hostname artificially discriminates + // between aliases and forces same document (when opened from // alias hosts) to load as separate documents and sharing doesn't // work. Worse, saving overwrites one another. - // But we also do not want different WOPI hosts using the same path - // for some file getting shared across WOPI hosts std::string docKey; - Poco::URI::encode(uri.getHost() + ":" + std::to_string(uri.getPort()) + uri.getPath(), "", docKey); + Poco::URI::encode(uri.getPath(), "", docKey); return docKey; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits