This gets almost everything done, including Paging, but not search.

This commit is contained in:
Zed A. Shaw 2025-07-28 02:16:59 -04:00
parent da183c453c
commit 51b18823ae
7 changed files with 64 additions and 65 deletions

View file

@ -1,20 +1,46 @@
class GetJson {
class PaginateTable {
constructor(url) {
this.url = url;
this.page = 0;
this.items = [];
this.item = undefined;
this.url = url;
this.headers = [];
}
async theData() {
const resp = await fetch(this.url);
async contents() {
if(this.page < 0) this.page = 0;
const resp = await fetch(`${this.url}?page=${this.page}`);
console.assert(resp.status == 200, "failed to get it");
this.items = await resp.json();
this.headers = Object.keys(this.items[0]);
return this.items;
}
}
async oneThing() {
this.item = await this.theData();
console.log("ITEMS", this.items);
class GetJson {
constructor(url) {
this.item;
this.url = url;
}
async item() {
const resp = await fetch(`${this.url}`);
console.assert(resp.status == 200, "failed to get it");
this.item = await resp.json();
return this.item;
}
}
const ConfirmDelete = async (table, obj_id) => {
if(confirm("Are you sure?")) {
await fetch("/api/admin/table/" + table + "/" + obj_id + "/",
{ method: "DELETE" });
window.location = "/admin/table/" + table + "/";
} else {
return false;
}
}