NewStatistics.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 io from "../../../io";
  194. export default {
  195. components: {},
  196. data() {
  197. return {
  198. modules: [],
  199. module: null
  200. };
  201. },
  202. mounted() {
  203. io.getSocket(socket => {
  204. this.socket = socket;
  205. if (this.socket.readyState === 1) this.init();
  206. io.onConnect(() => this.init());
  207. });
  208. },
  209. methods: {
  210. init() {
  211. this.socket.dispatch("utils.getModules", data => {
  212. console.log(data);
  213. if (data.status === "success") {
  214. this.modules = data.modules;
  215. }
  216. });
  217. if (this.$route.query.moduleName) {
  218. this.socket.dispatch(
  219. "utils.getModule",
  220. this.$route.query.moduleName,
  221. data => {
  222. console.log(data);
  223. if (data.status === "success") {
  224. this.module = {
  225. runningJobs: data.runningJobs,
  226. jobStatistics: data.jobStatistics
  227. };
  228. }
  229. }
  230. );
  231. }
  232. },
  233. round(number) {
  234. return Math.round(number);
  235. }
  236. }
  237. };
  238. </script>
  239. //
  240. <style lang="scss" scoped>
  241. .night-mode {
  242. .table {
  243. color: var(--light-grey-2);
  244. background-color: var(--dark-grey-3);
  245. thead tr {
  246. background: var(--dark-grey-3);
  247. td {
  248. color: var(--white);
  249. }
  250. }
  251. tbody tr:hover {
  252. background-color: var(--dark-grey-4) !important;
  253. }
  254. tbody tr:nth-child(even) {
  255. background-color: var(--dark-grey-2);
  256. }
  257. strong {
  258. color: var(--light-grey-2);
  259. }
  260. }
  261. .card {
  262. background-color: var(--dark-grey-3);
  263. p {
  264. color: var(--light-grey-2);
  265. }
  266. }
  267. }
  268. body {
  269. font-family: "Hind", sans-serif;
  270. }
  271. .user-avatar {
  272. display: block;
  273. max-width: 50px;
  274. margin: 0 auto;
  275. }
  276. td {
  277. vertical-align: middle;
  278. }
  279. .is-primary:focus {
  280. background-color: var(--primary-color) !important;
  281. }
  282. </style>