NewStatistics.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div class="container">
  3. <metadata title="Admin | Statistics" />
  4. <div class="columns">
  5. <div
  6. class="card column is-10-desktop is-offset-1-desktop is-12-mobile"
  7. >
  8. <header class="card-header">
  9. <p class="card-header-title">
  10. Average Logs
  11. </p>
  12. </header>
  13. <div class="card-content">
  14. <div class="content">
  15. <table class="table">
  16. <thead>
  17. <tr>
  18. <th>Name</th>
  19. <th>Status</th>
  20. <th>Stage</th>
  21. <th>Jobs in queue</th>
  22. <th>Jobs in progress</th>
  23. <th>Concurrency</th>
  24. </tr>
  25. </thead>
  26. <tbody>
  27. <tr
  28. v-for="module_ in modules"
  29. :key="module_.name"
  30. >
  31. <td>
  32. <router-link
  33. :to="'?moduleName=' + module_.name"
  34. >{{ module_.name }}</router-link
  35. >
  36. </td>
  37. <td>{{ module_.status }}</td>
  38. <td>{{ module_.stage }}</td>
  39. <td>{{ module_.jobsInQueue }}</td>
  40. <td>{{ module_.jobsInProgress }}</td>
  41. <td>{{ module_.concurrency }}</td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <br />
  50. <div class="columns" v-if="module_">
  51. <div
  52. class="card column is-10-desktop is-offset-1-desktop is-12-mobile"
  53. >
  54. <header class="card-header">
  55. <p class="card-header-title">
  56. Average Logs
  57. </p>
  58. </header>
  59. <div class="card-content">
  60. <div class="content">
  61. <table class="table">
  62. <thead>
  63. <tr>
  64. <th>Name</th>
  65. <th>Payload</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <tr
  70. v-for="job in module_.runningJobs"
  71. :key="JSON.stringify(job)"
  72. >
  73. <td>{{ job.name }}</td>
  74. <td>
  75. {{ JSON.stringify(job.payload) }}
  76. </td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <br />
  85. <div class="columns" v-if="module_">
  86. <div
  87. class="card column is-10-desktop is-offset-1-desktop is-12-mobile"
  88. >
  89. <header class="card-header">
  90. <p class="card-header-title">
  91. Average Logs
  92. </p>
  93. </header>
  94. <div class="card-content">
  95. <div class="content">
  96. <table class="table">
  97. <thead>
  98. <tr>
  99. <th>Job name</th>
  100. <th>Successful</th>
  101. <th>Failed</th>
  102. <th>Total</th>
  103. <th>Average timing</th>
  104. </tr>
  105. </thead>
  106. <tbody>
  107. <tr
  108. v-for="(job,
  109. jobName) in module_.jobStatistics"
  110. :key="jobName"
  111. >
  112. <td>{{ jobName }}</td>
  113. <td>
  114. {{ job.successful }}
  115. </td>
  116. <td>
  117. {{ job.failed }}
  118. </td>
  119. <td>
  120. {{ job.total }}
  121. </td>
  122. <td>
  123. {{ job.averageTiming }}
  124. </td>
  125. </tr>
  126. </tbody>
  127. </table>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </template>
  134. <script>
  135. import io from "../../io";
  136. export default {
  137. components: {},
  138. data() {
  139. return {
  140. modules: [],
  141. module_: null
  142. };
  143. },
  144. mounted() {
  145. io.getSocket(socket => {
  146. this.socket = socket;
  147. if (this.socket.connected) this.init();
  148. io.onConnect(() => this.init());
  149. });
  150. },
  151. methods: {
  152. init() {
  153. this.socket.emit("utils.getModules", data => {
  154. console.log(data);
  155. if (data.status === "success") {
  156. this.modules = data.modules;
  157. }
  158. });
  159. if (this.$route.query.moduleName) {
  160. this.socket.emit(
  161. "utils.getModule",
  162. this.$route.query.moduleName,
  163. data => {
  164. console.log(data);
  165. if (data.status === "success") {
  166. this.module_ = {
  167. runningJobs: data.runningJobs,
  168. jobStatistics: data.jobStatistics
  169. };
  170. }
  171. }
  172. );
  173. }
  174. },
  175. round(number) {
  176. return Math.round(number);
  177. }
  178. }
  179. };
  180. </script>
  181. //
  182. <style lang="scss" scoped>
  183. @import "styles/global.scss";
  184. .night-mode {
  185. .table {
  186. color: #ddd;
  187. background-color: #222;
  188. thead tr {
  189. background: $night-mode-secondary;
  190. td {
  191. color: #fff;
  192. }
  193. }
  194. tbody tr:hover {
  195. background-color: #111 !important;
  196. }
  197. tbody tr:nth-child(even) {
  198. background-color: #444;
  199. }
  200. strong {
  201. color: #ddd;
  202. }
  203. }
  204. .card {
  205. background-color: $night-mode-secondary;
  206. p {
  207. color: #ddd;
  208. }
  209. }
  210. }
  211. body {
  212. font-family: "Roboto", sans-serif;
  213. }
  214. .user-avatar {
  215. display: block;
  216. max-width: 50px;
  217. margin: 0 auto;
  218. }
  219. td {
  220. vertical-align: middle;
  221. }
  222. .is-primary:focus {
  223. background-color: $primary-color !important;
  224. }
  225. </style>