sbd-npm 1.4.6 → 1.4.7

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 +42 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -3,6 +3,8 @@ $(function () {
3
3
  let Status = {
4
4
 
5
5
  tab_token: "status_nav",
6
+ task_status: 0,
7
+ task_timer_id: 0,
6
8
  data: {},
7
9
 
8
10
  fetch_data: function () {
@@ -394,10 +396,11 @@ $(function () {
394
396
  ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
395
397
  ht_html.push('<div class="form-inline">');
396
398
  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;"/>');
399
+ ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" />');
398
400
  ht_html.push('</div>&nbsp;');
399
401
  ht_html.push('<button class="btn btn-default" id="task_add">添加任务</button>');
400
- ht_html.push('<span id="task_tips"></span>');
402
+ ht_html.push('<input type="checkbox" id="is_refresh_task"> 定时刷新数据');
403
+ ht_html.push('&nbsp;<span id="task_tips"></span>');
401
404
  ht_html.push('</div>');
402
405
  ht_html.push('<form class="form-horizontal" style="margin-top: 10px;">');
403
406
  ht_html.push('<div class="form-group" id="task_result_zone"></div>');
@@ -413,12 +416,19 @@ $(function () {
413
416
  $("#task_tips").html("");
414
417
  Util.post(location.pathname, {active_div: "task_add", "task_content": task_content}, function (j) {
415
418
  if (j["code"] && j["code"] === 1) {
416
- $("#task_add").html('任务处理中...');
419
+ Status.task_status = 1;
420
+ $("#task_add").html('任务处理中...').removeClass("btn-default").addClass("btn-warning");
417
421
  if (!document.getElementById("task_result")) {
418
422
  $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
419
423
  }
420
424
  $("#task_result").val("任务 `" + task_content + "` 处理中...");
425
+ if ($("#is_refresh_task").prop("checked")) {
426
+ Status.task_timer_id = setTimeout(function () {
427
+ Status.fetch_task_data();
428
+ }, 3456);
429
+ }
421
430
  } else {
431
+ Status.task_status = 0;
422
432
  if (j["code"] && j["code"] === 2) {
423
433
  $("#task_tips").html("<b class='text-danger'>已添加新任务在处理中!</b>");
424
434
  } else if (j["code"] && j["code"] === 3) {
@@ -436,21 +446,41 @@ $(function () {
436
446
  }
437
447
  return false;
438
448
  });
449
+ $("#is_refresh_task").click(function() {
450
+ if (Status.task_status > 0) {
451
+ clearTimeout(Status.task_timer_id);
452
+ if ($("#is_refresh_task").prop("checked")) {
453
+ Status.fetch_task_data();
454
+ }
455
+ }
456
+ });
439
457
  }
458
+ Status.fetch_task_data();
459
+ },
460
+
461
+ fetch_task_data: function() {
440
462
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
441
463
  if (j["code"] && j["code"] > 1 && j["content"]) {
442
464
  let ta_obj = $("#task_add");
443
465
  let tc_obj = $("#task_content");
444
466
  tc_obj.val(j["content"]);
445
467
  if (j["code"] === 4) {
446
- ta_obj.html('添加任务');
447
- ta_obj.prop('disabled', false);
468
+ if (Status.task_status > 0) {
469
+ clearTimeout(Status.task_timer_id);
470
+ }
471
+ Status.task_status = 0;
472
+ ta_obj.html('添加任务').prop('disabled', false).removeClass("btn-warning").addClass("btn-default");
448
473
  tc_obj.prop('disabled', false);
449
474
  $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` 已经完成!</b>");
450
475
  } else {
451
- ta_obj.html('任务处理中...');
452
- ta_obj.prop('disabled', true);
476
+ Status.task_status = 1;
477
+ ta_obj.html('任务处理中...').prop('disabled', true).removeClass("btn-default").addClass("btn-warning");
453
478
  tc_obj.prop('disabled', true);
479
+ if ($("#is_refresh_task").prop("checked")) {
480
+ Status.task_timer_id = setTimeout(function () {
481
+ Status.fetch_task_data();
482
+ }, 3456);
483
+ }
454
484
  }
455
485
  if (!document.getElementById("task_result")) {
456
486
  $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
@@ -464,6 +494,11 @@ $(function () {
464
494
  tr_obj.val("任务 `" + j["content"] + "` 处理中...");
465
495
  }
466
496
  }
497
+ } else {
498
+ if (Status.task_status > 0) {
499
+ clearTimeout(Status.task_timer_id);
500
+ }
501
+ Status.task_status = 0;
467
502
  }
468
503
  Util.hide_tips();
469
504
  });