index.vue 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470
  1. <template>
  2. <div>
  3. <modal
  4. :title="`${newSong ? 'Create' : 'Edit'} Song`"
  5. class="song-modal"
  6. :size="'wide'"
  7. :split="true"
  8. :intercept-close="true"
  9. @close="onCloseModal"
  10. >
  11. <template #toggleMobileSidebar>
  12. <slot name="toggleMobileSidebar" />
  13. </template>
  14. <template #sidebar>
  15. <slot name="sidebar" />
  16. </template>
  17. <template #body>
  18. <div v-if="!songId && !newSong" class="notice-container">
  19. <h4>No song has been selected</h4>
  20. </div>
  21. <div v-if="songDeleted" class="notice-container">
  22. <h4>The song you were editing has been deleted</h4>
  23. </div>
  24. <div
  25. v-if="
  26. songId && !songDataLoaded && !songNotFound && !newSong
  27. "
  28. class="notice-container"
  29. >
  30. <h4>Song hasn't loaded yet</h4>
  31. </div>
  32. <div
  33. v-if="songId && songNotFound && !newSong"
  34. class="notice-container"
  35. >
  36. <h4>Song was not found</h4>
  37. </div>
  38. <div
  39. class="left-section"
  40. v-show="songDataLoaded && !songDeleted"
  41. >
  42. <div class="top-section">
  43. <div class="player-section">
  44. <div id="editSongPlayer" />
  45. <div v-show="youtubeError" class="player-error">
  46. <h2>{{ youtubeErrorMessage }}</h2>
  47. </div>
  48. <canvas
  49. ref="durationCanvas"
  50. id="durationCanvas"
  51. v-show="!youtubeError"
  52. height="20"
  53. width="530"
  54. @click="setTrackPosition($event)"
  55. />
  56. <div class="player-footer">
  57. <div class="player-footer-left">
  58. <button
  59. class="button is-primary"
  60. @click="play()"
  61. @keyup.enter="play()"
  62. v-if="video.paused"
  63. content="Resume Playback"
  64. v-tippy
  65. >
  66. <i class="material-icons">play_arrow</i>
  67. </button>
  68. <button
  69. class="button is-primary"
  70. @click="settings('pause')"
  71. @keyup.enter="settings('pause')"
  72. v-else
  73. content="Pause Playback"
  74. v-tippy
  75. >
  76. <i class="material-icons">pause</i>
  77. </button>
  78. <button
  79. class="button is-danger"
  80. @click.exact="settings('stop')"
  81. @click.shift="settings('hardStop')"
  82. @keyup.enter.exact="settings('stop')"
  83. @keyup.shift.enter="
  84. settings('hardStop')
  85. "
  86. content="Stop Playback"
  87. v-tippy
  88. >
  89. <i class="material-icons">stop</i>
  90. </button>
  91. <tippy
  92. class="playerRateDropdown"
  93. :touch="true"
  94. :interactive="true"
  95. placement="bottom"
  96. theme="dropdown"
  97. ref="dropdown"
  98. trigger="click"
  99. append-to="parent"
  100. @show="
  101. () => {
  102. showRateDropdown = true;
  103. }
  104. "
  105. @hide="
  106. () => {
  107. showRateDropdown = false;
  108. }
  109. "
  110. >
  111. <div
  112. ref="trigger"
  113. class="control has-addons"
  114. content="Set Playback Rate"
  115. v-tippy
  116. >
  117. <button class="button is-primary">
  118. <i class="material-icons"
  119. >fast_forward</i
  120. >
  121. </button>
  122. <button
  123. class="button dropdown-toggle"
  124. >
  125. <i class="material-icons">
  126. {{
  127. showRateDropdown
  128. ? "expand_more"
  129. : "expand_less"
  130. }}
  131. </i>
  132. </button>
  133. </div>
  134. <template #content>
  135. <div class="nav-dropdown-items">
  136. <button
  137. class="nav-item button"
  138. :class="{
  139. active:
  140. video.playbackRate ===
  141. 0.5
  142. }"
  143. title="0.5x"
  144. @click="
  145. setPlaybackRate(0.5)
  146. "
  147. >
  148. <p>0.5x</p>
  149. </button>
  150. <button
  151. class="nav-item button"
  152. :class="{
  153. active:
  154. video.playbackRate ===
  155. 1
  156. }"
  157. title="1x"
  158. @click="setPlaybackRate(1)"
  159. >
  160. <p>1x</p>
  161. </button>
  162. <button
  163. class="nav-item button"
  164. :class="{
  165. active:
  166. video.playbackRate ===
  167. 2
  168. }"
  169. title="2x"
  170. @click="setPlaybackRate(2)"
  171. >
  172. <p>2x</p>
  173. </button>
  174. </div>
  175. </template>
  176. </tippy>
  177. </div>
  178. <div class="player-footer-center">
  179. <span>
  180. <span>
  181. {{ youtubeVideoCurrentTime }}
  182. </span>
  183. /
  184. <span>
  185. {{ youtubeVideoDuration }}
  186. {{ youtubeVideoNote }}
  187. </span>
  188. </span>
  189. </div>
  190. <div class="player-footer-right">
  191. <p id="volume-control">
  192. <i
  193. class="material-icons"
  194. @click="toggleMute()"
  195. :content="`${
  196. muted ? 'Unmute' : 'Mute'
  197. }`"
  198. v-tippy
  199. >{{
  200. muted
  201. ? "volume_mute"
  202. : volumeSliderValue >= 50
  203. ? "volume_up"
  204. : "volume_down"
  205. }}</i
  206. >
  207. <input
  208. v-model="volumeSliderValue"
  209. type="range"
  210. min="0"
  211. max="100"
  212. class="volume-slider active"
  213. @change="changeVolume()"
  214. @input="changeVolume()"
  215. />
  216. </p>
  217. </div>
  218. </div>
  219. </div>
  220. <song-thumbnail
  221. v-if="songDataLoaded && !songDeleted"
  222. :song="song"
  223. :fallback="false"
  224. class="thumbnail-preview"
  225. />
  226. <img
  227. v-if="!isYoutubeThumbnail && !songDeleted"
  228. class="thumbnail-dummy"
  229. :src="song.thumbnail"
  230. ref="thumbnailElement"
  231. @load="onThumbnailLoad"
  232. />
  233. </div>
  234. <div
  235. class="edit-section"
  236. v-if="songDataLoaded && !songDeleted"
  237. >
  238. <div class="control is-grouped">
  239. <div class="title-container">
  240. <label class="label">Title</label>
  241. <p class="control has-addons">
  242. <input
  243. class="input"
  244. type="text"
  245. ref="title-input"
  246. v-model="song.title"
  247. placeholder="Enter song title..."
  248. @keyup.shift.enter="
  249. getAlbumData('title')
  250. "
  251. />
  252. <button
  253. class="button youtube-get-button"
  254. @click="getYouTubeData('title')"
  255. >
  256. <div
  257. class="youtube-icon"
  258. v-tippy
  259. content="Fill from YouTube"
  260. ></div>
  261. </button>
  262. <button
  263. class="button album-get-button"
  264. @click="getAlbumData('title')"
  265. >
  266. <i
  267. class="material-icons"
  268. v-tippy
  269. content="Fill from Discogs"
  270. >album</i
  271. >
  272. </button>
  273. </p>
  274. </div>
  275. <div class="duration-container">
  276. <label class="label">Duration</label>
  277. <p class="control has-addons">
  278. <input
  279. class="input"
  280. type="text"
  281. placeholder="Enter song duration..."
  282. v-model.number="song.duration"
  283. @keyup.shift.enter="fillDuration()"
  284. />
  285. <button
  286. class="button duration-fill-button"
  287. @click="fillDuration()"
  288. >
  289. <i
  290. class="material-icons"
  291. v-tippy
  292. content="Sync duration with YouTube"
  293. >sync</i
  294. >
  295. </button>
  296. </p>
  297. </div>
  298. <div class="skip-duration-container">
  299. <label class="label">Skip duration</label>
  300. <p class="control">
  301. <input
  302. class="input"
  303. type="text"
  304. placeholder="Enter skip duration..."
  305. v-model.number="song.skipDuration"
  306. />
  307. </p>
  308. </div>
  309. </div>
  310. <div class="control is-grouped">
  311. <div class="album-art-container">
  312. <label class="label">
  313. Thumbnail
  314. <i
  315. v-if="
  316. thumbnailNotSquare &&
  317. !isYoutubeThumbnail
  318. "
  319. class="material-icons thumbnail-warning"
  320. content="Thumbnail not square, it will be stretched"
  321. v-tippy="{ theme: 'info' }"
  322. >
  323. warning
  324. </i>
  325. </label>
  326. <p class="control has-addons">
  327. <input
  328. class="input"
  329. type="text"
  330. v-model="song.thumbnail"
  331. placeholder="Enter link to thumbnail..."
  332. @keyup.shift.enter="
  333. getAlbumData('albumArt')
  334. "
  335. />
  336. <button
  337. class="button youtube-get-button"
  338. @click="getYouTubeData('thumbnail')"
  339. >
  340. <div
  341. class="youtube-icon"
  342. v-tippy
  343. content="Fill from YouTube"
  344. ></div>
  345. </button>
  346. <button
  347. class="button album-get-button"
  348. @click="getAlbumData('albumArt')"
  349. >
  350. <i
  351. class="material-icons"
  352. v-tippy
  353. content="Fill from Discogs"
  354. >album</i
  355. >
  356. </button>
  357. </p>
  358. </div>
  359. <div class="youtube-id-container">
  360. <label class="label">YouTube ID</label>
  361. <p class="control">
  362. <input
  363. class="input"
  364. type="text"
  365. placeholder="Enter YouTube ID..."
  366. v-model="song.youtubeId"
  367. />
  368. </p>
  369. </div>
  370. <div class="verified-container">
  371. <label class="label">Verified</label>
  372. <p class="is-expanded checkbox-control">
  373. <label class="switch">
  374. <input
  375. type="checkbox"
  376. id="verified"
  377. v-model="song.verified"
  378. />
  379. <span class="slider round"></span>
  380. </label>
  381. </p>
  382. </div>
  383. </div>
  384. <div class="control is-grouped">
  385. <div class="artists-container">
  386. <label class="label">Artists</label>
  387. <p class="control has-addons">
  388. <auto-suggest
  389. v-model="artistInputValue"
  390. ref="new-artist"
  391. placeholder="Add artist..."
  392. :all-items="
  393. autosuggest.allItems.artists
  394. "
  395. @submitted="addTag('artists')"
  396. @keyup.shift.enter="
  397. getAlbumData('artists')
  398. "
  399. />
  400. <button
  401. class="button album-get-button"
  402. @click="getAlbumData('artists')"
  403. >
  404. <i
  405. class="material-icons"
  406. v-tippy
  407. content="Fill from Discogs"
  408. >album</i
  409. >
  410. </button>
  411. <button
  412. class="button is-info add-button"
  413. @click="addTag('artists')"
  414. >
  415. <i class="material-icons">add</i>
  416. </button>
  417. </p>
  418. <div class="list-container">
  419. <div
  420. class="list-item"
  421. v-for="artist in song.artists"
  422. :key="artist"
  423. >
  424. <div
  425. class="list-item-circle"
  426. @click="
  427. removeTag('artists', artist)
  428. "
  429. >
  430. <i class="material-icons">close</i>
  431. </div>
  432. <p>{{ artist }}</p>
  433. </div>
  434. </div>
  435. </div>
  436. <div class="genres-container">
  437. <label class="label">
  438. <span>Genres</span>
  439. <i
  440. class="material-icons"
  441. @click="toggleGenreHelper"
  442. @dblclick="resetGenreHelper"
  443. v-tippy
  444. content="View list of genres"
  445. >info</i
  446. >
  447. </label>
  448. <p class="control has-addons">
  449. <auto-suggest
  450. v-model="genreInputValue"
  451. ref="new-genre"
  452. placeholder="Add genre..."
  453. :all-items="autosuggest.allItems.genres"
  454. @submitted="addTag('genres')"
  455. @keyup.shift.enter="
  456. getAlbumData('genres')
  457. "
  458. />
  459. <button
  460. class="button album-get-button"
  461. @click="getAlbumData('genres')"
  462. >
  463. <i
  464. class="material-icons"
  465. v-tippy
  466. content="Fill from Discogs"
  467. >album</i
  468. >
  469. </button>
  470. <button
  471. class="button is-info add-button"
  472. @click="addTag('genres')"
  473. >
  474. <i class="material-icons">add</i>
  475. </button>
  476. </p>
  477. <div class="list-container">
  478. <div
  479. class="list-item"
  480. v-for="genre in song.genres"
  481. :key="genre"
  482. >
  483. <div
  484. class="list-item-circle"
  485. @click="removeTag('genres', genre)"
  486. >
  487. <i class="material-icons">close</i>
  488. </div>
  489. <p>{{ genre }}</p>
  490. </div>
  491. </div>
  492. </div>
  493. <div class="tags-container">
  494. <label class="label">Tags</label>
  495. <p class="control has-addons">
  496. <auto-suggest
  497. v-model="tagInputValue"
  498. ref="new-tag"
  499. placeholder="Add tag..."
  500. :all-items="autosuggest.allItems.tags"
  501. @submitted="addTag('tags')"
  502. />
  503. <button
  504. class="button is-info add-button"
  505. @click="addTag('tags')"
  506. >
  507. <i class="material-icons">add</i>
  508. </button>
  509. </p>
  510. <div class="list-container">
  511. <div
  512. class="list-item"
  513. v-for="tag in song.tags"
  514. :key="tag"
  515. >
  516. <div
  517. class="list-item-circle"
  518. @click="removeTag('tags', tag)"
  519. >
  520. <i class="material-icons">close</i>
  521. </div>
  522. <p>{{ tag }}</p>
  523. </div>
  524. </div>
  525. </div>
  526. </div>
  527. </div>
  528. </div>
  529. <div
  530. class="right-section"
  531. v-if="songDataLoaded && !songDeleted"
  532. >
  533. <div id="tabs-container">
  534. <div id="tab-selection">
  535. <button
  536. class="button is-default"
  537. :class="{ selected: tab === 'discogs' }"
  538. ref="discogs-tab"
  539. @click="showTab('discogs')"
  540. >
  541. Discogs
  542. </button>
  543. <button
  544. v-if="!newSong"
  545. class="button is-default"
  546. :class="{ selected: tab === 'reports' }"
  547. ref="reports-tab"
  548. @click="showTab('reports')"
  549. >
  550. Reports ({{ reports.length }})
  551. </button>
  552. <button
  553. class="button is-default"
  554. :class="{ selected: tab === 'youtube' }"
  555. ref="youtube-tab"
  556. @click="showTab('youtube')"
  557. >
  558. YouTube
  559. </button>
  560. <button
  561. class="button is-default"
  562. :class="{ selected: tab === 'musare-songs' }"
  563. ref="musare-songs-tab"
  564. @click="showTab('musare-songs')"
  565. >
  566. Songs
  567. </button>
  568. </div>
  569. <discogs
  570. class="tab"
  571. v-show="tab === 'discogs'"
  572. :bulk="bulk"
  573. :modal-uuid="modalUuid"
  574. :modal-module-path="modalModulePath"
  575. />
  576. <reports
  577. v-if="!newSong"
  578. class="tab"
  579. v-show="tab === 'reports'"
  580. :modal-uuid="modalUuid"
  581. :modal-module-path="modalModulePath"
  582. />
  583. <youtube
  584. class="tab"
  585. v-show="tab === 'youtube'"
  586. :modal-uuid="modalUuid"
  587. :modal-module-path="modalModulePath"
  588. />
  589. <musare-songs
  590. class="tab"
  591. v-show="tab === 'musare-songs'"
  592. :modal-uuid="modalUuid"
  593. :modal-module-path="modalModulePath"
  594. />
  595. </div>
  596. </div>
  597. </template>
  598. <template #footer>
  599. <div v-if="bulk">
  600. <button class="button is-primary" @click="editNextSong()">
  601. Next
  602. </button>
  603. <button
  604. class="button is-primary"
  605. @click="toggleFlag()"
  606. v-if="songId && !songDeleted"
  607. >
  608. {{ flagged ? "Unflag" : "Flag" }}
  609. </button>
  610. </div>
  611. <div v-if="!newSong && !songDeleted">
  612. <save-button
  613. ref="saveButton"
  614. @clicked="save(song, false, 'saveButton')"
  615. />
  616. <save-button
  617. ref="saveAndCloseButton"
  618. :default-message="
  619. bulk ? `Save and next` : `Save and close`
  620. "
  621. @clicked="save(song, true, 'saveAndCloseButton')"
  622. />
  623. <div class="right">
  624. <button
  625. class="button is-danger icon-with-button material-icons"
  626. @click.prevent="
  627. confirmAction({
  628. message:
  629. 'Removing this song will remove it from all playlists and cause a ratings recalculation.',
  630. action: 'remove',
  631. params: song._id
  632. })
  633. "
  634. content="Delete Song"
  635. v-tippy
  636. >
  637. delete_forever
  638. </button>
  639. </div>
  640. </div>
  641. <div v-else-if="newSong">
  642. <save-button
  643. ref="createButton"
  644. default-message="Create Song"
  645. @clicked="save(song, false, 'createButton', true)"
  646. />
  647. </div>
  648. </template>
  649. </modal>
  650. <floating-box id="genreHelper" ref="genreHelper" :column="false">
  651. <template #body>
  652. <span
  653. v-for="item in autosuggest.allItems.genres"
  654. :key="`genre-helper-${item}`"
  655. >
  656. {{ item }}
  657. </span>
  658. </template>
  659. </floating-box>
  660. </div>
  661. </template>
  662. <script>
  663. import { mapState, mapGetters, mapActions } from "vuex";
  664. import Toast from "toasters";
  665. import { mapModalState, mapModalActions } from "@/vuex_helpers";
  666. import aw from "@/aw";
  667. import ws from "@/ws";
  668. import validation from "@/validation";
  669. import keyboardShortcuts from "@/keyboardShortcuts";
  670. import FloatingBox from "../../FloatingBox.vue";
  671. import SaveButton from "../../SaveButton.vue";
  672. import AutoSuggest from "@/components/AutoSuggest.vue";
  673. import Discogs from "./Tabs/Discogs.vue";
  674. import Reports from "./Tabs/Reports.vue";
  675. import Youtube from "./Tabs/Youtube.vue";
  676. import MusareSongs from "./Tabs/Songs.vue";
  677. export default {
  678. components: {
  679. FloatingBox,
  680. SaveButton,
  681. AutoSuggest,
  682. Discogs,
  683. Reports,
  684. Youtube,
  685. MusareSongs
  686. },
  687. props: {
  688. // songId: { type: String, default: null },
  689. modalUuid: { type: String, default: "" },
  690. modalModulePath: {
  691. type: String,
  692. default: "modals/editSong/MODAL_UUID"
  693. },
  694. discogsAlbum: { type: Object, default: null },
  695. bulk: { type: Boolean, default: false },
  696. flagged: { type: Boolean, default: false }
  697. },
  698. emits: [
  699. "error",
  700. "savedSuccess",
  701. "savedError",
  702. "flagSong",
  703. "nextSong",
  704. "close"
  705. ],
  706. data() {
  707. return {
  708. songDataLoaded: false,
  709. songDeleted: false,
  710. youtubeError: false,
  711. youtubeErrorMessage: "",
  712. focusedElementBefore: null,
  713. youtubeVideoDuration: "0.000",
  714. youtubeVideoCurrentTime: 0,
  715. youtubeVideoNote: "",
  716. useHTTPS: false,
  717. muted: false,
  718. volumeSliderValue: 0,
  719. artistInputValue: "",
  720. genreInputValue: "",
  721. tagInputValue: "",
  722. activityWatchVideoDataInterval: null,
  723. activityWatchVideoLastStatus: "",
  724. activityWatchVideoLastStartDuration: "",
  725. recommendedGenres: [
  726. "Blues",
  727. "Country",
  728. "Disco",
  729. "Funk",
  730. "Hip-Hop",
  731. "Jazz",
  732. "Metal",
  733. "Oldies",
  734. "Other",
  735. "Pop",
  736. "Rap",
  737. "Reggae",
  738. "Rock",
  739. "Techno",
  740. "Trance",
  741. "Classical",
  742. "Instrumental",
  743. "House",
  744. "Electronic",
  745. "Christian Rap",
  746. "Lo-Fi",
  747. "Musical",
  748. "Rock 'n' Roll",
  749. "Opera",
  750. "Drum & Bass",
  751. "Club-House",
  752. "Indie",
  753. "Heavy Metal",
  754. "Christian rock",
  755. "Dubstep"
  756. ],
  757. autosuggest: {
  758. allItems: {
  759. artists: [],
  760. genres: [],
  761. tags: []
  762. }
  763. },
  764. songNotFound: false,
  765. showRateDropdown: false,
  766. thumbnailNotSquare: false,
  767. thumbnailWidth: null,
  768. thumbnailHeight: null
  769. };
  770. },
  771. computed: {
  772. isYoutubeThumbnail() {
  773. return (
  774. this.songDataLoaded &&
  775. this.song.youtubeId &&
  776. this.song.thumbnail &&
  777. (this.song.thumbnail.lastIndexOf("i.ytimg.com") !== -1 ||
  778. this.song.thumbnail.lastIndexOf("img.youtube.com") !== -1)
  779. );
  780. },
  781. ...mapModalState("MODAL_MODULE_PATH", {
  782. tab: state => state.tab,
  783. video: state => state.video,
  784. song: state => state.song,
  785. songId: state => state.songId,
  786. prefillData: state => state.prefillData,
  787. originalSong: state => state.originalSong,
  788. reports: state => state.reports,
  789. newSong: state => state.newSong
  790. }),
  791. ...mapState("modalVisibility", {
  792. activeModals: state => state.activeModals
  793. }),
  794. ...mapGetters({
  795. socket: "websockets/getSocket"
  796. })
  797. },
  798. watch: {
  799. /* eslint-disable */
  800. "song.duration": function () {
  801. this.drawCanvas();
  802. },
  803. "song.skipDuration": function () {
  804. this.drawCanvas();
  805. },
  806. /* eslint-enable */
  807. songId(songId, oldSongId) {
  808. console.log("NEW SONG ID", songId);
  809. this.unloadSong(oldSongId);
  810. this.loadSong(songId);
  811. }
  812. },
  813. async mounted() {
  814. console.log("MOUNTED");
  815. this.activityWatchVideoDataInterval = setInterval(() => {
  816. this.sendActivityWatchVideoData();
  817. }, 1000);
  818. this.useHTTPS = await lofig.get("cookie.secure");
  819. ws.onConnect(this.init);
  820. let volume = parseFloat(localStorage.getItem("volume"));
  821. volume =
  822. typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  823. localStorage.setItem("volume", volume);
  824. this.volumeSliderValue = volume;
  825. if (!this.newSong) {
  826. this.socket.on(
  827. "event:admin.song.removed",
  828. res => {
  829. if (res.data.songId === this.song._id) {
  830. this.songDeleted = true;
  831. }
  832. },
  833. { modalUuid: this.modalUuid }
  834. );
  835. }
  836. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  837. keyCode: 101,
  838. preventDefault: true,
  839. handler: () => {
  840. if (this.video.paused) this.play();
  841. else this.settings("pause");
  842. }
  843. });
  844. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  845. keyCode: 101,
  846. ctrl: true,
  847. preventDefault: true,
  848. handler: () => {
  849. this.settings("stop");
  850. }
  851. });
  852. keyboardShortcuts.registerShortcut("editSong.hardStopVideo", {
  853. keyCode: 101,
  854. ctrl: true,
  855. shift: true,
  856. preventDefault: true,
  857. handler: () => {
  858. this.settings("hardStop");
  859. }
  860. });
  861. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  862. keyCode: 102,
  863. preventDefault: true,
  864. handler: () => {
  865. this.settings("skipToLast10Secs");
  866. }
  867. });
  868. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  869. keyCode: 98,
  870. preventDefault: true,
  871. handler: () => {
  872. this.volumeSliderValue = Math.max(
  873. 0,
  874. this.volumeSliderValue - 10
  875. );
  876. this.changeVolume();
  877. }
  878. });
  879. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  880. keyCode: 98,
  881. ctrl: true,
  882. preventDefault: true,
  883. handler: () => {
  884. this.volumeSliderValue = Math.max(
  885. 0,
  886. this.volumeSliderValue - 1
  887. );
  888. this.changeVolume();
  889. }
  890. });
  891. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  892. keyCode: 104,
  893. preventDefault: true,
  894. handler: () => {
  895. this.volumeSliderValue = Math.min(
  896. 100,
  897. this.volumeSliderValue + 10
  898. );
  899. this.changeVolume();
  900. }
  901. });
  902. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  903. keyCode: 104,
  904. ctrl: true,
  905. preventDefault: true,
  906. handler: () => {
  907. this.volumeSliderValue = Math.min(
  908. 100,
  909. this.volumeSliderValue + 1
  910. );
  911. this.changeVolume();
  912. }
  913. });
  914. keyboardShortcuts.registerShortcut("editSong.save", {
  915. keyCode: 83,
  916. ctrl: true,
  917. preventDefault: true,
  918. handler: () => {
  919. this.save(this.song, false, "saveButton");
  920. }
  921. });
  922. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  923. keyCode: 83,
  924. ctrl: true,
  925. alt: true,
  926. preventDefault: true,
  927. handler: () => {
  928. this.save(this.song, true, "saveAndCloseButton");
  929. }
  930. });
  931. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  932. keyCode: 36,
  933. preventDefault: true,
  934. handler: () => {
  935. this.$refs["title-input"].focus();
  936. }
  937. });
  938. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  939. keyCode: 68,
  940. alt: true,
  941. ctrl: true,
  942. preventDefault: true,
  943. handler: () => {
  944. this.getAlbumData("title");
  945. this.getAlbumData("albumArt");
  946. this.getAlbumData("artists");
  947. this.getAlbumData("genres");
  948. }
  949. });
  950. keyboardShortcuts.registerShortcut("editSong.closeModal", {
  951. keyCode: 27,
  952. handler: () => {
  953. if (
  954. this.modals[
  955. this.activeModals[this.activeModals.length - 1]
  956. ] === "editSong" ||
  957. this.modals[
  958. this.activeModals[this.activeModals.length - 1]
  959. ] === "editSongs"
  960. ) {
  961. this.onCloseModal();
  962. }
  963. }
  964. });
  965. /*
  966. editSong.pauseResume - Num 5 - Pause/resume song
  967. editSong.stopVideo - Ctrl - Num 5 - Stop
  968. editSong.hardStopVideo - Shift - Ctrl - Num 5 - Stop
  969. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  970. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  971. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  972. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  973. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  974. editSong.focusTitle - Home - Focus the title input
  975. editSong.focusDicogs - End - Focus the discogs input
  976. editSong.save - Ctrl - S - Saves song
  977. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  978. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  979. editSong.close - F4 - Closes modal without saving
  980. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  981. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  982. */
  983. },
  984. beforeUnmount() {
  985. console.log("UNMOUNT");
  986. if (!this.newSong) this.unloadSong(this.songId);
  987. this.playerReady = false;
  988. clearInterval(this.interval);
  989. clearInterval(this.activityWatchVideoDataInterval);
  990. const shortcutNames = [
  991. "editSong.pauseResume",
  992. "editSong.stopVideo",
  993. "editSong.hardStopVideo",
  994. "editSong.skipToLast10Secs",
  995. "editSong.lowerVolumeLarge",
  996. "editSong.lowerVolumeSmall",
  997. "editSong.increaseVolumeLarge",
  998. "editSong.increaseVolumeSmall",
  999. "editSong.focusTitle",
  1000. "editSong.focusDicogs",
  1001. "editSong.save",
  1002. "editSong.saveClose",
  1003. "editSong.useAllDiscogs",
  1004. "editSong.closeModal"
  1005. ];
  1006. shortcutNames.forEach(shortcutName => {
  1007. keyboardShortcuts.unregisterShortcut(shortcutName);
  1008. });
  1009. if (!this.bulk) {
  1010. // Delete the VueX module that was created for this modal, after all other cleanup tasks are performed
  1011. this.$store.unregisterModule([
  1012. "modals",
  1013. "editSong",
  1014. this.modalUuid
  1015. ]);
  1016. }
  1017. },
  1018. methods: {
  1019. onThumbnailLoad() {
  1020. if (this.$refs.thumbnailElement) {
  1021. const thumbnailHeight =
  1022. this.$refs.thumbnailElement.naturalHeight;
  1023. const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  1024. this.thumbnailNotSquare = thumbnailHeight !== thumbnailWidth;
  1025. this.thumbnailHeight = thumbnailHeight;
  1026. this.thumbnailWidth = thumbnailWidth;
  1027. } else {
  1028. this.thumbnailNotSquare = false;
  1029. this.thumbnailHeight = null;
  1030. this.thumbnailWidth = null;
  1031. }
  1032. },
  1033. init() {
  1034. if (this.newSong) {
  1035. this.setSong({
  1036. youtubeId: "",
  1037. title: "",
  1038. artists: [],
  1039. genres: [],
  1040. tags: [],
  1041. duration: 0,
  1042. skipDuration: 0,
  1043. thumbnail: "",
  1044. verified: false
  1045. });
  1046. this.songDataLoaded = true;
  1047. this.showTab("youtube");
  1048. } else if (this.songId) this.loadSong(this.songId);
  1049. else if (!this.bulk) {
  1050. new Toast("You can't open EditSong without editing a song");
  1051. return this.closeModal("editSong");
  1052. }
  1053. this.interval = setInterval(() => {
  1054. if (
  1055. this.song.duration !== -1 &&
  1056. this.video.paused === false &&
  1057. this.playerReady &&
  1058. (this.video.player.getCurrentTime() -
  1059. this.song.skipDuration >
  1060. this.song.duration ||
  1061. (this.video.player.getCurrentTime() > 0 &&
  1062. this.video.player.getCurrentTime() >=
  1063. this.video.player.getDuration()))
  1064. ) {
  1065. this.stopVideo();
  1066. this.pauseVideo(true);
  1067. this.drawCanvas();
  1068. }
  1069. if (
  1070. this.playerReady &&
  1071. this.video.player.getVideoData &&
  1072. this.video.player.getVideoData() &&
  1073. this.video.player.getVideoData().video_id ===
  1074. this.song.youtubeId
  1075. ) {
  1076. const currentTime = this.video.player.getCurrentTime();
  1077. if (currentTime !== undefined)
  1078. this.youtubeVideoCurrentTime = currentTime.toFixed(3);
  1079. if (this.youtubeVideoDuration.indexOf(".000") !== -1) {
  1080. const duration = this.video.player.getDuration();
  1081. if (duration !== undefined) {
  1082. if (
  1083. `${this.youtubeVideoDuration}` ===
  1084. `${Number(this.song.duration).toFixed(3)}`
  1085. )
  1086. this.song.duration = duration.toFixed(3);
  1087. this.youtubeVideoDuration = duration.toFixed(3);
  1088. if (
  1089. this.youtubeVideoDuration.indexOf(".000") !== -1
  1090. )
  1091. this.youtubeVideoNote = "(~)";
  1092. else this.youtubeVideoNote = "";
  1093. this.drawCanvas();
  1094. }
  1095. }
  1096. }
  1097. if (this.video.paused === false) this.drawCanvas();
  1098. }, 200);
  1099. if (window.YT && window.YT.Player) {
  1100. this.video.player = new window.YT.Player("editSongPlayer", {
  1101. height: 298,
  1102. width: 530,
  1103. videoId: null,
  1104. host: "https://www.youtube-nocookie.com",
  1105. playerVars: {
  1106. controls: 0,
  1107. iv_load_policy: 3,
  1108. rel: 0,
  1109. showinfo: 0,
  1110. autoplay: 0
  1111. },
  1112. startSeconds: this.song.skipDuration,
  1113. events: {
  1114. onReady: () => {
  1115. let volume = parseFloat(
  1116. localStorage.getItem("volume")
  1117. );
  1118. volume = typeof volume === "number" ? volume : 20;
  1119. this.video.player.setVolume(volume);
  1120. if (volume > 0) this.video.player.unMute();
  1121. this.playerReady = true;
  1122. if (this.song && this.song._id)
  1123. this.video.player.cueVideoById(
  1124. this.song.youtubeId,
  1125. this.song.skipDuration
  1126. );
  1127. this.setPlaybackRate(null);
  1128. this.drawCanvas();
  1129. },
  1130. onStateChange: event => {
  1131. this.drawCanvas();
  1132. if (event.data === 1) {
  1133. this.video.paused = false;
  1134. let youtubeDuration =
  1135. this.video.player.getDuration();
  1136. const newYoutubeVideoDuration =
  1137. youtubeDuration.toFixed(3);
  1138. if (
  1139. this.youtubeVideoDuration.indexOf(
  1140. ".000"
  1141. ) !== -1 &&
  1142. `${this.youtubeVideoDuration}` !==
  1143. `${newYoutubeVideoDuration}`
  1144. ) {
  1145. const songDurationNumber = Number(
  1146. this.song.duration
  1147. );
  1148. const songDurationNumber2 =
  1149. Number(this.song.duration) + 1;
  1150. const songDurationNumber3 =
  1151. Number(this.song.duration) - 1;
  1152. const fixedSongDuration =
  1153. songDurationNumber.toFixed(3);
  1154. const fixedSongDuration2 =
  1155. songDurationNumber2.toFixed(3);
  1156. const fixedSongDuration3 =
  1157. songDurationNumber3.toFixed(3);
  1158. if (
  1159. `${this.youtubeVideoDuration}` ===
  1160. `${Number(
  1161. this.song.duration
  1162. ).toFixed(3)}` &&
  1163. (fixedSongDuration ===
  1164. this.youtubeVideoDuration ||
  1165. fixedSongDuration2 ===
  1166. this.youtubeVideoDuration ||
  1167. fixedSongDuration3 ===
  1168. this.youtubeVideoDuration)
  1169. )
  1170. this.song.duration =
  1171. newYoutubeVideoDuration;
  1172. this.youtubeVideoDuration =
  1173. newYoutubeVideoDuration;
  1174. if (
  1175. this.youtubeVideoDuration.indexOf(
  1176. ".000"
  1177. ) !== -1
  1178. )
  1179. this.youtubeVideoNote = "(~)";
  1180. else this.youtubeVideoNote = "";
  1181. }
  1182. if (this.song.duration === -1)
  1183. this.song.duration =
  1184. this.youtubeVideoDuration;
  1185. youtubeDuration -= this.song.skipDuration;
  1186. if (this.song.duration > youtubeDuration + 1) {
  1187. this.stopVideo();
  1188. this.pauseVideo(true);
  1189. return new Toast(
  1190. "Video can't play. Specified duration is bigger than the YouTube song duration."
  1191. );
  1192. }
  1193. if (this.song.duration <= 0) {
  1194. this.stopVideo();
  1195. this.pauseVideo(true);
  1196. return new Toast(
  1197. "Video can't play. Specified duration has to be more than 0 seconds."
  1198. );
  1199. }
  1200. if (
  1201. this.video.player.getCurrentTime() <
  1202. this.song.skipDuration
  1203. ) {
  1204. return this.seekTo(this.song.skipDuration);
  1205. }
  1206. this.setPlaybackRate(null);
  1207. } else if (event.data === 2) {
  1208. this.video.paused = true;
  1209. }
  1210. return false;
  1211. }
  1212. }
  1213. });
  1214. } else {
  1215. this.youtubeError = true;
  1216. this.youtubeErrorMessage = "Player could not be loaded.";
  1217. }
  1218. ["artists", "genres", "tags"].forEach(type => {
  1219. this.socket.dispatch(
  1220. `songs.get${type.charAt(0).toUpperCase()}${type.slice(1)}`,
  1221. res => {
  1222. if (res.status === "success") {
  1223. const { items } = res.data;
  1224. if (type === "genres")
  1225. this.autosuggest.allItems[type] = Array.from(
  1226. new Set([
  1227. ...this.recommendedGenres,
  1228. ...items
  1229. ])
  1230. );
  1231. else this.autosuggest.allItems[type] = items;
  1232. } else {
  1233. new Toast(res.message);
  1234. }
  1235. }
  1236. );
  1237. });
  1238. return null;
  1239. },
  1240. unloadSong(songId) {
  1241. this.songDataLoaded = false;
  1242. this.songDeleted = false;
  1243. this.stopVideo();
  1244. this.pauseVideo(true);
  1245. this.resetSong(songId);
  1246. this.thumbnailNotSquare = false;
  1247. this.thumbnailWidth = null;
  1248. this.thumbnailHeight = null;
  1249. this.youtubeVideoCurrentTime = "0.000";
  1250. this.youtubeVideoDuration = "0.000";
  1251. this.youtubeVideoNote = "";
  1252. this.socket.dispatch("apis.leaveRoom", `edit-song.${songId}`);
  1253. if (this.$refs.saveButton) this.$refs.saveButton.status = "default";
  1254. },
  1255. loadSong(songId) {
  1256. console.log(`LOAD SONG ${songId}`);
  1257. this.songNotFound = false;
  1258. this.socket.dispatch(`songs.getSongFromSongId`, songId, res => {
  1259. if (res.status === "success") {
  1260. let { song } = res.data;
  1261. song = Object.assign(song, this.prefillData);
  1262. this.setSong(song);
  1263. this.songDataLoaded = true;
  1264. this.socket.dispatch(
  1265. "apis.joinRoom",
  1266. `edit-song.${this.song._id}`
  1267. );
  1268. if (this.video.player && this.video.player.cueVideoById) {
  1269. this.video.player.cueVideoById(
  1270. this.song.youtubeId,
  1271. this.song.skipDuration
  1272. );
  1273. }
  1274. } else {
  1275. new Toast("Song with that ID not found");
  1276. if (this.bulk) this.songNotFound = true;
  1277. if (!this.bulk) this.closeModal("editSong");
  1278. }
  1279. });
  1280. this.socket.dispatch("reports.getReportsForSong", songId, res => {
  1281. this.updateReports(res.data.reports);
  1282. });
  1283. },
  1284. importAlbum(result) {
  1285. this.selectDiscogsAlbum(result);
  1286. this.openModal("importAlbum");
  1287. this.closeModal("editSong");
  1288. },
  1289. save(songToCopy, closeOrNext, saveButtonRefName, newSong = false) {
  1290. const song = JSON.parse(JSON.stringify(songToCopy));
  1291. if (!newSong) this.$emit("saving", song._id);
  1292. const saveButtonRef = this.$refs[saveButtonRefName];
  1293. if (!this.youtubeError && this.youtubeVideoDuration === "0.000") {
  1294. saveButtonRef.handleFailedSave();
  1295. if (!newSong) this.$emit("savedError", song._id);
  1296. return new Toast("The video appears to not be working.");
  1297. }
  1298. if (!song.title) {
  1299. saveButtonRef.handleFailedSave();
  1300. if (!newSong) this.$emit("savedError", song._id);
  1301. return new Toast("Please fill in all fields");
  1302. }
  1303. if (!song.thumbnail) {
  1304. saveButtonRef.handleFailedSave();
  1305. if (!newSong) this.$emit("savedError", song._id);
  1306. return new Toast("Please fill in all fields");
  1307. }
  1308. // const thumbnailHeight = this.$refs.thumbnailElement.naturalHeight;
  1309. // const thumbnailWidth = this.$refs.thumbnailElement.naturalWidth;
  1310. // if (thumbnailHeight < 80 || thumbnailWidth < 80) {
  1311. // saveButtonRef.handleFailedSave();
  1312. // return new Toast(
  1313. // "Thumbnail width and height must be at least 80px."
  1314. // );
  1315. // }
  1316. // if (thumbnailHeight > 4000 || thumbnailWidth > 4000) {
  1317. // saveButtonRef.handleFailedSave();
  1318. // return new Toast(
  1319. // "Thumbnail width and height must be less than 4000px."
  1320. // );
  1321. // }
  1322. // if (thumbnailHeight - thumbnailWidth > 5) {
  1323. // saveButtonRef.handleFailedSave();
  1324. // return new Toast("Thumbnail cannot be taller than it is wide.");
  1325. // }
  1326. // Youtube Id
  1327. if (
  1328. !newSong &&
  1329. this.youtubeError &&
  1330. this.originalSong.youtubeId !== song.youtubeId
  1331. ) {
  1332. saveButtonRef.handleFailedSave();
  1333. if (!newSong) this.$emit("savedError", song._id);
  1334. return new Toast(
  1335. "You're not allowed to change the YouTube id while the player is not working"
  1336. );
  1337. }
  1338. // Duration
  1339. if (
  1340. Number(song.skipDuration) + Number(song.duration) >
  1341. this.youtubeVideoDuration &&
  1342. ((!newSong && !this.youtubeError) ||
  1343. this.originalSong.duration !== song.duration)
  1344. ) {
  1345. saveButtonRef.handleFailedSave();
  1346. if (!newSong) this.$emit("savedError", song._id);
  1347. return new Toast(
  1348. "Duration can't be higher than the length of the video"
  1349. );
  1350. }
  1351. // Title
  1352. if (!validation.isLength(song.title, 1, 100)) {
  1353. saveButtonRef.handleFailedSave();
  1354. if (!newSong) this.$emit("savedError", song._id);
  1355. return new Toast(
  1356. "Title must have between 1 and 100 characters."
  1357. );
  1358. }
  1359. // Artists
  1360. if (
  1361. (song.verified && song.artists.length < 1) ||
  1362. song.artists.length > 10
  1363. ) {
  1364. saveButtonRef.handleFailedSave();
  1365. if (!newSong) this.$emit("savedError", song._id);
  1366. return new Toast(
  1367. "Invalid artists. You must have at least 1 artist and a maximum of 10 artists."
  1368. );
  1369. }
  1370. let error;
  1371. song.artists.forEach(artist => {
  1372. if (!validation.isLength(artist, 1, 64)) {
  1373. error = "Artist must have between 1 and 64 characters.";
  1374. return error;
  1375. }
  1376. if (artist === "NONE") {
  1377. error =
  1378. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  1379. return error;
  1380. }
  1381. return false;
  1382. });
  1383. if (error) {
  1384. saveButtonRef.handleFailedSave();
  1385. if (!newSong) this.$emit("savedError", song._id);
  1386. return new Toast(error);
  1387. }
  1388. // Genres
  1389. error = undefined;
  1390. song.genres.forEach(genre => {
  1391. if (!validation.isLength(genre, 1, 32)) {
  1392. error = "Genre must have between 1 and 32 characters.";
  1393. return error;
  1394. }
  1395. if (!validation.regex.ascii.test(genre)) {
  1396. error =
  1397. "Invalid genre format. Only ascii characters are allowed.";
  1398. return error;
  1399. }
  1400. return false;
  1401. });
  1402. if (
  1403. (song.verified && song.genres.length < 1) ||
  1404. song.genres.length > 16
  1405. )
  1406. error = "You must have between 1 and 16 genres.";
  1407. if (error) {
  1408. saveButtonRef.handleFailedSave();
  1409. if (!newSong) this.$emit("savedError", song._id);
  1410. return new Toast(error);
  1411. }
  1412. error = undefined;
  1413. song.tags.forEach(tag => {
  1414. if (
  1415. !/^[a-zA-Z0-9_]{1,64}$|^[a-zA-Z0-9_]{1,64}\[[a-zA-Z0-9_]{1,64}\]$/.test(
  1416. tag
  1417. )
  1418. ) {
  1419. error = "Invalid tag format.";
  1420. return error;
  1421. }
  1422. return false;
  1423. });
  1424. if (error) {
  1425. saveButtonRef.handleFailedSave();
  1426. if (!newSong) this.$emit("savedError", song._id);
  1427. return new Toast(error);
  1428. }
  1429. // Thumbnail
  1430. if (!validation.isLength(song.thumbnail, 1, 256)) {
  1431. saveButtonRef.handleFailedSave();
  1432. if (!newSong) this.$emit("savedError", song._id);
  1433. return new Toast(
  1434. "Thumbnail must have between 8 and 256 characters."
  1435. );
  1436. }
  1437. if (this.useHTTPS && song.thumbnail.indexOf("https://") !== 0) {
  1438. saveButtonRef.handleFailedSave();
  1439. if (!newSong) this.$emit("savedError", song._id);
  1440. return new Toast('Thumbnail must start with "https://".');
  1441. }
  1442. if (
  1443. !this.useHTTPS &&
  1444. song.thumbnail.indexOf("http://") !== 0 &&
  1445. song.thumbnail.indexOf("https://") !== 0
  1446. ) {
  1447. saveButtonRef.handleFailedSave();
  1448. if (!newSong) this.$emit("savedError", song._id);
  1449. return new Toast('Thumbnail must start with "http://".');
  1450. }
  1451. saveButtonRef.status = "saving";
  1452. if (newSong)
  1453. return this.socket.dispatch(`songs.create`, song, res => {
  1454. new Toast(res.message);
  1455. if (res.status === "error") {
  1456. saveButtonRef.handleFailedSave();
  1457. return;
  1458. }
  1459. saveButtonRef.handleSuccessfulSave();
  1460. this.closeModal("editSong");
  1461. });
  1462. return this.socket.dispatch(`songs.update`, song._id, song, res => {
  1463. new Toast(res.message);
  1464. if (res.status === "error") {
  1465. saveButtonRef.handleFailedSave();
  1466. this.$emit("savedError", song._id);
  1467. return;
  1468. }
  1469. this.updateOriginalSong(song);
  1470. saveButtonRef.handleSuccessfulSave();
  1471. this.$emit("savedSuccess", song._id);
  1472. if (!closeOrNext) return;
  1473. if (this.bulk) this.$emit("nextSong");
  1474. else this.closeModal("editSong");
  1475. });
  1476. },
  1477. editNextSong() {
  1478. this.$emit("nextSong");
  1479. },
  1480. toggleFlag() {
  1481. this.$emit("toggleFlag");
  1482. },
  1483. getAlbumData(type) {
  1484. if (!this.song.discogs) return;
  1485. if (type === "title")
  1486. this.updateSongField({
  1487. field: "title",
  1488. value: this.song.discogs.track.title
  1489. });
  1490. if (type === "albumArt")
  1491. this.updateSongField({
  1492. field: "thumbnail",
  1493. value: this.song.discogs.album.albumArt
  1494. });
  1495. if (type === "genres")
  1496. this.updateSongField({
  1497. field: "genres",
  1498. value: JSON.parse(
  1499. JSON.stringify(this.song.discogs.album.genres)
  1500. )
  1501. });
  1502. if (type === "artists")
  1503. this.updateSongField({
  1504. field: "artists",
  1505. value: JSON.parse(
  1506. JSON.stringify(this.song.discogs.album.artists)
  1507. )
  1508. });
  1509. },
  1510. getYouTubeData(type) {
  1511. if (type === "title") {
  1512. try {
  1513. const { title } = this.video.player.getVideoData();
  1514. if (title)
  1515. this.updateSongField({
  1516. field: "title",
  1517. value: title
  1518. });
  1519. else throw new Error("No title found");
  1520. } catch (e) {
  1521. new Toast("Unable to fetch YouTube title");
  1522. }
  1523. }
  1524. if (type === "thumbnail")
  1525. this.updateSongField({
  1526. field: "thumbnail",
  1527. value: `https://img.youtube.com/vi/${this.song.youtubeId}/mqdefault.jpg`
  1528. });
  1529. },
  1530. fillDuration() {
  1531. this.song.duration =
  1532. this.youtubeVideoDuration - this.song.skipDuration;
  1533. },
  1534. settings(type) {
  1535. switch (type) {
  1536. case "stop":
  1537. this.stopVideo();
  1538. this.pauseVideo(true);
  1539. break;
  1540. case "hardStop":
  1541. this.hardStopVideo();
  1542. this.pauseVideo(true);
  1543. break;
  1544. case "pause":
  1545. this.pauseVideo(true);
  1546. break;
  1547. case "play":
  1548. this.pauseVideo(false);
  1549. break;
  1550. case "skipToLast10Secs":
  1551. this.seekTo(
  1552. this.song.duration - 10 + this.song.skipDuration
  1553. );
  1554. break;
  1555. default:
  1556. break;
  1557. }
  1558. },
  1559. play() {
  1560. if (
  1561. this.video.player.getVideoData().video_id !==
  1562. this.song.youtubeId
  1563. ) {
  1564. this.song.duration = -1;
  1565. this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
  1566. }
  1567. this.settings("play");
  1568. },
  1569. seekTo(position) {
  1570. this.settings("play");
  1571. this.video.player.seekTo(position);
  1572. },
  1573. changeVolume() {
  1574. const volume = this.volumeSliderValue;
  1575. localStorage.setItem("volume", volume);
  1576. this.video.player.setVolume(volume);
  1577. if (volume > 0) {
  1578. this.video.player.unMute();
  1579. this.muted = false;
  1580. }
  1581. },
  1582. toggleMute() {
  1583. const previousVolume = parseFloat(localStorage.getItem("volume"));
  1584. const volume =
  1585. this.video.player.getVolume() <= 0 ? previousVolume : 0;
  1586. this.muted = !this.muted;
  1587. this.volumeSliderValue = volume;
  1588. this.video.player.setVolume(volume);
  1589. if (!this.muted) localStorage.setItem("volume", volume);
  1590. },
  1591. increaseVolume() {
  1592. const previousVolume = parseFloat(localStorage.getItem("volume"));
  1593. let volume = previousVolume + 5;
  1594. this.muted = false;
  1595. if (volume > 100) volume = 100;
  1596. this.volumeSliderValue = volume;
  1597. this.video.player.setVolume(volume);
  1598. localStorage.setItem("volume", volume);
  1599. },
  1600. addTag(type, value) {
  1601. if (type === "genres") {
  1602. const genre = value || this.genreInputValue.trim();
  1603. if (
  1604. this.song.genres
  1605. .map(genre => genre.toLowerCase())
  1606. .indexOf(genre.toLowerCase()) !== -1
  1607. )
  1608. return new Toast("Genre already exists");
  1609. if (genre) {
  1610. this.song.genres.push(genre);
  1611. this.genreInputValue = "";
  1612. return false;
  1613. }
  1614. return new Toast("Genre cannot be empty");
  1615. }
  1616. if (type === "artists") {
  1617. const artist = value || this.artistInputValue;
  1618. if (this.song.artists.indexOf(artist) !== -1)
  1619. return new Toast("Artist already exists");
  1620. if (artist !== "") {
  1621. this.song.artists.push(artist);
  1622. this.artistInputValue = "";
  1623. return false;
  1624. }
  1625. return new Toast("Artist cannot be empty");
  1626. }
  1627. if (type === "tags") {
  1628. const tag = value || this.tagInputValue;
  1629. if (this.song.tags.indexOf(tag) !== -1)
  1630. return new Toast("Tag already exists");
  1631. if (tag !== "") {
  1632. this.song.tags.push(tag);
  1633. this.tagInputValue = "";
  1634. return false;
  1635. }
  1636. return new Toast("Tag cannot be empty");
  1637. }
  1638. return false;
  1639. },
  1640. removeTag(type, value) {
  1641. if (type === "genres")
  1642. this.song.genres.splice(this.song.genres.indexOf(value), 1);
  1643. else if (type === "artists")
  1644. this.song.artists.splice(this.song.artists.indexOf(value), 1);
  1645. else if (type === "tags")
  1646. this.song.tags.splice(this.song.tags.indexOf(value), 1);
  1647. },
  1648. drawCanvas() {
  1649. if (!this.songDataLoaded) return;
  1650. const canvasElement = this.$refs.durationCanvas;
  1651. const ctx = canvasElement.getContext("2d");
  1652. const videoDuration = Number(this.youtubeVideoDuration);
  1653. const skipDuration = Number(this.song.skipDuration);
  1654. const duration = Number(this.song.duration);
  1655. const afterDuration = videoDuration - (skipDuration + duration);
  1656. const width = 530;
  1657. const currentTime =
  1658. this.video.player && this.video.player.getCurrentTime
  1659. ? this.video.player.getCurrentTime()
  1660. : 0;
  1661. const widthSkipDuration = (skipDuration / videoDuration) * width;
  1662. const widthDuration = (duration / videoDuration) * width;
  1663. const widthAfterDuration = (afterDuration / videoDuration) * width;
  1664. const widthCurrentTime = (currentTime / videoDuration) * width;
  1665. const skipDurationColor = "#F42003";
  1666. const durationColor = "#03A9F4";
  1667. const afterDurationColor = "#41E841";
  1668. const currentDurationColor = "#3b25e8";
  1669. ctx.fillStyle = skipDurationColor;
  1670. ctx.fillRect(0, 0, widthSkipDuration, 20);
  1671. ctx.fillStyle = durationColor;
  1672. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  1673. ctx.fillStyle = afterDurationColor;
  1674. ctx.fillRect(
  1675. widthSkipDuration + widthDuration,
  1676. 0,
  1677. widthAfterDuration,
  1678. 20
  1679. );
  1680. ctx.fillStyle = currentDurationColor;
  1681. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  1682. },
  1683. setTrackPosition(event) {
  1684. this.seekTo(
  1685. Number(
  1686. Number(this.video.player.getDuration()) *
  1687. ((event.pageX -
  1688. event.target.getBoundingClientRect().left) /
  1689. 530)
  1690. )
  1691. );
  1692. },
  1693. toggleGenreHelper() {
  1694. this.$refs.genreHelper.toggleBox();
  1695. },
  1696. resetGenreHelper() {
  1697. this.$refs.genreHelper.resetBox();
  1698. },
  1699. sendActivityWatchVideoData() {
  1700. if (!this.video.paused) {
  1701. if (this.activityWatchVideoLastStatus !== "playing") {
  1702. this.activityWatchVideoLastStatus = "playing";
  1703. if (
  1704. this.song.skipDuration > 0 &&
  1705. parseFloat(this.youtubeVideoCurrentTime) === 0
  1706. ) {
  1707. this.activityWatchVideoLastStartDuration = Math.floor(
  1708. this.song.skipDuration +
  1709. parseFloat(this.youtubeVideoCurrentTime)
  1710. );
  1711. } else {
  1712. this.activityWatchVideoLastStartDuration = Math.floor(
  1713. parseFloat(this.youtubeVideoCurrentTime)
  1714. );
  1715. }
  1716. }
  1717. const videoData = {
  1718. title: this.song.title,
  1719. artists: this.song.artists
  1720. ? this.song.artists.join(", ")
  1721. : null,
  1722. youtubeId: this.song.youtubeId,
  1723. muted: this.muted,
  1724. volume: this.volumeSliderValue,
  1725. startedDuration:
  1726. this.activityWatchVideoLastStartDuration <= 0
  1727. ? 0
  1728. : this.activityWatchVideoLastStartDuration,
  1729. source: `editSong#${this.song.youtubeId}`,
  1730. hostname: window.location.hostname
  1731. };
  1732. aw.sendVideoData(videoData);
  1733. } else {
  1734. this.activityWatchVideoLastStatus = "not_playing";
  1735. }
  1736. },
  1737. remove(id) {
  1738. this.socket.dispatch("songs.remove", id, res => {
  1739. new Toast(res.message);
  1740. });
  1741. },
  1742. confirmAction({ message, action, params }) {
  1743. this.openModal({
  1744. modal: "confirm",
  1745. data: {
  1746. message,
  1747. action,
  1748. params,
  1749. onCompleted: this.handleConfirmed
  1750. }
  1751. });
  1752. },
  1753. handleConfirmed({ action, params }) {
  1754. if (typeof this[action] === "function") {
  1755. if (params) this[action](params);
  1756. else this[action]();
  1757. }
  1758. },
  1759. onCloseModal() {
  1760. const songStringified = JSON.stringify({
  1761. ...this.song,
  1762. ...{
  1763. duration: Number(this.song.duration).toFixed(3)
  1764. }
  1765. });
  1766. const originalSongStringified = JSON.stringify({
  1767. ...this.originalSong,
  1768. ...{
  1769. duration: Number(this.originalSong.duration).toFixed(3)
  1770. }
  1771. });
  1772. const unsavedChanges = songStringified !== originalSongStringified;
  1773. if (unsavedChanges) {
  1774. return this.confirmAction({
  1775. message:
  1776. "You have unsaved changes. Are you sure you want to discard unsaved changes?",
  1777. action: "closeThisModal",
  1778. params: null
  1779. });
  1780. }
  1781. return this.closeThisModal();
  1782. },
  1783. closeThisModal() {
  1784. if (this.bulk) this.$emit("close");
  1785. else this.closeModal("editSong");
  1786. },
  1787. ...mapActions("modals/importAlbum", ["selectDiscogsAlbum"]),
  1788. ...mapActions({
  1789. showTab(dispatch, payload) {
  1790. if (this.$refs[`${payload}-tab`])
  1791. this.$refs[`${payload}-tab`].scrollIntoView({
  1792. block: "nearest"
  1793. });
  1794. return dispatch(
  1795. `${this.modalModulePath.replace(
  1796. "MODAL_UUID",
  1797. this.modalUuid
  1798. )}/showTab`,
  1799. payload
  1800. );
  1801. }
  1802. }),
  1803. ...mapModalActions("MODAL_MODULE_PATH", [
  1804. "stopVideo",
  1805. "hardStopVideo",
  1806. "loadVideoById",
  1807. "pauseVideo",
  1808. "getCurrentTime",
  1809. "setSong",
  1810. "resetSong",
  1811. "updateOriginalSong",
  1812. "updateSongField",
  1813. "updateReports",
  1814. "setPlaybackRate"
  1815. ]),
  1816. ...mapActions("modalVisibility", ["closeModal", "openModal"])
  1817. }
  1818. };
  1819. </script>
  1820. <style lang="less" scoped>
  1821. .night-mode {
  1822. .edit-section,
  1823. .player-section,
  1824. #tabs-container {
  1825. background-color: var(--dark-grey-3) !important;
  1826. border: 0 !important;
  1827. .tab {
  1828. border: 0 !important;
  1829. }
  1830. }
  1831. #tabs-container #tab-selection .button {
  1832. background: var(--dark-grey) !important;
  1833. color: var(--white) !important;
  1834. }
  1835. .left-section {
  1836. .edit-section {
  1837. .album-get-button,
  1838. .duration-fill-button,
  1839. .youtube-get-button,
  1840. .add-button {
  1841. &:focus,
  1842. &:hover {
  1843. border: none !important;
  1844. }
  1845. }
  1846. }
  1847. }
  1848. #durationCanvas {
  1849. background-color: var(--dark-grey-2) !important;
  1850. }
  1851. }
  1852. .modal-card-body {
  1853. display: flex;
  1854. }
  1855. .notice-container {
  1856. display: flex;
  1857. flex: 1;
  1858. justify-content: center;
  1859. h4 {
  1860. margin: auto;
  1861. }
  1862. }
  1863. .left-section {
  1864. height: 100%;
  1865. display: flex;
  1866. flex-direction: column;
  1867. margin-right: 16px;
  1868. .top-section {
  1869. display: flex;
  1870. .player-section {
  1871. width: 530px;
  1872. display: flex;
  1873. flex-direction: column;
  1874. border: 1px solid var(--light-grey-3);
  1875. border-radius: @border-radius;
  1876. overflow: hidden;
  1877. #durationCanvas {
  1878. background-color: var(--light-grey-2);
  1879. }
  1880. .player-error {
  1881. display: flex;
  1882. height: 318px;
  1883. width: 530px;
  1884. align-items: center;
  1885. * {
  1886. margin: 0;
  1887. flex: 1;
  1888. font-size: 30px;
  1889. text-align: center;
  1890. }
  1891. }
  1892. .player-footer {
  1893. display: flex;
  1894. justify-content: space-between;
  1895. height: 54px;
  1896. padding-left: 10px;
  1897. padding-right: 10px;
  1898. > * {
  1899. width: 33.3%;
  1900. display: flex;
  1901. align-items: center;
  1902. }
  1903. .player-footer-left {
  1904. flex: 1;
  1905. & > .button:not(:first-child) {
  1906. margin-left: 5px;
  1907. }
  1908. :deep(& > .playerRateDropdown) {
  1909. margin-left: 5px;
  1910. margin-bottom: unset !important;
  1911. .control.has-addons {
  1912. margin-bottom: unset !important;
  1913. & > .button {
  1914. font-size: 24px;
  1915. }
  1916. }
  1917. }
  1918. :deep(.tippy-box[data-theme~="dropdown"]) {
  1919. max-width: 100px !important;
  1920. .nav-dropdown-items .nav-item {
  1921. justify-content: center !important;
  1922. border-radius: @border-radius !important;
  1923. &.active {
  1924. background-color: var(--primary-color);
  1925. color: var(--white);
  1926. }
  1927. }
  1928. }
  1929. }
  1930. .player-footer-center {
  1931. justify-content: center;
  1932. align-items: center;
  1933. flex: 2;
  1934. font-size: 18px;
  1935. font-weight: 400;
  1936. width: 200px;
  1937. margin: 0 5px;
  1938. img {
  1939. height: 21px;
  1940. margin-right: 12px;
  1941. filter: invert(26%) sepia(54%) saturate(6317%)
  1942. hue-rotate(2deg) brightness(92%) contrast(115%);
  1943. }
  1944. }
  1945. .player-footer-right {
  1946. justify-content: right;
  1947. flex: 1;
  1948. #volume-control {
  1949. margin: 3px;
  1950. margin-top: 0;
  1951. display: flex;
  1952. align-items: center;
  1953. cursor: pointer;
  1954. .volume-slider {
  1955. width: 100%;
  1956. padding: 0 15px;
  1957. background: transparent;
  1958. min-width: 100px;
  1959. }
  1960. input[type="range"] {
  1961. -webkit-appearance: none;
  1962. margin: 7.3px 0;
  1963. }
  1964. input[type="range"]:focus {
  1965. outline: none;
  1966. }
  1967. input[type="range"]::-webkit-slider-runnable-track {
  1968. width: 100%;
  1969. height: 5.2px;
  1970. cursor: pointer;
  1971. box-shadow: 0;
  1972. background: var(--light-grey-3);
  1973. border-radius: @border-radius;
  1974. border: 0;
  1975. }
  1976. input[type="range"]::-webkit-slider-thumb {
  1977. box-shadow: 0;
  1978. border: 0;
  1979. height: 19px;
  1980. width: 19px;
  1981. border-radius: 100%;
  1982. background: var(--primary-color);
  1983. cursor: pointer;
  1984. -webkit-appearance: none;
  1985. margin-top: -6.5px;
  1986. }
  1987. input[type="range"]::-moz-range-track {
  1988. width: 100%;
  1989. height: 5.2px;
  1990. cursor: pointer;
  1991. box-shadow: 0;
  1992. background: var(--light-grey-3);
  1993. border-radius: @border-radius;
  1994. border: 0;
  1995. }
  1996. input[type="range"]::-moz-range-thumb {
  1997. box-shadow: 0;
  1998. border: 0;
  1999. height: 19px;
  2000. width: 19px;
  2001. border-radius: 100%;
  2002. background: var(--primary-color);
  2003. cursor: pointer;
  2004. -webkit-appearance: none;
  2005. margin-top: -6.5px;
  2006. }
  2007. input[type="range"]::-ms-track {
  2008. width: 100%;
  2009. height: 5.2px;
  2010. cursor: pointer;
  2011. box-shadow: 0;
  2012. background: var(--light-grey-3);
  2013. border-radius: @border-radius;
  2014. }
  2015. input[type="range"]::-ms-fill-lower {
  2016. background: var(--light-grey-3);
  2017. border: 0;
  2018. border-radius: 0;
  2019. box-shadow: 0;
  2020. }
  2021. input[type="range"]::-ms-fill-upper {
  2022. background: var(--light-grey-3);
  2023. border: 0;
  2024. border-radius: 0;
  2025. box-shadow: 0;
  2026. }
  2027. input[type="range"]::-ms-thumb {
  2028. box-shadow: 0;
  2029. border: 0;
  2030. height: 15px;
  2031. width: 15px;
  2032. border-radius: 100%;
  2033. background: var(--primary-color);
  2034. cursor: pointer;
  2035. -webkit-appearance: none;
  2036. margin-top: 1.5px;
  2037. }
  2038. }
  2039. }
  2040. }
  2041. }
  2042. :deep(.thumbnail-preview) {
  2043. width: 189px;
  2044. height: 189px;
  2045. margin-left: 16px;
  2046. }
  2047. .thumbnail-dummy {
  2048. opacity: 0;
  2049. height: 10px;
  2050. width: 10px;
  2051. }
  2052. }
  2053. .edit-section {
  2054. display: flex;
  2055. flex-wrap: wrap;
  2056. flex-grow: 1;
  2057. border: 1px solid var(--light-grey-3);
  2058. margin-top: 16px;
  2059. border-radius: @border-radius;
  2060. .album-get-button {
  2061. background-color: var(--purple);
  2062. color: var(--white);
  2063. width: 32px;
  2064. text-align: center;
  2065. border-width: 0;
  2066. }
  2067. .duration-fill-button,
  2068. .youtube-get-button {
  2069. background-color: var(--dark-red);
  2070. color: var(--white);
  2071. width: 32px;
  2072. text-align: center;
  2073. border-width: 0;
  2074. }
  2075. .add-button {
  2076. background-color: var(--primary-color) !important;
  2077. width: 32px;
  2078. i {
  2079. font-size: 32px;
  2080. }
  2081. }
  2082. .album-get-button,
  2083. .duration-fill-button,
  2084. .youtube-get-button,
  2085. .add-button {
  2086. &:focus,
  2087. &:hover {
  2088. filter: contrast(0.75);
  2089. border: 1px solid var(--black) !important;
  2090. }
  2091. }
  2092. .youtube-get-button {
  2093. padding-left: 4px;
  2094. padding-right: 4px;
  2095. .youtube-icon {
  2096. background: var(--white);
  2097. }
  2098. }
  2099. > div {
  2100. margin: 16px !important;
  2101. }
  2102. input {
  2103. width: 100%;
  2104. }
  2105. .title-container {
  2106. width: calc((100% - 32px) / 2);
  2107. }
  2108. .duration-container {
  2109. margin-right: 16px;
  2110. margin-left: 16px;
  2111. width: calc((100% - 32px) / 4);
  2112. }
  2113. .skip-duration-container {
  2114. width: calc((100% - 32px) / 4);
  2115. }
  2116. .album-art-container {
  2117. margin-right: 16px;
  2118. width: calc((100% - 16px) / 8 * 4);
  2119. }
  2120. .youtube-id-container {
  2121. margin-right: 16px;
  2122. width: calc((100% - 16px) / 8 * 3);
  2123. }
  2124. .verified-container {
  2125. width: calc((100% - 16px) / 8);
  2126. .checkbox-control {
  2127. margin-top: 10px;
  2128. }
  2129. }
  2130. .artists-container {
  2131. width: calc((100% - 32px) / 3);
  2132. position: relative;
  2133. }
  2134. .genres-container {
  2135. width: calc((100% - 32px) / 3);
  2136. margin-left: 16px;
  2137. margin-right: 16px;
  2138. position: relative;
  2139. label {
  2140. display: flex;
  2141. i {
  2142. font-size: 15px;
  2143. align-self: center;
  2144. margin-left: 5px;
  2145. color: var(--primary-color);
  2146. cursor: pointer;
  2147. -webkit-user-select: none;
  2148. -moz-user-select: none;
  2149. -ms-user-select: none;
  2150. user-select: none;
  2151. }
  2152. }
  2153. }
  2154. .tags-container {
  2155. width: calc((100% - 32px) / 3);
  2156. position: relative;
  2157. }
  2158. .list-item-circle {
  2159. background-color: var(--primary-color);
  2160. width: 16px;
  2161. height: 16px;
  2162. border-radius: 8px;
  2163. cursor: pointer;
  2164. margin-right: 8px;
  2165. float: left;
  2166. -webkit-touch-callout: none;
  2167. -webkit-user-select: none;
  2168. -khtml-user-select: none;
  2169. -moz-user-select: none;
  2170. -ms-user-select: none;
  2171. user-select: none;
  2172. i {
  2173. color: var(--primary-color);
  2174. font-size: 14px;
  2175. margin-left: 1px;
  2176. position: relative;
  2177. top: -1px;
  2178. }
  2179. }
  2180. .list-item-circle:hover,
  2181. .list-item-circle:focus {
  2182. i {
  2183. color: var(--white);
  2184. }
  2185. }
  2186. .list-item > p {
  2187. line-height: 16px;
  2188. word-wrap: break-word;
  2189. width: calc(100% - 24px);
  2190. left: 24px;
  2191. float: left;
  2192. margin-bottom: 8px;
  2193. }
  2194. .list-item:last-child > p {
  2195. margin-bottom: 0;
  2196. }
  2197. .thumbnail-warning {
  2198. color: var(--red);
  2199. font-size: 18px;
  2200. margin: auto 0 auto 5px;
  2201. }
  2202. }
  2203. }
  2204. .right-section {
  2205. flex-basis: unset !important;
  2206. flex-grow: 0 !important;
  2207. display: flex;
  2208. height: 100%;
  2209. #tabs-container {
  2210. width: 376px;
  2211. #tab-selection {
  2212. display: flex;
  2213. overflow-x: auto;
  2214. .button {
  2215. border-radius: @border-radius @border-radius 0 0;
  2216. border: 0;
  2217. text-transform: uppercase;
  2218. font-size: 14px;
  2219. color: var(--dark-grey-3);
  2220. background-color: var(--light-grey-2);
  2221. flex-grow: 1;
  2222. height: 32px;
  2223. &:not(:first-of-type) {
  2224. margin-left: 5px;
  2225. }
  2226. }
  2227. .selected {
  2228. background-color: var(--primary-color) !important;
  2229. color: var(--white) !important;
  2230. font-weight: 600;
  2231. }
  2232. }
  2233. .tab {
  2234. border: 1px solid var(--light-grey-3);
  2235. border-radius: 0 0 @border-radius @border-radius;
  2236. padding: 15px;
  2237. height: calc(100% - 32px);
  2238. overflow: auto;
  2239. }
  2240. }
  2241. }
  2242. @media screen and (max-width: 1100px) {
  2243. .left-section,
  2244. .right-section {
  2245. height: unset;
  2246. max-height: unset;
  2247. }
  2248. .left-section {
  2249. margin-right: 0;
  2250. }
  2251. .right-section {
  2252. flex-basis: 100% !important;
  2253. #tabs-container {
  2254. width: 100%;
  2255. }
  2256. }
  2257. }
  2258. .modal-card-foot .is-primary {
  2259. width: 200px;
  2260. }
  2261. :deep(.autosuggest-container) {
  2262. top: unset;
  2263. }
  2264. </style>