Can update device general information
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::devices::device::DeviceId;
|
||||
use crate::devices::device::{DeviceGeneralInfo, DeviceId};
|
||||
use crate::energy::energy_actor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
@ -54,6 +54,26 @@ pub async fn validate_device(actor: WebEnergyActor, id: web::Path<DeviceInPath>)
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Update a device information
|
||||
pub async fn update_device(
|
||||
actor: WebEnergyActor,
|
||||
id: web::Path<DeviceInPath>,
|
||||
update: web::Json<DeviceGeneralInfo>,
|
||||
) -> HttpResult {
|
||||
if let Some(e) = update.error() {
|
||||
return Ok(HttpResponse::BadRequest().json(e));
|
||||
}
|
||||
|
||||
actor
|
||||
.send(energy_actor::UpdateDeviceGeneralInfo(
|
||||
id.id.clone(),
|
||||
update.0.clone(),
|
||||
))
|
||||
.await??;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete a device
|
||||
pub async fn delete_device(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
|
||||
actor
|
||||
|
Reference in New Issue
Block a user