-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsample_blank.htm
274 lines (216 loc) · 6.96 KB
/
sample_blank.htm
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
<!-- /*********************************************************************
* Copyright (c) Intel Corporation 2019-2021
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/ -->
<!DOCTYPE html>
<html lang="en">
<!-- ************** DO NOT MODIFY HTML/CSS *************** -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Intel AMT API Demo</title>
</head>
<style>
.grid {
display: grid;
grid-template-columns: 50% 50%;
grid-auto-rows: 40vh 40vh;
margin: 5% 10%;
}
.item {
border: 1px solid black;
padding: 3%;
}
.actions {
padding: 0;
margin: 1%;
}
.row {
display: flex;
}
.column {
flex: 50%;
}
</style>
<!---------- BASIC HTML TEMPLATE FOR DEMO --------- -->
<body>
<div class="grid">
<div class="item">
<h3>1. Get Authorization Token</h3>
<div>
<button id="authTest">Test</button>
</div>
<p>My Token: <span id="token_output" style="word-wrap: break-word;"></span></p>
</div>
<div class="item">
<h3>2. Hardware Information</h3>
<div>
<button id="hwInfoTest">Test</button>
</div>
<br>
<h4>Find and update with correct hardware data</h4>
<p>CPU: <span id="cpu"></span></p>
<p>Manufacturer: <span id="man_cpu"></span></p>
<p>Model: <span id="model"></span></p>
<p>BIOS Manufacturer: <span id="man_bios"></span></p>
<p>BIOS Version: <span id="ver_bios"></span></p>
</div>
<div class="item">
<h3>3. Power Capabilities</h3>
<div>
<button id="capabilitiesTest">Test</button>
</div>
<h4>Find possible power actions</h4>
<div class="row">
<div class="column" id="power1"></div>
<div class="column" id="power2"></div>
</div>
</div>
<div class="item">
<h3>4. Perform Power Actions</h3>
<span>Power Action: </span><input type="text" id="actioninput" placeholder="Action Number">
<div style="margin-top: 5%;">
<button id="performActionTest">Test</button>
</div>
<p id="action_output"></p>
</div>
</div>
<script type="text/javascript">
//Link the button listeners
getElementById('authTest').addEventListener('click', getAuth);
getElementById('hwInfoTest').addEventListener('click', getHW);
getElementById('capabilitiesTest').addEventListener('click', getFeatures);
getElementById('performActionTest').addEventListener('click', execReset);
// ******************* MAKE ALL CHANGES BELOW *******************
// TODO:
// Fill out the MPS Server Config Information
// Edit API Calls by setting the:
// CORRECT URL
// CORRECT Method
// CORRECT Body (if applicable)
//----------- MPS SERVER CONFIG INFORMATION --------------
var config = {
username: "",
password: "",
deviceGUID: "",
mpsserverIP: "",
auth_token: "" //Skip, the auth_token will auto-populate
};
//----------- Authorization Token API --------------
var auth_url = "" //API URL For Authorize
function getAuth() {
console.log('Start fetching auth token.....');
fetch(auth_url, {
"headers": {
"content-type": "application/json"
},
"method": "", //REST Method
"body": JSON.stringify({
"username": "", //MPS User
"password": "" //MPS Pass
})
})
.then(res => {
return res.json();
})
.then(data => {
// console.log(data);
getElementById("token_output").innerHTML = data.token;
config.auth_token = data.token;
})
.catch(error => {
console.log('Caught Exception', error);
})
}
//----------- HARDWARE INFORMATION API --------------
var hw_url = "" //API URL for Hardware Information
function getHW() {
console.log('Start fetching hardwareInfo.....');
fetch(hw_url, {
"headers": {
"content-type": "application/json",
"authorization": "Bearer " + config.auth_token
},
"method": "" //REST Method
})
.then(res => {
return res.json();
})
.then(data => {
// console.log(data)
getElementById('cpu').innerHTML = data.CIM_Chip.responses[0].Version;
getElementById('man_cpu').innerHTML = data.CIM_Chip.responses[0].Manufacturer;
getElementById('model').innerHTML = data.CIM_Chassis.response.Model;
getElementById('man_bios').innerHTML = data.CIM_BIOSElement.response.Manufacturer;
getElementById('ver_bios').innerHTML = data.CIM_BIOSElement.response.Version;
})
.catch(error => {
console.log('Caught Exception', error);
})
}
//----------- POWER CAPABILITIES API --------------
var capab_url = "" //API URL for Power Capabilities
function getFeatures() {
console.log('Start fetching power capabilities.....');
fetch(capab_url, {
"headers": {
"content-type": "application/json",
"authorization": "Bearer " + config.auth_token
},
"method": "" //REST Method
})
.then(res => {
return res.json();
})
.then(data => {
// console.log(data)
var inc = 0;
for (var key of Object.keys(data)) {
// console.log(key + " -> " + data[key])
var item = document.createElement('ul');
item.setAttribute('class', 'actions');
item.innerHTML = key + " -> " + data[key];
if (inc < 9) { getElementById("power1").appendChild(item); }
else { getElementById("power2").appendChild(item); }
inc++;
}
})
.catch(error => {
console.log('Caught Exception', error);
})
}
//----------- POWER ACTION API --------------
var power_url = "" //API URL for performing Power Actions
function execReset() {
console.log('Start fetching power action.....');
var poweraction = getElementById("actioninput").value;
fetch(power_url, {
"headers": {
"content-type": "application/json",
"authorization": "Bearer " + config.auth_token
},
"method": "", //REST Method
//The body is already filled out for you
"body": JSON.stringify({
"action": poweraction,
"useSOL": false
})
})
.then(res => {
return res.json();
})
.then(data => {
// console.log(data);
getElementById("action_output").innerHTML = data.Body.ReturnValue + ": " + data.Body.ReturnValueStr;
})
.catch(error => {
console.log('Caught Exception', error);
})
}
function getElementById(id) {
return document.getElementById(id);
}
</script>
</body>
</html>