diff --git a/static/src/js/app/admin/monitor/monitor.js b/static/src/js/app/admin/monitor/monitor.js index 19e637d6..7c76422d 100644 --- a/static/src/js/app/admin/monitor/monitor.js +++ b/static/src/js/app/admin/monitor/monitor.js @@ -1,54 +1,6 @@ require(["jquery", "chart"], function ($, Chart) { - var data2 = { - labels: ["January", "February", "March", "April", "May", "June", "July", - "January", "February", "March", "April", "January", "February", "March", "April"], - datasets: [ - { - label: "2222222", - fillColor: "rgba(255,255,255,0.2)", - strokeColor: "rgba(151,187,205,1)", - pointColor: "rgba(151,187,205,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(151,187,205,1)", - data: [3, 7, 8, 9, 1, 4, 10, 10, 9, 8, 7, 10, 10, 10, 10] - } - ] - }; - new Chart($("#waiting-queue-chart").get(0).getContext("2d")).Line(data2); - var data = { - labels: ["January", "February", "March", "April", "May", "June", "July", - "January", "February", "March", "April", "January", "February", "March", "April"], - datasets: [ - { - label: "11111111", - fillColor: "rgba(255,255,255,0.2)", - strokeColor: "rgba(250,68,68,1)", - pointColor: "rgba(220,220,220,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(220,220,220,1)", - data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] - }, - { - label: "2222222", - fillColor: "rgba(255,255,255,0.2)", - strokeColor: "rgba(151,187,205,1)", - pointColor: "rgba(151,187,205,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(151,187,205,1)", - data: [3, 7, 8, 9, 1, 4, 10, 10, 9, 8, 7, 10, 10, 10, 10] - } - ] - }; - Chart.defaults.global.responsive = true; - new Chart($("#judge-instance-chart").get(0).getContext("2d")).Line(data); - - var data1 = { - labels: ["January", "February", "March", "April", "May", "June", "July", - "January", "February", "March", "April", "January", "February", "March", "April"], + labels: ["初始化"], datasets: [ { label: "2222222", @@ -58,23 +10,29 @@ require(["jquery", "chart"], function ($, Chart) { pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", - data: [3, 7, 8, 9, 1, 4, 10, 10, 9, 8, 7, 10, 10, 10, 10] - }, - { - label: "2222222", - fillColor: "rgba(255,255,255,0.2)", - strokeColor: "rgba(252,214,48,1)", - pointColor: "rgba(252,214,48,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(151,187,205,1)", - data: [30, 70, 58, 49, 19, 44, 100, 100, 89, 88, 77, 50, 80, 66, 100] + data: [0] } ] }; - Chart.defaults.global.responsive = true; - new Chart($("#c1").get(0).getContext("2d")).Line(data1); + var chart = new Chart($("#waiting-queue-chart").get(0).getContext("2d")).Line(data); + function getMonitorData(){ + $.ajax({ + url: "/api/admin/monitor/", + method: "get", + dataType: "json", + success: function(data){ + if(!data.code){ + chart.addData([data.data["count"]], data.data["time"]) + } + } + }) + } + $("#clear-chart-data").click(function(){ + chart.removeData(); + }); + + setInterval(getMonitorData, 3000); }); \ No newline at end of file diff --git a/template/admin/monitor/monitor.html b/template/admin/monitor/monitor.html index 657586c4..0ccf6df8 100644 --- a/template/admin/monitor/monitor.html +++ b/template/admin/monitor/monitor.html @@ -9,21 +9,7 @@ -
- -

【10.1.24.23 - judge1 】

- -
- -
判题实例数量变化
-
- -
- -
cpu 和 内存
-
-
- + \ No newline at end of file