degrade.hbs
8.45 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
<style>
.degrade-page {
padding: 20px;
}
.server-in-use,
.connect-err .server-name,
.connect-err .fa {
font-size: 24px;
color: #a94442;
}
.ip-port-modify-btn {
color: #999;
text-decoration: underline;
cursor: pointer;
margin-left: 10px;
}
.degrade-tab li {
cursor: pointer;
}
.pc-degrade,
.wap-degrade {
list-style: none;
padding: 20px;
}
.err-tip {
color: #a94442;
}
.refresh {
float: right;
cursor: pointer;
}
.config-panel .server-port {
width: 100px;
}
.config-panel .form-inline {
padding: 20px 0;
border-bottom: 1px solid #d9edf7;
}
</style>
<div class="degrade-page">
<div class="panel panel-info">
<div class="panel-heading">zookeeper configure</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6 config-panel" data-type="qcloud">
<div class="panel panel-success">
<div class="panel-heading">
腾讯云
<span class="refresh">
<i class="glyphicon glyphicon-refresh"></i>
</span>
</div>
<div class="panel-body">
{{# qCloudConfig}}
<div class="form-inline">
<div class="current-server{{#unless ip}} hide{{/unless}}">
当前server地址:
<span class="server-in-use" data-ip="{{ip}}" data-port="{{port}}">{{ip}}:{{port}}</span>
<span class="ip-port-modify-btn">修改</span>
</div>
<div class="server-editor{{#if ip}} hide{{/if}}">
<div class="form-group">
<label>Server IP</label>
<input class="form-control server-ip" type="text" value="{{ip}}">
</div>
<div class="form-group">
<label for="server-port">Server Port</label>
<input class="form-control server-port" type="text" value="{{port}}">
</div>
<span class="btn btn-default server-sure">保存</span>
</div>
</div>
{{/ qCloudConfig}}
<div class="panel-body list-container">
Waitting for connecting to server...
</div>
</div>
</div>
</div>
{{!-- <div class="col-md-6 config-panel" data-type="aws">
<div class="panel panel-warning">
<div class="panel-heading">
AWS
<span class="refresh">
<i class="glyphicon glyphicon-refresh"></i>
</span>
</div>
<div class="panel-body">
{{# awsConfig}}
<div class="form-inline">
<div class="current-server{{#unless ip}} hide{{/unless}}">
当前server地址:
<span class="server-in-use" data-ip="{{ip}}" data-port="{{port}}">{{ip}}:{{port}}</span>
<span class="ip-port-modify-btn">修改</span>
</div>
<div class="server-editor{{#if ip}} hide{{/if}}">
<div class="form-group">
<label>Server IP</label>
<input class="form-control server-ip" type="text" value="{{ip}}">
</div>
<div class="form-group">
<label>Server Port</label>
<input class="form-control server-port" type="text" value="{{port}}">
</div>
<span class="btn btn-default server-sure">保存</span>
</div>
</div>
{{/ awsConfig}}
<div class="panel-body list-container">
Waitting for connecting to server...
</div>
</div>
</div>
</div> --}}
</div>
</div>
</div>
</div>
<script>
$(function() {
$('.ip-port-modify-btn').click(function() {
var $form = $(this).closest('.form-inline');
$('.server-editor', $form).removeClass('hide');
$('.current-server', $form).addClass('hide');
});
// server
$('.server-sure').click(function() {
var $panel = $(this).closest('.config-panel');
var $ip = $('.server-ip', $panel);
var $port = $('.server-port', $panel);
var ip = $.trim($ip.val());
var port = $.trim($port.val());
$.ajax({
type: 'POST',
url: '/degrade/server',
data: {
ip: ip,
port: port,
type: $panel.data('type')
}
}).then(function(data) {
if (data.code === 200) {
//$.pjax.reload('#pjax-container');
$('.server-editor', $panel).addClass('hide');
$('.current-server', $panel).removeClass('hide');
$('.server-in-use', $panel).text(ip + ':' + port).data('ip', ip).data('port', port);
$('.list-container', $panel).html('waiting for connecting server...');
}
});
});
$('.list-container').on('click', '.degrade-tab li', function() {
var $this = $(this);
var $panel = $this.closest('.config-panel');
if ($this.hasClass('active')) {
return;
}
$this.parent().children('li').toggleClass('active');
var index = $this.index();
if (index === 0) {
//PC active
$('.pc-degrade', $panel).removeClass('hide');
$('.wap-degrade', $panel).addClass('hide');
} else {
// wap active
$('.wap-degrade', $panel).removeClass('hide');
$('.pc-degrade', $panel).addClass('hide');
}
}).on('change', '.degrade-content input[type="checkbox"]', function() {
var $checkbox = $(this),
$li = $checkbox.closest('li');
var checked = $checkbox.prop('checked');
var id = $li.data('id');
$.ajax({
url: '/degrade/setter',
data: {
checked: checked,
id: id,
type: $checkbox.closest('.config-panel').data('type')
}
}).then(function(data) {
if (data.code !== 200) {
$checkbox.prop('checked', !checked);
alert(data.message);
}
});
});
$('.refresh').click(function() {
var $panel = $(this).closest('.config-panel');
$.ajax({
type: 'GET',
url: '/degrade/connect',
data: {
ip: $('.server-in-use', $panel).data('ip'),
port: $('.server-in-use', $panel).data('port')
}
}).then(function(data) {
$('.list-container', $panel).html(data);
});
})
})
</script>