From c061461d01c0b9f20ce4f3b7ae44fcb190e6d946 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 13 May 2021 17:22:31 +0200 Subject: [PATCH] fix md perm reqs + dyn up2k modeset --- copyparty/httpcli.py | 9 ++++++--- copyparty/web/browser.html | 2 +- copyparty/web/browser.js | 23 +++++++++++------------ copyparty/web/up2k.js | 14 +++++++++----- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 1adabe6a..673a2eb2 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -120,6 +120,8 @@ class HttpCli(object): else: uparam[k.lower()] = False + self.ouparam = {k: v for k, v in uparam.items()} + cookies = self.headers.get("cookie") or {} if cookies: cookies = [x.split("=", 1) for x in cookies.split(";") if "=" in x] @@ -273,7 +275,7 @@ class HttpCli(object): return self.tx_tree() # conditional redirect to single volumes - if self.vpath == "" and not self.uparam: + if self.vpath == "" and not self.ouparam: nread = len(self.rvol) nwrite = len(self.wvol) if nread + nwrite == 1 or (self.rvol == self.wvol and nread == 1): @@ -282,8 +284,9 @@ class HttpCli(object): else: vpath = self.wvol[0] - self.redirect(vpath, flavor="redirecting to", use302=True) - return True + if self.vpath != vpath: + self.redirect(vpath, flavor="redirecting to", use302=True) + return True self.readable, self.writable = self.conn.auth.vfs.can_access( self.vpath, self.uname diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html index 541c6202..2bede24a 100644 --- a/copyparty/web/browser.html +++ b/copyparty/web/browser.html @@ -21,7 +21,7 @@ {%- endif %} 🎈 📂 - 📝 + 📝 📟 ⚙️
diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index d5811b94..9588b48b 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1307,21 +1307,20 @@ function apply_perms(perms) { perms = perms || []; var o = QSA('#ops>a[data-perm]'); - for (var a = 0; a < o.length; a++) - o[a].style.display = 'none'; - - for (var a = 0; a < perms.length; a++) { - o = QSA('#ops>a[data-perm="' + perms[a] + '"]'); - for (var b = 0; b < o.length; b++) - o[b].style.display = 'inline'; + for (var a = 0; a < o.length; a++) { + var display = 'inline'; + var needed = o[a].getAttribute('data-perm').split(' '); + for (var b = 0; b < needed.length; b++) { + if (!has(perms, needed[b])) { + display = 'none'; + } + } + o[a].style.display = display; } var act = QS('#ops>a.act'); - if (act) { - var areq = act.getAttribute('data-perm'); - if (areq && !has(perms, areq)) - goto(); - } + if (act && act.style.display === 'none') + goto(); document.body.setAttribute('perms', perms.join(' ')); diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 31b54fcc..92ead14b 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -1309,15 +1309,19 @@ function up2k_init(have_crypto) { } function set_fsearch(new_state) { - var perms = document.body.getAttribute('perms'), - read_only = false; + var perms = (document.body.getAttribute('perms') + '').split(' '), + fixed = false; if (!ebi('fsearch')) { new_state = false; } - else if (perms && perms.indexOf('write') === -1) { + else if (!has(perms, 'write')) { new_state = true; - read_only = true; + fixed = true; + } + else if (!has(perms, 'read')) { + new_state = false; + fixed = true; } if (new_state !== undefined) { @@ -1326,7 +1330,7 @@ function up2k_init(have_crypto) { } try { - QS('label[for="fsearch"]').style.opacity = read_only ? '0' : '1'; + QS('label[for="fsearch"]').style.display = QS('#fsearch').style.display = fixed ? 'none' : ''; } catch (ex) { }