sbd-npm 1.5.40 → 1.5.41

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 +46 -14
  3. package/util.js +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.5.40",
3
+ "version": "1.5.41",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -849,13 +849,40 @@ $(function () {
849
849
  {"name": "物理内存", "table_sort": 1, "title": "Resident Set Size(常驻内存,进程实际占用的物理内存)"},
850
850
  {"name": "启动命令"},
851
851
  {"name": "创建时间", "class": "info", "table_sort": 1},
852
- {"name": "操作", "id": "machine_action", "link": "#"}
852
+ {"name": "操作", "id": "machine_action_log", "link": "#", "title": "操作日志记录"}
853
853
  ]
854
854
  });
855
+ $("#machine_action_log").click(function() {
856
+ let machine_id = $("#machines").val();
857
+ if (machine_id) {
858
+ let instruction = "screen_1_machine_action_log";
859
+ Util.post(location.pathname, {action: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": 2}, function (j) {
860
+ Util.hide_tips();
861
+ if (j.code === 1) {
862
+ Status.reset_screen_status("machine_process_div_body");
863
+ $("#machine_action_log").html("<a href='#'><span title='日志记录获取中...' class='label label-info'>操作</span></a>");
864
+ Util.show_tips("[获取操作日志记录] 已加到会话队列中", 4567, "alert-success");
865
+ } else if (j.code === 2) {
866
+ Util.show_tips("Machine 不存在!", 4567, "alert-danger");
867
+ } else {
868
+ Util.show_tips("[获取操作日志记录] 异常!", 4567, "alert-danger");
869
+ }
870
+ });
871
+ }
872
+ });
855
873
  }
856
874
  let html = [], process_num = 0;
857
875
  let screen_pid = j.screen_pid ? j.screen_pid : 0;
858
876
  let screen_pid_date = j.screen_pid_date ? j.screen_pid_date : 0;
877
+ if (screen_pid === 1) {
878
+ if (screen_pid_date > 0) {
879
+ $("#machine_action_log").html("<a href='#'><span title='日志记录已成功获取(" + Util.seconds_to_format(screen_pid_date) + ")' class='label label-success'>操作</span></a>");
880
+ } else {
881
+ $("#machine_action_log").html("<a href='#'><span title='日志记录获取中...' class='label label-info'>操作</span></a>");
882
+ }
883
+ } else {
884
+ $("#machine_action_log").html("<a href='#'>操作</a>");
885
+ }
859
886
  j.process.forEach(function (item) {
860
887
  process_num++;
861
888
  let is_xmr = 0, is_screen = 0;
@@ -984,19 +1011,8 @@ $(function () {
984
1011
  Util.post(location.pathname, {action: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": action_type}, function (j) {
985
1012
  Util.hide_tips();
986
1013
  if (j.code === 1) {
987
- $("#" + element_id + " a").each(function() {
988
- let span_object = $(this).find('span.label.label-info');
989
- if (span_object.length) {
990
- var span_text = span_object.text();
991
- span_object.remove();
992
- $(this).append(span_text);
993
- } else {
994
- let is_fetch_screen = $(this).attr("data-screen");
995
- if (is_fetch_screen && is_fetch_screen == "1") {
996
- $(this).text('会话').removeAttr('data-screen');
997
- }
998
- }
999
- });
1014
+ $("#machine_action_log").html("<a href='#'>操作</a>");
1015
+ Status.reset_screen_status(element_id);
1000
1016
  this_object.html("<span title='会话数据获取中...' class='label label-info'>会话</span>");
1001
1017
  Util.show_tips("进程 [" + pid + "(" + action + ")] 已加到会话队列中", 4567, "alert-success");
1002
1018
  } else if (j.code === 2) {
@@ -1013,6 +1029,22 @@ $(function () {
1013
1029
  });
1014
1030
  },
1015
1031
 
1032
+ reset_screen_status: function(element_id) {
1033
+ $("#" + element_id + " a").each(function() {
1034
+ let span_object = $(this).find('span.label.label-info');
1035
+ if (span_object.length) {
1036
+ let span_text = span_object.text();
1037
+ span_object.remove();
1038
+ $(this).append(span_text);
1039
+ } else {
1040
+ let is_fetch_screen = $(this).attr("data-screen");
1041
+ if (is_fetch_screen && is_fetch_screen == "1") {
1042
+ $(this).text('会话').removeAttr('data-screen');
1043
+ }
1044
+ }
1045
+ });
1046
+ },
1047
+
1016
1048
  pack_screen_html: function(is_screen, pid, screen_pid, screen_pid_date, cmdline) {
1017
1049
  if (is_screen === 1) {
1018
1050
  let screen_html = "";
package/util.js CHANGED
@@ -2894,9 +2894,10 @@ const Util = {
2894
2894
  },
2895
2895
 
2896
2896
  uuid: function () {
2897
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2898
- var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
2899
- return v.toString(16);
2897
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
2898
+ let randomHexDigit = Math.random() * 16 | 0;
2899
+ let digit = char == 'x' ? randomHexDigit : (randomHexDigit & 0x3 | 0x8);
2900
+ return digit.toString(16);
2900
2901
  });
2901
2902
  },
2902
2903