@@ -10,61 +10,153 @@ function calculate_table_height() {
1010 return ( percent * h ) / 100 ;
1111}
1212
13- var table = new DataTable ( "#indicatorSetsTable" , {
13+ var table = new DataTable ( "#indicatorSetsTable" , {
14+ ajax : {
15+ url : `${ window . location . pathname } ${ window . location . search . replace ( / [ ? & ] f o r m a t = [ ^ & ] * / , "" ) } ${ window . location . search ? "&" : "?" } format=json` ,
16+ dataSrc : "data"
17+ } ,
18+ columns : [
19+ {
20+ className : 'dt-control' ,
21+ orderable : false ,
22+ data : null ,
23+ defaultContent : ''
24+ } , // dt-control column
25+ { data : "name" } , // Name
26+ {
27+ data : "pathogens" ,
28+ render : function ( data , type , row ) {
29+ if ( data ) {
30+ return data . map ( pathogen => `<span class="badge badge-pill-outline">${ pathogen . display_name } </span>` ) . join ( '' ) ;
31+ } else {
32+ return '' ;
33+ }
34+ }
35+ } , // Pathogens
36+ { data : "geographic_scope" } , // Geographic Coverage
37+ {
38+ data : "geographic_levels" ,
39+ render : function ( data , type , row ) {
40+ if ( data ) {
41+ return data . map ( geography => `<span class="badge badge-pill-outline">${ geography . display_name } </span>` ) . join ( '' ) ;
42+ } else {
43+ return '' ;
44+ }
45+ }
46+ } , // Geographic Levels
47+ { data : "temporal_scope_start" } , // Temporal Scope Start
48+ { data : "temporal_scope_end" } , // Temporal Scope End
49+ {
50+ data : "temporal_granularity" ,
51+ render : function ( data , type , row ) {
52+ if ( data ) {
53+ return `<span class="badge badge-pill-outline">${ data } </span>` ;
54+ } else {
55+ return '' ;
56+ }
57+ }
58+ } , // Temporal Granularity
59+ { data : "reporting_cadence" } , // Reporting Cadence
60+ { data : "reporting_lag" } , // Reporting Lag
61+ { data : "revision_cadence" } , // Revision Cadence
62+ { data : "demographic_scope" } , // Population
63+ { data : "demographic_granularity" } , // Population Stratifiers
64+ {
65+ data : "severity_pyramid_rungs" ,
66+ render : function ( data , type , row ) {
67+ if ( data ) {
68+ return data . map ( severity_pyramid_rung => `<span class="badge badge-pill-outline">${ severity_pyramid_rung . display_name } </span>` ) . join ( '' ) ;
69+ } else {
70+ return '' ;
71+ }
72+ }
73+ } , // Surveillance Categories
74+ { data : "original_data_provider" } , // Original Data Provider
75+ { data : "preprocessing_description" } , // Pre-processing
76+ { data : "censoring" } , // Censoring
77+ { data : "missingness" } , // Missingness
78+ { data : "delphi_hosted" } , // Hosted by Delphi?
79+ { data : "dua_required" } , // DUA required?
80+ { data : "license" } , // Data Use Terms
81+ {
82+ data : "documentation_link" ,
83+ render : function ( data , type , row ) {
84+ if ( data ) {
85+ return `<a href="${ data } " target="_blank">${ data } </a>` ;
86+ } else {
87+ return '' ;
88+ }
89+ }
90+ } , // Documentation
91+ ] ,
1492 fixedHeader : true ,
1593 paging : false ,
1694 scrollCollapse : true ,
1795 scrollX : true ,
1896 scrollY : calculate_table_height ( ) + 75 ,
19- info : false ,
2097 fixedColumns : {
2198 left : 2 ,
2299 } ,
23100 ordering : false ,
24101 mark : true ,
25-
26102 language : {
27103 emptyTable : "No indicators match your specified filters. Try relaxing some filters, or clear all filters and try again." ,
28- // buttons: {
29- // colvis: "Toggle Columns",
30- // },
31104 } ,
32- search : {
33- smart : true ,
34- highlight : true ,
105+ layout : {
106+ topStart : function ( ) {
107+ let indicatorSetsInfo = document . createElement ( 'span' ) ;
108+ indicatorSetsInfo . className = 'table-stats-info' ;
109+ indicatorSetsInfo . id = 'indicatorSetsInfo' ;
110+ $ . ajax ( {
111+
112+ url : "get_table_stats_info/" + window . location . search ,
113+ method : "GET" ,
114+ success : function ( response ) {
115+ if ( response . num_of_locations > 0 ) {
116+ indicatorSetsInfo . innerHTML =
117+ `Showing <b>${ response . num_of_indicators } </b> distinct ${ pluralize ( response . num_of_indicators , "indicator" ) } (arranged in <b>${ response . num_of_indicator_sets } </b> ${ pluralize ( response . num_of_indicator_sets , "set" ) } ), including <b>${ numberWithCommas ( response . num_of_locations ) } </b> Delphi-hosted time series across numerous locations.` ;
118+ } else {
119+ indicatorSetsInfo . innerHTML =
120+ `Showing <b>${ response . num_of_indicators } </b> indicator sets (arranged in <b>${ response . num_of_indicator_sets } </b> ${ pluralize ( response . num_of_indicator_sets , "set" ) } ).` ;
121+ }
122+ }
123+ } ) ;
124+ return indicatorSetsInfo ;
125+ } ,
126+ topEnd : null ,
127+ bottomStart : null ,
128+ bottomEnd : null
35129 } ,
36- sDom : 'ltipr' ,
37- rowCallback : function ( row , data , index ) {
38- if ( index % 2 === 0 ) {
130+ createdRow : function ( row , data , dataIndex ) {
131+ if ( data . description ) {
132+ $ ( row ) . attr ( 'data-description' , data . description ) ;
133+ } else {
134+ $ ( row ) . attr ( 'data-description' , '' ) ;
135+ }
136+ // Set row ID if present
137+ if ( data . DT_RowId ) {
138+ $ ( row ) . attr ( 'data-id' , data . DT_RowId ) ;
139+ }
140+ // Add odd-row class for styling
141+ if ( dataIndex % 2 === 0 ) {
39142 $ ( row ) . addClass ( 'odd-row' ) ;
40143 }
41- }
144+ } ,
42145} ) ;
43146
44- // new DataTable.Buttons(table, {
45- // buttons: [
46- // {
47- // extend: "colvis",
48- // columns: "th:nth-child(n+3)",
49- // prefixButtons: ["colvisRestore"],
50- // },
51- // ],
52- // });
53-
54- // table.buttons(0, null).container().appendTo("#colvis");
55-
56- // $("#tableSearch").keyup(function () {
57- // table.search(this.value).draw();
58- // });
59-
60147function format ( indicatorSetId , relatedIndicators , indicatorSetDescription ) {
61148 if ( ! relatedIndicators ) {
62149 return '<div class="d-flex justify-content-start my-3" style="padding-left: 20px;"><div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading...</span></div></div>' ;
63150 }
64151
65- var indicators = relatedIndicators . filter (
66- ( indicator ) => indicator . indicator_set === indicatorSetId
67- ) ;
152+ var indicators ;
153+ if ( Array . isArray ( relatedIndicators ) ) {
154+ indicators = relatedIndicators . filter (
155+ ( indicator ) => indicator . indicator_set === indicatorSetId
156+ ) ;
157+ } else {
158+ indicators = relatedIndicators [ indicatorSetId ] || [ ] ;
159+ }
68160 var disabled , restricted , sourceType ;
69161
70162 if ( indicators . length > 0 ) {
0 commit comments