sbd-npm 1.4.84 → 1.4.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +97 -38
  3. package/util.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.84",
3
+ "version": "1.4.85",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -79,7 +79,7 @@ $(function () {
79
79
  });
80
80
  mysql_remote_ip = mri_html.join("、");
81
81
  }
82
- html.push("<tr><th>数据库正在连接的IP</th><td colspan='5'>", mysql_remote_ip, "</td></tr>");
82
+ html.push("<tr><th><a data-toggle='modal' data-target='.mysql_access_modal'>数据库正在连接的IP</a></th><td colspan='5'>", mysql_remote_ip, "</td></tr>");
83
83
 
84
84
  let max_files_tips = "系统允许打开的最大文件描述符数量(即每个进程最多能打开多少个文件,包括网络连接、管道、实际文件等)";
85
85
  html.push("<tr><th>最大文件描述符数量 <i class='glyphicon glyphicon-info-sign' data-toggle='tooltip' data-original-title='", max_files_tips, "'></i></th><td>", (j["max_files"] == "None" ? "--" : j["max_files"]), "</td>");
@@ -147,25 +147,8 @@ $(function () {
147
147
  $("#ip_daily_data .block_ip").each(function() {
148
148
  $(this).click(function() {
149
149
  let ip = $(this).parent().parent().children('td').eq(0).text();
150
- let match_ip_data = Util.regexp_match_ip(ip);
151
- if (match_ip_data && match_ip_data[0]) {
152
- ip = match_ip_data[0];
153
- let ip_address = $(this).parent().parent().children('td').eq(1).text().split("-");
154
- ip_address = ip + "[" + ip_address[0].trim() + "]";
155
- if (confirm("是否确定要屏蔽IP “ " + ip_address + " ” ?")) {
156
- Util.show_loading();
157
- Util.post(location.pathname, {"active_div": "block_ip", "ip": ip}, function (j) {
158
- Util.hide_tips();
159
- if (j["code"] === 1) {
160
- Util.show_tips("IP “ " + ip_address + " ” 已加到屏蔽队列中", 4567, "alert-success");
161
- } else if (j["code"] === 2) {
162
- Util.show_tips("IP “ " + ip_address + " ” 已在屏蔽队列中", 4567, "alert-success");
163
- } else {
164
- Util.show_tips("屏蔽IP “ " + ip_address + " ” 失败", 4567, "alert-danger");
165
- }
166
- });
167
- }
168
- }
150
+ let ip_address = $(this).parent().parent().children('td').eq(1).text();
151
+ Status.do_block_ip(ip, ip_address);
169
152
  });
170
153
  });
171
154
  },
@@ -193,6 +176,60 @@ $(function () {
193
176
  });
194
177
  },
195
178
 
