index.vue 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554
  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 } = 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. :id="`editSongPlayerSoundCloud-${modalUuid}`"
  1864. v-show="currentSongMediaType === 'soundcloud'"
  1865. ref="soundcloudIframeElement"
  1866. style="
  1867. width: 100%;
  1868. height: 100%;
  1869. min-height: 200px;
  1870. "
  1871. scrolling="no"
  1872. frameborder="no"
  1873. allow="autoplay"
  1874. ></iframe>
  1875. <div
  1876. class="no-media-source-specified-message"
  1877. v-show="
  1878. currentSongMediaType !== 'youtube' &&
  1879. currentSongMediaType !== 'soundcloud'
  1880. "
  1881. >
  1882. <h2>No media source specified</h2>
  1883. </div>
  1884. <div v-show="youtubeError" class="player-error">
  1885. <h2>{{ youtubeErrorMessage }}</h2>
  1886. </div>
  1887. <canvas
  1888. ref="canvasElement"
  1889. class="duration-canvas"
  1890. v-show="!youtubeError"
  1891. height="20"
  1892. width="530"
  1893. @click="setTrackPosition($event)"
  1894. />
  1895. <div class="player-footer">
  1896. <div class="player-footer-left">
  1897. <button
  1898. class="button is-primary"
  1899. @click="play()"
  1900. @keyup.enter="play()"
  1901. v-if="video.paused"
  1902. content="Resume Playback"
  1903. v-tippy
  1904. >
  1905. <i class="material-icons">play_arrow</i>
  1906. </button>
  1907. <button
  1908. class="button is-primary"
  1909. @click="settings('pause')"
  1910. @keyup.enter="settings('pause')"
  1911. v-else
  1912. content="Pause Playback"
  1913. v-tippy
  1914. >
  1915. <i class="material-icons">pause</i>
  1916. </button>
  1917. <button
  1918. class="button is-danger"
  1919. @click.exact="settings('stop')"
  1920. @click.shift="settings('hardStop')"
  1921. @keyup.enter.exact="settings('stop')"
  1922. @keyup.shift.enter="
  1923. settings('hardStop')
  1924. "
  1925. content="Stop Playback"
  1926. v-tippy
  1927. >
  1928. <i class="material-icons">stop</i>
  1929. </button>
  1930. <tippy
  1931. class="playerRateDropdown"
  1932. :touch="true"
  1933. :interactive="true"
  1934. placement="bottom"
  1935. theme="dropdown"
  1936. ref="dropdown"
  1937. trigger="click"
  1938. append-to="parent"
  1939. @show="
  1940. () => {
  1941. showRateDropdown = true;
  1942. }
  1943. "
  1944. @hide="
  1945. () => {
  1946. showRateDropdown = false;
  1947. }
  1948. "
  1949. >
  1950. <div
  1951. ref="trigger"
  1952. class="control has-addons"
  1953. content="Set Playback Rate"
  1954. v-tippy
  1955. >
  1956. <button class="button is-primary">
  1957. <i class="material-icons"
  1958. >fast_forward</i
  1959. >
  1960. </button>
  1961. <button
  1962. class="button dropdown-toggle"
  1963. >
  1964. <i class="material-icons">
  1965. {{
  1966. showRateDropdown
  1967. ? "expand_more"
  1968. : "expand_less"
  1969. }}
  1970. </i>
  1971. </button>
  1972. </div>
  1973. <template #content>
  1974. <div class="nav-dropdown-items">
  1975. <button
  1976. class="nav-item button"
  1977. :class="{
  1978. active:
  1979. video.playbackRate ===
  1980. 0.5
  1981. }"
  1982. title="0.5x"
  1983. @click="
  1984. setPlaybackRate(0.5)
  1985. "
  1986. >
  1987. <p>0.5x</p>
  1988. </button>
  1989. <button
  1990. class="nav-item button"
  1991. :class="{
  1992. active:
  1993. video.playbackRate ===
  1994. 1
  1995. }"
  1996. title="1x"
  1997. @click="setPlaybackRate(1)"
  1998. >
  1999. <p>1x</p>
  2000. </button>
  2001. <button
  2002. class="nav-item button"
  2003. :class="{
  2004. active:
  2005. video.playbackRate ===
  2006. 2
  2007. }"
  2008. title="2x"
  2009. @click="setPlaybackRate(2)"
  2010. >
  2011. <p>2x</p>
  2012. </button>
  2013. </div>
  2014. </template>
  2015. </tippy>
  2016. </div>
  2017. <div class="player-footer-center">
  2018. <span>
  2019. <span>
  2020. {{ youtubeVideoCurrentTime }}
  2021. </span>
  2022. /
  2023. <span>
  2024. {{ youtubeVideoDuration }}
  2025. {{ youtubeVideoNote }}
  2026. </span>
  2027. </span>
  2028. </div>
  2029. <div class="player-footer-right">
  2030. <p id="volume-control">
  2031. <i
  2032. class="material-icons"
  2033. @click="toggleMute()"
  2034. :content="`${
  2035. muted ? 'Unmute' : 'Mute'
  2036. }`"
  2037. v-tippy
  2038. >{{
  2039. muted
  2040. ? "volume_mute"
  2041. : volumeSliderValue >= 50
  2042. ? "volume_up"
  2043. : "volume_down"
  2044. }}</i
  2045. >
  2046. <input
  2047. v-model="volumeSliderValue"
  2048. type="range"
  2049. min="0"
  2050. max="100"
  2051. class="volume-slider active"
  2052. @change="changeVolume()"
  2053. @input="changeVolume()"
  2054. />
  2055. </p>
  2056. </div>
  2057. </div>
  2058. </div>
  2059. <song-thumbnail
  2060. v-if="songDataLoaded && !songDeleted"
  2061. :song="{
  2062. mediaSource: inputs['mediaSource'].value,
  2063. thumbnail: inputs['thumbnail'].value
  2064. }"
  2065. :fallback="false"
  2066. class="thumbnail-preview"
  2067. @load-error="onThumbnailLoadError"
  2068. />
  2069. <img
  2070. v-if="
  2071. !isYoutubeThumbnail &&
  2072. songDataLoaded &&
  2073. !songDeleted
  2074. "
  2075. class="thumbnail-dummy"
  2076. :src="inputs['thumbnail'].value"
  2077. ref="thumbnailElement"
  2078. @load="onThumbnailLoad"
  2079. />
  2080. </div>
  2081. <div
  2082. class="edit-section"
  2083. v-if="songDataLoaded && !songDeleted"
  2084. >
  2085. <div class="control is-grouped">
  2086. <div class="title-container">
  2087. <label class="label">Title</label>
  2088. <p class="control has-addons">
  2089. <input
  2090. class="input"
  2091. type="text"
  2092. :ref="el => (inputs['title'].ref = el)"
  2093. v-model="inputs['title'].value"
  2094. placeholder="Enter song title..."
  2095. @keyup.shift.enter="
  2096. getAlbumData('title')
  2097. "
  2098. />
  2099. <button
  2100. v-if="
  2101. currentSongMediaType ===
  2102. 'soundcloud'
  2103. "
  2104. class="button soundcloud-get-button"
  2105. @click="getSoundCloudData('title')"
  2106. >
  2107. <div
  2108. class="soundcloud-icon"
  2109. v-tippy
  2110. content="Fill from SoundCloud"
  2111. ></div>
  2112. </button>
  2113. <button
  2114. v-if="
  2115. currentSongMediaType ===
  2116. 'youtube' && youtubePlayerReady
  2117. "
  2118. class="button youtube-get-button"
  2119. @click="getYouTubeData('title')"
  2120. >
  2121. <div
  2122. class="youtube-icon"
  2123. v-tippy
  2124. content="Fill from YouTube"
  2125. ></div>
  2126. </button>
  2127. <button
  2128. v-if="inputs.discogs.value"
  2129. class="button album-get-button"
  2130. @click="getAlbumData('title')"
  2131. >
  2132. <i
  2133. class="material-icons"
  2134. v-tippy
  2135. content="Fill from Discogs"
  2136. >album</i
  2137. >
  2138. </button>
  2139. </p>
  2140. </div>
  2141. <div class="duration-container">
  2142. <label class="label">Duration</label>
  2143. <p class="control has-addons">
  2144. <input
  2145. class="input"
  2146. type="text"
  2147. placeholder="Enter song duration..."
  2148. v-model.number="
  2149. inputs['duration'].value
  2150. "
  2151. @keyup.shift.enter="fillDuration()"
  2152. />
  2153. <button
  2154. class="button duration-fill-button"
  2155. @click="fillDuration()"
  2156. >
  2157. <i
  2158. class="material-icons"
  2159. v-tippy
  2160. content="Sync duration with player"
  2161. >sync</i
  2162. >
  2163. </button>
  2164. </p>
  2165. </div>
  2166. <div class="skip-duration-container">
  2167. <label class="label">Skip duration</label>
  2168. <p class="control">
  2169. <input
  2170. class="input"
  2171. type="text"
  2172. placeholder="Enter skip duration..."
  2173. v-model.number="
  2174. inputs['skipDuration'].value
  2175. "
  2176. />
  2177. </p>
  2178. </div>
  2179. </div>
  2180. <div class="control is-grouped">
  2181. <div class="album-art-container">
  2182. <label class="label">
  2183. Thumbnail
  2184. <i
  2185. v-if="
  2186. thumbnailNotSquare &&
  2187. !isYoutubeThumbnail
  2188. "
  2189. class="material-icons thumbnail-warning"
  2190. content="Thumbnail not square, it will be stretched"
  2191. v-tippy="{ theme: 'info' }"
  2192. >
  2193. warning
  2194. </i>
  2195. <i
  2196. v-if="
  2197. thumbnailLoadError &&
  2198. !isYoutubeThumbnail
  2199. "
  2200. class="material-icons thumbnail-warning"
  2201. content="Error loading thumbnail"
  2202. v-tippy="{ theme: 'info' }"
  2203. >
  2204. warning
  2205. </i>
  2206. </label>
  2207. <p class="control has-addons">
  2208. <input
  2209. class="input"
  2210. type="text"
  2211. v-model="inputs['thumbnail'].value"
  2212. placeholder="Enter link to thumbnail..."
  2213. @keyup.shift.enter="
  2214. getAlbumData('albumArt')
  2215. "
  2216. />
  2217. <button
  2218. v-if="
  2219. currentSongMediaType ===
  2220. 'soundcloud'
  2221. "
  2222. class="button soundcloud-get-button"
  2223. @click="getSoundCloudData('thumbnail')"
  2224. >
  2225. <div
  2226. class="soundcloud-icon"
  2227. v-tippy
  2228. content="Fill from SoundCloud"
  2229. ></div>
  2230. </button>
  2231. <button
  2232. v-if="
  2233. currentSongMediaType ===
  2234. 'youtube' && youtubePlayerReady
  2235. "
  2236. class="button youtube-get-button"
  2237. @click="getYouTubeData('thumbnail')"
  2238. >
  2239. <div
  2240. class="youtube-icon"
  2241. v-tippy
  2242. content="Fill from YouTube"
  2243. ></div>
  2244. </button>
  2245. <button
  2246. v-if="inputs.discogs.value"
  2247. class="button album-get-button"
  2248. @click="getAlbumData('albumArt')"
  2249. >
  2250. <i
  2251. class="material-icons"
  2252. v-tippy
  2253. content="Fill from Discogs"
  2254. >album</i
  2255. >
  2256. </button>
  2257. </p>
  2258. </div>
  2259. <div class="youtube-id-container">
  2260. <label class="label">Media source</label>
  2261. <p class="control">
  2262. <input
  2263. class="input"
  2264. type="text"
  2265. placeholder="Enter media source..."
  2266. v-model="inputs['mediaSource'].value"
  2267. />
  2268. </p>
  2269. </div>
  2270. <div class="verified-container">
  2271. <label class="label">Verified</label>
  2272. <p class="is-expanded checkbox-control">
  2273. <label class="switch">
  2274. <input
  2275. type="checkbox"
  2276. id="verified"
  2277. v-model="inputs['verified'].value"
  2278. />
  2279. <span class="slider round"></span>
  2280. </label>
  2281. </p>
  2282. </div>
  2283. </div>
  2284. <div class="control is-grouped">
  2285. <div class="artists-container">
  2286. <label class="label">Artists</label>
  2287. <p class="control has-addons">
  2288. <auto-suggest
  2289. v-model="inputs['addArtist'].value"
  2290. ref="new-artist"
  2291. placeholder="Add artist..."
  2292. :all-items="
  2293. autosuggest.allItems.artists
  2294. "
  2295. @submitted="addTag('artists')"
  2296. @keyup.shift.enter="
  2297. getAlbumData('artists')
  2298. "
  2299. />
  2300. <button
  2301. v-if="
  2302. currentSongMediaType ===
  2303. 'soundcloud'
  2304. "
  2305. class="button soundcloud-get-button"
  2306. @click="getSoundCloudData('author')"
  2307. >
  2308. <div
  2309. class="soundcloud-icon"
  2310. v-tippy
  2311. content="Fill from SoundCloud"
  2312. ></div>
  2313. </button>
  2314. <button
  2315. v-if="
  2316. currentSongMediaType ===
  2317. 'youtube' && youtubePlayerReady
  2318. "
  2319. class="button youtube-get-button"
  2320. @click="getYouTubeData('author')"
  2321. >
  2322. <div
  2323. class="youtube-icon"
  2324. v-tippy
  2325. content="Fill from YouTube"
  2326. ></div>
  2327. </button>
  2328. <button
  2329. v-if="inputs.discogs.value"
  2330. class="button album-get-button"
  2331. @click="getAlbumData('artists')"
  2332. >
  2333. <i
  2334. class="material-icons"
  2335. v-tippy
  2336. content="Fill from Discogs"
  2337. >album</i
  2338. >
  2339. </button>
  2340. <button
  2341. class="button is-info add-button"
  2342. @click="addTag('artists')"
  2343. >
  2344. <i class="material-icons">add</i>
  2345. </button>
  2346. </p>
  2347. <div class="list-container">
  2348. <div
  2349. class="list-item"
  2350. v-for="artist in inputs['artists']
  2351. .value"
  2352. :key="artist"
  2353. >
  2354. <div
  2355. class="list-item-circle"
  2356. @click="
  2357. removeTag('artists', artist)
  2358. "
  2359. >
  2360. <i class="material-icons">close</i>
  2361. </div>
  2362. <p>{{ artist }}</p>
  2363. </div>
  2364. </div>
  2365. </div>
  2366. <div class="genres-container">
  2367. <label class="label">
  2368. <span>Genres</span>
  2369. <i
  2370. class="material-icons"
  2371. @click="toggleGenreHelper"
  2372. @dblclick="resetGenreHelper"
  2373. v-tippy
  2374. content="View list of genres"
  2375. >info</i
  2376. >
  2377. </label>
  2378. <p class="control has-addons">
  2379. <auto-suggest
  2380. v-model="inputs['addGenre'].value"
  2381. ref="new-genre"
  2382. placeholder="Add genre..."
  2383. :all-items="autosuggest.allItems.genres"
  2384. @submitted="addTag('genres')"
  2385. @keyup.shift.enter="
  2386. getAlbumData('genres')
  2387. "
  2388. />
  2389. <button
  2390. v-if="inputs.discogs.value"
  2391. class="button album-get-button"
  2392. @click="getAlbumData('genres')"
  2393. >
  2394. <i
  2395. class="material-icons"
  2396. v-tippy
  2397. content="Fill from Discogs"
  2398. >album</i
  2399. >
  2400. </button>
  2401. <button
  2402. class="button is-info add-button"
  2403. @click="addTag('genres')"
  2404. >
  2405. <i class="material-icons">add</i>
  2406. </button>
  2407. </p>
  2408. <div class="list-container">
  2409. <div
  2410. class="list-item"
  2411. v-for="genre in inputs['genres'].value"
  2412. :key="genre"
  2413. >
  2414. <div
  2415. class="list-item-circle"
  2416. @click="removeTag('genres', genre)"
  2417. >
  2418. <i class="material-icons">close</i>
  2419. </div>
  2420. <p>{{ genre }}</p>
  2421. </div>
  2422. </div>
  2423. </div>
  2424. <div class="tags-container">
  2425. <label class="label">Tags</label>
  2426. <p class="control has-addons">
  2427. <auto-suggest
  2428. v-model="inputs['addTag'].value"
  2429. ref="new-tag"
  2430. placeholder="Add tag..."
  2431. :all-items="autosuggest.allItems.tags"
  2432. @submitted="addTag('tags')"
  2433. />
  2434. <button
  2435. class="button is-info add-button"
  2436. @click="addTag('tags')"
  2437. >
  2438. <i class="material-icons">add</i>
  2439. </button>
  2440. </p>
  2441. <div class="list-container">
  2442. <div
  2443. class="list-item"
  2444. v-for="tag in inputs['tags'].value"
  2445. :key="tag"
  2446. >
  2447. <div
  2448. class="list-item-circle"
  2449. @click="removeTag('tags', tag)"
  2450. >
  2451. <i class="material-icons">close</i>
  2452. </div>
  2453. <p>{{ tag }}</p>
  2454. </div>
  2455. </div>
  2456. </div>
  2457. </div>
  2458. </div>
  2459. </div>
  2460. <div
  2461. class="right-section"
  2462. v-if="songDataLoaded && !songDeleted"
  2463. >
  2464. <div id="tabs-container">
  2465. <div id="tab-selection">
  2466. <button
  2467. v-if="discogsEnabled || inputs.discogs.value"
  2468. class="button is-default"
  2469. :class="{ selected: tab === 'discogs' }"
  2470. :ref="el => (tabs['discogs-tab'] = el)"
  2471. @click="showTab('discogs')"
  2472. >
  2473. Discogs
  2474. </button>
  2475. <button
  2476. v-if="!newSong"
  2477. class="button is-default"
  2478. :class="{ selected: tab === 'reports' }"
  2479. :ref="el => (tabs['reports-tab'] = el)"
  2480. @click="showTab('reports')"
  2481. >
  2482. Reports ({{ reports.length }})
  2483. </button>
  2484. <button
  2485. class="button is-default"
  2486. :class="{ selected: tab === 'youtube' }"
  2487. :ref="el => (tabs['youtube-tab'] = el)"
  2488. @click="showTab('youtube')"
  2489. >
  2490. YouTube
  2491. </button>
  2492. <button
  2493. class="button is-default"
  2494. :class="{ selected: tab === 'musare-songs' }"
  2495. :ref="el => (tabs['musare-songs-tab'] = el)"
  2496. @click="showTab('musare-songs')"
  2497. >
  2498. Songs
  2499. </button>
  2500. </div>
  2501. <discogs
  2502. v-if="discogsEnabled || inputs.discogs.value"
  2503. class="tab"
  2504. v-show="tab === 'discogs'"
  2505. :bulk="bulk"
  2506. :modal-uuid="modalUuid"
  2507. :modal-module-path="modalModulePath"
  2508. />
  2509. <reports-tab
  2510. v-if="!newSong"
  2511. class="tab"
  2512. v-show="tab === 'reports'"
  2513. :modal-uuid="modalUuid"
  2514. :modal-module-path="modalModulePath"
  2515. />
  2516. <youtube
  2517. class="tab"
  2518. v-show="tab === 'youtube'"
  2519. :modal-uuid="modalUuid"
  2520. :modal-module-path="modalModulePath"
  2521. />
  2522. <musare-songs
  2523. class="tab"
  2524. v-show="tab === 'musare-songs'"
  2525. :modal-uuid="modalUuid"
  2526. :modal-module-path="modalModulePath"
  2527. />
  2528. </div>
  2529. </div>
  2530. </template>
  2531. <template #footer>
  2532. <div v-if="bulk">
  2533. <button class="button is-primary" @click="editNextSong()">
  2534. Next
  2535. </button>
  2536. <button
  2537. class="button is-primary"
  2538. @click="toggleFlag()"
  2539. v-if="mediaSource && !songDeleted"
  2540. >
  2541. {{ currentSongFlagged ? "Unflag" : "Flag" }}
  2542. </button>
  2543. </div>
  2544. <div v-if="!newSong && !songDeleted">
  2545. <save-button
  2546. :ref="el => (saveButtonRefs['saveButton'] = el)"
  2547. @clicked="saveSong('saveButton')"
  2548. />
  2549. <save-button
  2550. :ref="el => (saveButtonRefs['saveAndCloseButton'] = el)"
  2551. :default-message="
  2552. bulk ? `Save and next` : `Save and close`
  2553. "
  2554. @clicked="saveSong('saveAndCloseButton', true)"
  2555. />
  2556. <div class="right">
  2557. <button
  2558. v-if="hasPermission('songs.remove')"
  2559. class="button is-danger icon-with-button material-icons"
  2560. @click.prevent="
  2561. openModal({
  2562. modal: 'confirm',
  2563. props: {
  2564. message:
  2565. 'Removing this song will remove it from all playlists and cause a ratings recalculation.',
  2566. onCompleted: () => remove(song._id)
  2567. }
  2568. })
  2569. "
  2570. content="Delete Song"
  2571. v-tippy
  2572. >
  2573. delete_forever
  2574. </button>
  2575. </div>
  2576. </div>
  2577. <div v-else-if="newSong">
  2578. <save-button
  2579. :ref="el => (saveButtonRefs['createButton'] = el)"
  2580. default-message="Create Song"
  2581. @clicked="saveSong('createButton')"
  2582. />
  2583. <save-button
  2584. :ref="
  2585. el => (saveButtonRefs['createAndCloseButton'] = el)
  2586. "
  2587. :default-message="
  2588. bulk ? `Create and next` : `Create and close`
  2589. "
  2590. @clicked="saveSong('createAndCloseButton', true)"
  2591. />
  2592. </div>
  2593. </template>
  2594. </modal>
  2595. <floating-box
  2596. id="genreHelper"
  2597. ref="genreHelper"
  2598. :column="false"
  2599. title="Song Genres List"
  2600. >
  2601. <template #body>
  2602. <span
  2603. v-for="item in autosuggest.allItems.genres"
  2604. :key="`genre-helper-${item}`"
  2605. >
  2606. {{ item }}
  2607. </span>
  2608. </template>
  2609. </floating-box>
  2610. </div>
  2611. </template>
  2612. <style lang="less" scoped>
  2613. .night-mode {
  2614. .edit-section,
  2615. .player-section,
  2616. #tabs-container {
  2617. background-color: var(--dark-grey-3) !important;
  2618. border: 0 !important;
  2619. .tab {
  2620. border: 0 !important;
  2621. }
  2622. }
  2623. #tabs-container #tab-selection .button {
  2624. background: var(--dark-grey) !important;
  2625. color: var(--white) !important;
  2626. }
  2627. .left-section {
  2628. .edit-section {
  2629. .album-get-button,
  2630. .duration-fill-button,
  2631. .youtube-get-button,
  2632. .soundcloud-get-button,
  2633. .add-button {
  2634. &:focus,
  2635. &:hover {
  2636. border: none !important;
  2637. }
  2638. }
  2639. }
  2640. }
  2641. .duration-canvas {
  2642. background-color: var(--dark-grey-2) !important;
  2643. }
  2644. .sidebar {
  2645. .sidebar-head,
  2646. .sidebar-foot {
  2647. background-color: var(--dark-grey-3);
  2648. border: none;
  2649. }
  2650. .sidebar-body {
  2651. background-color: var(--dark-grey-4) !important;
  2652. }
  2653. .sidebar-head .toggle-sidebar-icon.material-icons,
  2654. .sidebar-title {
  2655. color: var(--white);
  2656. }
  2657. p,
  2658. label,
  2659. td,
  2660. th {
  2661. color: var(--light-grey-2) !important;
  2662. }
  2663. h1,
  2664. h2,
  2665. h3,
  2666. h4,
  2667. h5,
  2668. h6 {
  2669. color: var(--white) !important;
  2670. }
  2671. }
  2672. }
  2673. .modal-card-body {
  2674. display: flex;
  2675. }
  2676. .notice-container {
  2677. display: flex;
  2678. flex: 1;
  2679. justify-content: center;
  2680. h4 {
  2681. margin: auto;
  2682. }
  2683. }
  2684. .left-section {
  2685. height: 100%;
  2686. display: flex;
  2687. flex-direction: column;
  2688. margin-right: 16px;
  2689. .top-section {
  2690. display: flex;
  2691. .player-section {
  2692. width: 530px;
  2693. display: flex;
  2694. flex-direction: column;
  2695. border: 1px solid var(--light-grey-3);
  2696. border-radius: @border-radius;
  2697. overflow: hidden;
  2698. .youtube-player-wrapper {
  2699. display: flex;
  2700. > * {
  2701. flex: 1;
  2702. }
  2703. }
  2704. .duration-canvas {
  2705. background-color: var(--light-grey-2);
  2706. }
  2707. .player-error,
  2708. .no-media-source-specified-message {
  2709. display: flex;
  2710. height: 318px;
  2711. width: 530px;
  2712. align-items: center;
  2713. * {
  2714. margin: 0;
  2715. flex: 1;
  2716. font-size: 30px;
  2717. text-align: center;
  2718. }
  2719. }
  2720. .player-footer {
  2721. display: flex;
  2722. justify-content: space-between;
  2723. height: 54px;
  2724. padding-left: 10px;
  2725. padding-right: 10px;
  2726. > * {
  2727. width: 33.3%;
  2728. display: flex;
  2729. align-items: center;
  2730. }
  2731. .player-footer-left {
  2732. flex: 1;
  2733. & > .button:not(:first-child) {
  2734. margin-left: 5px;
  2735. }
  2736. :deep(& > .playerRateDropdown) {
  2737. margin-left: 5px;
  2738. margin-bottom: unset !important;
  2739. .control.has-addons {
  2740. margin-bottom: unset !important;
  2741. & > .button {
  2742. font-size: 24px;
  2743. }
  2744. }
  2745. }
  2746. :deep(.tippy-box[data-theme~="dropdown"]) {
  2747. max-width: 100px !important;
  2748. .nav-dropdown-items .nav-item {
  2749. justify-content: center !important;
  2750. border-radius: @border-radius !important;
  2751. &.active {
  2752. background-color: var(--primary-color);
  2753. color: var(--white);
  2754. }
  2755. }
  2756. }
  2757. }
  2758. .player-footer-center {
  2759. justify-content: center;
  2760. align-items: center;
  2761. flex: 2;
  2762. font-size: 18px;
  2763. font-weight: 400;
  2764. width: 200px;
  2765. margin: 0 5px;
  2766. img {
  2767. height: 21px;
  2768. margin-right: 12px;
  2769. filter: invert(26%) sepia(54%) saturate(6317%)
  2770. hue-rotate(2deg) brightness(92%) contrast(115%);
  2771. }
  2772. }
  2773. .player-footer-right {
  2774. justify-content: right;
  2775. flex: 1;
  2776. #volume-control {
  2777. margin: 3px;
  2778. margin-top: 0;
  2779. display: flex;
  2780. align-items: center;
  2781. cursor: pointer;
  2782. .volume-slider {
  2783. width: 100%;
  2784. padding: 0 15px;
  2785. background: transparent;
  2786. min-width: 100px;
  2787. }
  2788. input[type="range"] {
  2789. -webkit-appearance: none;
  2790. margin: 7.3px 0;
  2791. }
  2792. input[type="range"]:focus {
  2793. outline: none;
  2794. }
  2795. input[type="range"]::-webkit-slider-runnable-track {
  2796. width: 100%;
  2797. height: 5.2px;
  2798. cursor: pointer;
  2799. box-shadow: 0;
  2800. background: var(--light-grey-3);
  2801. border-radius: @border-radius;
  2802. border: 0;
  2803. }
  2804. input[type="range"]::-webkit-slider-thumb {
  2805. box-shadow: 0;
  2806. border: 0;
  2807. height: 19px;
  2808. width: 19px;
  2809. border-radius: 100%;
  2810. background: var(--primary-color);
  2811. cursor: pointer;
  2812. -webkit-appearance: none;
  2813. margin-top: -6.5px;
  2814. }
  2815. input[type="range"]::-moz-range-track {
  2816. width: 100%;
  2817. height: 5.2px;
  2818. cursor: pointer;
  2819. box-shadow: 0;
  2820. background: var(--light-grey-3);
  2821. border-radius: @border-radius;
  2822. border: 0;
  2823. }
  2824. input[type="range"]::-moz-range-thumb {
  2825. box-shadow: 0;
  2826. border: 0;
  2827. height: 19px;
  2828. width: 19px;
  2829. border-radius: 100%;
  2830. background: var(--primary-color);
  2831. cursor: pointer;
  2832. -webkit-appearance: none;
  2833. margin-top: -6.5px;
  2834. }
  2835. input[type="range"]::-ms-track {
  2836. width: 100%;
  2837. height: 5.2px;
  2838. cursor: pointer;
  2839. box-shadow: 0;
  2840. background: var(--light-grey-3);
  2841. border-radius: @border-radius;
  2842. }
  2843. input[type="range"]::-ms-fill-lower {
  2844. background: var(--light-grey-3);
  2845. border: 0;
  2846. border-radius: 0;
  2847. box-shadow: 0;
  2848. }
  2849. input[type="range"]::-ms-fill-upper {
  2850. background: var(--light-grey-3);
  2851. border: 0;
  2852. border-radius: 0;
  2853. box-shadow: 0;
  2854. }
  2855. input[type="range"]::-ms-thumb {
  2856. box-shadow: 0;
  2857. border: 0;
  2858. height: 15px;
  2859. width: 15px;
  2860. border-radius: 100%;
  2861. background: var(--primary-color);
  2862. cursor: pointer;
  2863. -webkit-appearance: none;
  2864. margin-top: 1.5px;
  2865. }
  2866. }
  2867. }
  2868. }
  2869. }
  2870. :deep(.thumbnail-preview) {
  2871. width: 189px;
  2872. height: 189px;
  2873. margin-left: 16px;
  2874. }
  2875. .thumbnail-dummy {
  2876. opacity: 0;
  2877. height: 10px;
  2878. width: 10px;
  2879. }
  2880. }
  2881. .edit-section {
  2882. display: flex;
  2883. flex-wrap: wrap;
  2884. flex-grow: 1;
  2885. border: 1px solid var(--light-grey-3);
  2886. margin-top: 16px;
  2887. border-radius: @border-radius;
  2888. .album-get-button {
  2889. background-color: var(--purple);
  2890. color: var(--white);
  2891. width: 32px;
  2892. text-align: center;
  2893. border-width: 0;
  2894. }
  2895. .duration-fill-button,
  2896. .youtube-get-button {
  2897. background-color: var(--dark-red);
  2898. color: var(--white);
  2899. width: 32px;
  2900. text-align: center;
  2901. border-width: 0;
  2902. }
  2903. .soundcloud-get-button {
  2904. background-color: var(--orange);
  2905. color: var(--white);
  2906. width: 32px;
  2907. text-align: center;
  2908. border-width: 0;
  2909. }
  2910. .add-button {
  2911. background-color: var(--primary-color) !important;
  2912. width: 32px;
  2913. i {
  2914. font-size: 32px;
  2915. }
  2916. }
  2917. .album-get-button,
  2918. .duration-fill-button,
  2919. .youtube-get-button,
  2920. .add-button {
  2921. &:focus,
  2922. &:hover {
  2923. filter: contrast(0.75);
  2924. border: 1px solid var(--black) !important;
  2925. }
  2926. }
  2927. .youtube-get-button,
  2928. .soundcloud-get-button {
  2929. padding-left: 4px;
  2930. padding-right: 4px;
  2931. .youtube-icon,
  2932. .soundcloud-icon,
  2933. .spotify-icon {
  2934. background: var(--white);
  2935. }
  2936. }
  2937. > div {
  2938. margin: 16px !important;
  2939. width: 100%;
  2940. }
  2941. input {
  2942. width: 100%;
  2943. }
  2944. .title-container {
  2945. width: calc((100% - 32px) / 2);
  2946. }
  2947. .duration-container {
  2948. margin-right: 16px;
  2949. margin-left: 16px;
  2950. width: calc((100% - 32px) / 4);
  2951. }
  2952. .skip-duration-container {
  2953. width: calc((100% - 32px) / 4);
  2954. }
  2955. .album-art-container {
  2956. margin-right: 16px;
  2957. width: 100%;
  2958. }
  2959. .youtube-id-container {
  2960. margin-right: 16px;
  2961. width: calc((100% - 16px) / 8 * 3);
  2962. }
  2963. .verified-container {
  2964. width: calc((100% - 16px) / 8);
  2965. .checkbox-control {
  2966. margin-top: 10px;
  2967. }
  2968. }
  2969. .artists-container {
  2970. width: calc((100% - 32px) / 3);
  2971. position: relative;
  2972. }
  2973. .genres-container {
  2974. width: calc((100% - 32px) / 3);
  2975. margin-left: 16px;
  2976. margin-right: 16px;
  2977. position: relative;
  2978. label {
  2979. display: flex;
  2980. i {
  2981. font-size: 15px;
  2982. align-self: center;
  2983. margin-left: 5px;
  2984. color: var(--primary-color);
  2985. cursor: pointer;
  2986. -webkit-user-select: none;
  2987. -moz-user-select: none;
  2988. -ms-user-select: none;
  2989. user-select: none;
  2990. }
  2991. }
  2992. }
  2993. .tags-container {
  2994. width: calc((100% - 32px) / 3);
  2995. position: relative;
  2996. }
  2997. .list-item-circle {
  2998. background-color: var(--primary-color);
  2999. width: 16px;
  3000. height: 16px;
  3001. border-radius: 8px;
  3002. cursor: pointer;
  3003. margin-right: 8px;
  3004. float: left;
  3005. -webkit-touch-callout: none;
  3006. -webkit-user-select: none;
  3007. -khtml-user-select: none;
  3008. -moz-user-select: none;
  3009. -ms-user-select: none;
  3010. user-select: none;
  3011. i {
  3012. color: var(--primary-color);
  3013. font-size: 14px;
  3014. margin-left: 1px;
  3015. position: relative;
  3016. top: -1px;
  3017. }
  3018. }
  3019. .list-item-circle:hover,
  3020. .list-item-circle:focus {
  3021. i {
  3022. color: var(--white);
  3023. }
  3024. }
  3025. .list-item > p {
  3026. line-height: 16px;
  3027. word-wrap: break-word;
  3028. width: calc(100% - 24px);
  3029. left: 24px;
  3030. float: left;
  3031. margin-bottom: 8px;
  3032. }
  3033. .list-item:last-child > p {
  3034. margin-bottom: 0;
  3035. }
  3036. .thumbnail-warning {
  3037. color: var(--red);
  3038. font-size: 18px;
  3039. margin: auto 0 auto 5px;
  3040. }
  3041. }
  3042. }
  3043. .right-section {
  3044. flex-basis: unset !important;
  3045. flex-grow: 0 !important;
  3046. display: flex;
  3047. height: 100%;
  3048. #tabs-container {
  3049. width: 376px;
  3050. #tab-selection {
  3051. display: flex;
  3052. overflow-x: auto;
  3053. .button {
  3054. border-radius: @border-radius @border-radius 0 0;
  3055. border: 0;
  3056. text-transform: uppercase;
  3057. font-size: 14px;
  3058. color: var(--dark-grey-3);
  3059. background-color: var(--light-grey-2);
  3060. flex-grow: 1;
  3061. height: 32px;
  3062. &:not(:first-of-type) {
  3063. margin-left: 5px;
  3064. }
  3065. }
  3066. .selected {
  3067. background-color: var(--primary-color) !important;
  3068. color: var(--white) !important;
  3069. font-weight: 600;
  3070. }
  3071. }
  3072. .tab {
  3073. border: 1px solid var(--light-grey-3);
  3074. border-radius: 0 0 @border-radius @border-radius;
  3075. padding: 15px;
  3076. height: calc(100% - 32px);
  3077. overflow: auto;
  3078. }
  3079. }
  3080. }
  3081. @media screen and (max-width: 1100px) {
  3082. .left-section,
  3083. .right-section {
  3084. height: unset;
  3085. max-height: unset;
  3086. }
  3087. .left-section {
  3088. margin-right: 0;
  3089. }
  3090. .right-section {
  3091. flex-basis: 100% !important;
  3092. #tabs-container {
  3093. width: 100%;
  3094. }
  3095. }
  3096. }
  3097. .modal-card-foot .is-primary {
  3098. width: 200px;
  3099. }
  3100. :deep(.autosuggest-container) {
  3101. top: unset;
  3102. }
  3103. .toggle-sidebar-icon {
  3104. display: none;
  3105. }
  3106. .sidebar {
  3107. width: 100%;
  3108. max-width: 350px;
  3109. z-index: 2000;
  3110. display: flex;
  3111. flex-direction: column;
  3112. position: relative;
  3113. height: 100%;
  3114. max-height: calc(100vh - 40px);
  3115. overflow: auto;
  3116. margin-right: 8px;
  3117. border-radius: @border-radius;
  3118. .sidebar-head,
  3119. .sidebar-foot {
  3120. display: flex;
  3121. flex-shrink: 0;
  3122. position: relative;
  3123. justify-content: flex-start;
  3124. align-items: center;
  3125. padding: 20px;
  3126. background-color: var(--light-grey);
  3127. }
  3128. .sidebar-head {
  3129. border-bottom: 1px solid var(--light-grey-2);
  3130. border-radius: @border-radius @border-radius 0 0;
  3131. .sidebar-title {
  3132. display: flex;
  3133. flex: 1;
  3134. margin: 0;
  3135. font-size: 26px;
  3136. font-weight: 600;
  3137. }
  3138. }
  3139. .sidebar-body {
  3140. background-color: var(--white);
  3141. display: flex;
  3142. flex-direction: column;
  3143. row-gap: 8px;
  3144. flex: 1;
  3145. overflow: auto;
  3146. padding: 10px;
  3147. .edit-songs-items {
  3148. display: flex;
  3149. flex-direction: column;
  3150. row-gap: 8px;
  3151. .item {
  3152. display: flex;
  3153. flex-direction: row;
  3154. align-items: center;
  3155. column-gap: 8px;
  3156. :deep(.song-item) {
  3157. .item-icon {
  3158. margin-right: 10px;
  3159. cursor: pointer;
  3160. }
  3161. .removed-icon,
  3162. .error-icon {
  3163. color: var(--red);
  3164. }
  3165. .saving-icon,
  3166. .todo-icon,
  3167. .editing-icon {
  3168. color: var(--primary-color);
  3169. }
  3170. .done-icon {
  3171. color: var(--green);
  3172. }
  3173. .flag-icon {
  3174. color: var(--orange);
  3175. &.flagged {
  3176. color: var(--grey);
  3177. }
  3178. }
  3179. &.removed {
  3180. filter: grayscale(100%);
  3181. cursor: not-allowed;
  3182. user-select: none;
  3183. }
  3184. }
  3185. }
  3186. }
  3187. .no-items {
  3188. text-align: center;
  3189. font-size: 18px;
  3190. }
  3191. }
  3192. .sidebar-foot {
  3193. border-top: 1px solid var(--light-grey-2);
  3194. border-radius: 0 0 @border-radius @border-radius;
  3195. .button {
  3196. flex: 1;
  3197. }
  3198. }
  3199. .sidebar-overlay {
  3200. display: none;
  3201. }
  3202. }
  3203. @media only screen and (max-width: 1580px) {
  3204. .toggle-sidebar-icon {
  3205. display: flex;
  3206. margin-right: 5px;
  3207. transform: rotate(90deg);
  3208. cursor: pointer;
  3209. }
  3210. .sidebar {
  3211. display: none;
  3212. &.active {
  3213. display: flex;
  3214. position: absolute;
  3215. z-index: 2010;
  3216. top: 20px;
  3217. left: 20px;
  3218. .sidebar-head .toggle-sidebar-icon {
  3219. display: flex;
  3220. margin-left: 5px;
  3221. transform: rotate(-90deg);
  3222. }
  3223. }
  3224. }
  3225. .sidebar-overlay {
  3226. display: flex;
  3227. position: absolute;
  3228. z-index: 2009;
  3229. top: 0;
  3230. left: 0;
  3231. right: 0;
  3232. bottom: 0;
  3233. background-color: rgba(10, 10, 10, 0.85);
  3234. }
  3235. }
  3236. </style>