sbd-npm 1.4.11 → 1.4.13

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 +44 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -172,7 +172,7 @@ $(function () {
172
172
  }
173
173
  Util.init_table_skeleton({
174
174
  "element_id": "process_div",
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>',
175
+ "caption": prefix_caption + '共 <span class="label label-info" id="process_num"></span> 进程,&nbsp;&nbsp;<input checked type="checkbox" id="is_py_process"> 只显示 Python 进程&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" data-type="1" href="#" class="btn btn-warning btn-xs">添加任务</a></caption>',
176
176
  "head_cols": [
177
177
  {"name": "进程ID", "table_sort": 1},
178
178
  {"name": "进程名", "table_sort": 1},
@@ -189,6 +189,9 @@ $(function () {
189
189
  Util.set_table_loading("process_div_body");
190
190
  Status.handle_process();
191
191
  });
192
+ if (!document.getElementById("client_action_add")) {
193
+ Status.init_worker_modal();
194
+ }
192
195
  }
193
196
  let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
194
197
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_py_process: is_py_process}, function (j) {
@@ -530,11 +533,13 @@ $(function () {
530
533
  hw_html.push('<option value="">Loading...</option>');
531
534
  hw_html.push('</select>');
532
535
  hw_html.push('</div>');
533
- hw_html.push('&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" class="btn btn-warning" id="add_client_action">添加任务</a>');
536
+ hw_html.push('&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" data-type="2" class="btn btn-warning">添加任务</a>');
534
537
  hw_html.push('</form>');
535
538
  hw_html.push('<div id="worker_process_div"></div>');
536
539
  $("#worker_div").html(hw_html.join(""));
537
- Status.init_worker_modal();
540
+ if (!document.getElementById("client_action_add")) {
541
+ Status.init_worker_modal();
542
+ }
538
543
  }
539
544
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, key: $("#workers").val()}, function (j) {
540
545
  if (j["workers"]) {
@@ -596,7 +601,7 @@ $(function () {
596
601
  $("#client_action_modal_title").html("添加任务");
597
602
  let html = [];
598
603
  html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
599
- html.push('<div class="form-group">');
604
+ html.push('<div class="form-group" id="action_worker_div">');
600
605
  html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Worker </label>');
601
606
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
602
607
  html.push('<select id="client_action_worker" class="form-control col-md-7 col-xs-12">');
@@ -607,7 +612,9 @@ $(function () {
607
612
  html.push('<div class="form-group">');
608
613
  html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">任务命令 </label>');
609
614
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
610
- html.push('<input type="text" id="client_action_content" name="client_action_content" placeholder="任务命令" class="form-control col-md-7 col-xs-12">');
615
+ html.push('<select id="client_action_content" class="form-control col-md-7 col-xs-12">');
616
+ html.push('<option value="">任务命令</option>');
617
+ html.push('</select>');
611
618
  html.push('</div>');
612
619
  html.push('</div>');
613
620
  html.push('<div class="form-group">');
@@ -623,13 +630,31 @@ $(function () {
623
630
  let cam_obj = $('#client_action_modal');
624
631
  cam_obj.on('show.bs.modal', function (e) {
625
632
  Util.show_loading();
626
- Util.post(location.pathname, {active_div: "client_action"}, function (j) {
633
+ let action_type = parseInt($(e.relatedTarget).attr("data-type"));
634
+ if (action_type === 1) {
635
+ $("#action_worker_div").css("display", "none");
636
+ } else {
637
+ $("#action_worker_div").css("display", "block");
638
+ }
639
+ Util.post(location.pathname, {active_div: "client_action", action_type: action_type}, function (j) {
627
640
  if (j["workers"]) {
628
- let html = [];
641
+ let worker_html = [];
629
642
  j["workers"].forEach(function (w) {
630
- html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
643
+ worker_html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
631
644
  });
632
- $("#client_action_worker").html(html.join(""));
645
+ let caw_obj = $("#client_action_worker");
646
+ caw_obj.html(worker_html.join(""));
647
+ let worker = $("#workers").val();
648
+ if (worker) {
649
+ caw_obj.find("option[value='" + worker + "']").attr("selected", true);
650
+ }
651
+ }
652
+ if (j["actions"]) {
653
+ let action_html = [];
654
+ j["actions"].forEach(function (action) {
655
+ action_html.push("<option value='", action, "'>", action, "</option>");
656
+ });
657
+ $("#client_action_content").html(action_html.join(""));
633
658
  }
634
659
  Util.hide_tips();
635
660
  });
@@ -640,15 +665,21 @@ $(function () {
640
665
  Util.hide_tips();
641
666
  });
642
667
  $("#client_action_add").click(function() {
643
- let worker_key = $("#client_action_worker").val();
668
+ let action_type = 1, worker_key = "1";
669
+ if ($("#action_worker_div").css("display") === "block") {
670
+ action_type == 2;
671
+ worker_key = $("#client_action_worker").val();
672
+ }
644
673
  if (worker_key) {
645
674
  let action_content = $("#client_action_content").val();
646
675
  if (action_content) {
647
676
  Util.show_loading();
648
677
  $("#client_action_tips").html("");
649
- Util.post(location.pathname, {active_div: "client_action_add", "key": worker_key, "content": action_content}, function (j) {
678
+ $("#client_action_add").attr("disabled", true);
679
+ Util.post(location.pathname, {active_div: "client_action_add", "key": worker_key, "content": action_content, action_type: action_type}, function (j) {
680
+ $("#client_action_add").attr("disabled", false);
650
681
  if (j["code"] && j["code"] === 1) {
651
- $("#client_action_tips").html("<b class='text-success'>添加成功!</b>");
682
+ $("#client_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
652
683
  } else if (j["code"] && j["code"] === 2) {
653
684
  $("#client_action_tips").html("<b class='text-danger'>Worker 不存在!</b>");
654
685
  } else if (j["code"] && j["code"] === 3) {
@@ -664,7 +695,7 @@ $(function () {
664
695
  } else {
665
696
  $("#client_action_tips").html("<b class='text-danger'>Worker 异常!</b>");
666
697
  }
667
- return False;
698
+ return false;
668
699
  });
669
700
  },
670
701