EditStation.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <modal title='Edit Station'>
  3. <div slot='body'>
  4. <label class='label'>Display name</label>
  5. <div class='control is-grouped'>
  6. <p class='control is-expanded'>
  7. <input class='input' type='text' placeholder='Station Display Name' v-model='data.displayName' autofocus>
  8. </p>
  9. <p class='control'>
  10. <a class='button is-info' @click='updateDisplayName()' href='#'>Update</a>
  11. </p>
  12. </div>
  13. <label class='label'>Description</label>
  14. <div class='control is-grouped'>
  15. <p class='control is-expanded'>
  16. <input class='input' type='text' placeholder='Station Display Name' v-model='data.description'>
  17. </p>
  18. <p class='control'>
  19. <a class='button is-info' @click='updateDescription()' href='#'>Update</a>
  20. </p>
  21. </div>
  22. <label class='label'>Privacy</label>
  23. <div class='control is-grouped'>
  24. <p class='control is-expanded'>
  25. <span class='select'>
  26. <select v-model='data.privacy'>
  27. <option :value='"public"'>Public</option>
  28. <option :value='"unlisted"'>Unlisted</option>
  29. <option :value='"private"'>Private</option>
  30. </select>
  31. </span>
  32. </p>
  33. <p class='control'>
  34. <a class='button is-info' @click='updatePrivacy()' href='#'>Update</a>
  35. </p>
  36. </div>
  37. <div class='control is-grouped' v-if="$parent.type === 'community'">
  38. <p class="control is-expanded party-mode-outer">
  39. <label class="checkbox party-mode-inner">
  40. <input type="checkbox" v-model="data.partyMode">
  41. &nbsp;Party mode
  42. </label>
  43. </p>
  44. <p class='control'>
  45. <a class='button is-info' @click='updatePartyMode()' href='#'>Update</a>
  46. </p>
  47. </div>
  48. </div>
  49. </modal>
  50. </template>
  51. <script>
  52. import { Toast } from 'vue-roaster';
  53. import Modal from './Modal.vue';
  54. import io from '../../io';
  55. export default {
  56. data: function() {
  57. return {
  58. data: {
  59. displayName: '',
  60. description: '',
  61. privacy: 'private',
  62. partyMode: false
  63. }
  64. }
  65. },
  66. methods: {
  67. updateDisplayName: function () {
  68. this.socket.emit('stations.updateDisplayName', this.data.stationId, this.data.displayName, res => {
  69. if (res.status === 'success') {
  70. this.$parent.station.displayName = this.data.displayName;
  71. }
  72. Toast.methods.addToast(res.message, 8000);
  73. });
  74. },
  75. updateDescription: function () {
  76. this.socket.emit('stations.updateDescription', this.data.stationId, this.data.description, res => {
  77. if (res.status === 'success') {
  78. this.$parent.station.description = this.data.description;
  79. return Toast.methods.addToast(res.message, 4000);
  80. }
  81. Toast.methods.addToast(res.message, 8000);
  82. });
  83. },
  84. updatePrivacy: function () {
  85. this.socket.emit('stations.updatePrivacy', this.data.stationId, this.data.privacy, res => {
  86. if (res.status === 'success') {
  87. this.$parent.station.privacy = this.data.privacy;
  88. return Toast.methods.addToast(res.message, 4000);
  89. }
  90. Toast.methods.addToast(res.message, 8000);
  91. });
  92. },
  93. updatePartyMode: function () {
  94. this.socket.emit('stations.updatePartyMode', this.data.stationId, this.data.partyMode, res => {
  95. if (res.status === 'success') {
  96. this.$parent.station.partyMode = this.data.partyMode;
  97. return Toast.methods.addToast(res.message, 4000);
  98. }
  99. Toast.methods.addToast(res.message, 8000);
  100. });
  101. }
  102. },
  103. ready: function () {
  104. let _this = this;
  105. io.getSocket((socket) => {
  106. _this.socket = socket;
  107. });
  108. this.data.stationId = this.$parent.stationId;
  109. this.data.partyMode = this.$parent.station.partyMode;
  110. this.data.description = this.$parent.station.description;
  111. this.data.privacy = this.$parent.station.privacy;
  112. this.data.displayName = this.$parent.station.displayName;
  113. },
  114. events: {
  115. closeModal: function() {
  116. this.$parent.modals.editStation = !this.$parent.modals.editStation;
  117. }
  118. },
  119. components: { Modal }
  120. }
  121. </script>
  122. <style type='scss' scoped>
  123. .controls {
  124. display: flex;
  125. a {
  126. display: flex;
  127. align-items: center;
  128. }
  129. }
  130. .table { margin-bottom: 0; }
  131. h5 { padding: 20px 0; }
  132. .party-mode-inner, .party-mode-outer {
  133. display: flex;
  134. align-items: center;
  135. }
  136. </style>