Skip to content

Commit

Permalink
add audio modes to browse-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Zainrax committed Oct 8, 2024
1 parent 735ea29 commit f69bb64
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 12 deletions.
5 changes: 4 additions & 1 deletion api/api/V1/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,10 @@ export default function (app: Application, baseUrl: string) {
}
);
} catch (e) {
return next(new FatalError("Failed to update device settings."));
console.log(e);
return next(
new FatalError(`Failed to update device settings: ${e.message}`)
);
}
}
);
Expand Down
32 changes: 32 additions & 0 deletions browse-next/src/api/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const getDeviceNodeGroup = (deviceId: DeviceId) => {
type: "salt-update",
limit: 1,
}).then((response) => {
debugger;
if (response.success && response.result.rows.length) {
resolve(
response.result.rows[0].EventDetail.details.nodegroup ||
Expand All @@ -153,6 +154,37 @@ export const getDeviceNodeGroup = (deviceId: DeviceId) => {
}) as Promise<string | false>;
};

export const getDeviceModel = async (deviceId: DeviceId) => {
try {
const nodegroup = await getDeviceNodeGroup(deviceId);
if (nodegroup) {
const model = nodegroup.includes("tc2")
? "tc2"
: nodegroup.includes("pi")
? "pi"
: null;
if (model !== null) {
return model;
}
}
const model = await getLatestEventsByDeviceId(deviceId, {
type: "versionData",
limit: 1,
}).then((response) => {
if (response.success && response.result.rows.length) {
return response.result.rows[0].EventDetail.details["tc2-agent"]
? "tc2"
: "pi";
} else {
return null;
}
});
return model;
} catch (e) {
return null;
}
};

export interface BatteryInfoEvent {
dateTime: IsoFormattedString | Date;
voltage: number | null;
Expand Down
Loading

0 comments on commit f69bb64

Please sign in to comment.