sbd-npm 1.4.6 → 1.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +64 -23
  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.6",
3
+ "version": "1.4.8",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -3,6 +3,8 @@ $(function () {
3
3
  let Status = {
4
4
 
5
5
  tab_token: "status_nav",
6
+ task_status: 0,
7
+ task_timer_id: 0,
6
8
  data: {},
7
9
 
8
10
  fetch_data: function () {
@@ -161,7 +163,7 @@ $(function () {
161
163
  if (!document.getElementById("process_div_body")) {
162
164
  Util.init_table_skeleton({
163
165
  "element_id": "process_div",
164
- "caption": '<caption class="text-right" id="process_num"></caption>',
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>',
165
167
  "head_cols": [
166
168
  {"name": "进程ID", "table_sort": 1},
167
169
  {"name": "进程名", "table_sort": 1},
@@ -173,24 +175,30 @@ $(function () {
173
175
  {"name": "创建时间", "table_sort": 1},
174
176
  ]
175
177
  });
178
+ $("#is_py_process").click(function () {
179
+ Util.show_loading();
180
+ Util.set_table_loading("process_div_body");
181
+ Status.handle_process();
182
+ });
176
183
  }
177
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
178
- let _html = [], process_num = 0;
184
+ let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
185
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_py_process: is_py_process}, function (j) {
186
+ let html = [], process_num = 0;
179
187
  j["data"].forEach(function (item) {
180
188
  process_num++;
181
- _html.push("<tr>");
182
- _html.push("<td>", item["pid"], "</td>");
183
- _html.push("<td>", item["name"], "</td>");
184
- _html.push("<td>", item["username"], "</td>");
185
- _html.push("<td>", item["status"], "</td>");
186
- _html.push("<td data-val='", item["rss"], "'>", Util.trans_byte_size(item["rss"]), "</td>");
187
- _html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
188
- _html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 50), "</td>");
189
- _html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
190
- _html.push("</tr>");
189
+ html.push("<tr>");
190
+ html.push("<td>", item["pid"], "</td>");
191
+ html.push("<td>", item["name"], "</td>");
192
+ html.push("<td>", item["username"], "</td>");
193
+ html.push("<td>", item["status"], "</td>");
194
+ html.push("<td data-val='", item["rss"], "'>", Util.trans_byte_size(item["rss"]), "</td>");
195
+ html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
196
+ html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 60), "</td>");
197
+ html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
198
+ html.push("</tr>");
191
199
  });
192
- $("#process_div_body").html(_html.join(""));
193
- $("#process_num").html("共 <span class='label label-info'>" + process_num + "</span> 进程");
200
+ $("#process_div_body").html(html.join(""));
201
+ $("#process_num").html(process_num);
194
202
  Util.hide_tips();
195
203
  });
196
204
  },
@@ -394,10 +402,11 @@ $(function () {
394
402
  ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
395
403
  ht_html.push('<div class="form-inline">');
396
404
  ht_html.push('<div class="form-group">');
397
- ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" style="width: 300px;"/>');
405
+ ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" />');
398
406
  ht_html.push('</div>&nbsp;');
399
407
  ht_html.push('<button class="btn btn-default" id="task_add">添加任务</button>');
400
- ht_html.push('<span id="task_tips"></span>');
408
+ ht_html.push('<input type="checkbox" id="is_refresh_task"> 定时刷新数据');
409
+ ht_html.push('&nbsp;<span id="task_tips"></span>');
401
410
  ht_html.push('</div>');
402
411
  ht_html.push('<form class="form-horizontal" style="margin-top: 10px;">');
403
412
  ht_html.push('<div class="form-group" id="task_result_zone"></div>');
@@ -413,12 +422,19 @@ $(function () {
413
422
  $("#task_tips").html("");
414
423
  Util.post(location.pathname, {active_div: "task_add", "task_content": task_content}, function (j) {
415
424
  if (j["code"] && j["code"] === 1) {
416
- $("#task_add").html('任务处理中...');
425
+ Status.task_status = 1;
426
+ $("#task_add").html('任务处理中...').removeClass("btn-default").addClass("btn-warning");
417
427
  if (!document.getElementById("task_result")) {
418
428
  $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
419
429
  }
420
430
  $("#task_result").val("任务 `" + task_content + "` 处理中...");
431
+ if ($("#is_refresh_task").prop("checked")) {
432
+ Status.task_timer_id = setTimeout(function () {
433
+ Status.fetch_task_data();
434
+ }, 5678);
435
+ }
421
436
  } else {
437
+ Status.task_status = 0;
422
438
  if (j["code"] && j["code"] === 2) {
423
439
  $("#task_tips").html("<b class='text-danger'>已添加新任务在处理中!</b>");
424
440
  } else if (j["code"] && j["code"] === 3) {
@@ -436,21 +452,41 @@ $(function () {
436
452
  }
437
453
  return false;
438
454
  });
455
+ $("#is_refresh_task").click(function() {
456
+ if (Status.task_status > 0) {
457
+ clearTimeout(Status.task_timer_id);
458
+ if ($("#is_refresh_task").prop("checked")) {
459
+ Status.fetch_task_data();
460
+ }
461
+ }
462
+ });
439
463
  }
464
+ Status.fetch_task_data();
465
+ },
466
+
467
+ fetch_task_data: function() {
440
468
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
441
469
  if (j["code"] && j["code"] > 1 && j["content"]) {
442
470
  let ta_obj = $("#task_add");
443
471
  let tc_obj = $("#task_content");
444
472
  tc_obj.val(j["content"]);
445
473
  if (j["code"] === 4) {
446
- ta_obj.html('添加任务');
447
- ta_obj.prop('disabled', false);
474
+ if (Status.task_status > 0) {
475
+ clearTimeout(Status.task_timer_id);
476
+ }
477
+ Status.task_status = 0;
478
+ ta_obj.html('添加任务').prop('disabled', false).removeClass("btn-warning").addClass("btn-default");
448
479
  tc_obj.prop('disabled', false);
449
- $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` 已经完成!</b>");
480
+ $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` DONE</b>");
450
481
  } else {
451
- ta_obj.html('任务处理中...');
452
- ta_obj.prop('disabled', true);
482
+ Status.task_status = 1;
483
+ ta_obj.html('任务处理中...').prop('disabled', true).removeClass("btn-default").addClass("btn-warning");
453
484
  tc_obj.prop('disabled', true);
485
+ if ($("#is_refresh_task").prop("checked")) {
486
+ Status.task_timer_id = setTimeout(function () {
487
+ Status.fetch_task_data();
488
+ }, 3456);
489
+ }
454
490
  }
455
491
  if (!document.getElementById("task_result")) {
456
492
  $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
@@ -464,6 +500,11 @@ $(function () {
464
500
  tr_obj.val("任务 `" + j["content"] + "` 处理中...");
465
501
  }
466
502
  }
503
+ } else {
504
+ if (Status.task_status > 0) {
505
+ clearTimeout(Status.task_timer_id);
506
+ }
507
+ Status.task_status = 0;
467
508
  }
468
509
  Util.hide_tips();
469
510
  });
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>";