sbd-npm 1.4.10 → 1.4.11

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 (2) hide show
  1. package/package.json +1 -1
  2. package/status.js +85 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -530,16 +530,18 @@ $(function () {
530
530
  hw_html.push('<option value="">Loading...</option>');
531
531
  hw_html.push('</select>');
532
532
  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>');
533
534
  hw_html.push('</form>');
534
535
  hw_html.push('<div id="worker_process_div"></div>');
535
536
  $("#worker_div").html(hw_html.join(""));
537
+ Status.init_worker_modal();
536
538
  }
537
539
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, key: $("#workers").val()}, function (j) {
538
540
  if (j["workers"]) {
539
541
  let select_html = [];
540
542
  select_html.push("<option value=''>共 ", j["workers"].length, " 个Worker</option>");
541
543
  j["workers"].forEach(function (w) {
542
- select_html.push("<option value='", w["key"], "'>", w["ip"], "</option>");
544
+ select_html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
543
545
  });
544
546
  $("#workers").html(select_html.join(""));
545
547
  if (j["workers"].length > 0) {
@@ -583,11 +585,89 @@ $(function () {
583
585
  });
584
586
  Util.render_table_html("worker_process_div_body", html);
585
587
  $("#worker_process_tip").html('共 <span class="label label-info">' + process_num + '</span> 进程,最后更新时间:' + Util.seconds_to_format(j["date"]));
588
+ $("#workers option[value='" + $("#workers").val() + "']").text(j["ip"] + "(" + process_num + ")");
586
589
  }
587
590
  Util.hide_tips();
588
591
  });
589
592
  },
590
593
 
594
+ init_worker_modal: function () {
595
+ Util.init_modal_skeleton("client_action_modal");
596
+ $("#client_action_modal_title").html("添加任务");
597
+ let html = [];
598
+ html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
599
+ html.push('<div class="form-group">');
600
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Worker </label>');
601
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
602
+ html.push('<select id="client_action_worker" class="form-control col-md-7 col-xs-12">');
603
+ html.push('<option value="">Loading...</option>');
604
+ html.push('</select>');
605
+ html.push('</div>');
606
+ html.push('</div>');
607
+ html.push('<div class="form-group">');
608
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">任务命令 </label>');
609
+ 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">');
611
+ html.push('</div>');
612
+ html.push('</div>');
613
+ html.push('<div class="form-group">');
614
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">');
615
+ html.push('<button id="client_action_add" type="button" class="btn btn-success">添 加</button>');
616
+ html.push('<span id="client_action_tips"></span>');
617
+ html.push('</div>');
618
+ html.push('</div>');
619
+ html.push('</form>');
620
+ let camb_obj = $("#client_action_modal_body");
621
+ camb_obj.html(html.join(""));
622
+ camb_obj.parent().parent().removeClass("modal-xlg");
623
+ let cam_obj = $('#client_action_modal');
624
+ cam_obj.on('show.bs.modal', function (e) {
625
+ Util.show_loading();
626
+ Util.post(location.pathname, {active_div: "client_action"}, function (j) {
627
+ if (j["workers"]) {
628
+ let html = [];
629
+ j["workers"].forEach(function (w) {
630
+ html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
631
+ });
632
+ $("#client_action_worker").html(html.join(""));
633
+ }
634
+ Util.hide_tips();
635
+ });
636
+ });
637
+ cam_obj.on('hidden.bs.modal', function () {
638
+ $("#client_action_content").val("");
639
+ $("#client_action_tips").html("");
640
+ Util.hide_tips();
641
+ });
642
+ $("#client_action_add").click(function() {
643
+ let worker_key = $("#client_action_worker").val();
644
+ if (worker_key) {
645
+ let action_content = $("#client_action_content").val();
646
+ if (action_content) {
647
+ Util.show_loading();
648
+ $("#client_action_tips").html("");
649
+ Util.post(location.pathname, {active_div: "client_action_add", "key": worker_key, "content": action_content}, function (j) {
650
+ if (j["code"] && j["code"] === 1) {
651
+ $("#client_action_tips").html("<b class='text-success'>添加成功!</b>");
652
+ } else if (j["code"] && j["code"] === 2) {
653
+ $("#client_action_tips").html("<b class='text-danger'>Worker 不存在!</b>");
654
+ } else if (j["code"] && j["code"] === 3) {
655
+ $("#client_action_tips").html("<b class='text-danger'>任务内容异常!</b>");
656
+ } else {
657
+ $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
658
+ }
659
+ Util.hide_tips();
660
+ });
661
+ } else {
662
+ $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
663
+ }
664
+ } else {
665
+ $("#client_action_tips").html("<b class='text-danger'>Worker 异常!</b>");
666
+ }
667
+ return False;
668
+ });
669
+ },
670
+
591
671
  handle_tool: function () {
592
672
  let t_obj = $("#timestamp");
593
673
  let t_val = t_obj.val();
@@ -748,18 +828,18 @@ $(function () {
748
828
  },
749
829
 
750
830
  handle_site_map: function () {
751
- let _html = [];
831
+ let html = [];
752
832
  $('.side-menu li a').each(function () {
753
833
  let url = $(this).attr("href");
754
834
  if (url) {
755
835
  let title = $(this).text();
756
836
  if (title && title.length > 0) {
757
- _html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
837
+ html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
758
838
  }
759
839
  }
760
840
  });
761
- _html.push('<a href="/xmr" target="_blank" class="btn btn-default">门罗币XMR</a>');
762
- $("#site_map_zone").html(_html.join(""));
841
+ html.push('<a href="/xmr" target="_blank" class="btn btn-default">门罗币XMR</a>');
842
+ $("#site_map_zone").html(html.join(""));
763
843
  Util.hide_tips();
764
844
  },
765
845