Rewrite frontend, added rooms, voltage selection per project, startet with todos

This commit is contained in:
2026-05-01 17:07:56 +02:00
parent 81d47ce16f
commit 65819900b1
49 changed files with 3695 additions and 394 deletions
@@ -0,0 +1,57 @@
import crypto from "node:crypto";
import { eq } from "drizzle-orm";
import { db } from "../client.js";
import { globalDevices } from "../schema/global-devices.js";
import type {
CreateGlobalDeviceInput,
UpdateGlobalDeviceInput,
} from "../../shared/validation/global-device.schemas.js";
export class GlobalDeviceRepository {
async list() {
return db.select().from(globalDevices);
}
async create(input: CreateGlobalDeviceInput) {
const id = crypto.randomUUID();
await db.insert(globalDevices).values({
id,
name: input.name,
category: input.category ?? null,
quantity: input.quantity,
installedPowerPerUnitKw: input.installedPowerPerUnitKw,
demandFactor: input.demandFactor,
voltageV: input.voltageV ?? null,
phaseCount: input.phaseCount ?? null,
powerFactor: input.powerFactor ?? null,
note: input.note ?? null,
});
return { id, ...input };
}
async update(globalDeviceId: string, input: UpdateGlobalDeviceInput) {
await db
.update(globalDevices)
.set({
name: input.name,
category: input.category ?? null,
quantity: input.quantity,
installedPowerPerUnitKw: input.installedPowerPerUnitKw,
demandFactor: input.demandFactor,
voltageV: input.voltageV ?? null,
phaseCount: input.phaseCount ?? null,
powerFactor: input.powerFactor ?? null,
note: input.note ?? null,
})
.where(eq(globalDevices.id, globalDeviceId));
}
async findById(globalDeviceId: string) {
const [row] = await db.select().from(globalDevices).where(eq(globalDevices.id, globalDeviceId)).limit(1);
return row ?? null;
}
async delete(globalDeviceId: string) {
await db.delete(globalDevices).where(eq(globalDevices.id, globalDeviceId));
}
}