1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-06-05 21:49:31 +02:00

Updated statistics page (#74)

This commit is contained in:
nobody
2020-08-09 10:08:38 +02:00
parent f92e8fd157
commit 34b1ee18b3
3 changed files with 11 additions and 30 deletions

View File

@@ -28,22 +28,16 @@ statistics._onDocumentLoaded = function () {
// Default view is 'today'
statistics._dateRange = [new Date().toISOString().slice(0, 10)];
document.getElementById('date-range').value = 'day';
document.getElementById('date-range').value = statistics._dateUnit;
statistics._registerListener();
statistics._getStatistics().then(statistics._renderContents);
};
statistics._renderContents = function () {
if (statistics._data === undefined || statistics._dateRange.length === 0) {
statistics._showData(false);
return false;
}
statistics._filterAndSortData();
statistics._determineInjections();
statistics._showData(true);
statistics._clearTables();
statistics._determineInjections();
statistics._generateTable(statistics._dataSortedCDNs, 'cdns');
@@ -185,7 +179,6 @@ statistics._handlerDateRange = function ({ target }) {
statistics._getStatistics().then(statistics._setDateRange);
} else if (type === 'delete') {
statistics._deleteStatistic();
statistics._showData(false);
}
};
@@ -197,15 +190,6 @@ statistics._deleteStatistic = function () {
}
};
statistics._showData = function (type) {
let attr = type === true ? 'block' : 'none';
document.getElementById('statistics-overview').style.display = attr;
document.getElementById('tbl-statistics-cdns').style.display = attr;
document.getElementById('tbl-statistics-frameworks').style.display = attr;
document.getElementById('btn-delete').disabled = !type;
};
statistics._registerListener = function () {
document.getElementById('date-range').addEventListener('change', statistics._handlerDateRange);
document.getElementById('btn-delete').addEventListener('click', function () {