I have done Javascript and html 20yrs back and almost forgot howtos. So Please excuse me for ignorance. Also lot of things and syntax seems to have changed.
My requirement:
- Pull server Data from Solarwinds API
- Put it in a Dual List Box with Search options :)
- User Select the server they want to put in maintenance from list box (move from left list box to right list box)
- Select a From and To (Date time picker)
- Submit to API for muting alerts for the servers selected
First I am trying to get the data from the Solarwinds API and to my utter dismay I can't even show the data in a page :(. I am able to fetch the data using Postman. My webserver is IIS
var myHeaders = new Headers();
myHeaders.append("User-Agent", "curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3");
myHeaders.append("Access-Control-Allow-Origin", "*");
myHeaders.append("rejectUnauthorized", "");
myHeaders.append("Authorization", "Basic blahblahblhablhablahblah");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://serverHostName.net:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+Caption,+IPAddress,+NodeID,+Uri+AS+[EntityUri]+FROM+Orion.Nodes+WHERE+Vendor+=+'Windows'", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
My HTML looks like below
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Maintenance Window</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="SolarwindsApiInteraction.js"></script>
</body>
</html>
SADLY: I am getting a blank Page.
What I need is the publish the output of the Data in a Dual List box. The Json usually looks like below based on Postman output
{"results":[{"Caption":"ServerA","IPAddress":"5X.1XX.XX.XX1","NodeID":1,"EntityUri":"swis://ServerA.net/Orion/Orion.Nodes/NodeID=1"},{"Caption":"ServerB","IPAddress":"5X.1XX.XX.XX2","NodeID":2,"EntityUri":"swis://ServerA.net/Orion/Orion.Nodes/NodeID=2"},{"Caption":"ServerC","IPAddress":"5X.1XX.XX.XX8","NodeID":3,"EntityUri":"swis://ServerC.net/Orion/Orion.Nodes/NodeID=3"},{"Caption":"ServerD","IPAddress":"5X.1XX.XX.XX4","NodeID":4,"EntityUri":"swis://ServerD.net/Orion/Orion.Nodes/NodeID=4"},{"Caption":"ServerE","IPAddress":"5X.1XX.XX.XX5","NodeID":5,"EntityUri":"swis://ServerE.net/Orion/Orion.Nodes/NodeID=5"}]}
The nodeID can be the index in the listbox with ServerName as name in the listbox