Skip to content

Commit 86ae31c

Browse files
patrickelectricjoaoantoniocardoso
authored andcommitted
webpage: app: Run cargo fmt
Signed-off-by: Patrick José Pereira <[email protected]>
1 parent c26ab2e commit 86ae31c

File tree

1 file changed

+84
-69
lines changed

1 file changed

+84
-69
lines changed

src/webpage/src/app.rs

+84-69
Original file line numberDiff line numberDiff line change
@@ -209,105 +209,120 @@ impl App {
209209
}
210210

211211
fn show_helper_screen(&mut self, ctx: &Context) {
212-
egui::CentralPanel::default()
213-
.show(ctx, |ui| {
214-
ui.horizontal_top(|ui| {
215-
ui.label("Search:");
216-
ui.add(
217-
AutoCompleteTextEdit::new(
218-
&mut self.search_help_mavlink_query,
219-
mavlink_names,
220-
),
221-
);
222-
223-
if ui.button("Find").clicked() {
224-
let mavlink_code = self.mavlink_code.clone();
225-
ehttp::fetch(Request::get(format!("/{MAVLINK_HELPER}?name={}", self.search_help_mavlink_query)), move |res| {
212+
egui::CentralPanel::default().show(ctx, |ui| {
213+
ui.horizontal_top(|ui| {
214+
ui.label("Search:");
215+
ui.add(AutoCompleteTextEdit::new(
216+
&mut self.search_help_mavlink_query,
217+
mavlink_names,
218+
));
219+
220+
if ui.button("Find").clicked() {
221+
let mavlink_code = self.mavlink_code.clone();
222+
ehttp::fetch(
223+
Request::get(format!(
224+
"/{MAVLINK_HELPER}?name={}",
225+
self.search_help_mavlink_query
226+
)),
227+
move |res| {
226228
let mut s = mavlink_code.lock();
227229
*s = match res {
228230
Ok(Response { bytes, .. }) => String::from_utf8(bytes).unwrap(),
229231
Err(error) => format!("Error: {error:?}"),
230232
};
231-
});
232-
}
233-
});
234-
235-
let mut theme = egui_extras::syntax_highlighting::CodeTheme::from_memory(ui.ctx(), ui.style());
236-
ui.collapsing("Theme", |ui| {
237-
ui.group(|ui| {
238-
theme.ui(ui);
239-
theme.clone().store_in_memory(ui.ctx());
240-
});
241-
});
242-
243-
let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| {
244-
let mut layout_job = egui_extras::syntax_highlighting::highlight(
245-
ui.ctx(),
246-
ui.style(),
247-
&theme,
248-
string,
249-
"js",
233+
},
250234
);
251-
layout_job.wrap.max_width = wrap_width;
252-
ui.fonts(|f| f.layout_job(layout_job))
253-
};
235+
}
236+
});
254237

255-
egui::ScrollArea::vertical().show(ui, |ui| {
256-
let mut mavlink_code = self.mavlink_code.lock().to_owned();
257-
ui.add(
258-
egui::TextEdit::multiline(&mut mavlink_code)
259-
.font(egui::TextStyle::Monospace)
260-
.code_editor()
261-
.desired_rows(30)
262-
.lock_focus(true)
263-
.desired_width(500.0)
264-
.layouter(&mut layouter),
265-
);
266-
*self.mavlink_code.lock() = mavlink_code;
238+
let mut theme =
239+
egui_extras::syntax_highlighting::CodeTheme::from_memory(ui.ctx(), ui.style());
240+
ui.collapsing("Theme", |ui| {
241+
ui.group(|ui| {
242+
theme.ui(ui);
243+
theme.clone().store_in_memory(ui.ctx());
267244
});
245+
});
268246

269-
ui.horizontal_top(|ui| {
270-
if ui.button("Send").clicked() {
271-
let mavlink_code = self.mavlink_code.lock();
272-
273-
let mut request = Request::post(format!("/{MAVLINK_POST}"), mavlink_code.clone().into_bytes());
274-
request.headers.insert("Content-Type", "application/json");
247+
let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| {
248+
let mut layout_job = egui_extras::syntax_highlighting::highlight(
249+
ui.ctx(),
250+
ui.style(),
251+
&theme,
252+
string,
253+
"js",
254+
);
255+
layout_job.wrap.max_width = wrap_width;
256+
ui.fonts(|f| f.layout_job(layout_job))
257+
};
275258

276-
let mavlink_code_post_response = self.mavlink_code_post_response.clone();
277-
*mavlink_code_post_response.lock() = String::default();
278-
ehttp::fetch(request, move |res| {
279-
let mut s = mavlink_code_post_response.lock();
280-
*s = match res {
281-
Ok(Response { bytes, .. }) => String::from_utf8(bytes).unwrap(),
282-
Err(error) => format!("Error: {error:?}"),
283-
};
284-
});
285-
}
286-
ui.label(format!("{}", *self.mavlink_code_post_response.lock()));
259+
egui::ScrollArea::vertical().show(ui, |ui| {
260+
let mut mavlink_code = self.mavlink_code.lock().to_owned();
261+
ui.add(
262+
egui::TextEdit::multiline(&mut mavlink_code)
263+
.font(egui::TextStyle::Monospace)
264+
.code_editor()
265+
.desired_rows(30)
266+
.lock_focus(true)
267+
.desired_width(500.0)
268+
.layouter(&mut layouter),
269+
);
270+
*self.mavlink_code.lock() = mavlink_code;
287271
});
272+
273+
ui.horizontal_top(|ui| {
274+
if ui.button("Send").clicked() {
275+
let mavlink_code = self.mavlink_code.lock();
276+
277+
let mut request = Request::post(
278+
format!("/{MAVLINK_POST}"),
279+
mavlink_code.clone().into_bytes(),
280+
);
281+
request.headers.insert("Content-Type", "application/json");
282+
283+
let mavlink_code_post_response = self.mavlink_code_post_response.clone();
284+
*mavlink_code_post_response.lock() = String::default();
285+
ehttp::fetch(request, move |res| {
286+
let mut s = mavlink_code_post_response.lock();
287+
*s = match res {
288+
Ok(Response { bytes, .. }) => String::from_utf8(bytes).unwrap(),
289+
Err(error) => format!("Error: {error:?}"),
290+
};
291+
});
292+
}
293+
ui.label(format!("{}", *self.mavlink_code_post_response.lock()));
288294
});
295+
});
289296
}
290297

291298
fn show_control_screen(&mut self, ctx: &Context) {
292299
egui::CentralPanel::default().show(ctx, |ui| {
293300
ui.label("Control");
294301
if ui.button("Arm").clicked() {
295-
let mut request = Request::post(format!("/{CONTROL_VEHICLES}/arm"), "{
302+
let mut request = Request::post(
303+
format!("/{CONTROL_VEHICLES}/arm"),
304+
"{
296305
\"system_id\": 1,
297306
\"component_id\": 1,
298307
\"force\": true
299-
}".into());
308+
}"
309+
.into(),
310+
);
300311
request.headers.insert("Content-Type", "application/json");
301312
ehttp::fetch(request, |res| {
302313
log::info!("Arm response: {res:?}");
303314
});
304315
}
305316
if ui.button("Disarm").clicked() {
306-
let mut request = Request::post(format!("/{CONTROL_VEHICLES}/disarm"), "{
317+
let mut request = Request::post(
318+
format!("/{CONTROL_VEHICLES}/disarm"),
319+
"{
307320
\"system_id\": 1,
308321
\"component_id\": 1,
309322
\"force\": true
310-
}".into());
323+
}"
324+
.into(),
325+
);
311326
request.headers.insert("Content-Type", "application/json");
312327
ehttp::fetch(request, |res| {
313328
log::info!("Disarm response: {res:?}");

0 commit comments

Comments
 (0)