sbd-npm 1.4.9 → 1.4.11
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/status.js +87 -8
- package/util.js +38 -27
package/package.json
CHANGED
package/status.js
CHANGED
@@ -530,22 +530,25 @@ $(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(' <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) {
|
546
548
|
$("#workers").change(function() {
|
547
549
|
let worker_key = $(this).val();
|
548
550
|
if (worker_key) {
|
551
|
+
Util.show_loading();
|
549
552
|
Util.set_table_loading("worker_process_div_body");
|
550
553
|
Status.handle_worker();
|
551
554
|
}
|
@@ -564,7 +567,6 @@ $(function () {
|
|
564
567
|
"caption": prefix_caption + '</caption>',
|
565
568
|
"head_cols": [
|
566
569
|
{"name": "进程ID", "table_sort": 1},
|
567
|
-
{"name": "用户名", "table_sort": 1},
|
568
570
|
{"name": "状态", "table_sort": 1},
|
569
571
|
{"name": "启动命令"},
|
570
572
|
{"name": "创建时间", "class": "info", "table_sort": 1},
|
@@ -576,19 +578,96 @@ $(function () {
|
|
576
578
|
process_num++;
|
577
579
|
html.push("<tr>");
|
578
580
|
html.push("<td>", item["pid"], "</td>");
|
579
|
-
html.push("<td>", item["username"], "</td>");
|
580
581
|
html.push("<td>", item["status"], "</td>");
|
581
|
-
html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"],
|
582
|
+
html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 100), "</td>");
|
582
583
|
html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
|
583
584
|
html.push("</tr>");
|
584
585
|
});
|
585
586
|
Util.render_table_html("worker_process_div_body", html);
|
586
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 + ")");
|
587
589
|
}
|
588
590
|
Util.hide_tips();
|
589
591
|
});
|
590
592
|
},
|
591
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
|
+
|
592
671
|
handle_tool: function () {
|
593
672
|
let t_obj = $("#timestamp");
|
594
673
|
let t_val = t_obj.val();
|
@@ -749,18 +828,18 @@ $(function () {
|
|
749
828
|
},
|
750
829
|
|
751
830
|
handle_site_map: function () {
|
752
|
-
let
|
831
|
+
let html = [];
|
753
832
|
$('.side-menu li a').each(function () {
|
754
833
|
let url = $(this).attr("href");
|
755
834
|
if (url) {
|
756
835
|
let title = $(this).text();
|
757
836
|
if (title && title.length > 0) {
|
758
|
-
|
837
|
+
html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
|
759
838
|
}
|
760
839
|
}
|
761
840
|
});
|
762
|
-
|
763
|
-
$("#site_map_zone").html(
|
841
|
+
html.push('<a href="/xmr" target="_blank" class="btn btn-default">门罗币XMR</a>');
|
842
|
+
$("#site_map_zone").html(html.join(""));
|
764
843
|
Util.hide_tips();
|
765
844
|
},
|
766
845
|
|
package/util.js
CHANGED
@@ -96,40 +96,16 @@ const Util = {
|
|
96
96
|
});
|
97
97
|
|
98
98
|
$('#stock').keyup(function () {
|
99
|
-
let st_obj = $("#search-tips");
|
100
99
|
let key_word = $(this).val();
|
101
100
|
if (key_word) {
|
102
101
|
if (Util.is_has_chinese(key_word) || (Util.is_alpha(key_word) && key_word.length >= 2) || ($.isNumeric(key_word) && key_word.length >= 3)) {
|
103
102
|
Util.hide_tips();
|
104
103
|
clearTimeout(Util.stock_timer_id);
|
105
|
-
|
106
|
-
Util.stock_timer_id = setTimeout(
|
107
|
-
Util.show_loading();
|
108
|
-
Util.post("/action", {action: "search", key_word: key_word}, function (j) {
|
109
|
-
let key_word = $("#stock").val();
|
110
|
-
if (key_word) {
|
111
|
-
let _html = [];
|
112
|
-
_html.push('<div class="list-group">');
|
113
|
-
if (j.data.length > 0) {
|
114
|
-
$.each(j.data, function (index, item) {
|
115
|
-
let upper_code = item["code"].toUpperCase();
|
116
|
-
_html.push('<a target="_blank" rel="noopener noreferrer nofollow" class="list-group-item" href="/stock/', upper_code, '">', (item["name"] ? item["name"] : upper_code), '(', upper_code, ')</a>');
|
117
|
-
});
|
118
|
-
} else {
|
119
|
-
_html.push('<a href="#" class="list-group-item disabled">无数据</a>');
|
120
|
-
}
|
121
|
-
_html.push('</div>');
|
122
|
-
st_obj.html(_html.join(""));
|
123
|
-
st_obj.css("display", "block");
|
124
|
-
} else {
|
125
|
-
st_obj.css("display", "none");
|
126
|
-
}
|
127
|
-
Util.hide_tips();
|
128
|
-
});
|
129
|
-
}, 500);
|
104
|
+
$("#search-tips").css("display", "none");
|
105
|
+
Util.stock_timer_id = setTimeout(Util.request_search, 500);
|
130
106
|
}
|
131
107
|
} else {
|
132
|
-
|
108
|
+
$("#search-tips").css("display", "none");
|
133
109
|
}
|
134
110
|
});
|
135
111
|
|
@@ -175,6 +151,41 @@ const Util = {
|
|
175
151
|
$("#sidebar-menu").html(_html.join(""));
|
176
152
|
},
|
177
153
|
|
154
|
+
/**
|
155
|
+
* 查询请求
|
156
|
+
*/
|
157
|
+
request_search: function() {
|
158
|
+
Util.show_loading();
|
159
|
+
Util.post("/action", {action: "search", key_word: $("#stock").val()}, function (j) {
|
160
|
+
let key_word = $("#stock").val();
|
161
|
+
if (key_word) {
|
162
|
+
if (key_word === j["key_word"]) {
|
163
|
+
let html = [];
|
164
|
+
html.push('<div class="list-group">');
|
165
|
+
if (j["data"] && j["data"].length > 0) {
|
166
|
+
j["data"].forEach(function (item) {
|
167
|
+
let upper_code = item["code"].toUpperCase();
|
168
|
+
html.push('<a target="_blank" rel="noopener noreferrer nofollow" class="list-group-item" href="/stock/', upper_code, '">', (item["name"] ? item["name"] : upper_code), '(', upper_code, ')</a>');
|
169
|
+
});
|
170
|
+
} else {
|
171
|
+
html.push('<a href="#" class="list-group-item disabled">无数据</a>');
|
172
|
+
}
|
173
|
+
html.push('</div>');
|
174
|
+
let st_obj = $("#search-tips");
|
175
|
+
st_obj.html(html.join(""));
|
176
|
+
st_obj.css("display", "block");
|
177
|
+
Util.hide_tips();
|
178
|
+
} else {
|
179
|
+
Util.hide_tips();
|
180
|
+
Util.request_search();
|
181
|
+
}
|
182
|
+
} else {
|
183
|
+
$("#search-tips").css("display", "none");
|
184
|
+
Util.hide_tips();
|
185
|
+
}
|
186
|
+
});
|
187
|
+
},
|
188
|
+
|
178
189
|
/**
|
179
190
|
* 获取链接 URL 地址
|
180
191
|
* @param key
|