mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-09 18:08:00 +00:00
create append_table_row js function
This commit is contained in:
parent
ad17fb64f1
commit
31f5decc4a
|
@ -27,6 +27,24 @@ function get_date_string(date) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function append_table_row(table, row_name, row) {
|
||||||
|
var table_row = table.insertRow(-1);
|
||||||
|
table_row.id = row_name;
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
for (var prop in row) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(row, prop)) {
|
||||||
|
var cell = table_row.insertCell(index);
|
||||||
|
cell.className = prop;
|
||||||
|
cell.innerHTML = row[prop];
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.token = get_cookie("user-token");
|
this.token = get_cookie("user-token");
|
||||||
|
|
|
@ -40,20 +40,11 @@ async function ban() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var row = table.insertRow(-1);
|
append_table_row(document.getElementById("instances"), ban.domain, {
|
||||||
row.id = ban.domain;
|
domain: create_ban_object(ban.domain, ban.reason, ban.note),
|
||||||
|
date: get_date_string(ban.created),
|
||||||
var new_domain = row.insertCell(0);
|
remove: `<a href="#" onclick="unban('${ban.domain}')" title="Unban domain">✖</a>`
|
||||||
var new_date = row.insertCell(1);
|
});
|
||||||
var new_remove = row.insertCell(2);
|
|
||||||
|
|
||||||
new_domain.className = "domain";
|
|
||||||
new_date.className = "date";
|
|
||||||
new_remove.className = "remove";
|
|
||||||
|
|
||||||
new_domain.innerHTML = create_ban_object(ban.domain, ban.reason, ban.note);
|
|
||||||
new_date.innerHTML = get_date_string(ban.created);
|
|
||||||
new_remove.innerHTML = `<a href="#" onclick="unban('${ban.domain}')" title="Unban domain">✖</a>`;
|
|
||||||
|
|
||||||
elems.domain.value = null;
|
elems.domain.value = null;
|
||||||
elems.reason.value = null;
|
elems.reason.value = null;
|
||||||
|
|
|
@ -1,25 +1,3 @@
|
||||||
function append_table_row(table, instance) {
|
|
||||||
var row = table.insertRow(-1);
|
|
||||||
row.id = instance.domain;
|
|
||||||
|
|
||||||
var domain = row.insertCell(0);
|
|
||||||
domain.className = "domain";
|
|
||||||
domain.innerHTML = `<a href="https://${instance.domain}/" target="_new">${instance.domain}</a>`;
|
|
||||||
|
|
||||||
var software = row.insertCell(1);
|
|
||||||
software.className = "software";
|
|
||||||
software.innerHTML = instance.software
|
|
||||||
|
|
||||||
var date = row.insertCell(2);
|
|
||||||
date.className = "date";
|
|
||||||
date.innerHTML = get_date_string(instance.created);
|
|
||||||
|
|
||||||
var remove = row.insertCell(3);
|
|
||||||
remove.className = "remove";
|
|
||||||
remove.innerHTML = `<a href="#" onclick="del_instance('${instance.domain}')" title="Remove Instance">✖</a>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function add_instance() {
|
async function add_instance() {
|
||||||
var elems = {
|
var elems = {
|
||||||
actor: document.getElementById("new-actor"),
|
actor: document.getElementById("new-actor"),
|
||||||
|
@ -48,7 +26,12 @@ async function add_instance() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
append_table_row(document.getElementById("instances"), instance);
|
append_table_row(document.getElementById("instances"), instance.domain, {
|
||||||
|
domain: `<a href="https://${instance.domain}/" target="_new">${instance.domain}</a>`,
|
||||||
|
software: instance.software,
|
||||||
|
date: get_date_string(instance.created),
|
||||||
|
remove: `<a href="#" onclick="del_instance('${instance.domain}')" title="Remove Instance">✖</a>`
|
||||||
|
});
|
||||||
|
|
||||||
elems.actor.value = null;
|
elems.actor.value = null;
|
||||||
elems.inbox.value = null;
|
elems.inbox.value = null;
|
||||||
|
@ -99,7 +82,12 @@ async function req_response(domain, accept) {
|
||||||
instances = await client.request("GET", `v1/instance`, null);
|
instances = await client.request("GET", `v1/instance`, null);
|
||||||
instances.forEach((instance) => {
|
instances.forEach((instance) => {
|
||||||
if (instance.domain === domain) {
|
if (instance.domain === domain) {
|
||||||
append_table_row(document.getElementById("instances"), instance);
|
append_table_row(document.getElementById("instances"), instance.domain, {
|
||||||
|
domain: `<a href="https://${instance.domain}/" target="_new">${instance.domain}</a>`,
|
||||||
|
software: instance.software,
|
||||||
|
date: get_date_string(instance.created),
|
||||||
|
remove: `<a href="#" onclick="del_instance('${instance.domain}')" title="Remove Instance">✖</a>`
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,18 +42,11 @@ async function ban() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
row.id = ban.name;
|
append_table_row(document.getElementById("instances"), ban.name, {
|
||||||
var new_name = row.insertCell(0);
|
name: create_ban_object(ban.name, ban.reason, ban.note),
|
||||||
var new_date = row.insertCell(1);
|
date: get_date_string(ban.created),
|
||||||
var new_remove = row.insertCell(2);
|
remove: `<a href="#" onclick="unban('${ban.domain}')" title="Unban software">✖</a>`
|
||||||
|
});
|
||||||
new_name.className = "name";
|
|
||||||
new_date.className = "date";
|
|
||||||
new_remove.className = "remove";
|
|
||||||
|
|
||||||
new_name.innerHTML = create_ban_object(ban.name, ban.reason, ban.note);
|
|
||||||
new_date.innerHTML = get_date_string(ban.created);
|
|
||||||
new_remove.innerHTML = `<a href="#" onclick="unban('${ban.name}')" title="Unban name">✖</a>`;
|
|
||||||
|
|
||||||
elems.name.value = null;
|
elems.name.value = null;
|
||||||
elems.reason.value = null;
|
elems.reason.value = null;
|
||||||
|
|
|
@ -15,21 +15,11 @@ async function add_whitelist() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var table = document.getElementById("whitelist");
|
append_table_row(document.getElementById("instances"), item.domain, {
|
||||||
var row = table.insertRow(-1);
|
domain: item.domain,
|
||||||
row.id = item.domain;
|
date: get_date_string(ban.created),
|
||||||
|
remove: `<a href="#" onclick="del_whitelist('${item.domain}')" title="Remove whitelisted domain">✖</a>`
|
||||||
var domain = row.insertCell(0);
|
});
|
||||||
domain.className = "domain";
|
|
||||||
domain.innerHTML = item.domain;
|
|
||||||
|
|
||||||
var date = row.insertCell(1);
|
|
||||||
date.className = "date";
|
|
||||||
date.innerHTML = get_date_string(item.created);
|
|
||||||
|
|
||||||
var remove = row.insertCell(2);
|
|
||||||
remove.className = "remove";
|
|
||||||
remove.innerHTML = `<a href="#" onclick="del_whitelist('${item.domain}')" title="Remove whitelisted domain">✖</a>`;
|
|
||||||
|
|
||||||
domain_elem.value = null;
|
domain_elem.value = null;
|
||||||
document.querySelector("details.section").open = false;
|
document.querySelector("details.section").open = false;
|
||||||
|
|
Loading…
Reference in a new issue