Playlist.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class='sidebar' transition='slide' v-if='$parent.sidebars.playlist'>
  3. <div class='inner-wrapper'>
  4. <div class='title'>Playlists</div>
  5. <aside class='menu' v-if='playlists.length > 0'>
  6. <ul class='menu-list'>
  7. <li v-for='playlist in playlists'>
  8. <a href='#'>{{ playlist.displayName }}</a>
  9. <!--Will play playlist in community station Kris-->
  10. <div class='icons-group'>
  11. <a href='#' @click='selectPlaylist(playlist._id)' v-if="$parent.station && !$parent.station.privatePlaylist === playlist._id">
  12. <i class='material-icons'>play_arrow</i>
  13. </a>
  14. <a href='#' @click='editPlaylist(playlist._id)'>
  15. <i class='material-icons'>edit</i>
  16. </a>
  17. </div>
  18. </li>
  19. </ul>
  20. </aside>
  21. <div class='none-found' v-else>No Playlists found</div>
  22. <a class='button create-playlist' @click='$parent.toggleModal("createPlaylist")'>Create Playlist</a>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { Toast } from 'vue-roaster';
  28. export default {
  29. data() {
  30. return {
  31. playlists: []
  32. }
  33. },
  34. methods: {
  35. editPlaylist: function(id) {
  36. this.$parent.editPlaylist(id);
  37. },
  38. selectPlaylist: function(id) {
  39. this.socket.emit('stations.selectPrivatePlaylist', this.$parent.stationId, id, (res) => {
  40. if (res.status === 'failure') return Toast.methods.addToast(res.message, 8000);
  41. Toast.methods.addToast(res.message, 4000);
  42. });
  43. }
  44. },
  45. ready: function () {
  46. // TODO: Update when playlist is removed/created
  47. let _this = this;
  48. let socketInterval = setInterval(() => {
  49. if (!!_this.$parent.$parent.socket) {
  50. _this.socket = _this.$parent.$parent.socket;
  51. _this.socket.emit('playlists.indexForUser', _this.$parent.$parent.username, res => {
  52. if (res.status == 'success') _this.playlists = res.data;
  53. });
  54. clearInterval(socketInterval);
  55. }
  56. }, 100);
  57. }
  58. }
  59. </script>
  60. <style type='scss' scoped>
  61. .sidebar {
  62. position: fixed;
  63. top: 0;
  64. right: 0;
  65. width: 300px;
  66. height: 100vh;
  67. background-color: #fff;
  68. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  69. }
  70. .inner-wrapper {
  71. top: 50px;
  72. position: relative;
  73. }
  74. .slide-transition {
  75. transition: transform 0.6s ease-in-out;
  76. transform: translateX(0);
  77. }
  78. .slide-enter, .slide-leave { transform: translateX(100%); }
  79. .title {
  80. background-color: rgb(3, 169, 244);
  81. text-align: center;
  82. padding: 10px;
  83. color: white;
  84. font-weight: 600;
  85. }
  86. .create-playlist {
  87. width: 100%;
  88. margin-top: 20px;
  89. height: 40px;
  90. border-radius: 0;
  91. background: rgb(3, 169, 244);
  92. color: #fff !important;
  93. border: 0;
  94. &:active, &:focus { border: 0; }
  95. }
  96. .menu { padding: 0 20px; }
  97. .menu-list li a:hover { color: #000 !important; }
  98. .menu-list li {
  99. display: flex;
  100. justify-content: space-between;
  101. }
  102. .icons-group { display: flex; }
  103. .none-found { text-align: center; }
  104. </style>