This repository was archived by the owner on Dec 28, 2023. It is now read-only.
forked from Kutkovsky/NeuroReports
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatisticsWindow.html
More file actions
132 lines (108 loc) · 4.53 KB
/
statisticsWindow.html
File metadata and controls
132 lines (108 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<title>Statistic</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="./styles/statistic.css">
</head>
<body>
<div class="container">
<ul class="week"></ul>
<hr>
<!-- <div class="date"></div>-->
<div id="list">
</div>
</div>
</body>
<script src="./scripts/excel.js"></script>
<script src="./scripts/d3.js"></script>
<script src="./scripts/radial-progress-chart.js"></script>
<script>
const $ = require('jquery');
let currentSettings = null;
$(() => {
const { ipcRenderer } = electron;
var dateFormatter = d3.time.format("%A, %B %d, %Y");
ipcRenderer.send('statistics:opened', {});
ipcRenderer.on('settings:sent', (e, settings) => {
currentSettings = settings;
getStatistics().then((stat) => {
// console.log(d)
var data = [
{ day: 'S' },
{ day: 'M' },
{ day: 'T' },
{ day: 'W' },
{ day: 'T' },
{ day: 'F' },
{ day: 'S' },
];
data.map((d, i) => {
d.list = stat.WeekDescriptions.dayList[i];
d.summ = stat.WeekDescriptions.daySumm[i];
});
d3.select('.week').selectAll('li')
.data(data).enter()
.append('li').on('click', function (d) {
// Update active class, date and main chart
d3.selectAll('.circle').classed('active', false);
d3.select(this).select('.circle').classed('active', true);
d3.select('.date').text(d.date);
// mainChart.update(d.series);
renderList(d.list);
})
.append('div').attr('class', 'circle').text(function (d) {
return d.day;
})
.each(function (d, i) {
d.date = dateFormatter(getDate(i));
d.series = [{
value: d.summ,
color: ['red', '#7CFC00']
}];
new RadialProgressChart(this.parentNode, {
diameter: 40,
stroke: {
width: 5,
gap: 1
},
shadow: {
width: 1
},
max: currentSettings.workTime,
series: d.series,
center: (Math.round( d.summ * 10 ) / 10).toString()
});
});
// Set current day as active
var currentDay = (new Date()).getDay();
$('li')[currentDay].click();
});
// Return some chronological dates
function getDate(i) {
var curr = new Date(); // get current date
var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var firstday = new Date(curr.setDate(first));
// var date = new Date();
// date.setDate(date.getDate() + i);
return firstday;
}
function renderList(list) {
$("#list").empty();
for (let index = list.length-1; index >= 0; index--) {
const l = list[index];
const project = "<div title=\"" + l.ProjectTask + "\" class='report-project'>" + l.ProjectTask + "</div>";
const effort = "<div class='report-effort'>" + l.Effort + "</div>";
const description = "<div title=\"" + l.Description + "\" class='report-description'>" + l.Description + "</div>";
$("#list").append("<div class='report'>" + project + " " + effort + " " + description + "</div>");
}
}
// Random int between 20-80
function getRandom() {
return Math.round(Math.random() * 60) + 20;
}
});
});
</script>
</html>