sbd-npm 1.4.7 → 1.4.9

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 +104 -19
  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.7",
3
+ "version": "1.4.9",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -38,6 +38,9 @@ $(function () {
38
38
  case "task":
39
39
  Status.handle_task();
40
40
  break;
41
+ case "worker":
42
+ Status.handle_worker();
43
+ break;
41
44
  case "tool":
42
45
  Status.handle_tool();
43
46
  break;
@@ -161,38 +164,50 @@ $(function () {
161
164
 
162
165
  handle_process: function () {
163
166
  if (!document.getElementById("process_div_body")) {
167
+ let prefix_caption = "";
168
+ if (Util.is_mobile()) {
169
+ prefix_caption = "<caption>&nbsp;&nbsp;&nbsp;";
170
+ } else {
171
+ prefix_caption = '<caption class="text-right">';
172
+ }
164
173
  Util.init_table_skeleton({
165
174
  "element_id": "process_div",
166
- "caption": '<caption class="text-right" id="process_num"></caption>',
175
+ "caption": prefix_caption + '<span class="label label-info" id="process_num"></span> 进程,&nbsp;&nbsp;<input checked type="checkbox" id="is_py_process"> 只显示 Python 进程</caption>',
167
176
  "head_cols": [
168
177
  {"name": "进程ID", "table_sort": 1},
169
178
  {"name": "进程名", "table_sort": 1},
170
179
  {"name": "用户名", "table_sort": 1},
171
180
  {"name": "状态", "table_sort": 1},
172
- {"name": "实际内存", "table_sort": 1, "title": "resident set size"},
181
+ {"name": "实际内存", "class": "info", "table_sort": 1, "title": "resident set size"},
173
182
  {"name": "虚拟内存", "table_sort": 1},
174
183
  {"name": "启动命令"},
175
184
  {"name": "创建时间", "table_sort": 1},
176
185
  ]
177
186
  });
187
+ $("#is_py_process").click(function () {
188
+ Util.show_loading();
189
+ Util.set_table_loading("process_div_body");
190
+ Status.handle_process();
191
+ });
178
192
  }
179
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
180
- let _html = [], process_num = 0;
193
+ let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
194
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_py_process: is_py_process}, function (j) {
195
+ let html = [], process_num = 0;
181
196
  j["data"].forEach(function (item) {
182
197
  process_num++;
183
- _html.push("<tr>");
184
- _html.push("<td>", item["pid"], "</td>");
185
- _html.push("<td>", item["name"], "</td>");
186
- _html.push("<td>", item["username"], "</td>");
187
- _html.push("<td>", item["status"], "</td>");
188
- _html.push("<td data-val='", item["rss"], "'>", Util.trans_byte_size(item["rss"]), "</td>");
189
- _html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
190
- _html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 50), "</td>");
191
- _html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
192
- _html.push("</tr>");
198
+ html.push("<tr>");
199
+ html.push("<td>", item["pid"], "</td>");
200
+ html.push("<td>", item["name"], "</td>");
201
+ html.push("<td>", item["username"], "</td>");
202
+ html.push("<td>", item["status"], "</td>");
203
+ html.push("<td data-val='", item["rss"], "'>", Util.trans_byte_size(item["rss"]), "</td>");
204
+ html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
205
+ html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 60), "</td>");
206
+ html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
207
+ html.push("</tr>");
193
208
  });
194
- $("#process_div_body").html(_html.join(""));
195
- $("#process_num").html("共 <span class='label label-info'>" + process_num + "</span> 进程");
209
+ Util.render_table_html("process_div_body", html);
210
+ $("#process_num").html(process_num);
196
211
  Util.hide_tips();
197
212
  });
198
213
  },
@@ -392,7 +407,7 @@ $(function () {
392
407
 
393
408
  handle_task: function () {
394
409
  if (!document.getElementById("task_content")) {
395
- let ht_html =[];
410
+ let ht_html = [];
396
411
  ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
397
412
  ht_html.push('<div class="form-inline">');
398
413
  ht_html.push('<div class="form-group">');
@@ -425,7 +440,7 @@ $(function () {
425
440
  if ($("#is_refresh_task").prop("checked")) {
426
441
  Status.task_timer_id = setTimeout(function () {
427
442
  Status.fetch_task_data();
428
- }, 3456);
443
+ }, 5678);
429
444
  }
430
445
  } else {
431
446
  Status.task_status = 0;
@@ -471,7 +486,7 @@ $(function () {
471
486
  Status.task_status = 0;
472
487
  ta_obj.html('添加任务').prop('disabled', false).removeClass("btn-warning").addClass("btn-default");
473
488
  tc_obj.prop('disabled', false);
474
- $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` 已经完成!</b>");
489
+ $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` DONE</b>");
475
490
  } else {
476
491
  Status.task_status = 1;
477
492
  ta_obj.html('任务处理中...').prop('disabled', true).removeClass("btn-default").addClass("btn-warning");
@@ -504,6 +519,76 @@ $(function () {
504
519
  });
505
520
  },
506
521
 
522
+ handle_worker: function () {
523
+ let is_init = 0;
524
+ if (!document.getElementById("workers")) {
525
+ is_init = 1;
526
+ let hw_html = [];
527
+ hw_html.push('<form class="form-inline">');
528
+ hw_html.push('<div class="form-group">');
529
+ hw_html.push('<select id="workers" class="form-control">');
530
+ hw_html.push('<option value="">Loading...</option>');
531
+ hw_html.push('</select>');
532
+ hw_html.push('</div>');
533
+ hw_html.push('</form>');
534
+ hw_html.push('<div id="worker_process_div"></div>');
535
+ $("#worker_div").html(hw_html.join(""));
536
+ }
537
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, key: $("#workers").val()}, function (j) {
538
+ if (j["workers"]) {
539
+ let select_html = [];
540
+ select_html.push("<option value=''>共 ", j["workers"].length, " 个Worker</option>");
541
+ j["workers"].forEach(function (w) {
542
+ select_html.push("<option value='", w["key"], "'>", w["ip"], "</option>");
543
+ });
544
+ $("#workers").html(select_html.join(""));
545
+ if (j["workers"].length > 0) {
546
+ $("#workers").change(function() {
547
+ let worker_key = $(this).val();
548
+ if (worker_key) {
549
+ Util.set_table_loading("worker_process_div_body");
550
+ Status.handle_worker();
551
+ }
552
+ });
553
+ }
554
+ } else if (j["process"]) {
555
+ if (!document.getElementById("worker_process_div_body")) {
556
+ let prefix_caption = "";
557
+ if (Util.is_mobile()) {
558
+ prefix_caption = "<caption id='worker_process_tip'>&nbsp;&nbsp;&nbsp;";
559
+ } else {
560
+ prefix_caption = '<caption id="worker_process_tip" class="text-right">';
561
+ }
562
+ Util.init_table_skeleton({
563
+ "element_id": "worker_process_div",
564
+ "caption": prefix_caption + '</caption>',
565
+ "head_cols": [
566
+ {"name": "进程ID", "table_sort": 1},
567
+ {"name": "用户名", "table_sort": 1},
568
+ {"name": "状态", "table_sort": 1},
569
+ {"name": "启动命令"},
570
+ {"name": "创建时间", "class": "info", "table_sort": 1},
571
+ ]
572
+ });
573
+ }
574
+ let html = [], process_num = 0;
575
+ j["process"].forEach(function (item) {
576
+ process_num++;
577
+ html.push("<tr>");
578
+ html.push("<td>", item["pid"], "</td>");
579
+ html.push("<td>", item["username"], "</td>");
580
+ html.push("<td>", item["status"], "</td>");
581
+ html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 60), "</td>");
582
+ html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
583
+ html.push("</tr>");
584
+ });
585
+ Util.render_table_html("worker_process_div_body", html);
586
+ $("#worker_process_tip").html('共 <span class="label label-info">' + process_num + '</span> 进程,最后更新时间:' + Util.seconds_to_format(j["date"]));
587
+ }
588
+ Util.hide_tips();
589
+ });
590
+ },
591
+
507
592
  handle_tool: function () {
508
593
  let t_obj = $("#timestamp");
509
594
  let t_val = t_obj.val();
package/util.js CHANGED
@@ -3271,7 +3271,7 @@ const Util = {
3271
3271
  pack_fund_rating: function (item) {
3272
3272
  if (item["rating"]) {
3273
3273
  let rating = item["rating"];
3274
- if (rating.includes("买入") || rating.includes("增持")) {
3274
+ if (rating.includes("买入") || rating.includes("增持") || rating.includes("推荐")) {
3275
3275
  return "<b class='text-danger'>" + rating + "</b>";
3276
3276
  } else if (rating.includes("卖出") || rating.includes("减持")) {
3277
3277
  return "<b class='text-success'>" + rating + "</b>";