forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiManagerNodeManager.html
More file actions
308 lines (292 loc) · 12.1 KB
/
iManagerNodeManager.html
File metadata and controls
308 lines (292 loc) · 12.1 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
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>iManager 节点管理使用示例</title>
<script type="text/javascript" include="jquery,bootstrap-css" src="../js/include-web.js"></script>
<script type="text/javascript" src="../../dist/include-leaflet.js"></script>
<style>
.panel {
margin-bottom: 0;
}
#listTable th,#listTable td{
padding:5px;
}
</style>
</head>
<body style=" margin: 0;overflow: auto;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div class="container">
<div class="page-header">
<h4>iManager 节点管理使用示例</h4>
</div>
<div class="row">
<table class="table table-bordered col-md-6">
<thead>
<tr>
<th class="text-center">功能</th>
<th class="text-center">示例</th>
</tr>
</thead>
<tbody>
<!--登录-->
<tr>
<td class="text-center text-success">登录</td>
<td>
<div class="col-md-10 col-md-offset-1">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label for="loginUrl_iManager" class="col-md-2 control-label">服务地址</label>
<div class="col-md-8">
<input type="text" class="form-control" id="loginUrl_iManager" placeholder="iManager首页地址,如http://localhost:8390/imanager">
</div>
</div>
<div class="form-group">
<label for="username_iManager" class="col-md-2 control-label">用户名</label>
<div class="col-md-8">
<input type="text" class="form-control" id="username_iManager" value="admin">
</div>
</div>
<div class="form-group">
<label for="password_iManager" class="col-md-2 control-label">密码</label>
<div class="col-md-8">
<input type="password" class="form-control" id="password_iManager" value="admin">
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<a class="btn btn-success" onclick="loginManager()">登录</a>
</div>
</div>
</fieldset>
</form>
</div>
</td>
</tr>
<!--token 获取iServer列表-->
<tr>
<td class="text-center text-success">获取iServer列表</td>
<td>
<div class="col-md-10 col-md-offset-1">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<div class="col-md-12">
<table id="listTable">
<thead>
<tr role="row">
<th rowspan="1" colspan="1" style="width: 50px;">
<div><span>id</span></div>
</th>
<th rowspan="1" colspan="1" style="width: 150px;">
<div><span>名称</span></div>
</th>
<th rowspan="1" colspan="1" style="width: 150px;">
<div><span>地址</span></div>
</th>
</tr>
</thead>
<tbody id="nodeList">
</tbody>
</table>
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<a class="btn btn-success" onclick="iServerList()">获取</a>
</div>
</div>
</fieldset>
</form>
</div>
</td>
</tr>
<!--token 停止节点-->
<!--token 启动节点-->
<tr>
<td class="text-center text-success">启动节点</td>
<td>
<div class="col-md-10 col-md-offset-1">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label for="start_node_ids" class="col-md-2 control-label">节点id</label>
<div class="col-md-8">
<input type="text" class="form-control" id="start_node_ids" placeholder="要启动节点的id">
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<a class="btn btn-success" onclick="startNodes()">启动</a>
</div>
</div>
</fieldset>
</form>
</div>
</td>
</tr>
<!--token 停止节点-->
<tr>
<td class="text-center text-success">停止节点</td>
<td>
<div class="col-md-10 col-md-offset-1">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label for="stop_node_ids" class="col-md-2 control-label">节点id</label>
<div class="col-md-8">
<input type="text" class="form-control" id="stop_node_ids" placeholder="要停止节点的id">
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<a class="btn btn-success" onclick="stopNodes()">停止</a>
</div>
</div>
</fieldset>
</form>
</div>
</td>
</tr>
<!--创建iServer-->
<tr>
<td class="text-center text-success">创建iServer</td>
<td>
<div class="col-md-10 col-md-offset-1">
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label for="create_nodeName" class="col-md-2 control-label">节点名称</label>
<div class="col-md-8">
<input type="text" class="form-control" id="create_nodeName" placeholder="请填写节点名称">
</div>
</div>
<div class="form-group">
<label for="create_physicalMachineName" class="col-md-2 control-label">物理机名称</label>
<div class="col-md-8">
<input type="text" class="form-control" id="create_physicalMachineName" placeholder="填写vm所属的物理机">
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<a class="btn btn-success" onclick="createIServer()">创建</a>
</div>
</div>
</fieldset>
</form>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="row">
<div class="col-md-12 text-center">
<div class="col-md-12" id="iportal_map" style=" height: 300px;"></div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
$(document).ready(function () {
$("#loginUrl_iManager").val("http://imgr.supermapol.com/imanager");
});
/*登录*/
function loginManager() {
var loginUrl = $("#loginUrl_iManager").val();
if (!checkValue(loginUrl,'请填写服务地址')) {
return;
}
var userName = $('#username_iManager').val();
var password = $('#password_iManager').val();
SuperMap.SecurityManager.loginManager(loginUrl, {userName: userName, password: password});
}
/*登录 end*/
/*获取iServer List*/
function iServerList() {
var url = getIManagerURL();
var iManager = new SuperMap.iManager(url)
.iServerList()
.then(function (response) {
console.log(JSON.stringify(response));
var result = response;
if(result.list){
var html = "";
for(var i = 0 ;i < result.list.length; i++){
var obj = result.list[i];
var address = obj.productInfos? obj.productInfos[0].address : "";
html+="<tr role='row'><td>"+obj.id+"</td><td>"+obj.nodeName+"</td><td><a href='"+address+"' target='_blank'>"+address+"</a></td><td></tr>";
}
$("#nodeList").html(html);
}
});
}
/*获取iServer List end*/
/*启动节点*/
function startNodes() {
var url = getIManagerURL();
var id = $("#start_node_ids").val();
if (!checkValue(id,'请填写id')) {
return;
}
var ids = [id];
var iManager = new SuperMap.iManager(url)
.startNodes(ids)
.then(function (response) {
console.log(JSON.stringify(response));
alert(JSON.stringify(response));
});
}
/*启动节点 end*/
/*停止节点*/
function stopNodes() {
var url = getIManagerURL();
var id = $("#stop_node_ids").val();
if (!checkValue(id,'请填写id')) {
return;
}
var ids = [id];
var iManager = new SuperMap.iManager(url)
.stopNodes(ids)
.then(function (response) {
console.log(JSON.stringify(response));
alert(JSON.stringify(response));
});
}
/*停止节点 end*/
/*创建iServer*/
function createIServer() {
var url = getIManagerURL();
var nodeName = $("#create_nodeName").val();
var physicalMachineName = $("#create_physicalMachineName").val();
if (!checkValue(nodeName,'请填写节点名称')) {
return;
}
if (!checkValue(physicalMachineName,'请填写物理机名称')) {
return;
}
var param = {nodeName:nodeName,physicalMachineName:physicalMachineName};
var iManager = new SuperMap.iManager(url)
.createIServer(param)
.then(function (response) {
console.log(JSON.stringify(response));
alert(JSON.stringify(response));
});
}
/*创建iServer end*/
function getIManagerURL() {
return $("#loginUrl_iManager").val();
}
function checkValue(value,tip) {
if (value === "") {
alert(tip);
return false;
}
return true;
}
</script>
</body>
</html>