mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
fix dashboard and inbounds load failure states
This commit is contained in:
parent
537c73c1b2
commit
6131c55882
2 changed files with 34 additions and 6 deletions
|
|
@ -19,6 +19,15 @@
|
||||||
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<a-row v-else-if="loadFailed">
|
||||||
|
<a-col>
|
||||||
|
<a-alert type="error" show-icon
|
||||||
|
message="Failed to load inbounds"
|
||||||
|
description="The current page data was not loaded. Refresh and retry before editing or operating on inbounds."
|
||||||
|
:style="{ marginTop: '10px' }">
|
||||||
|
</a-alert>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
|
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
|
||||||
<a-col>
|
<a-col>
|
||||||
<a-card size="small" :style="{ padding: '16px' }" hoverable>
|
<a-card size="small" :style="{ padding: '16px' }" hoverable>
|
||||||
|
|
@ -749,6 +758,7 @@
|
||||||
isAdmin: {{if .is_admin}}true{{else}}false{{end}},
|
isAdmin: {{if .is_admin}}true{{else}}false{{end}},
|
||||||
currentUsername: {{ printf "%q" .current_username }},
|
currentUsername: {{ printf "%q" .current_username }},
|
||||||
clientEmailOptions: [],
|
clientEmailOptions: [],
|
||||||
|
loadFailed: false,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loading(spinning = true) {
|
loading(spinning = true) {
|
||||||
|
|
@ -759,16 +769,19 @@
|
||||||
const msg = await HttpUtil.get('/panel/api/inbounds/list');
|
const msg = await HttpUtil.get('/panel/api/inbounds/list');
|
||||||
if (!msg.success) {
|
if (!msg.success) {
|
||||||
this.refreshing = false;
|
this.refreshing = false;
|
||||||
return;
|
this.loadFailed = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.getLastOnlineMap();
|
await this.getLastOnlineMap();
|
||||||
await this.getOnlineUsers();
|
await this.getOnlineUsers();
|
||||||
|
|
||||||
|
this.loadFailed = false;
|
||||||
this.setInbounds(msg.obj);
|
this.setInbounds(msg.obj);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.refreshing = false;
|
this.refreshing = false;
|
||||||
}, 500);
|
}, 500);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
async getOnlineUsers() {
|
async getOnlineUsers() {
|
||||||
const msg = await HttpUtil.post('/panel/api/inbounds/onlines');
|
const msg = await HttpUtil.post('/panel/api/inbounds/onlines');
|
||||||
|
|
@ -1633,9 +1646,11 @@
|
||||||
// Initial data fetch
|
// Initial data fetch
|
||||||
this.getDBInbounds()
|
this.getDBInbounds()
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
this.loadFailed = true;
|
||||||
console.error(e);
|
console.error(e);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
this.loadingStates.fetched = true;
|
||||||
this.loading(false);
|
this.loading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@
|
||||||
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
<a-spin tip='{{ i18n "loading" }}'></a-spin>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
<a-row v-else-if="loadFailed">
|
||||||
|
<a-col>
|
||||||
|
<a-alert type="error" show-icon class="mb-10"
|
||||||
|
message="Failed to load dashboard status"
|
||||||
|
description="The current page data was not loaded. Refresh and retry before relying on this dashboard.">
|
||||||
|
</a-alert>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
|
<a-row :gutter="[isMobile ? 8 : 16, isMobile ? 0 : 12]" v-else>
|
||||||
<a-col>
|
<a-col>
|
||||||
<a-card hoverable>
|
<a-card hoverable>
|
||||||
|
|
@ -882,6 +890,7 @@
|
||||||
fetched: false,
|
fetched: false,
|
||||||
spinning: false
|
spinning: false
|
||||||
},
|
},
|
||||||
|
loadFailed: false,
|
||||||
status: new Status(),
|
status: new Status(),
|
||||||
cpuHistory: [], // small live widget history
|
cpuHistory: [], // small live widget history
|
||||||
cpuHistoryLong: [], // aggregated points from backend
|
cpuHistoryLong: [], // aggregated points from backend
|
||||||
|
|
@ -905,15 +914,15 @@
|
||||||
try {
|
try {
|
||||||
const msg = await HttpUtil.get('/panel/api/server/status');
|
const msg = await HttpUtil.get('/panel/api/server/status');
|
||||||
if (msg.success) {
|
if (msg.success) {
|
||||||
if (!this.loadingStates.fetched) {
|
this.loadFailed = false;
|
||||||
this.loadingStates.fetched = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setStatus(msg.obj, true);
|
this.setStatus(msg.obj, true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to get status:", e);
|
console.error("Failed to get status:", e);
|
||||||
}
|
}
|
||||||
|
this.loadFailed = true;
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
setStatus(data) {
|
setStatus(data) {
|
||||||
this.status = new Status(data);
|
this.status = new Status(data);
|
||||||
|
|
@ -1134,7 +1143,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial status fetch
|
// Initial status fetch
|
||||||
await this.getStatus();
|
try {
|
||||||
|
await this.getStatus();
|
||||||
|
} finally {
|
||||||
|
this.loadingStates.fetched = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup WebSocket for real-time updates
|
// Setup WebSocket for real-time updates
|
||||||
if (window.wsClient) {
|
if (window.wsClient) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue