Просмотр исходного кода

生成图表方法支持参数选择

James Iter 9 лет назад
Родитель
Сommit
500f96312f
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      templates/guest_detail.html

+ 14 - 3
templates/guest_detail.html

@@ -50,9 +50,20 @@
         }
     }
 
-    function render_cpu_memory_chart(uuid) {
+    function render_cpu_memory_chart(uuid, granularity) {
+        var url = '/api/performance/cpu_memory/last_hour/' + uuid;
+        if (granularity === 'hour') {
+            url = '/api/performance/cpu_memory/last_hour/' + uuid
+        } else if (granularity === 'six_hours') {
+            url = '/api/performance/cpu_memory/last_six_hours/' + uuid
+        } else if (granularity === 'day') {
+            url = '/api/performance/cpu_memory/last_day/' + uuid
+        } else {
+            url = '/api/performance/cpu_memory/last_seven_days/' + uuid
+        }
+
         $.ajax({
-            url : '/api/performance/cpu_memory/last_hour/' + uuid,
+            url : url,
             type : 'GET',
             contentType: "application/json; charset=utf-8",
             dataType: 'json',
@@ -177,7 +188,7 @@
         });
 
         cpu_chart = echarts.init(document.getElementById('cpu_chart'));
-        render_cpu_memory_chart(uuid);
+        render_cpu_memory_chart(uuid, 'six_hours');
     });
 </script>
 <div class="container" style="padding-top: 100px; width: 90%; max-width: 100%;">