index.vue 48 KB

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