about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-27 16:47:29 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-10-27 16:47:51 +0200
commit02333e4a1ca6f1e260693b0bf6b580d5844fcb92 (patch)
tree10eeeb714958cd263b9ea7fa6fa757eb97518916
parentFrontend: Fetch results from indexer (diff)
downloadOSSE-02333e4a1ca6f1e260693b0bf6b580d5844fcb92.tar.gz
OSSE-02333e4a1ca6f1e260693b0bf6b580d5844fcb92.tar.bz2
OSSE-02333e4a1ca6f1e260693b0bf6b580d5844fcb92.zip
Frontend: Use display_results() function for rendering CrawledResources
-rw-r--r--frontend/src/main.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index 26fb7e4..fd28d89 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -42,6 +42,19 @@ fn osse() -> Html {
         results: vec![],
     });
 
+    let display_results = |results: &Vec<CrawledResource>| -> Html {
+        results
+            .into_iter()
+            .map(|r| {
+                html! {
+                    <div key={r.url.to_owned()}>
+                        <a href={r.url.to_owned()}>{r.url.to_owned()}{"--"}{r.priority}</a>
+                    </div>
+                }
+            })
+            .collect::<Html>()
+    };
+
     let search_query_changed = {
         let cloned_state = state.clone();
         Callback::from(move |event: InputEvent| {
@@ -112,11 +125,7 @@ fn osse() -> Html {
                             </div>
                         </form>
                         <section>
-                            {curr_state.results.into_iter().map(|r| {
-                                html!{
-                                    <div key={r.url.to_owned()}>{ format!("Result: {:?}!", r) }</div>
-                                }
-                            }).collect::<Html>()}
+                            {display_results(&curr_state.results)}
                         </section>
                 </div>
             </div>