index.vue 82 KB

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