Statistics.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="container">
  3. <page-metadata title="Admin | Statistics" />
  4. <div class="card">
  5. <header class="card-header">
  6. <p>Average Logs</p>
  7. </header>
  8. <div class="card-content">
  9. <table class="table">
  10. <thead>
  11. <tr>
  12. <th>Name</th>
  13. <th>Status</th>
  14. <th>Stage</th>
  15. <th>Jobs in queue</th>
  16. <th>Jobs in progress</th>
  17. <th>Jobs paused</th>
  18. <th>Concurrency</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <tr
  23. v-for="moduleItem in modules"
  24. :key="moduleItem.name"
  25. >
  26. <td>
  27. <router-link
  28. :to="'?moduleName=' + moduleItem.name"
  29. >{{ moduleItem.name }}</router-link
  30. >
  31. </td>
  32. <td>{{ moduleItem.status }}</td>
  33. <td>{{ moduleItem.stage }}</td>
  34. <td>{{ moduleItem.jobsInQueue }}</td>
  35. <td>{{ moduleItem.jobsInProgress }}</td>
  36. <td>{{ moduleItem.jobsPaused }}</td>
  37. <td>{{ moduleItem.concurrency }}</td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </div>
  42. </div>
  43. <br />
  44. <div v-if="module">
  45. <div class="card">
  46. <header class="card-header">
  47. <p>Running tasks</p>
  48. </header>
  49. <div class="card-content">
  50. <table class="table">
  51. <thead>
  52. <tr>
  53. <th>Name</th>
  54. <th>Payload</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <tr
  59. v-for="job in module.runningTasks"
  60. :key="JSON.stringify(job)"
  61. >
  62. <td>{{ job.name }}</td>
  63. <td>
  64. {{ JSON.stringify(job.payload) }}
  65. </td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. </div>
  70. </div>
  71. <div class="card">
  72. <header class="card-header">
  73. <p>Paused tasks</p>
  74. </header>
  75. <div class="card-content">
  76. <table class="table">
  77. <thead>
  78. <tr>
  79. <th>Name</th>
  80. <th>Payload</th>
  81. </tr>
  82. </thead>
  83. <tbody>
  84. <tr
  85. v-for="job in module.pausedTasks"
  86. :key="JSON.stringify(job)"
  87. >
  88. <td>{{ job.name }}</td>
  89. <td>
  90. {{ JSON.stringify(job.payload) }}
  91. </td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. </div>
  96. </div>
  97. <div class="card">
  98. <header class="card-header">
  99. <p>Queued tasks</p>
  100. </header>
  101. <div class="card-content">
  102. <table class="table">
  103. <thead>
  104. <tr>
  105. <th>Name</th>
  106. <th>Payload</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. <tr
  111. v-for="job in module.queuedTasks"
  112. :key="JSON.stringify(job)"
  113. >
  114. <td>{{ job.name }}</td>
  115. <td>
  116. {{ JSON.stringify(job.payload) }}
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. </div>
  122. </div>
  123. </div>
  124. <br />
  125. <div v-if="module">
  126. <div class="card">
  127. <header class="card-header">
  128. <p>Average Logs</p>
  129. </header>
  130. <div class="card-content">
  131. <table class="table">
  132. <thead>
  133. <tr>
  134. <th>Job name</th>
  135. <th>Successful</th>
  136. <th>Failed</th>
  137. <th>Total</th>
  138. <th>Average timing</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <tr
  143. v-for="(job, jobName) in module.jobStatistics"
  144. :key="jobName"
  145. >
  146. <td>{{ jobName }}</td>
  147. <td>
  148. {{ job.successful }}
  149. </td>
  150. <td>
  151. {{ job.failed }}
  152. </td>
  153. <td>
  154. {{ job.total }}
  155. </td>
  156. <td>
  157. {{ job.averageTiming }}
  158. </td>
  159. </tr>
  160. </tbody>
  161. </table>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import { mapGetters } from "vuex";
  169. import ws from "@/ws";
  170. export default {
  171. components: {},
  172. data() {
  173. return {
  174. modules: [],
  175. module: null
  176. };
  177. },
  178. computed: mapGetters({
  179. socket: "websockets/getSocket"
  180. }),
  181. mounted() {
  182. ws.onConnect(this.init);
  183. },
  184. methods: {
  185. init() {
  186. this.socket.dispatch("utils.getModules", res => {
  187. if (res.status === "success") this.modules = res.data.modules;
  188. });
  189. if (this.$route.query.moduleName) {
  190. this.socket.dispatch(
  191. "utils.getModule",
  192. this.$route.query.moduleName,
  193. res => {
  194. if (res.status === "success")
  195. this.module = {
  196. runningJobs: res.data.runningJobs,
  197. jobStatistics: res.data.jobStatistics
  198. };
  199. }
  200. );
  201. }
  202. },
  203. round(number) {
  204. return Math.round(number);
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="less" scoped>
  210. .night-mode {
  211. .table {
  212. color: var(--light-grey-2);
  213. background-color: var(--dark-grey-3);
  214. thead tr {
  215. background: var(--dark-grey-3);
  216. td {
  217. color: var(--white);
  218. }
  219. }
  220. tbody tr:hover {
  221. background-color: var(--dark-grey-4) !important;
  222. }
  223. tbody tr:nth-child(even) {
  224. background-color: var(--dark-grey-2);
  225. }
  226. strong {
  227. color: var(--light-grey-2);
  228. }
  229. }
  230. .card {
  231. background-color: var(--dark-grey-3);
  232. p {
  233. color: var(--light-grey-2);
  234. }
  235. }
  236. }
  237. .user-avatar {
  238. display: block;
  239. max-width: 50px;
  240. margin: 0 auto;
  241. }
  242. td {
  243. vertical-align: middle;
  244. }
  245. .is-primary:focus {
  246. background-color: var(--primary-color) !important;
  247. }
  248. .card {
  249. display: flex;
  250. flex-grow: 1;
  251. flex-direction: column;
  252. padding: 20px;
  253. margin: 10px;
  254. border-radius: @border-radius;
  255. background-color: var(--white);
  256. color: var(--dark-grey);
  257. box-shadow: @box-shadow;
  258. .card-header {
  259. font-weight: 700;
  260. padding-bottom: 10px;
  261. }
  262. }
  263. </style>