added global alias for js folders, removed modules folder in js

This commit is contained in:
Roberto Tonino 2020-06-24 19:10:10 +02:00
parent e32b7b7959
commit 2cb0986928
23 changed files with 117 additions and 100 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ __pycache__
.DS_Store .DS_Store
node_modules node_modules
jsconfig.json
# pyinstaller build dirs # pyinstaller build dirs
/dist /dist

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,14 @@ export default {
{ {
find: 'vue', find: 'vue',
replacement: 'vue/dist/vue.esm' replacement: 'vue/dist/vue.esm'
},
{
find: '@',
replacement: __dirname + '/src'
},
{
find: '@components',
replacement: __dirname + '/src/js/components'
} }
] ]
}), }),

View File

@ -1,25 +1,27 @@
// Global Vue components // Global Vue components
import './modules/components/LoadingPlaceholder.js' import '@components/LoadingPlaceholder.js'
// Vue views components // Vue views components
import './modules/components/artist-tab.js' import '@components/artist-tab.js'
import './modules/components/charts-tab.js' import '@components/charts-tab.js'
import './modules/components/errors-tab.js' import '@components/errors-tab.js'
import './modules/components/favorites-tab.js' import '@components/favorites-tab.js'
import './modules/components/home-tab.js' import '@components/home-tab.js'
import './modules/components/link-analyzer-tab.js' import '@components/link-analyzer-tab.js'
import './modules/components/main-search.js' import '@components/main-search.js'
import './modules/components/settings-tab.js' import '@components/settings-tab.js'
import './modules/components/tracklist-tab.js' import '@components/tracklist-tab.js'
import '@components/TestComponent.vue'
import $ from 'jquery' import $ from 'jquery'
import { socket } from './modules/socket.js' import { socket } from '@/js/socket.js'
import { toast } from './modules/toasts.js' import { toast } from '@/js/toasts.js'
import Downloads from './modules/downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from './modules/quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import Tabs from './modules/tabs.js' import Tabs from '@/js/tabs.js'
import Search from './modules/search.js' import Search from '@/js/search.js'
import TrackPreview from './modules/track-preview.js' import TrackPreview from '@/js/track-preview.js'
/* ===== App initialization ===== */ /* ===== App initialization ===== */
@ -61,15 +63,15 @@ function setCurrentUserTheme() {
/* ===== Socketio listeners ===== */ /* ===== Socketio listeners ===== */
// Debug messages for socketio // Debug messages for socketio
socket.on('message', function (msg) { socket.on('message', function(msg) {
console.log(msg) console.log(msg)
}) })
socket.on('logging_in', function () { socket.on('logging_in', function() {
toast('Logging in', 'loading', false, 'login-toast') toast('Logging in', 'loading', false, 'login-toast')
}) })
socket.on('init_autologin', function () { socket.on('init_autologin', function() {
let arl = localStorage.getItem('arl') let arl = localStorage.getItem('arl')
let accountNum = localStorage.getItem('accountNum') let accountNum = localStorage.getItem('accountNum')
if (arl) { if (arl) {
@ -82,7 +84,7 @@ socket.on('init_autologin', function () {
} }
}) })
socket.on('logged_in', function (data) { socket.on('logged_in', function(data) {
switch (data.status) { switch (data.status) {
case 1: case 1:
case 3: case 3:
@ -130,7 +132,7 @@ socket.on('logged_in', function (data) {
} }
}) })
socket.on('logged_out', function () { socket.on('logged_out', function() {
toast('Logged out', 'done', true, 'login-toast') toast('Logged out', 'done', true, 'login-toast')
localStorage.removeItem('arl') localStorage.removeItem('arl')
$('#login_input_arl').val('') $('#login_input_arl').val('')
@ -141,34 +143,34 @@ socket.on('logged_out', function () {
document.getElementById('home_not_logged_in').classList.remove('hide') document.getElementById('home_not_logged_in').classList.remove('hide')
}) })
socket.on('cancellingCurrentItem', function (uuid) { socket.on('cancellingCurrentItem', function(uuid) {
toast('Cancelling current item.', 'loading', false, 'cancelling_' + uuid) toast('Cancelling current item.', 'loading', false, 'cancelling_' + uuid)
}) })
socket.on('currentItemCancelled', function (uuid) { socket.on('currentItemCancelled', function(uuid) {
toast('Current item cancelled.', 'done', true, 'cancelling_' + uuid) toast('Current item cancelled.', 'done', true, 'cancelling_' + uuid)
}) })
socket.on('startAddingArtist', function (data) { socket.on('startAddingArtist', function(data) {
toast(`Adding ${data.name} albums to queue`, 'loading', false, 'artist_' + data.id) toast(`Adding ${data.name} albums to queue`, 'loading', false, 'artist_' + data.id)
}) })
socket.on('finishAddingArtist', function (data) { socket.on('finishAddingArtist', function(data) {
toast(`Added ${data.name} albums to queue`, 'done', true, 'artist_' + data.id) toast(`Added ${data.name} albums to queue`, 'done', true, 'artist_' + data.id)
}) })
socket.on('startConvertingSpotifyPlaylist', function (id) { socket.on('startConvertingSpotifyPlaylist', function(id) {
toast('Converting spotify tracks to deezer tracks', 'loading', false, 'spotifyplaylist_' + id) toast('Converting spotify tracks to deezer tracks', 'loading', false, 'spotifyplaylist_' + id)
}) })
socket.on('finishConvertingSpotifyPlaylist', function (id) { socket.on('finishConvertingSpotifyPlaylist', function(id) {
toast('Spotify playlist converted', 'done', true, 'spotifyplaylist_' + id) toast('Spotify playlist converted', 'done', true, 'spotifyplaylist_' + id)
}) })
socket.on('errorMessage', function (error) { socket.on('errorMessage', function(error) {
toast(error, 'error') toast(error, 'error')
}) })
socket.on('alreadyInQueue', function (data) { socket.on('alreadyInQueue', function(data) {
toast(`${data.title} is already in queue!`, 'playlist_add_check') toast(`${data.title} is already in queue!`, 'playlist_add_check')
}) })

View File

@ -1,9 +1,9 @@
import { isEmpty, orderBy } from 'lodash-es' import { isEmpty, orderBy } from 'lodash-es'
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
const ArtistTab = new Vue({ const ArtistTab = new Vue({
data() { data() {

View File

@ -1,10 +1,10 @@
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import TrackPreview from '../track-preview.js' import TrackPreview from '@/js/track-preview.js'
import Utils from '../utils.js' import Utils from '@/js/utils.js'
const ChartsTab = new Vue({ const ChartsTab = new Vue({
data() { data() {

View File

@ -1,11 +1,11 @@
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import TrackPreview from '../track-preview.js' import TrackPreview from '@/js/track-preview.js'
import Utils from '../utils.js' import Utils from '@/js/utils.js'
import { toast } from '../toasts' import { toast } from '@/js/toasts'
const FavoritesTab = new Vue({ const FavoritesTab = new Vue({
data() { data() {

View File

@ -1,10 +1,8 @@
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
// import TrackPreview from '../track-preview.js'
// import Utils from '../utils.js'
const HomeTab = new Vue({ const HomeTab = new Vue({
data() { data() {

View File

@ -1,7 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Utils from '../utils.js' import Utils from '@/js/utils.js'
const LinkAnalyzerTab = new Vue({ const LinkAnalyzerTab = new Vue({
data() { data() {
@ -65,7 +65,7 @@ const LinkAnalyzerTab = new Vue({
this.data = data this.data = data
this.id = id this.id = id
}, },
notSupported(){ notSupported() {
this.link = 'error' this.link = 'error'
} }
}, },

View File

@ -1,10 +1,10 @@
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import TrackPreview from '../track-preview.js' import TrackPreview from '@/js/track-preview.js'
import Utils from '../utils.js' import Utils from '@/js/utils.js'
const MainSearch = new Vue({ const MainSearch = new Vue({
data: { data: {

View File

@ -1,7 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import { toast } from '../toasts.js' import { toast } from '@/js/toasts.js'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import TestComponent from './TestComponent.vue' import TestComponent from '@components/TestComponent.vue'
const SettingsTab = new Vue({ const SettingsTab = new Vue({
components: { components: {
@ -81,7 +81,9 @@ const SettingsTab = new Vue({
}, },
accountChanged(user, accountNum) { accountChanged(user, accountNum) {
this.$refs.username.innerText = user.name this.$refs.username.innerText = user.name
this.$refs.userpicture.src = `https://e-cdns-images.dzcdn.net/images/user/${user.picture}/125x125-000000-80-0-0.jpg` this.$refs.userpicture.src = `https://e-cdns-images.dzcdn.net/images/user/${
user.picture
}/125x125-000000-80-0-0.jpg`
this.accountNum = accountNum this.accountNum = accountNum
localStorage.setItem('accountNum', this.accountNum) localStorage.setItem('accountNum', this.accountNum)
}, },

View File

@ -1,11 +1,11 @@
import { isEmpty } from 'lodash-es' import { isEmpty } from 'lodash-es'
import Vue from 'vue' import Vue from 'vue'
import { socket } from '../socket.js' import { socket } from '@/js/socket.js'
import { showView } from '../tabs.js' import { showView } from '@/js/tabs.js'
import Downloads from '../downloads.js' import Downloads from '@/js/downloads.js'
import QualityModal from '../quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import TrackPreview from '../track-preview.js' import TrackPreview from '@/js/track-preview.js'
import Utils from '../utils.js' import Utils from '@/js/utils.js'
const TracklistTab = new Vue({ const TracklistTab = new Vue({
data: () => ({ data: () => ({

View File

@ -1,7 +1,7 @@
import $ from 'jquery' import $ from 'jquery'
import { socket } from './socket.js' import { socket } from '@/js/socket.js'
import { toast } from './toasts.js' import { toast } from '@/js/toasts.js'
import { showErrors } from './tabs.js' import { showErrors } from '@/js/tabs.js'
/* ===== Locals ===== */ /* ===== Locals ===== */
const tabMinWidth = 250 const tabMinWidth = 250
@ -141,7 +141,9 @@ function addToQueue(queueItem, current = false) {
$('#bar_' + queueItem.uuid).css('width', queueItem.progress + '%') $('#bar_' + queueItem.uuid).css('width', queueItem.progress + '%')
if (queueItem.failed >= 1 && $('#download_' + queueItem.uuid + ' .queue_failed').length == 0) { if (queueItem.failed >= 1 && $('#download_' + queueItem.uuid + ' .queue_failed').length == 0) {
$('#download_' + queueItem.uuid + ' .download_info_status').append( $('#download_' + queueItem.uuid + ' .download_info_status').append(
`<span class="secondary-text inline-flex"><span class="download_slim_separator">(</span><span class="queue_failed_button inline-flex"><span class="queue_failed">${queueItem.failed}</span><i class="material-icons">error_outline</i></span><span class="download_slim_separator">)</span></span>` `<span class="secondary-text inline-flex"><span class="download_slim_separator">(</span><span class="queue_failed_button inline-flex"><span class="queue_failed">${
queueItem.failed
}</span><i class="material-icons">error_outline</i></span><span class="download_slim_separator">)</span></span>`
) )
} }
if (queueItem.downloaded + queueItem.failed == queueItem.size) { if (queueItem.downloaded + queueItem.failed == queueItem.size) {
@ -152,8 +154,8 @@ function addToQueue(queueItem, current = false) {
let failed_button = $('#download_' + queueItem.uuid).find('.queue_failed_button') let failed_button = $('#download_' + queueItem.uuid).find('.queue_failed_button')
result_icon.addClass('clickable') result_icon.addClass('clickable')
failed_button.addClass('clickable') failed_button.addClass('clickable')
result_icon.bind('click', {item:queueItem}, showErrors) result_icon.bind('click', { item: queueItem }, showErrors)
failed_button.bind('click', {item:queueItem}, showErrors) failed_button.bind('click', { item: queueItem }, showErrors)
if (queueItem.failed >= queueItem.size) { if (queueItem.failed >= queueItem.size) {
result_icon.text('error') result_icon.text('error')
} else { } else {
@ -254,8 +256,8 @@ function finishDownload(uuid) {
let failed_button = $('#download_' + uuid).find('.queue_failed_button') let failed_button = $('#download_' + uuid).find('.queue_failed_button')
result_icon.addClass('clickable') result_icon.addClass('clickable')
failed_button.addClass('clickable') failed_button.addClass('clickable')
result_icon.bind('click', {item:queueList[uuid]}, showErrors) result_icon.bind('click', { item: queueList[uuid] }, showErrors)
failed_button.bind('click', {item:queueList[uuid]}, showErrors) failed_button.bind('click', { item: queueList[uuid] }, showErrors)
if (queueList[uuid].failed >= queueList[uuid].size) { if (queueList[uuid].failed >= queueList[uuid].size) {
result_icon.text('error') result_icon.text('error')
} else { } else {
@ -287,7 +289,7 @@ function removeAllDownloads(currentItem) {
let tempQueueItem = queueList[currentItem] let tempQueueItem = queueList[currentItem]
queueList = {} queueList = {}
queueList[currentItem] = tempQueueItem queueList[currentItem] = tempQueueItem
$('.download_object').each(function (index) { $('.download_object').each(function(index) {
if ($(this).attr('id') != 'download_' + currentItem) $(this).remove() if ($(this).attr('id') != 'download_' + currentItem) $(this).remove()
}) })
} }
@ -323,7 +325,7 @@ function updateQueue(update) {
} else { } else {
$('#download_' + uuid + ' .queue_failed').text(queueList[uuid].failed) $('#download_' + uuid + ' .queue_failed').text(queueList[uuid].failed)
} }
queueList[uuid].errors.push({message: update.error, data: update.data}) queueList[uuid].errors.push({ message: update.error, data: update.data })
} }
if (progress) { if (progress) {
queueList[uuid].progress = progress queueList[uuid].progress = progress

View File

@ -1,4 +1,4 @@
import Downloads from './downloads.js' import Downloads from '@/js/downloads.js'
const QualityModal = { const QualityModal = {
// Defaults // Defaults

View File

@ -1,9 +1,9 @@
import MainSearch from './components/main-search.js' import MainSearch from '@components/main-search.js'
import Utils from './utils.js' import Utils from '@/js/utils.js'
import QualityModal from './quality-modal.js' import QualityModal from '@/js/quality-modal.js'
import Downloads from './downloads.js' import Downloads from '@/js/downloads.js'
import { socket } from './socket.js' import { socket } from '@/js/socket.js'
import Tabs from './tabs.js' import Tabs from '@/js/tabs.js'
function linkListeners() { function linkListeners() {
document.getElementById('content').addEventListener('scroll', Utils.debounce(handleContentScroll, 100)) document.getElementById('content').addEventListener('scroll', Utils.debounce(handleContentScroll, 100))

View File

@ -1,11 +1,11 @@
import ArtistTab from './components/artist-tab.js' import ArtistTab from '@components/artist-tab.js'
import TracklistTab from './components/tracklist-tab.js' import TracklistTab from '@components/tracklist-tab.js'
import LinkAnalyzerTab from './components/link-analyzer-tab.js' import LinkAnalyzerTab from '@components/link-analyzer-tab.js'
import ErrorsTab from './components/errors-tab.js' import ErrorsTab from '@components/errors-tab.js'
import { socket } from './socket.js' import SettingsTab from '@components/settings-tab.js'
import SettingsTab from './components/settings-tab.js' import MainSearch from '@components/main-search.js'
import MainSearch from './components/main-search.js' import { socket } from '@/js/socket.js'
import TrackPreview from './track-preview.js' import TrackPreview from '@/js/track-preview.js'
/* ===== Globals ====== */ /* ===== Globals ====== */
window.search_selected = '' window.search_selected = ''
@ -242,7 +242,10 @@ function showTab(type, id, back = false) {
if (windows_stack.length == 0) { if (windows_stack.length == 0) {
windows_stack.push({ tab: main_selected }) windows_stack.push({ tab: main_selected })
} else if (!back) { } else if (!back) {
if (currentStack.type === 'artist') currentStack.selected = ArtistTab.getCurrentTab() if (currentStack.type === 'artist') {
currentStack.selected = ArtistTab.getCurrentTab()
}
windows_stack.push(currentStack) windows_stack.push(currentStack)
} }
@ -254,6 +257,7 @@ function showTab(type, id, back = false) {
for (let i = 0; i < tabcontent.length; i++) { for (let i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = 'none' tabcontent[i].style.display = 'none'
} }
document.getElementById(tab).style.display = 'block' document.getElementById(tab).style.display = 'block'
TrackPreview.stopStackedTabsPreview() TrackPreview.stopStackedTabsPreview()
} }