Update setting.html

This commit is contained in:
MHSanaei 2023-04-24 02:48:17 +03:30
parent dfa3d39ab3
commit d1c4eb9b4c

View File

@ -298,9 +298,9 @@
this.spinning = spinning; this.spinning = spinning;
}, },
async getAllSetting() { async getAllSetting() {
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.post("/xui/setting/all"); const msg = await HttpUtil.post("/xui/setting/all");
this.loading(false,null); this.loading(false);
if (msg.success) { if (msg.success) {
this.oldAllSetting = new AllSetting(msg.obj); this.oldAllSetting = new AllSetting(msg.obj);
this.allSetting = new AllSetting(msg.obj); this.allSetting = new AllSetting(msg.obj);
@ -309,17 +309,17 @@
await this.getUserSecret(); await this.getUserSecret();
}, },
async updateAllSetting() { async updateAllSetting() {
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.post("/xui/setting/update", this.allSetting); const msg = await HttpUtil.post("/xui/setting/update", this.allSetting);
this.loading(false,null); this.loading(false);
if (msg.success) { if (msg.success) {
await this.getAllSetting(); await this.getAllSetting();
} }
}, },
async updateUser() { async updateUser() {
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.post("/xui/setting/updateUser", this.user); const msg = await HttpUtil.post("/xui/setting/updateUser", this.user);
this.loading(false,null); this.loading(false);
if (msg.success) { if (msg.success) {
this.user = {}; this.user = {};
} }
@ -334,11 +334,11 @@
onOk: () => resolve(), onOk: () => resolve(),
}); });
}); });
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.post("/xui/setting/restartPanel"); const msg = await HttpUtil.post("/xui/setting/restartPanel");
this.loading(false,null); this.loading(false);
if (msg.success) { if (msg.success) {
this.loading(true,{}); this.loading(true);
await PromiseUtil.sleep(5000); await PromiseUtil.sleep(5000);
location.reload(); location.reload();
} }
@ -351,16 +351,16 @@
this.loading(false); this.loading(false);
}, },
async updateSecret(){ async updateSecret(){
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.post("/xui/setting/updateUserSecret", this.user); const msg = await HttpUtil.post("/xui/setting/updateUserSecret", this.user);
if (msg.success){ if (msg.success){
this.user = msg.obj; this.user = msg.obj;
} }
this.loading(false,null); this.loading(false);
await this.updateAllSetting(); await this.updateAllSetting();
}, },
async getNewSecret(){ async getNewSecret(){
this.loading(true,{}); this.loading(true);
await PromiseUtil.sleep(1000); await PromiseUtil.sleep(1000);
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
var string = ''; var string = '';
@ -370,7 +370,7 @@
} }
this.user.loginSecret = string; this.user.loginSecret = string;
document.getElementById('token').value =this.user.loginSecret; document.getElementById('token').value =this.user.loginSecret;
this.loading(false,null); this.loading(false);
}, },
async toggleToken(value){ async toggleToken(value){
if(value) if(value)
@ -379,9 +379,9 @@
this.user.loginSecret = ""; this.user.loginSecret = "";
}, },
async resetXrayConfigToDefault() { async resetXrayConfigToDefault() {
this.loading(true,{}); this.loading(true);
const msg = await HttpUtil.get("/xui/setting/getDefaultJsonConfig"); const msg = await HttpUtil.get("/xui/setting/getDefaultJsonConfig");
this.loading(false,null); this.loading(false);
if (msg.success) { if (msg.success) {
this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2)); this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
this.saveBtnDisable = true; this.saveBtnDisable = true;