home.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var errorTable;
  2. var sites = {};
  3. $.ajaxSettings.async = false;
  4. var jqxhr = $.getJSON("/BIM-Monitor/assets/errorTable.json", function (json) {
  5. errorTable = json;
  6. });
  7. var C3Json = $.getJSON("/BIM-Monitor/assets/json/c3-monitorList.json", function (json) {
  8. sites["c3"] = json;
  9. });
  10. var R03Json = $.getJSON("/BIM-Monitor/assets/json/r03-monitorList.json", function (json) {
  11. sites["r03"] = json;
  12. });
  13. $.ajaxSettings.async = true;
  14. var lastNode;
  15. var errorArray = [];
  16. function GetCheckAllAJAXValue() {
  17. for (i = 0; i < sites["r03"].length; i++) {
  18. var option = sites["r03"][i].code;
  19. $.ajax({
  20. url: "/BIM-Monitor/script/php/get_abnormal.php",
  21. data: {
  22. type: option
  23. },
  24. async: false,
  25. contentType: "application/json",
  26. dataType: "json"
  27. })
  28. .success(function (response) {
  29. var normal_count = response['normal_count'];
  30. var abnormal_count = response['abnormal_count'];
  31. var all_count = 0 + normal_count + abnormal_count;
  32. $(`.${option}`).html("(<font color='#FF0000'>" + abnormal_count + "</font>/" + all_count + ")");
  33. })
  34. .error(function () {
  35. console.log("錯誤統計未正常獲取");
  36. })
  37. .complete(function () {});
  38. }
  39. errorArray = [];
  40. var phase
  41. if (document.getElementById("phase") !== null) {
  42. phase = document.getElementById("phase").value;
  43. } else {
  44. phase = 7;
  45. }
  46. for (i = 0; i < errorTable.length; i++) {
  47. var method = errorTable[i].method;
  48. var option = errorTable[i].table_name;
  49. var table_name = errorTable[i].table_name + "data";
  50. var warning1 = errorTable[i].warning1;
  51. var warning2 = errorTable[i].warning2;
  52. var warning_Count = errorTable[i].warning_Count;
  53. $.ajax({
  54. url: "/BIM-Monitor/script/php/checkValue2.php",
  55. data: {
  56. method: method,
  57. table_name: table_name,
  58. warning1: warning1,
  59. warning2: warning2,
  60. warning_Count: warning_Count,
  61. phase: phase
  62. },
  63. async: false,
  64. contentType: "application/json",
  65. dataType: "json"
  66. })
  67. .success(function (response) {
  68. var normal_count = response['normal_count'];
  69. var abnormal_count = response['abnormal_count'];
  70. var all_count = 0 + normal_count + abnormal_count;
  71. document.getElementById(option).innerHTML = "(<font color='#FF0000'>" + abnormal_count + "</font>/" + all_count + ")";
  72. errorArray.push(abnormal_count);
  73. })
  74. .error(function () {
  75. alert("錯誤統計未正常獲取");
  76. })
  77. .complete(function () {});
  78. }
  79. }
  80. $(document).ready(function () {
  81. $(".monitor").on('click', function () {
  82. let site = $(this).parent().parent().parent().attr("monitor");
  83. location.href = `./${site}/Index.php`;
  84. });
  85. })