sbd-npm 1.4.59 → 1.4.61
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.
- package/package.json +1 -1
- package/status.js +42 -42
- package/util.js +116 -0
package/package.json
CHANGED
package/status.js
CHANGED
@@ -220,7 +220,7 @@ $(function () {
|
|
220
220
|
}
|
221
221
|
Util.init_table_skeleton({
|
222
222
|
"element_id": "process_div",
|
223
|
-
"caption": prefix_caption + '共 <span class="label label-info" id="process_num"></span> 进程, <input checked type="checkbox" id="is_py_process"> 只显示 Python 进程 <a href="#" data-toggle="modal" data-target=".
|
223
|
+
"caption": prefix_caption + '共 <span class="label label-info" id="process_num"></span> 进程, <input checked type="checkbox" id="is_py_process"> 只显示 Python 进程 <a href="#" data-toggle="modal" data-target=".machine_instruction_modal" data-type="1" href="#" class="btn btn-warning btn-xs">添加任务</a></caption>',
|
224
224
|
"head_cols": [
|
225
225
|
{"name": "进程ID", "table_sort": 1},
|
226
226
|
{"name": "进程名", "table_sort": 1},
|
@@ -237,8 +237,8 @@ $(function () {
|
|
237
237
|
Util.set_table_loading("process_div_body");
|
238
238
|
Status.handle_process();
|
239
239
|
});
|
240
|
-
if (!document.getElementById("
|
241
|
-
Status.
|
240
|
+
if (!document.getElementById("machine_instruction_add")) {
|
241
|
+
Status.init_machine_instruction_modal();
|
242
242
|
}
|
243
243
|
}
|
244
244
|
let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
|
@@ -684,14 +684,14 @@ $(function () {
|
|
684
684
|
machine_html.push('<option value="">Loading...</option>');
|
685
685
|
machine_html.push('</select>');
|
686
686
|
machine_html.push('</div>');
|
687
|
-
machine_html.push(' <a href="#" data-toggle="modal" data-target=".
|
687
|
+
machine_html.push(' <a href="#" data-toggle="modal" data-target=".machine_instruction_modal" data-type="2" class="btn btn-warning">添加任务</a>');
|
688
688
|
machine_html.push('<a href="#" data-toggle="modal" data-target=".machine_cookie_modal" class="btn btn-warning">雪球Cookie</a>');
|
689
689
|
machine_html.push('<a href="#" id="machine_refresh" class="btn btn-warning">刷新Machine</a>');
|
690
690
|
machine_html.push('</form>');
|
691
691
|
machine_html.push('<div id="machine_process_div"></div>');
|
692
692
|
$("#machine_div").html(machine_html.join(""));
|
693
|
-
if (!document.getElementById("
|
694
|
-
Status.
|
693
|
+
if (!document.getElementById("machine_instruction_add")) {
|
694
|
+
Status.init_machine_instruction_modal();
|
695
695
|
Status.init_machine_cookie_modal();
|
696
696
|
$("#machine_refresh").click(function() {
|
697
697
|
if (confirm("是否确定要“ 刷新Machine ” ?")) {
|
@@ -772,8 +772,8 @@ $(function () {
|
|
772
772
|
let pid = $(this).parent().parent().children('td').eq(0).text();
|
773
773
|
if (confirm("是否确定要终止进程 [" + pid + "] ?")) {
|
774
774
|
Util.show_loading();
|
775
|
-
let action_content = "
|
776
|
-
Util.post(location.pathname, {active_div: "
|
775
|
+
let action_content = "kill_pid_" + pid;
|
776
|
+
Util.post(location.pathname, {active_div: "machine_instruction_add", "machine_id": $("#machines").val(), "content": action_content, action_type: 2}, function (j) {
|
777
777
|
Util.hide_tips();
|
778
778
|
if (j["code"] === 1) {
|
779
779
|
Util.show_tips("进程 [" + pid + "] 已加到终止队列中", 4567, "alert-success");
|
@@ -853,22 +853,22 @@ $(function () {
|
|
853
853
|
voices.forEach(voice => {
|
854
854
|
data.push(`Name: ${voice.name}, Lang: ${voice.lang}, Default: ${voice.default}`);
|
855
855
|
});
|
856
|
-
|
856
|
+
Util.showAlert(data.join("\n"));
|
857
857
|
} else {
|
858
|
-
|
858
|
+
Util.showAlert("空列表: []");
|
859
859
|
}
|
860
860
|
Util.is_load = false;
|
861
861
|
},
|
862
862
|
|
863
|
-
|
864
|
-
Util.init_modal_skeleton("
|
865
|
-
$("#
|
863
|
+
init_machine_instruction_modal: function () {
|
864
|
+
Util.init_modal_skeleton("machine_instruction_modal");
|
865
|
+
$("#machine_instruction_modal_title").html("添加任务");
|
866
866
|
let html = [];
|
867
867
|
html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
|
868
868
|
html.push('<div class="form-group" id="action_machine_div">');
|
869
869
|
html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12">Machine </label>');
|
870
870
|
html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
|
871
|
-
html.push('<select id="
|
871
|
+
html.push('<select id="machine_instruction_machine" class="form-control col-md-7 col-xs-12">');
|
872
872
|
html.push('<option value="">Loading...</option>');
|
873
873
|
html.push('</select>');
|
874
874
|
html.push('</div>');
|
@@ -876,22 +876,22 @@ $(function () {
|
|
876
876
|
html.push('<div class="form-group">');
|
877
877
|
html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12">任务命令 </label>');
|
878
878
|
html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
|
879
|
-
html.push('<select id="
|
879
|
+
html.push('<select id="machine_instruction_content" class="form-control col-md-7 col-xs-12">');
|
880
880
|
html.push('<option value="">任务命令</option>');
|
881
881
|
html.push('</select>');
|
882
882
|
html.push('</div>');
|
883
883
|
html.push('</div>');
|
884
884
|
html.push('<div class="form-group">');
|
885
885
|
html.push('<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">');
|
886
|
-
html.push('<button id="
|
887
|
-
html.push('<span id="
|
886
|
+
html.push('<button id="machine_instruction_add" type="button" class="btn btn-success">添 加</button>');
|
887
|
+
html.push('<span id="machine_instruction_tips"></span>');
|
888
888
|
html.push('</div>');
|
889
889
|
html.push('</div>');
|
890
890
|
html.push('</form>');
|
891
|
-
let camb_obj = $("#
|
891
|
+
let camb_obj = $("#machine_instruction_modal_body");
|
892
892
|
camb_obj.html(html.join(""));
|
893
893
|
camb_obj.parent().parent().removeClass("modal-xlg");
|
894
|
-
let cam_obj = $('#
|
894
|
+
let cam_obj = $('#machine_instruction_modal');
|
895
895
|
cam_obj.on('show.bs.modal', function (e) {
|
896
896
|
Util.show_loading();
|
897
897
|
let action_type = parseInt($(e.relatedTarget).attr("data-type"));
|
@@ -900,58 +900,58 @@ $(function () {
|
|
900
900
|
} else {
|
901
901
|
$("#action_machine_div").css("display", "block");
|
902
902
|
}
|
903
|
-
Util.post(location.pathname, {active_div: "
|
903
|
+
Util.post(location.pathname, {active_div: "machine_instruction", action_type: action_type}, function (j) {
|
904
904
|
if (j["machines"]) {
|
905
|
-
Status.pack_machine_component("
|
905
|
+
Status.pack_machine_component("machine_instruction_machine", j["machines"]);
|
906
906
|
let machine = $("#machines").val();
|
907
907
|
if (machine) {
|
908
|
-
$("#
|
908
|
+
$("#machine_instruction_machine").find("option[value='" + machine + "']").attr("selected", true);
|
909
909
|
}
|
910
910
|
}
|
911
|
-
if (j["
|
912
|
-
let
|
913
|
-
j["
|
914
|
-
|
911
|
+
if (j["instructions"]) {
|
912
|
+
let instruction_html = [];
|
913
|
+
j["instructions"].forEach(function (instruction) {
|
914
|
+
instruction_html.push("<option value='", instruction, "'>", instruction, "</option>");
|
915
915
|
});
|
916
|
-
$("#
|
916
|
+
$("#machine_instruction_content").html(instruction_html.join(""));
|
917
917
|
}
|
918
918
|
Util.hide_tips();
|
919
919
|
});
|
920
920
|
});
|
921
921
|
cam_obj.on('hidden.bs.modal', function () {
|
922
|
-
$("#
|
922
|
+
$("#machine_instruction_tips").html("");
|
923
923
|
Util.hide_tips();
|
924
924
|
});
|
925
|
-
$("#
|
925
|
+
$("#machine_instruction_add").click(function() {
|
926
926
|
let action_type = 1, machine_id = "1";
|
927
927
|
if ($("#action_machine_div").css("display") === "block") {
|
928
928
|
action_type = 2;
|
929
|
-
machine_id = $("#
|
929
|
+
machine_id = $("#machine_instruction_machine").val();
|
930
930
|
}
|
931
931
|
if (machine_id) {
|
932
|
-
let action_content = $("#
|
932
|
+
let action_content = $("#machine_instruction_content").val();
|
933
933
|
if (action_content) {
|
934
934
|
Util.show_loading();
|
935
|
-
$("#
|
936
|
-
$("#
|
937
|
-
Util.post(location.pathname, {active_div: "
|
938
|
-
$("#
|
935
|
+
$("#machine_instruction_tips").html("");
|
936
|
+
$("#machine_instruction_add").attr("disabled", true);
|
937
|
+
Util.post(location.pathname, {active_div: "machine_instruction_add", "machine_id": machine_id, "content": action_content, action_type: action_type}, function (j) {
|
938
|
+
$("#machine_instruction_add").attr("disabled", false);
|
939
939
|
if (j["code"] === 1) {
|
940
|
-
$("#
|
940
|
+
$("#machine_instruction_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
|
941
941
|
} else if (j["code"] === 2) {
|
942
|
-
$("#
|
942
|
+
$("#machine_instruction_tips").html("<b class='text-danger'>Machine 不存在!</b>");
|
943
943
|
} else if (j["code"] === 3) {
|
944
|
-
$("#
|
944
|
+
$("#machine_instruction_tips").html("<b class='text-danger'>任务内容异常!</b>");
|
945
945
|
} else {
|
946
|
-
$("#
|
946
|
+
$("#machine_instruction_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
|
947
947
|
}
|
948
948
|
Util.hide_tips();
|
949
949
|
});
|
950
950
|
} else {
|
951
|
-
$("#
|
951
|
+
$("#machine_instruction_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
|
952
952
|
}
|
953
953
|
} else {
|
954
|
-
$("#
|
954
|
+
$("#machine_instruction_tips").html("<b class='text-danger'>Machine 异常!</b>");
|
955
955
|
}
|
956
956
|
return false;
|
957
957
|
});
|
@@ -989,7 +989,7 @@ $(function () {
|
|
989
989
|
let ccm_obj = $('#machine_cookie_modal');
|
990
990
|
ccm_obj.on('show.bs.modal', function (e) {
|
991
991
|
Util.show_loading();
|
992
|
-
Util.post(location.pathname, {active_div: "
|
992
|
+
Util.post(location.pathname, {active_div: "machine_instruction", action_type: 2}, function (j) {
|
993
993
|
if (j["machines"]) {
|
994
994
|
Status.pack_machine_component("machine_cookie_machine", j["machines"]);
|
995
995
|
let machine = $("#machines").val();
|
package/util.js
CHANGED
@@ -4650,6 +4650,122 @@ const Util = {
|
|
4650
4650
|
]
|
4651
4651
|
});
|
4652
4652
|
return chart_instance;
|
4653
|
+
},
|
4654
|
+
|
4655
|
+
/**
|
4656
|
+
* 显示自定义弹窗
|
4657
|
+
* @param {string} message - 要显示的消息内容
|
4658
|
+
* @returns {void}
|
4659
|
+
*/
|
4660
|
+
showAlert: function(message) {
|
4661
|
+
// 创建模态框容器
|
4662
|
+
const modal = document.createElement('div');
|
4663
|
+
modal.style.cssText = `
|
4664
|
+
position: fixed;
|
4665
|
+
top: 0;
|
4666
|
+
left: 0;
|
4667
|
+
width: 100%;
|
4668
|
+
height: 100%;
|
4669
|
+
background-color: rgba(0, 0, 0, 0.5);
|
4670
|
+
display: flex;
|
4671
|
+
justify-content: center;
|
4672
|
+
align-items: center;
|
4673
|
+
z-index: 9999;
|
4674
|
+
`;
|
4675
|
+
// 创建模态框内容
|
4676
|
+
const modalContent = document.createElement('div');
|
4677
|
+
modalContent.style.cssText = `
|
4678
|
+
background-color: white;
|
4679
|
+
padding: 20px;
|
4680
|
+
border-radius: 5px;
|
4681
|
+
max-width: 80%;
|
4682
|
+
max-height: 80%;
|
4683
|
+
overflow: auto;
|
4684
|
+
position: relative;
|
4685
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
4686
|
+
display: flex;
|
4687
|
+
flex-direction: column;
|
4688
|
+
align-items: center;
|
4689
|
+
`;
|
4690
|
+
// 创建消息内容
|
4691
|
+
const messageElement = document.createElement('div');
|
4692
|
+
messageElement.style.cssText = `
|
4693
|
+
margin-bottom: 20px;
|
4694
|
+
word-break: break-all;
|
4695
|
+
padding: 10px;
|
4696
|
+
border: 1px solid #ddd;
|
4697
|
+
background-color: #f9f9f9;
|
4698
|
+
width: 100%;
|
4699
|
+
box-sizing: border-box;
|
4700
|
+
`;
|
4701
|
+
messageElement.innerHTML = message.replace(/\n/g, '<br>');
|
4702
|
+
// 创建按钮容器
|
4703
|
+
const buttonContainer = document.createElement('div');
|
4704
|
+
buttonContainer.style.cssText = `
|
4705
|
+
display: flex;
|
4706
|
+
gap: 10px;
|
4707
|
+
margin-top: 10px;
|
4708
|
+
`;
|
4709
|
+
// 创建复制按钮
|
4710
|
+
const copyButton = document.createElement('button');
|
4711
|
+
copyButton.textContent = '复制';
|
4712
|
+
copyButton.style.cssText = `
|
4713
|
+
padding: 8px 20px;
|
4714
|
+
background-color: #4CAF50;
|
4715
|
+
color: white;
|
4716
|
+
border: none;
|
4717
|
+
border-radius: 3px;
|
4718
|
+
cursor: pointer;
|
4719
|
+
font-size: 14px;
|
4720
|
+
`;
|
4721
|
+
copyButton.addEventListener('click', function() {
|
4722
|
+
navigator.clipboard.writeText(message).then(
|
4723
|
+
function() {
|
4724
|
+
// 复制成功,临时改变按钮文字
|
4725
|
+
const originalText = copyButton.textContent;
|
4726
|
+
copyButton.textContent = '已复制';
|
4727
|
+
copyButton.style.backgroundColor = '#45a049';
|
4728
|
+
setTimeout(function() {
|
4729
|
+
copyButton.textContent = originalText;
|
4730
|
+
copyButton.style.backgroundColor = '#4CAF50';
|
4731
|
+
}, 2000);
|
4732
|
+
},
|
4733
|
+
function() {
|
4734
|
+
// 复制失败
|
4735
|
+
alert('复制失败,请重试');
|
4736
|
+
}
|
4737
|
+
);
|
4738
|
+
});
|
4739
|
+
// 创建关闭按钮
|
4740
|
+
const closeButton = document.createElement('button');
|
4741
|
+
closeButton.textContent = '关闭';
|
4742
|
+
closeButton.style.cssText = `
|
4743
|
+
padding: 8px 20px;
|
4744
|
+
background-color: #f44336;
|
4745
|
+
color: white;
|
4746
|
+
border: none;
|
4747
|
+
border-radius: 3px;
|
4748
|
+
cursor: pointer;
|
4749
|
+
font-size: 14px;
|
4750
|
+
`;
|
4751
|
+
closeButton.addEventListener('click', function() {
|
4752
|
+
document.body.removeChild(modal);
|
4753
|
+
});
|
4754
|
+
// 组装按钮容器
|
4755
|
+
buttonContainer.appendChild(copyButton);
|
4756
|
+
buttonContainer.appendChild(closeButton);
|
4757
|
+
// 组装模态框
|
4758
|
+
modalContent.appendChild(messageElement);
|
4759
|
+
modalContent.appendChild(buttonContainer);
|
4760
|
+
modal.appendChild(modalContent);
|
4761
|
+
// 添加到页面
|
4762
|
+
document.body.appendChild(modal);
|
4763
|
+
// 点击模态框背景也可以关闭
|
4764
|
+
modal.addEventListener('click', function(event) {
|
4765
|
+
if (event.target === modal) {
|
4766
|
+
document.body.removeChild(modal);
|
4767
|
+
}
|
4768
|
+
});
|
4653
4769
|
}
|
4654
4770
|
|
4655
4771
|
};
|