NewStatistics.vue 4.4 KB

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