StationHeader.vue 9.7 KB

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