LongJobs.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <floating-box
  3. v-if="activeJobs.length > 0"
  4. title="Jobs"
  5. id="longJobs"
  6. ref="longJobs"
  7. :persist="true"
  8. >
  9. <template #body>
  10. <div class="active-jobs">
  11. <div
  12. v-for="job in activeJobs"
  13. :key="`activeJob-${job.id}`"
  14. class="active-job"
  15. >
  16. <div class="name" :title="job.name">{{ job.name }}</div>
  17. <div class="actions">
  18. <i
  19. v-if="
  20. job.status === 'started' ||
  21. job.status === 'update'
  22. "
  23. class="material-icons"
  24. content="In Progress"
  25. v-tippy="{ theme: 'info' }"
  26. >
  27. pending
  28. </i>
  29. <i
  30. v-else-if="job.status === 'success'"
  31. class="material-icons success"
  32. content="Complete"
  33. v-tippy="{ theme: 'info' }"
  34. >
  35. check_circle
  36. </i>
  37. <i
  38. v-else
  39. class="material-icons error"
  40. content="Failed"
  41. v-tippy="{ theme: 'info' }"
  42. >
  43. error
  44. </i>
  45. <i class="material-icons" content="View Log" v-tippy>
  46. description
  47. </i>
  48. <i
  49. class="material-icons clear"
  50. :class="{ disabled: job.status !== 'success' }"
  51. content="Clear"
  52. v-tippy
  53. @click="remove(job)"
  54. >
  55. remove_circle
  56. </i>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. </floating-box>
  62. </template>
  63. <script>
  64. import { mapState, mapActions } from "vuex";
  65. import FloatingBox from "@/components/FloatingBox.vue";
  66. export default {
  67. components: {
  68. FloatingBox
  69. },
  70. data() {
  71. return {
  72. minimise: true
  73. };
  74. },
  75. computed: {
  76. ...mapState("longJobs", {
  77. activeJobs: state => state.activeJobs
  78. })
  79. },
  80. methods: {
  81. remove(job) {
  82. if (job.status === "success" || job.status === "error")
  83. this.removeJob(job.id);
  84. },
  85. ...mapActions("longJobs", ["removeJob"])
  86. }
  87. };
  88. </script>
  89. <style lang="less" scoped>
  90. .night-mode #longJobs {
  91. .active-jobs {
  92. .active-job {
  93. background-color: var(--dark-grey);
  94. border: 0;
  95. }
  96. }
  97. }
  98. #longJobs {
  99. min-width: 200px !important;
  100. max-width: 400px !important;
  101. min-height: 200px !important;
  102. z-index: 5000 !important;
  103. .active-jobs {
  104. .active-job {
  105. display: flex;
  106. padding: 5px;
  107. margin: 5px 0;
  108. border: 1px solid var(--light-grey-3);
  109. border-radius: @border-radius;
  110. &:first-child {
  111. margin-top: 0;
  112. }
  113. &:last-child {
  114. margin-bottom: 0;
  115. }
  116. .name {
  117. line-height: 24px;
  118. font-weight: 600;
  119. text-transform: capitalize;
  120. text-overflow: ellipsis;
  121. white-space: nowrap;
  122. overflow: hidden;
  123. margin-right: auto;
  124. }
  125. .actions {
  126. display: flex;
  127. .material-icons {
  128. font-size: 20px;
  129. color: var(--primary-color);
  130. margin: auto 0 auto 5px;
  131. cursor: pointer;
  132. &.success {
  133. color: var(--green);
  134. }
  135. &.error,
  136. &.clear {
  137. color: var(--red);
  138. }
  139. &.disabled {
  140. color: var(--light-grey-3);
  141. cursor: not-allowed;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. </style>