Skip to content

Commit a96b054

Browse files
authored
UI Improvements (#14)
* Show watched workloads on main page. Refactor to create a 'system info card' for future information. Add css styles for card. * Rename release workflow to not have the release version in the name
1 parent 47d2591 commit a96b054

File tree

3 files changed

+56
-34
lines changed

3 files changed

+56
-34
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release v0.3.8
1+
name: Release Slackwatch
22

33
on:
44
push:

assets/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@
109109
font-size: 1.25em;
110110
}
111111

112-
.next-scheduled-time {
112+
.system-info-entry {
113+
margin-top: 10px;
114+
}
115+
116+
.system-info-card {
113117
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
114118
padding: 20px;
115119
border-radius: 8px;

src/site/app.rs

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ struct WorkloadCardProps {
3333
workload: Workload,
3434
}
3535

36+
#[derive(PartialEq, Clone,Props)]
37+
struct WorkloadsProps {
38+
workloads: Vec<Workload>,
39+
}
40+
3641

3742
#[server] // For the server-side rendering version
3843
async fn get_all_workloads() -> Result<String, ServerFnError> {
@@ -118,7 +123,7 @@ fn Home() -> Element {
118123
} else {
119124
rsx! {
120125
div { class: "workloads-page",
121-
NextScheduledTimeCard {},
126+
SystemInfoCard {workloads: workloads.clone()},
122127
for w in workloads.iter() {
123128
WorkloadCard{workload: w.clone()}
124129
}
@@ -136,6 +141,49 @@ fn Home() -> Element {
136141
}
137142
}
138143

144+
145+
// ... rest of the code ...
146+
#[component]
147+
fn SystemInfoCard(props: WorkloadsProps) -> Element {
148+
let data = use_signal(|| {props.workloads.clone()});
149+
rsx! {
150+
div { class: "system-info-card",
151+
div { class: "system-info", "System Info" },
152+
div { class: "system-info-entry","Watched Workloads: {data().len()}" },
153+
NextScheduledTimeCard {},
154+
}
155+
}
156+
}
157+
158+
#[component]
159+
fn NextScheduledTimeCard() -> Element {
160+
let settings_context = use_context::<Signal<Settings>>();
161+
log::info!("settings context: {:?}", settings_context);
162+
let mut next_schedule = use_server_future(move || async move {
163+
let settings = settings_context.read();
164+
get_next_schedule_time(settings.clone()).await
165+
})?;
166+
match next_schedule() {
167+
Some(Ok(next_schedule)) => {
168+
rsx! {
169+
div { class: "system-info-entry", "Next Run: {next_schedule}" }
170+
div { class: "system-info-entry",
171+
a { href: "/refresh-all", "Click to Run Now" }
172+
}
173+
}
174+
},
175+
Some(Err(err)) => {
176+
rsx! { div { "Error: {err}" } }
177+
},
178+
None => {
179+
rsx! { div { "Loading..." } }
180+
}
181+
_ => {
182+
rsx! { div { "Loading..." } }
183+
}
184+
}
185+
}
186+
139187
#[component]
140188
fn DebugWorkloadCard(props: WorkloadCardProps) -> Element {
141189
rsx! {
@@ -214,7 +262,7 @@ pub fn App() -> Element {
214262
//use_context_provider(|| {
215263
// //Signal::new(settings)
216264
//});
217-
265+
218266
// use_context_provider(|| Signal::new(Appsettings:settings) );
219267
// use_context_provider(|| Signal::new(load_settings) );
220268
//load config
@@ -299,37 +347,7 @@ fn All() -> Element {
299347
}
300348

301349

302-
// ... rest of the code ...
303350

304-
#[component]
305-
fn NextScheduledTimeCard() -> Element {
306-
let settings_context = use_context::<Signal<Settings>>();
307-
log::info!("settings context: {:?}", settings_context);
308-
let mut next_schedule = use_server_future(move || async move {
309-
let settings = settings_context.read();
310-
get_next_schedule_time(settings.clone()).await
311-
})?;
312-
match next_schedule() {
313-
Some(Ok(next_schedule)) => {
314-
rsx! {
315-
div { class: "next-scheduled-time",
316-
div { class: "system-info", "System Info" },
317-
div { "Next Run: {next_schedule}" }
318-
a { href: "/refresh-all", "Click to Run Now" }
319-
}
320-
}
321-
},
322-
Some(Err(err)) => {
323-
rsx! { div { "Error: {err}" } }
324-
},
325-
None => {
326-
rsx! { div { "Loading..." } }
327-
}
328-
_ => {
329-
rsx! { div { "Loading..." } }
330-
}
331-
}
332-
}
333351

334352
#[server]
335353
async fn get_next_schedule_time(settings: Settings) -> Result<String, ServerFnError> {

0 commit comments

Comments
 (0)