This repository has been archived by the owner on Apr 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
213 lines (197 loc) · 7.79 KB
/
index.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
<!-- /**
* Entry / Start Point of the Websocket Applicartion
* + Setup
* + Create App
* + Run App
*
* @version 1.0
* @author Benjamin Thomas Schwertfeger
* @email [email protected]
* @github https://github.com/ProjectPepperHSB/WebsocketServer
* / -->
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Pepper Bachelor Project</title>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
<script src='https://code.jquery.com/jquery-3.3.1.slim.min.js'
integrity='sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo'
crossorigin='anonymous'></script>
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js'
integrity='sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1'
crossorigin='anonymous'></script>
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js'
integrity='sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM'
crossorigin='anonymous'></script>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'
integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>
<link rel='stylesheet' type'' href='styles.css' />
<script src='https://cdn.jsdelivr.net/npm/chart.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#navbarExample01"
aria-controls="navbarExample01"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarExample01">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link" aria-current="page" href="/">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/ProjectPepperHSB">GitHub</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar -->
<div class="pt-5 pb-2 text-center bg-light">
<h1 class="mb-3">Bachelor Project Pepper / KI Lab Dashboard</h1>
</div>
<div class='container-fluid'>
<div class='row'>
<div class='col-8' style='padding-right: 1rem;'>
<div class='card mt-5'>
<div class='card-body'>
<h5 class='card-title'>Some nice headline</h5>
<p class='card-text'>Our collected Data:
<div class="row" style="height: 30rem;">
<!-- PIE CHARTS -->
<div class="col-3">
<div class='dashboard-plot-container-sm'>
<canvas id='dashboard-plot-canvas-2' class='canvas'></canvas>
</div>
</div>
<div class="col-3">
<div class='dashboard-plot-container-sm'>
<canvas id='dashboard-plot-canvas-3' class='canvas'></canvas>
</div>
</div>
<div class="col-3">
<div class='dashboard-plot-container-sm'>
<canvas id='dashboard-plot-canvas-4' class='canvas'></canvas>
</div>
</div>
<div class="col-3">
<div class='dashboard-plot-container-sm'>
<canvas id='dashboard-plot-canvas-5' class='canvas'></canvas>
</div>
</div>
</div>
<!-- BAR CHARTS -->
<div class="row">
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
</div>
</p>
</div>
</div>
</div>
<div class='col-4' style='padding-left: 0px;'>
<div class='card bg-light mr-5 mt-5' style="height: 38.4rem;">
<div class='card-body'>
<h5 class='card-title' id="msgcnt">Query Log</p></h5>
<div id='logdiv' style='overflow-y: scroll; height: 550px;'> <!-- kinda tricky here-->
<p class='card-text'>
<ul id='messages'></ul>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!--
<form id='form' action=''>
<input id='input' autocomplete='off' /><button>Send</button>
</form>
-->
<div id="footer" class="mt-3" style="text-align:center; margin: 0 auto; width: 50%; font-size: 16px;">Site developed by <a href="https://www.b-schwertfeger.de">Benjamin T. Schwertfeger</a> © 2022</div>
<script src='/socket.io/socket.io.js'></script>
<script type='module'>
import updatePieChart from './chart.js';
let
socket = io(),
messages = document.getElementById('messages'),
form = document.getElementById('form'),
input = document.getElementById('input'),
received_messages_count = 0,
received_data = {
smiles: {},
gender: {},
emotion_state: {},
pleasure_state: {}
};
function handle_topic(data) {
data = JSON.parse(data);
let data2Plot;
try {
if (data.topic === 'smile_state') {
if (typeof received_data.smiles[data.state] == 'undefined') received_data.smiles[data.state] = 1;
else received_data.smiles[data.state]++;
data2Plot = received_data.smiles;
} else if (data.topic === 'gender') {
if (typeof received_data.gender[data.gender] == 'undefined') received_data.gender[data.gender] = 1;
else received_data.gender[data.gender]++;
data2Plot = received_data.gender;
} else if (data.topic === 'pleasure_state') {
if (typeof received_data.pleasure_state[data.state] == 'undefined') received_data.pleasure_state[data.state] = 1;
else received_data.pleasure_state[data.state]++;
data2Plot = received_data.pleasure_state;
} else if (data.topic === 'emotion_state') {
if (typeof received_data.emotion_state[data.state] == 'undefined') received_data.emotion_state[data.state] = 1;
else received_data.emotion_state[data.state]++;
data2Plot = received_data.emotion_state;
} else if (data.topic === 'phrase') {
if (typeof received_data.phrases[data.state] == 'undefined') eceived_data.phrases[data.state] = 1;
else received_data.phrases[data.state]++;
data2Plot = received_data.phrases;
}
updatePieChart(data.topic, data2Plot)
} catch (e) { }
}
socket.on('chat message', (msg) => {
received_messages_count++;
$('#msgcnt').text(`Query Log - Messages: ${received_messages_count}`);
try {
msg = JSON.parse(msg);
handle_topic(msg);
} catch (e) { }
var date = new Date();
const dateStr =
('00' + (date.getMonth() + 1)).slice(-2) + '.' +
('00' + date.getDate()).slice(-2) + '.' +
date.getFullYear() + ' ' +
('00' + date.getHours()).slice(-2) + ':' +
('00' + date.getMinutes()).slice(-2) + ':' +
('00' + date.getSeconds()).slice(-2);
let item = document.createElement('li');
item.textContent = `${dateStr}: ${msg}`;
messages.appendChild(item);
let logdiv = $("#logdiv").get(0);
logdiv.scrollTop = logdiv.scrollHeight;
});
</script>
</body>
</html>