Skip to content

Commit 3d30e5f

Browse files
luizhf42otavio
authored andcommitted
fix(ui): fix Device listing
1 parent d93c895 commit 3d30e5f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ui/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const routes: Array<RouteRecordRaw> = [
239239
name: "Devices",
240240
component: Devices,
241241
beforeEnter: async (to, from, next) => {
242-
await useDevicesStore().fetchDeviceList();
242+
await useDevicesStore().setDeviceListVisibility();
243243
next();
244244
},
245245
redirect: { name: "DeviceList" },

ui/src/store/api/devices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const addTag = async (data: IDevicePostTag) => tagsApi.createDeviceTag(da
66
export const fetchDevices = async (
77
page: number,
88
perPage: number,
9-
status: "accepted" | "rejected" | "pending",
9+
status?: "accepted" | "rejected" | "pending",
1010
filter?: string,
1111
sortStatusField?: string,
1212
sortStatusString?: "asc" | "desc",

ui/src/store/modules/devices.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const useDevicesStore = defineStore("devices", () => {
3737
}
3838
};
3939

40+
const setDeviceListVisibility = async () => {
41+
const { headers } = await devicesApi.fetchDevices(1, 1);
42+
if (parseInt(headers["x-total-count"], 10)) showDevices.value = true;
43+
};
44+
4045
const fetchOnlineDevices = async (filter?: string) => {
4146
try {
4247
const res = await devicesApi.fetchDevices(
@@ -120,6 +125,7 @@ const useDevicesStore = defineStore("devices", () => {
120125
duplicatedDeviceName,
121126

122127
fetchDeviceList,
128+
setDeviceListVisibility,
123129
fetchOnlineDevices,
124130
removeDevice,
125131
renameDevice,

0 commit comments

Comments
 (0)