88 lines
No EOL
2.2 KiB
JavaScript
88 lines
No EOL
2.2 KiB
JavaScript
import { adminauth, admincheck, admincomments, adminposts, adminquery, adminsessions, adminusers, adminlikes } from './api.js'
|
|
|
|
async function auth(event) {
|
|
event.preventDefault();
|
|
const text = event.target.elements.adminpassword.value;
|
|
const response = await adminauth(text);
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
} else {
|
|
document.getElementById("admin").classList.remove("hidden")
|
|
document.getElementById("login").classList.add("hidden")
|
|
}
|
|
return false;
|
|
}
|
|
window.auth = auth
|
|
|
|
async function submit() {
|
|
let text = document.getElementById("query").value
|
|
let response = await adminquery(text)
|
|
alert(response.msg)
|
|
}
|
|
window.submit = submit
|
|
|
|
async function posts() {
|
|
let response = await adminposts();
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
return
|
|
}
|
|
let table = document.getElementById("table")
|
|
table.innerHTML = response.msg
|
|
}
|
|
window.posts = posts
|
|
|
|
async function users() {
|
|
let response = await adminusers();
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
return
|
|
}
|
|
let table = document.getElementById("table")
|
|
table.innerHTML = response.msg
|
|
}
|
|
window.users = users
|
|
|
|
async function sessions() {
|
|
let response = await adminsessions();
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
return
|
|
}
|
|
let table = document.getElementById("table")
|
|
table.innerHTML = response.msg
|
|
}
|
|
window.sessions = sessions
|
|
|
|
async function comments() {
|
|
let response = await admincomments();
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
return
|
|
}
|
|
let table = document.getElementById("table")
|
|
table.innerHTML = response.msg
|
|
}
|
|
window.comments = comments
|
|
|
|
async function likes() {
|
|
let response = await adminlikes();
|
|
if (response.status !== 200) {
|
|
alert(response.msg)
|
|
return
|
|
}
|
|
let table = document.getElementById("table")
|
|
table.innerHTML = response.msg
|
|
}
|
|
window.likes = likes
|
|
|
|
async function load() {
|
|
let check = await admincheck();
|
|
if (check.msg === "true") {
|
|
document.getElementById("admin").classList.remove("hidden")
|
|
} else {
|
|
document.getElementById("login").classList.remove("hidden")
|
|
}
|
|
}
|
|
|
|
load() |