fix: errors tab displaying

This commit is contained in:
Roberto Tonino 2020-09-19 15:11:06 +02:00
parent 5fc41db230
commit 6e195827aa
8 changed files with 73 additions and 37 deletions

File diff suppressed because one or more lines are too long

View File

@ -50,10 +50,12 @@
height: 100vh; height: 100vh;
} }
</style> </style>
<script> <script>
import $ from 'jquery' import $ from 'jquery'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import { toast } from '@/utils/toasts' import { toast } from '@/utils/toasts'
import { mapActions } from 'vuex'
const tabMinWidth = 250 const tabMinWidth = 250
const tabMaxWidth = 500 const tabMaxWidth = 500
@ -99,6 +101,7 @@ export default {
}) })
}, },
methods: { methods: {
...mapActions(['setErrors']),
setTabWidth(newWidth) { setTabWidth(newWidth) {
if (undefined === newWidth) { if (undefined === newWidth) {
this.$refs.container.style.width = '' this.$refs.container.style.width = ''
@ -411,8 +414,10 @@ export default {
.addClass('determinate') .addClass('determinate')
.css('width', '100%') .css('width', '100%')
}, },
showErrorsTab(clickEvent) { async showErrorsTab(clickEvent) {
this.$root.$emit('showTabErrors', clickEvent.data.item, clickEvent.target) await this.setErrors(clickEvent.data.item)
this.$router.push({ name: 'Errors' })
} }
} }
} }

View File

@ -1,6 +1,7 @@
<template> <template>
<div id="errors_tab" class="main_tabcontent"> <div id="errors_tab" class="main_tabcontent">
<h1>{{ $t('errors.title', { name: title }) }}</h1> <h1>{{ $t('errors.title', { name: title }) }}</h1>
<table class="table table--tracklist"> <table class="table table--tracklist">
<tr> <tr>
<th>ID</th> <th>ID</th>
@ -19,37 +20,17 @@
</template> </template>
<script> <script>
import { changeTab } from '@js/tabs.js' import { mapGetters } from 'vuex'
import EventBus from '@/utils/EventBus'
export default { export default {
name: 'the-errors-tab', computed: {
data: () => ({ ...mapGetters(['getErrors']),
title: '', title() {
errors: [] return `${this.getErrors.artist} - ${this.getErrors.title}`
}),
methods: {
reset() {
this.title = ''
this.errors = []
}, },
showErrors(data, eventTarget) { errors() {
this.title = data.artist + ' - ' + data.title return this.getErrors.errors
this.errors = data.errors
changeTab(eventTarget, 'main', 'errors_tab')
} }
},
mounted() {
console.log('errors mounted')
// this.$refs.root.style.display = 'block'
EventBus.$on('showTabErrors', this.showErrors)
this.$root.$on('showTabErrors', this.showErrors)
},
beforeDestroy() {
console.log('errors bef dest')
// this.$refs.root.style.display = 'none'
} }
} }
</script> </script>

View File

@ -7,6 +7,7 @@ window.main_selected = ''
window.windows_stack = [] window.windows_stack = []
window.currentStack = {} window.currentStack = {}
// Used only in errors tab
export function changeTab(sidebarEl, section, tabName) { export function changeTab(sidebarEl, section, tabName) {
window.windows_stack = [] window.windows_stack = []
window.currentStack = {} window.currentStack = {}

View File

@ -9,6 +9,7 @@ import charts from '@/store/modules/charts'
import favorites from '@/store/modules/favorites' import favorites from '@/store/modules/favorites'
import about from '@/store/modules/about' import about from '@/store/modules/about'
import login from '@/store/modules/login' import login from '@/store/modules/login'
import errors from '@/store/modules/errors'
// Load Vuex // Load Vuex
Vue.use(Vuex) Vue.use(Vuex)
@ -23,7 +24,8 @@ export default new Vuex.Store({
charts, charts,
favorites, favorites,
about, about,
login login,
errors
}, },
strict: process.env.NODE_ENV !== 'production' strict: process.env.NODE_ENV !== 'production'
}) })

View File

@ -0,0 +1,45 @@
const state = {
artist: '',
bitrate: '',
cover: '',
downloaded: 0,
errors: [],
failed: 0,
id: '',
progress: 0,
silent: true,
size: 0,
title: '',
type: '',
uuid: ''
}
const actions = {
setErrors({ commit }, payload) {
commit('SET_ERRORS', payload)
}
}
const getters = {
getErrors: state => state
}
const mutations = {
SET_ERRORS(state, payload) {
// The payload has useless data for the GUI, so only the needed data is saved in the store
for (const errorName in state) {
if (state.hasOwnProperty(errorName)) {
const error = payload[errorName]
state[errorName] = error
}
}
}
}
export default {
state,
getters,
actions,
mutations
}

View File

@ -4,7 +4,8 @@ const state = {
albums: [], albums: [],
artists: [], artists: [],
playlists: [], playlists: [],
tracks: [] tracks: [],
test: ''
} }
const actions = { const actions = {
@ -21,7 +22,7 @@ const actions = {
commit('SET_FAVORITES_ARTISTS', { index, data: artist }) commit('SET_FAVORITES_ARTISTS', { index, data: artist })
}) })
dispatch('setFavoritesTracks', payload.tracks) // dispatch('setFavoritesTracks', payload.tracks)
}, },
setFavoritesTracks({ commit }, payload) { setFavoritesTracks({ commit }, payload) {
payload.forEach((track, index) => { payload.forEach((track, index) => {

View File

@ -11,7 +11,8 @@ socket.on('init_charts', charts => {
}) })
socket.on('init_favorites', favorites => { socket.on('init_favorites', favorites => {
// store.dispatch('setFavorites', favorites) store.dispatch('setFavorites', favorites)
// store.dispatch('setFavorites', JSON.parse(JSON.stringify(favorites)))
}) })
socket.on('init_settings', (settings, credentials, defaults) => { socket.on('init_settings', (settings, credentials, defaults) => {