-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.html
355 lines (327 loc) · 17.7 KB
/
dashboard.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<DOCTYPE html>
<html :class="{ 'theme-dark': dark }" x-data="data()" lang="en">
</html>
<head>
<title>CEGE0043 Asset Dashboard</title>
<!--Cesium-->
<script src="Build/Cesium/Cesium.js"></script>
<!--link to functionality-->
<script src="js/requestData.js"></script>
<script src="js/dashboard.js"></script>
<!--link to jquery-->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<!--link to d3 library-->
<script src="https://d3js.org/d3.v5.min.js"></script>
<style>
@import url(Build/Cesium/Widgets/widgets.css);
html,
body,
#cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
.toolbar-left {
display: block;
position: absolute;
top: 5px;
left: 5px;
}
</style>
<!--head part for template-->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Charts html adapted from Windmill Dashboard</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap"
rel="stylesheet" />
<link rel="stylesheet" href="./css/tailwind.output.css" />
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
<script src="./assets/js/init-alpine.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js" defer></script>
</head>
<body>
<!--dashboard template-->
<div class="flex h-screen bg-gray-50 dark:bg-gray-900" :class="{ 'overflow-hidden': isSideMenuOpen}">
<!-- Desktop sidebar -->
<aside class="z-20 hidden w-64 overflow-y-auto bg-white dark:bg-gray-800 md:block flex-shrink-0">
<div class="py-4 text-gray-500 dark:text-gray-400">
<a class="ml-6 text-lg font-bold text-gray-800 dark:text-gray-200" href="#">
CEGE0043 Dashboard
</a>
<ul class="mt-6">
<li class="relative px-6 py-3">
<span class="absolute inset-y-0 left-0 w-1 bg-purple-600 rounded-tr-lg rounded-br-lg"
aria-hidden="true"></span>
<a class="inline-flex items-center w-full text-sm font-semibold text-gray-800 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 dark:text-gray-100"
href="dashboard.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"></path>
<path d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"></path>
</svg>
<span class="ml-4">Gallery</span>
</a>
</li>
<li class="relative px-6 py-3">
<a class="inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200"
href="bootStrap.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6">
</path>
</svg>
<span class="ml-4">Back to App</span>
</a>
</li>
</ul>
<ul>
<li class="relative px-6 py-3">
<a class="inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200"
href="cesium.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01">
</path>
</svg>
<span class="ml-4">Full View Cesium</span>
</a>
</li>
</ul>
</div>
</aside>
<!-- Mobile sidebar -->
<!-- Backdrop -->
<div x-show="isSideMenuOpen" x-transition:enter="transition ease-in-out duration-150"
x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in-out duration-150" x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 z-10 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"></div>
<aside class="fixed inset-y-0 z-20 flex-shrink-0 w-64 mt-16 overflow-y-auto bg-white dark:bg-gray-800 md:hidden"
x-show="isSideMenuOpen" x-transition:enter="transition ease-in-out duration-150"
x-transition:enter-start="opacity-0 transform -translate-x-20" x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in-out duration-150" x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0 transform -translate-x-20" @click.away="closeSideMenu"
@keydown.escape="closeSideMenu">
<div class="py-4 text-gray-500 dark:text-gray-400">
<a class="ml-6 text-lg font-bold text-gray-800 dark:text-gray-200" href="#">
CEGE0043 Dashboard
</a>
<ul class="mt-6">
<li class="relative px-6 py-3">
<a class="inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200"
href="bootStrap.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6">
</path>
</svg>
<span class="ml-4">Back to APP</span>
</a>
</li>
</ul>
<ul>
<li class="relative px-6 py-3">
<span class="absolute inset-y-0 left-0 w-1 bg-purple-600 rounded-tr-lg rounded-br-lg"
aria-hidden="true"></span>
<a class="inline-flex items-center w-full text-sm font-semibold text-gray-800 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 dark:text-gray-100"
href="dashboard.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"></path>
<path d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"></path>
</svg>
<span class="ml-4">Gallery</span>
</a>
</li>
<li class="relative px-6 py-3">
<span class="absolute inset-y-0 left-0 w-1 bg-purple-600 rounded-tr-lg rounded-br-lg"
aria-hidden="true"></span>
<a class="inline-flex items-center w-full text-sm font-semibold text-gray-800 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 dark:text-gray-100"
href="cesium.html">
<svg class="w-5 h-5" aria-hidden="true" fill="none" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" viewBox="0 0 24 24" stroke="currentColor">
<path d="M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"></path>
<path d="M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"></path>
</svg>
<span class="ml-4">Full View Cesium</span>
</a>
</li>
</ul>
</div>
</aside>
<!--main screen container-->
<div class="flex flex-col flex-1">
<!--Header-->
<header class="z-10 py-4 bg-white shadow-md dark:bg-gray-800">
<div
class="container flex items-center justify-between h-full px-6 mx-auto text-purple-600 dark:text-purple-300">
<!-- Mobile hamburger -->
<button class="p-1 -ml-1 mr-5 rounded-md md:hidden focus:outline-none focus:shadow-outline-purple"
@click="toggleSideMenu" aria-label="Menu">
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
clip-rule="evenodd"></path>
</svg>
</button>
<!-- Header -->
<div class="flex justify-center flex-1 lg:mr-32">
</div>
<ul class="flex items-center flex-shrink-0 space-x-6">
<!-- Theme toggler -->
<li class="flex">
<button class="rounded-md focus:outline-none focus:shadow-outline-purple" @click="toggleTheme"
aria-label="Toggle color mode">
<template x-if="!dark">
<svg class="w-5 h-5" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20">
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path>
</svg>
</template>
<template x-if="dark">
<svg class="w-5 h-5" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z"
clip-rule="evenodd"></path>
</svg>
</template>
</button>
</li>
</ul>
</div>
</header>
<!--Main area of screen-->
<main class="h-full pb-16 overflow-y-auto">
<div class="container px-6 mx-auto grid">
<h2 class="my-6 text-2xl font-semibold text-gray-700 dark:text-gray-200">
Graphs of Asset Information
</h2>
<!-- CTA -->
<a class="flex items-center justify-between p-4 mb-8 text-sm font-semibold text-purple-100 bg-purple-600 rounded-lg shadow-md focus:outline-none focus:shadow-outline-purple"
href="https://github.com/estevanmaito/windmill-dashboard">
<div class="flex items-center">
<svg class="w-5 h-5 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
</svg>
<span>The GitHub Repository of this dashboard template</span>
</div>
<span>View more →</span>
</a>
<!--Description of charts below, adapted accordingly-->
<p class="mb-8 text-gray-600 dark:text-gray-400">
The pie chart and bar chart are provided by
<a class="text-purple-600 dark:text-purple-400 hover:underline" href="https://www.chartjs.org/">
Chart.js
</a>
,the 3D map below is provided by
<a class="text-purple-600 dark:text-purple-400 hover:underline" href="https://www.cesium.com/">
Cesium
</a>
<br>
If you want to check the asset in 3D map, simply click on the bar graph.
</p>
<!--Charts-->
<div class="grid gap-6 mb-8 md:grid-cols-2">
<!-- Bars chart -->
<div class="min-w-0 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
<h4 class="mb-4 font-semibold text-gray-800 dark:text-gray-300">
Bar Chart: assets with condition number
</h4>
<canvas id="bars"></canvas>
<div class="flex justify-center mt-4 space-x-3 text-sm text-gray-600 dark:text-gray-400">
</div>
</div>
<!--cesium-->
<div id="cesiumContainer" href="cesium.html"></div>
<!-- Doughnut/Pie chart -->
<div class="min-w-0 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
<h4 class="mb-4 font-semibold text-gray-800 dark:text-gray-300">
Pie Chart: Occurance of assets with differnt conditions
</h4>
<canvas id="pie"></canvas>
<div class="flex justify-center mt-4 space-x-3 text-sm text-gray-600 dark:text-gray-400">
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</body>
</html>
<script>
"use strict";
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3NmQ2NmVmNy0zZGY4LTQ1ZDAtYmUwOC03MjkzM2JjNzQ2OTQiLCJpZCI6MTU2NjMsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1Njg1MjQwNTl9.siDvMt3fH91XzE39FU_xqVrx-i6M1wWOBl_2vCrY6Xo';
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3NmQ2NmVmNy0zZGY4LTQ1ZDAtYmUwOC03MjkzM2JjNzQ2OTQiLCJpZCI6MTU2NjMsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1Njg1MjQwNTl9.siDvMt3fH91XzE39FU_xqVrx-i6M1wWOBl_2vCrY6Xo';
let imageryProviders = Cesium.createDefaultImageryProviderViewModels();
let selectedImageryProviderIndex = 7;
let viewer = new Cesium.Viewer('cesiumContainer', {
imageryProviderViewModels: imageryProviders,
selectedImageryProviderViewModel: imageryProviders[selectedImageryProviderIndex]
});
// only load the layer when the cesium basemap has been created
document.addEventListener('DOMContentLoaded', async function () {
await loadVectorLayer();
await loadBarChart();
await loadPieChart();
},
false);
</script>
<script>
"use strict";
async function loadVectorLayer() {
// get the data - NB this assumes that the API is running
//the following code is adapted from
// https://cesium.com/learn/cesiumjs/ref-doc/GeoJsonDataSource.html
let user_id = await getUserId();
let res = await getData(`/api/geojson/userAssets/${user_id}`);
let assets = res[0];
// set up color of different condition description
let conditions = await getData('/api/geojson/conditionDetails');
let pointColor;
// the following code is adapted from
//https://www.w3schools.com/jsref/jsref_forEach.asp
//THE color choice is adapted from
//https://cesium.com/learn/cesiumjs/ref-doc/Color.html?classFilter=color
assets.features.forEach((feature) => {
if (feature.properties.condition_description == conditions[0].condition_description) {
pointColor = Cesium.Color.LIGHTSKYBLUE
}
else if (feature.properties.condition_description == conditions[1].condition_description) {
pointColor = Cesium.Color.BLUE
}
else if (feature.properties.condition_description == conditions[2].condition_description) {
pointColor = Cesium.Color.BLUEVIOLET
}
else if (feature.properties.condition_description == conditions[3].condition_description) {
pointColor = Cesium.Color.CHOCOLATE
}
else if (feature.properties.condition_description == conditions[4].condition_description) {
pointColor = Cesium.Color.GOLD
}
else if (feature.properties.condition_description == conditions[5].condition_description) {
pointColor = Cesium.Color.DARKGRAY
}
let geoJSONOptions = {
markerColor: pointColor,
markerSymbol: '*',
}
// add data
let dataSource = new Cesium.GeoJsonDataSource("Assets");
dataSource.clampToGround = false;
dataSource._name = "Assets";
viewer.dataSources.add(dataSource)
dataSource.load(feature, geoJSONOptions).then(function (dataSource) {
viewer.flyTo(dataSource);
});
});
}
</script>