guest_detail.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. {% extends "layout.html" %}
  2. {% block title %} Guest {% endblock %}
  3. {% block head %}
  4. {{ super() }}
  5. <style type="text/css">
  6. @media (min-width: 768px) {
  7. .form-horizontal .control-label {
  8. text-align: left;
  9. }
  10. }
  11. label>span {
  12. color: deepskyblue;
  13. }
  14. .btn,
  15. .form-group>div>div,
  16. .form-control {
  17. border-radius: 0;
  18. }
  19. .btn-ability {
  20. margin-right: 16px;
  21. height: 50px;
  22. padding: 8px 50px;
  23. margin-bottom: 30px;
  24. }
  25. .btn-ability-line {
  26. }
  27. </style>
  28. {% endblock head %}
  29. {% block body %}
  30. <script>
  31. var resource_path = window.location.pathname;
  32. var resource_path_array = resource_path.split('/');
  33. var uuid = resource_path_array[resource_path_array.length - 1];
  34. var cpu_chart = null;
  35. function format_time(timestamp, i) {
  36. return new Date(timestamp).format('HH:MM');
  37. }
  38. function render_cpu_memory_chart(uuid) {
  39. $.ajax({
  40. url : '/api/performance/cpu_memory/last_six_hours/' + uuid,
  41. type : 'GET',
  42. contentType: "application/json; charset=utf-8",
  43. dataType: 'json',
  44. error : function() {
  45. alter_danger('获取图表数据失败失败!');
  46. },
  47. success : function(data, textStatus, xhr) {
  48. var option = {
  49. color: ['#3BC0FF'],
  50. title: {
  51. text: 'CPU'
  52. },
  53. toolbox: {
  54. feature: {
  55. dataZoom: {
  56. yAxisIndex: 'none'
  57. },
  58. magicType: {type: ['line', 'bar']},
  59. saveAsImage: {show: true}
  60. }
  61. },
  62. tooltip: {
  63. show: true,
  64. trigger: 'axis'
  65. },
  66. xAxis: {
  67. type: 'time',
  68. axisTick: {
  69. show: false
  70. },
  71. axisLine: {
  72. lineStyle: {
  73. opacity: 0.1,
  74. color: '#3d4245'
  75. }
  76. },
  77. splitLine: {
  78. show: false
  79. },
  80. axisLabel: {
  81. formatter: format_time
  82. }
  83. },
  84. yAxis: {
  85. min: 1,
  86. max: 'dataMax',
  87. minInterval: 1,
  88. axisTick: {
  89. show: false
  90. },
  91. axisLine: {
  92. lineStyle: {
  93. opacity: 0,
  94. color: '#8c8f91'
  95. }
  96. },
  97. splitLine: {
  98. show: true,
  99. lineStyle: {
  100. width: 1,
  101. opacity: 0.5
  102. }
  103. }
  104. },
  105. series: [{
  106. name: 'CPU 负载',
  107. type: 'line',
  108. showSymbol: false,
  109. smooth: true,
  110. lineStyle: {
  111. normal: {
  112. width: 1
  113. }
  114. },
  115. data: (function () {
  116. var d = [];
  117. $.each(data.data, function(i, ele) {
  118. d.push([
  119. ele['timestamp'] * 1000,
  120. ele['cpu_load']
  121. ])
  122. });
  123. return d;
  124. })()
  125. }]
  126. };
  127. cpu_chart.setOption(option);
  128. }
  129. });
  130. }
  131. $(document).ready(function() {
  132. $('body').addClass('add-transition');
  133. $('.add-page-transition').on('click', function(){
  134. var transAttr = $(this).attr('data-transition');
  135. $('.add-transition').attr('class', 'add-transition');
  136. $('.add-transition').addClass(transAttr);
  137. });
  138. cpu_chart = echarts.init(document.getElementById('cpu_chart'));
  139. render_cpu_memory_chart(uuid);
  140. });
  141. </script>
  142. <div class="container" style="padding-top: 100px;">
  143. <div class="panel">
  144. <div class="panel-body">
  145. <h3 class="title-hero" style="display: inline;">
  146. 虚拟机实例详情
  147. </h3>
  148. <a href="/guests" class="btn btn-xs btn-default add-page-transition" data-transition="pt-page-moveFromLeft-init" style="margin-bottom: 4px; margin-left: 10px;">
  149. <span class="glyph-icon icon-separator" style="transform: rotateY(-180deg);">
  150. <i class="glyph-icon icon-level-up"></i>
  151. </span>
  152. <span class="button-content">
  153. 返回虚拟机列表
  154. </span>
  155. </a>
  156. <div>
  157. <div id="cpu_chart" style="width: 800px;height:280px;"></div>
  158. <div id="traffic_chart" style="width: 600px;height:300px;"></div>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. {% endblock body %}