Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
405ebe1e8e | ||
|
|
1fb937973c | ||
|
|
9688c9581a | ||
|
|
6b4bd73b14 | ||
|
|
e834725b1a | ||
|
|
e6a7262cf7 | ||
|
|
850eb74210 | ||
|
|
c1c5a41aa5 | ||
|
|
2b85020d52 | ||
|
|
493739238e | ||
|
|
7d96b3a82e | ||
|
|
f49c868007 | ||
|
|
ff4248961b | ||
|
|
fbc6916e2c | ||
|
|
934b287673 | ||
|
|
9f28e5eeb6 | ||
|
|
b2d4953fb6 | ||
|
|
ec4c9ec492 |
2
dist/fastify.d.ts
vendored
2
dist/fastify.d.ts
vendored
@@ -17,6 +17,6 @@ export declare abstract class BaseService<T> {
|
|||||||
constructor(client: T);
|
constructor(client: T);
|
||||||
getClient(): T;
|
getClient(): T;
|
||||||
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>;
|
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>;
|
||||||
getErrorResult(error: string): ServiceResult<string>;
|
getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string>;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=fastify.d.ts.map
|
//# sourceMappingURL=fastify.d.ts.map
|
||||||
2
dist/fastify.d.ts.map
vendored
2
dist/fastify.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,SAAS;IACF,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,8BAAsB,UAAU;IAC/B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAIxC,QAAQ,IAAI,aAAa;CAGzB;AAED,8BAAsB,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,SAAS,IAAI,CAAC;IAId,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;CAMpD"}
|
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,SAAS;IACF,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,8BAAsB,UAAU;IAC/B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAIxC,QAAQ,IAAI,aAAa;CAGzB;AAED,8BAAsB,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,SAAS,IAAI,CAAC;IAId,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC;CAO5E"}
|
||||||
6
dist/fastify.js
vendored
6
dist/fastify.js
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
import { logWarning } from "./logger.js";
|
||||||
export class API_Error {
|
export class API_Error {
|
||||||
error;
|
error;
|
||||||
constructor(error) {
|
constructor(error) {
|
||||||
@@ -27,9 +28,10 @@ export class BaseService {
|
|||||||
successful: true,
|
successful: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
getErrorResult(error) {
|
getErrorResult(errorMessage, error) {
|
||||||
|
logWarning(errorMessage);
|
||||||
return {
|
return {
|
||||||
result: error,
|
result: errorMessage,
|
||||||
successful: false,
|
successful: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
8
dist/homeassistant.d.ts
vendored
8
dist/homeassistant.d.ts
vendored
@@ -21,13 +21,17 @@ export type HomeAssistantEntity = {
|
|||||||
export interface HomeAssistantDeskPositionResult {
|
export interface HomeAssistantDeskPositionResult {
|
||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
as_boolean: boolean;
|
as_boolean: boolean;
|
||||||
as_text: () => string;
|
|
||||||
last_changed: TimeBetween;
|
last_changed: TimeBetween;
|
||||||
}
|
}
|
||||||
export type API_HA_DeskPosition = {
|
export type API_HA_DeskPosition = {
|
||||||
position: string;
|
|
||||||
is_standing: boolean;
|
is_standing: boolean;
|
||||||
last_changed: string;
|
last_changed: string;
|
||||||
last_changed_seconds: number;
|
last_changed_seconds: number;
|
||||||
};
|
};
|
||||||
|
export type HA_Update = {
|
||||||
|
entity_id: string;
|
||||||
|
state: string;
|
||||||
|
attributes: unknown;
|
||||||
|
timestamp: string;
|
||||||
|
};
|
||||||
//# sourceMappingURL=homeassistant.d.ts.map
|
//# sourceMappingURL=homeassistant.d.ts.map
|
||||||
2
dist/homeassistant.d.ts.map
vendored
2
dist/homeassistant.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC/C,GAAG,EAAE,mBAAmB,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,MAAM,CAAC;IACtB,YAAY,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC"}
|
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC/C,GAAG,EAAE,mBAAmB,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAA"}
|
||||||
6
dist/homepage.d.ts
vendored
6
dist/homepage.d.ts
vendored
@@ -1,8 +1,14 @@
|
|||||||
|
import type { GristRecord_PersonalGoals } from "./grist";
|
||||||
import type { API_HA_DeskPosition } from "./homeassistant";
|
import type { API_HA_DeskPosition } from "./homeassistant";
|
||||||
import type { TidalGetCurrent } from "./tidal";
|
import type { TidalGetCurrent } from "./tidal";
|
||||||
export type FullInformation = {
|
export type FullInformation = {
|
||||||
ha_desk_position: API_HA_DeskPosition | null;
|
ha_desk_position: API_HA_DeskPosition | null;
|
||||||
ha_temp: string | null;
|
ha_temp: string | null;
|
||||||
tidal_current: TidalGetCurrent | null;
|
tidal_current: TidalGetCurrent | null;
|
||||||
|
grist_personal_goals: GristRecord_PersonalGoals | null;
|
||||||
|
};
|
||||||
|
export type ComponentUpdate = {
|
||||||
|
component: string;
|
||||||
|
data: unknown;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=homepage.d.ts.map
|
//# sourceMappingURL=homepage.d.ts.map
|
||||||
2
dist/homepage.d.ts.map
vendored
2
dist/homepage.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../src/homepage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC7B,gBAAgB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC,CAAC"}
|
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../src/homepage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC7B,gBAAgB,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC7C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,oBAAoB,EAAE,yBAAyB,GAAG,IAAI,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;CACd,CAAC"}
|
||||||
3
dist/timehelper.d.ts
vendored
3
dist/timehelper.d.ts
vendored
@@ -11,5 +11,6 @@ export interface TimeBetween {
|
|||||||
toReadable: (roundToMinutes?: boolean) => string;
|
toReadable: (roundToMinutes?: boolean) => string;
|
||||||
}
|
}
|
||||||
export declare function calculateSecondsBetween(start: number, end: number): TimeBetween;
|
export declare function calculateSecondsBetween(start: number, end: number): TimeBetween;
|
||||||
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
|
export declare function formatSecondsToDHMS(secs: number, roundToMinutes?: boolean): string;
|
||||||
|
export declare function formatSecondsToMS(s: number): string;
|
||||||
//# sourceMappingURL=timehelper.d.ts.map
|
//# sourceMappingURL=timehelper.d.ts.map
|
||||||
2
dist/timehelper.d.ts.map
vendored
2
dist/timehelper.d.ts.map
vendored
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACpB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBjD;AAED,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CACjD;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,WAAW,CAOb;AAED,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC7B,MAAM,CAmBR"}
|
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACpB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBjD;AAED,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CACjD;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,WAAW,CAOb;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC7B,MAAM,CAmBR;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAInD"}
|
||||||
25
dist/timehelper.js
vendored
25
dist/timehelper.js
vendored
@@ -36,18 +36,23 @@ export function calculateSecondsBetween(start, end) {
|
|||||||
const seconds = Math.max(60, (end - start) / 1000);
|
const seconds = Math.max(60, (end - start) / 1000);
|
||||||
return {
|
return {
|
||||||
seconds,
|
seconds,
|
||||||
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes),
|
toReadable: (roundToMinutes) => formatSecondsToDHMS(seconds, roundToMinutes),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export function secondsToReadable(secs, roundToMinutes = false) {
|
export function formatSecondsToDHMS(secs, roundToMinutes = false) {
|
||||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
||||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
const days = Math.floor(totalSeconds / (3600 * 24));
|
||||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||||
var seconds = Math.floor(totalSeconds % 60);
|
const seconds = Math.floor(totalSeconds % 60);
|
||||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||||
var hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
const hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||||
var minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
const minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||||
var secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
const secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
||||||
}
|
}
|
||||||
|
export function formatSecondsToMS(s) {
|
||||||
|
const mins = Math.floor(s / 60);
|
||||||
|
const secs = s % 60;
|
||||||
|
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
||||||
|
}
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.8.1",
|
"version": "1.9.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.8.1",
|
"version": "1.9.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.8.1",
|
"version": "1.9.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { AxiosInstance } from "axios";
|
import type { AxiosInstance } from "axios";
|
||||||
|
import { logWarning } from "./logger.js";
|
||||||
|
|
||||||
export type ServiceResult<T = unknown> = {
|
export type ServiceResult<T = unknown> = {
|
||||||
result: T;
|
result: T;
|
||||||
@@ -39,9 +40,10 @@ export abstract class BaseService<T> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getErrorResult(error: string): ServiceResult<string> {
|
getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string> {
|
||||||
|
logWarning(errorMessage);
|
||||||
return {
|
return {
|
||||||
result: error,
|
result: errorMessage,
|
||||||
successful: false,
|
successful: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,18 @@ export type HomeAssistantEntity = {
|
|||||||
export interface HomeAssistantDeskPositionResult {
|
export interface HomeAssistantDeskPositionResult {
|
||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
as_boolean: boolean;
|
as_boolean: boolean;
|
||||||
as_text: () => string;
|
|
||||||
last_changed: TimeBetween;
|
last_changed: TimeBetween;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type API_HA_DeskPosition = {
|
export type API_HA_DeskPosition = {
|
||||||
position: string;
|
|
||||||
is_standing: boolean;
|
is_standing: boolean;
|
||||||
last_changed: string;
|
last_changed: string;
|
||||||
last_changed_seconds: number;
|
last_changed_seconds: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type HA_Update = {
|
||||||
|
entity_id: string;
|
||||||
|
state: string;
|
||||||
|
attributes: unknown;
|
||||||
|
timestamp: string; // datetime string
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { GristRecord_PersonalGoals } from "./grist";
|
||||||
import type { API_HA_DeskPosition } from "./homeassistant";
|
import type { API_HA_DeskPosition } from "./homeassistant";
|
||||||
import type { TidalGetCurrent } from "./tidal";
|
import type { TidalGetCurrent } from "./tidal";
|
||||||
|
|
||||||
@@ -5,4 +6,10 @@ export type FullInformation = {
|
|||||||
ha_desk_position: API_HA_DeskPosition | null;
|
ha_desk_position: API_HA_DeskPosition | null;
|
||||||
ha_temp: string | null;
|
ha_temp: string | null;
|
||||||
tidal_current: TidalGetCurrent | null;
|
tidal_current: TidalGetCurrent | null;
|
||||||
|
grist_personal_goals: GristRecord_PersonalGoals | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ComponentUpdate = {
|
||||||
|
component: string;
|
||||||
|
data: unknown;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,30 +51,36 @@ export function calculateSecondsBetween(
|
|||||||
return {
|
return {
|
||||||
seconds,
|
seconds,
|
||||||
toReadable: (roundToMinutes?: boolean) =>
|
toReadable: (roundToMinutes?: boolean) =>
|
||||||
secondsToReadable(seconds, roundToMinutes),
|
formatSecondsToDHMS(seconds, roundToMinutes),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function secondsToReadable(
|
export function formatSecondsToDHMS(
|
||||||
secs: number,
|
secs: number,
|
||||||
roundToMinutes: boolean = false,
|
roundToMinutes: boolean = false,
|
||||||
): string {
|
): string {
|
||||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
||||||
|
|
||||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
const days = Math.floor(totalSeconds / (3600 * 24));
|
||||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||||
var seconds = Math.floor(totalSeconds % 60);
|
const seconds = Math.floor(totalSeconds % 60);
|
||||||
|
|
||||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||||
var hourDisplay =
|
const hourDisplay =
|
||||||
hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||||
var minuteDisplay =
|
const minuteDisplay =
|
||||||
minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||||
var secondDisplay =
|
const secondDisplay =
|
||||||
seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(
|
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(
|
||||||
/,\s*$/,
|
/,\s*$/,
|
||||||
"",
|
"",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatSecondsToMS(s: number): string {
|
||||||
|
const mins = Math.floor(s / 60);
|
||||||
|
const secs = s % 60;
|
||||||
|
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user