filtered unnecesary stuff
This commit is contained in:
+10
-2
@@ -73,9 +73,17 @@ async fn get_apps(query: web::Query<Auth>) -> Result<impl Responder> {
|
|||||||
units
|
units
|
||||||
.iter()
|
.iter()
|
||||||
.map(|v| match systemctl.status(v) {
|
.map(|v| match systemctl.status(v) {
|
||||||
Ok(unit) => serde_json::to_value(service::parse_service(unit)).unwrap(),
|
Ok(unit) => {
|
||||||
Err(_) => json!({ "name": v, "status": "undefined" }),
|
let a = service::parse_service(unit);
|
||||||
|
// In the case of debugging, i found out these have a pattern of .target or .device
|
||||||
|
// if a.all_fields_none() {
|
||||||
|
// println!("\n--START--\n{v}\n--END--\n");
|
||||||
|
// }
|
||||||
|
a
|
||||||
|
}
|
||||||
|
Err(_) => service::parse_service(String::new()),
|
||||||
})
|
})
|
||||||
|
.filter(|i| !i.all_fields_none())
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)),
|
)),
|
||||||
Err(e) => Err(actix_web::error::ErrorInternalServerError(format!(
|
Err(e) => Err(actix_web::error::ErrorInternalServerError(format!(
|
||||||
|
|||||||
+16
-1
@@ -15,7 +15,6 @@ pub struct Service {
|
|||||||
pub trigger: Option<String>,
|
pub trigger: Option<String>,
|
||||||
pub triggers: Option<String>,
|
pub triggers: Option<String>,
|
||||||
pub docs: Option<String>,
|
pub docs: Option<String>,
|
||||||
// Other fields can be added as needed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -63,3 +62,19 @@ pub fn parse_service(input: String) -> Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Service {
|
||||||
|
pub fn all_fields_none(&self) -> bool {
|
||||||
|
self.name.is_none()
|
||||||
|
&& self.description.is_none()
|
||||||
|
&& self.loaded_status.is_none()
|
||||||
|
&& self.unit_file_path.is_none()
|
||||||
|
&& self.enabled.is_none()
|
||||||
|
&& self.preset.is_none()
|
||||||
|
&& self.active.is_none()
|
||||||
|
&& self.active_state.is_none()
|
||||||
|
&& self.trigger.is_none()
|
||||||
|
&& self.triggers.is_none()
|
||||||
|
&& self.docs.is_none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user