|
@@ -1,53 +1,55 @@
|
|
<template>
|
|
<template>
|
|
- <modal title='Edit Station'>
|
|
|
|
- <div slot='body'>
|
|
|
|
- <label class='label'>Display name</label>
|
|
|
|
- <div class='control is-grouped'>
|
|
|
|
- <p class='control is-expanded'>
|
|
|
|
- <input class='input' type='text' placeholder='Station Display Name' v-model='data.displayName' autofocus>
|
|
|
|
- </p>
|
|
|
|
- <p class='control'>
|
|
|
|
- <a class='button is-info' @click='updateDisplayName()' href='#'>Update</a>
|
|
|
|
- </p>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <modal title='Edit Station'>
|
|
|
|
+ <div slot='body'>
|
|
|
|
+ <label class='label'>Display name</label>
|
|
|
|
+ <div class='control is-grouped'>
|
|
|
|
+ <p class='control is-expanded'>
|
|
|
|
+ <input class='input' type='text' placeholder='Station Display Name' v-model='editing.displayName' autofocus>
|
|
|
|
+ </p>
|
|
|
|
+ <p class='control'>
|
|
|
|
+ <a class='button is-info' @click='updateDisplayName()' href='#'>Update</a>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <label class='label'>Description</label>
|
|
|
|
+ <div class='control is-grouped'>
|
|
|
|
+ <p class='control is-expanded'>
|
|
|
|
+ <input class='input' type='text' placeholder='Station Display Name' v-model='editing.description'>
|
|
|
|
+ </p>
|
|
|
|
+ <p class='control'>
|
|
|
|
+ <a class='button is-info' @click='updateDescription()' href='#'>Update</a>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <label class='label'>Privacy</label>
|
|
|
|
+ <div class='control is-grouped'>
|
|
|
|
+ <p class='control is-expanded'>
|
|
|
|
+ <span class='select'>
|
|
|
|
+ <select v-model='editing.privacy'>
|
|
|
|
+ <option :value='"public"'>Public</option>
|
|
|
|
+ <option :value='"unlisted"'>Unlisted</option>
|
|
|
|
+ <option :value='"private"'>Private</option>
|
|
|
|
+ </select>
|
|
|
|
+ </span>
|
|
|
|
+ </p>
|
|
|
|
+ <p class='control'>
|
|
|
|
+ <a class='button is-info' @click='updatePrivacy()' href='#'>Update</a>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <div class='control is-grouped' v-if="editing.type === 'community'">
|
|
|
|
+ <p class="control is-expanded party-mode-outer">
|
|
|
|
+ <label class="checkbox party-mode-inner">
|
|
|
|
+ <input type="checkbox" v-model="editing.partyMode">
|
|
|
|
+ Party mode
|
|
|
|
+ </label>
|
|
|
|
+ </p>
|
|
|
|
+ <p class='control'>
|
|
|
|
+ <a class='button is-info' @click='updatePartyMode()' href='#'>Update</a>
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ <button class='button is-danger' @click='deleteStation()' v-if="$parent.type === 'community'">Delete station</button>
|
|
</div>
|
|
</div>
|
|
- <label class='label'>Description</label>
|
|
|
|
- <div class='control is-grouped'>
|
|
|
|
- <p class='control is-expanded'>
|
|
|
|
- <input class='input' type='text' placeholder='Station Display Name' v-model='data.description'>
|
|
|
|
- </p>
|
|
|
|
- <p class='control'>
|
|
|
|
- <a class='button is-info' @click='updateDescription()' href='#'>Update</a>
|
|
|
|
- </p>
|
|
|
|
- </div>
|
|
|
|
- <label class='label'>Privacy</label>
|
|
|
|
- <div class='control is-grouped'>
|
|
|
|
- <p class='control is-expanded'>
|
|
|
|
- <span class='select'>
|
|
|
|
- <select v-model='data.privacy'>
|
|
|
|
- <option :value='"public"'>Public</option>
|
|
|
|
- <option :value='"unlisted"'>Unlisted</option>
|
|
|
|
- <option :value='"private"'>Private</option>
|
|
|
|
- </select>
|
|
|
|
- </span>
|
|
|
|
- </p>
|
|
|
|
- <p class='control'>
|
|
|
|
- <a class='button is-info' @click='updatePrivacy()' href='#'>Update</a>
|
|
|
|
- </p>
|
|
|
|
- </div>
|
|
|
|
- <div class='control is-grouped' v-if="$parent.type === 'community'">
|
|
|
|
- <p class="control is-expanded party-mode-outer">
|
|
|
|
- <label class="checkbox party-mode-inner">
|
|
|
|
- <input type="checkbox" v-model="data.partyMode">
|
|
|
|
- Party mode
|
|
|
|
- </label>
|
|
|
|
- </p>
|
|
|
|
- <p class='control'>
|
|
|
|
- <a class='button is-info' @click='updatePartyMode()' href='#'>Update</a>
|
|
|
|
- </p>
|
|
|
|
- </div>
|
|
|
|
- <button class='button is-danger' @click='deleteStation()' v-if="$parent.type === 'community'">Delete station</button>
|
|
|
|
- </div>
|
|
|
|
- </modal>
|
|
|
|
|
|
+ </modal>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
@@ -58,7 +60,9 @@
|
|
export default {
|
|
export default {
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
- data: {
|
|
|
|
|
|
+ editing: {
|
|
|
|
+ _id: '',
|
|
|
|
+ type: '',
|
|
displayName: '',
|
|
displayName: '',
|
|
description: '',
|
|
description: '',
|
|
privacy: 'private',
|
|
privacy: 'private',
|
|
@@ -68,63 +72,85 @@
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
updateDisplayName: function () {
|
|
updateDisplayName: function () {
|
|
- this.socket.emit('stations.updateDisplayName', this.data.stationId, this.data.displayName, res => {
|
|
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.socket.emit('stations.updateDisplayName', this.editing._id, this.editing.displayName, res => {
|
|
if (res.status === 'success') {
|
|
if (res.status === 'success') {
|
|
- this.$parent.station.displayName = this.data.displayName;
|
|
|
|
|
|
+ if (_this.$parent.station) _this.$parent.station.displayName = _this.editing.displayName;
|
|
|
|
+ else {
|
|
|
|
+ _this.$parent.stations.forEach((station, index) => {
|
|
|
|
+ if (station._id === _this.editing._id) return _this.$parent.stations[index].displayName = _this.editing.displayName;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
Toast.methods.addToast(res.message, 8000);
|
|
Toast.methods.addToast(res.message, 8000);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
updateDescription: function () {
|
|
updateDescription: function () {
|
|
- this.socket.emit('stations.updateDescription', this.data.stationId, this.data.description, res => {
|
|
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.socket.emit('stations.updateDescription', this.editing._id, this.editing.description, res => {
|
|
if (res.status === 'success') {
|
|
if (res.status === 'success') {
|
|
- this.$parent.station.description = this.data.description;
|
|
|
|
|
|
+ if (_this.$parent.station) _this.$parent.station.description = _this.editing.description;
|
|
|
|
+ else {
|
|
|
|
+ _this.$parent.stations.forEach((station, index) => {
|
|
|
|
+ if (station._id === station._id) return _this.$parent.stations[index].description = _this.editing.description;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
}
|
|
}
|
|
Toast.methods.addToast(res.message, 8000);
|
|
Toast.methods.addToast(res.message, 8000);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
updatePrivacy: function () {
|
|
updatePrivacy: function () {
|
|
- this.socket.emit('stations.updatePrivacy', this.data.stationId, this.data.privacy, res => {
|
|
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.socket.emit('stations.updatePrivacy', this.editing._id, this.editing.privacy, res => {
|
|
if (res.status === 'success') {
|
|
if (res.status === 'success') {
|
|
- this.$parent.station.privacy = this.data.privacy;
|
|
|
|
|
|
+ if (_this.$parent.station) _this.$parent.station.privacy = _this.editing.privacy;
|
|
|
|
+ else {
|
|
|
|
+ _this.$parent.stations.forEach((station, index) => {
|
|
|
|
+ if (station._id === station._id) return _this.$parent.stations[index].privacy = _this.editing.privacy;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
}
|
|
}
|
|
Toast.methods.addToast(res.message, 8000);
|
|
Toast.methods.addToast(res.message, 8000);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
updatePartyMode: function () {
|
|
updatePartyMode: function () {
|
|
- this.socket.emit('stations.updatePartyMode', this.data.stationId, this.data.partyMode, res => {
|
|
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.socket.emit('stations.updatePartyMode', this.editing._id, this.editing.partyMode, res => {
|
|
if (res.status === 'success') {
|
|
if (res.status === 'success') {
|
|
- this.$parent.station.partyMode = this.data.partyMode;
|
|
|
|
|
|
+ if (_this.$parent.station) _this.$parent.station.partyMode = _this.editing.partyMode;
|
|
|
|
+ else {
|
|
|
|
+ _this.$parent.stations.forEach((station, index) => {
|
|
|
|
+ if (station._id === station._id) return _this.$parent.stations[index].partyMode = _this.editing.partyMode;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
return Toast.methods.addToast(res.message, 4000);
|
|
}
|
|
}
|
|
Toast.methods.addToast(res.message, 8000);
|
|
Toast.methods.addToast(res.message, 8000);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
deleteStation: function() {
|
|
deleteStation: function() {
|
|
- this.socket.emit('stations.remove', this.data.stationId, res => {
|
|
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.socket.emit('stations.remove', this.editing._id, res => {
|
|
Toast.methods.addToast(res.message, 8000);
|
|
Toast.methods.addToast(res.message, 8000);
|
|
- if (res.status === 'success') {
|
|
|
|
- location.href = '/';
|
|
|
|
- }
|
|
|
|
|
|
+ if (res.status === 'success' && _this.$parent.station) location.href = '/';
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
ready: function () {
|
|
ready: function () {
|
|
let _this = this;
|
|
let _this = this;
|
|
- io.getSocket((socket) => {
|
|
|
|
|
|
+ io.getSocket(socket => {
|
|
_this.socket = socket;
|
|
_this.socket = socket;
|
|
});
|
|
});
|
|
- this.data.stationId = this.$parent.stationId;
|
|
|
|
- this.data.partyMode = this.$parent.station.partyMode;
|
|
|
|
- this.data.description = this.$parent.station.description;
|
|
|
|
- this.data.privacy = this.$parent.station.privacy;
|
|
|
|
- this.data.displayName = this.$parent.station.displayName;
|
|
|
|
},
|
|
},
|
|
events: {
|
|
events: {
|
|
closeModal: function() {
|
|
closeModal: function() {
|
|
- this.$parent.modals.editStation = !this.$parent.modals.editStation;
|
|
|
|
|
|
+ this.$parent.modals.editStation = false;
|
|
|
|
+ },
|
|
|
|
+ editStation: function (station) {
|
|
|
|
+ this.editing = station;
|
|
|
|
+ this.$parent.toggleModal();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
components: { Modal }
|
|
components: { Modal }
|