-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample-filter-meta.html
167 lines (153 loc) · 5.44 KB
/
sample-filter-meta.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
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<title>VXG AI Meta loader</title>
<!-- frameworks -->
<script src="frw/jquery.min.js"></script>
<script src="frw/jquery-ui.min.js"></script>
<script src="frw/jquery.formatDateTime.js"></script>
<script src="frw/datetimepicker.full.min.js"></script>
<link rel="stylesheet" type="text/css" href="frw/bootstrap.min.css">
<script src="frw/bootstrap.min.js"></script>
<style>
#tokenContainer {
width: 700px;
}
.btn {
color: white;
background-color: #a0cf4d;
}
table td {
text-align: center;
padding: 5px;
}
td.middle-color > div {
width: 40px;
height: 40px;
}
.subitem {
display: inline-block;
width: fit-content;
}
.container > div {
margin-top: 30px;
}
</style>
</head>
<body>
<div class="container">
<h1>Filter Meta</h1>
<div class="form-inline" role="form">
<h3>Select a camera</h3>
<div class="form-group ">
<div class="input-group ">
<input id="tokenContainer" type="text" class="form-control" placeholder="Enter access token"
value="token">
</div>
</div>
</div>
<h3>Create filter</h3>
<div id="filter-container">
<p class="subitem" style="min-width: 60px;">From</p>
<input type="datetime-local" name="from" step="2"
class="form-control form-control-lg subitem"><br/><br/>
<p class="subitem" style="min-width: 60px;">To</p>
<input type="datetime-local" name="to" step="2"
class="form-control form-control-lg subitem"><br/><br/>
<div>
<p class="subitem" style="min-width: 60px;">People</p>
<select name="pers-op" class="form-control subitem">
<option value="eq">=</option>
<option value="gt">></option>
<option value="lt"><</option>
</select>
<input type="number" name="people-count" placeholder="value" step="1"
class="form-control form-control-lg subitem" required>
</div>
<div style="margin: 20px 0 20px 0">
<select name="main-op" class="form-control subitem">
<option value="and">and</option>
<option value="or">or</option>
</select>
</div>
<div>
<p class="subitem" style="min-width: 60px;">Car</p>
<select name="car-op" class="form-control subitem">
<option value="eq">=</option>
<option value="gt">></option>
<option value="lt"><</option>
</select>
<input type="number" name="car-count" placeholder="value" step="1"
class="form-control form-control-lg subitem" required>
</div>
</div>
<div style="margin-top:10px; font-family: 'Ubuntu Mono',serif">
<button id="apply" class="btn btn-default" onclick="applyFilter()">Apply</button>
<div id="result"></div>
</div>
<br/>
<div id="result-container">
<table class="table table-striped" style="width: fit-content">
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Person</th>
<th scope="col">Car</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</div>
</div>
<script>
const drawResult = (r) => {
let text = r['objects'].map(k => `<tr>
<td>${k['timestamp']}</td>
<td>${k['long']['Person'] || 0}</td>
<td>${k['long']['Vehicle'] || 0}</td>
</tr>`);
$('#tbody').html(text)
};
const applyFilter = () => {
let [main_op, pers_op, car_op, people_count, car_count] =
['main-op', 'pers-op', 'car-op',
'people-count', 'car-count'].map((e) => {
return $('[name=' + e + ']');
});
[people_count, car_count] = [people_count, car_count].map(e => Number(e.val()));
let data = {
"limit": 1000,
"filter": {
'and': [{
[main_op.val()]: [
{
"field": "long.Person",
[pers_op.val()]: people_count,
}, {
"field": "long.Vehicle",
[car_op.val()]: car_count,
}
]
}, {
"field": "timestamp",
"gt": $('[name=from]').val()
}, {
"field": "timestamp",
"lt": $('[name=to]').val()
}]
},
};
return $.post({
url: 'https://web.skyvr.videoexpertsgroup.com/api/v4/meta/filter/',
dataType: 'json',
data: JSON.stringify(data),
headers: {
'Authorization': 'Acc ' + $('#tokenContainer').val(),
'Content-Type': 'application/json',
'Accept': 'application/json',
},
}).then(drawResult)
};
</script>
</body>