Reports.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class='columns is-mobile'>
  3. <div class='column is-8-desktop is-offset-2-desktop is-12-mobile'>
  4. <table class='table is-striped'>
  5. <thead>
  6. <tr>
  7. <td>Song ID</td>
  8. <td>Created By</td>
  9. <td>Created At</td>
  10. <td>Description</td>
  11. <td>Options</td>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <tr v-for='(index, report) in reports' track-by='$index'>
  16. <td>
  17. <span>{{ report.songId }}</span>
  18. </td>
  19. <td>
  20. <span>{{ report.createdBy }}</span>
  21. </td>
  22. <td>
  23. <span>{{ report.createdAt }}</span>
  24. </td>
  25. <td>
  26. <span>{{ report.description }}</span>
  27. </td>
  28. <td>
  29. <a class='button is-warning' @click='toggleModal(report.issues)'>Issues</a>
  30. <a class='button is-primary' @click='resolve(report._id)'>Resolve</a>
  31. </td>
  32. </tr>
  33. </tbody>
  34. </table>
  35. </div>
  36. </div>
  37. <issues-modal v-if='isModalActive'></issues-modal>
  38. </template>
  39. <script>
  40. import { Toast } from 'vue-roaster';
  41. import io from '../../io';
  42. import IssuesModal from '../Modals/IssuesModal.vue';
  43. export default {
  44. data() {
  45. return {
  46. reports: [],
  47. isModalActive: false
  48. }
  49. },
  50. methods: {
  51. init: function() {
  52. this.socket.emit('apis.joinAdminRoom', 'reports', data => {});
  53. },
  54. toggleModal: function (issues) {
  55. this.isModalActive = !this.isModalActive;
  56. if (this.isModalActive) this.currentReport = issues;
  57. },
  58. resolve: function (reportId) {
  59. this.socket.emit('reports.resolve', reportId, res => {
  60. Toast.methods.addToast(res.message, 3000);
  61. });
  62. }
  63. },
  64. ready: function () {
  65. let _this = this;
  66. io.getSocket((socket) => {
  67. _this.socket = socket;
  68. if (_this.socket.connected) _this.init();
  69. _this.socket.emit('reports.index', res => {
  70. _this.reports = res.data;
  71. });
  72. _this.socket.on('event:admin.report.resolved', reportId => {
  73. _this.reports = _this.reports.filter(report => {
  74. return report._id !== reportId;
  75. });
  76. });
  77. _this.socket.on('event:admin.report.created', report => {
  78. _this.reports.push(report);
  79. });
  80. io.onConnect(() => {
  81. _this.init();
  82. });
  83. });
  84. },
  85. components: { IssuesModal }
  86. }
  87. </script>
  88. <style lang='scss' scoped>
  89. .tag:not(:last-child) { margin-right: 5px; }
  90. td {
  91. word-wrap: break-word;
  92. max-width: 10vw;
  93. vertical-align: middle;
  94. }
  95. </style>