-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
143 lines (136 loc) · 4.81 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
<!DOCTYPE html>
<html>
<head>
<title>I Have No Thumbs</title>
<meta charset="UTF-8" />
<meta name="google" content="notranslate">
<meta http-equiv="Content-Language" content="en" />
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
</head>
<body>
<script type=text/javascript>
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function display_san_list() {
$("#sanlist").empty().append("<h1>SAN List</h1>");
$.ajax({
url: "json/san_host_list.php",
type: "GET",
dataType: "json",
success: function (result) {
console.log(result);
if (result.hasOwnProperty('error')) {
$.each(result.error, function(idx, val) {
$("#error").append(val);
});
} else {
$.each(result, function(idx,val) {
if (val.active % 2 == 1) {
var button = "<button id=" + val._id.$id + ">Deactivate</button>";
} else {
var button = "<button id=" + val._id.$id + ">Activate</button>";
}
$("#sanlist").append("<p id=" + val.sanname + ">" + val.sanname + " " + button + "<br></p>");
$.each(val.sp, function(s_idx,s_val) {
$("#" + val.sanname).append("<a href='stats.html?id=" + s_val._id.$id + "'>" + s_val.hostname + "</a><br>");
});
//$("#" + val.sanname).append(
});
}
//display_san(result);
},
error: function (xhr) {
$("#error").empty().append("Ajax error json/list_san.php");
console.log(xhr);
}
});
}
$(document).on('click', 'button', function(event) {
console.log($(this).attr('id'));
$.ajax({
url: "json/san_host_toggle.php?id=" + $(this).attr('id'),
type: "GET",
dataType: "json",
success: function (result) {
console.log(result);
display_san_list();
},
error: function (xhr) {
$("#error").empty().append("Ajax error json/list_san.php");
console.log(xhr);
}
})
});
$(document).ready(function() {
$("#error").empty();
$("input").tooltip();
// Display the current list of SAN's
display_san_list();
var request;
$("#san_input").submit(function (event) {
event.preventDefault();
if (request) {
request.abort();
}
var serializedData = $(this).serialize();
var $inputs = $(this).find("input");
$inputs.prop("disabled", true);
var request = $.ajax({
url: "json/san_host_add.php",
type: "POST",
data: serializedData,
dataType: "json",
success: function (result) {
console.log(result);
if (result.hasOwnProperty('error')) {
$.each(result.error, function(idx, val) {
$("#error").append(val);
});
}
display_san_list();
},
error: function (xhr) {
console.log(xhr);
$("#error").empty().append("AJAX Error json/add_san.php");
}
});
request.always(function() {
$inputs.prop("disabled", false);
});
});
$("#loading").empty();
$("#input_form").show();
});
</script>
<div id=loading>Loading.....Data</div>
<div id=error></div>
<div id=sanlist></div>
<div id=input_form style="display : none">
<form id=san_input>
<table>
<tr>
<th colspan=2>Add New SAN</th>
</tr>
<tr>
<td><label>SAN Name:</label></td><td><input type=text name=sanname id=form_vnxname title="Friendly name that you know this SAN by."/></td>
</tr>
<tr>
<td><label>SPA Hostname:</label></td><td><input type=text name=spa id=form_spa title="Hostaname of the SP."/></td>
</tr>
<tr>
<td><label>SPB Hostname:</label></td><td><input type=text name=spb id=form_spb title="Hostaname of the SP."/></td>
</tr>
<tr>
<td colspan=2><input type=submit id=form_submit value=Add></td>
</tr>
</table>
</form>
</body>
</html>