Add "manage" button on users, to open the account on instance manager URL

This commit is contained in:
Bofh 2022-12-14 23:44:03 +01:00
parent 717d1bba06
commit 695fefe5ab
3 changed files with 42 additions and 6 deletions

View File

@ -110,6 +110,10 @@ span.sr {
background: #ffb5b5; background: #ffb5b5;
color: #9d0202; color: #9d0202;
} }
.blue {
background: #b5d5ff;
color: #253d5e;
}
.green { .green {
background: #c2ffb5; background: #c2ffb5;
color: #386f2c; color: #386f2c;

View File

@ -175,13 +175,29 @@
<div class="only mastodon disable-able">{mastodon:fields}</div> <div class="only mastodon disable-able">{mastodon:fields}</div>
<div class="note">{note}</div> <div class="note">{note}</div>
<div style="margin-top: 1em; text-align: right;"> <div style="margin-top: 1em; text-align: right;">
<button style="float:left" onclick="if ({do.js}.users.trust_user('{acct}'))
<div style="float:left">
<button onclick="if ({do.js}.users.trust_user('{acct}'))
E.element('.item[data-id=&quot;{id}&quot;]').remove()" E.element('.item[data-id=&quot;{id}&quot;]').remove()"
class="btn mid green"><i class="fa fa-thumbs-up fa-fw"></i>Trust</button> title="Add this user to the trusted_users list"
class="btn mid green"><i class="fa fa-thumbs-up fa-fw"></i>
Trust</button>
<a href="{accountAdminLink}" target="_blank" rel="noreferrer noopener">
<button class="btn mid"
title="Open this account in the AP application manager"
><i class="fa fa-id-card fa-fw"></i>
Manage</button>
</a>
</div>
<button onclick="if ({do.js}.users.hide_on_filters('{acct}', 86400)) <button onclick="if ({do.js}.users.hide_on_filters('{acct}', 86400))
E.element('.item[data-id=&quot;{id}&quot;]').remove()" E.element('.item[data-id=&quot;{id}&quot;]').remove()"
class="btn mid"><i class="fa fa-clock-o fa-fw"></i>Hide 1 day</button> title="Hide the selected account for 1 day (24 hours)"
class="btn mid"><i class="fa fa-clock-o fa-fw"></i>
Hide 1d</button>
<button onclick=" <button onclick="
if ('' === '{disabledClass}') { if ('' === '{disabledClass}') {
@ -191,13 +207,17 @@
this.setAttribute('disabled', 'true'); this.setAttribute('disabled', 'true');
} }
}" }"
title="Silence this user on the instance"
class="btn mid disable-able" {disabledHTML}> class="btn mid disable-able" {disabledHTML}>
<i class="fa fa-volume-mute fa-fw"></i><span>{silencedText}</span></button> <i class="fa fa-volume-mute fa-fw"></i>
<span>{silencedText}</span></button>
<button onclick="if ({do.js}.users.suspend('{id}')) { <button onclick="if ({do.js}.users.suspend('{id}')) {
E.element('.item[data-id=&quot;{id}&quot;]').classList.add('suspended'); E.element('.item[data-id=&quot;{id}&quot;]').classList.add('suspended');
this.querySelector('span'),innerText = 'Suspended'}" this.querySelector('span'),innerText = 'Suspended'}"
class="btn mid red"><i class="fa fa-ban fa-fw"></i><span>Suspend</span></button> title="Suspend this user on the instance"
class="btn mid red"><i class="fa fa-ban fa-fw"></i>
<span>Suspend</span></button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,6 +15,16 @@
<script> <script>
window.view.instance = { window.view.instance = {
get_config: function() {
var config = {};
const hdict = window.vars.current_instance.config.trim().split('\n');
for (var i = 0; i < hdict.length; i++) {
const k = hdict[i].substr(0, hdict[i].indexOf('=')).trim();
const v = hdict[i].substr(hdict[i].indexOf('=')+1).trim();
config[k] = v;
}
return config;
},
show_config: function() { show_config: function() {
window.location.hash = window.location.hash.replace('#instance/','#instance_config/'); window.location.hash = window.location.hash.replace('#instance/','#instance_config/');
}, },
@ -303,6 +313,8 @@ window.view.instance = {
tpl = tpl.replaceAll('{disabledHTML}', it.silenced === true ? 'disabled="true"' : ''); tpl = tpl.replaceAll('{disabledHTML}', it.silenced === true ? 'disabled="true"' : '');
tpl = tpl.replaceAll('{silencedText}', it.silenced === true ? 'Silenced' : 'Silence'); tpl = tpl.replaceAll('{silencedText}', it.silenced === true ? 'Silenced' : 'Silence');
if (hargs.software === 'mastodon') { if (hargs.software === 'mastodon') {
const instance_url = window.view.instance.get_config().instance_url;
tpl = tpl.replaceAll('{accountAdminLink}', instance_url+'/admin/accounts/'+it.id);
if (![null, undefined].includes(it.fields)) { if (![null, undefined].includes(it.fields)) {
var _fields = '<table class="fields"><tbody>'; var _fields = '<table class="fields"><tbody>';
for (var j = 0; j < it.fields.length; j++) { for (var j = 0; j < it.fields.length; j++) {