implemented device statistics

This commit is contained in:
Carter 2025-01-27 10:36:54 -06:00
parent 0076f2d208
commit 3a000b0094
8 changed files with 276 additions and 111 deletions

View file

@ -100,6 +100,10 @@ export interface IDeviceAPIContext {
keys?: string[],
types?: string[]
) => Promise<any>;
statistics: (
keys?: string[],
types?: string[]
) => Promise<any>;
tag: (id: number, tag: string) => Promise<any>;
untag: (id: number, tag: string) => Promise<any>;
getDatacap: (id: number) => Promise<any>;
@ -177,6 +181,22 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
return get(url);
};
const statistics = (
keys?: string[],
types?: string[]
) => {
if (types && types.length > 0 && types[0] === "team")
return get(
pondURL(
"/deviceStatistics/" +
(keys ? "?keys=" + keys.toString() : "") +
(types ? "&types=" + types.toString() : "")
)
);
const url = pondURL("/deviceStatistics");
return get<pond.GetDeviceStatisticsResponse>(url);
};
const getDevicePageData = (
id: number | string,
keys?: string[],
@ -615,6 +635,7 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
update,
remove,
get: getDevice,
statistics,
getPageData: getDevicePageData,
getMulti,
getGeoJson: getDeviceGeoJSON,