major updates to device and links management in admin

This commit is contained in:
user
2026-03-28 15:34:03 +02:00
parent e8c5986df6
commit 6639bcd799
32 changed files with 3304 additions and 496 deletions

View File

@@ -47,10 +47,13 @@ export class DeviceController {
*/
allocate(fctx: FlowExecCtx, id: number): ResultAsync<Device, Err> {
return this.repo.getById(fctx, id).andThen((dev) => {
if (dev.status !== DeviceStatus.ONLINE) {
if (dev.status !== DeviceStatus.ONLINE || dev.inUse) {
return errAsync(deviceErrors.deviceNotAvailable(fctx, id));
}
return this.repo.setStatus(fctx, id, DeviceStatus.BUSY);
return this.repo.update(fctx, id, {
status: DeviceStatus.BUSY,
inUse: true,
});
});
}
@@ -58,7 +61,10 @@ export class DeviceController {
* Release a device back to online after a session ends.
*/
release(fctx: FlowExecCtx, id: number): ResultAsync<Device, Err> {
return this.repo.setStatus(fctx, id, DeviceStatus.ONLINE);
return this.repo.update(fctx, id, {
status: DeviceStatus.ONLINE,
inUse: false,
});
}
}