summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRash419 <rashesh.padia@collabora.com>2021-09-09 10:48:39 +0530
committerRashesh Padia <rasheshpadia419@gmail.com>2021-09-09 13:58:36 +0530
commit86814e310780b2a1f9cf20ef0019ec08766abc77 (patch)
treec4e02258e04efa4e162e1888f3077484992e4669
parentloleaflet: added local storage to recent and custom color in color pick (diff)
downloadonline-86814e310780b2a1f9cf20ef0019ec08766abc77.tar.gz
online-86814e310780b2a1f9cf20ef0019ec08766abc77.zip
Admin Console: add wopihost name in the dashboard
Signed-off-by: Rash419 <rashesh.padia@collabora.com> Change-Id: I8ce68653200bb16877f6ced57fc77f6291b375a8
-rw-r--r--loleaflet/admin/admin.html8
-rw-r--r--loleaflet/admin/admin.strings.js1
-rw-r--r--loleaflet/admin/src/AdminSocketOverview.js25
-rw-r--r--wsd/Admin.cpp4
-rw-r--r--wsd/Admin.hpp2
-rw-r--r--wsd/AdminModel.cpp7
-rw-r--r--wsd/AdminModel.hpp9
-rw-r--r--wsd/DocumentBroker.cpp6
8 files changed, 45 insertions, 17 deletions
diff --git a/loleaflet/admin/admin.html b/loleaflet/admin/admin.html
index 8db2277eeb..08845fb437 100644
--- a/loleaflet/admin/admin.html
+++ b/loleaflet/admin/admin.html
@@ -54,8 +54,9 @@
<table id="docview" class="table is-fullwidth is-striped is-hoverable is-bordered">
<thead>
<tr style="height:40px;">
- <th></th><!--This header doesn't need text, this column will hold session closer buttons.-->
- <th class="has-text-centered"><script>document.write(l10nstrings.strViewers)</script></th>
+ <th></th><!--This header doesn't need text, this column will hold session closer buttons.-->
+ <th class="has-text-centered"><script>document.write(l10nstrings.strWopihost)</script></th>
+ <th class="has-text-centered"><script>document.write(l10nstrings.strViewers)</script></th>
<th class="has-text-centered"><script>document.write(l10nstrings.strPid)</script></th>
<th class="has-text-centered"><script>document.write(l10nstrings.strDocument)</script></th>
<th class="has-text-centered"><script>document.write(l10nstrings.strMemoryConsumed)</script></th>
@@ -72,6 +73,7 @@
<table id="userview" class="table is-bordered is-hoverable is-striped is-fullwidth">
<thead>
<tr style="height:40px;">
+ <th class="has-text-centered"><script>document.write(l10nstrings.strWopihost)</script></th>
<th class="has-text-centered"><script>document.write(l10nstrings.strUserName)</script></th>
<th class="has-text-centered"><script>document.write(l10nstrings.strDocumentNumber)</script></th>
</tr>
@@ -99,4 +101,4 @@
document.getElementById('tab-content-users-online').style.display = 'grid';
document.getElementById('tab-content-documents-opened').style.display = 'none';
}
-</script> \ No newline at end of file
+</script>
diff --git a/loleaflet/admin/admin.strings.js b/loleaflet/admin/admin.strings.js
index 059ac46ba4..84f73e0e71 100644
--- a/loleaflet/admin/admin.strings.js
+++ b/loleaflet/admin/admin.strings.js
@@ -26,6 +26,7 @@ l10nstrings.strViewers = _('Views');
l10nstrings.strElapsedTime = _('Elapsed time');
l10nstrings.strIdleTime = _('Idle time');
l10nstrings.strModified = _('Modified');
+l10nstrings.strWopihost = _('WOPI host');
l10nstrings.strKill = _('Kill');
l10nstrings.strGraphs = _('Graphs');
l10nstrings.strMemoryGraph = _('Memory Graph');
diff --git a/loleaflet/admin/src/AdminSocketOverview.js b/loleaflet/admin/src/AdminSocketOverview.js
index 7d6f52b6d0..2e2c4c9d5c 100644
--- a/loleaflet/admin/src/AdminSocketOverview.js
+++ b/loleaflet/admin/src/AdminSocketOverview.js
@@ -76,7 +76,7 @@ function createDocumentUserListElement(cell, doc) {
}
}
-function upsertDocsTable(doc, sName, socket) {
+function upsertDocsTable(doc, sName, socket, wopiHost) {
var add = false;
var row = document.getElementById('doc' + doc['pid']);
if (row === undefined || row === null) {
@@ -105,6 +105,11 @@ function upsertDocsTable(doc, sName, socket) {
dialog.open();
};
+ var wopiHostCell = document.createElement('td');
+ wopiHostCell.innerText = wopiHost;
+ if (add === true) { row.appendChild(wopiHostCell); } else { row.cells[0] = wopiHostCell; }
+ wopiHostCell.className = 'has-text-left';
+
if (add === true) {
var userInfoCell = document.createElement('td');
userInfoCell.className = 'has-text-left';
@@ -162,7 +167,7 @@ function upsertDocsTable(doc, sName, socket) {
}
}
-function upsertUsersTable(docPid, sName, userList) {
+function upsertUsersTable(docPid, sName, userList, wopiHost) {
for (var i = 0; i < userList.length; i++) {
var encodedUId = encodeURI(userList[i]['userId']);
var row = document.getElementById('usr' + encodedUId);
@@ -172,6 +177,10 @@ function upsertUsersTable(docPid, sName, userList) {
row.id = 'usr' + encodedUId;
document.getElementById('userlist').appendChild(row);
+ var wopiHostCell = document.createElement('td');
+ wopiHostCell.innerText = wopiHost;
+ row.appendChild(wopiHostCell);
+
var userNameCell = document.createElement('td');
userNameCell.innerText = userList[i]['userName'];
row.appendChild(userNameCell);
@@ -257,8 +266,8 @@ var AdminSocketOverview = AdminSocketBase.extend({
for (var i = 0; i < docList.length; i++) {
sName = decodeURI(docList[i]['fileName']);
- upsertUsersTable(docList[i]['pid'], sName, docList[i]['views']);
- upsertDocsTable(docList[i], sName, this.socket);
+ upsertUsersTable(docList[i]['pid'], sName, docList[i]['views'], docList[i]['wopiHost']);
+ upsertDocsTable(docList[i], sName, this.socket, docList[i]['wopiHost']);
}
}
else if (textMsg.startsWith('resetidle')) {
@@ -277,14 +286,18 @@ var AdminSocketOverview = AdminSocketBase.extend({
'encodedUId': encodeURI(docProps[4]),
'userId': docProps[4],
'memory': docProps[5],
+ 'wopiHost': docProps[6],
'elapsedTime': '0',
'idleTime': '0',
'modified': 'No',
'views': [{ 'sessionid': docProps[2], 'userName': decodeURI(docProps[3]) }]
};
- upsertDocsTable(docProps, docProps['sName'], this.socket);
- upsertUsersTable(docProps['pid'], docProps['sName'], [docProps]);
+ if (typeof docProps['wopiHost'] === 'undefined') {
+ docProps['wopiHost'] = '';
+ }
+ upsertDocsTable(docProps, docProps['sName'], this.socket, docProps['wopiHost']);
+ upsertUsersTable(docProps['pid'], docProps['sName'], [docProps], docProps['wopiHost']);
document.getElementById('active_docs_count').innerText = String(parseInt(document.getElementById('active_docs_count').innerText) + 1);
document.getElementById('active_users_count').innerText = String(parseInt(document.getElementById('active_users_count')) + 1);
}
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 28f050e855..1a78bf25dc 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -526,9 +526,9 @@ void Admin::modificationAlert(const std::string& dockey, pid_t pid, bool value){
void Admin::addDoc(const std::string& docKey, pid_t pid, const std::string& filename,
const std::string& sessionId, const std::string& userName, const std::string& userId,
- const int smapsFD)
+ const int smapsFD, const std::string& wopiHost)
{
- addCallback([=] { _model.addDocument(docKey, pid, filename, sessionId, userName, userId, smapsFD); });
+ addCallback([=] { _model.addDocument(docKey, pid, filename, sessionId, userName, userId, smapsFD, wopiHost); });
}
void Admin::rmDoc(const std::string& docKey, const std::string& sessionId)
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index b44937a8f8..01f531337b 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -84,7 +84,7 @@ public:
/// Calls with same pid will increment view count, if pid already exists
void addDoc(const std::string& docKey, pid_t pid, const std::string& filename,
const std::string& sessionId, const std::string& userName, const std::string& userId,
- const int smapsFD);
+ const int smapsFD, const std::string& wopiHost);
/// Decrement view count till becomes zero after which doc is removed
void rmDoc(const std::string& docKey, const std::string& sessionId);
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 07b3886fb5..3fa02d66a7 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -505,11 +505,11 @@ void AdminModel::modificationAlert(const std::string& docKey, pid_t pid, bool va
void AdminModel::addDocument(const std::string& docKey, pid_t pid,
const std::string& filename, const std::string& sessionId,
const std::string& userName, const std::string& userId,
- const int smapsFD)
+ const int smapsFD, const std::string& wopiHost)
{
assertCorrectThread();
- const auto ret = _documents.emplace(docKey, std::unique_ptr<Document>(new Document(docKey, pid, filename)));
+ const auto ret = _documents.emplace(docKey, std::unique_ptr<Document>(new Document(docKey, pid, filename, wopiHost)));
ret.first->second->setProcSMapsFD(smapsFD);
ret.first->second->takeSnapshot();
ret.first->second->addView(sessionId, userName, userId);
@@ -550,6 +550,8 @@ void AdminModel::addDocument(const std::string& docKey, pid_t pid,
oss << _documents.begin()->second->getMemoryDirty();
}
+ oss << ' ' << wopiHost;
+
notify(oss.str());
}
@@ -769,6 +771,7 @@ std::string AdminModel::getDocuments() const
<< "\"pid\"" << ':' << it.second->getPid() << ','
<< "\"docKey\"" << ':' << '"' << it.second->getDocKey() << '"' << ','
<< "\"fileName\"" << ':' << '"' << encodedFilename << '"' << ','
+ << "\"wopiHost\"" << ':' << '"' << it.second -> getHostName() << '"' << ','
<< "\"activeViews\"" << ':' << it.second->getActiveViews() << ','
<< "\"memory\"" << ':' << it.second->getMemoryDirty() << ','
<< "\"elapsedTime\"" << ':' << it.second->getElapsedTime() << ','
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index f0b6dd15c3..a6f7a5bebf 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -134,11 +134,12 @@ class Document
Document& operator = (const Document &) = delete;
public:
- Document(std::string docKey, pid_t pid, std::string filename)
+ Document(std::string docKey, pid_t pid, std::string filename, std::string wopiHost)
: _docKey(std::move(docKey))
, _pid(pid)
, _activeViews(0)
, _filename(std::move(filename))
+ , _wopiHost(std::move(wopiHost))
, _memoryDirty(0)
, _lastJiffy(0)
, _lastCpuPercentage(0)
@@ -170,6 +171,8 @@ public:
std::string getFilename() const { return _filename; }
+ std::string getHostName() const { return _wopiHost; }
+
bool isExpired() const { return _end != 0 && std::time(nullptr) >= _end; }
std::time_t getElapsedTime() const { return std::time(nullptr) - _start; }
@@ -232,6 +235,8 @@ private:
unsigned _activeViews;
/// Hosted filename
std::string _filename;
+
+ std::string _wopiHost;
/// The dirty (ie. un-shared) memory of the document's Kit process.
size_t _memoryDirty;
/// Last noted Jiffy count
@@ -353,7 +358,7 @@ public:
void addDocument(const std::string& docKey, pid_t pid, const std::string& filename,
const std::string& sessionId, const std::string& userName, const std::string& userId,
- const int smapsFD);
+ const int smapsFD, const std::string& URI);
void removeDocument(const std::string& docKey, const std::string& sessionId);
void removeDocument(const std::string& docKey);
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fc673658c6..8ecdca93ee 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1935,8 +1935,12 @@ size_t DocumentBroker::addSessionInternal(const std::shared_ptr<ClientSession>&
#if !MOBILEAPP
// Tell the admin console about this new doc
+ std::string wopiHost = _storage->getUri().Poco::URI::getHost();
+ if (wopiHost.std::string::empty()) {
+ wopiHost = "";
+ }
Admin::instance().addDoc(_docKey, getPid(), getFilename(), id, session->getUserName(),
- session->getUserId(), _childProcess->getSMapsFD());
+ session->getUserId(), _childProcess->getSMapsFD(), wopiHost);
Admin::instance().setDocWopiDownloadDuration(_docKey, _wopiLoadDuration);
#endif