فهرست منبع

Added unstyled button for removing songs from the queue.

KrisVos130 8 سال پیش
والد
کامیت
dcdb9b5846
2فایلهای تغییر یافته به همراه11 افزوده شده و 2 حذف شده
  1. 2 2
      backend/logic/actions/stations.js
  2. 9 0
      frontend/components/Sidebars/SongsList.vue

+ 2 - 2
backend/logic/actions/stations.js

@@ -1019,10 +1019,10 @@ module.exports = {
 			},
 
 			(next) => {
-				db.models.update({_id: stationId}, {$pull: {queue: {songId: songId}}}, next);
+				db.models.station.update({_id: stationId}, {$pull: {queue: {songId: songId}}}, next);
 			},
 
-			(next) => {
+			(res, next) => {
 				stations.updateStation(stationId, next);
 			}
 		], (err, station) => {

+ 9 - 0
frontend/components/Sidebars/SongsList.vue

@@ -35,6 +35,7 @@
 							<div v-if="this.$parent.$parent.type === 'community'">
 								<br>
 								<small>Requested by <b>{{this.$parent.$parent.$parent.getUsernameFromId(song.requestedBy)}} {{this.userIdMap[song.requestedBy]}}</b></small>
+								<button class="button" @click="removeFromQueue(song.songId)" v-if="isOwnerOnly() || isAdminOnly()">REMOVE</button>
 							</div>
 						</p>
 					</div>
@@ -54,6 +55,7 @@
 
 <script>
 	import io from '../../io';
+	import { Toast } from 'vue-roaster';
 
 	export default {
 		data: function () {
@@ -68,6 +70,13 @@
 			},
 			isAdminOnly: function() {
 				return this.$parent.$parent.loggedIn && this.$parent.$parent.role === 'admin';
+			},
+			removeFromQueue: function(songId) {
+				socket.emit('stations.removeFromQueue', this.$parent.station._id, songId, res => {
+					if (res.status === 'success') {
+						Toast.methods.addToast('Successfully removed song from the queue.', 4000);
+					} else Toast.methods.addToast(res.message, 8000);
+				});
 			}
 		},
 		ready: function () {