Reports.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. io.onConnect(() => {
  78. _this.init();
  79. });
  80. });
  81. },
  82. components: { IssuesModal }
  83. }
  84. </script>
  85. <style lang='scss' scoped>
  86. .tag:not(:last-child) { margin-right: 5px; }
  87. td {
  88. word-wrap: break-word;
  89. max-width: 10vw;
  90. vertical-align: middle;
  91. }
  92. </style>