dashboard: change data fetch in wireguard widget

This commit is contained in:
Stephan de Wit 2024-07-05 10:24:17 +02:00
parent dd0594ae3f
commit d042a4800d
2 changed files with 13 additions and 19 deletions

View File

@ -237,7 +237,6 @@
<users>Users</users>
<unconfigured>IPsec is currently disabled. Click to configure IPsec.</unconfigured>
<noleases>There are currently no leases.</noleases>
<nodata>Failed to load data.</nodata>
</translations>
</ipsecleases>
<ipsectunnels>
@ -252,7 +251,6 @@
<total>Tunnels</total>
<unconfigured>IPsec is currently disabled. Click to configure IPsec.</unconfigured>
<notunnels>There are currently no tunnels.</notunnels>
<nodata>Failed to load data.</nodata>
<notavailable>N/A</notavailable>
</translations>
</ipsectunnels>

View File

@ -53,24 +53,20 @@ export default class Wireguard extends BaseTableWidget {
}
async onWidgetTick() {
try {
const wg = await ajaxGet('/api/wireguard/general/get', {});
if (!wg.general || !wg.general.enabled) {
this.displayError(`${this.translations.unconfigured}`);
return;
}
const response = await ajaxGet('/api/wireguard/service/show', {});
if (!response || !response.rows || response.rows.length === 0) {
this.displayError(`${this.translations.notunnels}`);
return;
}
this.processTunnels(response.rows);
} catch (error) {
this.displayError(`${this.translations.nodata}`);
const wg = await this.ajaxGet('/api/wireguard/general/get');
if (!wg.general || !wg.general.enabled) {
this.displayError(`${this.translations.unconfigured}`);
return;
}
const response = await this.ajaxGet('/api/wireguard/service/show');
if (!response || !response.rows || response.rows.length === 0) {
this.displayError(`${this.translations.notunnels}`);
return;
}
this.processTunnels(response.rows);
}
displayError(message) {