index.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046
  1. <template>
  2. <div>
  3. <modal title="Edit Song" class="song-modal">
  4. <template #body>
  5. <div class="left-section">
  6. <div class="top-section">
  7. <div class="player-section">
  8. <div id="editSongPlayer"></div>
  9. <div v-show="youtubeError" class="player-error">
  10. <h2>{{ youtubeErrorMessage }}</h2>
  11. </div>
  12. <canvas
  13. ref="durationCanvas"
  14. v-show="!youtubeError"
  15. height="20"
  16. width="530"
  17. ></canvas>
  18. <div class="player-footer">
  19. <div class="player-footer-left">
  20. <i
  21. class="material-icons player-play-pause"
  22. @click="play()"
  23. @keyup.enter="play()"
  24. tabindex="0"
  25. v-if="video.paused"
  26. >play_arrow</i
  27. >
  28. <i
  29. class="material-icons player-play-pause"
  30. @click="settings('pause')"
  31. @keyup.enter="settings('pause')"
  32. tabindex="0"
  33. v-if="!video.paused"
  34. >pause</i
  35. >
  36. <i
  37. class="material-icons player-stop"
  38. @click="settings('stop')"
  39. @keyup.enter="settings('stop')"
  40. tabindex="0"
  41. >stop</i
  42. >
  43. <i
  44. class="material-icons player-fast-forward"
  45. @click="settings('skipToLast10Secs')"
  46. @keyup.enter="
  47. settings('skipToLast10Secs')
  48. "
  49. tabindex="0"
  50. >fast_forward</i
  51. >
  52. </div>
  53. <div class="player-footer-center">
  54. <img src="/assets/social/youtube.svg" />
  55. <span>
  56. <span>
  57. {{ youtubeVideoCurrentTime }}
  58. </span>
  59. /
  60. <span>
  61. {{ youtubeVideoDuration }}
  62. {{ youtubeVideoNote }}
  63. </span>
  64. </span>
  65. </div>
  66. <div class="player-footer-right">
  67. <input
  68. type="range"
  69. v-model="volumeSliderValue"
  70. min="0"
  71. max="10000"
  72. class="active"
  73. @change="changeVolume()"
  74. @input="changeVolume()"
  75. />
  76. </div>
  77. </div>
  78. </div>
  79. <img
  80. class="thumbnail-preview"
  81. :src="song.thumbnail"
  82. onerror="this.src='/assets/notes-transparent.png'"
  83. ref="thumbnailElement"
  84. v-if="songDataLoaded"
  85. />
  86. </div>
  87. <div class="edit-section" v-if="songDataLoaded">
  88. <div class="control is-grouped">
  89. <div class="title-container">
  90. <label class="label">Title</label>
  91. <p class="control has-addons">
  92. <input
  93. class="input"
  94. type="text"
  95. ref="title-input"
  96. v-model="song.title"
  97. @keyup.shift.enter="
  98. getAlbumData('title')
  99. "
  100. />
  101. <button
  102. class="button album-get-button"
  103. @click="getAlbumData('title')"
  104. >
  105. <i class="material-icons">album</i>
  106. </button>
  107. </p>
  108. </div>
  109. <div class="duration-container">
  110. <label class="label">Duration</label>
  111. <p class="control has-addons">
  112. <input
  113. class="input"
  114. type="text"
  115. v-model.number="song.duration"
  116. @keyup.shift.enter="fillDuration()"
  117. />
  118. <button
  119. class="button duration-fill-button"
  120. @click="fillDuration()"
  121. >
  122. <i class="material-icons">sync</i>
  123. </button>
  124. </p>
  125. </div>
  126. <div class="skip-duration-container">
  127. <label class="label">Skip duration</label>
  128. <p class="control">
  129. <input
  130. class="input"
  131. type="text"
  132. v-model.number="song.skipDuration"
  133. />
  134. </p>
  135. </div>
  136. </div>
  137. <div class="control is-grouped">
  138. <div class="album-art-container">
  139. <label class="label">Album art</label>
  140. <p class="control has-addons">
  141. <input
  142. class="input"
  143. type="text"
  144. v-model="song.thumbnail"
  145. @keyup.shift.enter="
  146. getAlbumData('albumArt')
  147. "
  148. />
  149. <button
  150. class="button album-get-button"
  151. @click="getAlbumData('albumArt')"
  152. >
  153. <i class="material-icons">album</i>
  154. </button>
  155. </p>
  156. </div>
  157. </div>
  158. <div class="control is-grouped">
  159. <div class="artists-container">
  160. <label class="label">Artists</label>
  161. <p class="control has-addons">
  162. <input
  163. class="input"
  164. type="text"
  165. ref="new-artist"
  166. v-model="artistInputValue"
  167. @blur="blurArtistInput()"
  168. @focus="focusArtistInput()"
  169. @keydown="keydownArtistInput()"
  170. @keyup.exact.enter="addTag('artists')"
  171. @keyup.shift.enter="
  172. getAlbumData('artists')
  173. "
  174. />
  175. <button
  176. class="button album-get-button"
  177. @click="getAlbumData('artists')"
  178. >
  179. <i class="material-icons">album</i>
  180. </button>
  181. <button
  182. class="button is-info add-button"
  183. @click="addTag('artists')"
  184. >
  185. <i class="material-icons">add</i>
  186. </button>
  187. </p>
  188. <div
  189. class="autosuggest-container"
  190. v-if="
  191. (artistInputFocussed ||
  192. artistAutosuggestContainerFocussed) &&
  193. artistAutosuggestItems.length > 0
  194. "
  195. @mouseover="focusArtistContainer()"
  196. @mouseleave="blurArtistContainer()"
  197. >
  198. <span
  199. class="autosuggest-item"
  200. tabindex="0"
  201. @click="selectArtistAutosuggest(item)"
  202. v-for="item in artistAutosuggestItems"
  203. :key="item"
  204. >{{ item }}</span
  205. >
  206. </div>
  207. <div class="list-container">
  208. <div
  209. class="list-item"
  210. v-for="artist in song.artists"
  211. :key="artist"
  212. >
  213. <div
  214. class="list-item-circle"
  215. @click="
  216. removeTag('artists', artist)
  217. "
  218. >
  219. <i class="material-icons">close</i>
  220. </div>
  221. <p>{{ artist }}</p>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="genres-container">
  226. <label class="label">
  227. <span>Genres</span>
  228. <i
  229. class="material-icons"
  230. @click="toggleGenreHelper"
  231. @dblclick="resetGenreHelper"
  232. >info</i
  233. >
  234. </label>
  235. <p class="control has-addons">
  236. <input
  237. class="input"
  238. type="text"
  239. ref="new-genre"
  240. v-model="genreInputValue"
  241. @blur="blurGenreInput()"
  242. @focus="focusGenreInput()"
  243. @keydown="keydownGenreInput()"
  244. @keyup.exact.enter="addTag('genres')"
  245. @keyup.shift.enter="
  246. getAlbumData('genres')
  247. "
  248. />
  249. <button
  250. class="button album-get-button"
  251. @click="getAlbumData('genres')"
  252. >
  253. <i class="material-icons">album</i>
  254. </button>
  255. <button
  256. class="button is-info add-button"
  257. @click="addTag('genres')"
  258. >
  259. <i class="material-icons">add</i>
  260. </button>
  261. </p>
  262. <div
  263. class="autosuggest-container"
  264. v-if="
  265. (genreInputFocussed ||
  266. genreAutosuggestContainerFocussed) &&
  267. genreAutosuggestItems.length > 0
  268. "
  269. @mouseover="focusGenreContainer()"
  270. @mouseleave="blurGenreContainer()"
  271. >
  272. <span
  273. class="autosuggest-item"
  274. @click="selectGenreAutosuggest(item)"
  275. v-for="item in genreAutosuggestItems"
  276. :key="item"
  277. >{{ item }}</span
  278. >
  279. </div>
  280. <div class="list-container">
  281. <div
  282. class="list-item"
  283. v-for="genre in song.genres"
  284. :key="genre"
  285. >
  286. <div
  287. class="list-item-circle"
  288. @click="removeTag('genres', genre)"
  289. >
  290. <i class="material-icons">close</i>
  291. </div>
  292. <p>{{ genre }}</p>
  293. </div>
  294. </div>
  295. </div>
  296. <div class="youtube-id-container">
  297. <label class="label">YouTube ID</label>
  298. <p class="control">
  299. <input
  300. class="input"
  301. type="text"
  302. v-model="song.youtubeId"
  303. />
  304. </p>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. <div class="right-section" v-if="songDataLoaded">
  310. <div id="tabs-container">
  311. <div id="tab-selection">
  312. <button
  313. class="button is-default"
  314. :class="{ selected: tab === 'discogs' }"
  315. ref="discogs-tab"
  316. @click="showTab('discogs')"
  317. >
  318. Discogs
  319. </button>
  320. <button
  321. class="button is-default"
  322. :class="{ selected: tab === 'reports' }"
  323. ref="reports-tab"
  324. @click="showTab('reports')"
  325. >
  326. Reports ({{ reports.length }})
  327. </button>
  328. </div>
  329. <discogs class="tab" v-show="tab === 'discogs'" />
  330. <reports class="tab" v-show="tab === 'reports'" />
  331. </div>
  332. </div>
  333. </template>
  334. <template #footer>
  335. <save-button ref="saveButton" @clicked="save(song, false)" />
  336. <save-button
  337. ref="saveAndCloseButton"
  338. type="save-and-close"
  339. @clicked="save(song, true)"
  340. />
  341. <div class="right">
  342. <button
  343. v-if="song.status !== 'verified'"
  344. class="button is-success"
  345. @click="verify(song._id)"
  346. content="Verify Song"
  347. v-tippy
  348. >
  349. <i class="material-icons">check_circle</i>
  350. </button>
  351. <confirm
  352. v-if="song.status === 'verified'"
  353. placement="left"
  354. @confirm="unverify(song._id)"
  355. >
  356. <button
  357. class="button is-danger"
  358. content="Unverify Song"
  359. v-tippy
  360. >
  361. <i class="material-icons">cancel</i>
  362. </button>
  363. </confirm>
  364. <confirm
  365. v-if="song.status !== 'hidden'"
  366. placement="left"
  367. @confirm="hide(song._id)"
  368. >
  369. <button
  370. class="button is-danger"
  371. content="Hide Song"
  372. v-tippy
  373. >
  374. <i class="material-icons">visibility_off</i>
  375. </button>
  376. </confirm>
  377. <button
  378. v-if="song.status === 'hidden'"
  379. class="button is-success"
  380. @click="unhide(song._id)"
  381. content="Unhide Song"
  382. v-tippy
  383. >
  384. <i class="material-icons">visibility</i>
  385. </button>
  386. <!-- <confirm placement="left" @confirm="remove(song._id)">
  387. <button
  388. class="button is-danger"
  389. content="Remove Song"
  390. v-tippy
  391. >
  392. <i class="material-icons">delete</i>
  393. </button>
  394. </confirm> -->
  395. </div>
  396. </template>
  397. </modal>
  398. <floating-box id="genreHelper" ref="genreHelper">
  399. <template #body>
  400. <span>Blues</span><span>Country</span><span>Disco</span
  401. ><span>Funk</span><span>Hip-Hop</span><span>Jazz</span
  402. ><span>Metal</span><span>Oldies</span><span>Other</span
  403. ><span>Pop</span><span>Rap</span><span>Reggae</span
  404. ><span>Rock</span><span>Techno</span><span>Trance</span
  405. ><span>Classical</span><span>Instrumental</span
  406. ><span>House</span><span>Electronic</span
  407. ><span>Christian Rap</span><span>Lo-Fi</span><span>Musical</span
  408. ><span>Rock 'n' Roll</span><span>Opera</span
  409. ><span>Drum & Bass</span><span>Club-House</span
  410. ><span>Indie</span><span>Heavy Metal</span
  411. ><span>Christian rock</span><span>Dubstep</span>
  412. </template>
  413. </floating-box>
  414. </div>
  415. </template>
  416. <script>
  417. import { mapState, mapGetters, mapActions } from "vuex";
  418. import Toast from "toasters";
  419. import aw from "@/aw";
  420. import validation from "@/validation";
  421. import keyboardShortcuts from "@/keyboardShortcuts";
  422. import Confirm from "@/components/Confirm.vue";
  423. import Modal from "../../Modal.vue";
  424. import FloatingBox from "../../FloatingBox.vue";
  425. import SaveButton from "../../SaveButton.vue";
  426. import Discogs from "./Tabs/Discogs.vue";
  427. import Reports from "./Tabs/Reports.vue";
  428. export default {
  429. components: { Modal, FloatingBox, SaveButton, Confirm, Discogs, Reports },
  430. props: {
  431. youtubeId: { type: String, default: null },
  432. // songType: { type: String, default: null },
  433. sector: { type: String, default: "admin" }
  434. },
  435. data() {
  436. return {
  437. songDataLoaded: false,
  438. youtubeError: false,
  439. youtubeErrorMessage: "",
  440. focusedElementBefore: null,
  441. youtubeVideoDuration: "0.000",
  442. youtubeVideoCurrentTime: 0,
  443. youtubeVideoNote: "",
  444. useHTTPS: false,
  445. volumeSliderValue: 0,
  446. skipToLast10SecsPressed: false,
  447. artistInputValue: "",
  448. genreInputValue: "",
  449. artistInputFocussed: false,
  450. genreInputFocussed: false,
  451. genreAutosuggestContainerFocussed: false,
  452. artistAutosuggestContainerFocussed: false,
  453. keydownArtistInputTimeout: 0,
  454. keydownGenreInputTimeout: 0,
  455. artistAutosuggestItems: [],
  456. genreAutosuggestItems: [],
  457. activityWatchVideoDataInterval: null,
  458. activityWatchVideoLastStatus: "",
  459. activityWatchVideoLastStartDuration: "",
  460. genres: [
  461. "Blues",
  462. "Country",
  463. "Disco",
  464. "Funk",
  465. "Hip-Hop",
  466. "Jazz",
  467. "Metal",
  468. "Oldies",
  469. "Other",
  470. "Pop",
  471. "Rap",
  472. "Reggae",
  473. "Rock",
  474. "Techno",
  475. "Trance",
  476. "Classical",
  477. "Instrumental",
  478. "House",
  479. "Electronic",
  480. "Christian Rap",
  481. "Lo-Fi",
  482. "Musical",
  483. "Rock 'n' Roll",
  484. "Opera",
  485. "Drum & Bass",
  486. "Club-House",
  487. "Indie",
  488. "Heavy Metal",
  489. "Christian rock",
  490. "Dubstep"
  491. ]
  492. };
  493. },
  494. computed: {
  495. ...mapState("modals/editSong", {
  496. tab: state => state.tab,
  497. video: state => state.video,
  498. song: state => state.song,
  499. originalSong: state => state.originalSong,
  500. reports: state => state.reports
  501. }),
  502. ...mapState("modalVisibility", {
  503. modals: state => state.modals
  504. }),
  505. ...mapGetters({
  506. socket: "websockets/getSocket"
  507. })
  508. },
  509. watch: {
  510. /* eslint-disable */
  511. "song.duration": function() {
  512. this.drawCanvas();
  513. },
  514. "song.skipDuration": function() {
  515. this.drawCanvas();
  516. }
  517. /* eslint-enable */
  518. },
  519. async mounted() {
  520. // if (this.modals.editSong = false) this.video.player.stopVideo();
  521. // this.loadVideoById(
  522. // this.song.youtubeId,
  523. // this.song.skipDuration
  524. // );
  525. this.activityWatchVideoDataInterval = setInterval(() => {
  526. this.sendActivityWatchVideoData();
  527. }, 1000);
  528. this.useHTTPS = await lofig.get("cookie.secure");
  529. this.socket.dispatch(`songs.getSongFromSongId`, this.song._id, res => {
  530. if (res.status === "success") {
  531. const { song } = res.data;
  532. // this.song = { ...song };
  533. // if (this.song.discogs === undefined)
  534. // this.song.discogs = null;
  535. this.editSong(song);
  536. this.songDataLoaded = true;
  537. this.socket.dispatch(
  538. "apis.joinRoom",
  539. `edit-song.${this.song._id}`
  540. );
  541. // this.edit(res.data.song);
  542. this.interval = setInterval(() => {
  543. if (
  544. this.song.duration !== -1 &&
  545. this.video.paused === false &&
  546. this.playerReady &&
  547. (this.video.player.getCurrentTime() -
  548. this.song.skipDuration >
  549. this.song.duration ||
  550. (this.video.player.getCurrentTime() > 0 &&
  551. this.video.player.getCurrentTime() >=
  552. this.video.player.getDuration()))
  553. ) {
  554. this.video.paused = true;
  555. this.video.player.stopVideo();
  556. this.drawCanvas();
  557. }
  558. if (this.playerReady) {
  559. this.youtubeVideoCurrentTime = this.video.player
  560. .getCurrentTime()
  561. .toFixed(3);
  562. }
  563. if (this.video.paused === false) this.drawCanvas();
  564. }, 200);
  565. if (window.YT && window.YT.Player) {
  566. this.video.player = new window.YT.Player("editSongPlayer", {
  567. height: 298,
  568. width: 530,
  569. videoId: this.song.youtubeId,
  570. host: "https://www.youtube-nocookie.com",
  571. playerVars: {
  572. controls: 0,
  573. iv_load_policy: 3,
  574. rel: 0,
  575. showinfo: 0,
  576. autoplay: 0
  577. },
  578. startSeconds: this.song.skipDuration,
  579. events: {
  580. onReady: () => {
  581. let volume = parseInt(
  582. localStorage.getItem("volume")
  583. );
  584. volume =
  585. typeof volume === "number" ? volume : 20;
  586. this.video.player.setVolume(volume);
  587. if (volume > 0) this.video.player.unMute();
  588. const duration = this.video.player.getDuration();
  589. this.youtubeVideoDuration = duration.toFixed(3);
  590. this.youtubeVideoNote = "(~)";
  591. this.playerReady = true;
  592. this.drawCanvas();
  593. },
  594. onStateChange: event => {
  595. this.drawCanvas();
  596. let skipToLast10SecsPressed = false;
  597. if (
  598. event.data === 1 &&
  599. this.skipToLast10SecsPressed
  600. ) {
  601. this.skipToLast10SecsPressed = false;
  602. skipToLast10SecsPressed = true;
  603. }
  604. if (
  605. event.data === 1 &&
  606. !skipToLast10SecsPressed
  607. ) {
  608. this.video.paused = false;
  609. let youtubeDuration = this.video.player.getDuration();
  610. const newYoutubeVideoDuration = youtubeDuration.toFixed(
  611. 3
  612. );
  613. const songDurationNumber = Number(
  614. this.song.duration
  615. );
  616. const songDurationNumber2 =
  617. Number(this.song.duration) + 1;
  618. const songDurationNumber3 =
  619. Number(this.song.duration) - 1;
  620. const fixedSongDuration = songDurationNumber.toFixed(
  621. 3
  622. );
  623. const fixedSongDuration2 = songDurationNumber2.toFixed(
  624. 3
  625. );
  626. const fixedSongDuration3 = songDurationNumber3.toFixed(
  627. 3
  628. );
  629. if (
  630. this.youtubeVideoDuration !==
  631. newYoutubeVideoDuration &&
  632. (fixedSongDuration ===
  633. this.youtubeVideoDuration ||
  634. fixedSongDuration2 ===
  635. this.youtubeVideoDuration ||
  636. fixedSongDuration3 ===
  637. this.youtubeVideoDuration)
  638. )
  639. this.song.duration = newYoutubeVideoDuration;
  640. this.youtubeVideoDuration = newYoutubeVideoDuration;
  641. this.youtubeVideoNote = "";
  642. if (this.song.duration === -1)
  643. this.song.duration = youtubeDuration;
  644. youtubeDuration -= this.song.skipDuration;
  645. if (
  646. this.song.duration >
  647. youtubeDuration + 1
  648. ) {
  649. this.video.player.stopVideo();
  650. this.video.paused = true;
  651. return new Toast(
  652. "Video can't play. Specified duration is bigger than the YouTube song duration."
  653. );
  654. }
  655. if (this.song.duration <= 0) {
  656. this.video.player.stopVideo();
  657. this.video.paused = true;
  658. return new Toast(
  659. "Video can't play. Specified duration has to be more than 0 seconds."
  660. );
  661. }
  662. if (
  663. this.video.player.getCurrentTime() <
  664. this.song.skipDuration
  665. ) {
  666. return this.video.player.seekTo(
  667. this.song.skipDuration
  668. );
  669. }
  670. } else if (event.data === 2) {
  671. this.video.paused = true;
  672. }
  673. return false;
  674. }
  675. }
  676. });
  677. } else {
  678. this.youtubeError = true;
  679. this.youtubeErrorMessage = "Player could not be loaded.";
  680. }
  681. } else {
  682. new Toast("Song with that ID not found");
  683. this.closeModal("editSong");
  684. }
  685. });
  686. this.socket.dispatch(
  687. "reports.getReportsForSong",
  688. this.song._id,
  689. res => {
  690. this.updateReports(res.data.reports);
  691. }
  692. );
  693. let volume = parseFloat(localStorage.getItem("volume"));
  694. volume =
  695. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  696. localStorage.setItem("volume", volume);
  697. this.volumeSliderValue = volume * 100;
  698. this.socket.on(
  699. "event:admin.hiddenSong.created",
  700. res => {
  701. this.song.status = res.data.song.status;
  702. },
  703. { modal: "editSong" }
  704. );
  705. this.socket.on(
  706. "event:admin.unverifiedSong.created",
  707. res => {
  708. this.song.status = res.data.song.status;
  709. },
  710. { modal: "editSong" }
  711. );
  712. this.socket.on(
  713. "event:admin.verifiedSong.created",
  714. res => {
  715. this.song.status = res.data.song.status;
  716. },
  717. { modal: "editSong" }
  718. );
  719. this.socket.on(
  720. "event:admin.hiddenSong.deleted",
  721. () => {
  722. new Toast("The song you were editing was removed");
  723. this.closeModal("editSong");
  724. },
  725. { modal: "editSong" }
  726. );
  727. this.socket.on(
  728. "event:admin.unverifiedSong.deleted",
  729. () => {
  730. new Toast("The song you were editing was removed");
  731. this.closeModal("editSong");
  732. },
  733. { modal: "editSong" }
  734. );
  735. this.socket.on(
  736. "event:admin.verifiedSong.deleted",
  737. () => {
  738. new Toast("The song you were editing was removed");
  739. this.closeModal("editSong");
  740. },
  741. { modal: "editSong" }
  742. );
  743. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  744. keyCode: 101,
  745. preventDefault: true,
  746. handler: () => {
  747. if (this.video.paused) this.play();
  748. else this.settings("pause");
  749. }
  750. });
  751. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  752. keyCode: 101,
  753. ctrl: true,
  754. preventDefault: true,
  755. handler: () => {
  756. this.settings("stop");
  757. }
  758. });
  759. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  760. keyCode: 102,
  761. preventDefault: true,
  762. handler: () => {
  763. this.settings("skipToLast10Secs");
  764. }
  765. });
  766. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  767. keyCode: 98,
  768. preventDefault: true,
  769. handler: () => {
  770. this.volumeSliderValue = Math.max(
  771. 0,
  772. this.volumeSliderValue - 1000
  773. );
  774. this.changeVolume();
  775. }
  776. });
  777. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  778. keyCode: 98,
  779. ctrl: true,
  780. preventDefault: true,
  781. handler: () => {
  782. this.volumeSliderValue = Math.max(
  783. 0,
  784. this.volumeSliderValue - 100
  785. );
  786. this.changeVolume();
  787. }
  788. });
  789. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  790. keyCode: 104,
  791. preventDefault: true,
  792. handler: () => {
  793. this.volumeSliderValue = Math.min(
  794. 10000,
  795. this.volumeSliderValue + 1000
  796. );
  797. this.changeVolume();
  798. }
  799. });
  800. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  801. keyCode: 104,
  802. ctrl: true,
  803. preventDefault: true,
  804. handler: () => {
  805. this.volumeSliderValue = Math.min(
  806. 10000,
  807. this.volumeSliderValue + 100
  808. );
  809. this.changeVolume();
  810. }
  811. });
  812. keyboardShortcuts.registerShortcut("editSong.save", {
  813. keyCode: 83,
  814. ctrl: true,
  815. preventDefault: true,
  816. handler: () => {
  817. this.save(this.song, false);
  818. }
  819. });
  820. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  821. keyCode: 83,
  822. ctrl: true,
  823. alt: true,
  824. preventDefault: true,
  825. handler: () => {
  826. this.save(this.song, true);
  827. }
  828. });
  829. keyboardShortcuts.registerShortcut("editSong.saveVerifyClose", {
  830. keyCode: 86,
  831. ctrl: true,
  832. alt: true,
  833. preventDefault: true,
  834. handler: () => {
  835. // alert("not implemented yet");
  836. }
  837. });
  838. keyboardShortcuts.registerShortcut("editSong.close", {
  839. keyCode: 115,
  840. preventDefault: true,
  841. handler: () => {
  842. this.closeModal("editSong");
  843. setTimeout(() => {
  844. window.focusedElementBefore.focus();
  845. }, 500);
  846. }
  847. });
  848. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  849. keyCode: 36,
  850. preventDefault: true,
  851. handler: () => {
  852. this.$refs["title-input"].focus();
  853. }
  854. });
  855. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  856. keyCode: 68,
  857. alt: true,
  858. ctrl: true,
  859. preventDefault: true,
  860. handler: () => {
  861. this.getAlbumData("title");
  862. this.getAlbumData("albumArt");
  863. this.getAlbumData("artists");
  864. this.getAlbumData("genres");
  865. }
  866. });
  867. /*
  868. editSong.pauseResume - Num 5 - Pause/resume song
  869. editSong.stopVideo - Ctrl - Num 5 - Stop
  870. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  871. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  872. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  873. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  874. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  875. editSong.focusTitle - Home - Focus the title input
  876. editSong.focusDicogs - End - Focus the discogs input
  877. editSong.save - Ctrl - S - Saves song
  878. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  879. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  880. editSong.close - F4 - Closes modal without saving
  881. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  882. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  883. */
  884. },
  885. beforeUnmount() {
  886. this.playerReady = false;
  887. clearInterval(this.interval);
  888. clearInterval(this.activityWatchVideoDataInterval);
  889. this.socket.dispatch("apis.leaveRoom", `edit-song.${this.song._id}`);
  890. const shortcutNames = [
  891. "editSong.pauseResume",
  892. "editSong.stopVideo",
  893. "editSong.skipToLast10Secs",
  894. "editSong.lowerVolumeLarge",
  895. "editSong.lowerVolumeSmall",
  896. "editSong.increaseVolumeLarge",
  897. "editSong.increaseVolumeSmall",
  898. "editSong.focusTitle",
  899. "editSong.focusDicogs",
  900. "editSong.save",
  901. "editSong.saveClose",
  902. "editSong.saveVerifyClose",
  903. "editSong.close",
  904. "editSong.useAllDiscogs"
  905. ];
  906. shortcutNames.forEach(shortcutName => {
  907. keyboardShortcuts.unregisterShortcut(shortcutName);
  908. });
  909. },
  910. methods: {
  911. save(songToCopy, close) {
  912. const song = JSON.parse(JSON.stringify(songToCopy));
  913. let saveButtonRef = this.$refs.saveButton;
  914. if (close) saveButtonRef = this.$refs.saveAndCloseButton;
  915. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  916. saveButtonRef.handleFailedSave();
  917. return new Toast("The video appears to not be working.");
  918. }
  919. if (!song.title) {
  920. saveButtonRef.handleFailedSave();
  921. return new Toast("Please fill in all fields");
  922. }
  923. if (!song.thumbnail) {
  924. saveButtonRef.handleFailedSave();
  925. return new Toast("Please fill in all fields");
  926. }
  927. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  928. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  929. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  930. // saveButtonRef.handleFailedSave();
  931. // return new Toast(
  932. // "Thumbnail width and height must be at least 80px."
  933. // );
  934. // }
  935. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  936. // saveButtonRef.handleFailedSave();
  937. // return new Toast(
  938. // "Thumbnail width and height must be less than 4000px."
  939. // );
  940. // }
  941. // if (thumbnailHeight - thumbnailWidth > 5) {
  942. // saveButtonRef.handleFailedSave();
  943. // return new Toast("Thumbnail cannot be taller than it is wide.");
  944. // }
  945. // Youtube Id
  946. if (
  947. this.youtubeError &&
  948. this.originalSong.youtubeId !== song.youtubeId
  949. ) {
  950. saveButtonRef.handleFailedSave();
  951. return new Toast(
  952. "You're not allowed to change the YouTube id while the player is not working"
  953. );
  954. }
  955. // Duration
  956. if (
  957. Number(song.skipDuration) + Number(song.duration) >
  958. this.youtubeVideoDuration &&
  959. (!this.youtubeError ||
  960. this.originalSong.duration !== song.duration)
  961. ) {
  962. saveButtonRef.handleFailedSave();
  963. return new Toast(
  964. "Duration can't be higher than the length of the video"
  965. );
  966. }
  967. // Title
  968. if (!validation.isLength(song.title, 1, 100)) {
  969. saveButtonRef.handleFailedSave();
  970. return new Toast(
  971. "Title must have between 1 and 100 characters."
  972. );
  973. }
  974. // Artists
  975. if (song.artists.length < 1 || song.artists.length > 10) {
  976. saveButtonRef.handleFailedSave();
  977. return new Toast(
  978. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  979. );
  980. }
  981. let error;
  982. song.artists.forEach(artist => {
  983. if (!validation.isLength(artist, 1, 64)) {
  984. error = "Artist must have between 1 and 64 characters.";
  985. return error;
  986. }
  987. if (artist === "NONE") {
  988. error =
  989. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  990. return error;
  991. }
  992. return false;
  993. });
  994. if (error) {
  995. saveButtonRef.handleFailedSave();
  996. return new Toast(error);
  997. }
  998. // Genres
  999. error = undefined;
  1000. song.genres.forEach(genre => {
  1001. if (!validation.isLength(genre, 1, 32)) {
  1002. error = "Genre must have between 1 and 32 characters.";
  1003. return error;
  1004. }
  1005. if (!validation.regex.ascii.test(genre)) {
  1006. error =
  1007. "Invalid genre format. Only ascii characters are allowed.";
  1008. return error;
  1009. }
  1010. return false;
  1011. });
  1012. if (song.genres.length < 1 || song.genres.length > 16)
  1013. error = "You must have between 1 and 16 genres.";
  1014. if (error) {
  1015. saveButtonRef.handleFailedSave();
  1016. return new Toast(error);
  1017. }
  1018. // Thumbnail
  1019. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1020. saveButtonRef.handleFailedSave();
  1021. return new Toast(
  1022. "Thumbnail must have between 8 and 256 characters."
  1023. );
  1024. }
  1025. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1026. saveButtonRef.handleFailedSave();
  1027. return new Toast('Thumbnail must start with "https://".');
  1028. }
  1029. if (
  1030. !this.useHTTPS &&
  1031. song.thumbnail.indexOf("http://") !== 0 &&
  1032. song.thumbnail.indexOf("https://") !== 0
  1033. ) {
  1034. saveButtonRef.handleFailedSave();
  1035. return new Toast('Thumbnail must start with "http://".');
  1036. }
  1037. saveButtonRef.status = "disabled";
  1038. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1039. new Toast(res.message);
  1040. if (res.status === "success")
  1041. saveButtonRef.handleSuccessfulSave();
  1042. else saveButtonRef.handleFailedSave();
  1043. if (close) this.closeModal("editSong");
  1044. });
  1045. },
  1046. getAlbumData(type) {
  1047. if (!this.song.discogs) return;
  1048. if (type === "title")
  1049. this.updateSongField({
  1050. field: "title",
  1051. value: this.song.discogs.track.title
  1052. });
  1053. if (type === "albumArt")
  1054. this.updateSongField({
  1055. field: "thumbnail",
  1056. value: this.song.discogs.album.albumArt
  1057. });
  1058. if (type === "genres")
  1059. this.updateSongField({
  1060. field: "genres",
  1061. value: JSON.parse(
  1062. JSON.stringify(this.song.discogs.album.genres)
  1063. )
  1064. });
  1065. if (type === "artists")
  1066. this.updateSongField({
  1067. field: "artists",
  1068. value: JSON.parse(
  1069. JSON.stringify(this.song.discogs.album.artists)
  1070. )
  1071. });
  1072. },
  1073. fillDuration() {
  1074. this.song.duration =
  1075. this.youtubeVideoDuration - this.song.skipDuration;
  1076. },
  1077. blurArtistInput() {
  1078. this.artistInputFocussed = false;
  1079. },
  1080. focusArtistInput() {
  1081. this.artistInputFocussed = true;
  1082. },
  1083. blurArtistContainer() {
  1084. this.artistAutosuggestContainerFocussed = false;
  1085. },
  1086. focusArtistContainer() {
  1087. this.artistAutosuggestContainerFocussed = true;
  1088. },
  1089. keydownArtistInput() {
  1090. clearTimeout(this.keydownArtistInputTimeout);
  1091. this.keydownArtistInputTimeout = setTimeout(() => {
  1092. // Do things here to query the artist
  1093. }, 1000);
  1094. },
  1095. selectArtistAutosuggest(value) {
  1096. this.artistInputValue = value;
  1097. },
  1098. blurGenreInput() {
  1099. this.genreInputFocussed = false;
  1100. },
  1101. focusGenreInput() {
  1102. this.genreInputFocussed = true;
  1103. },
  1104. blurGenreContainer() {
  1105. this.genreAutosuggestContainerFocussed = false;
  1106. },
  1107. focusGenreContainer() {
  1108. this.genreAutosuggestContainerFocussed = true;
  1109. },
  1110. keydownGenreInput() {
  1111. clearTimeout(this.keydownGenreInputTimeout);
  1112. this.keydownGenreInputTimeout = setTimeout(() => {
  1113. if (this.genreInputValue.length > 1) {
  1114. this.genreAutosuggestItems = this.genres.filter(genre => {
  1115. return genre
  1116. .toLowerCase()
  1117. .startsWith(this.genreInputValue.toLowerCase());
  1118. });
  1119. } else this.genreAutosuggestItems = [];
  1120. }, 1000);
  1121. },
  1122. selectGenreAutosuggest(value) {
  1123. this.genreInputValue = value;
  1124. },
  1125. settings(type) {
  1126. switch (type) {
  1127. default:
  1128. break;
  1129. case "stop":
  1130. this.stopVideo();
  1131. this.pauseVideo(true);
  1132. break;
  1133. case "pause":
  1134. this.pauseVideo(true);
  1135. break;
  1136. case "play":
  1137. this.pauseVideo(false);
  1138. break;
  1139. case "skipToLast10Secs":
  1140. this.skipToLast10SecsPressed = true;
  1141. if (this.video.paused) this.pauseVideo(false);
  1142. this.video.player.seekTo(
  1143. this.song.duration - 10 + this.song.skipDuration
  1144. );
  1145. break;
  1146. }
  1147. },
  1148. play() {
  1149. if (
  1150. this.video.player.getVideoData().video_id !==
  1151. this.song.youtubeId
  1152. ) {
  1153. this.song.duration = -1;
  1154. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1155. }
  1156. this.settings("play");
  1157. },
  1158. changeVolume() {
  1159. const volume = this.volumeSliderValue;
  1160. localStorage.setItem("volume", volume / 100);
  1161. this.video.player.setVolume(volume / 100);
  1162. if (volume > 0) this.video.player.unMute();
  1163. },
  1164. addTag(type) {
  1165. if (type === "genres") {
  1166. const genre = this.genreInputValue.trim();
  1167. if (
  1168. this.song.genres
  1169. .map(genre => genre.toLowerCase())
  1170. .indexOf(genre.toLowerCase()) !== -1
  1171. )
  1172. return new Toast("Genre already exists");
  1173. if (genre) {
  1174. this.song.genres.push(genre);
  1175. this.genreInputValue = "";
  1176. return false;
  1177. }
  1178. return new Toast("Genre cannot be empty");
  1179. }
  1180. if (type === "artists") {
  1181. const artist = this.artistInputValue;
  1182. if (this.song.artists.indexOf(artist) !== -1)
  1183. return new Toast("Artist already exists");
  1184. if (artist !== "") {
  1185. this.song.artists.push(artist);
  1186. this.artistInputValue = "";
  1187. return false;
  1188. }
  1189. return new Toast("Artist cannot be empty");
  1190. }
  1191. return false;
  1192. },
  1193. removeTag(type, value) {
  1194. if (type === "genres")
  1195. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1196. else if (type === "artists")
  1197. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1198. },
  1199. drawCanvas() {
  1200. const canvasElement = this.$refs.durationCanvas;
  1201. const ctx = canvasElement.getContext("2d");
  1202. const videoDuration = Number(this.youtubeVideoDuration);
  1203. const skipDuration = Number(this.song.skipDuration);
  1204. const duration = Number(this.song.duration);
  1205. const afterDuration = videoDuration - (skipDuration + duration);
  1206. const width = 530;
  1207. const currentTime =
  1208. this.video.player && this.video.player.getCurrentTime
  1209. ? this.video.player.getCurrentTime()
  1210. : 0;
  1211. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1212. const widthDuration = (duration / videoDuration) * width;
  1213. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1214. const widthCurrentTime = (currentTime / videoDuration) * width;
  1215. const skipDurationColor = "#F42003";
  1216. const durationColor = "#03A9F4";
  1217. const afterDurationColor = "#41E841";
  1218. const currentDurationColor = "#3b25e8";
  1219. ctx.fillStyle = skipDurationColor;
  1220. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1221. ctx.fillStyle = durationColor;
  1222. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1223. ctx.fillStyle = afterDurationColor;
  1224. ctx.fillRect(
  1225. widthSkipDuration + widthDuration,
  1226. 0,
  1227. widthAfterDuration,
  1228. 20
  1229. );
  1230. ctx.fillStyle = currentDurationColor;
  1231. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1232. },
  1233. toggleGenreHelper() {
  1234. this.$refs.genreHelper.toggleBox();
  1235. },
  1236. resetGenreHelper() {
  1237. this.$refs.genreHelper.resetBox();
  1238. },
  1239. sendActivityWatchVideoData() {
  1240. if (!this.video.paused) {
  1241. if (this.activityWatchVideoLastStatus !== "playing") {
  1242. this.activityWatchVideoLastStatus = "playing";
  1243. if (
  1244. this.song.skipDuration > 0 &&
  1245. parseFloat(this.youtubeVideoCurrentTime) === 0
  1246. ) {
  1247. this.activityWatchVideoLastStartDuration = Math.floor(
  1248. this.song.skipDuration +
  1249. parseFloat(this.youtubeVideoCurrentTime)
  1250. );
  1251. } else {
  1252. this.activityWatchVideoLastStartDuration = Math.floor(
  1253. parseFloat(this.youtubeVideoCurrentTime)
  1254. );
  1255. }
  1256. }
  1257. const videoData = {
  1258. title: this.song.title,
  1259. artists: this.song.artists
  1260. ? this.song.artists.join(", ")
  1261. : null,
  1262. youtubeId: this.song.youtubeId,
  1263. muted: this.muted,
  1264. volume: this.volumeSliderValue / 100,
  1265. startedDuration:
  1266. this.activityWatchVideoLastStartDuration <= 0
  1267. ? 0
  1268. : this.activityWatchVideoLastStartDuration,
  1269. source: `editSong#${this.song.youtubeId}`,
  1270. hostname: window.location.hostname
  1271. };
  1272. aw.sendVideoData(videoData);
  1273. } else {
  1274. this.activityWatchVideoLastStatus = "not_playing";
  1275. }
  1276. },
  1277. verify(id) {
  1278. this.socket.dispatch("songs.verify", id, res => {
  1279. new Toast(res.message);
  1280. });
  1281. },
  1282. unverify(id) {
  1283. this.socket.dispatch("songs.unverify", id, res => {
  1284. new Toast(res.message);
  1285. });
  1286. },
  1287. hide(id) {
  1288. this.socket.dispatch("songs.hide", id, res => {
  1289. new Toast(res.message);
  1290. });
  1291. },
  1292. unhide(id) {
  1293. this.socket.dispatch("songs.unhide", id, res => {
  1294. new Toast(res.message);
  1295. });
  1296. },
  1297. // remove(id) {
  1298. // this.socket.dispatch("songs.remove", id, res => {
  1299. // new Toast(res.message);
  1300. // });
  1301. // },
  1302. ...mapActions({
  1303. showTab(dispatch, payload) {
  1304. this.$refs[`${payload}-tab`].scrollIntoView();
  1305. return dispatch("modals/editSong/showTab", payload);
  1306. }
  1307. }),
  1308. ...mapActions("modals/editSong", [
  1309. "stopVideo",
  1310. "loadVideoById",
  1311. "pauseVideo",
  1312. "getCurrentTime",
  1313. "editSong",
  1314. "updateSongField",
  1315. "updateReports"
  1316. ]),
  1317. ...mapActions("modalVisibility", ["closeModal"])
  1318. }
  1319. };
  1320. </script>
  1321. <style lang="scss">
  1322. .song-modal {
  1323. .modal-card-title {
  1324. text-align: center;
  1325. margin-left: 24px;
  1326. }
  1327. .modal-card {
  1328. width: 1160px;
  1329. height: 100%;
  1330. .modal-card-body {
  1331. padding: 16px;
  1332. display: flex;
  1333. }
  1334. .modal-card-foot {
  1335. .right {
  1336. display: flex;
  1337. margin-left: auto;
  1338. margin-right: 0;
  1339. }
  1340. }
  1341. }
  1342. }
  1343. </style>
  1344. <style lang="scss" scoped>
  1345. .night-mode {
  1346. .edit-section,
  1347. .api-section,
  1348. .api-result,
  1349. .player-footer {
  1350. background-color: var(--dark-grey-3) !important;
  1351. }
  1352. .api-result .tracks .track:hover,
  1353. .selected-discogs-info {
  1354. background-color: var(--dark-grey-2) !important;
  1355. }
  1356. .label,
  1357. p,
  1358. strong {
  1359. color: var(--light-grey-2);
  1360. }
  1361. }
  1362. .modal-card-body > div {
  1363. display: flex;
  1364. height: 100%;
  1365. }
  1366. .left-section {
  1367. display: flex;
  1368. flex-direction: column;
  1369. margin-right: 16px;
  1370. .top-section {
  1371. display: flex;
  1372. .player-section {
  1373. width: 530px;
  1374. display: flex;
  1375. flex-direction: column;
  1376. .player-error {
  1377. height: 318px;
  1378. width: 530px;
  1379. display: block;
  1380. border: 1px rgba(163, 224, 255, 0.75) solid;
  1381. border-radius: 5px 5px 0px 0px;
  1382. display: flex;
  1383. align-items: center;
  1384. * {
  1385. margin: 0;
  1386. flex: 1;
  1387. font-size: 30px;
  1388. text-align: center;
  1389. }
  1390. }
  1391. .player-footer {
  1392. background-color: var(--light-grey);
  1393. border: 1px rgba(163, 224, 255, 0.75) solid;
  1394. border-radius: 0px 0px 5px 5px;
  1395. display: flex;
  1396. justify-content: space-between;
  1397. height: 54px;
  1398. > * {
  1399. width: 33.3%;
  1400. display: flex;
  1401. align-items: center;
  1402. }
  1403. .player-footer-left {
  1404. flex: 1;
  1405. .material-icons {
  1406. font-size: 38px;
  1407. cursor: pointer;
  1408. }
  1409. .player-play-pause {
  1410. color: var(--primary-color);
  1411. }
  1412. .player-stop {
  1413. color: var(--red);
  1414. }
  1415. .player-fast-forward {
  1416. color: var(--green);
  1417. }
  1418. }
  1419. .player-footer-center {
  1420. justify-content: center;
  1421. align-items: center;
  1422. flex: 2;
  1423. font-size: 21px;
  1424. font-weight: 400;
  1425. img {
  1426. height: 21px;
  1427. margin-right: 12px;
  1428. filter: invert(26%) sepia(54%) saturate(6317%)
  1429. hue-rotate(2deg) brightness(92%) contrast(115%);
  1430. }
  1431. }
  1432. .player-footer-right {
  1433. justify-content: right;
  1434. flex: 1;
  1435. #volumeSlider {
  1436. width: 126px;
  1437. margin-right: 10px;
  1438. background-color: var(--light-grey);
  1439. }
  1440. }
  1441. }
  1442. }
  1443. .thumbnail-preview {
  1444. width: 189px;
  1445. height: 189px;
  1446. margin-left: 16px;
  1447. }
  1448. }
  1449. .edit-section {
  1450. width: 735px;
  1451. background-color: var(--light-grey);
  1452. border: 1px rgba(163, 224, 255, 0.75) solid;
  1453. margin-top: 16px;
  1454. flex: 1;
  1455. overflow: auto;
  1456. border-radius: 5px;
  1457. .album-get-button {
  1458. background-color: var(--purple);
  1459. color: var(--white);
  1460. width: 32px;
  1461. text-align: center;
  1462. border-width: 0;
  1463. }
  1464. .duration-fill-button {
  1465. background-color: var(--red);
  1466. color: var(--white);
  1467. width: 32px;
  1468. text-align: center;
  1469. border-width: 0;
  1470. }
  1471. .add-button {
  1472. background-color: var(--primary-color) !important;
  1473. width: 32px;
  1474. i {
  1475. font-size: 32px;
  1476. }
  1477. }
  1478. .album-get-button,
  1479. .duration-fill-button,
  1480. .add-button {
  1481. &:focus,
  1482. &:hover {
  1483. filter: contrast(0.75);
  1484. border: 1px solid var(--black) !important;
  1485. }
  1486. }
  1487. > div {
  1488. margin: 16px;
  1489. }
  1490. input {
  1491. width: 100%;
  1492. }
  1493. .title-container {
  1494. width: calc((100% - 32px) / 2);
  1495. }
  1496. .duration-container {
  1497. margin-right: 16px;
  1498. margin-left: 16px;
  1499. width: calc((100% - 32px) / 4);
  1500. }
  1501. .skip-duration-container {
  1502. width: calc((100% - 32px) / 4);
  1503. }
  1504. .album-art-container {
  1505. width: 100%;
  1506. }
  1507. .artists-container {
  1508. width: calc((100% - 32px) / 3);
  1509. position: relative;
  1510. }
  1511. .genres-container {
  1512. width: calc((100% - 32px) / 3);
  1513. margin-left: 16px;
  1514. margin-right: 16px;
  1515. position: relative;
  1516. label {
  1517. display: flex;
  1518. i {
  1519. font-size: 15px;
  1520. align-self: center;
  1521. margin-left: 5px;
  1522. color: var(--primary-color);
  1523. cursor: pointer;
  1524. -webkit-user-select: none;
  1525. -moz-user-select: none;
  1526. -ms-user-select: none;
  1527. user-select: none;
  1528. }
  1529. }
  1530. }
  1531. .youtube-id-container {
  1532. width: calc((100% - 32px) / 3);
  1533. }
  1534. .list-item-circle {
  1535. background-color: var(--primary-color);
  1536. width: 16px;
  1537. height: 16px;
  1538. border-radius: 8px;
  1539. cursor: pointer;
  1540. margin-right: 8px;
  1541. float: left;
  1542. -webkit-touch-callout: none;
  1543. -webkit-user-select: none;
  1544. -khtml-user-select: none;
  1545. -moz-user-select: none;
  1546. -ms-user-select: none;
  1547. user-select: none;
  1548. i {
  1549. color: var(--primary-color);
  1550. font-size: 14px;
  1551. margin-left: 1px;
  1552. }
  1553. }
  1554. .list-item-circle:hover,
  1555. .list-item-circle:focus {
  1556. i {
  1557. color: var(--white);
  1558. }
  1559. }
  1560. .list-item > p {
  1561. line-height: 16px;
  1562. word-wrap: break-word;
  1563. width: calc(100% - 24px);
  1564. left: 24px;
  1565. float: left;
  1566. margin-bottom: 8px;
  1567. }
  1568. .list-item:last-child > p {
  1569. margin-bottom: 0;
  1570. }
  1571. .autosuggest-container {
  1572. position: absolute;
  1573. background: var(--white);
  1574. width: calc(100% + 1px);
  1575. top: 57px;
  1576. z-index: 200;
  1577. overflow: auto;
  1578. max-height: 100%;
  1579. clear: both;
  1580. .autosuggest-item {
  1581. padding: 8px;
  1582. display: block;
  1583. border: 1px solid var(--light-grey-2);
  1584. margin-top: -1px;
  1585. line-height: 16px;
  1586. cursor: pointer;
  1587. -webkit-user-select: none;
  1588. -ms-user-select: none;
  1589. -moz-user-select: none;
  1590. user-select: none;
  1591. }
  1592. .autosuggest-item:hover,
  1593. .autosuggest-item:focus {
  1594. background-color: var(--light-grey);
  1595. }
  1596. .autosuggest-item:first-child {
  1597. border-top: none;
  1598. }
  1599. .autosuggest-item:last-child {
  1600. border-radius: 0 0 3px 3px;
  1601. }
  1602. }
  1603. }
  1604. }
  1605. .right-section {
  1606. display: flex;
  1607. flex-wrap: wrap;
  1608. #tabs-container {
  1609. width: 376px;
  1610. background-color: var(--light-grey);
  1611. border: 1px rgba(163, 224, 255, 0.75) solid;
  1612. border-radius: 5px;
  1613. // padding: 16px;
  1614. overflow: auto;
  1615. height: 100%;
  1616. #tab-selection {
  1617. display: flex;
  1618. overflow-x: auto;
  1619. .button {
  1620. border-radius: 5px 5px 0 0;
  1621. border: 0;
  1622. text-transform: uppercase;
  1623. font-size: 14px;
  1624. color: var(--dark-grey-3);
  1625. background-color: var(--light-grey-2);
  1626. flex-grow: 1;
  1627. height: 32px;
  1628. &:not(:first-of-type) {
  1629. margin-left: 5px;
  1630. }
  1631. }
  1632. .selected {
  1633. background-color: var(--primary-color) !important;
  1634. color: var(--white) !important;
  1635. font-weight: 600;
  1636. }
  1637. }
  1638. .tab {
  1639. // border: 1px solid var(--light-grey-3);
  1640. padding: 15px;
  1641. // border-radius: 0 0 5px 5px;
  1642. }
  1643. }
  1644. // .api-section {
  1645. // width: 376px;
  1646. // background-color: var(--light-grey);
  1647. // border: 1px rgba(163, 224, 255, 0.75) solid;
  1648. // border-radius: 5px;
  1649. // padding: 16px;
  1650. // overflow: auto;
  1651. // height: 100%;
  1652. // > label {
  1653. // margin-top: 12px;
  1654. // }
  1655. // .top-container {
  1656. // display: flex;
  1657. // img {
  1658. // height: 85px;
  1659. // width: 85px;
  1660. // }
  1661. // .right-container {
  1662. // padding: 8px;
  1663. // display: flex;
  1664. // flex-direction: column;
  1665. // flex: 1;
  1666. // .album-title {
  1667. // flex: 1;
  1668. // font-weight: 600;
  1669. // }
  1670. // .bottom-row {
  1671. // display: flex;
  1672. // flex-flow: row;
  1673. // line-height: 15px;
  1674. // img {
  1675. // height: 15px;
  1676. // align-self: end;
  1677. // flex: 1;
  1678. // user-select: none;
  1679. // -moz-user-select: none;
  1680. // -ms-user-select: none;
  1681. // -webkit-user-select: none;
  1682. // cursor: pointer;
  1683. // }
  1684. // p {
  1685. // text-align: right;
  1686. // }
  1687. // .type-year {
  1688. // font-size: 13px;
  1689. // align-self: end;
  1690. // }
  1691. // }
  1692. // }
  1693. // }
  1694. // .bottom-container {
  1695. // padding: 12px;
  1696. // .bottom-container-field {
  1697. // line-height: 16px;
  1698. // margin-bottom: 8px;
  1699. // font-weight: 600;
  1700. // span {
  1701. // font-weight: 400;
  1702. // }
  1703. // }
  1704. // .bottom-container-field:last-of-type {
  1705. // margin-bottom: 0;
  1706. // }
  1707. // }
  1708. // .selected-discogs-info {
  1709. // background-color: var(--white);
  1710. // border: 1px solid var(--purple);
  1711. // border-radius: 5px;
  1712. // margin-bottom: 16px;
  1713. // .selected-discogs-info-none {
  1714. // font-size: 18px;
  1715. // text-align: center;
  1716. // }
  1717. // .bottom-row > p {
  1718. // flex: 1;
  1719. // }
  1720. // }
  1721. // .api-result {
  1722. // background-color: var(--white);
  1723. // border: 0.5px solid var(--primary-color);
  1724. // border-radius: 5px;
  1725. // margin-bottom: 16px;
  1726. // }
  1727. // button {
  1728. // background-color: var(--primary-color) !important;
  1729. // &:focus,
  1730. // &:hover {
  1731. // filter: contrast(0.75);
  1732. // }
  1733. // }
  1734. // .tracks {
  1735. // margin-top: 12px;
  1736. // .track:first-child {
  1737. // margin-top: 0;
  1738. // border-radius: 3px 3px 0 0;
  1739. // }
  1740. // .track:last-child {
  1741. // border-radius: 0 0 3px 3px;
  1742. // }
  1743. // .track {
  1744. // border: 0.5px solid var(--black);
  1745. // margin-top: -1px;
  1746. // line-height: 16px;
  1747. // display: flex;
  1748. // cursor: pointer;
  1749. // span {
  1750. // font-weight: 600;
  1751. // display: inline-block;
  1752. // margin-top: 7px;
  1753. // margin-bottom: 7px;
  1754. // margin-left: 7px;
  1755. // }
  1756. // p {
  1757. // display: inline-block;
  1758. // margin: 7px;
  1759. // flex: 1;
  1760. // }
  1761. // }
  1762. // .track:hover,
  1763. // .track:focus {
  1764. // background-color: var(--light-grey);
  1765. // }
  1766. // }
  1767. // .discogs-load-more {
  1768. // margin-bottom: 8px;
  1769. // }
  1770. // }
  1771. }
  1772. .modal-card-foot .is-primary {
  1773. width: 200px;
  1774. }
  1775. input[type="range"] {
  1776. -webkit-appearance: none;
  1777. width: 100%;
  1778. margin: 8.5px 0;
  1779. }
  1780. input[type="range"]:focus {
  1781. outline-style: outset;
  1782. }
  1783. input[type="range"]::-webkit-slider-runnable-track {
  1784. width: 100%;
  1785. height: 3px;
  1786. cursor: pointer;
  1787. box-shadow: none;
  1788. background: var(--grey-3);
  1789. border-radius: none;
  1790. border: none;
  1791. }
  1792. input[type="range"]::-webkit-slider-thumb {
  1793. box-shadow: none;
  1794. border: none;
  1795. height: 20px;
  1796. width: 20px;
  1797. border-radius: 100px;
  1798. background: var(--primary-color);
  1799. cursor: pointer;
  1800. -webkit-appearance: none;
  1801. margin-top: -8.5px;
  1802. }
  1803. input[type="range"]:focus::-webkit-slider-runnable-track {
  1804. background: var(--grey-3);
  1805. }
  1806. input[type="range"]::-moz-range-track {
  1807. width: 100%;
  1808. height: 3px;
  1809. cursor: pointer;
  1810. box-shadow: none;
  1811. background: var(--grey-3);
  1812. border-radius: none;
  1813. border: none;
  1814. }
  1815. input[type="range"]::-moz-range-thumb {
  1816. box-shadow: none;
  1817. border: none;
  1818. height: 20px;
  1819. width: 20px;
  1820. border-radius: 100px;
  1821. background: var(--primary-color);
  1822. cursor: pointer;
  1823. }
  1824. input[type="range"]::-ms-track {
  1825. width: 100%;
  1826. height: 3px;
  1827. cursor: pointer;
  1828. background: transparent;
  1829. border-color: transparent;
  1830. color: transparent;
  1831. }
  1832. input[type="range"]::-ms-fill-lower {
  1833. background: var(--grey-2);
  1834. border: none;
  1835. border-radius: none;
  1836. box-shadow: none;
  1837. }
  1838. input[type="range"]::-ms-fill-upper {
  1839. background: var(--grey-3);
  1840. border: none;
  1841. border-radius: none;
  1842. box-shadow: none;
  1843. }
  1844. input[type="range"]::-ms-thumb {
  1845. box-shadow: none;
  1846. border: none;
  1847. height: 20px;
  1848. width: 20px;
  1849. border-radius: 100px;
  1850. background: var(--primary-color);
  1851. cursor: pointer;
  1852. height: 3px;
  1853. }
  1854. input[type="range"]:focus::-ms-fill-lower {
  1855. background: var(--grey-3);
  1856. }
  1857. input[type="range"]:focus::-ms-fill-upper {
  1858. background: var(--grey-3);
  1859. }
  1860. </style>