179
+ fetch_mysql_access_data: function() {
180
+ Util.show_loading();
181
+ Util.post(location.pathname, {"active_div": "mysql_access"}, function (j) {
182
+ let html = [], ip_num = 0;
183
+ j["data"].forEach(function (item) {
184
+ ip_num++;
185
+ if (item["is_block"] === 1) {
186
+ html.push("<tr class='danger'>");
187
+ } else {
188
+ html.push("<tr>");
189
+ }
190
+ html.push("<td><a href='#' class='block_ip'>", ip_num, "</a></td>");
191
+ html.push("<td>", Util.pack_html_link(Status.ip_url(item["ip"]), item["ip"]), "</td>");
192
+ html.push("<td>", Status.map_url(Status.convert_ip_address(item)), "</td>");
193
+ html.push("<td>", item["times"], "</td>");
194
+ html.push("<td>", Util.seconds_to_format(item["first_time"]), "</td>");
195
+ html.push("<td>", Util.seconds_to_format(item["latest_time"]), "</td>");
196
+ html.push("</tr>");
197
+ });
198
+ Util.render_table_html("mysql_access_modal_body_body", html);
199
+ $("#mysql_access_summary").html("共 <span class='label label-info'>" + ip_num + "</span> 条");
200
+ $("#mysql_access_modal_body_body .block_ip").each(function() {
201
+ $(this).click(function() {
202
+ let ip = $(this).parent().parent().children('td').eq(1).text();
203
+ let ip_address = $(this).parent().parent().children('td').eq(2).text();
204
+ Status.do_block_ip(ip, ip_address);
205
+ });
206
+ });
207
+ Util.hide_tips();
208
+ });
209
+ },
210
+
211
+ do_block_ip: function(ip, ip_address) {
212
+ let match_ip_data = Util.regexp_match_ip(ip);
213
+ if (match_ip_data && match_ip_data[0]) {
214
+ ip = match_ip_data[0];
215
+ ip_address = ip_address.split("-");
216
+ ip_address = ip + "[" + ip_address[0].trim() + "]";
217
+ if (confirm("是否确定要屏蔽IP “ " + ip_address + " ” ?")) {
218
+ Util.show_loading();
219
+ Util.post(location.pathname, {"active_div": "block_ip", "ip": ip}, function (j) {
220
+ Util.hide_tips();
221
+ if (j["code"] === 1) {
222
+ Util.show_tips("IP “ " + ip_address + " ” 已加到屏蔽队列中", 4567, "alert-success");
223
+ } else if (j["code"] === 2) {
224
+ Util.show_tips("IP “ " + ip_address + " ” 已在屏蔽队列中", 4567, "alert-success");
225
+ } else {
226
+ Util.show_tips("屏蔽IP “ " + ip_address + " ” 失败", 4567, "alert-danger");
227
+ }
228
+ });
229
+ }
230
+ }
231
+ },
232
+
196
233
  pack_ip_link: function(ip) {
197
234
  let match_ip_data = Util.regexp_match_ip(ip);
198
235
  if (match_ip_data && match_ip_data[0]) {
@@ -279,17 +316,17 @@ $(function () {
279
316
  if (!document.getElementById("block_ip_div_body")) {
280
317
  Util.init_table_skeleton({
281
318
  "element_id": "block_ip_div",
282
- "caption": '<caption class="text-right" id="ip_num"></caption>',
319
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="block_ip_num"></caption>',
283
320
  "head_cols": [
284
- {"name": "序号"},
285
- {"name": "IP", "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
286
- {"name": "位置"},
321
+ {"name": "序号", "table_sort": 1},
322
+ {"name": "IP", "table_sort": 1, "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
323
+ {"name": "地址信息", "table_sort": 1},
287
324
  ]
288
325
  });
289
326
  }
290
327
  Util.post(location.pathname, {active_div: "get_block_ip"}, function (j) {
291
328
  let html = [], ip_num = j["num"];
292
- $("#ip_num").html("共 <span class='label label-info'>" + ip_num + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
329
+ $("#block_ip_num").html("共 <span class='label label-info'>" + ip_num + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
293
330
  j["data"].forEach(function (item) {
294
331
  html.push("<tr>");
295
332
  html.push("<td>", ip_num, "</td>");
@@ -309,12 +346,12 @@ $(function () {
309
346
  "element_id": "login_log_div",
310
347
  "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="login_log_num"></caption>',
311
348
  "head_cols": [
312
- {"name": "序号"},
349
+ {"name": "序号", "table_sort": 1},
313
350
  {"name": "用户"},
314
351
  {"name": "终端"},
315
- {"name": "登录IP"},
316
- {"name": "IP地址"},
317
- {"name": "时间"},
352
+ {"name": "登录IP", "table_sort": 1},
353
+ {"name": "地址信息", "table_sort": 1},
354
+ {"name": "时间", "table_sort": 1},
318
355
  ]
319
356
  });
320
357
  }
@@ -398,7 +435,7 @@ $(function () {
398
435
  }
399
436
  Util.init_table_skeleton({
400
437
  "element_id": "database_variable_div",
401
- "caption": '<caption class="text-right" id="database_variable_num"></caption>',
438
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="database_variable_num"></caption>',
402
439
  "head_cols": head_cols
403
440
  });
404
441
  }
@@ -463,7 +500,7 @@ $(function () {
463
500
  if (!document.getElementById("environment_div_body")) {
464
501
  Util.init_table_skeleton({
465
502
  "element_id": "environment_div",
466
- "caption": '<caption class="text-right" id="environment_num"></caption>',
503
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="environment_num"></caption>',
467
504
  "head_cols": [
468
505
  {"name": "键"},
469
506
  {"name": "值"},
@@ -503,7 +540,7 @@ $(function () {
503
540
  }
504
541
  Util.init_table_skeleton({
505
542
  "element_id": "sysctl_div",
506
- "caption": '<caption class="text-right" id="sysctl_num"></caption>',
543
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="sysctl_num"></caption>',
507
544
  "head_cols": head_cols
508
545
  });
509
546
  }
@@ -1586,14 +1623,14 @@ $(function () {
1586
1623
  $("#mysql_process_modal_title").html("MySQL正在运行(连接)的线程");
1587
1624
  Util.init_table_skeleton({
1588
1625
  "element_id": "mysql_process_modal_body",
1589
- "caption": '<caption class="text-right" id="mysql_process_summary"></caption>',
1626
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="mysql_process_summary"></caption>',
1590
1627
  "head_cols": [
1591
- {"name": "标识", "tooltip": "Id:线程的唯一标识(线程ID)"},
1592
- {"name": "用户", "tooltip": "User:执行该线程的用户"},
1593
- {"name": "IP:端口号", "tooltip": "Host:发送请求的客户端的IP和端口号"},
1628
+ {"name": "标识", "table_sort": 1, "tooltip": "Id:线程的唯一标识(线程ID)"},
1629
+ {"name": "用户", "table_sort": 1, "tooltip": "User:执行该线程的用户"},
1630
+ {"name": "IP:端口号", "table_sort": 1, "tooltip": "Host:发送请求的客户端的IP和端口号"},
1594
1631
  {"name": "数据库", "tooltip": "db:当前执行的命令使用的数据库"},
1595
- {"name": "正执行的命令", "tooltip": "Command:当前该线程正在执行的命令(Query、Sleep、Connect)"},
1596
- {"name": "状态持续时间", "tooltip": "Time:该线程处于当前状态的持续时间(秒)"},
1632
+ {"name": "正执行的命令", "table_sort": 1, "tooltip": "Command:当前该线程正在执行的命令(Query、Sleep、Connect)"},
1633
+ {"name": "状态持续时间", "table_sort": 1, "tooltip": "Time:该线程处于当前状态的持续时间(秒)"},
1597
1634
  {"name": "线程状态", "tooltip": "State:当前线程的状态描述(Sending data、Locked)"},
1598
1635
  {"name": "执行语句", "tooltip": "Info:线程正在执行的SQL语句"},
1599
1636
  ]
@@ -1606,6 +1643,28 @@ $(function () {
1606
1643
  Util.set_table_loading("mysql_process_modal_body_body");
1607
1644
  });
1608
1645
 
1646
+ Util.init_modal_skeleton("mysql_access_modal");
1647
+ $("#mysql_access_modal_title").html("连接 MySQL 的 IP 日志统计数据");
1648
+ Util.init_table_skeleton({
1649
+ "element_id": "mysql_access_modal_body",
1650
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="mysql_access_summary"></caption>',
1651
+ "head_cols": [
1652
+ {"name": "序号", "table_sort": 1},
1653
+ {"name": "IP", "table_sort": 1, "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
1654
+ {"name": "地址信息", "table_sort": 1},
1655
+ {"name": "连接次数", "table_sort": 1},
1656
+ {"name": "第一次连接时间", "table_sort": 1},
1657
+ {"name": "最后一次连接时间", "class": "info", "table_sort": 1},
1658
+ ]
1659
+ });
1660
+ let mam_obj = $('#mysql_access_modal');
1661
+ mam_obj.on('shown.bs.modal', function (e) {
1662
+ Status.fetch_mysql_access_data();
1663
+ });
1664
+ mam_obj.on('hidden.bs.modal', function () {
1665
+ Util.set_table_loading("mysql_access_modal_body_body");
1666
+ });
1667
+
1609
1668
  let request_arguments = Util.request_arguments();
1610
1669
  if (request_arguments["tab"]) {
1611
1670
  localStorage[Status.tab_token] = request_arguments["tab"];
package/util.js CHANGED
@@ -1564,7 +1564,7 @@ const Util = {
1564
1564
  let issue_date = j["issue_date"] > 0 ? Util.seconds_to_format(j["issue_date"], "%Y-%m-%d") : "--";
1565
1565
  html.push("<tr title='最后更新时间: ", Util.seconds_to_format(j["update_time"], "%Y-%m-%d"), "' class='info'><th colspan='15' style='text-align: center;'>基金概况</th></tr>");
1566
1566
  html.push("<tr><td colspan='3'>基金代码</td><td colspan='4'>", Util.pack_html_link('https://xueqiu.com/S/' + Util.code_to_fund_symbol(j["fund_code"]), j["fund_code"]), "</td><td colspan='3'>基金名</td><td colspan='5'>", Util.pack_html_link('https://fundf10.eastmoney.com/jbgk_' + j["fund_code"] + '.html', j["fund_name"]), "</td></tr>");
1567
- html.push("<tr><td colspan='3'>基金类型</td><td colspan='4'>", j["fund_type"], "</td><td colspan='3'>投资类型</td><td colspan='5'>", j["invest_type"], "</td></tr>");
1567
+ html.push("<tr><td colspan='3'>基金类型</td><td colspan='4'>", (j["fund_type"] ? j["fund_type"] : "--"), "</td><td colspan='3'>投资类型</td><td colspan='5'>", (j["invest_type"] ? j["invest_type"] : "--"), "</td></tr>");
1568
1568
  html.push("<tr><td colspan='3'>单位净值</td><td colspan='4'>", net, "</td><td colspan='3'>资产规模</td><td colspan='5'>", assets, "</td></tr>");
1569
1569
  html.push("<tr><td colspan='3'>成立日期</td><td colspan='4'>", public_date, "</td><td colspan='3'>发行日期</td><td colspan='5'>", issue_date, "</td></tr>");
1570
1570
  html.push("<tr><td colspan='3'>基金管理公司</td><td colspan='4'>", Util.pack_fund_administrator(j), "</td><td colspan='3'>基金经理</td><td colspan='5'>", Util.pack_fund_manager(j), "</td></tr>");