major updates to device and links management in admin
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user