sbd-npm 1.4.84 → 1.4.86

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 +103 -42
  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.86",
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
  },
@@ -188,11 +171,67 @@ $(function () {
188
171
  html.push("</tr>");
189
172
  });
190
173
  Util.render_table_html("mysql_process_modal_body_body", html);
191
- $("#mysql_process_summary").html(" <span class='label label-info'>" + current_connections + "</span> 条");
174
+ $("#mysql_process_summary").html("&nbsp;&nbsp;共 <span class='label label-info'>" + current_connections + "</span> 条");
192
175
  Util.hide_tips();
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("&nbsp;&nbsp;共 <span class='label label-info'>" + ip_num + "</span> 条,屏蔽 <span class='label label-danger'>" + j["block_len"] + "</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
+ } else {
231
+ Util.show_tips("IP值异常:" + ip, 4567, "alert-danger");
232
+ }
233
+ },
234
+
196
235
  pack_ip_link: function(ip) {
197
236
  let match_ip_data = Util.regexp_match_ip(ip);
198
237
  if (match_ip_data && match_ip_data[0]) {
@@ -279,17 +318,17 @@ $(function () {
279
318
  if (!document.getElementById("block_ip_div_body")) {
280
319
  Util.init_table_skeleton({
281
320
  "element_id": "block_ip_div",
282
- "caption": '<caption class="text-right" id="ip_num"></caption>',
321
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="block_ip_num"></caption>',
283
322
  "head_cols": [
284
- {"name": "序号"},
285
- {"name": "IP", "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
286
- {"name": "位置"},
323
+ {"name": "序号", "table_sort": 1},
324
+ {"name": "IP", "table_sort": 1, "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
325
+ {"name": "地址信息", "table_sort": 1},
287
326
  ]
288
327
  });
289
328
  }
290
329
  Util.post(location.pathname, {active_div: "get_block_ip"}, function (j) {
291
330
  let html = [], ip_num = j["num"];
292
- $("#ip_num").html(" <span class='label label-info'>" + ip_num + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
331
+ $("#block_ip_num").html("&nbsp;&nbsp;共 <span class='label label-info'>" + ip_num + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
293
332
  j["data"].forEach(function (item) {
294
333
  html.push("<tr>");
295
334
  html.push("<td>", ip_num, "</td>");
@@ -309,12 +348,12 @@ $(function () {
309
348
  "element_id": "login_log_div",
310
349
  "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="login_log_num"></caption>',
311
350
  "head_cols": [
312
- {"name": "序号"},
351
+ {"name": "序号", "table_sort": 1},
313
352
  {"name": "用户"},
314
353
  {"name": "终端"},
315
- {"name": "登录IP"},
316
- {"name": "IP地址"},
317
- {"name": "时间"},
354
+ {"name": "登录IP", "table_sort": 1},
355
+ {"name": "地址信息", "table_sort": 1},
356
+ {"name": "时间", "table_sort": 1},
318
357
  ]
319
358
  });
320
359
  }
@@ -398,7 +437,7 @@ $(function () {
398
437
  }
399
438
  Util.init_table_skeleton({
400
439
  "element_id": "database_variable_div",
401
- "caption": '<caption class="text-right" id="database_variable_num"></caption>',
440
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="database_variable_num"></caption>',
402
441
  "head_cols": head_cols
403
442
  });
404
443
  }
@@ -420,7 +459,7 @@ $(function () {
420
459
  html.push("</tr>");
421
460
  });
422
461
  Util.render_table_html("database_variable_div_body", html);
423
- $("#database_variable_num").html(" <span class='label label-info'>" + database_variable_num + "</span> 条&nbsp;&nbsp;");
462
+ $("#database_variable_num").html("&nbsp;&nbsp;共 <span class='label label-info'>" + database_variable_num + "</span> 条&nbsp;&nbsp;");
424
463
  Util.hide_tips();
425
464
  });
426
465
  },
@@ -463,7 +502,7 @@ $(function () {
463
502
  if (!document.getElementById("environment_div_body")) {
464
503
  Util.init_table_skeleton({
465
504
  "element_id": "environment_div",
466
- "caption": '<caption class="text-right" id="environment_num"></caption>',
505
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="environment_num"></caption>',
467
506
  "head_cols": [
468
507
  {"name": "键"},
469
508
  {"name": "值"},
@@ -480,7 +519,7 @@ $(function () {
480
519
  html.push("</tr>");
481
520
  });
482
521
  Util.render_table_html("environment_div_body", html);
483
- $("#environment_num").html(" <span class='label label-info'>" + environment_num + "</span> 条&nbsp;&nbsp;");
522
+ $("#environment_num").html("&nbsp;&nbsp;共 <span class='label label-info'>" + environment_num + "</span> 条&nbsp;&nbsp;");
484
523
  Util.hide_tips();
485
524
  });
486
525
  },
@@ -503,7 +542,7 @@ $(function () {
503
542
  }
504
543
  Util.init_table_skeleton({
505
544
  "element_id": "sysctl_div",
506
- "caption": '<caption class="text-right" id="sysctl_num"></caption>',
545
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="sysctl_num"></caption>',
507
546
  "head_cols": head_cols
508
547
  });
509
548
  }
@@ -522,7 +561,7 @@ $(function () {
522
561
  html.push("</tr>");
523
562
  });
524
563
  Util.render_table_html("sysctl_div_body", html);
525
- $("#sysctl_num").html(" <span class='label label-info'>" + sysctl_num + "</span> 条&nbsp;&nbsp;");
564
+ $("#sysctl_num").html("&nbsp;&nbsp;共 <span class='label label-info'>" + sysctl_num + "</span> 条&nbsp;&nbsp;");
526
565
  Util.hide_tips();
527
566
  });
528
567
  },
@@ -1586,14 +1625,14 @@ $(function () {
1586
1625
  $("#mysql_process_modal_title").html("MySQL正在运行(连接)的线程");
1587
1626
  Util.init_table_skeleton({
1588
1627
  "element_id": "mysql_process_modal_body",
1589
- "caption": '<caption class="text-right" id="mysql_process_summary"></caption>',
1628
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="mysql_process_summary"></caption>',
1590
1629
  "head_cols": [
1591
- {"name": "标识", "tooltip": "Id:线程的唯一标识(线程ID)"},
1592
- {"name": "用户", "tooltip": "User:执行该线程的用户"},
1593
- {"name": "IP:端口号", "tooltip": "Host:发送请求的客户端的IP和端口号"},
1630
+ {"name": "标识", "table_sort": 1, "tooltip": "Id:线程的唯一标识(线程ID)"},
1631
+ {"name": "用户", "table_sort": 1, "tooltip": "User:执行该线程的用户"},
1632
+ {"name": "IP:端口号", "table_sort": 1, "tooltip": "Host:发送请求的客户端的IP和端口号"},
1594
1633
  {"name": "数据库", "tooltip": "db:当前执行的命令使用的数据库"},
1595
- {"name": "正执行的命令", "tooltip": "Command:当前该线程正在执行的命令(Query、Sleep、Connect)"},
1596
- {"name": "状态持续时间", "tooltip": "Time:该线程处于当前状态的持续时间(秒)"},
1634
+ {"name": "正执行的命令", "table_sort": 1, "tooltip": "Command:当前该线程正在执行的命令(Query、Sleep、Connect)"},
1635
+ {"name": "状态持续时间", "table_sort": 1, "tooltip": "Time:该线程处于当前状态的持续时间(秒)"},
1597
1636
  {"name": "线程状态", "tooltip": "State:当前线程的状态描述(Sending data、Locked)"},
1598
1637
  {"name": "执行语句", "tooltip": "Info:线程正在执行的SQL语句"},
1599
1638
  ]
@@ -1606,6 +1645,28 @@ $(function () {
1606
1645
  Util.set_table_loading("mysql_process_modal_body_body");
1607
1646
  });
1608
1647
 
1648
+ Util.init_modal_skeleton("mysql_access_modal");
1649
+ $("#mysql_access_modal_title").html("连接 MySQL 的 IP 日志统计数据");
1650
+ Util.init_table_skeleton({
1651
+ "element_id": "mysql_access_modal_body",
1652
+ "caption": '<caption class="' + (Util.is_mobile() ? "text-left" : "text-right") + '" id="mysql_access_summary"></caption>',
1653
+ "head_cols": [
1654
+ {"name": "序号", "table_sort": 1},
1655
+ {"name": "IP", "table_sort": 1, "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
1656
+ {"name": "地址信息", "table_sort": 1},
1657
+ {"name": "连接次数", "table_sort": 1},
1658
+ {"name": "第一次连接时间", "table_sort": 1},
1659
+ {"name": "最后一次连接时间", "class": "info", "table_sort": 1},
1660
+ ]
1661
+ });
1662
+ let mam_obj = $('#mysql_access_modal');
1663
+ mam_obj.on('shown.bs.modal', function (e) {
1664
+ Status.fetch_mysql_access_data();
1665
+ });
1666
+ mam_obj.on('hidden.bs.modal', function () {
1667
+ Util.set_table_loading("mysql_access_modal_body_body");
1668
+ });
1669
+
1609
1670
  let request_arguments = Util.request_arguments();
1610
1671
  if (request_arguments["tab"]) {
1611
1672
  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>");