Skip to content

Commit 447b0d6

Browse files
authored
Merge pull request #200 from ineiti/fix_things
Fix things
2 parents 54b0ea2 + 54e6c6c commit 447b0d6

9 files changed

Lines changed: 207 additions & 106 deletions

File tree

flbrowser/index.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ <h1>Danu</h1>
8888
</nav>
8989

9090
<main>
91+
<section id="status-section">
92+
<h2 style="display: inline; margin-right: 2em;">Node Status</h2>
93+
<div id="status-steps">
94+
<ul><li>Connecting to signalling server</li></ul>
95+
</div>
96+
</section>
97+
9198
<div class="container">
9299
<!-- Left column - Node Statistics -->
93100
<div class="column stats-column left" id="node-stats">
@@ -177,12 +184,6 @@ <h2>About Danu <button class="expand-btn" id="loading-info-button"
177184
</p>
178185
</section>
179186

180-
<section class="status-section">
181-
<h2>Node Status</h2>
182-
<ol class="status-steps" id="status-steps">
183-
<li>Connecting to signalling server</li>
184-
</ol>
185-
</section>
186187
</div>
187188

188189
<div id="home_page" hidden>

flbrowser/main.css

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,25 @@ section h2 {
363363
}
364364

365365
/* Status indicators */
366-
.status-section {
367-
background-color: rgba(52, 152, 219, 0.05);
368-
padding: 1rem;
369-
border-radius: 4px;
370-
border-left: 4px solid var(--primary-color);
366+
#status-section {
367+
max-width: 1400px;
368+
margin: 0.75rem auto 0;
369+
padding: 0.75rem 1rem;
370+
background-color: var(--card-bg-color);
371+
border-radius: 6px;
372+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
373+
border-bottom: none;
374+
}
375+
376+
#status-section h2 {
377+
font-size: 0.95rem;
378+
color: var(--text-secondary);
379+
font-weight: 500;
380+
margin-bottom: 0.4rem;
371381
}
372382

373-
.status-section .error {
374-
background-color: rgba(219, 152, 52, 0.05);
383+
#status-section.error {
384+
background-color: rgba(231, 76, 60, 0.08);
375385
}
376386

377387
#node-status {
@@ -452,18 +462,66 @@ section h2 {
452462
text-align: right;
453463
}
454464

455-
/* Make the status steps list look nicer */
456-
.status-steps {
465+
/* Arrow stepper for status steps */
466+
#status-steps {
467+
background-color: var(--border-color);
468+
border-radius: 4px;
469+
padding: 3px;
470+
padding-right: calc(1rem + 3px);
471+
display: inline-flex;
472+
align-items: center;
473+
}
474+
475+
#status-steps ul {
476+
display: flex;
457477
list-style: none;
458478
margin: 0;
459-
padding: 0.5rem 0 0 0;
460-
border-top: 1px dashed var(--border-color);
479+
padding: 0;
461480
}
462481

463-
.status-steps li {
482+
#status-steps li {
483+
position: relative;
484+
height: 2.4rem;
485+
line-height: 2.4rem;
486+
padding: 0 1.8rem 0 2rem;
487+
background-color: var(--highlight-bg-color);
464488
font-size: 0.9rem;
465-
color: var(--text-secondary);
466-
margin: 0.25rem 0 0 1rem;
489+
color: var(--text-color);
490+
white-space: nowrap;
491+
}
492+
493+
#status-steps li:first-child {
494+
padding-left: 1rem;
495+
}
496+
497+
#status-steps li:not(:first-child) {
498+
margin-left: -1rem;
499+
}
500+
501+
/* Right-pointing arrow on each step */
502+
#status-steps li::after {
503+
content: "";
504+
position: absolute;
505+
top: 0;
506+
right: -1rem;
507+
width: 0;
508+
height: 0;
509+
border-top: 1.2rem solid transparent;
510+
border-bottom: 1.2rem solid transparent;
511+
border-left: 1rem solid var(--highlight-bg-color);
512+
}
513+
514+
/* Left notch (">" cut) for non-first steps, revealing the border-color background */
515+
#status-steps li:not(:first-child)::before {
516+
content: "";
517+
position: absolute;
518+
top: 0;
519+
left: 0;
520+
width: 0;
521+
height: 0;
522+
border-top: 1.2rem solid transparent;
523+
border-bottom: 1.2rem solid transparent;
524+
border-left: 1rem solid var(--border-color);
467525
}
468526

469527
/* Homepage container */

