add login/permissions indicator

This commit is contained in:
ed 2021-07-20 22:42:03 +02:00
parent f9be4c62b1
commit 0194eeb31f
5 changed files with 54 additions and 12 deletions

View file

@ -1653,6 +1653,7 @@ class HttpCli(object):
"files": [],
"taglist": [],
"srvinf": srv_info,
"acct": self.uname,
"perms": perms,
"logues": logues,
}
@ -1660,6 +1661,7 @@ class HttpCli(object):
"vdir": quotep(self.vpath),
"vpnodes": vpnodes,
"files": [],
"acct": self.uname,
"perms": json.dumps(perms),
"taglist": [],
"tag_order": [],

View file

@ -211,15 +211,39 @@ a, #files tbody div a:last-child {
margin: .8em 0;
}
#srv_info {
opacity: .5;
font-size: .8em;
color: #fc5;
color: #a73;
background: #333;
position: absolute;
top: .5em;
font-size: .8em;
top: .5em;
left: 2em;
padding-right: .5em;
}
#srv_info span {
color: #fff;
color: #aaa;
}
#acc_info {
position: absolute;
font-size: .81em;
top: .5em;
right: 2em;
color: #999;
}
#acc_info span:before {
color: #f4c;
border-bottom: 1px solid rgba(255,68,204,0.6);
margin-right: .6em;
}
html.read #acc_info span:before {
content: 'Read-Only access';
}
html.write #acc_info span:before {
content: 'Write-Only access';
}
html.read.write #acc_info span:before {
content: 'Read-Write access';
color: #999;
border: none;
}
#files tbody a.play {
color: #e70;
@ -1001,10 +1025,14 @@ html.light .tgl.btn.on {
}
html.light #srv_info {
color: #c83;
background: #eee;
}
html.light #srv_info,
html.light #acc_info {
text-shadow: 1px 1px 0 #fff;
}
html.light #srv_info span {
color: #000;
color: #777;
}
html.light #treeul a+a {
background: inherit;

View file

@ -121,7 +121,8 @@
<div id="widget"></div>
<script>
var perms = {{ perms }},
var acct = "{{ acct }}",
perms = {{ perms }},
tag_order_cfg = {{ tag_order }},
have_up2k_idx = {{ have_up2k_idx|tojson }},
have_tags_idx = {{ have_tags_idx|tojson }},

View file

@ -1452,6 +1452,13 @@ function play_linked() {
};
(function () {
var d = mknod('div');
d.setAttribute('id', 'acc_info');
document.body.insertBefore(d, ebi('ops'));
})();
var thegrid = (function () {
var lfiles = ebi('files'),
gfiles = mknod('div');
@ -2434,6 +2441,7 @@ var treectl = (function () {
if (this.hpush)
hist_push(this.top);
acct = res.acct;
apply_perms(res.perms);
despin('#files');
despin('#gfiles');
@ -2550,6 +2558,10 @@ function despin(sel) {
function apply_perms(newperms) {
perms = newperms || [];
ebi('acc_info').innerHTML = '<span>' + (acct != '*' ?
'<a href="?pw=x">Logout ' + acct + '</a>' :
'<a href="?h">Login</a>') + '</span>';
var o = QSA('#ops>a[data-perm], #u2footfoot');
for (var a = 0; a < o.length; a++) {
var display = '';
@ -2573,12 +2585,10 @@ function apply_perms(newperms) {
de = document.documentElement,
tds = QSA('#u2conf td');
/* good idea maybe
clmod(de, "read", have_read);
clmod(de, "write", have_write);
clmod(de, "nread", !have_read);
clmod(de, "nwrite", !have_write);
*/
for (var a = 0; a < tds.length; a++) {
tds[a].style.display =

View file

@ -462,6 +462,9 @@ function U2pvis(act, btns) {
function fsearch_explain(e) {
ev(e);
if (!has(perms, 'write'))
return alert('your access to this folder is Read-Only\n\n' + (acct == '*' ? 'you are currently not logged in' : 'you are currently logged in as ' + acct));
alert('you are currently in file-search mode\n\nswitch to upload-mode by clicking the green magnifying glass (next to the big yellow search button), and then refresh\n\nsorry');
}
@ -1297,9 +1300,7 @@ function up2k_init(subtle) {
if (!response || !response.hits || !response.hits.length) {
smsg = '404';
msg = 'not found on server';
if (has(perms, 'write'))
msg += ' <a href="#" onclick="fsearch_explain()" class="fsearch_explain">(explain)</a>';
msg = 'not found on server <a href="#" onclick="fsearch_explain()" class="fsearch_explain">(explain)</a>';
}
else {
smsg = 'found';