Skip to content

Commit 37654ae

Browse files
committed
add table header with summary count of days and first date
1 parent 894ae98 commit 37654ae

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

scripts/ui.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,37 @@ class UI {
7171

7272
drawChart(tabs) {
7373
var donut = donutChart()
74-
.width(480)
75-
.height(280)
76-
.cornerRadius(5) // sets how rounded the corners are on each slice
77-
.padAngle(0.020) // effectively dictates the gap between slices
78-
.variable('percentage')
79-
.category('url');
74+
.width(480)
75+
.height(280)
76+
.cornerRadius(5) // sets how rounded the corners are on each slice
77+
.padAngle(0.020) // effectively dictates the gap between slices
78+
.variable('percentage')
79+
.category('url');
8080

8181
d3.select('#chart')
82-
.datum(tabs) // bind data to the div
83-
.call(donut); // draw chart in div
82+
.datum(tabs) // bind data to the div
83+
.call(donut); // draw chart in div
8484

8585
ui.addHrAfterChart();
8686
}
8787

88-
addLineToTableOfSite(tab, currentTab, summaryTime){
88+
addTableHeader(currentTypeOfList, totalDays) {
89+
var p = document.createElement('p');
90+
p.classList.add('table-header');
91+
if (currentTypeOfList === TypeListEnum.ToDay)
92+
p.innerHTML = 'Today';
93+
if (currentTypeOfList === TypeListEnum.All && totalDays !== undefined) {
94+
if (totalDays.countOfDays > 0) {
95+
p.innerHTML = 'Aggregate data since ' + totalDays.minDate + ' (' + totalDays.countOfDays + ' days)';
96+
} else {
97+
p.innerHTML = 'Aggregate data since ' + today;
98+
}
99+
}
100+
101+
this.getTableOfSite().appendChild(p);
102+
}
103+
104+
addLineToTableOfSite(tab, currentTab, summaryTime) {
89105
var div = document.createElement('div');
90106
div.classList.add('inline-flex');
91107

scripts/webact.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ function getTabsFromStorage(tabs) {
6969
}
7070
}
7171

72+
if (currentTypeOfList === TypeListEnum.All)
73+
ui.addTableHeader(currentTypeOfList, getFirstDay());
74+
if (currentTypeOfList === TypeListEnum.ToDay)
75+
ui.addTableHeader(currentTypeOfList);
76+
7277
var currentTab = getCurrentTab();
7378

7479
var tabsForChart = [];
@@ -144,4 +149,22 @@ function addTabOthersForChart(tabsForChart, summaryTime) {
144149
tab['summary'] += summaryTime;
145150
tab['percentage'] = getPercentageForChart(tab['summary']);
146151
}
152+
}
153+
154+
function getFirstDay() {
155+
var array = [];
156+
tabsFromStorage.map(function (a) {
157+
return a.days.map(function (a) {
158+
if (array.indexOf(a.date) === -1)
159+
return array.push(a.date);
160+
});
161+
});
162+
array = array.sort(function (a, b) {
163+
return new Date(a) - new Date(b);
164+
});
165+
166+
return {
167+
'countOfDays': array.length,
168+
'minDate': array[0]
169+
};
147170
}

style/webact.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,12 @@ input[type="button"].active {
124124
text-align: center;
125125
font-weight: 600;
126126
font-size: 14px;
127+
.table-header{
128+
margin:3px 0;
129+
border-radius: 5px;
130+
font-weight: 600;
131+
font-size: 13px;
132+
padding: 4px;
133+
background-color: rgb(223, 221, 221);
134+
text-align: center;
127135
}

0 commit comments

Comments
 (0)