Added show project name on launchpad functionnality and updated the README accordingly
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
5ad765fcae
commit
de1e93a64f
30
README.md
30
README.md
@ -18,6 +18,30 @@ I used mainly two libraries for this project:
|
|||||||
|
|
||||||
These two libraries are maintained at the moment this README is being written.
|
These two libraries are maintained at the moment this README is being written.
|
||||||
|
|
||||||
|
## Using
|
||||||
|
|
||||||
|
### Open associated project
|
||||||
|
|
||||||
|
Clicking on a tile opens the corresponding web page for the project linked to
|
||||||
|
this tile.
|
||||||
|
|
||||||
|
### Retry/create pipeline for project
|
||||||
|
|
||||||
|
Clicking on the `A` button will engage the `restart` mode. As long as it is
|
||||||
|
lit up, the mode is engaged.
|
||||||
|
|
||||||
|
If you click on a tile while the `A` button is lit up, it will retry or create a
|
||||||
|
new pipeline for this project and for this ref. You can disengage the mode by
|
||||||
|
pressing again the `A` button.
|
||||||
|
|
||||||
|
### Show project name on launchpad
|
||||||
|
|
||||||
|
Clicking on the `B` button will engage the `show text` mode. As long as it is
|
||||||
|
lit up, the mode is engaged.
|
||||||
|
|
||||||
|
If you click on a tile while the `B` button is lit up, it will show the project
|
||||||
|
name. You can disengage the mode by pressing again the `B` button.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
As any other `cargo` project, it can be built with a simple command:
|
As any other `cargo` project, it can be built with a simple command:
|
||||||
@ -41,12 +65,6 @@ in the current working directory. An example configuration file is provided,
|
|||||||
The abs\_x and abs\_y coordinate are defined using the top-left grid tile as
|
The abs\_x and abs\_y coordinate are defined using the top-left grid tile as
|
||||||
the origin.
|
the origin.
|
||||||
|
|
||||||
Clicking on a tile opens the corresponding web page for the project linked to
|
|
||||||
this tile. Clicking on the `A` button will light it up, it is the restart button.
|
|
||||||
If you click on a tile with the `A` button lit up, it will retry or create a
|
|
||||||
new pipeline for this project and for this ref. You can disengage the restart
|
|
||||||
mode by pressing again the `A` button.
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
This project has some limitations right now, and some of them will be fixed:
|
This project has some limitations right now, and some of them will be fixed:
|
||||||
|
@ -4,34 +4,38 @@ use log::{trace, debug, warn};
|
|||||||
use crate::{config_manager::Config, gitlab_controller::retry_pipeline};
|
use crate::{config_manager::Config, gitlab_controller::retry_pipeline};
|
||||||
|
|
||||||
const RESTART_BUTTON: Button = Button::GridButton { x: 8, y: 0 }; // A BUTTON
|
const RESTART_BUTTON: Button = Button::GridButton { x: 8, y: 0 }; // A BUTTON
|
||||||
|
const SHOW_TEXT_BUTTON: Button = Button::GridButton { x: 8, y: 1 }; // B BUTTON
|
||||||
|
|
||||||
fn engage_restart(output: &mut Output) {
|
fn set_restart_light(output: &mut Output, status: bool) {
|
||||||
trace!("Engaging restart mode.");
|
trace!("{} restart mode.", if status { "Engaged" } else { "Disengaged" });
|
||||||
output.set_button(RESTART_BUTTON, Color::DIM_GREEN, DoubleBufferingBehavior::Copy).unwrap();
|
output.set_button(RESTART_BUTTON,
|
||||||
|
if status { Color::DIM_GREEN } else { Color::OFF },
|
||||||
|
DoubleBufferingBehavior::Copy).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disengage_restart(output: &mut Output) {
|
fn set_show_text_light(output: &mut Output, status: bool) {
|
||||||
trace!("Disengaging restart mode.");
|
trace!("{} show text mode.", if status { "Engaged" } else { "Disengaged" });
|
||||||
output.set_button(RESTART_BUTTON, Color::OFF, DoubleBufferingBehavior::Copy).unwrap();
|
output.set_button(SHOW_TEXT_BUTTON,
|
||||||
|
if status { Color::DIM_GREEN } else { Color::OFF },
|
||||||
|
DoubleBufferingBehavior::Copy).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn running_thread(config: Config) {
|
fn running_thread(config: Config) {
|
||||||
trace!("Starting a thread dedicated to the Launchpad input.");
|
trace!("Starting a thread dedicated to the Launchpad input.");
|
||||||
let mut output = Output::guess().unwrap();
|
let mut output = Output::guess().unwrap();
|
||||||
let input = Input::guess_polling().unwrap();
|
let input = Input::guess_polling().unwrap();
|
||||||
let mut restart = false;
|
let (mut restart, mut show) = (false, false);
|
||||||
for msg in input.iter() {
|
for msg in input.iter() {
|
||||||
debug!("Got message from Launchpad: {:?}.", msg);
|
debug!("Got message from Launchpad: {:?}.", msg);
|
||||||
if let Message::Release { button } = msg {
|
if let Message::Release { button } = msg {
|
||||||
if button == RESTART_BUTTON {
|
if button == RESTART_BUTTON {
|
||||||
debug!("Restart button has been pressed.");
|
debug!("Restart button has been pressed.");
|
||||||
if !restart {
|
restart = !restart;
|
||||||
restart = true;
|
set_restart_light(&mut output, restart);
|
||||||
engage_restart(&mut output);
|
} else if button == SHOW_TEXT_BUTTON {
|
||||||
} else {
|
debug!("Show text button has been pressed.");
|
||||||
restart = false;
|
show = !show;
|
||||||
disengage_restart(&mut output);
|
set_show_text_light(&mut output, show);
|
||||||
}
|
|
||||||
} else if button.abs_x() != 8 {
|
} else if button.abs_x() != 8 {
|
||||||
debug!("A project tile has been pressed.");
|
debug!("A project tile has been pressed.");
|
||||||
let project = config.projects.iter()
|
let project = config.projects.iter()
|
||||||
@ -47,7 +51,12 @@ fn running_thread(config: Config) {
|
|||||||
project);
|
project);
|
||||||
restart = false;
|
restart = false;
|
||||||
retry_pipeline(config.host.as_str(), config.token.as_str(), project);
|
retry_pipeline(config.host.as_str(), config.token.as_str(), project);
|
||||||
disengage_restart(&mut output);
|
set_restart_light(&mut output, restart);
|
||||||
|
} else if show {
|
||||||
|
debug!("Showing project name on launchpad for project {:?}.", project);
|
||||||
|
show = false;
|
||||||
|
set_show_text_light(&mut output, show);
|
||||||
|
output.scroll_text(project.name.as_bytes(), Color::RED, false).unwrap();
|
||||||
} else {
|
} else {
|
||||||
let url = format!("https://{}/{}", config.host, project.name);
|
let url = format!("https://{}/{}", config.host, project.name);
|
||||||
debug!("Restart mode isn't engaged. Trying to open project {:?} in browser with URL {}.",
|
debug!("Restart mode isn't engaged. Trying to open project {:?} in browser with URL {}.",
|
||||||
|
Loading…
Reference in New Issue
Block a user