-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (88 loc) · 3.35 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MariaDB Xpand</title>
<!-- Add some CSS to change client UI -->
<style>
body {
background-color: #232F3E;
}
label, button {
color: #FF9900;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
margin-left: 40px;
}
input {
color: #232F3E;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
margin-left: 20px;
}
</style>
<script>
// define the callAPI function that takes parameters
var callAPI = (accountID, ipAddress, hardwareAddress, serialNumber, info, lastReported, lastInfo, online )=>{
// instantiate a headers object
var myHeaders = new Headers();
// add content type header to object
myHeaders.append("Content-Type", "application/json");
// using built in JSON utility package turn object to string and store in a variable
console.log ("Serial # is " + serialNumber + " and IP Address " + ipAddress)
var raw = JSON.stringify({"accountID":accountID,"ipAddress":ipAddress , "hardwareAddress":hardwareAddress , "serialNumber":serialNumber , "info":info , "lastReported":lastReported , "lastInfo":lastInfo, "online":online });
console.log ("raw is " + raw)
// create a JSON object with parameters for API call and store in a variable
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
// make API call with parameters and use promises to get response
fetch("https://9bv4cbvm4m.execute-api.us-west-2.amazonaws.com/dev", requestOptions)
.then(response => response.text())
.then(result => alert(JSON.parse(result).body))
.catch(error => console.log('the error is', error));
}
</script>
</head>
<body>
<form>
<label>AccountID :</label>
<input type="text" id="accountID">
<BR>
<label>IP Address :</label>
<input type="text" id="ipAddress">
<BR>
<label>Hardware Address :</label>
<input type="text" id="hardwareAddress">
<BR>
<label>Serial # of Device :</label>
<input type="text" id="serialNumber">
<BR>
<label>Info :</label>
<input type="text" id="info">
<BR>
<label>Last Reported Date :</label>
<input type="text" id="lastReported">
<BR>
<label>Last Info Date :</label>
<input type="text" id="lastInfo">
<BR>
<label>Online? :</label>
<input type="text" id="online">
<BR>
<!-- set button onClick method to call function we defined passing input values as parameters -->
<button type="button" onclick="callAPI(document.getElementById('accountID').value,
document.getElementById('ipAddress').value,
document.getElementById('hardwareAddress').value,
document.getElementById('serialNumber').value,
document.getElementById('info').value,
document.getElementById('lastReported').value,
document.getElementById('lastInfo').value,
document.getElementById('online').value
)">Call API</button>
</form>
</body>
</html>