sbd-npm 1.4.10 → 1.4.12

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 +101 -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.12",
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,105 @@ $(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('<select id="client_action_content" class="form-control col-md-7 col-xs-12">');
611
+ html.push('<option value="">任务命令</option>');
612
+ html.push('</select>');
613
+ html.push('</div>');
614
+ html.push('</div>');
615
+ html.push('<div class="form-group">');
616
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">');
617
+ html.push('<button id="client_action_add" type="button" class="btn btn-success">添 加</button>');
618
+ html.push('<span id="client_action_tips"></span>');
619
+ html.push('</div>');
620
+ html.push('</div>');
621
+ html.push('</form>');
622
+ let camb_obj = $("#client_action_modal_body");
623
+ camb_obj.html(html.join(""));
624
+ camb_obj.parent().parent().removeClass("modal-xlg");
625
+ let cam_obj = $('#client_action_modal');
626
+ cam_obj.on('show.bs.modal', function (e) {
627
+ Util.show_loading();
628
+ Util.post(location.pathname, {active_div: "client_action"}, function (j) {
629
+ if (j["workers"]) {
630
+ let worker_html = [];
631
+ j["workers"].forEach(function (w) {
632
+ worker_html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
633
+ });
634
+ let caw_obj = $("#client_action_worker");
635
+ caw_obj.html(worker_html.join(""));
636
+ let worker = $("#workers").val();
637
+ if (worker) {
638
+ caw_obj.find("option[value='" + worker + "']").attr("selected", true);
639
+ }
640
+ }
641
+ if (j["actions"]) {
642
+ let action_html = [];
643
+ j["actions"].forEach(function (action) {
644
+ action_html.push("<option value='", action, "'>", action, "</option>");
645
+ });
646
+ $("#client_action_content").html(action_html.join(""));
647
+ }
648
+ Util.hide_tips();
649
+ });
650
+ });
651
+ cam_obj.on('hidden.bs.modal', function () {
652
+ $("#client_action_content").val("");
653
+ $("#client_action_tips").html("");
654
+ Util.hide_tips();
655
+ });
656
+ $("#client_action_add").click(function() {
657
+ let worker_key = $("#client_action_worker").val();
658
+ if (worker_key) {
659
+ let action_content = $("#client_action_content").val();
660
+ if (action_content) {
661
+ Util.show_loading();
662
+ $("#client_action_tips").html("");
663
+ $("#client_action_add").attr("disabled", true);
664
+ Util.post(location.pathname, {active_div: "client_action_add", "key": worker_key, "content": action_content}, function (j) {
665
+ $("#client_action_add").attr("disabled", false);
666
+ if (j["code"] && j["code"] === 1) {
667
+ $("#client_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
668
+ } else if (j["code"] && j["code"] === 2) {
669
+ $("#client_action_tips").html("<b class='text-danger'>Worker 不存在!</b>");
670
+ } else if (j["code"] && j["code"] === 3) {
671
+ $("#client_action_tips").html("<b class='text-danger'>任务内容异常!</b>");
672
+ } else {
673
+ $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
674
+ }
675
+ Util.hide_tips();
676
+ });
677
+ } else {
678
+ $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
679
+ }
680
+ } else {
681
+ $("#client_action_tips").html("<b class='text-danger'>Worker 异常!</b>");
682
+ }
683
+ return False;
684
+ });
685
+ },
686
+
591
687
  handle_tool: function () {
592
688
  let t_obj = $("#timestamp");
593
689
  let t_val = t_obj.val();
@@ -748,18 +844,18 @@ $(function () {
748
844
  },
749
845
 
750
846
  handle_site_map: function () {
751
- let _html = [];
847
+ let html = [];
752
848
  $('.side-menu li a').each(function () {
753
849
  let url = $(this).attr("href");
754
850
  if (url) {
755
851
  let title = $(this).text();
756
852
  if (title && title.length > 0) {
757
- _html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
853
+ html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
758
854
  }
759
855
  }
760
856
  });
761
- _html.push('<a href="/xmr" target="_blank" class="btn btn-default">门罗币XMR</a>');
762
- $("#site_map_zone").html(_html.join(""));
857
+ html.push('<a href="/xmr" target="_blank" class="btn btn-default">门罗币XMR</a>');
858
+ $("#site_map_zone").html(html.join(""));
763
859
  Util.hide_tips();
764
860
  },
765
861