@@ -155,8 +155,14 @@ async fn get_values_by_id(id: i32) -> Result<(Vec<f64>, Vec<f64>, String), reqwe
155
155
let output = convert_string ( entry) ;
156
156
console:: log_1 ( & serde_wasm_bindgen:: to_value ( & "output" ) . unwrap ( ) ) ;
157
157
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 ( ) ) ;
158
160
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
+ } ;
160
166
161
167
console:: log_1 ( & serde_wasm_bindgen:: to_value ( & url) . unwrap ( ) ) ;
162
168
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
166
172
console:: log_1 ( & serde_wasm_bindgen:: to_value ( "downloaded data" ) . unwrap ( ) ) ;
167
173
console:: log_1 ( & serde_wasm_bindgen:: to_value ( & downloaded_reaction_data) . unwrap ( ) ) ;
168
174
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();
170
176
Ok ( ( downloaded_reaction_data. energy_values , downloaded_reaction_data. cross_section_values , label) )
171
177
}
172
178
@@ -179,7 +185,7 @@ fn convert_string(entry: &Entry) -> String {
179
185
let particle: char = 'n' ; // entry.particle.clone();
180
186
let mt = entry. mt . clone ( ) ;
181
187
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) ;
183
189
output
184
190
}
185
191
@@ -193,10 +199,12 @@ pub fn home() -> Html {
193
199
let nucleons_search_term = use_state ( || None :: < String > ) ;
194
200
let reaction_search_term = use_state ( || None :: < String > ) ;
195
201
let mt_search_term = use_state ( || None :: < String > ) ;
202
+ let library_search_term = use_state ( || None :: < String > ) ;
196
203
let element_search = ( * element_search_term) . as_ref ( ) . cloned ( ) ;
197
204
let nucleons_search = ( * nucleons_search_term) . as_ref ( ) . cloned ( ) ;
198
205
let reaction_search = ( * reaction_search_term) . as_ref ( ) . cloned ( ) ;
199
206
let mt_search = ( * mt_search_term) . as_ref ( ) . cloned ( ) ;
207
+ let library_search = ( * library_search_term) . as_ref ( ) . cloned ( ) ;
200
208
201
209
let page = use_state ( || 0usize ) ;
202
210
let current_page = ( * page) . clone ( ) ;
@@ -212,6 +220,7 @@ pub fn home() -> Html {
212
220
ColumnBuilder :: new( "reaction" ) . orderable( true ) . short_name( "Reaction" ) . data_property( "reaction" ) . header_class( "user-select-none" ) . build( ) ,
213
221
// ColumnBuilder::new("library").orderable(true).short_name("Library").data_property("library").header_class("user-select-none").build(),
214
222
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( ) ,
215
224
// ColumnBuilder::new("temperature").orderable(true).short_name("Temperature").data_property("temperature").header_class("user-select-none").build(),
216
225
] ;
217
226
@@ -239,6 +248,7 @@ pub fn home() -> Html {
239
248
let nucleons = & entry. nucleons ;
240
249
let reaction = & entry. reaction ;
241
250
let mt = & entry. mt ;
251
+ let library = & entry. library ;
242
252
243
253
let element_match = match element_search {
244
254
Some ( ref term) => element. to_lowercase ( ) . contains ( & term. to_lowercase ( ) ) ,
@@ -256,17 +266,21 @@ pub fn home() -> Html {
256
266
Some ( ref term) => mt. to_string ( ) . contains ( & * term) ,
257
267
None => true ,
258
268
} ;
269
+ let library_match = match library_search {
270
+ Some ( ref term) => library. to_lowercase ( ) . contains ( & term. to_lowercase ( ) ) ,
271
+ None => true ,
272
+ } ;
259
273
260
- element_match && nucleons_match && reaction_match && mt_match
274
+ element_match && nucleons_match && reaction_match && mt_match && library_match
261
275
} )
262
276
. map ( |( index, entry) | TableLine {
263
277
original_index : index,
264
278
id : entry. id ,
265
279
element : entry. element . clone ( ) ,
266
280
nucleons : entry. nucleons . clone ( ) ,
267
- library : entry. library . clone ( ) ,
268
281
reaction : entry. reaction . clone ( ) ,
269
282
mt : entry. mt . clone ( ) ,
283
+ library : entry. library . clone ( ) ,
270
284
temperature : entry. temperature . clone ( ) ,
271
285
checked : selected_indexes. current ( ) . contains ( & index) ,
272
286
sum_callback : callback_sum. clone ( ) ,
@@ -339,6 +353,18 @@ pub fn home() -> Html {
339
353
} )
340
354
} ;
341
355
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
+
342
368
// let pagination_options = yew_custom_components::pagination::Options::default()
343
369
// .show_prev_next(true)
344
370
// .show_first_last(true)
@@ -412,6 +438,18 @@ pub fn home() -> Html {
412
438
oninput={ oninput_mt_search}
413
439
/>
414
440
</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>
415
453
</div>
416
454
417
455
@@ -421,13 +459,13 @@ pub fn home() -> Html {
421
459
options={ options. clone( ) }
422
460
limit={ Some ( limit) }
423
461
page={ current_page}
424
- search={ element_search. clone( ) }
462
+ // search={element_search.clone()}
425
463
classes={ classes!( "table" , "table-hover" ) }
426
464
columns={ columns. clone( ) }
427
465
data={ paginated_data}
428
466
orderable={ true }
429
467
/>
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>
431
469
</div>
432
470
<div class="flex-grow-1 p-2 input-group" >
433
471
@@ -454,17 +492,17 @@ struct TableLine {
454
492
pub id : i32 ,
455
493
pub element : String ,
456
494
pub nucleons : i32 ,
457
- pub library : String ,
458
495
pub reaction : String ,
459
496
pub mt : i32 ,
497
+ pub library : String ,
460
498
pub temperature : String ,
461
499
#[ serde( skip_serializing) ]
462
500
pub sum_callback : Callback < usize > ,
463
501
}
464
502
465
503
impl PartialEq < Self > for TableLine {
466
504
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
468
506
}
469
507
}
470
508
0 commit comments