-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display tracker batery information (if known)
- Loading branch information
Showing
5 changed files
with
56 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
import {getFetcher, TrackerIdRoute} from "@/utils/fetcher"; | ||
import { getFetcher, TrackerIdRoute } from "@/utils/fetcher"; | ||
import useSWR from "swr"; | ||
import { batteryLevelFormatter } from "@/utils/helpers"; | ||
|
||
export default function TrackerCharge({trackerId}: {trackerId: string}) { | ||
export default function TrackerCharge({ trackerId }: { trackerId: string }) { | ||
const safeTrackerId = encodeURIComponent(trackerId); | ||
const { data: tracker_data } = useSWR(`/webapi/tracker/read/${safeTrackerId}`, getFetcher<TrackerIdRoute>); | ||
|
||
const safeTrackerId = encodeURIComponent(trackerId); | ||
const {data: tracker_data} = useSWR(`/webapi/tracker/read/${safeTrackerId}`, getFetcher<TrackerIdRoute>) | ||
|
||
return (<div>{tracker_data && <>{tracker_data.id}: {tracker_data.data ?? "unbekannt"} %</>}</div>) | ||
|
||
} | ||
return ( | ||
<> | ||
{tracker_data && ( | ||
<div className={"w-full flex flex-nowrap my-1 gap-1"}> | ||
<div className={"group relative sm:grow shrink min-w-0 basis-32 text-left"}> | ||
<div className={"truncate w-32 sm:w-full max-w-full min-w-0"}>{tracker_data.id}</div> | ||
<div | ||
className={ | ||
"opacity-0 group-hover:opacity-100 z-10 transition-opacity pointer-events-none absolute bg-gray-100 rounded py-2 px-3 top-5 w-max" | ||
}> | ||
{tracker_data.id} | ||
</div> | ||
</div> | ||
<div className={"basis-10 text-right shrink-0"}> | ||
{tracker_data.battery == undefined ? "?" : batteryLevelFormatter.format(tracker_data.battery)} | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters