sbd-npm 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/status.js +83 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.8",
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,15 +164,21 @@ $(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">共 <span class="label label-info" id="process_num"></span> 进程,<input checked type="checkbox" id="is_py_process"> 只显示Python进程</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},
@@ -197,7 +206,7 @@ $(function () {
197
206
  html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
198
207
  html.push("</tr>");
199
208
  });
200
- $("#process_div_body").html(html.join(""));
209
+ Util.render_table_html("process_div_body", html);
201
210
  $("#process_num").html(process_num);
202
211
  Util.hide_tips();
203
212
  });
@@ -398,7 +407,7 @@ $(function () {
398
407
 
399
408
  handle_task: function () {
400
409
  if (!document.getElementById("task_content")) {
401
- let ht_html =[];
410
+ let ht_html = [];
402
411
  ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
403
412
  ht_html.push('<div class="form-inline">');
404
413
  ht_html.push('<div class="form-group">');
@@ -510,6 +519,76 @@ $(function () {
510
519
  });
511
520
  },
512
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
+
513
592
  handle_tool: function () {
514
593
  let t_obj = $("#timestamp");
515
594
  let t_val = t_obj.val();