Added more info to link analyzer

This commit is contained in:
RemixDev 2021-10-05 12:14:59 +02:00
parent 9c80d4b28c
commit 78d9b2decd
4 changed files with 49 additions and 9 deletions

View File

@ -27,6 +27,13 @@ import { isValidURL } from '@/utils/utils'
import { sendAddToQueue } from '@/utils/downloads' import { sendAddToQueue } from '@/utils/downloads'
import { SPOTIFY_STATUS } from '@/constants' import { SPOTIFY_STATUS } from '@/constants'
/* ===== Random utils ===== */
/* eslint-disable no-extend-native */
String.prototype.capitalize = function () {
return this.charAt(0).toUpperCase() + this.slice(1)
}
/* ===== App initialization ===== */ /* ===== App initialization ===== */
async function startApp() { async function startApp() {
new Vue({ new Vue({

View File

@ -118,12 +118,24 @@
<td>{{ $t('linkAnalyzer.table.genres') }}</td> <td>{{ $t('linkAnalyzer.table.genres') }}</td>
<td>{{ data.genres.data.map(x => x.name).join('; ') }}</td> <td>{{ data.genres.data.map(x => x.name).join('; ') }}</td>
</tr> </tr>
<tr v-if="data.readable !== undefined">
<td>{{ $t('linkAnalyzer.table.readable') }}</td>
<td>{{ $t( data.readable ? 'globals.yes' : 'globals.no').capitalize() }}</td>
</tr>
<tr v-if="countries.length"> <tr v-if="countries.length">
<td>{{ $t('linkAnalyzer.table.countries') }}</td> <td>{{ $t('linkAnalyzer.table.available') }}</td>
<td v-for="(country, i) in countries" :key="i">{{ country[0] }} - {{ country[1] }}</td> <td>{{ $t( available_countries.includes(user.country.toLowerCase()) ? 'globals.yes' : 'globals.no').capitalize() }}</td>
</tr> </tr>
</table> </table>
<template v-if="countries.length">
<h3>{{ $t('linkAnalyzer.countries') }}</h3>
<p v-for="(country, i) in countries" :key="i">{{ country[0] }} - {{ country[1] }}</p>
</template>
<template v-else>
<h3>{{ $t('linkAnalyzer.noCountries') }}</h3>
</template>
<div v-if="type === 'album'"> <div v-if="type === 'album'">
<router-link tag="button" class="btn btn-primary" name="button" :to="{ name: 'Album', params: { id } }"> <router-link tag="button" class="btn btn-primary" name="button" :to="{ name: 'Album', params: { id } }">
{{ $t('linkAnalyzer.table.tracklist') }} {{ $t('linkAnalyzer.table.tracklist') }}
@ -135,6 +147,7 @@
<script> <script>
/* eslint-disable camelcase */ /* eslint-disable camelcase */
import { mapGetters } from 'vuex'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import { convertDuration } from '@/utils/utils' import { convertDuration } from '@/utils/utils'
import { COUNTRIES } from '@/utils/countries' import { COUNTRIES } from '@/utils/countries'
@ -151,9 +164,15 @@ export default {
data: {}, data: {},
type: '', type: '',
id: '0', id: '0',
countries: [] countries: [],
available_countries: []
} }
}, },
computed: {
...mapGetters({
user: 'getUser'
})
},
mounted() { mounted() {
EventBus.$on('analyze_track', this.showTrack) EventBus.$on('analyze_track', this.showTrack)
EventBus.$on('analyze_album', this.showAlbum) EventBus.$on('analyze_album', this.showAlbum)
@ -169,6 +188,7 @@ export default {
this.type = '' this.type = ''
this.link = '' this.link = ''
this.countries = [] this.countries = []
this.available_countries = []
}, },
showTrack(data) { showTrack(data) {
this.reset() this.reset()
@ -193,6 +213,7 @@ export default {
temp.push(String.fromCodePoint(...chars)) temp.push(String.fromCodePoint(...chars))
temp.push(COUNTRIES[cc]) temp.push(COUNTRIES[cc])
this.countries.push(temp) this.countries.push(temp)
this.available_countries.push(cc.toLowerCase())
}) })
this.data = data this.data = data

View File

@ -41,7 +41,9 @@ const en = {
albumN: '0 albums | {n} album | {n} albums', albumN: '0 albums | {n} album | {n} albums',
artistN: '0 artists | {n} artist | {n} artists', artistN: '0 artists | {n} artist | {n} artists',
playlistN: '0 playlists | {n} playlist | {n} playlists' playlistN: '0 playlists | {n} playlist | {n} playlists'
} },
yes: 'yes',
no: 'no'
}, },
about: { about: {
appStatus: { appStatus: {
@ -166,8 +168,12 @@ const en = {
label: 'Label', label: 'Label',
recordType: 'Record Type', recordType: 'Record Type',
genres: 'Genres', genres: 'Genres',
tracklist: 'Tracklist' tracklist: 'Tracklist',
} readable: 'Readable',
available: 'Available'
},
countries: 'Countries',
noCountries: 'This track is not available in any country.'
}, },
search: { search: {
startSearching: 'Start searching!', startSearching: 'Start searching!',

View File

@ -41,7 +41,9 @@ const it = {
albumN: '{n} album', albumN: '{n} album',
artistN: '0 artisti | {n} artista | {n} artisti', artistN: '0 artisti | {n} artista | {n} artisti',
playlistN: '{n} playlist' playlistN: '{n} playlist'
} },
yes: 'sì',
no: 'no'
}, },
about: { about: {
appStatus: { appStatus: {
@ -166,8 +168,12 @@ const it = {
label: 'Etichetta', label: 'Etichetta',
recordType: 'Tipologia di registrazione', recordType: 'Tipologia di registrazione',
genres: 'Generi', genres: 'Generi',
tracklist: 'Lista tracce' tracklist: 'Lista tracce',
} readable: 'Leggibile',
available: 'Disponibile'
},
countries: 'Paesi',
noCountries: 'Questo brano non è disponibile in nessun paese.'
}, },
search: { search: {
startSearching: 'Inizia a cercare!', startSearching: 'Inizia a cercare!',