Kaynağa Gözat

feat(AdvancedTable): Support joining normal and admin socket rooms

Owen Diffey 3 yıl önce
ebeveyn
işleme
a5620a6446

+ 13 - 6
frontend/src/components/AdvancedTable.vue

@@ -1022,12 +1022,19 @@ export default {
 		init() {
 			this.getData();
 			if (this.query) this.setQuery();
-			if (this.events && this.events.room) {
-				this.socket.dispatch(
-					"apis.joinAdminRoom",
-					this.events.room,
-					() => {}
-				);
+			if (this.events) {
+				if (this.events.room)
+					this.socket.dispatch(
+						"apis.joinRoom",
+						this.events.room,
+						() => {}
+					);
+				if (this.events.adminRoom)
+					this.socket.dispatch(
+						"apis.joinAdminRoom",
+						this.events.adminRoom,
+						() => {}
+					);
 			}
 		},
 		getData() {

+ 13 - 12
frontend/src/pages/Admin/tabs/Songs.vue

@@ -30,18 +30,7 @@
 				:filters="filters"
 				data-action="songs.getData"
 				name="admin-songs"
-				:events="{
-					room: 'songs',
-					updated: {
-						event: 'admin.song.updated',
-						id: 'song._id',
-						item: 'song'
-					},
-					removed: {
-						event: 'admin.song.removed',
-						id: 'song._id'
-					}
-				}"
+				:events="events"
 			>
 				<template #column-options="slotProps">
 					<div class="row-options">
@@ -587,6 +576,18 @@ export default {
 					defaultFilterType: "numberLesser"
 				}
 			],
+			events: {
+				adminRoom: "songs",
+				updated: {
+					event: "admin.song.updated",
+					id: "song._id",
+					item: "song"
+				},
+				removed: {
+					event: "admin.song.removed",
+					id: "song._id"
+				}
+			},
 			jobs: [
 				{
 					name: "Update all songs",