-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.html
174 lines (151 loc) · 6.41 KB
/
dashboard.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Script Execution</title>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h1 class="mb-4">Execute Scripts</h1>
<div class="row justify-content-center mb-4">
<div class="col-md-6">
<!-- Password Form -->
<form id="passwordForm" method="post" class="mb-3">
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" placeholder="Enter password">
</div>
</form>
</div>
</div>
<div class="row justify-content-center mb-2">
<div class="col-md-6">
<!-- Create Form -->
<form id="createForm" method="post">
<div class="form-group">
<label for="regions">Select Region:</label>
<select class='form-control' id='regions'>
<option value='nrt'>Tokyo</option>
<option value='sgp'>Singapore</option>
<option value='bom'>Mumbai</option>
<option value='icn'>Seoul</option>
</select>
</div>
<div class="form-group">
<label for="duration">Running Duration (e.g. 55min):</label>
<input type="text" class="form-control" id="duration" value="55">
</div>
<button type="submit" class="btn btn-primary btn-block mt-2">Execute create.sh</button>
</form>
</div>
</div>
<div class="row justify-content-center mb-2">
<div class="col-md-6">
<!-- Remove Form -->
<form id="removeForm" method="post">
<button type="submit" class="btn btn-danger btn-block mt-2">Execute remove.sh</button>
</form>
</div>
</div>
<div class="row justify-content-center mb-2">
<div class="col-md-6">
<form id='reinstallForm' method='post'>
<div class="form-group">
<label for="regions">Select Xray Schema:</label>
<select class='form-control' id='xraySchema'>
<option value='reality'>Reality</option>
<option value='tcp'>TCP</option>
</select>
</div>
<button type="submit" class="btn btn-primary btn-block mt-2">Execute Reintall.sh</button>
</form>
</div>
</div>
<!-- Result Section -->
<div id='result' style='margin-top: 20px;'></div>
<div id="loader" class="text-center" style="display: none;">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
</div>
<script type='text/javascript'>
function showLoader() {
$('#loader').show();
}
function hideLoader() {
$('#loader').hide();
}
function getPassword() {
return $('#password').val();
}
$(document).ready(function () {
// Create script AJAX call
$('#createForm').on('submit', function (e) {
e.preventDefault();
showLoader();
var region = $('#regions').val();
var duration = $('#duration').val();
//清空结果
$('#result').html('<pre></pre>');
$.ajax({
url: '/vps/create',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ password: getPassword(), region: region ,duration: duration}),
success: function (response) {
hideLoader();
$('#result').html('<pre>' + JSON.stringify(response, null, 2) + '</pre>');
},
error: function (response) {
hideLoader();
$('#result').html('<pre>Error occurred!</pre>');
}
});
});
$('#removeForm').on('submit', function (e) {
e.preventDefault();
$('#result').html('<pre></pre>');
showLoader();
$.ajax({
url: '/vps/remove',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ password: getPassword() }),
success: function (response) {
hideLoader();
$('#result').html('<pre>' + JSON.stringify(response, null, 2) + '</pre>');
},
error: function (response) {
hideLoader();
$('#result').html('<pre>Error occurred!</pre>');
}
});
});
$('#reinstallForm').on('submit', function (e) {
e.preventDefault();
showLoader();
var xrayschema = $('#xraySchema').val();
$('#result').html('<pre></pre>');
$.ajax({
url: '/vps/xray',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ password: getPassword(), xrayschema: xrayschema }),
success: function (response) {
hideLoader();
$('#result').html('<pre>' + JSON.stringify(response, null, 2) + '</pre>');
},
error: function (response) {
hideLoader();
$('#result').html('<pre>Error occurred!</pre>');
}
});
});
});
</script>
</body>
</html>