@@ -155,8 +155,14 @@ async fn get_values_by_id(id: i32) -> Result<(Vec<f64>, Vec<f64>, String), reqwe
155155 let output = convert_string ( entry) ;
156156 console:: log_1 ( & serde_wasm_bindgen:: to_value ( & "output" ) . unwrap ( ) ) ;
157157 console:: log_1 ( & serde_wasm_bindgen:: to_value ( & output) . unwrap ( ) ) ;
158+ console:: log_1 ( & serde_wasm_bindgen:: to_value ( & "entry.library" ) . unwrap ( ) ) ;
159+ console:: log_1 ( & serde_wasm_bindgen:: to_value ( & entry. library ) . unwrap ( ) ) ;
158160
159- let url = format ! ( "https://raw.githubusercontent.com/openmc-data-storage/ENDF-B-VIII.0-NNDC-json/refs/heads/main/json_files/{output}.json" ) ;
161+ let url = match entry. library . as_str ( ) {
162+ "ENDFB-8.0" => format ! ( "https://raw.githubusercontent.com/openmc-data-storage/ENDF-B-VIII.0-NNDC-json/refs/heads/main/json_files/{output}.json" ) ,
163+ "FENDL-3.2c" => format ! ( "https://raw.githubusercontent.com/openmc-data-storage/FENDL-3.2c-json/refs/heads/main/FENDL-3.2c_json/{output}.json" ) ,
164+ _ => panic ! ( "Unsupported library: {}" , entry. library) ,
165+ } ;
160166
161167 console:: log_1 ( & serde_wasm_bindgen:: to_value ( & url) . unwrap ( ) ) ;
162168 let downloaded_reaction_data: ReactionData = reqwest:: get ( url)
@@ -166,7 +172,7 @@ async fn get_values_by_id(id: i32) -> Result<(Vec<f64>, Vec<f64>, String), reqwe
166172 console:: log_1 ( & serde_wasm_bindgen:: to_value ( "downloaded data" ) . unwrap ( ) ) ;
167173 console:: log_1 ( & serde_wasm_bindgen:: to_value ( & downloaded_reaction_data) . unwrap ( ) ) ;
168174
169- let label = entry. element . clone ( ) + entry. nucleons . to_string ( ) . as_str ( ) + " " + entry. reaction . as_str ( ) ; // + " " +entry.library.as_str() +" " + entry.temperature.as_str();
175+ let label = entry. element . clone ( ) + entry. nucleons . to_string ( ) . as_str ( ) + " " + entry. reaction . as_str ( ) + " " +entry. library . as_str ( ) ; // +" " + entry.temperature.as_str();
170176 Ok ( ( downloaded_reaction_data. energy_values , downloaded_reaction_data. cross_section_values , label) )
171177}
172178
@@ -179,7 +185,7 @@ fn convert_string(entry: &Entry) -> String {
179185 let particle: char = 'n' ; // entry.particle.clone();
180186 let mt = entry. mt . clone ( ) ;
181187 let temperature = entry. temperature . clone ( ) ;
182- let output = format ! ( "{}_{}_{}_{}_{}_{}" , element, nucleons, library, particle, mt, temperature) ;
188+ let output = format ! ( "{}_{}_{}_{}_{}_{}K " , element, nucleons, library, particle, mt, temperature) ;
183189 output
184190}
185191
@@ -193,10 +199,12 @@ pub fn home() -> Html {
193199 let nucleons_search_term = use_state ( || None :: < String > ) ;
194200 let reaction_search_term = use_state ( || None :: < String > ) ;
195201 let mt_search_term = use_state ( || None :: < String > ) ;
202+ let library_search_term = use_state ( || None :: < String > ) ;
196203 let element_search = ( * element_search_term) . as_ref ( ) . cloned ( ) ;
197204 let nucleons_search = ( * nucleons_search_term) . as_ref ( ) . cloned ( ) ;
198205 let reaction_search = ( * reaction_search_term) . as_ref ( ) . cloned ( ) ;
199206 let mt_search = ( * mt_search_term) . as_ref ( ) . cloned ( ) ;
207+ let library_search = ( * library_search_term) . as_ref ( ) . cloned ( ) ;
200208
201209 let page = use_state ( || 0usize ) ;
202210 let current_page = ( * page) . clone ( ) ;
@@ -212,6 +220,7 @@ pub fn home() -> Html {
212220 ColumnBuilder :: new( "reaction" ) . orderable( true ) . short_name( "Reaction" ) . data_property( "reaction" ) . header_class( "user-select-none" ) . build( ) ,
213221 // ColumnBuilder::new("library").orderable(true).short_name("Library").data_property("library").header_class("user-select-none").build(),
214222 ColumnBuilder :: new( "mt" ) . orderable( true ) . short_name( "MT" ) . data_property( "mt" ) . header_class( "user-select-none" ) . build( ) ,
223+ ColumnBuilder :: new( "library" ) . orderable( true ) . short_name( "Library" ) . data_property( "library" ) . header_class( "user-select-none" ) . build( ) ,
215224 // ColumnBuilder::new("temperature").orderable(true).short_name("Temperature").data_property("temperature").header_class("user-select-none").build(),
216225 ] ;
217226
@@ -239,6 +248,7 @@ pub fn home() -> Html {
239248 let nucleons = & entry. nucleons ;
240249 let reaction = & entry. reaction ;
241250 let mt = & entry. mt ;
251+ let library = & entry. library ;
242252
243253 let element_match = match element_search {
244254 Some ( ref term) => element. to_lowercase ( ) . contains ( & term. to_lowercase ( ) ) ,
@@ -256,17 +266,21 @@ pub fn home() -> Html {
256266 Some ( ref term) => mt. to_string ( ) . contains ( & * term) ,
257267 None => true ,
258268 } ;
269+ let library_match = match library_search {
270+ Some ( ref term) => library. to_lowercase ( ) . contains ( & term. to_lowercase ( ) ) ,
271+ None => true ,
272+ } ;
259273
260- element_match && nucleons_match && reaction_match && mt_match
274+ element_match && nucleons_match && reaction_match && mt_match && library_match
261275 } )
262276 . map ( |( index, entry) | TableLine {
263277 original_index : index,
264278 id : entry. id ,
265279 element : entry. element . clone ( ) ,
266280 nucleons : entry. nucleons . clone ( ) ,
267- library : entry. library . clone ( ) ,
268281 reaction : entry. reaction . clone ( ) ,
269282 mt : entry. mt . clone ( ) ,
283+ library : entry. library . clone ( ) ,
270284 temperature : entry. temperature . clone ( ) ,
271285 checked : selected_indexes. current ( ) . contains ( & index) ,
272286 sum_callback : callback_sum. clone ( ) ,
@@ -339,6 +353,18 @@ pub fn home() -> Html {
339353 } )
340354 } ;
341355
356+ let oninput_library_search = {
357+ let library_search_term = library_search_term. clone ( ) ;
358+ Callback :: from ( move |e : InputEvent | {
359+ let input: HtmlInputElement = e. target_unchecked_into ( ) ;
360+ if input. value ( ) . is_empty ( ) {
361+ library_search_term. set ( None ) ;
362+ } else {
363+ library_search_term. set ( Some ( input. value ( ) ) ) ;
364+ }
365+ } )
366+ } ;
367+
342368 // let pagination_options = yew_custom_components::pagination::Options::default()
343369 // .show_prev_next(true)
344370 // .show_first_last(true)
@@ -412,6 +438,18 @@ pub fn home() -> Html {
412438 oninput={ oninput_mt_search}
413439 />
414440 </div>
441+ <div class="flex-grow-1 p-2 input-group" >
442+ <span class="input-group-text" >
443+ <i class="fas fa-search" ></i>
444+ </span>
445+ <input
446+ class="form-control"
447+ type ="text"
448+ id="library-search"
449+ placeholder="Search by library"
450+ oninput={ oninput_library_search}
451+ />
452+ </div>
415453 </div>
416454
417455
@@ -421,13 +459,13 @@ pub fn home() -> Html {
421459 options={ options. clone( ) }
422460 limit={ Some ( limit) }
423461 page={ current_page}
424- search={ element_search. clone( ) }
462+ // search={element_search.clone()}
425463 classes={ classes!( "table" , "table-hover" ) }
426464 columns={ columns. clone( ) }
427465 data={ paginated_data}
428466 orderable={ true }
429467 />
430- <h5>{ "Number selected " } <span class="badge text-bg-secondary" >{ sum} </span></h5>
468+ <h5>{ "Selected " } <span class="badge text-bg-secondary" >{ sum} </span>{ " from 41337 available database entries." } </h5>
431469 </div>
432470 <div class="flex-grow-1 p-2 input-group" >
433471
@@ -454,17 +492,17 @@ struct TableLine {
454492 pub id : i32 ,
455493 pub element : String ,
456494 pub nucleons : i32 ,
457- pub library : String ,
458495 pub reaction : String ,
459496 pub mt : i32 ,
497+ pub library : String ,
460498 pub temperature : String ,
461499 #[ serde( skip_serializing) ]
462500 pub sum_callback : Callback < usize > ,
463501}
464502
465503impl PartialEq < Self > for TableLine {
466504 fn eq ( & self , other : & Self ) -> bool {
467- self . element == other. element && self . nucleons == other. nucleons && self . checked == other. checked
505+ self . element == other. element && self . nucleons == other. nucleons && self . library == other . library && self . reaction == other . reaction && self . mt == other . mt && self . checked == other. checked
468506 }
469507}
470508
0 commit comments