loleaflet/admin.strings.js | 2 loleaflet/dist/admin/admin.html | 66 +++++++--- loleaflet/dist/admin/bootstrap/dashboard.css | 28 +++- loleaflet/src/admin/AdminSocketOverview.js | 163 +++++++++++++++++++++++++-- 4 files changed, 224 insertions(+), 35 deletions(-)
New commits: commit 6cb5ec34b9765f60a93723e0eba65aa3ad67a002 Author: Aditya Dewan <iit2015...@iiita.ac.in> Date: Thu May 25 14:24:09 2017 +0530 tdf#106449 Admin console: adding user list Reviewed-on: https://gerrit.libreoffice.org/38017 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> (cherry picked from commit 66a3e1c273c9f967d650e65d40e9d16e3b8454d1) Change-Id: Ic8c2a833c8fd0605336e16642c26f9b7bf8a5fbc Reviewed-on: https://gerrit.libreoffice.org/38570 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/loleaflet/admin.strings.js b/loleaflet/admin.strings.js index 6a5e2d39..d8a02918 100644 --- a/loleaflet/admin.strings.js +++ b/loleaflet/admin.strings.js @@ -10,7 +10,9 @@ l10nstrings.strCurrent = _('(current)'); l10nstrings.strAnalytics = _('Analytics'); l10nstrings.strDashboard = _('Dashboard'); l10nstrings.strUsersOnline = _('Users online'); +l10nstrings.strUserName = _('Users Name'); l10nstrings.strDocumentsOpened = _('Documents opened'); +l10nstrings.strDocumentNumber = _('Number of Documents'); l10nstrings.strMemoryConsumed = _('Memory consumed'); l10nstrings.strPid = _('PID'); l10nstrings.strDocument = _('Document'); diff --git a/loleaflet/dist/admin/admin.html b/loleaflet/dist/admin/admin.html index 59e63507..2409e4f2 100644 --- a/loleaflet/dist/admin/admin.html +++ b/loleaflet/dist/admin/admin.html @@ -77,28 +77,56 @@ <h4><script>document.write(l10nstrings.strMemoryConsumed)</script></h4> </div> </div> + <div class="container"> + <ul class="nav nav-tabs"> + <li class="active"> + <a href="#view1" data-toggle="tab"> + <h4><script>document.write(l10nstrings.strDocumentsOpened)</script></h4> + </a> + </li> + <li> + <a href="#view2" data-toggle="tab"> + <h4><script>document.write(l10nstrings.strUsersOnline)</script></h4> + </a> + </li> + </ul> - <h2 class="sub-header"><script>document.write(l10nstrings.strDocumentsOpened)</script></h2> - <div class="table-responsive"> - <table class="table table-striped"> - <thead> - <tr> - <th><script>document.write(l10nstrings.strPid)</script></th> - <th><script>document.write(l10nstrings.strDocument)</script></th> - <th><script>document.write(l10nstrings.strNumberOfViews)</script></th> - <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"> - </tbody> - </table> - </div> - </div> + <div class="tab-content"> + <div id="view1" class="active tab-pane table-responsive"> + <table id="docview" class="table table-striped"> + <thead> + <tr> + <th><script>document.write(l10nstrings.strPid)</script></th> + <th><script>document.write(l10nstrings.strDocument)</script></th> + <th><script>document.write(l10nstrings.strNumberOfViews)</script></th> + <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"> + </tbody> + </table> + </div> + + <div id="view2" class="tab-pane table-responsive"> + <table id="userview" class="tab-pane table table-striped"> + <thead> + <tr> + <th><script>document.write(l10nstrings.strUserName)</script></th> + <th><script>document.write(l10nstrings.strDocumentNumber)</script></th> + <th><script>document.write(l10nstrings.strDocumentsOpened)</script></th> + </tr> + </thead> + <tbody id="userlist"> + </tbody> + </table> + </div> </div> </div> + </div> +</div> <div id="rowContextMenu" class="dropdown clearfix"> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;"> diff --git a/loleaflet/dist/admin/bootstrap/dashboard.css b/loleaflet/dist/admin/bootstrap/dashboard.css index 60ed98d2..cdf37a82 100644 --- a/loleaflet/dist/admin/bootstrap/dashboard.css +++ b/loleaflet/dist/admin/bootstrap/dashboard.css @@ -113,15 +113,29 @@ body { position: absolute; display: none; } - .userContainer{ - display: none; position: absolute; - border: 1px solid black; - padding: 5px; - border-radius: 4px; - background-color: #dddddd; } -tr:hover .userContainer{ +tr:hover .dropdown-menu{ display: block; +} + +/* + * User list view + */ +.view-opt-button{ + border: 1px solid lightgrey; + border-radius: 5px; + padding: 4px 5px; + cursor: pointer; + transition: background-color .3s; +} +.view-opt-button:hover{ + background-color: #f5f5f5; +} +.selected-view-opt{ + background-color: #f5f5f5; +} +.doc_list_label{ + cursor: pointer; } \ No newline at end of file diff --git a/loleaflet/src/admin/AdminSocketOverview.js b/loleaflet/src/admin/AdminSocketOverview.js index b1070fcd..dfb92b64 100644 --- a/loleaflet/src/admin/AdminSocketOverview.js +++ b/loleaflet/src/admin/AdminSocketOverview.js @@ -47,7 +47,7 @@ var AdminSocketOverview = AdminSocketBase.extend({ }, 1000); // Allow table rows to have a context menu for terminating sessions - $('body').on('contextmenu', 'table tr', function(ev) { + $('body').on('contextmenu', '#docview tr', function(ev) { $('#rowContextMenu').css({ display: 'block', left: ev.pageX, @@ -73,6 +73,25 @@ var AdminSocketOverview = AdminSocketBase.extend({ } }); }); + + $('.view-opt-button').on('click', function() { + $('#docview-btn').toggleClass('selected-view-opt'); + $('#userview-btn').toggleClass('selected-view-opt'); + $('#docview').toggle(); + $('#userview').toggle(); + }); + + $('body').on('click', '#userlist .doc_list_label', function() { + if ($(this).text() === 'ð¢ list') { + docName = $($('.docentry', $(this).parent())[0]).text(); + $user = $(this).parent().parent(); + docCount = parseInt($('.doc_number', $user).text()) - 1 ; + $(this).text('𡺠' + docName + ' and ' + String(docCount) + ' other docs'); + } + else + $(this).text('ð¢ list'); + $('.docentry', $(this).parent()).toggle(); + }); }, onSocketMessage: function(e) { @@ -108,12 +127,66 @@ var AdminSocketOverview = AdminSocketBase.extend({ $rowContainer = $(document.createElement('tr')).attr('id', 'doc' + sPid); $pid = $(document.createElement('td')).text(sPid); $userContainer = $(document.createElement('div')).attr('id', 'ucontainer' + sPid) - .addClass('userContainer'); + .addClass('userContainer dropdown'); + $listContainer = $(document.createElement('ul')).addClass('dropdown-menu'); + $listLabel = $(document.createElement('li')).addClass('dropdown-header') + .text('Users'); + $listContainer.append($listLabel); + for (var j = 0; j < userListJson.length; j++) { - $user = $(document.createElement('div')).text(userListJson[j]['userName']) - .attr('id', 'user' + userListJson[j]['sessionid']); - $userContainer.append($user); + $user = $(document.createElement('li')).attr('id', 'user' + userListJson[j]['sessionid']); + $userA = $(document.createElement('a')).text(userListJson[j]['userName']); + $user.append($userA); + $listContainer.append($user); + + sessionid = userListJson[j]['sessionid']; + encodedUName = userListJson[j]['userName'].replace(/ /g, ''); + // this isn't the right way to do this, but we can't also use encode here. what should we do then. + + $userListRow = $('#usr' + encodedUName); + + if ($userListRow.length == 0) { + + $userListRow = $(document.createElement('tr')).attr('id', 'usr' + encodedUName); + + $uName = $(document.createElement('td')).text(userListJson[j]['userName']); + $userListRow.append($uName); + + $noOfDocuments = $(document.createElement('td')).addClass('doc_number') + .text('1'); + $userListRow.append($noOfDocuments); + + $docList = $(document.createElement('td')).addClass('doc_list'); + $docLabel = $(document.createElement('div')).addClass('doc_list_label'); + $docentry = $(document.createElement('div')).addClass('docentry') + .attr('id', sessionid + '_' + sPid) + .text(sName); + $docList.append($docLabel); + $docList.append($docentry); + $userListRow.append($docList); + + $('#userlist').append($userListRow); + } + else { + userListChildren = $userListRow[0].childNodes; + + docCount = parseInt($(userListChildren[1]).text()) + $(userListChildren[1]).text(docCount + 1); + + $docLabel = $(userListChildren[2].getElementsByClassName('doc_list_label')[0]); + $docLabel.text('𡺠' + sName + ' and ' + String(docCount) + ' other docs'); + + $('.docentry', $('userListChildren[2]').hide()); + + $docentry = $(document.createElement('div')).addClass('docentry') + .attr('id', sessionid + '_' + sPid) + .text(sName); + + $(userListChildren[2]).append($docentry); + $('.docentry', $userListRow).css('display', 'none'); + } } + $userContainer.append($listContainer); $pid.append($userContainer); $rowContainer.append($pid); @@ -168,7 +241,12 @@ var AdminSocketOverview = AdminSocketBase.extend({ $pid = $(document.createElement('td')).text(sPid); $userContainer = $(document.createElement('div')).attr('id', 'ucontainer' + sPid) - .addClass('userContainer'); + .addClass('userContainer dropdown'); + $listContainer = $(document.createElement('ul')).addClass('dropdown-menu'); + $listLabel = $(document.createElement('li')).addClass('dropdown-header') + .text('Users'); + $listContainer.append($listLabel); + $userContainer.append($listContainer); $pid.append($userContainer); $rowContainer.append($pid); @@ -208,13 +286,58 @@ var AdminSocketOverview = AdminSocketBase.extend({ $views.text(nViews + 1); $userContainer = $(document.getElementById('ucontainer' + sPid)); - $user = $(document.createElement('div')).text(uName) - .attr('id', 'user' + sessionid); - $userContainer.append($user); + $list = $('ul', $userContainer) + $user = $(document.createElement('li')).attr('id', 'user' + sessionid); + $userA = $(document.createElement('a')).text(uName); + $user.append($userA); + $list.append($user); + $userContainer.append($list); $a = $(document.getElementById('active_users_count')); nTotalViews = parseInt($a.text()); $a.text(nTotalViews + 1); + + + encodedUName = uName.replace(/ /g, ''); + $user = $('#usr' + encodedUName); + if ($user.length === 0) { + + $userListRow = $(document.createElement('tr')).attr('id', 'usr' + encodedUName); + + $uName = $(document.createElement('td')).text(uName); + $userListRow.append($uName); + + $noOfDocuments = $(document.createElement('td')).addClass('doc_number') + .text('1'); + $userListRow.append($noOfDocuments); + + $docList = $(document.createElement('td')).addClass('doc_list'); + $docLabel = $(document.createElement('div')).addClass('doc_list_label'); + $docentry = $(document.createElement('div')).addClass('docentry') + .attr('id', sessionid + '_' + sPid) + .text(sName); + $docList.append($docLabel); + $docList.append($docentry); + $userListRow.append($docList); + + $('#userlist').append($userListRow); + } + else { + userListChildren = $user[0].childNodes; + + docCount = parseInt($(userListChildren[1]).text()) + $(userListChildren[1]).text(docCount + 1); + + $docLabel = $(userListChildren[2].getElementsByClassName('doc_list_label')[0]); + $docLabel.text('𡺠' + sName + ' and ' + String(docCount) + ' other docs'); + + $docentry = $(document.createElement('div')).addClass('docentry') + .attr('id', sessionid + '_' + sPid) + .text(sName); + + $(userListChildren[2]).append($docentry); + $('.docentry', $(userListChildren[2])).hide(); + } } else if (textMsg.startsWith('total_mem') || textMsg.startsWith('active_docs_count') || @@ -249,6 +372,28 @@ var AdminSocketOverview = AdminSocketBase.extend({ nTotalViews = parseInt($a.text()); $a.text(nTotalViews - 1); } + + $docEntry = $('#' + sessionid + '_' + sPid); + $user = $docEntry.parent().parent(); + $nDocs = $('.doc_number', $user); + docCount = parseInt($nDocs.text()); + if (docCount == 1) { + $user.remove(); + } + else if (docCount == 2) { + $('.doc_list_label', $user).text(''); + $('.docentry', $user).show(); + $nDocs.text(docCount - 1); + $docEntry.remove(); + } + else { + $parent = $docEntry.parent() + $docEntry.remove(); + $child = $('.docentry', $parent); + $('.doc_list_label', $user).text('𡺠' + $($child[0]).text() + ' and ' + String(docCount - 2) + ' other docs') + $('.docentry', $user).hide(); + $nDocs.text(docCount - 1); + } } else if (textMsg.startsWith('propchange')) { textMsg = textMsg.substring('propchange'.length);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits