fix and improve

This commit is contained in:
MHSanaei
2023-06-14 19:50:19 +03:30
parent c0f1a926e5
commit d40e61fc45
4 changed files with 21 additions and 24 deletions

View File

@@ -124,12 +124,14 @@
try {
const msg = await HttpUtil.post(`/panel/inbound/clientIps/${email}`);
if (!msg.success) {
document.getElementById("clientIPs").value = msg.obj;
return;
}
const ips = JSON.parse(msg.obj).join(",\n");
const ips = Array.isArray(msg.obj) ? msg.obj.join(",\n") : msg.obj;
document.getElementById("clientIPs").value = ips;
} catch (error) {
document.getElementById("clientIPs").value = msg.obj;
console.error(error);
document.getElementById("clientIPs").value = 'An error occurred while making the request';
}
},
async clearDBClientIps(email) {

View File

@@ -449,9 +449,13 @@
this.loadingTip = tip;
},
async getStatus() {
const msg = await HttpUtil.post('/server/status');
if (msg.success) {
this.setStatus(msg.obj);
try {
const msg = await HttpUtil.post('/server/status');
if (msg.success) {
this.setStatus(msg.obj);
}
} catch (e) {
console.error("Failed to get status:", e);
}
},
setStatus(data) {
@@ -560,11 +564,14 @@
},
},
async mounted() {
while (true) {
let retries = 0;
while (retries < 5) {
try {
await this.getStatus();
retries = 0;
} catch (e) {
console.error(e);
console.error("Error occurred while fetching status:", e);
retries++;
}
await PromiseUtil.sleep(2000);
}