@@ -88,6 +88,7 @@ document.addEventListener('DOMContentLoaded', function() {
88
88
} ) ;
89
89
}
90
90
} ) ;
91
+
91
92
} ) ;
92
93
93
94
@@ -214,6 +215,7 @@ class Storage {
214
215
end_window_date : null ,
215
216
adm_1 : null ,
216
217
adm_2 : null ,
218
+ score : null ,
217
219
}
218
220
}
219
221
data [ this . dashboard ] . prediction_ids = data [ this . dashboard ] . prediction_ids || [ ] ;
@@ -231,6 +233,7 @@ class Storage {
231
233
}
232
234
data [ this . dashboard ] . adm_1 = data [ this . dashboard ] . adm_1 || null ;
233
235
data [ this . dashboard ] . adm_2 = data [ this . dashboard ] . adm_2 || null ;
236
+ data [ this . dashboard ] . score = data [ this . dashboard ] . score || null ;
234
237
localStorage . setItem ( "dashboards" , JSON . stringify ( data ) ) ;
235
238
}
236
239
@@ -301,7 +304,7 @@ class ModelList {
301
304
<td class="truncate-name"><a href="/${ model . author . username } /">${ model . author . name } </a></td>
302
305
<td class="truncate-name">${ model . updated } </td>
303
306
</tr>
304
- <tr class="expandable-body d-none"><td colspan="2 "><p>${ model . description } </p></td></tr>
307
+ <tr class="expandable-body d-none"><td colspan="5 "><p>${ model . description } </p></td></tr>
305
308
` ;
306
309
}
307
310
@@ -457,6 +460,7 @@ class PredictionList {
457
460
constructor ( dashboard ) {
458
461
this . dashboard = dashboard ;
459
462
this . predictions_map = { } ;
463
+ this . current_predictions = [ ] ;
460
464
this . get_data ( ) ;
461
465
}
462
466
@@ -491,27 +495,25 @@ class PredictionList {
491
495
const selected = storage . get ( "prediction_ids" ) . includes ( prediction . id ) ;
492
496
493
497
return `
494
- <tr data-widget="expandable-table" aria-expanded="false" class="prediction-row">
498
+ <tr data-widget="expandable-table" aria-expanded="false" class="prediction-row" data-id=" ${ prediction . id } " >
495
499
<td style="width: 40px;" class="${ selected ? 'selected' : '' } " id="td-${ prediction . id } ">
496
500
<input type="checkbox" value="${ prediction . id } " id="checkbox-${ prediction . id } " class="checkbox-prediction">
497
501
</td>
498
- <td>${ prediction . id } </td>
499
- <td>${ prediction . start_date } </td>
500
- <td>${ prediction . end_date } </td>
502
+ <td style="width: 40px;">${ prediction . id } </td>
503
+ <td style="width: 40px;"><a href="/registry/model/${ prediction . model } /">${ prediction . model } </a></td>
504
+ <td style="width: 110px;">${ prediction . start_date } </td>
505
+ <td style="width: 110px;">${ prediction . end_date } </td>
506
+ <td style="width: 150px;">${ prediction . scores [ storage . get ( "score" ) ] || "-" } </td>
501
507
</tr>
502
- <tr class="expandable-body d-none"><td colspan="2 "><p>${ prediction . description } </p></td></tr>
508
+ <tr class="expandable-body d-none"><td colspan="6 "><p>${ prediction . description } </p></td></tr>
503
509
` ;
504
510
}
505
511
506
-
507
-
508
512
list ( predictions ) {
509
- predictions . sort ( ( a , b ) => {
510
- const aChecked = storage . get ( "prediction_ids" ) . includes ( a . id ) ;
511
- const bChecked = storage . get ( "prediction_ids" ) . includes ( b . id ) ;
512
- if ( aChecked && ! bChecked ) return - 1 ;
513
- if ( ! aChecked && bChecked ) return 1 ;
514
- return 0 ;
513
+ predictions = [ ...predictions ] . sort ( ( a , b ) => {
514
+ const aScore = a . scores [ storage . get ( "score" ) ] ?? Infinity ;
515
+ const bScore = b . scores [ storage . get ( "score" ) ] ?? Infinity ;
516
+ return aScore - bScore ;
515
517
} ) ;
516
518
517
519
const self = this ;
@@ -562,6 +564,10 @@ class PredictionList {
562
564
chart . clearPredictions ( ) ;
563
565
self . paginate ( self . filter ( predictions , admLevel , $ ( this ) . val ( ) ) ) ;
564
566
} ) ;
567
+
568
+ $ ( "#predictions-clear-all" ) . on ( "click" , function ( ) {
569
+ self . clear ( )
570
+ } ) ;
565
571
}
566
572
567
573
filter ( predictions , adm_level , adm ) {
@@ -586,34 +592,46 @@ class PredictionList {
586
592
587
593
paginate ( predictions ) {
588
594
const self = this ;
595
+ this . current_predictions = predictions ;
589
596
$ ( '#predictions-pagination' ) . pagination ( {
590
597
dataSource : predictions ,
591
598
pageSize : 5 ,
592
599
callback : function ( data , pagination ) {
593
600
const body = data . map ( ( item ) => self . li ( item ) ) . join ( "" ) ;
601
+ const score = storage . get ( "score" ) ;
594
602
$ ( `#predictions-list` ) . html ( `
595
603
<thead>
596
604
<tr>
597
605
<th style="width: 40px;">
598
606
<input type="checkbox" id="select-all-checkbox">
599
607
</th>
600
- <th>ID</th>
601
- <th>Start Date</th>
602
- <th>End Date</th>
603
- <th style="width: 100px;">
604
- <select id="scores" title="Score" class="form-select form-select-sm w-auto" style="width: 80px !important;">
605
- <option value="mae">MAE</option>
606
- <option value="mse">MSE</option>
607
- <option value="crps">CRPS</option>
608
- <option value="log_score">Log Score</option>
609
- <option value="interval_score">Interval Score</option>
610
- </select>
608
+ <th style="width: 65px;">ID</th>
609
+ <th style="width: 85px;">Model</th>
610
+ <th style="width: 110px;">Start Date</th>
611
+ <th style="width: 110px;">End Date</th>
612
+ <th style="width: 150px;">
613
+ <div class="row">
614
+ <div class="col">Score</div>
615
+ <div class="col">
616
+ <select id="scores" title="Score" class="form-select form-select-sm w-auto" style="width: 80px !important;">
617
+ <option value="mae" ${ score === "mae" ? "selected" : "" } >MAE</option>
618
+ <option value="mse" ${ score === "mse" ? "selected" : "" } >MSE</option>
619
+ <option value="crps" ${ score === "crps" ? "selected" : "" } >CRPS</option>
620
+ <option value="log_score" ${ score === "log_score" ? "selected" : "" } >Log Score</option>
621
+ <option value="interval_score" ${ score === "interval_score" ? "selected" : "" } >Interval Score</option>
622
+ </select>
623
+ </div>
624
+ </div>
611
625
</th>
612
626
</tr>
613
627
</thead>
614
628
<tbody>${ body } </tbody>
615
629
` ) ;
616
630
631
+ $ ( "#scores" ) . on ( "change" , function ( ) {
632
+ self . set_score ( $ ( this ) . val ( ) ) ;
633
+ } ) ;
634
+
617
635
$ ( ".checkbox-prediction" ) . each ( function ( ) {
618
636
const prediction_id = parseInt ( $ ( this ) . val ( ) , 10 ) ;
619
637
const td = $ ( `#td-${ prediction_id } ` ) ;
@@ -647,10 +665,22 @@ class PredictionList {
647
665
self . unselect ( prediction_id )
648
666
}
649
667
} ) ;
668
+
669
+ $ ( "#select-all-checkbox" ) . prop ( "checked" , $ ( ".checkbox-prediction" ) . length === $ ( ".checkbox-prediction:checked" ) . length ) ;
650
670
} ,
651
671
} ) ;
652
672
}
653
673
674
+ set_score ( score ) {
675
+ storage . set ( "score" , score ) ;
676
+ const predictions = [ ...this . current_predictions ] . sort ( ( a , b ) => {
677
+ const aScore = a . scores [ score ] ?? Infinity ;
678
+ const bScore = b . scores [ score ] ?? Infinity ;
679
+ return aScore - bScore ;
680
+ } ) ;
681
+ this . list ( predictions ) ;
682
+ }
683
+
654
684
select ( prediction ) {
655
685
let prediction_ids = new Set ( storage . get ( "prediction_ids" ) ) ;
656
686
@@ -679,6 +709,12 @@ class PredictionList {
679
709
const td = $ ( `#td-${ prediction_id } ` ) ;
680
710
td . removeClass ( 'selected' ) ;
681
711
td . css ( "background-color" , '' ) ;
712
+ $ ( `.checkbox-prediction[value="${ prediction_id } "]` ) . prop ( "checked" , false ) ;
713
+ $ ( "#select-all-checkbox" ) . prop ( "checked" , false ) ;
714
+ }
715
+
716
+ clear ( ) {
717
+ storage . get ( "prediction_ids" ) . forEach ( id => this . unselect ( id ) ) ;
682
718
}
683
719
}
684
720
0 commit comments