global variable apiUrl

This commit is contained in:
Jonas Heinrich 2020-10-30 18:36:01 +01:00
parent cbcb7445c7
commit 415a672af3
2 changed files with 17 additions and 21 deletions

View File

@ -86,23 +86,7 @@ export default {
this.tableData = []
const route = this.$route
this.$store.dispatch('setMenuState', route.name)
switch (route.name) {
case 'TOP':
this.loadStations()
break
case 'RECENT':
this.loadStations()
break
case 'NEW':
this.loadStations()
break
case 'FAVORITES':
this.loadStations()
break
case 'CATEGORIES':
this.loadStations()
break
}
this.loadStations(route.name)
},
/**
* Favor a new station by sending the information to the server
@ -131,7 +115,7 @@ export default {
audioPlayer.fade(vm.player.volume, 0, 500)
}
vm.$store.dispatch('setTitle', station.name)
this.$jquery.get('http://de1.api.radio-browser.info/json/url/' + station.stationuuid,
this.$jquery.get(this.$apiUrl + '/json/url/' + station.stationuuid,
{
'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work
})
@ -168,16 +152,26 @@ export default {
},
/**
* Fetching radio stations using Radio-Browser.info API
* @param {String} menuState Entries to load
*/
loadStations() {
loadStations(menuState = 'TOP') {
const vm = this
if (vm.offset === 0) {
vm.pageLoading = true
}
this.$jquery.getJSON('https://de1.api.radio-browser.info/json/stations',
let sortBy = 'clickcount'
if (menuState === 'TOP') {
sortBy = 'clickcount'
} else if (menuState === 'NEW') {
sortBy = 'lastchangetime'
}
this.$jquery.getJSON(this.$apiUrl + '/json/stations',
{
limit: 20,
order: 'clickcount',
order: sortBy,
reverse: true,
offset: vm.offset,
'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version, doesnt seem to work

View File

@ -36,6 +36,8 @@ Vue.prototype.t = translate
Vue.prototype.n = translatePlural
Vue.prototype.$jquery = jquery
Vue.prototype.$apiUrl = 'https://de1.api.radio-browser.info'
Vue.use(VueBlurHash)
export default new Vue({