sbd-npm 1.4.5 → 1.4.6

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 +84 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -33,6 +33,9 @@ $(function () {
33
33
  case "environment":
34
34
  Status.handle_environment();
35
35
  break;
36
+ case "task":
37
+ Status.handle_task();
38
+ break;
36
39
  case "tool":
37
40
  Status.handle_tool();
38
41
  break;
@@ -385,6 +388,87 @@ $(function () {
385
388
  });
386
389
  },
387
390
 
391
+ handle_task: function () {
392
+ if (!document.getElementById("task_content")) {
393
+ let ht_html =[];
394
+ ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
395
+ ht_html.push('<div class="form-inline">');
396
+ ht_html.push('<div class="form-group">');
397
+ ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" style="width: 300px;"/>');
398
+ ht_html.push('</div>&nbsp;');
399
+ ht_html.push('<button class="btn btn-default" id="task_add">添加任务</button>');
400
+ ht_html.push('<span id="task_tips"></span>');
401
+ ht_html.push('</div>');
402
+ ht_html.push('<form class="form-horizontal" style="margin-top: 10px;">');
403
+ ht_html.push('<div class="form-group" id="task_result_zone"></div>');
404
+ ht_html.push('</form>');
405
+ ht_html.push('</div>');
406
+ $("#task_div").html(ht_html.join(""));
407
+ $("#task_add").click(function() {
408
+ let task_content = $("#task_content").val();
409
+ if (task_content) {
410
+ $("#task_content").prop('disabled', true);
411
+ $("#task_add").prop('disabled', true);
412
+ Util.show_loading();
413
+ $("#task_tips").html("");
414
+ Util.post(location.pathname, {active_div: "task_add", "task_content": task_content}, function (j) {
415
+ if (j["code"] && j["code"] === 1) {
416
+ $("#task_add").html('任务处理中...');
417
+ if (!document.getElementById("task_result")) {
418
+ $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
419
+ }
420
+ $("#task_result").val("任务 `" + task_content + "` 处理中...");
421
+ } else {
422
+ if (j["code"] && j["code"] === 2) {
423
+ $("#task_tips").html("<b class='text-danger'>已添加新任务在处理中!</b>");
424
+ } else if (j["code"] && j["code"] === 3) {
425
+ $("#task_tips").html("<b class='text-danger'>有任务在执行中!</b>");
426
+ } else {
427
+ $("#task_tips").html("<b class='text-danger'>参数异常!</b>");
428
+ }
429
+ $("#task_content").prop('disabled', false);
430
+ $("#task_add").prop('disabled', false);
431
+ }
432
+ Util.hide_tips();
433
+ });
434
+ } else {
435
+ $("#task_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
436
+ }
437
+ return false;
438
+ });
439
+ }
440
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
441
+ if (j["code"] && j["code"] > 1 && j["content"]) {
442
+ let ta_obj = $("#task_add");
443
+ let tc_obj = $("#task_content");
444
+ tc_obj.val(j["content"]);
445
+ if (j["code"] === 4) {
446
+ ta_obj.html('添加任务');
447
+ ta_obj.prop('disabled', false);
448
+ tc_obj.prop('disabled', false);
449
+ $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` 已经完成!</b>");
450
+ } else {
451
+ ta_obj.html('任务处理中...');
452
+ ta_obj.prop('disabled', true);
453
+ tc_obj.prop('disabled', true);
454
+ }
455
+ if (!document.getElementById("task_result")) {
456
+ $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
457
+ }
458
+ let tr_obj = $("#task_result");
459
+ if (j["result"]) {
460
+ tr_obj.val(j["result"]);
461
+ tr_obj.scrollTop(tr_obj[0].scrollHeight);
462
+ } else {
463
+ if (j["code"] !== 4) {
464
+ tr_obj.val("任务 `" + j["content"] + "` 处理中...");
465
+ }
466
+ }
467
+ }
468
+ Util.hide_tips();
469
+ });
470
+ },
471
+
388
472
  handle_tool: function () {
389
473
  let t_obj = $("#timestamp");
390
474
  let t_val = t_obj.val();