forked from hacker_marc/spamhasi
Finish Opfer Page
This commit is contained in:
1 parent
1f5ada7bfa
commit
8d0245c769
10 files changed
+559
-28
No files matched your search
+110
-1
@@ -96,7 +96,7 @@
|
||||
</h4>
|
||||
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
||||
Das neue Opfer wurde erfolgreich hinzugefügt!
|
||||
Die Aktion wurde erfolgreich ausgeführt
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,6 +179,115 @@
|
||||
document.getElementById("alert-error").style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
fetch("/api/opfer/list.php")
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.status == 500) {
|
||||
console.error("API Error: " + data.error);
|
||||
}
|
||||
|
||||
var list = document.getElementById("opfer_table").innerHTML;
|
||||
|
||||
for (const opfer of data.opfer) {
|
||||
if (opfer.enabled) {
|
||||
var status_class = "rounded-full bg-success-50 px-2 py-0.5 text-theme-xs font-medium text-success-700 dark:bg-success-500/15 dark:text-success-500";
|
||||
var status_text = "Enabled";
|
||||
}else{
|
||||
var status_class = "rounded-full bg-error-50 px-2 py-0.5 text-theme-xs font-medium text-error-700 dark:bg-error-500/15 dark:text-error-500";
|
||||
var status_text = "Disabled";
|
||||
}
|
||||
|
||||
list += `
|
||||
<tr>
|
||||
<td class="px-5 py-4 sm:px-6">
|
||||
<div class="flex items-center">
|
||||
<div class="flex items-center gap-3">
|
||||
<div>
|
||||
<span
|
||||
@click="isOpferEdit = true"
|
||||
onclick="opferEdit(` + opfer.id + `)"
|
||||
class="block font-medium text-gray-800 text-theme-sm dark:text-white/90"
|
||||
>
|
||||
` + opfer.name + `
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 sm:px-6">
|
||||
<div class="flex items-center">
|
||||
<p class="text-gray-500 text-theme-sm dark:text-gray-400">
|
||||
` + opfer.mail + `
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 sm:px-6">
|
||||
<div class="flex items-center">
|
||||
<p
|
||||
class="` + status_class + `"
|
||||
>
|
||||
` + status_text + `
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 sm:px-6">
|
||||
<div class="flex items-center">
|
||||
<p class="text-gray-500 text-theme-sm dark:text-gray-400">` + opfer.number + `</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
document.getElementById("opfer_table").innerHTML = list;
|
||||
})
|
||||
.catch(error => console.error("API Error: " + error))
|
||||
|
||||
function opferEdit(id) {
|
||||
console.log(document.getElementById("opfer_name"));
|
||||
fetch("/api/opfer/info.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: "id=" + id
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.status == 500) {
|
||||
console.error("API Error: " + data.error);
|
||||
}
|
||||
|
||||
const opfer = data.opfer;
|
||||
|
||||
document.getElementById("opfer_id").value = id;
|
||||
document.getElementById("opfer_name").value = opfer.name;
|
||||
document.getElementById("opfer_mail").value = opfer.mail;
|
||||
document.getElementById("opfer_number").value = opfer.number;
|
||||
|
||||
|
||||
if (data.status == 1) {
|
||||
const toogle_el = document.querySelector('#toggle2');
|
||||
const toogle_data = Alpine.$data(document.getElementById("toogle2_div"));
|
||||
|
||||
toogle_data.switcherToggle = data.status;
|
||||
toogle_el.checked = data.status;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeOpfer() {
|
||||
const id = document.getElementById("opfer_id").value;
|
||||
|
||||
fetch("/api/opfer/delete.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: "id=" + id
|
||||
})
|
||||
window.location.reload();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user