From 74be90629eba74e6d30eb615d8bbc72de924f261 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 24 Nov 2025 14:07:45 -0600 Subject: [PATCH] deleting applications --- src/webpage/localuser.ts | 24 ++++++++++++++++++++---- src/webpage/settings.ts | 9 ++++++++- translations/en.json | 4 ++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/webpage/localuser.ts b/src/webpage/localuser.ts index 09faf42..abba5c9 100644 --- a/src/webpage/localuser.ts +++ b/src/webpage/localuser.ts @@ -2590,14 +2590,16 @@ class Localuser { }).then(async (teamsRes) => { const teams = await teamsRes.json(); - devPortal.addButtonInput("", I18n.localuser.createApp(), () => { + const button = devPortal.addButtonInput("", I18n.localuser.createApp(), () => { const form = devPortal.addSubForm( I18n.localuser.createApp(), (json: any) => { if (json.message) form.error("name", json.message); else { devPortal.returnFromSub(); - this.manageApplication(json.id, devPortal); + this.manageApplication(json.id, devPortal,()=>{ + form.options.deleteElm(button); + }); } }, { @@ -2654,7 +2656,9 @@ class Localuser { container.appendChild(name); container.addEventListener("click", async () => { - this.manageApplication(application.id, devPortal); + this.manageApplication(application.id, devPortal,()=>{ + appListContainer.remove(); + }); }); appListContainer.appendChild(container); }, @@ -3048,7 +3052,7 @@ class Localuser { settings.show(); } readonly botTokens: Map = new Map(); - async manageApplication(appId = "", container: Options) { + async manageApplication(appId = "", container: Options,deleteButton:()=>void) { if (this.perminfo.applications) { for (const item of Object.keys(this.perminfo.applications)) { this.botTokens.set(item, this.perminfo.applications[item]); @@ -3099,6 +3103,18 @@ class Localuser { } this.manageBot(appId, form); }); + form.addButtonInput("",I18n.applications.delete(),()=>{ + const sub=form.addSubForm(I18n.applications.delete(),()=>{ + deleteButton(); + container.returnFromSub(); + },{ + fetchURL:this.info.api+"/applications/" + appId + "/delete", + method:"POST", + headers:this.headers, + submitText:I18n.delete() + }); + sub.addText(I18n.applications.sure(json.name)); + }) } async manageBot(appId = "", container: Form) { const res = await fetch(this.info.api + "/applications/" + appId, { diff --git a/src/webpage/settings.ts b/src/webpage/settings.ts index 35ba83d..b024143 100644 --- a/src/webpage/settings.ts +++ b/src/webpage/settings.ts @@ -1038,7 +1038,7 @@ export {Dialog}; class Options implements OptionsElement { name: string; haschanged = false; - readonly options: OptionsElement[]; + options: OptionsElement[]; readonly owner: Buttons | Options | Form | Float; readonly ltr: boolean; value!: void; @@ -1302,6 +1302,13 @@ class Options implements OptionsElement { container.append(div); } } + deleteElm(opt:OptionsElement){ + const html = this.html.get(opt)?.deref(); + this.options=this.options.filter(_=>_!==opt); + if(!html) return; + html.remove(); + this.html.delete(opt); + } title: WeakRef = new WeakRef(document.createElement("h2")); generateHTML(): HTMLElement { const div = document.createElement("div"); diff --git a/translations/en.json b/translations/en.json index 2f6e350..d492c25 100644 --- a/translations/en.json +++ b/translations/en.json @@ -465,6 +465,10 @@ "desc": "Read or subscribe to the blog for updates on Fermi!" }, "remove":"Remove", + "applications":{ + "delete":"Delete Application", + "sure":"Are you sure you want to delete $1?" + }, "localuser": { "trusted":"Trusted Domains", "trustedDesc":"These domains when you click on links from them will ***not*** prompt you for permission to open like other links, only give this to URLs you trust",