From 10fab2b47f8dd4619f0864726b3930a4b71ebc08 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 9 Dec 2019 23:21:24 +0000 Subject: [PATCH] certification in view by table --- webui/src/main/js/filesTable.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/webui/src/main/js/filesTable.js b/webui/src/main/js/filesTable.js index ef06e5c5..69ac3539 100644 --- a/webui/src/main/js/filesTable.js +++ b/webui/src/main/js/filesTable.js @@ -1,8 +1,9 @@ class SharedFile { - constructor(name, size, comment) { + constructor(name, size, comment, certified) { this.name = name this.size = size this.comment = comment + this.certified = certified } } @@ -57,20 +58,27 @@ function refreshTable() { comment = comment[0].childNodes[0].nodeValue else comment = null + var certified = files[i].getElementsByTagName("Certified")[0].childNodes[0].nodeValue var nodeId = Base64.encode(fileName) - var newSharedFile = new SharedFile(fileName, size, comment) + var newSharedFile = new SharedFile(fileName, size, comment, certified) filesByPath.set(nodeId, newSharedFile) } for (var [path, file] of filesByPath) { - var unshareLink = "Unshare" + var unshareLink = "" + _t("Unshare") + "" + + var certifyLink = "" + _t("Certify") + "" + var certified = "" + if (file.certified == "true") + certified = _t("Certified") var commentLink = "" + generateCommentLink(path) + "" tableHtml += "" - tableHtml += ""+file.name+"
" + unshareLink + commentLink + "
" + tableHtml += ""+file.name+"
" + unshareLink + " " + certifyLink + " " + certified + " " + + commentLink + "
" tableHtml += ""+file.size+"" tableHtml += ""+(file.comment != null)+"" tableHtml += "" @@ -149,3 +157,15 @@ function saveComment(fileId) { function generateCommentLink(nodeId) { return "" + _t("Comment") + "" } + +function certify(path) { + var xmlhttp = new XMLHttpRequest() + xmlhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + refreshTable() + } + } + xmlhttp.open("POST", "/MuWire/Certificate", true) + xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xmlhttp.send("action=certify&file=" + path) +} \ No newline at end of file