|
@@ -6,8 +6,8 @@
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<td>Song ID</td>
|
|
|
- <td>Created By</td>
|
|
|
- <td>Created At</td>
|
|
|
+ <td>Author</td>
|
|
|
+ <td>Time of report</td>
|
|
|
<td>Description</td>
|
|
|
<td>Options</td>
|
|
|
</tr>
|
|
@@ -28,7 +28,13 @@
|
|
|
/>
|
|
|
</td>
|
|
|
<td>
|
|
|
- <span>{{ report.createdAt }}</span>
|
|
|
+ <span :title="report.createdAt">{{
|
|
|
+ formatDistance(
|
|
|
+ new Date(report.createdAt),
|
|
|
+ new Date(),
|
|
|
+ { addSuffix: true }
|
|
|
+ )
|
|
|
+ }}</span>
|
|
|
</td>
|
|
|
<td>
|
|
|
<span>{{ report.description }}</span>
|
|
@@ -58,6 +64,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapState, mapActions } from "vuex";
|
|
|
+import { formatDistance } from "date-fns";
|
|
|
|
|
|
import Toast from "toasters";
|
|
|
import io from "../../io";
|
|
@@ -76,17 +83,21 @@ export default {
|
|
|
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();
|
|
|
});
|
|
@@ -109,6 +120,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
methods: {
|
|
|
+ formatDistance,
|
|
|
init() {
|
|
|
this.socket.emit("apis.joinAdminRoom", "reports", () => {});
|
|
|
},
|