-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html.bak
More file actions
230 lines (210 loc) · 9.57 KB
/
dashboard.html.bak
File metadata and controls
230 lines (210 loc) · 9.57 KB
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
<!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 py-5">
<div class="row justify-content-center mb-4">
<div class="col-lg-6 col-md-8">
<div class="text-center mb-4">
<h2 class="font-weight-bold">VPS 管理面板</h2>
<p class="text-muted mb-0">一键创建、安装、删除 Vultr VPS</p>
</div>
<div class="card shadow-sm mb-3">
<div class="card-body">
<form id="passwordForm" method="post" autocomplete="off">
<div class="form-group mb-2">
<input type="password" class="form-control" id="password" placeholder="管理密码">
</div>
</form>
</div>
</div>
<div class="card shadow-sm mb-3">
<div class="card-body">
<form id="createForm" method="post">
<div class="form-row">
<div class="form-group col-4 mb-2">
<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 col-4 mb-2">
<select class='form-control' id='createXraySchema'>
<option value='reality'>Reality</option>
<option value='tcp'>TCP</option>
</select>
</div>
<div class="form-group col-4 mb-2">
<input type="text" class="form-control" id="duration" value="55" placeholder="运行时长(min)">
</div>
</div>
<div class="row">
<div class="col-6">
<button type="submit" class="btn btn-primary btn-block">创建 VPS</button>
</div>
<div class="col-6">
<button type="button" id="createAndInstallBtn" class="btn btn-success btn-block">一键创建</button>
</div>
</div>
</form>
</div>
</div>
<div class="card shadow-sm mb-3">
<div class="card-body">
<form id="removeForm" method="post">
<button type="submit" class="btn btn-danger btn-block">删除所有 VPS</button>
</form>
</div>
</div>
<div class="card shadow-sm mb-3">
<div class="card-body">
<form id='reinstallForm' method='post'>
<div class="form-row">
<div class="form-group col-12 mb-2">
<select class='form-control' id='xraySchema'>
<option value='reality'>Reality</option>
<option value='tcp'>TCP</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-info btn-block">重装 Xray</button>
</form>
</div>
</div>
<div id="loader" class="text-center" style="display: none;">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div id='result' class="mt-3"></div>
</div>
</div>
</div>
<script type='text/javascript'>
function showLoader() {
$('#loader').show();
}
function hideLoader() {
$('#loader').hide();
}
function getPassword() {
return $('#password').val();
}
function checkStatus() {
$.ajax({
url: '/vps/status',
type: 'GET',
success: function (response) {
if (response.in_progress) {
$('#result').html('<pre>任务进行中... 请稍候</pre>');
setTimeout(checkStatus, 5000); // 5秒后再次检查
} else {
$('#result').html('<pre>任务已完成!</pre>');
}
},
error: function () {
$('#result').html('<pre>检查状态时出错</pre>');
}
});
}
$(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>');
}
});
});
// 一键创建按钮处理
$('#createAndInstallBtn').on('click', function (e) {
e.preventDefault();
showLoader();
var region = $('#regions').val();
var xrayschema = $('#createXraySchema').val();
var duration = $('#duration').val();
//清空结果
$('#result').html('<pre></pre>');
$.ajax({
url: '/vps/create-and-install',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ password: getPassword(), region: region, xrayschema: xrayschema, duration: duration}),
success: function (response) {
hideLoader();
$('#result').html('<pre>' + JSON.stringify(response, null, 2) + '</pre>');
// 启动状态检查
checkStatus();
},
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>