-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate API URLs on the client during compile time
- Loading branch information
1 parent
24c2789
commit 952b29c
Showing
4 changed files
with
91 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use leptos::*; | ||
use leptos_router::*; | ||
|
||
use crate::{ | ||
app::sound_button::SoundButton, | ||
core::{get_sounds, Sound, HL_SOUNDS_STRING}, | ||
projector_commands, | ||
}; | ||
|
||
#[component] | ||
pub fn Projector(cx: Scope) -> impl IntoView { | ||
log!("Projector"); | ||
|
||
log!("{}", projector_commands::power::on); | ||
|
||
view! { cx, | ||
<div class=" | ||
grid gap-2 | ||
grid-cols-2 sm:grid-cols-3 md:grid-cols-4 | ||
m-2 max-w-[1400px] min-[1416px]:mx-auto | ||
"> | ||
// <For | ||
// each=async_result | ||
// key=|sound| sound.name.clone() | ||
// view=move |cx, sound: Sound| { | ||
// view! { cx, | ||
// // <button>"Value: " {move || counter.count.get()}</button> | ||
// <SoundButton sound/> | ||
// } | ||
// } | ||
// /> | ||
</div> | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod app; | ||
mod core; | ||
mod license_notice; | ||
mod projector_commands; | ||
// mod components; | ||
|
||
use leptos::*; | ||
|
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,53 @@ | ||
#![allow(non_upper_case_globals)] | ||
|
||
const BASE_URL: &str = "http://licht.realraum.at:4201/api/v1/"; | ||
|
||
macro_rules! make_api_urls { | ||
// Match the list of identifiers and the module name and assign them to $name and $module | ||
($($name:ident),*; $module:ident) => { | ||
// For each identifier in the list, expand to a constant declaration | ||
$(pub const $name: &str = concat!("http://licht.realraum.at:4201/api/v1/", stringify!($module), "/", stringify!($name));)* | ||
}; | ||
} | ||
|
||
pub mod input { | ||
// FIXME these may not work on all projectors | ||
|
||
make_api_urls!( | ||
vga_a, | ||
vga_b, | ||
composite, | ||
s_video, | ||
hdmi, | ||
wireless, | ||
usb_display, | ||
usb_viewer; | ||
input | ||
); | ||
} | ||
|
||
pub mod volume { | ||
make_api_urls!(up, down, mute, un_mute; volume); | ||
} | ||
|
||
pub mod power { | ||
make_api_urls!(on, off; power); | ||
} | ||
|
||
pub mod menu { | ||
make_api_urls!(menu_button, up, down, left, right, ok; menu); | ||
} | ||
|
||
pub mod picture { | ||
make_api_urls!( | ||
blank, | ||
un_blank, | ||
freeze, | ||
un_freeze, | ||
contrast_up, | ||
contrast_down, | ||
brightness_up, | ||
brightness_down; | ||
picture | ||
); | ||
} |