1<#--dateStr = year + "-01-01,yesterday"-->
2<#assign
3 year = .now?string("yyyy")
4 dateStr = config.wai_params.date
5 dateStr = year + "-01-01,yesterday"
6 url = "https://webanalytics.italia.it/matomo/index.php?format=json&idSite=" + config.wai_params.idsite + "&method=API.get&module=API&period=" + config.wai_params.period + "&date=" + dateStr + "&token_auth=" + config.wai_params.token_auth
7 entriesStr = queryUtil.fetch("GET", url, null, null)
8 entries = (entriesStr?eval)!{}
9/>
10<#if config.wai_params.filler?has_content && config.wai_params.filler>
11 <#if config.wai_params.period == 'month'>
12 <#list 1..12 as month>
13 <#assign key = year + "-" + month?string["00"] />
14 <#if !entries[key]?has_content>
15 <#assign entry = {} />
16 <#list config.wai_params.measure?eval as measure>
17 <#assign
18 field = measure
19 />
20 <#if field?is_hash>
21 <#assign field = field.field />
22 </#if>
23 <#assign entry = entry + {field: 0} />
24 </#list>
25 <#assign entries = entries + {key: entry} />
26 </#if>
27 </#list>
28 </#if>
29</#if>
30<style>
31.wai-paragraph-emph {
32 font-style: italic;
33}
34
35
36/* 8666a352-0862-0868-e16b-27c8bf6a0acb | https://www.unisalento.it/documents/20152/8550731/tabulator-5.5.2.min.css/8666a352-0862-0868-e16b-27c8bf6a0acb */
37
38.tabulator .tabulator-header {
39 border-bottom: 0 !important;
40 color: black;
41}
42
43.tabulator {
44 border: 0 !important;
45 background-color: white !important;
46}
47
48.tabulator-row .tabulator-cell {
49 border-right: 0 !important;
50}
51.tabulator .tabulator-tableholder .tabulator-table {
52 color: black !important;
53}
54</style>
55<#assign site_name = htmlUtil.escape(themeDisplay.getScopeGroup().getDescription(locale)) />
56<#if !site_name?has_content>
57 <#assign site_name = "Istituzionale" />
58<#else>
59 <#assign site_name = "del " + site_name />
60</#if>
61<div id="wai-descrizione">
62<p class="wai-paragraph">Di seguito vengono riportati i dati statistici relativi agli accessi al Portale ${site_name}, come previsto dalle Linee guida sui siti web delle PA.</p>
63<p class="wai-paragraph-emph">(Fonte: Web Analytics Italia)</p>
64</div>
65
66<button id="download-csv">Esporta Dati CSV</button> <button id="download-xlsx">Esporta Dati Excel</button>
67
68<div id="${randomNamespace}-main" style="width: 100%;height:<#if config.has("height")>${config["height"]}<#else>400px</#if>; display:block"></div>
69<h2 class="portlet-title-text">Dati di dettaglio</h2>
70<div id="${randomNamespace}-wai-table"></div>
71<script>
72<#if entries?has_content && entries?keys?size gt 0>
73
74 var seriesData = [
75 <#list entries?keys as key>
76 <#list config.wai_params.measure?eval as measure>
77 <#if measure?is_hash>
78 <#assign
79 field = measure.field
80 value = entries[key][measure.field]
81 label = measure.label
82 suffix = (measure.suffix)!""
83 />
84 <#if measure.multiplier?has_content>
85 <#assign value = value * measure.multiplier>
86 </#if>
87 <#else>
88 <#assign
89 field = measure
90 value = entries[key][measure]
91 label = measure
92 />
93 </#if>
94 { "category" : "${key}", "measure": "${field}", "value": ${value}, "label": "${label}", "suffix": "${suffix!""}"},
95 </#list>
96 </#list>
97 ];
98
99 var chartElemId = "#${randomNamespace}-main"
100 var chartOptions = ${config["chartOptions"]}
101
102 chartOptions.data.values = seriesData;
103
104</script>
105 <script type="text/javascript" src="/documents/20143/4672203/app-vega.js/749ef6b7-e3b4-7af0-c113-b2e75b7abf2a"></script>
106
107 <link href="/documents/20152/8550731/tabulator-5.5.2.min.css/8666a352-0862-0868-e16b-27c8bf6a0acb" rel="stylesheet">
108
109 <script type="module">
110 const { AjaxModule, DownloadModule, ExportModule, FilterModule, FormatModule, PageModule, PopupModule, ResponsiveLayoutModule, SortModule, Tabulator, TooltipModule } = await import ('/documents/20152/8550731/tabulator_esm-5.5.2.min.js/fc08a4ea-68d8-5287-c7b6-395d3beb06da');
111 window.luxon = await import ('/documents/20152/8550731/luxon-3.4.3.esm.js/49172b25-3077-9b6b-91c8-7fbf34d71ed6');
112 window.XLSX = await import("/documents/20152/8550731/xlsx-0.20.0.esm.js/98bcdb00-2757-1252-ecac-8d4a6572f759");
113
114 Tabulator.registerModule([AjaxModule, DownloadModule, ExportModule, FilterModule, FormatModule, PageModule, PopupModule, ResponsiveLayoutModule, SortModule, TooltipModule]);
115
116 var tabularData = [
117 <#list entries?keys as key>
118 { "${config.wai_params.key_label}" : window.luxon.DateTime.fromISO("${key}").setLocale("it")
119 <#list config.wai_params.measure?eval as measure>
120 <#if measure?is_hash>
121 <#assign
122 field = measure.field
123 value = entries[key][measure.field]
124 label = measure.label?replace('.','')
125 />
126 <#else>
127 <#assign
128 field = measure
129 value = entries[key][measure]
130 label = measure?replace('.','')
131 />
132 </#if>
133 , "${label}": ${value}
134 </#list>
135 },
136 </#list>
137 ];
138 var table = new Tabulator("#${randomNamespace}-wai-table", {
139 locale: "it",
140 height: 385,
141 layout:"fitColumns",
142 data: tabularData,
143 columns: [
144 {
145 field: "${config.wai_params.key_label}"
146 , title: "${config.wai_params.key_label}"
147 , sorter: "string"
148 , formatter:"datetime"
149 , formatterParams:{
150 inputFormat:"iso"
151 , outputFormat:"MMMM yy"
152 }
153 }
154 <#list config.wai_params.measure?eval as measure>
155 <#if measure?is_hash>
156 <#assign
157 field = measure.field
158 value = entries[key][measure.field]
159 label = measure.label?replace('.','')
160 hozAlign = measure.hozAlign!"left"
161 />
162 <#else>
163 <#assign
164 field = measure
165 value = entries[key][measure]
166 label = measure?replace('.','')
167 hozAlign = "left"
168 />
169 </#if>
170 , {field: "${label}", sorter: "number", title: "${label}", hozAlign: "${hozAlign}", headerHozAlign: "${hozAlign}"}
171 </#list>
172 ]
173 });
174
175
176 document.getElementById("download-csv").addEventListener("click", function() {
177 table.download("csv", "data.csv", {bom: true, delimiter: ";"});
178 });
179
180 document.getElementById("download-xlsx").addEventListener("click", function(){
181 table.download("xlsx", "data.xlsx", {sheetName:"Report"});
182 });
183
184
185 </script>
186<#else>
187 <p>Il server Web Analytics Italia non ha restituito dati. Si prega di riprovare.</p>
188</#if>