index.vue 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568
  1. <script setup lang="ts">
  2. import { storeToRefs } from "pinia";
  3. import {
  4. defineAsyncComponent,
  5. ref,
  6. computed,
  7. watch,
  8. onMounted,
  9. onBeforeUnmount
  10. } from "vue";
  11. import Toast from "toasters";
  12. import aw from "@/aw";
  13. import validation from "@/validation";
  14. import keyboardShortcuts from "@/keyboardShortcuts";
  15. import { useForm } from "@/composables/useForm";
  16. import { useSoundcloudPlayer } from "@/composables/useSoundcloudPlayer";
  17. import { Song } from "@/types/song.js";
  18. import { useWebsocketsStore } from "@/stores/websockets";
  19. import { useConfigStore } from "@/stores/config";
  20. import { useModalsStore } from "@/stores/modals";
  21. import { useEditSongStore } from "@/stores/editSong";
  22. import { useStationStore } from "@/stores/station";
  23. import { useUserAuthStore } from "@/stores/userAuth";
  24. import Modal from "@/components/Modal.vue";
  25. const TAG = "[EDITSONG]";
  26. const FloatingBox = defineAsyncComponent(
  27. () => import("@/components/FloatingBox.vue")
  28. );
  29. const SaveButton = defineAsyncComponent(
  30. () => import("@/components/SaveButton.vue")
  31. );
  32. const AutoSuggest = defineAsyncComponent(
  33. () => import("@/components/AutoSuggest.vue")
  34. );
  35. const MediaItem = defineAsyncComponent(
  36. () => import("@/components/MediaItem.vue")
  37. );
  38. const Discogs = defineAsyncComponent(() => import("./Tabs/Discogs.vue"));
  39. const ReportsTab = defineAsyncComponent(() => import("./Tabs/Reports.vue"));
  40. const Youtube = defineAsyncComponent(() => import("./Tabs/Youtube.vue"));
  41. const MusareSongs = defineAsyncComponent(() => import("./Tabs/Songs.vue"));
  42. const SongThumbnail = defineAsyncComponent(
  43. () => import("@/components/SongThumbnail.vue")
  44. );
  45. const props = defineProps({
  46. modalUuid: { type: String, required: true },
  47. modalModulePath: {
  48. type: String,
  49. default: "modals/editSong/MODAL_UUID"
  50. },
  51. discogsAlbum: { type: Object, default: null },
  52. song: { type: Object, default: null },
  53. songs: { type: Array, default: null }
  54. });
  55. const editSongStore = useEditSongStore({ modalUuid: props.modalUuid });
  56. const stationStore = useStationStore();
  57. const { socket } = useWebsocketsStore();
  58. const userAuthStore = useUserAuthStore();
  59. const {
  60. soundcloudIframeElement,
  61. soundcloudLoadTrack,
  62. soundcloudSeekTo,
  63. soundcloudPlay,
  64. soundcloudPause,
  65. soundcloudSetVolume,
  66. soundcloudGetPosition,
  67. soundcloudGetDuration,
  68. soundcloudGetCurrentSound,
  69. soundcloudGetTrackId,
  70. soundcloudBindListener,
  71. soundcloudUnload
  72. } = useSoundcloudPlayer();
  73. const { openModal, closeCurrentModal, preventCloseCbs } = useModalsStore();
  74. const { hasPermission } = userAuthStore;
  75. const {
  76. tab,
  77. video,
  78. song,
  79. mediaSource,
  80. prefillData,
  81. reports,
  82. newSong,
  83. bulk,
  84. mediaSources,
  85. songPrefillData
  86. } = storeToRefs(editSongStore);
  87. const songDataLoaded = ref(false);
  88. const songDeleted = ref(false);
  89. const youtubeError = ref(false);
  90. const youtubeErrorMessage = ref("");
  91. const youtubeVideoDuration = ref("0.000");
  92. const youtubeVideoCurrentTime = ref<number | string>(0);
  93. const youtubeVideoNote = ref("");
  94. const muted = ref(false);
  95. const volumeSliderValue = ref(0);
  96. const activityWatchMediaDataInterval = ref(null);
  97. const activityWatchMediaLastStatus = ref("");
  98. const activityWatchMediaLastStartDuration = ref(0);
  99. const recommendedGenres = ref([
  100. "Blues",
  101. "Country",
  102. "Disco",
  103. "Funk",
  104. "Hip-Hop",
  105. "Jazz",
  106. "Metal",
  107. "Oldies",
  108. "Other",
  109. "Pop",
  110. "Rap",
  111. "Reggae",
  112. "Rock",
  113. "Techno",
  114. "Trance",
  115. "Classical",
  116. "Instrumental",
  117. "House",
  118. "Electronic",
  119. "Christian Rap",
  120. "Lo-Fi",
  121. "Musical",
  122. "Rock 'n' Roll",
  123. "Opera",
  124. "Drum & Bass",
  125. "Club-House",
  126. "Indie",
  127. "Heavy Metal",
  128. "Christian rock",
  129. "Dubstep"
  130. ]);
  131. const autosuggest = ref({
  132. allItems: {
  133. artists: [],
  134. genres: [],
  135. tags: []
  136. }
  137. });
  138. const songNotFound = ref(false);
  139. const showRateDropdown = ref(false);
  140. const thumbnailElement = ref();
  141. const thumbnailNotSquare = ref(false);
  142. const thumbnailWidth = ref(null);
  143. const thumbnailHeight = ref(null);
  144. const thumbnailLoadError = ref(false);
  145. const tabs = ref([]);
  146. const youtubePlayerReady = ref(true);
  147. const interval = ref();
  148. const saveButtonRefs = ref([]);
  149. const canvasElement = ref();
  150. const genreHelper = ref();
  151. const saveButtonRefName = ref();
  152. // EditSongs
  153. const items = ref([]);
  154. const currentSong = ref<Song>({});
  155. const flagFilter = ref(false);
  156. const sidebarMobileActive = ref(false);
  157. const songItems = ref([]);
  158. const editingItemIndex = computed(() =>
  159. items.value.findIndex(
  160. item => item.song.mediaSource === currentSong.value.mediaSource
  161. )
  162. );
  163. const filteredItems = computed({
  164. get: () =>
  165. items.value.filter(item => (flagFilter.value ? item.flagged : true)),
  166. set: (newItem: any) => {
  167. const index = items.value.findIndex(
  168. item => item.song.mediaSource === newItem.mediaSource
  169. );
  170. items.value[index] = newItem;
  171. }
  172. });
  173. const filteredEditingItemIndex = computed(() =>
  174. filteredItems.value.findIndex(
  175. item => item.song.mediaSource === currentSong.value.mediaSource
  176. )
  177. );
  178. const currentSongFlagged = computed(
  179. () =>
  180. items.value.find(
  181. item => item.song.mediaSource === currentSong.value.mediaSource
  182. )?.flagged
  183. );
  184. // EditSongs end
  185. const configStore = useConfigStore();
  186. const { discogsEnabled, experimental } = storeToRefs(configStore);
  187. const {
  188. editSong,
  189. stopVideo,
  190. loadVideoById,
  191. pauseVideo,
  192. setSong,
  193. resetSong,
  194. updateReports,
  195. setPlaybackRate
  196. } = editSongStore;
  197. const { updateMediaModalPlayingAudio } = stationStore;
  198. const playerHardStop = () => {
  199. if (
  200. youtubePlayerReady.value &&
  201. video.value.player &&
  202. video.value.player.stopVideo
  203. )
  204. video.value.player.stopVideo();
  205. soundcloudUnload();
  206. };
  207. const unloadSong = (_mediaSource, songId?) => {
  208. songDataLoaded.value = false;
  209. songDeleted.value = false;
  210. pauseVideo(true);
  211. playerHardStop();
  212. resetSong(_mediaSource);
  213. thumbnailNotSquare.value = false;
  214. thumbnailWidth.value = null;
  215. thumbnailHeight.value = null;
  216. youtubeVideoCurrentTime.value = "0.000";
  217. youtubeVideoDuration.value = "0.000";
  218. youtubeVideoNote.value = "";
  219. if (songId) socket.dispatch("apis.leaveRoom", `edit-song.${songId}`);
  220. if (saveButtonRefs.value.saveButton)
  221. saveButtonRefs.value.saveButton.status = "default";
  222. };
  223. const loadSong = (_mediaSource: string, reset?: boolean) => {
  224. songNotFound.value = false;
  225. socket.dispatch(`songs.getSongsFromMediaSources`, [_mediaSource], res => {
  226. const { songs } = res.data;
  227. if (res.status === "success" && songs.length > 0) {
  228. let _song = songs[0];
  229. _song = Object.assign(_song, prefillData.value);
  230. setSong(_song, reset);
  231. // Reset the youtube data one more time so it can properly reset
  232. youtubeVideoCurrentTime.value = "0.000";
  233. youtubeVideoDuration.value = "0.000";
  234. youtubeVideoNote.value = "";
  235. songDataLoaded.value = true;
  236. if (_song._id) {
  237. socket.dispatch("apis.joinRoom", `edit-song.${_song._id}`);
  238. socket.dispatch("reports.getReportsForSong", _song._id, res => {
  239. updateReports(res.data.reports);
  240. });
  241. newSong.value = false;
  242. }
  243. } else {
  244. new Toast("Song with that ID not found");
  245. if (bulk.value) songNotFound.value = true;
  246. if (!bulk.value) closeCurrentModal();
  247. }
  248. });
  249. };
  250. const onSavedSuccess = mediaSource => {
  251. const itemIndex = items.value.findIndex(
  252. item => item.song.mediaSource === mediaSource
  253. );
  254. if (itemIndex > -1) {
  255. items.value[itemIndex].status = "done";
  256. items.value[itemIndex].flagged = false;
  257. }
  258. };
  259. const onSavedError = mediaSource => {
  260. const itemIndex = items.value.findIndex(
  261. item => item.song.mediaSource === mediaSource
  262. );
  263. if (itemIndex > -1) items.value[itemIndex].status = "error";
  264. };
  265. const onSaving = mediaSource => {
  266. const itemIndex = items.value.findIndex(
  267. item => item.song.mediaSource === mediaSource
  268. );
  269. if (itemIndex > -1) items.value[itemIndex].status = "saving";
  270. };
  271. const getCurrentSongMediaType = mediaSource => {
  272. if (!mediaSource || mediaSource.indexOf(":") === -1) return "none";
  273. return mediaSource.split(":")[0];
  274. };
  275. const getCurrentSongMediaValue = mediaSource => {
  276. if (!mediaSource || mediaSource.indexOf(":") === -1) return null;
  277. return mediaSource.split(":")[1];
  278. };
  279. const { inputs, unsavedChanges, save, setValue, setOriginalValue } = useForm(
  280. {
  281. title: {
  282. value: "",
  283. validate: value => {
  284. if (!validation.isLength(value, 1, 100))
  285. return "Title must have between 1 and 100 characters.";
  286. return true;
  287. }
  288. },
  289. duration: {
  290. value: 0,
  291. validate: value => {
  292. // If the original duration is the same as the current value, just accept the validation
  293. if (inputs.value.duration.originalValue === value) return true;
  294. // Sum of the specified duration and skipDuration
  295. const totalDuration =
  296. Number(inputs.value.skipDuration.value) + Number(value);
  297. // Duration of the video itself
  298. const videoDuration = Number.parseFloat(
  299. youtubeVideoDuration.value
  300. );
  301. // If the total duration specified is bigger than the video duration
  302. if (totalDuration > videoDuration)
  303. if ((!newSong.value || bulk.value) && !youtubeError.value)
  304. // If there is no youtube error and this is in bulk mode or not a new song, throw an error
  305. return "Duration can't be higher than the length of the video";
  306. // In all other cases, pass validation
  307. return true;
  308. }
  309. },
  310. skipDuration: 0,
  311. thumbnail: {
  312. value: "",
  313. validate: value => {
  314. if (!validation.isLength(value, 8, 256))
  315. return "Thumbnail must have between 8 and 256 characters.";
  316. if (configStore.urls.secure && value.indexOf("https://") !== 0)
  317. return 'Thumbnail must start with "https://".';
  318. if (
  319. !configStore.urls.secure &&
  320. value.indexOf("https://") !== 0 &&
  321. value.indexOf("http://") !== 0
  322. )
  323. return 'Thumbnail must start with "http(s)://".';
  324. return true;
  325. }
  326. },
  327. mediaSource: {
  328. value: "",
  329. validate: value => {
  330. if (
  331. getCurrentSongMediaType(inputs.value.mediaSource.value) ===
  332. "none"
  333. )
  334. return "Media source type is not valid.";
  335. if (!getCurrentSongMediaValue(inputs.value.mediaSource.value))
  336. return "Media source value is not valid.";
  337. if (
  338. getCurrentSongMediaType(inputs.value.mediaSource.value) ===
  339. "youtube" &&
  340. !newSong.value &&
  341. youtubeError.value &&
  342. inputs.value.mediaSource.originalValue !== value
  343. )
  344. return "You're not allowed to change the media source while the player is not working";
  345. return true;
  346. }
  347. },
  348. verified: false,
  349. addArtist: {
  350. value: "",
  351. ignoreUnsaved: true,
  352. required: false
  353. },
  354. artists: {
  355. value: [],
  356. validate: value => {
  357. if (
  358. (inputs.value.verified.value && value.length < 1) ||
  359. value.length > 10
  360. )
  361. return "Invalid artists. You must have at least 1 artist and a maximum of 10 artists.";
  362. let error;
  363. value.forEach(artist => {
  364. if (!validation.isLength(artist, 1, 64))
  365. error = "Artist must have between 1 and 64 characters.";
  366. if (artist === "NONE")
  367. error =
  368. 'Invalid artist format. Artists are not allowed to be named "NONE".';
  369. });
  370. return error || true;
  371. }
  372. },
  373. addGenre: {
  374. value: "",
  375. ignoreUnsaved: true,
  376. required: false
  377. },
  378. genres: {
  379. value: [],
  380. validate: value => {
  381. if (
  382. (inputs.value.verified.value && value.length < 1) ||
  383. value.length > 16
  384. )
  385. return "Invalid genres. You must have between 1 and 16 genres.";
  386. let error;
  387. value.forEach(genre => {
  388. if (!validation.isLength(genre, 1, 32))
  389. error = "Genre must have between 1 and 32 characters.";
  390. if (!validation.regex.ascii.test(genre))
  391. error =
  392. "Invalid genre format. Only ascii characters are allowed.";
  393. });
  394. return error || true;
  395. }
  396. },
  397. addTag: {
  398. value: "",
  399. ignoreUnsaved: true,
  400. required: false
  401. },
  402. tags: {
  403. value: [],
  404. validate: value => {
  405. let error;
  406. value.forEach(tag => {
  407. if (
  408. !/^[a-zA-Z0-9_]{1,64}$|^[a-zA-Z0-9_]{1,64}\[[a-zA-Z0-9_]{1,64}\]$/.test(
  409. tag
  410. )
  411. )
  412. error = "Invalid tag format.";
  413. });
  414. return error || true;
  415. }
  416. },
  417. discogs: {
  418. value: {},
  419. required: false
  420. }
  421. },
  422. ({ status, messages, values }, resolve, reject) => {
  423. const saveButtonRef = saveButtonRefs.value[saveButtonRefName.value];
  424. if (status === "success" || (status === "unchanged" && newSong.value)) {
  425. const mergedValues = Object.assign(song.value, values);
  426. const cb = res => {
  427. if (res.status === "error") {
  428. reject(new Error(res.message));
  429. return;
  430. }
  431. new Toast(res.message);
  432. saveButtonRef.handleSuccessfulSave();
  433. onSavedSuccess(values.mediaSource);
  434. if (newSong.value) loadSong(values.mediaSource, true);
  435. else setSong(mergedValues);
  436. resolve();
  437. };
  438. if (newSong.value)
  439. socket.dispatch("songs.create", mergedValues, cb);
  440. else
  441. socket.dispatch(
  442. "songs.update",
  443. song.value._id,
  444. mergedValues,
  445. cb
  446. );
  447. } else {
  448. if (status === "unchanged") {
  449. new Toast(messages.unchanged);
  450. saveButtonRef.handleSuccessfulSave();
  451. onSavedSuccess(values.mediaSource);
  452. } else {
  453. Object.values(messages).forEach(message => {
  454. new Toast({ content: message, timeout: 8000 });
  455. });
  456. saveButtonRef.handleFailedSave();
  457. onSavedError(values.mediaSource);
  458. }
  459. resolve();
  460. }
  461. },
  462. { modalUuid: props.modalUuid, preventCloseUnsaved: false }
  463. );
  464. const currentSongMediaType = computed(() =>
  465. getCurrentSongMediaType(inputs.value.mediaSource.value)
  466. );
  467. const currentSongMediaValue = computed(() =>
  468. getCurrentSongMediaValue(inputs.value.mediaSource.value)
  469. );
  470. const getCurrentPlayerTime = () =>
  471. new Promise<number>(resolve => {
  472. if (
  473. currentSongMediaType.value === "youtube" &&
  474. youtubePlayerReady.value
  475. ) {
  476. resolve(
  477. video.value.player && video.value.player.getCurrentTime
  478. ? video.value.player.getCurrentTime()
  479. : 0
  480. );
  481. return;
  482. }
  483. if (currentSongMediaType.value === "soundcloud") {
  484. soundcloudGetPosition(position => {
  485. resolve(position / 1000);
  486. });
  487. return;
  488. }
  489. resolve(0);
  490. });
  491. const getPlayerDuration = () =>
  492. new Promise<number>(resolve => {
  493. if (
  494. currentSongMediaType.value === "youtube" &&
  495. youtubePlayerReady.value
  496. ) {
  497. resolve(
  498. video.value.player && video.value.player.getDuration
  499. ? video.value.player.getDuration()
  500. : 0
  501. );
  502. return;
  503. }
  504. if (currentSongMediaType.value === "soundcloud") {
  505. soundcloudGetDuration(duration => {
  506. resolve(duration / 1000);
  507. });
  508. return;
  509. }
  510. resolve(0);
  511. });
  512. const showTab = payload => {
  513. if (tabs.value[`${payload}-tab`])
  514. tabs.value[`${payload}-tab`].scrollIntoView({ block: "nearest" });
  515. editSongStore.showTab(payload);
  516. };
  517. const toggleDone = (index, overwrite = null) => {
  518. const { status } = filteredItems.value[index];
  519. if (status === "done" && overwrite !== "done")
  520. filteredItems.value[index].status = "todo";
  521. else {
  522. filteredItems.value[index].status = "done";
  523. filteredItems.value[index].flagged = false;
  524. }
  525. };
  526. const toggleFlagFilter = () => {
  527. flagFilter.value = !flagFilter.value;
  528. };
  529. const toggleMobileSidebar = () => {
  530. sidebarMobileActive.value = !sidebarMobileActive.value;
  531. };
  532. const onCloseOrNext = (next?: boolean): Promise<void> =>
  533. new Promise(resolve => {
  534. const confirmReasons = [];
  535. if (unsavedChanges.value.length > 0) {
  536. confirmReasons.push(
  537. "You have unsaved changes. Are you sure you want to discard unsaved changes?"
  538. );
  539. }
  540. if (!next && bulk.value) {
  541. const doneItems = items.value.filter(
  542. item => item.status === "done"
  543. ).length;
  544. const flaggedItems = items.value.filter(
  545. item => item.flagged
  546. ).length;
  547. const notDoneItems = items.value.length - doneItems;
  548. if (doneItems > 0 && notDoneItems > 0)
  549. confirmReasons.push(
  550. "You have songs which are not done yet. Are you sure you want to stop editing songs?"
  551. );
  552. else if (flaggedItems > 0)
  553. confirmReasons.push(
  554. "You have songs which are flagged. Are you sure you want to stop editing songs?"
  555. );
  556. }
  557. if (confirmReasons.length > 0)
  558. openModal({
  559. modal: "confirm",
  560. props: {
  561. message: confirmReasons,
  562. onCompleted: resolve
  563. }
  564. });
  565. else resolve();
  566. });
  567. const pickSong = song => {
  568. onCloseOrNext(true).then(() => {
  569. editSong({
  570. mediaSource: song.mediaSource,
  571. prefill: songPrefillData.value[song.mediaSource]
  572. });
  573. currentSong.value = song;
  574. if (songItems.value[`edit-songs-item-${song.mediaSource}`])
  575. songItems.value[
  576. `edit-songs-item-${song.mediaSource}`
  577. ].scrollIntoView();
  578. });
  579. };
  580. const editNextSong = () => {
  581. const currentlyEditingSongIndex = filteredEditingItemIndex.value;
  582. let newEditingSongIndex = -1;
  583. const index =
  584. currentlyEditingSongIndex + 1 === filteredItems.value.length
  585. ? 0
  586. : currentlyEditingSongIndex + 1;
  587. for (let i = index; i < filteredItems.value.length; i += 1) {
  588. if (!flagFilter.value || filteredItems.value[i].flagged) {
  589. newEditingSongIndex = i;
  590. break;
  591. }
  592. }
  593. if (newEditingSongIndex > -1) {
  594. const nextSong = filteredItems.value[newEditingSongIndex].song;
  595. if (nextSong.removed) editNextSong();
  596. else pickSong(nextSong);
  597. }
  598. };
  599. const saveSong = (refName: string, closeOrNext?: boolean) => {
  600. saveButtonRefName.value = refName;
  601. onSaving(inputs.value.mediaSource.value);
  602. save(() => {
  603. if (closeOrNext && bulk.value) editNextSong();
  604. else if (closeOrNext) closeCurrentModal();
  605. });
  606. };
  607. const toggleFlag = (songIndex = null) => {
  608. if (songIndex && songIndex > -1) {
  609. filteredItems.value[songIndex].flagged =
  610. !filteredItems.value[songIndex].flagged;
  611. new Toast(
  612. `Successfully ${
  613. filteredItems.value[songIndex].flagged ? "flagged" : "unflagged"
  614. } song.`
  615. );
  616. } else if (!songIndex && editingItemIndex.value > -1) {
  617. items.value[editingItemIndex.value].flagged =
  618. !items.value[editingItemIndex.value].flagged;
  619. new Toast(
  620. `Successfully ${
  621. items.value[editingItemIndex.value].flagged
  622. ? "flagged"
  623. : "unflagged"
  624. } song.`
  625. );
  626. }
  627. };
  628. const onThumbnailLoad = () => {
  629. if (thumbnailElement.value) {
  630. const height = thumbnailElement.value.naturalHeight;
  631. const width = thumbnailElement.value.naturalWidth;
  632. thumbnailNotSquare.value = height !== width;
  633. thumbnailHeight.value = height;
  634. thumbnailWidth.value = width;
  635. } else {
  636. thumbnailNotSquare.value = false;
  637. thumbnailHeight.value = null;
  638. thumbnailWidth.value = null;
  639. }
  640. };
  641. const onThumbnailLoadError = error => {
  642. thumbnailLoadError.value = error !== 0;
  643. };
  644. const isYoutubeThumbnail = computed(
  645. () =>
  646. songDataLoaded.value &&
  647. inputs.value.mediaSource.value &&
  648. inputs.value.mediaSource.value.startsWith("youtube:") &&
  649. inputs.value.thumbnail.value &&
  650. (inputs.value.thumbnail.value.lastIndexOf("i.ytimg.com") !== -1 ||
  651. inputs.value.thumbnail.value.lastIndexOf("img.youtube.com") !== -1)
  652. );
  653. const drawCanvas = async () => {
  654. if (!songDataLoaded.value || !canvasElement.value) return;
  655. const ctx = canvasElement.value.getContext("2d");
  656. const videoDuration = Number(youtubeVideoDuration.value);
  657. const skipDuration = Number(inputs.value.skipDuration.value);
  658. const duration = Number(inputs.value.duration.value);
  659. const afterDuration = videoDuration - (skipDuration + duration);
  660. const width = 530;
  661. const currentTime = await getCurrentPlayerTime();
  662. const widthSkipDuration = (skipDuration / videoDuration) * width;
  663. const widthDuration = (duration / videoDuration) * width;
  664. const widthAfterDuration = (afterDuration / videoDuration) * width;
  665. const widthCurrentTime = (currentTime / videoDuration) * width;
  666. const skipDurationColor = "#F42003";
  667. const durationColor = "#03A9F4";
  668. const afterDurationColor = "#41E841";
  669. const currentDurationColor = "#3b25e8";
  670. ctx.fillStyle = skipDurationColor;
  671. ctx.fillRect(0, 0, widthSkipDuration, 20);
  672. ctx.fillStyle = durationColor;
  673. ctx.fillRect(widthSkipDuration, 0, widthDuration, 20);
  674. ctx.fillStyle = afterDurationColor;
  675. ctx.fillRect(widthSkipDuration + widthDuration, 0, widthAfterDuration, 20);
  676. ctx.fillStyle = currentDurationColor;
  677. ctx.fillRect(widthCurrentTime, 0, 1, 20);
  678. };
  679. const playerPlay = () => {
  680. if (currentSongMediaType.value === "youtube") {
  681. soundcloudPause();
  682. if (
  683. youtubePlayerReady.value &&
  684. video.value.player &&
  685. video.value.player.playVideo
  686. )
  687. video.value.player.playVideo();
  688. } else if (currentSongMediaType.value === "soundcloud") {
  689. if (
  690. youtubePlayerReady.value &&
  691. video.value.player &&
  692. video.value.player.pauseVideo
  693. )
  694. video.value.player.pauseVideo();
  695. soundcloudPlay();
  696. }
  697. };
  698. const seekTo = (position, play = true) => {
  699. if (currentSongMediaType.value === "youtube") {
  700. if (play) {
  701. video.value.player.seekTo(position);
  702. pauseVideo(false);
  703. playerPlay();
  704. }
  705. }
  706. if (currentSongMediaType.value === "soundcloud") {
  707. soundcloudSeekTo(position * 1000);
  708. if (play) {
  709. soundcloudPlay();
  710. }
  711. }
  712. };
  713. const getAlbumData = type => {
  714. if (!inputs.value.discogs.value) return;
  715. if (type === "title")
  716. setValue({ title: inputs.value.discogs.value.track.title });
  717. if (type === "albumArt")
  718. setValue({ thumbnail: inputs.value.discogs.value.album.albumArt });
  719. if (type === "genres")
  720. setValue({
  721. genres: JSON.parse(
  722. JSON.stringify(inputs.value.discogs.value.album.genres)
  723. )
  724. });
  725. if (type === "artists")
  726. setValue({
  727. artists: JSON.parse(
  728. JSON.stringify(inputs.value.discogs.value.album.artists)
  729. )
  730. });
  731. };
  732. const getYouTubeData = type => {
  733. if (type === "title") {
  734. try {
  735. const { title } = video.value.player.getVideoData();
  736. if (title) setValue({ title });
  737. else throw new Error("No title found");
  738. } catch (e) {
  739. new Toast(
  740. "Unable to fetch YouTube video title. Try starting the video."
  741. );
  742. }
  743. }
  744. if (type === "thumbnail")
  745. setValue({
  746. thumbnail: `https://img.youtube.com/vi/${
  747. inputs.value.mediaSource.value.split(":")[1]
  748. }/mqdefault.jpg`
  749. });
  750. if (type === "author") {
  751. try {
  752. const { author } = video.value.player.getVideoData();
  753. if (author) setValue({ addArtist: author });
  754. else throw new Error("No video author found");
  755. } catch (e) {
  756. new Toast(
  757. "Unable to fetch YouTube video author. Try starting the video."
  758. );
  759. }
  760. }
  761. };
  762. const getSoundCloudData = type => {
  763. if (type === "title") {
  764. try {
  765. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  766. const { title } = soundcloudCurrentSound;
  767. if (title) setValue({ title });
  768. else throw new Error("No title found");
  769. });
  770. } catch (e) {
  771. new Toast("Unable to fetch SoundCloud track title.");
  772. }
  773. }
  774. if (type === "thumbnail") {
  775. setValue({
  776. thumbnail: `https://img.youtube.com/vi/${
  777. inputs.value.mediaSource.value.split(":")[1]
  778. }/mqdefault.jpg`
  779. });
  780. try {
  781. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  782. const { artwork_url: artworkUrl } = soundcloudCurrentSound;
  783. if (artworkUrl) setValue({ thumbnail: artworkUrl });
  784. else throw new Error("No thumbnail found");
  785. });
  786. } catch (e) {
  787. new Toast("Unable to fetch SoundCloud track artwork.");
  788. }
  789. }
  790. if (type === "author") {
  791. try {
  792. soundcloudGetCurrentSound(soundcloudCurrentSound => {
  793. const { user } = soundcloudCurrentSound;
  794. if (user) setValue({ addArtist: user.username });
  795. else throw new Error("No artist found");
  796. });
  797. } catch (e) {
  798. new Toast("Unable to fetch SoundCloud track artist.");
  799. }
  800. }
  801. };
  802. const fillDuration = () => {
  803. if (currentSongMediaType.value === "youtube")
  804. setValue({
  805. duration:
  806. Number.parseFloat(youtubeVideoDuration.value) -
  807. inputs.value.skipDuration.value
  808. });
  809. else if (currentSongMediaType.value === "soundcloud") {
  810. soundcloudGetDuration(duration => {
  811. setValue({
  812. duration:
  813. Number.parseFloat(duration) / 1000 -
  814. inputs.value.skipDuration.value
  815. });
  816. });
  817. }
  818. };
  819. const playerPause = () => {
  820. if (
  821. youtubePlayerReady.value &&
  822. video.value.player &&
  823. video.value.player.pauseVideo
  824. )
  825. video.value.player.pauseVideo();
  826. soundcloudPause();
  827. };
  828. const settings = type => {
  829. switch (type) {
  830. case "stop":
  831. stopVideo();
  832. playerPause();
  833. pauseVideo(true);
  834. break;
  835. case "hardStop":
  836. playerHardStop();
  837. pauseVideo(true);
  838. break;
  839. case "pause":
  840. playerPause();
  841. pauseVideo(true);
  842. break;
  843. case "play":
  844. playerPlay();
  845. pauseVideo(false);
  846. break;
  847. case "skipToLast10Secs":
  848. seekTo(
  849. inputs.value.duration.value -
  850. 10 +
  851. inputs.value.skipDuration.value
  852. );
  853. break;
  854. default:
  855. break;
  856. }
  857. };
  858. const play = () => {
  859. if (
  860. currentSongMediaType.value === "youtube" &&
  861. inputs.value.mediaSource.value !==
  862. `youtube:${video.value.player.getVideoData().video_id}`
  863. ) {
  864. setValue({ duration: -1 });
  865. loadVideoById(
  866. inputs.value.mediaSource.value.split(":")[1],
  867. inputs.value.skipDuration.value
  868. );
  869. }
  870. console.log(
  871. `|${
  872. inputs.value.mediaSource.value
  873. }|--|soundcloud:${soundcloudGetTrackId()}|`
  874. );
  875. if (
  876. currentSongMediaType.value === "soundcloud" &&
  877. `${inputs.value.mediaSource.value}` !==
  878. `soundcloud:${soundcloudGetTrackId()}`
  879. ) {
  880. setValue({ duration: -1 });
  881. console.log(
  882. "ON PLAY LOAD SC",
  883. currentSongMediaValue.value,
  884. Math.max(Number(inputs.value.skipDuration.value), 0),
  885. true
  886. );
  887. soundcloudLoadTrack(
  888. currentSongMediaValue.value,
  889. Math.max(Number(inputs.value.skipDuration.value), 0),
  890. true
  891. );
  892. }
  893. settings("play");
  894. };
  895. const changeSoundcloudPlayerVolume = () => {
  896. if (muted.value) soundcloudSetVolume(0);
  897. else soundcloudSetVolume(volumeSliderValue.value);
  898. };
  899. const changePlayerVolume = () => {
  900. if (youtubePlayerReady.value) {
  901. video.value.player.setVolume(volumeSliderValue.value);
  902. if (muted.value) video.value.player.mute();
  903. else video.value.player.unMute();
  904. }
  905. changeSoundcloudPlayerVolume();
  906. };
  907. const changeVolume = () => {
  908. const volume = volumeSliderValue.value;
  909. localStorage.setItem("volume", `${volume}`);
  910. muted.value = volume <= 0;
  911. localStorage.setItem("muted", `${muted.value}`);
  912. changePlayerVolume();
  913. };
  914. const toggleMute = () => {
  915. muted.value = !muted.value;
  916. changePlayerVolume();
  917. };
  918. const addTag = (type, value?) => {
  919. if (type === "genres") {
  920. const genre = value || inputs.value.addGenre.value.trim();
  921. if (
  922. inputs.value.genres.value
  923. .map(genre => genre.toLowerCase())
  924. .indexOf(genre.toLowerCase()) !== -1
  925. )
  926. return new Toast("Genre already exists");
  927. if (genre) {
  928. inputs.value.genres.value.push(genre);
  929. setValue({ addGenre: "" });
  930. return false;
  931. }
  932. return new Toast("Genre cannot be empty");
  933. }
  934. if (type === "artists") {
  935. const artist = value || inputs.value.addArtist.value.trim();
  936. if (inputs.value.artists.value.indexOf(artist) !== -1)
  937. return new Toast("Artist already exists");
  938. if (artist !== "") {
  939. inputs.value.artists.value.push(artist);
  940. setValue({ addArtist: "" });
  941. return false;
  942. }
  943. return new Toast("Artist cannot be empty");
  944. }
  945. if (type === "tags") {
  946. const tag = value || inputs.value.addTag.value.trim();
  947. if (inputs.value.tags.value.indexOf(tag) !== -1)
  948. return new Toast("Tag already exists");
  949. if (tag !== "") {
  950. inputs.value.tags.value.push(tag);
  951. setValue({ addTag: "" });
  952. return false;
  953. }
  954. return new Toast("Tag cannot be empty");
  955. }
  956. return false;
  957. };
  958. const removeTag = (type, value) => {
  959. if (type === "genres")
  960. inputs.value.genres.value.splice(
  961. inputs.value.genres.value.indexOf(value),
  962. 1
  963. );
  964. else if (type === "artists")
  965. inputs.value.artists.value.splice(
  966. inputs.value.artists.value.indexOf(value),
  967. 1
  968. );
  969. else if (type === "tags")
  970. inputs.value.tags.value.splice(
  971. inputs.value.tags.value.indexOf(value),
  972. 1
  973. );
  974. };
  975. const setTrackPosition = async event => {
  976. const clickPosition =
  977. (event.pageX - event.target.getBoundingClientRect().left) / 530;
  978. if (currentSongMediaType.value === "youtube" && youtubePlayerReady.value) {
  979. seekTo(
  980. Number(Number(video.value.player.getDuration()) * clickPosition)
  981. );
  982. }
  983. if (currentSongMediaType.value === "soundcloud") {
  984. const duration = await getPlayerDuration();
  985. seekTo(Number(Number(duration) * clickPosition));
  986. }
  987. };
  988. const toggleGenreHelper = () => {
  989. genreHelper.value.toggleBox();
  990. };
  991. const resetGenreHelper = () => {
  992. genreHelper.value.resetBox();
  993. };
  994. const sendActivityWatchMediaData = () => {
  995. // TODO have this support soundcloud
  996. if (
  997. !video.value.paused &&
  998. (currentSongMediaType.value !== "youtube" ||
  999. video.value.player.getPlayerState() ===
  1000. window.YT.PlayerState.PLAYING)
  1001. ) {
  1002. if (activityWatchMediaLastStatus.value !== "playing") {
  1003. activityWatchMediaLastStatus.value = "playing";
  1004. if (
  1005. inputs.value.skipDuration.value > 0 &&
  1006. Number(youtubeVideoCurrentTime.value) === 0
  1007. ) {
  1008. activityWatchMediaLastStartDuration.value = Math.floor(
  1009. inputs.value.skipDuration.value +
  1010. Number(youtubeVideoCurrentTime.value)
  1011. );
  1012. } else {
  1013. activityWatchMediaLastStartDuration.value = Math.floor(
  1014. Number(youtubeVideoCurrentTime.value)
  1015. );
  1016. }
  1017. }
  1018. const videoData = {
  1019. title: inputs.value.title.value,
  1020. artists: inputs.value.artists.value
  1021. ? inputs.value.artists.value.join(", ")
  1022. : null,
  1023. mediaSource: inputs.value.mediaSource.value,
  1024. muted: muted.value,
  1025. volume: volumeSliderValue.value,
  1026. startedDuration:
  1027. activityWatchMediaLastStartDuration.value <= 0
  1028. ? 0
  1029. : activityWatchMediaLastStartDuration.value,
  1030. source: `editSong#${inputs.value.mediaSource.value}`,
  1031. hostname: window.location.hostname,
  1032. playerState: Object.keys(window.YT.PlayerState).find(
  1033. key =>
  1034. window.YT.PlayerState[key] ===
  1035. video.value.player.getPlayerState()
  1036. ),
  1037. playbackRate: video.value.playbackRate
  1038. };
  1039. aw.sendMediaData(videoData);
  1040. } else {
  1041. activityWatchMediaLastStatus.value = "not_playing";
  1042. }
  1043. };
  1044. const remove = id => {
  1045. socket.dispatch("songs.remove", id, res => {
  1046. new Toast(res.message);
  1047. });
  1048. };
  1049. watch(
  1050. [() => inputs.value.duration.value, () => inputs.value.skipDuration.value],
  1051. () => drawCanvas()
  1052. );
  1053. watch(mediaSource, (_mediaSource, _oldMediaSource) => {
  1054. if (_oldMediaSource) unloadSong(_oldMediaSource);
  1055. if (_mediaSource) loadSong(_mediaSource, true);
  1056. });
  1057. watch(
  1058. () => inputs.value.mediaSource.value,
  1059. value => {
  1060. if (
  1061. value.split(":")[0] === "youtube" &&
  1062. video.value.player &&
  1063. video.value.player.cueVideoById
  1064. ) {
  1065. soundcloudUnload();
  1066. video.value.player.cueVideoById(
  1067. value.split(":")[1],
  1068. inputs.value.skipDuration.value
  1069. );
  1070. }
  1071. if (value.split(":")[0] === "soundcloud") {
  1072. playerPause();
  1073. console.log(
  1074. "ON WATCH LOAD SC",
  1075. value.split(":")[1],
  1076. Number(inputs.value.skipDuration.value),
  1077. true
  1078. );
  1079. soundcloudLoadTrack(
  1080. value.split(":")[1],
  1081. Number(inputs.value.skipDuration.value),
  1082. true
  1083. );
  1084. }
  1085. }
  1086. );
  1087. watch(
  1088. () => hasPermission("songs.update"),
  1089. value => {
  1090. if (!value) closeCurrentModal(true);
  1091. }
  1092. );
  1093. watch(
  1094. () => discogsEnabled.value || inputs.value.discogs.value,
  1095. value => {
  1096. if (!value && tab.value === "discogs") showTab("musare-songs");
  1097. }
  1098. );
  1099. onMounted(async () => {
  1100. editSongStore.init({ song: props.song, songs: props.songs });
  1101. if (!(discogsEnabled.value || inputs.value.discogs.value))
  1102. showTab("musare-songs");
  1103. editSongStore.form = {
  1104. inputs,
  1105. unsavedChanges,
  1106. save,
  1107. setValue,
  1108. setOriginalValue
  1109. };
  1110. preventCloseCbs[props.modalUuid] = onCloseOrNext;
  1111. activityWatchMediaDataInterval.value = setInterval(() => {
  1112. sendActivityWatchMediaData();
  1113. }, 1000);
  1114. socket.onConnect(() => {
  1115. if (newSong.value && !mediaSource.value && !bulk.value) {
  1116. setSong({
  1117. mediaSource: "",
  1118. title: "",
  1119. artists: [],
  1120. genres: [],
  1121. tags: [],
  1122. duration: 0,
  1123. skipDuration: 0,
  1124. thumbnail: "",
  1125. verified: false
  1126. });
  1127. songDataLoaded.value = true;
  1128. showTab("youtube");
  1129. } else if (mediaSource.value) loadSong(mediaSource.value);
  1130. else if (!bulk.value) {
  1131. new Toast("You can't open EditSong without editing a song");
  1132. return closeCurrentModal();
  1133. }
  1134. interval.value = setInterval(async () => {
  1135. const currentPlayerTime = await getCurrentPlayerTime();
  1136. const playerDuration = await getPlayerDuration();
  1137. if (
  1138. inputs.value.duration.value !== -1 &&
  1139. video.value.paused === false
  1140. ) {
  1141. if (
  1142. (currentSongMediaType.value === "youtube" &&
  1143. youtubePlayerReady.value) ||
  1144. currentSongMediaType.value === "soundcloud"
  1145. ) {
  1146. if (
  1147. currentPlayerTime - inputs.value.skipDuration.value >
  1148. inputs.value.duration.value ||
  1149. (currentPlayerTime > 0 &&
  1150. currentPlayerTime >= playerDuration)
  1151. ) {
  1152. pauseVideo(true);
  1153. playerPause();
  1154. seekTo(0, false);
  1155. drawCanvas();
  1156. }
  1157. }
  1158. }
  1159. if (
  1160. currentSongMediaType.value === "youtube" &&
  1161. youtubePlayerReady.value &&
  1162. video.value.player.getVideoData &&
  1163. video.value.player.getVideoData() &&
  1164. `youtube:${video.value.player.getVideoData().video_id}` ===
  1165. inputs.value.mediaSource.value
  1166. ) {
  1167. const currentTime = video.value.player.getCurrentTime();
  1168. if (currentTime !== undefined)
  1169. youtubeVideoCurrentTime.value = currentTime.toFixed(3);
  1170. if (youtubeVideoDuration.value.indexOf(".000") !== -1) {
  1171. const duration = video.value.player.getDuration();
  1172. if (duration !== undefined) {
  1173. if (
  1174. `${youtubeVideoDuration.value}` ===
  1175. `${Number(inputs.value.duration.value).toFixed(3)}`
  1176. )
  1177. setValue({ duration: duration.toFixed(3) });
  1178. youtubeVideoDuration.value = duration.toFixed(3);
  1179. if (youtubeVideoDuration.value.indexOf(".000") !== -1)
  1180. youtubeVideoNote.value = "(~)";
  1181. else youtubeVideoNote.value = "";
  1182. drawCanvas();
  1183. }
  1184. }
  1185. }
  1186. if (currentSongMediaType.value === "soundcloud") {
  1187. console.log(
  1188. "INTERVAL SOUNDCLOUD",
  1189. currentPlayerTime,
  1190. playerDuration,
  1191. youtubeVideoCurrentTime.value,
  1192. youtubeVideoDuration.value,
  1193. inputs.value.duration.value
  1194. );
  1195. if (currentPlayerTime)
  1196. youtubeVideoCurrentTime.value =
  1197. Number(currentPlayerTime).toFixed(3);
  1198. if (youtubeVideoDuration.value === "0.000") {
  1199. if (playerDuration) {
  1200. youtubeVideoDuration.value =
  1201. Number(playerDuration).toFixed(3);
  1202. if (youtubeVideoDuration.value.indexOf(".000") !== -1)
  1203. youtubeVideoNote.value = "(~)";
  1204. else youtubeVideoNote.value = "";
  1205. }
  1206. if (
  1207. !inputs.value.duration.value ||
  1208. (Number(inputs.value.duration.value) <= 0 &&
  1209. playerDuration &&
  1210. Number(playerDuration) > 0)
  1211. ) {
  1212. setValue({ duration: playerDuration.toFixed(3) });
  1213. }
  1214. drawCanvas();
  1215. }
  1216. }
  1217. if (video.value.paused === false) drawCanvas();
  1218. }, 200);
  1219. if (window.YT && window.YT.Player) {
  1220. video.value.player = new window.YT.Player(
  1221. `editSongPlayerYouTube-${props.modalUuid}`,
  1222. {
  1223. height: 298,
  1224. width: 530,
  1225. videoId: null,
  1226. host: "https://www.youtube-nocookie.com",
  1227. playerVars: {
  1228. controls: 0,
  1229. iv_load_policy: 3,
  1230. rel: 0,
  1231. showinfo: 0,
  1232. autoplay: 0
  1233. },
  1234. startSeconds: inputs.value.skipDuration.value,
  1235. events: {
  1236. onReady: () => {
  1237. changePlayerVolume();
  1238. youtubePlayerReady.value = true;
  1239. if (
  1240. inputs.value.mediaSource.value &&
  1241. inputs.value.mediaSource.value.startsWith(
  1242. "youtube:"
  1243. )
  1244. )
  1245. video.value.player.cueVideoById(
  1246. inputs.value.mediaSource.value.split(
  1247. ":"
  1248. )[1],
  1249. inputs.value.skipDuration.value
  1250. );
  1251. setPlaybackRate(null);
  1252. drawCanvas();
  1253. },
  1254. onStateChange: event => {
  1255. drawCanvas();
  1256. if (event.data === 1) {
  1257. video.value.paused = false;
  1258. updateMediaModalPlayingAudio(true);
  1259. let youtubeDuration =
  1260. video.value.player.getDuration();
  1261. const newYoutubeVideoDuration =
  1262. youtubeDuration.toFixed(3);
  1263. if (
  1264. youtubeVideoDuration.value.indexOf(
  1265. ".000"
  1266. ) !== -1 &&
  1267. `${youtubeVideoDuration.value}` !==
  1268. `${newYoutubeVideoDuration}`
  1269. ) {
  1270. const songDurationNumber = Number(
  1271. inputs.value.duration.value
  1272. );
  1273. const songDurationNumber2 =
  1274. Number(inputs.value.duration.value) + 1;
  1275. const songDurationNumber3 =
  1276. Number(inputs.value.duration.value) - 1;
  1277. const fixedSongDuration =
  1278. songDurationNumber.toFixed(3);
  1279. const fixedSongDuration2 =
  1280. songDurationNumber2.toFixed(3);
  1281. const fixedSongDuration3 =
  1282. songDurationNumber3.toFixed(3);
  1283. if (
  1284. `${youtubeVideoDuration.value}` ===
  1285. `${Number(
  1286. inputs.value.duration.value
  1287. ).toFixed(3)}` &&
  1288. (fixedSongDuration ===
  1289. youtubeVideoDuration.value ||
  1290. fixedSongDuration2 ===
  1291. youtubeVideoDuration.value ||
  1292. fixedSongDuration3 ===
  1293. youtubeVideoDuration.value)
  1294. )
  1295. setValue({
  1296. duration: newYoutubeVideoDuration
  1297. });
  1298. youtubeVideoDuration.value =
  1299. newYoutubeVideoDuration;
  1300. if (
  1301. youtubeVideoDuration.value.indexOf(
  1302. ".000"
  1303. ) !== -1
  1304. )
  1305. youtubeVideoNote.value = "(~)";
  1306. else youtubeVideoNote.value = "";
  1307. }
  1308. if (inputs.value.duration.value === -1)
  1309. setValue({
  1310. duration: Number.parseFloat(
  1311. youtubeVideoDuration.value
  1312. )
  1313. });
  1314. youtubeDuration -=
  1315. inputs.value.skipDuration.value;
  1316. if (
  1317. inputs.value.duration.value >
  1318. youtubeDuration + 1
  1319. ) {
  1320. pauseVideo(true);
  1321. playerPause();
  1322. seekTo(0, false);
  1323. return new Toast(
  1324. "Video can't play. Specified duration is bigger than the YouTube song duration."
  1325. );
  1326. }
  1327. if (inputs.value.duration.value <= 0) {
  1328. pauseVideo(true);
  1329. playerPause();
  1330. seekTo(0, false);
  1331. return new Toast(
  1332. "Video can't play. Specified duration has to be more than 0 seconds."
  1333. );
  1334. }
  1335. if (
  1336. video.value.player.getCurrentTime() <
  1337. inputs.value.skipDuration.value
  1338. ) {
  1339. return seekTo(
  1340. inputs.value.skipDuration.value
  1341. );
  1342. }
  1343. setPlaybackRate(null);
  1344. } else if (event.data === 2) {
  1345. video.value.paused = true;
  1346. updateMediaModalPlayingAudio(false);
  1347. }
  1348. return false;
  1349. }
  1350. }
  1351. }
  1352. );
  1353. } else {
  1354. youtubeError.value = true;
  1355. youtubeErrorMessage.value = "Player could not be loaded.";
  1356. }
  1357. ["artists", "genres", "tags"].forEach(type => {
  1358. socket.dispatch(
  1359. `songs.get${type.charAt(0).toUpperCase()}${type.slice(1)}`,
  1360. res => {
  1361. if (res.status === "success") {
  1362. const { items } = res.data;
  1363. if (type === "genres")
  1364. autosuggest.value.allItems[type] = Array.from(
  1365. new Set([...recommendedGenres.value, ...items])
  1366. );
  1367. else autosuggest.value.allItems[type] = items;
  1368. } else {
  1369. new Toast(res.message);
  1370. }
  1371. }
  1372. );
  1373. });
  1374. if (bulk.value) {
  1375. socket.dispatch("apis.joinRoom", "edit-songs");
  1376. console.log(68768, mediaSources.value);
  1377. socket.dispatch(
  1378. "songs.getSongsFromMediaSources",
  1379. mediaSources.value,
  1380. res => {
  1381. if (res.data.songs.length === 0) {
  1382. closeCurrentModal();
  1383. new Toast("You can't edit 0 songs.");
  1384. } else {
  1385. items.value = res.data.songs.map(song => ({
  1386. status: "todo",
  1387. flagged: false,
  1388. song
  1389. }));
  1390. editNextSong();
  1391. }
  1392. }
  1393. );
  1394. }
  1395. return null;
  1396. });
  1397. socket.on(
  1398. `event:admin.song.updated`,
  1399. res => {
  1400. if (song.value._id === res.data.song._id)
  1401. setOriginalValue({
  1402. title: res.data.song.title,
  1403. duration: res.data.song.duration,
  1404. skipDuration: res.data.song.skipDuration,
  1405. thumbnail: res.data.song.thumbnail,
  1406. mediaSource: res.data.song.mediaSource,
  1407. verified: res.data.song.verified,
  1408. artists: res.data.song.artists,
  1409. genres: res.data.song.genres,
  1410. tags: res.data.song.tags,
  1411. discogs: res.data.song.discogs
  1412. });
  1413. if (bulk.value) {
  1414. const index = items.value
  1415. .map(item => item.song.mediaSource)
  1416. .indexOf(res.data.song.mediaSource);
  1417. if (index >= 0)
  1418. items.value[index].song = {
  1419. ...items.value[index].song,
  1420. ...res.data.song,
  1421. updated: true
  1422. };
  1423. }
  1424. },
  1425. { modalUuid: props.modalUuid }
  1426. );
  1427. socket.on(
  1428. "event:admin.song.removed",
  1429. res => {
  1430. if (res.data.songId === song.value._id) {
  1431. songDeleted.value = true;
  1432. if (!bulk.value) closeCurrentModal(true);
  1433. }
  1434. },
  1435. { modalUuid: props.modalUuid }
  1436. );
  1437. if (bulk.value) {
  1438. socket.on(
  1439. `event:admin.song.created`,
  1440. res => {
  1441. const index = items.value
  1442. .map(item => item.song.mediaSource)
  1443. .indexOf(res.data.song.mediaSource);
  1444. if (index >= 0)
  1445. items.value[index].song = {
  1446. ...items.value[index].song,
  1447. ...res.data.song,
  1448. created: true
  1449. };
  1450. },
  1451. { modalUuid: props.modalUuid }
  1452. );
  1453. socket.on(
  1454. `event:admin.song.removed`,
  1455. res => {
  1456. const index = items.value
  1457. .map(item => item.song._id)
  1458. .indexOf(res.data.songId);
  1459. if (index >= 0) items.value[index].song.removed = true;
  1460. },
  1461. { modalUuid: props.modalUuid }
  1462. );
  1463. socket.on(
  1464. `event:admin.youtubeVideo.removed`,
  1465. res => {
  1466. const index = items.value
  1467. .map(item => item.song.youtubeVideoId)
  1468. .indexOf(res.videoId);
  1469. if (index >= 0) items.value[index].song.removed = true;
  1470. },
  1471. { modalUuid: props.modalUuid }
  1472. );
  1473. }
  1474. let volume = parseFloat(localStorage.getItem("volume"));
  1475. volume = typeof volume === "number" && !Number.isNaN(volume) ? volume : 20;
  1476. localStorage.setItem("volume", `${volume}`);
  1477. volumeSliderValue.value = volume;
  1478. keyboardShortcuts.registerShortcut("editSong.pauseResumeVideo", {
  1479. keyCode: 101,
  1480. preventDefault: true,
  1481. handler: () => {
  1482. if (video.value.paused) play();
  1483. else settings("pause");
  1484. }
  1485. });
  1486. keyboardShortcuts.registerShortcut("editSong.stopVideo", {
  1487. keyCode: 101,
  1488. ctrl: true,
  1489. preventDefault: true,
  1490. handler: () => {
  1491. settings("stop");
  1492. }
  1493. });
  1494. keyboardShortcuts.registerShortcut("editSong.hardStopVideo", {
  1495. keyCode: 101,
  1496. ctrl: true,
  1497. shift: true,
  1498. preventDefault: true,
  1499. handler: () => {
  1500. settings("hardStop");
  1501. }
  1502. });
  1503. keyboardShortcuts.registerShortcut("editSong.skipToLast10Secs", {
  1504. keyCode: 102,
  1505. preventDefault: true,
  1506. handler: () => {
  1507. settings("skipToLast10Secs");
  1508. }
  1509. });
  1510. keyboardShortcuts.registerShortcut("editSong.lowerVolumeLarge", {
  1511. keyCode: 98,
  1512. preventDefault: true,
  1513. handler: () => {
  1514. volumeSliderValue.value = Math.max(0, volumeSliderValue.value - 10);
  1515. changeVolume();
  1516. }
  1517. });
  1518. keyboardShortcuts.registerShortcut("editSong.lowerVolumeSmall", {
  1519. keyCode: 98,
  1520. ctrl: true,
  1521. preventDefault: true,
  1522. handler: () => {
  1523. volumeSliderValue.value = Math.max(0, volumeSliderValue.value - 1);
  1524. changeVolume();
  1525. }
  1526. });
  1527. keyboardShortcuts.registerShortcut("editSong.increaseVolumeLarge", {
  1528. keyCode: 104,
  1529. preventDefault: true,
  1530. handler: () => {
  1531. volumeSliderValue.value = Math.min(
  1532. 100,
  1533. volumeSliderValue.value + 10
  1534. );
  1535. changeVolume();
  1536. }
  1537. });
  1538. keyboardShortcuts.registerShortcut("editSong.increaseVolumeSmall", {
  1539. keyCode: 104,
  1540. ctrl: true,
  1541. preventDefault: true,
  1542. handler: () => {
  1543. volumeSliderValue.value = Math.min(
  1544. 100,
  1545. volumeSliderValue.value + 1
  1546. );
  1547. changeVolume();
  1548. }
  1549. });
  1550. keyboardShortcuts.registerShortcut("editSong.save", {
  1551. keyCode: 83,
  1552. ctrl: true,
  1553. preventDefault: true,
  1554. handler: () => {
  1555. saveSong("saveButton");
  1556. }
  1557. });
  1558. keyboardShortcuts.registerShortcut("editSong.saveClose", {
  1559. keyCode: 83,
  1560. ctrl: true,
  1561. alt: true,
  1562. preventDefault: true,
  1563. handler: () => {
  1564. saveSong("saveAndCloseButton", true);
  1565. }
  1566. });
  1567. keyboardShortcuts.registerShortcut("editSong.focusTitle", {
  1568. keyCode: 36,
  1569. preventDefault: true,
  1570. handler: () => {
  1571. inputs.value["title-input"].focus();
  1572. }
  1573. });
  1574. keyboardShortcuts.registerShortcut("editSong.useAllDiscogs", {
  1575. keyCode: 68,
  1576. alt: true,
  1577. ctrl: true,
  1578. preventDefault: true,
  1579. handler: () => {
  1580. getAlbumData("title");
  1581. getAlbumData("albumArt");
  1582. getAlbumData("artists");
  1583. getAlbumData("genres");
  1584. }
  1585. });
  1586. /*
  1587. editSong.pauseResume - Num 5 - Pause/resume song
  1588. editSong.stopVideo - Ctrl - Num 5 - Stop
  1589. editSong.hardStopVideo - Shift - Ctrl - Num 5 - Stop
  1590. editSong.skipToLast10Secs - Num 6 - Skip to last 10 seconds
  1591. editSong.lowerVolumeLarge - Num 2 - Volume down by 10
  1592. editSong.lowerVolumeSmall - Ctrl - Num 2 - Volume down by 1
  1593. editSong.increaseVolumeLarge - Num 8 - Volume up by 10
  1594. editSong.increaseVolumeSmall - Ctrl - Num 8 - Volume up by 1
  1595. editSong.focusTitle - Home - Focus the title input
  1596. editSong.focusDicogs - End - Focus the discogs input
  1597. editSong.save - Ctrl - S - Saves song
  1598. editSong.save - Ctrl - Alt - S - Saves song and closes the modal
  1599. editSong.save - Ctrl - Alt - V - Saves song, verifies songs and then closes the modal
  1600. editSong.close - F4 - Closes modal without saving
  1601. editSong.useAllDiscogs - Ctrl - Alt - D - Sets all fields to the Discogs data
  1602. Inside Discogs inputs: Ctrl - D - Sets this field to the Discogs data
  1603. */
  1604. soundcloudBindListener("seek", () => {
  1605. console.debug(TAG, "Bind on seek");
  1606. // if (seeking.value) seeking.value = false;
  1607. });
  1608. soundcloudBindListener("error", value => {
  1609. console.debug(TAG, "Bind on error", value);
  1610. });
  1611. });
  1612. onBeforeUnmount(() => {
  1613. if (bulk.value) {
  1614. socket.dispatch("apis.leaveRoom", "edit-songs");
  1615. }
  1616. unloadSong(mediaSource.value, song.value._id);
  1617. updateMediaModalPlayingAudio(false);
  1618. youtubePlayerReady.value = false;
  1619. clearInterval(interval.value);
  1620. clearInterval(activityWatchMediaDataInterval.value);
  1621. const shortcutNames = [
  1622. "editSong.pauseResume",
  1623. "editSong.stopVideo",
  1624. "editSong.hardStopVideo",
  1625. "editSong.skipToLast10Secs",
  1626. "editSong.lowerVolumeLarge",
  1627. "editSong.lowerVolumeSmall",
  1628. "editSong.increaseVolumeLarge",
  1629. "editSong.increaseVolumeSmall",
  1630. "editSong.focusTitle",
  1631. "editSong.focusDicogs",
  1632. "editSong.save",
  1633. "editSong.saveClose",
  1634. "editSong.useAllDiscogs",
  1635. "editSong.closeModal"
  1636. ];
  1637. shortcutNames.forEach(shortcutName => {
  1638. keyboardShortcuts.unregisterShortcut(shortcutName);
  1639. });
  1640. delete preventCloseCbs[props.modalUuid];
  1641. // Delete the Pinia store that was created for this modal, after all other cleanup tasks are performed
  1642. editSongStore.$dispose();
  1643. });
  1644. </script>
  1645. <template>
  1646. <div>
  1647. <modal
  1648. :title="`${newSong ? 'Create' : 'Edit'} Song`"
  1649. class="song-modal"
  1650. :size="'wide'"
  1651. :split="true"
  1652. >
  1653. <template #toggleMobileSidebar v-if="bulk">
  1654. <i
  1655. class="material-icons toggle-sidebar-icon"
  1656. :content="`${
  1657. sidebarMobileActive ? 'Close' : 'Open'
  1658. } Edit Queue`"
  1659. v-tippy
  1660. @click="toggleMobileSidebar()"
  1661. >expand_circle_down</i
  1662. >
  1663. </template>
  1664. <template #sidebar v-if="bulk">
  1665. <div class="sidebar" :class="{ active: sidebarMobileActive }">
  1666. <header class="sidebar-head">
  1667. <h2 class="sidebar-title is-marginless">Edit Queue</h2>
  1668. <i
  1669. class="material-icons toggle-sidebar-icon"
  1670. :content="`${
  1671. sidebarMobileActive ? 'Close' : 'Open'
  1672. } Edit Queue`"
  1673. v-tippy
  1674. @click="toggleMobileSidebar()"
  1675. >expand_circle_down</i
  1676. >
  1677. </header>
  1678. <section class="sidebar-body">
  1679. <div
  1680. v-show="filteredItems.length > 0"
  1681. class="edit-songs-items"
  1682. >
  1683. <div
  1684. class="item"
  1685. v-for="(data, index) in filteredItems"
  1686. :key="`edit-songs-item-${index}`"
  1687. :ref="
  1688. el =>
  1689. (songItems[
  1690. `edit-songs-item-${data.song.mediaSource}`
  1691. ] = el)
  1692. "
  1693. >
  1694. <media-item
  1695. :song="data.song"
  1696. :thumbnail="false"
  1697. :duration="false"
  1698. :disabled-actions="
  1699. data.song.removed
  1700. ? ['all']
  1701. : ['report', 'edit']
  1702. "
  1703. :class="{
  1704. updated: data.song.updated,
  1705. removed: data.song.removed
  1706. }"
  1707. >
  1708. <template #leftIcon>
  1709. <i
  1710. v-if="
  1711. currentSong.mediaSource ===
  1712. data.song.mediaSource &&
  1713. !data.song.removed
  1714. "
  1715. class="material-icons item-icon editing-icon"
  1716. content="Currently editing song"
  1717. v-tippy="{ theme: 'info' }"
  1718. @click="toggleDone(index)"
  1719. >edit</i
  1720. >
  1721. <i
  1722. v-else-if="data.song.removed"
  1723. class="material-icons item-icon removed-icon"
  1724. content="Song removed"
  1725. v-tippy="{ theme: 'info' }"
  1726. >delete_forever</i
  1727. >
  1728. <i
  1729. v-else-if="data.status === 'error'"
  1730. class="material-icons item-icon error-icon"
  1731. content="Error saving song"
  1732. v-tippy="{ theme: 'info' }"
  1733. @click="toggleDone(index)"
  1734. >error</i
  1735. >
  1736. <i
  1737. v-else-if="data.status === 'saving'"
  1738. class="material-icons item-icon saving-icon"
  1739. content="Currently saving song"
  1740. v-tippy="{ theme: 'info' }"
  1741. >pending</i
  1742. >
  1743. <i
  1744. v-else-if="data.flagged"
  1745. class="material-icons item-icon flag-icon"
  1746. content="Song flagged"
  1747. v-tippy="{ theme: 'info' }"
  1748. @click="toggleDone(index)"
  1749. >flag_circle</i
  1750. >
  1751. <i
  1752. v-else-if="data.status === 'done'"
  1753. class="material-icons item-icon done-icon"
  1754. content="Song marked complete"
  1755. v-tippy="{ theme: 'info' }"
  1756. @click="toggleDone(index)"
  1757. >check_circle</i
  1758. >
  1759. <i
  1760. v-else-if="data.status === 'todo'"
  1761. class="material-icons item-icon todo-icon"
  1762. content="Song marked todo"
  1763. v-tippy="{ theme: 'info' }"
  1764. @click="toggleDone(index)"
  1765. >cancel</i
  1766. >
  1767. </template>
  1768. <template
  1769. v-if="!data.song.removed"
  1770. #actions
  1771. >
  1772. <i
  1773. class="material-icons edit-icon"
  1774. content="Edit Song"
  1775. v-tippy
  1776. @click="pickSong(data.song)"
  1777. >
  1778. edit
  1779. </i>
  1780. </template>
  1781. <template #tippyActions>
  1782. <i
  1783. class="material-icons flag-icon"
  1784. :class="{
  1785. flagged: data.flagged
  1786. }"
  1787. content="Toggle Flag"
  1788. v-tippy
  1789. @click="toggleFlag(index)"
  1790. >
  1791. flag_circle
  1792. </i>
  1793. </template>
  1794. </media-item>
  1795. </div>
  1796. </div>
  1797. <p v-if="filteredItems.length === 0" class="no-items">
  1798. {{
  1799. flagFilter
  1800. ? "No flagged songs queued"
  1801. : "No songs queued"
  1802. }}
  1803. </p>
  1804. </section>
  1805. <footer class="sidebar-foot">
  1806. <button
  1807. @click="toggleFlagFilter()"
  1808. class="button is-primary"
  1809. >
  1810. {{
  1811. flagFilter
  1812. ? "Show All Songs"
  1813. : "Show Only Flagged Songs"
  1814. }}
  1815. </button>
  1816. </footer>
  1817. </div>
  1818. <div
  1819. v-if="sidebarMobileActive"
  1820. class="sidebar-overlay"
  1821. @click="toggleMobileSidebar()"
  1822. ></div>
  1823. </template>
  1824. <template #body>
  1825. <div v-if="!mediaSource && !newSong" class="notice-container">
  1826. <h4>No song has been selected</h4>
  1827. </div>
  1828. <div v-if="songDeleted" class="notice-container">
  1829. <h4>The song you were editing has been deleted</h4>
  1830. </div>
  1831. <div
  1832. v-if="
  1833. mediaSource &&
  1834. !songDataLoaded &&
  1835. !songNotFound &&
  1836. !newSong
  1837. "
  1838. class="notice-container"
  1839. >
  1840. <h4>Song hasn't loaded yet</h4>
  1841. </div>
  1842. <div
  1843. v-if="mediaSource && songNotFound && !newSong"
  1844. class="notice-container"
  1845. >
  1846. <h4>Song was not found</h4>
  1847. </div>
  1848. <div
  1849. class="left-section"
  1850. v-show="songDataLoaded && !songDeleted"
  1851. >
  1852. <div class="top-section">
  1853. <div class="player-section">
  1854. <div
  1855. v-show="currentSongMediaType === 'youtube'"
  1856. class="youtube-player-wrapper"
  1857. >
  1858. <div
  1859. :id="`editSongPlayerYouTube-${modalUuid}`"
  1860. ></div>
  1861. </div>
  1862. <iframe
  1863. v-if="experimental.soundcloud"
  1864. :id="`editSongPlayerSoundCloud-${modalUuid}`"
  1865. v-show="currentSongMediaType === 'soundcloud'"
  1866. ref="soundcloudIframeElement"
  1867. style="
  1868. width: 100%;
  1869. height: 100%;
  1870. min-height: 200px;
  1871. "
  1872. scrolling="no"
  1873. frameborder="no"
  1874. allow="autoplay"
  1875. ></iframe>
  1876. <div
  1877. class="player-message"
  1878. v-show="
  1879. currentSongMediaType === 'soundcloud' &&
  1880. !experimental.soundcloud
  1881. "
  1882. >
  1883. <h2>SoundCloud is not enabled</h2>
  1884. </div>
  1885. <div
  1886. class="player-message"
  1887. v-show="
  1888. currentSongMediaType !== 'youtube' &&
  1889. currentSongMediaType !== 'soundcloud'
  1890. "
  1891. >
  1892. <h2>No media source specified</h2>
  1893. </div>
  1894. <div v-show="youtubeError" class="player-error">
  1895. <h2>{{ youtubeErrorMessage }}</h2>
  1896. </div>
  1897. <canvas
  1898. ref="canvasElement"
  1899. class="duration-canvas"
  1900. v-show="!youtubeError"
  1901. height="20"
  1902. width="530"
  1903. @click="setTrackPosition($event)"
  1904. />
  1905. <div class="player-footer">
  1906. <div class="player-footer-left">
  1907. <button
  1908. class="button is-primary"
  1909. @click="play()"
  1910. @keyup.enter="play()"
  1911. v-if="video.paused"
  1912. content="Resume Playback"
  1913. v-tippy
  1914. >
  1915. <i class="material-icons">play_arrow</i>
  1916. </button>
  1917. <button
  1918. class="button is-primary"
  1919. @click="settings('pause')"
  1920. @keyup.enter="settings('pause')"
  1921. v-else
  1922. content="Pause Playback"
  1923. v-tippy
  1924. >
  1925. <i class="material-icons">pause</i>
  1926. </button>
  1927. <button
  1928. class="button is-danger"
  1929. @click.exact="settings('stop')"
  1930. @click.shift="settings('hardStop')"
  1931. @keyup.enter.exact="settings('stop')"
  1932. @keyup.shift.enter="
  1933. settings('hardStop')
  1934. "
  1935. content="Stop Playback"
  1936. v-tippy
  1937. >
  1938. <i class="material-icons">stop</i>
  1939. </button>
  1940. <tippy
  1941. class="playerRateDropdown"
  1942. :touch="true"
  1943. :interactive="true"
  1944. placement="bottom"
  1945. theme="dropdown"
  1946. ref="dropdown"
  1947. trigger="click"
  1948. append-to="parent"
  1949. @show="
  1950. () => {
  1951. showRateDropdown = true;
  1952. }
  1953. "
  1954. @hide="
  1955. () => {
  1956. showRateDropdown = false;
  1957. }
  1958. "
  1959. >
  1960. <div
  1961. ref="trigger"
  1962. class="control has-addons"
  1963. content="Set Playback Rate"
  1964. v-tippy
  1965. >
  1966. <button class="button is-primary">
  1967. <i class="material-icons"
  1968. >fast_forward</i
  1969. >
  1970. </button>
  1971. <button
  1972. class="button dropdown-toggle"
  1973. >
  1974. <i class="material-icons">
  1975. {{
  1976. showRateDropdown
  1977. ? "expand_more"
  1978. : "expand_less"
  1979. }}
  1980. </i>
  1981. </button>
  1982. </div>
  1983. <template #content>
  1984. <div class="nav-dropdown-items">
  1985. <button
  1986. class="nav-item button"
  1987. :class="{
  1988. active:
  1989. video.playbackRate ===
  1990. 0.5
  1991. }"
  1992. title="0.5x"
  1993. @click="
  1994. setPlaybackRate(0.5)
  1995. "
  1996. >
  1997. <p>0.5x</p>
  1998. </button>
  1999. <button
  2000. class="nav-item button"
  2001. :class="{
  2002. active:
  2003. video.playbackRate ===
  2004. 1
  2005. }"
  2006. title="1x"
  2007. @click="setPlaybackRate(1)"
  2008. >
  2009. <p>1x</p>
  2010. </button>
  2011. <button
  2012. class="nav-item button"
  2013. :class="{
  2014. active:
  2015. video.playbackRate ===
  2016. 2
  2017. }"
  2018. title="2x"
  2019. @click="setPlaybackRate(2)"
  2020. >
  2021. <p>2x</p>
  2022. </button>
  2023. </div>
  2024. </template>
  2025. </tippy>
  2026. </div>
  2027. <div class="player-footer-center">
  2028. <span>
  2029. <span>
  2030. {{ youtubeVideoCurrentTime }}
  2031. </span>
  2032. /
  2033. <span>
  2034. {{ youtubeVideoDuration }}
  2035. {{ youtubeVideoNote }}
  2036. </span>
  2037. </span>
  2038. </div>
  2039. <div class="player-footer-right">
  2040. <p id="volume-control">
  2041. <i
  2042. class="material-icons"
  2043. @click="toggleMute()"
  2044. :content="`${
  2045. muted ? 'Unmute' : 'Mute'
  2046. }`"
  2047. v-tippy
  2048. >{{
  2049. muted
  2050. ? "volume_mute"
  2051. : volumeSliderValue >= 50
  2052. ? "volume_up"
  2053. : "volume_down"
  2054. }}</i
  2055. >
  2056. <input
  2057. v-model="volumeSliderValue"
  2058. type="range"
  2059. min="0"
  2060. max="100"
  2061. class="volume-slider active"
  2062. @change="changeVolume()"
  2063. @input="changeVolume()"
  2064. />
  2065. </p>
  2066. </div>
  2067. </div>
  2068. </div>
  2069. <song-thumbnail
  2070. v-if="songDataLoaded && !songDeleted"
  2071. :song="{
  2072. mediaSource: inputs['mediaSource'].value,
  2073. thumbnail: inputs['thumbnail'].value
  2074. }"
  2075. :fallback="false"
  2076. class="thumbnail-preview"
  2077. @load-error="onThumbnailLoadError"
  2078. />
  2079. <img
  2080. v-if="
  2081. !isYoutubeThumbnail &&
  2082. songDataLoaded &&
  2083. !songDeleted
  2084. "
  2085. class="thumbnail-dummy"
  2086. :src="inputs['thumbnail'].value"
  2087. ref="thumbnailElement"
  2088. @load="onThumbnailLoad"
  2089. />
  2090. </div>
  2091. <div
  2092. class="edit-section"
  2093. v-if="songDataLoaded && !songDeleted"
  2094. >
  2095. <div class="control is-grouped">
  2096. <div class="title-container">
  2097. <label class="label">Title</label>
  2098. <p class="control has-addons">
  2099. <input
  2100. class="input"
  2101. type="text"
  2102. :ref="el => (inputs['title'].ref = el)"
  2103. v-model="inputs['title'].value"
  2104. placeholder="Enter song title..."
  2105. @keyup.shift.enter="
  2106. getAlbumData('title')
  2107. "
  2108. />
  2109. <button
  2110. v-if="
  2111. currentSongMediaType ===
  2112. 'soundcloud' &&
  2113. experimental.soundcloud
  2114. "
  2115. class="button soundcloud-get-button"
  2116. @click="getSoundCloudData('title')"
  2117. >
  2118. <div
  2119. class="soundcloud-icon"
  2120. v-tippy
  2121. content="Fill from SoundCloud"
  2122. ></div>
  2123. </button>
  2124. <button
  2125. v-if="
  2126. currentSongMediaType ===
  2127. 'youtube' && youtubePlayerReady
  2128. "
  2129. class="button youtube-get-button"
  2130. @click="getYouTubeData('title')"
  2131. >
  2132. <div
  2133. class="youtube-icon"
  2134. v-tippy
  2135. content="Fill from YouTube"
  2136. ></div>
  2137. </button>
  2138. <button
  2139. v-if="inputs.discogs.value"
  2140. class="button album-get-button"
  2141. @click="getAlbumData('title')"
  2142. >
  2143. <i
  2144. class="material-icons"
  2145. v-tippy
  2146. content="Fill from Discogs"
  2147. >album</i
  2148. >
  2149. </button>
  2150. </p>
  2151. </div>
  2152. <div class="duration-container">
  2153. <label class="label">Duration</label>
  2154. <p class="control has-addons">
  2155. <input
  2156. class="input"
  2157. type="text"
  2158. placeholder="Enter song duration..."
  2159. v-model.number="
  2160. inputs['duration'].value
  2161. "
  2162. @keyup.shift.enter="fillDuration()"
  2163. />
  2164. <button
  2165. class="button duration-fill-button"
  2166. @click="fillDuration()"
  2167. >
  2168. <i
  2169. class="material-icons"
  2170. v-tippy
  2171. content="Sync duration with player"
  2172. >sync</i
  2173. >
  2174. </button>
  2175. </p>
  2176. </div>
  2177. <div class="skip-duration-container">
  2178. <label class="label">Skip duration</label>
  2179. <p class="control">
  2180. <input
  2181. class="input"
  2182. type="text"
  2183. placeholder="Enter skip duration..."
  2184. v-model.number="
  2185. inputs['skipDuration'].value
  2186. "
  2187. />
  2188. </p>
  2189. </div>
  2190. </div>
  2191. <div class="control is-grouped">
  2192. <div class="album-art-container">
  2193. <label class="label">
  2194. Thumbnail
  2195. <i
  2196. v-if="
  2197. thumbnailNotSquare &&
  2198. !isYoutubeThumbnail
  2199. "
  2200. class="material-icons thumbnail-warning"
  2201. content="Thumbnail not square, it will be stretched"
  2202. v-tippy="{ theme: 'info' }"
  2203. >
  2204. warning
  2205. </i>
  2206. <i
  2207. v-if="
  2208. thumbnailLoadError &&
  2209. !isYoutubeThumbnail
  2210. "
  2211. class="material-icons thumbnail-warning"
  2212. content="Error loading thumbnail"
  2213. v-tippy="{ theme: 'info' }"
  2214. >
  2215. warning
  2216. </i>
  2217. </label>
  2218. <p class="control has-addons">
  2219. <input
  2220. class="input"
  2221. type="text"
  2222. v-model="inputs['thumbnail'].value"
  2223. placeholder="Enter link to thumbnail..."
  2224. @keyup.shift.enter="
  2225. getAlbumData('albumArt')
  2226. "
  2227. />
  2228. <button
  2229. v-if="
  2230. currentSongMediaType ===
  2231. 'soundcloud' &&
  2232. experimental.soundcloud
  2233. "
  2234. class="button soundcloud-get-button"
  2235. @click="getSoundCloudData('thumbnail')"
  2236. >
  2237. <div
  2238. class="soundcloud-icon"
  2239. v-tippy
  2240. content="Fill from SoundCloud"
  2241. ></div>
  2242. </button>
  2243. <button
  2244. v-if="
  2245. currentSongMediaType ===
  2246. 'youtube' && youtubePlayerReady
  2247. "
  2248. class="button youtube-get-button"
  2249. @click="getYouTubeData('thumbnail')"
  2250. >
  2251. <div
  2252. class="youtube-icon"
  2253. v-tippy
  2254. content="Fill from YouTube"
  2255. ></div>
  2256. </button>
  2257. <button
  2258. v-if="inputs.discogs.value"
  2259. class="button album-get-button"
  2260. @click="getAlbumData('albumArt')"
  2261. >
  2262. <i
  2263. class="material-icons"
  2264. v-tippy
  2265. content="Fill from Discogs"
  2266. >album</i
  2267. >
  2268. </button>
  2269. </p>
  2270. </div>
  2271. <div class="youtube-id-container">
  2272. <label class="label">Media source</label>
  2273. <p class="control">
  2274. <input
  2275. class="input"
  2276. type="text"
  2277. placeholder="Enter media source..."
  2278. v-model="inputs['mediaSource'].value"
  2279. />
  2280. </p>
  2281. </div>
  2282. <div class="verified-container">
  2283. <label class="label">Verified</label>
  2284. <p class="is-expanded checkbox-control">
  2285. <label class="switch">
  2286. <input
  2287. type="checkbox"
  2288. id="verified"
  2289. v-model="inputs['verified'].value"
  2290. />
  2291. <span class="slider round"></span>
  2292. </label>
  2293. </p>
  2294. </div>
  2295. </div>
  2296. <div class="control is-grouped">
  2297. <div class="artists-container">
  2298. <label class="label">Artists</label>
  2299. <p class="control has-addons">
  2300. <auto-suggest
  2301. v-model="inputs['addArtist'].value"
  2302. ref="new-artist"
  2303. placeholder="Add artist..."
  2304. :all-items="
  2305. autosuggest.allItems.artists
  2306. "
  2307. @submitted="addTag('artists')"
  2308. @keyup.shift.enter="
  2309. getAlbumData('artists')
  2310. "
  2311. />
  2312. <button
  2313. v-if="
  2314. currentSongMediaType ===
  2315. 'soundcloud' &&
  2316. experimental.soundcloud
  2317. "
  2318. class="button soundcloud-get-button"
  2319. @click="getSoundCloudData('author')"
  2320. >
  2321. <div
  2322. class="soundcloud-icon"
  2323. v-tippy
  2324. content="Fill from SoundCloud"
  2325. ></div>
  2326. </button>
  2327. <button
  2328. v-if="
  2329. currentSongMediaType ===
  2330. 'youtube' && youtubePlayerReady
  2331. "
  2332. class="button youtube-get-button"
  2333. @click="getYouTubeData('author')"
  2334. >
  2335. <div
  2336. class="youtube-icon"
  2337. v-tippy
  2338. content="Fill from YouTube"
  2339. ></div>
  2340. </button>
  2341. <button
  2342. v-if="inputs.discogs.value"
  2343. class="button album-get-button"
  2344. @click="getAlbumData('artists')"
  2345. >
  2346. <i
  2347. class="material-icons"
  2348. v-tippy
  2349. content="Fill from Discogs"
  2350. >album</i
  2351. >
  2352. </button>
  2353. <button
  2354. class="button is-info add-button"
  2355. @click="addTag('artists')"
  2356. >
  2357. <i class="material-icons">add</i>
  2358. </button>
  2359. </p>
  2360. <div class="list-container">
  2361. <div
  2362. class="list-item"
  2363. v-for="artist in inputs['artists']
  2364. .value"
  2365. :key="artist"
  2366. >
  2367. <div
  2368. class="list-item-circle"
  2369. @click="
  2370. removeTag('artists', artist)
  2371. "
  2372. >
  2373. <i class="material-icons">close</i>
  2374. </div>
  2375. <p>{{ artist }}</p>
  2376. </div>
  2377. </div>
  2378. </div>
  2379. <div class="genres-container">
  2380. <label class="label">
  2381. <span>Genres</span>
  2382. <i
  2383. class="material-icons"
  2384. @click="toggleGenreHelper"
  2385. @dblclick="resetGenreHelper"
  2386. v-tippy
  2387. content="View list of genres"
  2388. >info</i
  2389. >
  2390. </label>
  2391. <p class="control has-addons">
  2392. <auto-suggest
  2393. v-model="inputs['addGenre'].value"
  2394. ref="new-genre"
  2395. placeholder="Add genre..."
  2396. :all-items="autosuggest.allItems.genres"
  2397. @submitted="addTag('genres')"
  2398. @keyup.shift.enter="
  2399. getAlbumData('genres')
  2400. "
  2401. />
  2402. <button
  2403. v-if="inputs.discogs.value"
  2404. class="button album-get-button"
  2405. @click="getAlbumData('genres')"
  2406. >
  2407. <i
  2408. class="material-icons"
  2409. v-tippy
  2410. content="Fill from Discogs"
  2411. >album</i
  2412. >
  2413. </button>
  2414. <button
  2415. class="button is-info add-button"
  2416. @click="addTag('genres')"
  2417. >
  2418. <i class="material-icons">add</i>
  2419. </button>
  2420. </p>
  2421. <div class="list-container">
  2422. <div
  2423. class="list-item"
  2424. v-for="genre in inputs['genres'].value"
  2425. :key="genre"
  2426. >
  2427. <div
  2428. class="list-item-circle"
  2429. @click="removeTag('genres', genre)"
  2430. >
  2431. <i class="material-icons">close</i>
  2432. </div>
  2433. <p>{{ genre }}</p>
  2434. </div>
  2435. </div>
  2436. </div>
  2437. <div class="tags-container">
  2438. <label class="label">Tags</label>
  2439. <p class="control has-addons">
  2440. <auto-suggest
  2441. v-model="inputs['addTag'].value"
  2442. ref="new-tag"
  2443. placeholder="Add tag..."
  2444. :all-items="autosuggest.allItems.tags"
  2445. @submitted="addTag('tags')"
  2446. />
  2447. <button
  2448. class="button is-info add-button"
  2449. @click="addTag('tags')"
  2450. >
  2451. <i class="material-icons">add</i>
  2452. </button>
  2453. </p>
  2454. <div class="list-container">
  2455. <div
  2456. class="list-item"
  2457. v-for="tag in inputs['tags'].value"
  2458. :key="tag"
  2459. >
  2460. <div
  2461. class="list-item-circle"
  2462. @click="removeTag('tags', tag)"
  2463. >
  2464. <i class="material-icons">close</i>
  2465. </div>
  2466. <p>{{ tag }}</p>
  2467. </div>
  2468. </div>
  2469. </div>
  2470. </div>
  2471. </div>
  2472. </div>
  2473. <div
  2474. class="right-section"
  2475. v-if="songDataLoaded && !songDeleted"
  2476. >
  2477. <div id="tabs-container">
  2478. <div id="tab-selection">
  2479. <button
  2480. v-if="discogsEnabled || inputs.discogs.value"
  2481. class="button is-default"
  2482. :class="{ selected: tab === 'discogs' }"
  2483. :ref="el => (tabs['discogs-tab'] = el)"
  2484. @click="showTab('discogs')"
  2485. >
  2486. Discogs
  2487. </button>
  2488. <button
  2489. v-if="!newSong"
  2490. class="button is-default"
  2491. :class="{ selected: tab === 'reports' }"
  2492. :ref="el => (tabs['reports-tab'] = el)"
  2493. @click="showTab('reports')"
  2494. >
  2495. Reports ({{ reports.length }})
  2496. </button>
  2497. <button
  2498. class="button is-default"
  2499. :class="{ selected: tab === 'youtube' }"
  2500. :ref="el => (tabs['youtube-tab'] = el)"
  2501. @click="showTab('youtube')"
  2502. >
  2503. YouTube
  2504. </button>
  2505. <button
  2506. class="button is-default"
  2507. :class="{ selected: tab === 'musare-songs' }"
  2508. :ref="el => (tabs['musare-songs-tab'] = el)"
  2509. @click="showTab('musare-songs')"
  2510. >
  2511. Songs
  2512. </button>
  2513. </div>
  2514. <discogs
  2515. v-if="discogsEnabled || inputs.discogs.value"
  2516. class="tab"
  2517. v-show="tab === 'discogs'"
  2518. :bulk="bulk"
  2519. :modal-uuid="modalUuid"
  2520. :modal-module-path="modalModulePath"
  2521. />
  2522. <reports-tab
  2523. v-if="!newSong"
  2524. class="tab"
  2525. v-show="tab === 'reports'"
  2526. :modal-uuid="modalUuid"
  2527. :modal-module-path="modalModulePath"
  2528. />
  2529. <youtube
  2530. class="tab"
  2531. v-show="tab === 'youtube'"
  2532. :modal-uuid="modalUuid"
  2533. :modal-module-path="modalModulePath"
  2534. />
  2535. <musare-songs
  2536. class="tab"
  2537. v-show="tab === 'musare-songs'"
  2538. :modal-uuid="modalUuid"
  2539. :modal-module-path="modalModulePath"
  2540. />
  2541. </div>
  2542. </div>
  2543. </template>
  2544. <template #footer>
  2545. <div v-if="bulk">
  2546. <button class="button is-primary" @click="editNextSong()">
  2547. Next
  2548. </button>
  2549. <button
  2550. class="button is-primary"
  2551. @click="toggleFlag()"
  2552. v-if="mediaSource && !songDeleted"
  2553. >
  2554. {{ currentSongFlagged ? "Unflag" : "Flag" }}
  2555. </button>
  2556. </div>
  2557. <div v-if="!newSong && !songDeleted">
  2558. <save-button
  2559. :ref="el => (saveButtonRefs['saveButton'] = el)"
  2560. @clicked="saveSong('saveButton')"
  2561. />
  2562. <save-button
  2563. :ref="el => (saveButtonRefs['saveAndCloseButton'] = el)"
  2564. :default-message="
  2565. bulk ? `Save and next` : `Save and close`
  2566. "
  2567. @clicked="saveSong('saveAndCloseButton', true)"
  2568. />
  2569. <div class="right">
  2570. <button
  2571. v-if="hasPermission('songs.remove')"
  2572. class="button is-danger icon-with-button material-icons"
  2573. @click.prevent="
  2574. openModal({
  2575. modal: 'confirm',
  2576. props: {
  2577. message:
  2578. 'Removing this song will remove it from all playlists and cause a ratings recalculation.',
  2579. onCompleted: () => remove(song._id)
  2580. }
  2581. })
  2582. "
  2583. content="Delete Song"
  2584. v-tippy
  2585. >
  2586. delete_forever
  2587. </button>
  2588. </div>
  2589. </div>
  2590. <div v-else-if="newSong">
  2591. <save-button
  2592. :ref="el => (saveButtonRefs['createButton'] = el)"
  2593. default-message="Create Song"
  2594. @clicked="saveSong('createButton')"
  2595. />
  2596. <save-button
  2597. :ref="
  2598. el => (saveButtonRefs['createAndCloseButton'] = el)
  2599. "
  2600. :default-message="
  2601. bulk ? `Create and next` : `Create and close`
  2602. "
  2603. @clicked="saveSong('createAndCloseButton', true)"
  2604. />
  2605. </div>
  2606. </template>
  2607. </modal>
  2608. <floating-box
  2609. id="genreHelper"
  2610. ref="genreHelper"
  2611. :column="false"
  2612. title="Song Genres List"
  2613. >
  2614. <template #body>
  2615. <span
  2616. v-for="item in autosuggest.allItems.genres"
  2617. :key="`genre-helper-${item}`"
  2618. >
  2619. {{ item }}
  2620. </span>
  2621. </template>
  2622. </floating-box>
  2623. </div>
  2624. </template>
  2625. <style lang="less" scoped>
  2626. .night-mode {
  2627. .edit-section,
  2628. .player-section,
  2629. #tabs-container {
  2630. background-color: var(--dark-grey-3) !important;
  2631. border: 0 !important;
  2632. .tab {
  2633. border: 0 !important;
  2634. }
  2635. }
  2636. #tabs-container #tab-selection .button {
  2637. background: var(--dark-grey) !important;
  2638. color: var(--white) !important;
  2639. }
  2640. .left-section {
  2641. .edit-section {
  2642. .album-get-button,
  2643. .duration-fill-button,
  2644. .youtube-get-button,
  2645. .soundcloud-get-button,
  2646. .add-button {
  2647. &:focus,
  2648. &:hover {
  2649. border: none !important;
  2650. }
  2651. }
  2652. }
  2653. }
  2654. .duration-canvas {
  2655. background-color: var(--dark-grey-2) !important;
  2656. }
  2657. .sidebar {
  2658. .sidebar-head,
  2659. .sidebar-foot {
  2660. background-color: var(--dark-grey-3);
  2661. border: none;
  2662. }
  2663. .sidebar-body {
  2664. background-color: var(--dark-grey-4) !important;
  2665. }
  2666. .sidebar-head .toggle-sidebar-icon.material-icons,
  2667. .sidebar-title {
  2668. color: var(--white);
  2669. }
  2670. p,
  2671. label,
  2672. td,
  2673. th {
  2674. color: var(--light-grey-2) !important;
  2675. }
  2676. h1,
  2677. h2,
  2678. h3,
  2679. h4,
  2680. h5,
  2681. h6 {
  2682. color: var(--white) !important;
  2683. }
  2684. }
  2685. }
  2686. .modal-card-body {
  2687. display: flex;
  2688. }
  2689. .notice-container {
  2690. display: flex;
  2691. flex: 1;
  2692. justify-content: center;
  2693. h4 {
  2694. margin: auto;
  2695. }
  2696. }
  2697. .left-section {
  2698. height: 100%;
  2699. display: flex;
  2700. flex-direction: column;
  2701. margin-right: 16px;
  2702. .top-section {
  2703. display: flex;
  2704. .player-section {
  2705. width: 530px;
  2706. display: flex;
  2707. flex-direction: column;
  2708. border: 1px solid var(--light-grey-3);
  2709. border-radius: @border-radius;
  2710. overflow: hidden;
  2711. .youtube-player-wrapper {
  2712. display: flex;
  2713. > * {
  2714. flex: 1;
  2715. }
  2716. }
  2717. .duration-canvas {
  2718. background-color: var(--light-grey-2);
  2719. }
  2720. .player-error,
  2721. .player-message {
  2722. display: flex;
  2723. height: 318px;
  2724. width: 530px;
  2725. align-items: center;
  2726. * {
  2727. margin: 0;
  2728. flex: 1;
  2729. font-size: 30px;
  2730. text-align: center;
  2731. }
  2732. }
  2733. .player-footer {
  2734. display: flex;
  2735. justify-content: space-between;
  2736. height: 54px;
  2737. padding-left: 10px;
  2738. padding-right: 10px;
  2739. > * {
  2740. width: 33.3%;
  2741. display: flex;
  2742. align-items: center;
  2743. }
  2744. .player-footer-left {
  2745. flex: 1;
  2746. & > .button:not(:first-child) {
  2747. margin-left: 5px;
  2748. }
  2749. :deep(& > .playerRateDropdown) {
  2750. margin-left: 5px;
  2751. margin-bottom: unset !important;
  2752. .control.has-addons {
  2753. margin-bottom: unset !important;
  2754. & > .button {
  2755. font-size: 24px;
  2756. }
  2757. }
  2758. }
  2759. :deep(.tippy-box[data-theme~="dropdown"]) {
  2760. max-width: 100px !important;
  2761. .nav-dropdown-items .nav-item {
  2762. justify-content: center !important;
  2763. border-radius: @border-radius !important;
  2764. &.active {
  2765. background-color: var(--primary-color);
  2766. color: var(--white);
  2767. }
  2768. }
  2769. }
  2770. }
  2771. .player-footer-center {
  2772. justify-content: center;
  2773. align-items: center;
  2774. flex: 2;
  2775. font-size: 18px;
  2776. font-weight: 400;
  2777. width: 200px;
  2778. margin: 0 5px;
  2779. img {
  2780. height: 21px;
  2781. margin-right: 12px;
  2782. filter: invert(26%) sepia(54%) saturate(6317%)
  2783. hue-rotate(2deg) brightness(92%) contrast(115%);
  2784. }
  2785. }
  2786. .player-footer-right {
  2787. justify-content: right;
  2788. flex: 1;
  2789. #volume-control {
  2790. margin: 3px;
  2791. margin-top: 0;
  2792. display: flex;
  2793. align-items: center;
  2794. cursor: pointer;
  2795. .volume-slider {
  2796. width: 100%;
  2797. padding: 0 15px;
  2798. background: transparent;
  2799. min-width: 100px;
  2800. }
  2801. input[type="range"] {
  2802. -webkit-appearance: none;
  2803. margin: 7.3px 0;
  2804. }
  2805. input[type="range"]:focus {
  2806. outline: none;
  2807. }
  2808. input[type="range"]::-webkit-slider-runnable-track {
  2809. width: 100%;
  2810. height: 5.2px;
  2811. cursor: pointer;
  2812. box-shadow: 0;
  2813. background: var(--light-grey-3);
  2814. border-radius: @border-radius;
  2815. border: 0;
  2816. }
  2817. input[type="range"]::-webkit-slider-thumb {
  2818. box-shadow: 0;
  2819. border: 0;
  2820. height: 19px;
  2821. width: 19px;
  2822. border-radius: 100%;
  2823. background: var(--primary-color);
  2824. cursor: pointer;
  2825. -webkit-appearance: none;
  2826. margin-top: -6.5px;
  2827. }
  2828. input[type="range"]::-moz-range-track {
  2829. width: 100%;
  2830. height: 5.2px;
  2831. cursor: pointer;
  2832. box-shadow: 0;
  2833. background: var(--light-grey-3);
  2834. border-radius: @border-radius;
  2835. border: 0;
  2836. }
  2837. input[type="range"]::-moz-range-thumb {
  2838. box-shadow: 0;
  2839. border: 0;
  2840. height: 19px;
  2841. width: 19px;
  2842. border-radius: 100%;
  2843. background: var(--primary-color);
  2844. cursor: pointer;
  2845. -webkit-appearance: none;
  2846. margin-top: -6.5px;
  2847. }
  2848. input[type="range"]::-ms-track {
  2849. width: 100%;
  2850. height: 5.2px;
  2851. cursor: pointer;
  2852. box-shadow: 0;
  2853. background: var(--light-grey-3);
  2854. border-radius: @border-radius;
  2855. }
  2856. input[type="range"]::-ms-fill-lower {
  2857. background: var(--light-grey-3);
  2858. border: 0;
  2859. border-radius: 0;
  2860. box-shadow: 0;
  2861. }
  2862. input[type="range"]::-ms-fill-upper {
  2863. background: var(--light-grey-3);
  2864. border: 0;
  2865. border-radius: 0;
  2866. box-shadow: 0;
  2867. }
  2868. input[type="range"]::-ms-thumb {
  2869. box-shadow: 0;
  2870. border: 0;
  2871. height: 15px;
  2872. width: 15px;
  2873. border-radius: 100%;
  2874. background: var(--primary-color);
  2875. cursor: pointer;
  2876. -webkit-appearance: none;
  2877. margin-top: 1.5px;
  2878. }
  2879. }
  2880. }
  2881. }
  2882. }
  2883. :deep(.thumbnail-preview) {
  2884. width: 189px;
  2885. height: 189px;
  2886. margin-left: 16px;
  2887. }
  2888. .thumbnail-dummy {
  2889. opacity: 0;
  2890. height: 10px;
  2891. width: 10px;
  2892. }
  2893. }
  2894. .edit-section {
  2895. display: flex;
  2896. flex-wrap: wrap;
  2897. flex-grow: 1;
  2898. border: 1px solid var(--light-grey-3);
  2899. margin-top: 16px;
  2900. border-radius: @border-radius;
  2901. .album-get-button {
  2902. background-color: var(--purple);
  2903. color: var(--white);
  2904. width: 32px;
  2905. text-align: center;
  2906. border-width: 0;
  2907. }
  2908. .duration-fill-button,
  2909. .youtube-get-button {
  2910. background-color: var(--dark-red);
  2911. color: var(--white);
  2912. width: 32px;
  2913. text-align: center;
  2914. border-width: 0;
  2915. }
  2916. .soundcloud-get-button {
  2917. background-color: var(--orange);
  2918. color: var(--white);
  2919. width: 32px;
  2920. text-align: center;
  2921. border-width: 0;
  2922. }
  2923. .add-button {
  2924. background-color: var(--primary-color) !important;
  2925. width: 32px;
  2926. i {
  2927. font-size: 32px;
  2928. }
  2929. }
  2930. .album-get-button,
  2931. .duration-fill-button,
  2932. .youtube-get-button,
  2933. .add-button {
  2934. &:focus,
  2935. &:hover {
  2936. filter: contrast(0.75);
  2937. border: 1px solid var(--black) !important;
  2938. }
  2939. }
  2940. .youtube-get-button,
  2941. .soundcloud-get-button {
  2942. padding-left: 4px;
  2943. padding-right: 4px;
  2944. .youtube-icon,
  2945. .soundcloud-icon,
  2946. .spotify-icon {
  2947. background: var(--white);
  2948. }
  2949. }
  2950. > div {
  2951. margin: 16px !important;
  2952. width: 100%;
  2953. }
  2954. input {
  2955. width: 100%;
  2956. }
  2957. .title-container {
  2958. width: calc((100% - 32px) / 2);
  2959. }
  2960. .duration-container {
  2961. margin-right: 16px;
  2962. margin-left: 16px;
  2963. width: calc((100% - 32px) / 4);
  2964. }
  2965. .skip-duration-container {
  2966. width: calc((100% - 32px) / 4);
  2967. }
  2968. .album-art-container {
  2969. margin-right: 16px;
  2970. width: 100%;
  2971. }
  2972. .youtube-id-container {
  2973. margin-right: 16px;
  2974. width: calc((100% - 16px) / 8 * 3);
  2975. }
  2976. .verified-container {
  2977. width: calc((100% - 16px) / 8);
  2978. .checkbox-control {
  2979. margin-top: 10px;
  2980. }
  2981. }
  2982. .artists-container {
  2983. width: calc((100% - 32px) / 3);
  2984. position: relative;
  2985. }
  2986. .genres-container {
  2987. width: calc((100% - 32px) / 3);
  2988. margin-left: 16px;
  2989. margin-right: 16px;
  2990. position: relative;
  2991. label {
  2992. display: flex;
  2993. i {
  2994. font-size: 15px;
  2995. align-self: center;
  2996. margin-left: 5px;
  2997. color: var(--primary-color);
  2998. cursor: pointer;
  2999. -webkit-user-select: none;
  3000. -moz-user-select: none;
  3001. -ms-user-select: none;
  3002. user-select: none;
  3003. }
  3004. }
  3005. }
  3006. .tags-container {
  3007. width: calc((100% - 32px) / 3);
  3008. position: relative;
  3009. }
  3010. .list-item-circle {
  3011. background-color: var(--primary-color);
  3012. width: 16px;
  3013. height: 16px;
  3014. border-radius: 8px;
  3015. cursor: pointer;
  3016. margin-right: 8px;
  3017. float: left;
  3018. -webkit-touch-callout: none;
  3019. -webkit-user-select: none;
  3020. -khtml-user-select: none;
  3021. -moz-user-select: none;
  3022. -ms-user-select: none;
  3023. user-select: none;
  3024. i {
  3025. color: var(--primary-color);
  3026. font-size: 14px;
  3027. margin-left: 1px;
  3028. position: relative;
  3029. top: -1px;
  3030. }
  3031. }
  3032. .list-item-circle:hover,
  3033. .list-item-circle:focus {
  3034. i {
  3035. color: var(--white);
  3036. }
  3037. }
  3038. .list-item > p {
  3039. line-height: 16px;
  3040. word-wrap: break-word;
  3041. width: calc(100% - 24px);
  3042. left: 24px;
  3043. float: left;
  3044. margin-bottom: 8px;
  3045. }
  3046. .list-item:last-child > p {
  3047. margin-bottom: 0;
  3048. }
  3049. .thumbnail-warning {
  3050. color: var(--red);
  3051. font-size: 18px;
  3052. margin: auto 0 auto 5px;
  3053. }
  3054. }
  3055. }
  3056. .right-section {
  3057. flex-basis: unset !important;
  3058. flex-grow: 0 !important;
  3059. display: flex;
  3060. height: 100%;
  3061. #tabs-container {
  3062. width: 376px;
  3063. #tab-selection {
  3064. display: flex;
  3065. overflow-x: auto;
  3066. .button {
  3067. border-radius: @border-radius @border-radius 0 0;
  3068. border: 0;
  3069. text-transform: uppercase;
  3070. font-size: 14px;
  3071. color: var(--dark-grey-3);
  3072. background-color: var(--light-grey-2);
  3073. flex-grow: 1;
  3074. height: 32px;
  3075. &:not(:first-of-type) {
  3076. margin-left: 5px;
  3077. }
  3078. }
  3079. .selected {
  3080. background-color: var(--primary-color) !important;
  3081. color: var(--white) !important;
  3082. font-weight: 600;
  3083. }
  3084. }
  3085. .tab {
  3086. border: 1px solid var(--light-grey-3);
  3087. border-radius: 0 0 @border-radius @border-radius;
  3088. padding: 15px;
  3089. height: calc(100% - 32px);
  3090. overflow: auto;
  3091. }
  3092. }
  3093. }
  3094. @media screen and (max-width: 1100px) {
  3095. .left-section,
  3096. .right-section {
  3097. height: unset;
  3098. max-height: unset;
  3099. }
  3100. .left-section {
  3101. margin-right: 0;
  3102. }
  3103. .right-section {
  3104. flex-basis: 100% !important;
  3105. #tabs-container {
  3106. width: 100%;
  3107. }
  3108. }
  3109. }
  3110. .modal-card-foot .is-primary {
  3111. width: 200px;
  3112. }
  3113. :deep(.autosuggest-container) {
  3114. top: unset;
  3115. }
  3116. .toggle-sidebar-icon {
  3117. display: none;
  3118. }
  3119. .sidebar {
  3120. width: 100%;
  3121. max-width: 350px;
  3122. z-index: 2000;
  3123. display: flex;
  3124. flex-direction: column;
  3125. position: relative;
  3126. height: 100%;
  3127. max-height: calc(100vh - 40px);
  3128. overflow: auto;
  3129. margin-right: 8px;
  3130. border-radius: @border-radius;
  3131. .sidebar-head,
  3132. .sidebar-foot {
  3133. display: flex;
  3134. flex-shrink: 0;
  3135. position: relative;
  3136. justify-content: flex-start;
  3137. align-items: center;
  3138. padding: 20px;
  3139. background-color: var(--light-grey);
  3140. }
  3141. .sidebar-head {
  3142. border-bottom: 1px solid var(--light-grey-2);
  3143. border-radius: @border-radius @border-radius 0 0;
  3144. .sidebar-title {
  3145. display: flex;
  3146. flex: 1;
  3147. margin: 0;
  3148. font-size: 26px;
  3149. font-weight: 600;
  3150. }
  3151. }
  3152. .sidebar-body {
  3153. background-color: var(--white);
  3154. display: flex;
  3155. flex-direction: column;
  3156. row-gap: 8px;
  3157. flex: 1;
  3158. overflow: auto;
  3159. padding: 10px;
  3160. .edit-songs-items {
  3161. display: flex;
  3162. flex-direction: column;
  3163. row-gap: 8px;
  3164. .item {
  3165. display: flex;
  3166. flex-direction: row;
  3167. align-items: center;
  3168. column-gap: 8px;
  3169. :deep(.song-item) {
  3170. .item-icon {
  3171. margin-right: 10px;
  3172. cursor: pointer;
  3173. }
  3174. .removed-icon,
  3175. .error-icon {
  3176. color: var(--red);
  3177. }
  3178. .saving-icon,
  3179. .todo-icon,
  3180. .editing-icon {
  3181. color: var(--primary-color);
  3182. }
  3183. .done-icon {
  3184. color: var(--green);
  3185. }
  3186. .flag-icon {
  3187. color: var(--orange);
  3188. &.flagged {
  3189. color: var(--grey);
  3190. }
  3191. }
  3192. &.removed {
  3193. filter: grayscale(100%);
  3194. cursor: not-allowed;
  3195. user-select: none;
  3196. }
  3197. }
  3198. }
  3199. }
  3200. .no-items {
  3201. text-align: center;
  3202. font-size: 18px;
  3203. }
  3204. }
  3205. .sidebar-foot {
  3206. border-top: 1px solid var(--light-grey-2);
  3207. border-radius: 0 0 @border-radius @border-radius;
  3208. .button {
  3209. flex: 1;
  3210. }
  3211. }
  3212. .sidebar-overlay {
  3213. display: none;
  3214. }
  3215. }
  3216. @media only screen and (max-width: 1580px) {
  3217. .toggle-sidebar-icon {
  3218. display: flex;
  3219. margin-right: 5px;
  3220. transform: rotate(90deg);
  3221. cursor: pointer;
  3222. }
  3223. .sidebar {
  3224. display: none;
  3225. &.active {
  3226. display: flex;
  3227. position: absolute;
  3228. z-index: 2010;
  3229. top: 20px;
  3230. left: 20px;
  3231. .sidebar-head .toggle-sidebar-icon {
  3232. display: flex;
  3233. margin-left: 5px;
  3234. transform: rotate(-90deg);
  3235. }
  3236. }
  3237. }
  3238. .sidebar-overlay {
  3239. display: flex;
  3240. position: absolute;
  3241. z-index: 2009;
  3242. top: 0;
  3243. left: 0;
  3244. right: 0;
  3245. bottom: 0;
  3246. background-color: rgba(10, 10, 10, 0.85);
  3247. }
  3248. }
  3249. </style>