nodeGroupManager.vm
6.96 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
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-12">
<h2>节点组管理</h2>
<ol class="breadcrumb">
<li><a>节点管理</a></li>
<li class="active"><b>节点组管理</b></li>
</ol>
</div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-title">
<h3><span class="text-navy">节点组管理</span></h3>
</div>
<div class="ibox-content">
<form method="post" id="form" class="form-horizontal" onsubmit="return false">
<div class="form-group">
<label class="col-sm-1 control-label">节点组</label>
<div class="col-sm-2">
<input type="text" class="form-control" name="nodeGroup"
placeholder="请输入节点组">
</div>
<label class="col-sm-1 control-label">节点类型</label>
<div class="col-sm-2">
<select name="nodeType" class="form-control">
<option value="">所有</option>
<option value="JOB_CLIENT">JOB_CLIENT</option>
<option value="TASK_TRACKER">TASK_TRACKER</option>
</select>
</div>
<div class="col-sm-1" style="margin-left:10px;width:70px;">
<button class="btn btn-primary" type="button" id="searchBtn">
搜索
</button>
</div>
<div class="col-sm-1">
<button class="btn btn-warning" type="button" id="addBtn">
添加
</button>
</div>
</div>
<div class="hr-line-dashed"></div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-content" id="ltstableContainer">
</div>
</div>
</div>
</div>
</div>
<script id="ltstable" type="text/html">
<table class="table table-stripped toggle-arrow-tiny footable" data-page-size="10">
<thead>
<tr>
<th data-toggle="true">节点类型</th>
<th>节点组名</th>
<th>节点组创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{each rows as row index}}
<tr>
<td>{{row.nodeType}}</td>
<td>{{row.name}}</td>
<td>{{row.gmtCreated | dateFormat:'yyyy-MM-dd HH:mm:ss'}}</td>
<td>{{row.opt | format:'optFormat',row}}</td>
</tr>
{{/each}}
{{if results == 0}}
<tr>
<td colspan="4">暂无数据</td>
</tr>
{{/if}}
</tbody>
<tfoot>
<tr>
<td colspan="4">
<span>共{{results}}条记录,每页展示{{pageSize}}条</span>
<ul class="pagination-sm pull-right"></ul>
</td>
</tr>
</tfoot>
</table>
</script>
<script>
$(document).ready(function () {
LTS.colFormatter.optFormat = function (v, row) {
return '<a href="javascript:;" class="node-group-del-btn" nodeGroup="' + row.name + '" nodeType="' + row.nodeType + '">' +
'<span class="label label-primary" style="background-color: #DD6B55;"><i class="fa fa-trash-o"></i> 删除</span></a>';
}
var ltsTable = $("#ltstableContainer").ltsTable({
url: 'api/node/node-group-get',
templateId: 'ltstable'
});
$(document).on("click", "#searchBtn", function () {
var params = {};
$.each($('#form').parent().find(".form-control"), function () {
var name = $(this).attr("name");
var value = $(this).val();
params[name] = value;
});
ltsTable.post(params, 1);
});
$(document).on("click", ".node-group-del-btn", function () {
var nodeGroup = $(this).attr("nodeGroup");
var nodeType = $(this).attr("nodeType");
var _this = $(this);
swal({
title: "确认要删除该节点组吗?",
text: "对应的该节点组的数据也将被删除,请谨慎操作 !",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "确认删除",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
$.ajax({
url: 'api/node/node-group-del',
type: 'POST',
dataType: 'json',
data: {nodeGroup: nodeGroup, nodeType: nodeType},
success: function (json) {
if (json && json.success) {
swal("删除成功!", "恭喜你", "success");
_this.parents("tr").remove();
} else {
json ? swal(json['msg']) : {};
}
}
});
}
});
});
$(document).on("click", "#addBtn", function(){
var nodeGroup = $("input[name='nodeGroup']").val();
var nodeType = $("select[name='nodeType']").val();
if (!nodeGroup) {
sweetAlert("请输入节点组名称", "节点组名称不能为空。", "error");
return;
}
if (!nodeType) {
sweetAlert("请选择节点类型", "节点类型不能为空。", "error");
return;
}
$.ajax({
url: 'api/node/node-group-add',
type: 'POST',
dataType: 'json',
data: {nodeGroup: nodeGroup, nodeType: nodeType},
success: function (json) {
if (json && json.success) {
$("input[name='nodeGroup']").val("");
$("select[name='nodeType']").val("");
$('#searchBtn').trigger("click");
} else {
json ? swal(json['msg']) : {};
}
}
});
});
$("#searchBtn").trigger("click");
});
</script>