-
Notifications
You must be signed in to change notification settings - Fork 1
/
summary.html
185 lines (165 loc) · 4.49 KB
/
summary.html
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
crossorigin=""></script>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/[email protected]"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="tabs.css" type="text/css">
<style>
h2 {color: green;
align-items : center;
font-size: 35px;
}
.map {
padding: 200px;
border: 1px solid #4CAF50;
}
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover {
opacity: 0.8;
}
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 40%;
border-radius: 50%;
}
.container {
padding: 16px;
}
span.psw {
float: right;
padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
#map { height: 400px; }
</style>
</head>
<body onload="getLocation()">
<!-- Tab links -->
<div class="tab">
<button class="tablinks" onclick="">Summary</button>
<button class="tablinks" onclick="window.location.replace(window.location.origin + '/grievance')">Submit Grievance</button>
</div>
<h2>View Summary</h2>
<select name="users" id="user" onchange="change(callb)">
<option value="ALL" selected>ALL</option>
<option value="Me">Me</option>
</select>
<select name="time" id="time" onchange="change(callb)">
<option value="ALL" selected>ALL</option>
<option value="Morning">Morning</option>
<option value="Afternoon" selected>Afternoon</option>
<option value="Night">Night</option>
</select>
<div id="map"></div>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
function change(cb){
console.log("cb called inside change")
const url = "http://" + window.location.host + "/data";
const params = {
user: document.getElementById('user').value,
time: document.getElementById('time').value
}
console.log("TIME "+params.time);
axios.get(url+'?time='+params.time+'&user='+params.user).then(
data => {
cb(data);
}
).catch(err => console.log(err));
}
</script>
<script>
var map;
function getLocation() {
var x = "1";
var y = "1";
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x = "0";
y = "0";
}
}
function showPosition(position) {
x = position.coords.latitude;
y = position.coords.longitude;
map = new L.Map('map', {
center: new L.LatLng(parseFloat(x), parseFloat(y)),
zoom: 12.5,
layers: [baseLayer, heatmapLayer]
});
}
var baseLayer = L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: ['a','b','c']
}
);
var cfg = {
// scales the radius based on map zoom
"scaleRadius": true,
// if set to false the heatmap uses the global maximum for colorization
// if activated: uses the data maximum within the current map boundaries
// (there will always be a red spot with useLocalExtremas true)
"useLocalExtrema": true,
// which field name in your data represents the latitude - default "lat"
latField: 'locationx',
// which field name in your data represents the longitude - default "lng"
lngField: 'locationy',
// which field name in your data represents the data value - default "value"
valueField: 'count'
};
var heatmapLayer = new HeatmapOverlay(cfg);
function callb(data){
console.log("Inside cb now");
d = {
data: data.data.rows
}
heatmapLayer.setData(d);
console.log(d);
}
</script>
</html>