console.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div id="app" style="width: 100%">
  3. <div class="page-header">
  4. <div class="page-title">控制台</div>
  5. <div class="page-header-btn">
  6. <el-button icon="el-icon-info" size="mini" style="margin-right: 1rem;" type="primary" @click="showInfo">平台信息
  7. </el-button>
  8. </div>
  9. </div>
  10. <el-row style="width: 100%">
  11. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  12. <div class="control-cell" id="ThreadsLoad" >
  13. <div style="width:100%; height:100%; ">
  14. <consoleCPU ref="consoleCPU"></consoleCPU>
  15. </div>
  16. </div>
  17. </el-col>
  18. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  19. <div class="control-cell" id="WorkThreadsLoad" >
  20. <div style="width:100%; height:100%; ">
  21. <consoleResource ref="consoleResource"></consoleResource>
  22. </div>
  23. </div>
  24. </el-col>
  25. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  26. <div class="control-cell" id="WorkThreadsLoad" >
  27. <div style="width:100%; height:100%; ">
  28. <consoleNet ref="consoleNet"></consoleNet>
  29. </div>
  30. </div>
  31. </el-col>
  32. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  33. <div class="control-cell" id="WorkThreadsLoad" >
  34. <div style="width:100%; height:100%; ">
  35. <consoleMem ref="consoleMem"></consoleMem>
  36. </div>
  37. </div>
  38. </el-col>
  39. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  40. <div class="control-cell" id="WorkThreadsLoad" >
  41. <div style="width:100%; height:100%; ">
  42. <consoleNodeLoad ref="consoleNodeLoad"></consoleNodeLoad>
  43. </div>
  44. </div>
  45. </el-col>
  46. <el-col :xl="{ span: 8 }" :lg="{ span: 8 }" :md="{ span: 12 }" :sm="{ span: 12 }" :xs="{ span: 24 }" >
  47. <div class="control-cell" id="WorkThreadsLoad" >
  48. <div style="width:100%; height:100%; ">
  49. <consoleDisk ref="consoleDisk"></consoleDisk>
  50. </div>
  51. </div>
  52. </el-col>
  53. </el-row>
  54. <configInfo ref="configInfo"></configInfo>
  55. </div>
  56. </template>
  57. <script>
  58. import uiHeader from '../layout/UiHeader.vue'
  59. import consoleCPU from './console/ConsoleCPU.vue'
  60. import consoleMem from './console/ConsoleMEM.vue'
  61. import consoleNet from './console/ConsoleNet.vue'
  62. import consoleNodeLoad from './console/ConsoleNodeLoad.vue'
  63. import consoleDisk from './console/ConsoleDisk.vue'
  64. import consoleResource from './console/ConsoleResource.vue'
  65. import configInfo from './dialog/configInfo.vue'
  66. import echarts from 'echarts';
  67. export default {
  68. name: 'app',
  69. components: {
  70. echarts,
  71. uiHeader,
  72. consoleCPU,
  73. consoleMem,
  74. consoleNet,
  75. consoleNodeLoad,
  76. consoleDisk,
  77. consoleResource,
  78. configInfo,
  79. },
  80. data() {
  81. return {
  82. timer: null,
  83. };
  84. },
  85. created() {
  86. this.getSystemInfo();
  87. this.getLoad();
  88. this.getResourceInfo();
  89. this.loopForSystemInfo();
  90. },
  91. destroyed() {
  92. },
  93. methods: {
  94. loopForSystemInfo: function (){
  95. if (this.timer != null) {
  96. window.clearTimeout(this.timer);
  97. }
  98. this.timer = setTimeout(()=>{
  99. if (this.$route.path === "/console") {
  100. this.getSystemInfo();
  101. this.getLoad();
  102. this.timer = null;
  103. this.loopForSystemInfo()
  104. this.getResourceInfo()
  105. }
  106. }, 2000)
  107. },
  108. getSystemInfo: function (){
  109. this.$axios({
  110. method: 'get',
  111. url: `/api/server/system/info`,
  112. }).then( (res)=> {
  113. if (res.data.code === 0) {
  114. this.$refs.consoleCPU.setData(res.data.data.cpu)
  115. this.$refs.consoleMem.setData(res.data.data.mem)
  116. this.$refs.consoleNet.setData(res.data.data.net, res.data.data.netTotal)
  117. this.$refs.consoleDisk.setData(res.data.data.disk)
  118. }
  119. }).catch( (error)=> {
  120. });
  121. },
  122. getLoad: function (){
  123. this.$axios({
  124. method: 'get',
  125. url: `/api/server/media_server/load`,
  126. }).then( (res)=> {
  127. if (res.data.code === 0) {
  128. this.$refs.consoleNodeLoad.setData(res.data.data)
  129. }
  130. }).catch( (error)=> {
  131. });
  132. },
  133. getResourceInfo: function (){
  134. this.$axios({
  135. method: 'get',
  136. url: `/api/server/resource/info`,
  137. }).then( (res)=> {
  138. if (res.data.code === 0) {
  139. this.$refs.consoleResource.setData(res.data.data)
  140. }
  141. }).catch( (error)=> {
  142. });
  143. },
  144. showInfo: function (){
  145. this.$axios({
  146. method: 'get',
  147. url: `/api/server/system/configInfo`,
  148. }).then( (res)=> {
  149. console.log(res)
  150. if (res.data.code === 0) {
  151. console.log(2222)
  152. console.log(this.$refs.configInfo)
  153. this.$refs.configInfo.openDialog(res.data.data)
  154. }
  155. }).catch( (error)=> {
  156. });
  157. }
  158. }
  159. };
  160. </script>
  161. <style>
  162. #app {
  163. height: 100%;
  164. }
  165. .control-cell {
  166. padding-top: 10px;
  167. padding-left: 5px;
  168. padding-right: 10px;
  169. height: 360px;
  170. }
  171. </style>