diff --git a/GatewayApp/Backend/Plantmonitor.Server/Features/DeviceProgramming/PowerOutletController.cs b/GatewayApp/Backend/Plantmonitor.Server/Features/DeviceProgramming/PowerOutletController.cs index dbdeae09..215c844e 100644 --- a/GatewayApp/Backend/Plantmonitor.Server/Features/DeviceProgramming/PowerOutletController.cs +++ b/GatewayApp/Backend/Plantmonitor.Server/Features/DeviceProgramming/PowerOutletController.cs @@ -48,8 +48,9 @@ public IEnumerable GetOutlets() } [HttpPost("switchoutlet")] - public void SwitchOutlet([FromServices] IDeviceApiFactory apiFactory, string ip, long code) + public void SwitchOutlet([FromServices] IDeviceApiFactory apiFactory, string ip, long codeId) { + var code = context.SwitchableOutletCodes.First(c => c.Id == codeId).Code; apiFactory.SwitchOutletsClient(ip).SwitchoutletAsync(code); } } diff --git a/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceConfiguration/+page.svelte b/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceConfiguration/+page.svelte index 6ebac542..c450c05b 100644 --- a/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceConfiguration/+page.svelte +++ b/GatewayApp/Frontend/Plantmonitor.Website/src/features/deviceConfiguration/+page.svelte @@ -33,6 +33,7 @@ let previewImage = new ThermalImage(); let pictureStreamer: PictureStreamer; let existingOutlets: OutletModel[] = []; + let selectedOutlet: OutletModel | undefined; let logData = ""; let searchingForDevices = true; @@ -111,6 +112,10 @@ pictureStreamer.stopStreaming(); pictureStreamer.showPreview(device, CameraType.Vis, 1); } + async function checkStatus(ip: string) { + const deviceClient = new DeviceConfigurationClient(); + await deviceClient.recheckDevice(ip); + } async function updateIpRange() { const client = new AppConfigurationClient(); client.updateIpRanges(configurationData.ipFrom, configurationData.ipTo); @@ -125,6 +130,14 @@ configurationData.userName = ""; configurationData.userPassword = ""; } + function switchPowerOutlet(code: number | undefined) { + if (code == undefined) return; + const switchDevices = devices.filter((d) => d.health.state != undefined && d.health.state & HealthState.CanSwitchOutlets); + const outletClient = new PowerOutletClient(); + switchDevices.forEach(async (d) => { + outletClient.switchOutlet(d.ip, code); + }); + } async function getDeviceStatus() { const client = new DeviceConfigurationClient(); const outletClient = new PowerOutletClient(); @@ -220,12 +233,22 @@ {/if} {/if} + {/each} + + {#if selectedOutlet != undefined} + + + {/if}
{#if !previewImage.dataUrl?.isEmpty()} diff --git a/GatewayApp/Frontend/Plantmonitor.Website/src/features/reuseableComponents/Select.svelte b/GatewayApp/Frontend/Plantmonitor.Website/src/features/reuseableComponents/Select.svelte index 6d9f647c..e8883a1f 100644 --- a/GatewayApp/Frontend/Plantmonitor.Website/src/features/reuseableComponents/Select.svelte +++ b/GatewayApp/Frontend/Plantmonitor.Website/src/features/reuseableComponents/Select.svelte @@ -1,8 +1,8 @@