StationHeader.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  3. <nav class="nav">
  4. <div class="nav-left">
  5. <router-link class="nav-item is-brand" :to="{ path: '/' }">
  6. <img
  7. :src="`${this.siteSettings.logo_white}`"
  8. :alt="`${this.siteSettings.siteName}` || `Musare`"
  9. />
  10. </router-link>
  11. </div>
  12. <div class="nav-center stationDisplayName">
  13. {{ station.displayName }}
  14. </div>
  15. <span class="nav-toggle" v-on:click="controlBar = !controlBar">
  16. <span />
  17. <span />
  18. <span />
  19. </span>
  20. <div class="nav-right nav-menu" :class="{ 'is-active': isMobile }">
  21. <router-link
  22. v-if="role === 'admin'"
  23. class="nav-item is-tab admin"
  24. :to="{ path: '/admin' }"
  25. >
  26. <strong>Admin</strong>
  27. </router-link>
  28. <span v-if="loggedIn" class="grouped">
  29. <router-link
  30. class="nav-item is-tab"
  31. :to="{ path: '/u/' + username }"
  32. >Profile</router-link
  33. >
  34. <router-link class="nav-item is-tab" to="/settings"
  35. >Settings</router-link
  36. >
  37. <a class="nav-item is-tab" @click="logout()">Logout</a>
  38. </span>
  39. <span v-else class="grouped">
  40. <a
  41. class="nav-item"
  42. href="#"
  43. @click="openModal({ sector: 'header', modal: 'login' })"
  44. >Login</a
  45. >
  46. <a
  47. class="nav-item"
  48. href="#"
  49. @click="
  50. openModal({ sector: 'header', modal: 'register' })
  51. "
  52. >Register</a
  53. >
  54. </span>
  55. </div>
  56. </nav>
  57. <div class="control-sidebar" :class="{ 'show-controlBar': controlBar }">
  58. <div class="inner-wrapper">
  59. <div v-if="isOwner()">
  60. <a class="sidebar-item" href="#" @click="settings()">
  61. <span class="icon">
  62. <i class="material-icons">settings</i>
  63. </span>
  64. <span class="icon-purpose">Station settings</span>
  65. </a>
  66. <a
  67. class="sidebar-item"
  68. href="#"
  69. @click="$parent.skipStation()"
  70. >
  71. <span class="icon">
  72. <i class="material-icons">skip_next</i>
  73. </span>
  74. <span class="icon-purpose">Skip current song</span>
  75. </a>
  76. <a
  77. v-if="paused"
  78. class="sidebar-item"
  79. href="#"
  80. @click="$parent.resumeStation()"
  81. >
  82. <span class="icon">
  83. <i class="material-icons">play_arrow</i>
  84. </span>
  85. <span class="icon-purpose">Resume station</span>
  86. </a>
  87. <a
  88. v-if="!paused"
  89. class="sidebar-item"
  90. href="#"
  91. @click="$parent.pauseStation()"
  92. >
  93. <span class="icon">
  94. <i class="material-icons">pause</i>
  95. </span>
  96. <span class="icon-purpose">Pause station</span>
  97. </a>
  98. <hr />
  99. </div>
  100. <div v-if="loggedIn">
  101. <a
  102. v-if="station.type === 'official'"
  103. class="sidebar-item"
  104. href="#"
  105. @click="
  106. openModal({
  107. sector: 'station',
  108. modal: 'addSongToQueue'
  109. })
  110. "
  111. >
  112. <span class="icon">
  113. <i class="material-icons">queue</i>
  114. </span>
  115. <span class="icon-purpose">Add song to queue</span>
  116. </a>
  117. <a
  118. v-if="!isOwner() && !noSong"
  119. class="sidebar-item"
  120. href="#"
  121. @click="$parent.voteSkipStation()"
  122. >
  123. <span class="icon">
  124. <i class="material-icons">skip_next</i>
  125. </span>
  126. <span class="skip-votes">{{
  127. currentSong.skipVotes
  128. }}</span>
  129. <span class="icon-purpose">Skip current song</span>
  130. </a>
  131. <a
  132. v-if="!noSong && !currentSong.simpleSong"
  133. class="sidebar-item"
  134. href="#"
  135. @click="
  136. openModal({
  137. sector: 'station',
  138. modal: 'report'
  139. })
  140. "
  141. >
  142. <span class="icon">
  143. <i class="material-icons">report</i>
  144. </span>
  145. <span class="icon-purpose">Report a song</span>
  146. </a>
  147. <a
  148. v-if="!noSong"
  149. class="sidebar-item"
  150. href="#"
  151. @click="
  152. openModal({
  153. sector: 'station',
  154. modal: 'addSongToPlaylist'
  155. })
  156. "
  157. >
  158. <span class="icon">
  159. <i class="material-icons">playlist_add</i>
  160. </span>
  161. <span class="icon-purpose"
  162. >Add current song to playlist</span
  163. >
  164. </a>
  165. <hr v-if="!noSong" />
  166. </div>
  167. <a
  168. v-if="
  169. station.partyMode === true ||
  170. station.type === 'official'
  171. "
  172. class="sidebar-item"
  173. href="#"
  174. @click="$parent.toggleSidebar('songslist')"
  175. >
  176. <span class="icon">
  177. <i class="material-icons">queue_music</i>
  178. </span>
  179. <span class="icon-purpose">Show the station queue</span>
  180. </a>
  181. <a
  182. class="sidebar-item"
  183. href="#"
  184. @click="$parent.toggleSidebar('users')"
  185. >
  186. <span class="icon">
  187. <i class="material-icons">people</i>
  188. </span>
  189. <span class="icon-purpose"
  190. >Display users in the station</span
  191. >
  192. </a>
  193. <a
  194. v-if="loggedIn && station.type === 'community'"
  195. class="sidebar-item"
  196. href="#"
  197. @click="$parent.toggleSidebar('playlist')"
  198. >
  199. <span class="icon">
  200. <i class="material-icons">library_music</i>
  201. </span>
  202. <span class="icon-purpose">Show your playlists</span>
  203. </a>
  204. </div>
  205. </div>
  206. </div>
  207. </template>
  208. <script>
  209. import { mapState, mapActions } from "vuex";
  210. export default {
  211. data() {
  212. return {
  213. title: this.$route.params.id,
  214. isMobile: false,
  215. controlBar: false,
  216. frontendDomain: "",
  217. siteSettings: {
  218. logo: "",
  219. siteName: ""
  220. }
  221. };
  222. },
  223. computed: mapState({
  224. loggedIn: state => state.user.auth.loggedIn,
  225. userId: state => state.user.auth.userId,
  226. username: state => state.user.auth.username,
  227. role: state => state.user.auth.role,
  228. station: state => state.station.station,
  229. paused: state => state.station.paused,
  230. noSong: state => state.station.noSong,
  231. currentSong: state => state.station.currentSong
  232. }),
  233. mounted() {
  234. lofig.get("frontendDomain").then(frontendDomain => {
  235. this.frontendDomain = frontendDomain;
  236. });
  237. lofig.get("siteSettings").then(siteSettings => {
  238. this.siteSettings = siteSettings;
  239. });
  240. },
  241. methods: {
  242. isOwner() {
  243. return (
  244. this.loggedIn &&
  245. (this.role === "admin" || this.userId === this.station.owner)
  246. );
  247. },
  248. settings() {
  249. this.editStation({
  250. _id: this.station._id,
  251. name: this.station.name,
  252. type: this.station.type,
  253. partyMode: this.station.partyMode,
  254. description: this.station.description,
  255. privacy: this.station.privacy,
  256. displayName: this.station.displayName,
  257. locked: this.station.locked
  258. });
  259. this.openModal({
  260. sector: "station",
  261. modal: "editStation"
  262. });
  263. },
  264. ...mapActions("modals", ["openModal"]),
  265. ...mapActions("station", ["editStation"]),
  266. ...mapActions("user/auth", ["logout"])
  267. }
  268. };
  269. </script>
  270. <style lang="scss" scoped>
  271. @import "styles/global.scss";
  272. .nav {
  273. background-color: $primary-color;
  274. line-height: 64px;
  275. border-radius: 0% 0% 33% 33% / 0% 0% 7% 7%;
  276. .is-brand {
  277. font-size: 2.1rem !important;
  278. line-height: 38px !important;
  279. padding: 0 20px;
  280. font-family: Pacifico, cursive;
  281. img {
  282. max-height: 38px;
  283. color: $musareBlue;
  284. }
  285. }
  286. }
  287. a.nav-item {
  288. color: $white;
  289. font-size: 17px;
  290. &:hover {
  291. color: $white;
  292. }
  293. padding: 0 12px;
  294. .icon {
  295. height: 64px;
  296. i {
  297. font-size: 2rem;
  298. line-height: 64px;
  299. height: 64px;
  300. width: 34px;
  301. }
  302. }
  303. }
  304. a.nav-item.is-tab:hover {
  305. border-bottom: none;
  306. border-top: solid 1px $white;
  307. }
  308. .admin strong {
  309. color: $purple;
  310. }
  311. .grouped {
  312. margin: 0;
  313. display: flex;
  314. text-decoration: none;
  315. }
  316. .skip-votes {
  317. position: relative;
  318. left: 11px;
  319. }
  320. .nav-toggle {
  321. height: 64px;
  322. }
  323. @media screen and (max-width: 998px) {
  324. .nav-menu {
  325. background-color: $white;
  326. box-shadow: 0 4px 7px rgba(10, 10, 10, 0.1);
  327. left: 0;
  328. display: none;
  329. right: 0;
  330. top: 100%;
  331. position: absolute;
  332. }
  333. .nav-toggle {
  334. display: block;
  335. }
  336. }
  337. .logo {
  338. font-size: 2.1rem;
  339. line-height: 64px;
  340. padding-left: 20px !important;
  341. padding-right: 20px !important;
  342. }
  343. .nav-center {
  344. display: flex;
  345. align-items: center;
  346. color: $primary-color;
  347. font-size: 22px;
  348. position: absolute;
  349. margin: auto;
  350. top: 50%;
  351. left: 50%;
  352. transform: translate(-50%, -50%);
  353. }
  354. .nav-right.is-active .nav-item {
  355. background: $primary-color;
  356. border: 0;
  357. }
  358. .hidden {
  359. display: none;
  360. }
  361. .control-sidebar {
  362. position: fixed;
  363. z-index: 1;
  364. top: 0;
  365. left: 0;
  366. width: 64px;
  367. height: 100vh;
  368. background-color: $primary-color;
  369. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16),
  370. 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  371. @media (max-width: 998px) {
  372. display: none;
  373. }
  374. .inner-wrapper {
  375. @media (min-width: 999px) {
  376. .mobile-only {
  377. display: none;
  378. }
  379. .desktop-only {
  380. display: flex;
  381. }
  382. }
  383. @media (max-width: 998px) {
  384. .mobile-only {
  385. display: flex;
  386. }
  387. .desktop-only {
  388. display: none;
  389. visibility: hidden;
  390. }
  391. }
  392. }
  393. }
  394. .show-controlBar {
  395. display: block;
  396. }
  397. .inner-wrapper {
  398. top: 64px;
  399. position: relative;
  400. }
  401. .control-sidebar .material-icons {
  402. width: 100%;
  403. font-size: 2rem;
  404. }
  405. .control-sidebar .sidebar-item {
  406. font-size: 2rem;
  407. height: 50px;
  408. color: $white;
  409. -webkit-box-align: center;
  410. -ms-flex-align: center;
  411. align-items: center;
  412. display: -webkit-box;
  413. display: -ms-flexbox;
  414. display: flex;
  415. -webkit-box-flex: 0;
  416. -ms-flex-positive: 0;
  417. flex-grow: 0;
  418. -ms-flex-negative: 0;
  419. flex-shrink: 0;
  420. -webkit-box-pack: center;
  421. -ms-flex-pack: center;
  422. justify-content: center;
  423. width: 100%;
  424. position: relative;
  425. }
  426. .control-sidebar .sidebar-top-hr {
  427. margin: 0 0 20px 0;
  428. }
  429. .sidebar-item .icon-purpose {
  430. visibility: hidden;
  431. width: 160px;
  432. font-size: 12px;
  433. background-color: rgba(3, 169, 244, 0.8);
  434. color: $white;
  435. text-align: center;
  436. border-radius: 6px;
  437. padding: 5px;
  438. position: absolute;
  439. z-index: 1;
  440. left: 115%;
  441. opacity: 0;
  442. transition: opacity 0.5s;
  443. display: none;
  444. }
  445. .sidebar-item .icon-purpose::after {
  446. content: "";
  447. position: absolute;
  448. top: 50%;
  449. right: 100%;
  450. margin-top: -5px;
  451. border-width: 5px;
  452. border-style: solid;
  453. border-color: transparent rgba(3, 169, 244, 0.8) transparent transparent;
  454. }
  455. .sidebar-item:hover .icon-purpose {
  456. visibility: visible;
  457. opacity: 1;
  458. display: block;
  459. }
  460. </style>