-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
156 lines (145 loc) · 6.85 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create Request</title>
<meta charset="UTF-8">
<script src="inc/main.js"></script>
<script src="inc/requests.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="/inc/main.css">
</head>
<body onload="populateList()">
<div class="accordion" id="testaccord">
<div class="accordion-item">
<h4 class="accordion-header" id="headingOne">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseOne"
aria-expanded="false" aria-controls="collapseOne">
Click here to add data
</button>
</h4>
<div id="collapseOne" class="accordion-collapse collapse" aria-labelledby="headingOne"
data-bs-parent="#testaccord">
<div class="accordion-body">
<form class="row g-3">
<div class="col-sm-3">
<label for="meter_serialnumber" class="form-label">Meter Serial Number</label>
<input type="text" class="form-control" name="meter_serialnumber" id="meter_serialnumber">
</div>
<div class="col-sm-3">
<label for="gw_serialnumber" class="form-label">Gateway Serial Number</label>
<input type="text" class="form-control" name="gw_serialnumber" id="gw_serialnumber">
</div>
<div class="col-sm-3">
<label for="ip" class="form-label">IP</label>
<input type="text" name="ip" id="ip" class="form-control" minlength="7" maxlength="15"
size="15"
pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$">
</div>
<div class="col-sm-1">
<label for="Add" class="form-label"></label>
<button type="submit" id="Add" class="btn btn-primary" onclick="addToDatabase()">Add</button>
</div>
<div class="col-sm-2">
<label for="delete" class="form-label"></label>
<button type="submit" id="delete" class="btn btn-danger">Delete All Data</button>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container-fluid border" style="width: 80%; ">
<div class="row">
<div class="col-6">
<div class="container">
<div class="col" style="margin: 5px; padding: 30px">
<label for="meter_list">Meter:</label>
<div id="meter_list" name="meter_list">
</div>
<div class="row-md-12">
<label for="gateway_list">Gateway: </label>
<select id="gateway_list" class="form-select"></select></div>
<div class="row-md-12">
<label for="ip_list">IP: </label>
<select id="ip_list" class="form-select"></select>
</div>
<div class="row-md-12">
<label for="requestName">Request:</label>
<input id="requestName" class="form-control" placeholder="Type to search.."
value="Energy Profile"
autoComplete="on"
list="suggestions" onfocus="this.value=''" onchange="this.blur();"/>
<datalist id="suggestions"></datalist>
</div>
<div class="row-md-12">
<label for="dt_from">From:</label>
<input type="datetime-local" class="form-control" name="dt_from" id="dt_from">
</div>
<div class="row-md-12">
<label for="dt_to">To: </label>
<input type="datetime-local" class="form-control" name="dt_to" id="dt_to">
</div>
<div class="row-sm-3" style="margin-top: 15px">
<button class="btn btn-primary" onclick="createRequest()">Create Request</button>
</div>
</div>
</div>
</div>
<div class="col-6 position-relative" style="margin-top: 36px;">
<h5 id="reqname"></h5>
<pre id="req" style=" margin-left: 10px; margin-top: 30px;"></pre>
<button class="btn btn-success position-absolute top-0 end-0" id="copybtn" data-clipboard-target="#req" style="border: none;
border-radius: 34px;
margin: 20px;
display: none;">
Copy
</button>
</div>
</div>
</div>
</body>
</html>
<script>
var deleteBtn = document.getElementById("delete");
deleteBtn.addEventListener("click", function () {
if (confirm("Delete all entries?")) {
localStorage.clear();
}
});
let meter_list = document.getElementById('meter_list');
let gatewayListOptions = document.getElementById('gateway_list').options;
let ipOptions = document.getElementById('ip_list').options;
let date_from = document.getElementById("dt_from");
let date_to = document.getElementById("dt_to");
let dt_yesterday = new Date((Date.now() - 72000000)).toISOString().substring(0, 16);
let dt_today = new Date((Date.now()) + 14400000).toISOString().substring(0, 16);
date_from.value = dt_yesterday;
date_to.value = dt_today;
const target = document.getElementById('req');
const button = target.nextElementSibling;
let clipboard = new ClipboardJS(button, {
target: target,
text: function () {
return target.value;
}
});
clipboard.on('success', function (e) {
const currentLabel = button.innerHTML;
if (button.innerHTML === 'Copied!') {
return;
}
button.innerHTML = 'Copied!';
setTimeout(function () {
button.innerHTML = currentLabel;
}, 3000)
});
</script>