index.vue 71 KB

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