123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <template>
- <div class='columns is-mobile'>
- <div class='column is-8-desktop is-offset-2-desktop is-12-mobile'>
- <table class='table is-striped'>
- <thead>
- <tr>
- <td>Song ID</td>
- <td>Created By</td>
- <td>Created At</td>
- <td>Description</td>
- <td>Options</td>
- </tr>
- </thead>
- <tbody>
- <tr v-for='(index, report) in reports' track-by='$index'>
- <td>
- <span>{{ report.songId }}</span>
- </td>
- <td>
- <span>{{ report.createdBy }}</span>
- </td>
- <td>
- <span>{{ report.createdAt }}</span>
- </td>
- <td>
- <span>{{ report.description }}</span>
- </td>
- <td>
- <a class='button is-warning' @click='toggleModal(report.issues)'>Issues</a>
- <a class='button is-primary' @click='resolve(report._id)'>Resolve</a>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <issues-modal v-if='isModalActive'></issues-modal>
- </template>
- <script>
- import { Toast } from 'vue-roaster';
- import io from '../../io';
- import IssuesModal from '../Modals/IssuesModal.vue';
- export default {
- data() {
- return {
- reports: [],
- isModalActive: false
- }
- },
- methods: {
- init: function() {
- this.socket.emit('apis.joinAdminRoom', 'reports', data => {});
- },
- toggleModal: function (issues) {
- this.isModalActive = !this.isModalActive;
- if (this.isModalActive) this.currentReport = issues;
- },
- resolve: function (reportId) {
- this.socket.emit('reports.resolve', reportId, res => {
- Toast.methods.addToast(res.message, 3000);
- });
- }
- },
- ready: function () {
- let _this = this;
- io.getSocket((socket) => {
- _this.socket = socket;
- if (_this.socket.connected) _this.init();
- _this.socket.emit('reports.index', res => {
- _this.reports = res.data;
- });
- _this.socket.on('event:admin.report.resolved', reportId => {
- _this.reports = _this.reports.filter(report => {
- return report._id !== reportId;
- });
- });
- _this.socket.on('event:admin.report.created', report => {
- _this.reports.push(report);
- });
- io.onConnect(() => {
- _this.init();
- });
- });
- },
- components: { IssuesModal }
- }
- </script>
- <style lang='scss' scoped>
- .tag:not(:last-child) { margin-right: 5px; }
- td {
- word-wrap: break-word;
- max-width: 10vw;
- vertical-align: middle;
- }
- </style>
|