-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persist servers and allow adding/removing them from the UI #9086
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3bc2320
move `RedapServers` to `AppState` and make it persistent (if empty)
abey79 460d982
Refactored collection query code + add/remove server icons + add serv…
abey79 7fea20b
Merge branch 'main' into antoine/add-remove-servers
abey79 cba8116
Post-merge fix + cleanup
abey79 9ca9f07
Add `with_ctx`
abey79 725771b
Merge branch 'main' into antoine/add-remove-servers
abey79 8e205df
Improve add server modal UI
abey79 bc63ca3
lint
abey79 1ab69da
Add generic `RequestedObject<T>`
abey79 520bb80
Use n=1 channel instead of a mutex
abey79 41527bc
Clean up duplicate server list and better de/ser handling
abey79 78ee134
Add auto ui repaint
abey79 b49c08a
remove useless crate
abey79 575da7a
Fix wasm build
abey79 a77ad20
Introduced `WasmNotSend` trait to fix that elusive, platform-dependen…
abey79 2ec97ee
add comment
abey79 bec44ad
duh
abey79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use re_ui::modal::{ModalHandler, ModalWrapper}; | ||
use re_uri::Scheme; | ||
|
||
use crate::context::Context; | ||
use crate::servers::Command; | ||
|
||
pub struct AddServerModal { | ||
modal: ModalHandler, | ||
|
||
scheme: Scheme, | ||
host: String, | ||
port: u16, | ||
} | ||
|
||
impl Default for AddServerModal { | ||
fn default() -> Self { | ||
Self { | ||
modal: Default::default(), | ||
scheme: Scheme::Rerun, | ||
host: String::new(), | ||
port: 443, | ||
} | ||
} | ||
} | ||
|
||
impl AddServerModal { | ||
pub fn open(&mut self) { | ||
self.scheme = Scheme::Rerun; | ||
self.port = 443; | ||
self.host = String::new(); | ||
|
||
self.modal.open(); | ||
} | ||
|
||
//TODO(ab): handle ESC and return | ||
pub fn ui(&mut self, ctx: &Context<'_>, ui: &egui::Ui) { | ||
self.modal.ui( | ||
ui.ctx(), | ||
|| ModalWrapper::new("Add Server"), | ||
|ui, keep_open| { | ||
ui.label("Scheme:"); | ||
|
||
egui::ComboBox::new("scheme", "") | ||
.selected_text(if self.scheme == Scheme::RerunHttp { | ||
"http" | ||
} else { | ||
"https" | ||
}) | ||
.show_ui(ui, |ui| { | ||
ui.selectable_value(&mut self.scheme, Scheme::RerunHttps, "https"); | ||
ui.selectable_value(&mut self.scheme, Scheme::RerunHttp, "http"); | ||
}); | ||
|
||
ui.add_space(14.0); | ||
|
||
ui.label("Host name:"); | ||
let host = url::Host::parse(&self.host); | ||
ui.scope(|ui| { | ||
// make field red if host is invalid | ||
if host.is_err() { | ||
ui.visuals_mut().widgets.active.bg_stroke = | ||
egui::Stroke::new(1.0, ui.visuals().error_fg_color); | ||
ui.visuals_mut().widgets.hovered.bg_stroke = | ||
egui::Stroke::new(1.0, ui.visuals().error_fg_color); | ||
ui.visuals_mut().widgets.inactive.bg_stroke = | ||
egui::Stroke::new(1.0, ui.visuals().error_fg_color); | ||
} | ||
ui.add(egui::TextEdit::singleline(&mut self.host).lock_focus(false)); | ||
}); | ||
|
||
ui.add_space(14.0); | ||
|
||
ui.label("Port:"); | ||
ui.add(egui::DragValue::new(&mut self.port)); | ||
|
||
let origin = host.map(|host| re_uri::Origin { | ||
scheme: self.scheme, | ||
host, | ||
port: self.port, | ||
}); | ||
|
||
ui.add_space(24.0); | ||
|
||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { | ||
if let Ok(origin) = origin { | ||
if ui.button("Add").clicked() { | ||
*keep_open = false; | ||
|
||
let _ = ctx.command_sender.send(Command::AddServer(origin)); | ||
} | ||
} else { | ||
ui.add_enabled(false, egui::Button::new("Add")); | ||
} | ||
|
||
if ui.button("Cancel").clicked() { | ||
*keep_open = false; | ||
} | ||
}); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was already in the dependency tree