flbrowser/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use proxy::Proxy;
1414
use std::{collections::HashMap, str::FromStr};
1515
use tokio::sync::{broadcast, watch};
1616
use wasm_bindgen::prelude::wasm_bindgen;
17-
use web_sys::{HtmlButtonElement, HtmlElement, HtmlOListElement};
17+
use web_sys::{HtmlButtonElement, HtmlElement, HtmlDivElement};
1818

1919
use flarch::{
2020
data_storage::DataStorageLocal,
@@ -171,7 +171,7 @@ impl WebState {
171171
}
172172
}
173173
StateEnum::ConnectingNodes => {
174-
if self.webn.dht_router.stats.borrow().active >= 2 {
174+
if self.webn.dht_router.stats.borrow().active >= 1 {
175175
self.set_state(StateEnum::UpdateDHT).await;
176176
}
177177
}
@@ -181,6 +181,7 @@ impl WebState {
181181
self.web
182182
.get_element::<HtmlButtonElement>("loading-info-button")
183183
.click();
184+
self.web.get_element::<HtmlElement>("status-section").set_hidden(true);
184185
self.web
185186
.get_element::<HtmlElement>("home_page")
186187
.set_hidden(false);
@@ -248,7 +249,7 @@ impl WebState {
248249
}
249250
self.state = new_state;
250251
self.web
251-
.get_element::<HtmlOListElement>("status-steps")
252+
.get_element::<HtmlDivElement>("status-steps")
252253
.set_inner_html(&self.status_box.to_string());
253254
}
254255

flmodules/src/dht_router/intern.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ impl Intern {
109109
vec![ModuleMessage::ConnectedIDsReply(self.core.active_nodes())
110110
.wrapper_network(from)]
111111
}
112-
ModuleMessage::ConnectedIDsReply(nodes) => self.add_nodes(nodes),
112+
ModuleMessage::ConnectedIDsReply(nodes) => {
113+
self.core.add_nodes(nodes);
114+
vec![]
115+
}
113116
},
114117
None => vec![],
115118
};
@@ -153,40 +156,40 @@ impl Intern {
153156
}
154157

155158
fn msg_network(&mut self, msg: RouterOut) -> Vec<InternOut> {
159+
// log::info!("msg_network({msg})");
156160
match msg {
157161
RouterOut::NodeInfoAvailable(node_infos) => self.add_node_infos(node_infos),
158162
RouterOut::NodeIDsConnected(connected) => {
159163
self.connected = connected.0.clone();
160-
self.add_nodes(connected.0)
164+
self.core.add_nodes(connected.0);
161165
}
162166
RouterOut::NetworkWrapperFromNetwork(from, network_wrapper) => {
163-
self.process_node_message(from, network_wrapper)
167+
return self.process_node_message(from, network_wrapper)
168+
}
169+
RouterOut::SystemConfig(conf) => {
170+
return conf
171+
.system_realm
172+
.map(|rid| vec![InternOut::DHTRouter(DHTRouterOut::SystemRealm(rid))])
173+
.unwrap_or(vec![])
164174
}
165-
RouterOut::SystemConfig(conf) => conf
166-
.system_realm
167-
.map(|rid| vec![InternOut::DHTRouter(DHTRouterOut::SystemRealm(rid))])
168-
.unwrap_or(vec![]),
169175
RouterOut::Disconnected(id) => {
170-
self.core.node_disconnected(id);
171-
vec![]
176+
self.core.node_disconnected(&id);
177+
}
178+
RouterOut::Connected(id) => {
179+
self.core.add_node(id);
172180
}
173-
_ => vec![],
181+
_ => {}
174182
}
183+
vec![]
175184
}
176185

177186
// Stores the new node list, excluding the ID of this node.
178-
fn add_node_infos(&mut self, infos: Vec<NodeInfo>) -> Vec<InternOut> {
187+
fn add_node_infos(&mut self, infos: Vec<NodeInfo>) {
179188
for info in &infos {
180189
self.infos.insert(info.get_id(), info.clone());
181190
}
182-
self.add_nodes(infos.iter().map(|i| i.get_id()).collect())
183-
}
184-
185-
fn add_nodes(&mut self, nodes: Vec<NodeID>) -> Vec<InternOut> {
186-
self.core.add_nodes(nodes);
187-
vec![InternOut::DHTRouter(DHTRouterOut::NodeList(
188-
self.core.active_nodes(),
189-
))]
191+
self.core
192+
.add_nodes(infos.iter().map(|i| i.get_id()).collect());
190193
}
191194

192195
// One second passes - and return messages for nodes to ping.
@@ -407,7 +410,7 @@ mod tests {
407410
InternIn::Tick,
408411
])
409412
.await;
410-
assert_eq!(5, out.len());
413+
assert_eq!(4, out.len());
411414

412415
Ok(())
413416
}

0 commit comments

Comments
 (0)