From 862967bf8ee4cd4bb707af5f28591600c48972b4 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 27 Mar 2020 15:14:36 +0000 Subject: [PATCH] configure panel for directories --- webui/src/main/css/muwire.css | 28 ++++++++++ .../src/main/java/com/muwire/webui/Util.java | 3 ++ webui/src/main/js/advancedSharing.js | 52 ++++++++++++++++++- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/webui/src/main/css/muwire.css b/webui/src/main/css/muwire.css index f30520f5..e60d9919 100644 --- a/webui/src/main/css/muwire.css +++ b/webui/src/main/css/muwire.css @@ -256,6 +256,34 @@ div#itemsTable table tbody td:nth-child(1) { text-overflow: ellipsis; } +div#dirConfig table * { + background: #bcd1e5 !important; +} +div#dirConfig table { + border-collapse: collapse; + width: auto; +} +div#dirConfig table td { + padding-left: 10px; + padding-right: 10px; + padding-top: 5px; + padding-bottom: 5px; +} + +div#dirsTable table thead th:nth-child(2) { + width: 80px; +} +div#dirsTable table thead th:nth-child(3) { + width: 80px; +} +div#dirsTable table thead th:nth-child(4) { + width: 170px; +} +div#dirsTable table tbody td:nth-child(1) { + text-overflow: ellipsis; + overflow: auto; +} + div#hitsTable table thead th:nth-child(1) { width: 270px; } diff --git a/webui/src/main/java/com/muwire/webui/Util.java b/webui/src/main/java/com/muwire/webui/Util.java index f533f0d3..e86437cc 100644 --- a/webui/src/main/java/com/muwire/webui/Util.java +++ b/webui/src/main/java/com/muwire/webui/Util.java @@ -45,6 +45,8 @@ public class Util { _x("Copy To Clipbaord"), _x("Default settings for new feeds"), _x("Details for {0}"), + _x("Directory configuration for {0}"), + _x("Directory sync frequency (seconds, 0 means never)"), _x("Distrusted"), _x("Distrusted User"), _x("Down"), @@ -138,6 +140,7 @@ public class Util { _x("User"), _x("View 1 Certificate"), _x("View {0} Certificates"), + _x("Watch directory for changes using operating system"), _x("Your full MuWire id is"), _x("Your short MuWire id is {0}"), _x("Your Trust"), diff --git a/webui/src/main/js/advancedSharing.js b/webui/src/main/js/advancedSharing.js index 3e4989ea..2692156c 100644 --- a/webui/src/main/js/advancedSharing.js +++ b/webui/src/main/js/advancedSharing.js @@ -1,6 +1,7 @@ class Directory { constructor(xmlNode) { this.directory = xmlNode.getElementsByTagName("Directory")[0].childNodes[0].nodeValue + this.path = Base64.encode(this.directory) this.autoWatch = xmlNode.getElementsByTagName("AutoWatch")[0].childNodes[0].nodeValue this.syncInterval = xmlNode.getElementsByTagName("SyncInterval")[0].childNodes[0].nodeValue this.lastSync = xmlNode.getElementsByTagName("LastSync")[0].childNodes[0].nodeValue @@ -9,7 +10,11 @@ class Directory { getMapping() { var mapping = new Map() - mapping.set("Directory", this.directory) + var configLink = new Link(_t("Configure"), "configure", [this.path]) + var divRight = "" + + mapping.set("Directory", this.directory + divRight) mapping.set("Auto Watch", this.autoWatch) mapping.set("Last Sync", this.lastSync) mapping.set("Sync Interval", this.syncInterval) @@ -42,11 +47,14 @@ function refreshDirs() { var xmlhttp = new XMLHttpRequest() xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { + pathToDir.clear() var listOfDirs = [] var dirNodes = this.responseXML.getElementsByTagName("WatchedDir") var i for (i = 0; i < dirNodes.length; i ++) { - listOfDirs.push(new Directory(dirNodes[i])) + var dir = new Directory(dirNodes[i]) + listOfDirs.push(dir) + pathToDir.set(dir.path, dir) } var newOrder @@ -77,7 +85,47 @@ function sortDirs(key, order) { refreshDirs() } +function configure(path) { + var dir = pathToDir.get(path) + + var html = "
" + html += "

" + _t("Directory configuration for {0}", dir.directory) + "

" + + html += "" + + html += "" + html += "" + html += "" + html += "" + + html += "
" + _t("Watch directory for changes using operating system") + "

" + html += "

" + + html += "" + html += "" + + html += "" + html += "" + _t("Cancel") + "" + html += "
" + + var tableDiv = document.getElementById("dirConfig") + tableDiv.innerHTML = html +} + +function cancelConfig() { + var tableDiv = document.getElementById("dirConfig") + tableDiv.innerHTML = "" +} + var revision = -1 +var pathToDir = new Map() var sortKey = "Directory" var sortOrder = "descending" \ No newline at end of file