mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
add login/permissions indicator
This commit is contained in:
parent
f9be4c62b1
commit
0194eeb31f
|
@ -1653,6 +1653,7 @@ class HttpCli(object):
|
||||||
"files": [],
|
"files": [],
|
||||||
"taglist": [],
|
"taglist": [],
|
||||||
"srvinf": srv_info,
|
"srvinf": srv_info,
|
||||||
|
"acct": self.uname,
|
||||||
"perms": perms,
|
"perms": perms,
|
||||||
"logues": logues,
|
"logues": logues,
|
||||||
}
|
}
|
||||||
|
@ -1660,6 +1661,7 @@ class HttpCli(object):
|
||||||
"vdir": quotep(self.vpath),
|
"vdir": quotep(self.vpath),
|
||||||
"vpnodes": vpnodes,
|
"vpnodes": vpnodes,
|
||||||
"files": [],
|
"files": [],
|
||||||
|
"acct": self.uname,
|
||||||
"perms": json.dumps(perms),
|
"perms": json.dumps(perms),
|
||||||
"taglist": [],
|
"taglist": [],
|
||||||
"tag_order": [],
|
"tag_order": [],
|
||||||
|
|
|
@ -211,15 +211,39 @@ a, #files tbody div a:last-child {
|
||||||
margin: .8em 0;
|
margin: .8em 0;
|
||||||
}
|
}
|
||||||
#srv_info {
|
#srv_info {
|
||||||
opacity: .5;
|
color: #a73;
|
||||||
font-size: .8em;
|
background: #333;
|
||||||
color: #fc5;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: .5em;
|
font-size: .8em;
|
||||||
|
top: .5em;
|
||||||
left: 2em;
|
left: 2em;
|
||||||
|
padding-right: .5em;
|
||||||
}
|
}
|
||||||
#srv_info span {
|
#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 {
|
#files tbody a.play {
|
||||||
color: #e70;
|
color: #e70;
|
||||||
|
@ -1001,10 +1025,14 @@ html.light .tgl.btn.on {
|
||||||
}
|
}
|
||||||
html.light #srv_info {
|
html.light #srv_info {
|
||||||
color: #c83;
|
color: #c83;
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
html.light #srv_info,
|
||||||
|
html.light #acc_info {
|
||||||
text-shadow: 1px 1px 0 #fff;
|
text-shadow: 1px 1px 0 #fff;
|
||||||
}
|
}
|
||||||
html.light #srv_info span {
|
html.light #srv_info span {
|
||||||
color: #000;
|
color: #777;
|
||||||
}
|
}
|
||||||
html.light #treeul a+a {
|
html.light #treeul a+a {
|
||||||
background: inherit;
|
background: inherit;
|
||||||
|
|
|
@ -121,7 +121,8 @@
|
||||||
<div id="widget"></div>
|
<div id="widget"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var perms = {{ perms }},
|
var acct = "{{ acct }}",
|
||||||
|
perms = {{ perms }},
|
||||||
tag_order_cfg = {{ tag_order }},
|
tag_order_cfg = {{ tag_order }},
|
||||||
have_up2k_idx = {{ have_up2k_idx|tojson }},
|
have_up2k_idx = {{ have_up2k_idx|tojson }},
|
||||||
have_tags_idx = {{ have_tags_idx|tojson }},
|
have_tags_idx = {{ have_tags_idx|tojson }},
|
||||||
|
|
|
@ -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 thegrid = (function () {
|
||||||
var lfiles = ebi('files'),
|
var lfiles = ebi('files'),
|
||||||
gfiles = mknod('div');
|
gfiles = mknod('div');
|
||||||
|
@ -2434,6 +2441,7 @@ var treectl = (function () {
|
||||||
if (this.hpush)
|
if (this.hpush)
|
||||||
hist_push(this.top);
|
hist_push(this.top);
|
||||||
|
|
||||||
|
acct = res.acct;
|
||||||
apply_perms(res.perms);
|
apply_perms(res.perms);
|
||||||
despin('#files');
|
despin('#files');
|
||||||
despin('#gfiles');
|
despin('#gfiles');
|
||||||
|
@ -2550,6 +2558,10 @@ function despin(sel) {
|
||||||
function apply_perms(newperms) {
|
function apply_perms(newperms) {
|
||||||
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');
|
var o = QSA('#ops>a[data-perm], #u2footfoot');
|
||||||
for (var a = 0; a < o.length; a++) {
|
for (var a = 0; a < o.length; a++) {
|
||||||
var display = '';
|
var display = '';
|
||||||
|
@ -2573,12 +2585,10 @@ function apply_perms(newperms) {
|
||||||
de = document.documentElement,
|
de = document.documentElement,
|
||||||
tds = QSA('#u2conf td');
|
tds = QSA('#u2conf td');
|
||||||
|
|
||||||
/* good idea maybe
|
|
||||||
clmod(de, "read", have_read);
|
clmod(de, "read", have_read);
|
||||||
clmod(de, "write", have_write);
|
clmod(de, "write", have_write);
|
||||||
clmod(de, "nread", !have_read);
|
clmod(de, "nread", !have_read);
|
||||||
clmod(de, "nwrite", !have_write);
|
clmod(de, "nwrite", !have_write);
|
||||||
*/
|
|
||||||
|
|
||||||
for (var a = 0; a < tds.length; a++) {
|
for (var a = 0; a < tds.length; a++) {
|
||||||
tds[a].style.display =
|
tds[a].style.display =
|
||||||
|
|
|
@ -462,6 +462,9 @@ function U2pvis(act, btns) {
|
||||||
|
|
||||||
function fsearch_explain(e) {
|
function fsearch_explain(e) {
|
||||||
ev(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');
|
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) {
|
if (!response || !response.hits || !response.hits.length) {
|
||||||
smsg = '404';
|
smsg = '404';
|
||||||
msg = 'not found on server';
|
msg = 'not found on server <a href="#" onclick="fsearch_explain()" class="fsearch_explain">(explain)</a>';
|
||||||
if (has(perms, 'write'))
|
|
||||||
msg += ' <a href="#" onclick="fsearch_explain()" class="fsearch_explain">(explain)</a>';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
smsg = 'found';
|
smsg = 'found';
|
||||||
|
|
Loading…
Reference in a new issue