Statistics.vue 5.8 KB

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