mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-04-28 04:06:05 +00:00
deleting applications
This commit is contained in:
@@ -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<string, string> = 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, {
|
||||
|
||||
@@ -1038,7 +1038,7 @@ export {Dialog};
|
||||
class Options implements OptionsElement<void> {
|
||||
name: string;
|
||||
haschanged = false;
|
||||
readonly options: OptionsElement<any>[];
|
||||
options: OptionsElement<any>[];
|
||||
readonly owner: Buttons | Options | Form | Float;
|
||||
readonly ltr: boolean;
|
||||
value!: void;
|
||||
@@ -1302,6 +1302,13 @@ class Options implements OptionsElement<void> {
|
||||
container.append(div);
|
||||
}
|
||||
}
|
||||
deleteElm(opt:OptionsElement<any>){
|
||||
const html = this.html.get(opt)?.deref();
|
||||
this.options=this.options.filter(_=>_!==opt);
|
||||
if(!html) return;
|
||||
html.remove();
|
||||
this.html.delete(opt);
|
||||
}
|
||||
title: WeakRef<HTMLElement> = new WeakRef(document.createElement("h2"));
|
||||
generateHTML(): HTMLElement {
|
||||
const div = document.createElement("div");
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user