index.vue 71 KB

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