showplaymenu: false,
showsearchbox: false,
playmenuitem: null,
- server: null
+ server: null,
+ apiAddress: null,
+ wsAddress: null
}
})
Vue.prototype.$globals = globalStore;
localStorage.setItem('last_update', cur_update);
window.location.reload(true);
}
- var loc = window.location;
- console.log(loc);
- this.$globals.server = loc;
+ // TODO: retrieve serveraddress through discovery and/or user settings
+ let loc = window.location;
+ this.$globals.server = loc.origin + loc.pathname;
+ this.$globals.apiAddress = this.$globals.server + 'api/';
+ if (loc.protocol === "https:") {
+ this.$globals.wsAddress = "wss://"+ loc.host + loc.pathname + 'ws';
+ } else {
+ this.$globals.wsAddress = "ws://"+ loc.host + loc.pathname + 'ws';
+ }
},
data: { },
methods: {},
if (!val)
this.cur_player_item = null;
else {
- const api_url = '/api/players/' + this.active_player_id + '/queue/' + val;
+ const api_url = this.$globals.server + 'api/players/' + this.active_player_id + '/queue/' + val;
axios
.get(api_url)
.then(result => {
},
connectWS() {
- var loc = window.location, new_uri;
- if (loc.protocol === "https:") {
- new_uri = "wss:";
- } else {
- new_uri = "ws:";
- }
- new_uri += "/" + loc.host;
- new_uri += loc.pathname + "ws";
- this.ws = new WebSocket(new_uri);
+ this.ws = new WebSocket(this.$globals.wsAddress);
this.ws.onopen = function() {
- console.log('websocket connected! ' + new_uri);
+ console.log('websocket connected! ' + this.$globals.wsAddress);
this.createAudioPlayer();
data = JSON.stringify({message:'players', message_details: null});
this.ws.send(data);
return hours+':'+minutes+':'+seconds;
}
function toggleLibrary (item) {
- var endpoint = "/api/" + item.media_type + "/";
+ var endpoint = this.$globals.server + "api/" + item.media_type + "/";
item_id = item.item_id.toString();
var action = "/library_remove"
if (item.in_library.length == 0)
},
getInfo (lazy=true) {
this.$globals.loading = true;
- const api_url = '/api/artists/' + this.media_id;
+ const api_url = this.$globals.apiAddress + 'artists/' + this.media_id;
console.log(api_url + ' - ' + this.provider);
axios
.get(api_url, { params: { lazy: lazy, provider: this.provider }})
},
getArtistTopTracks () {
- const api_url = '/api/artists/' + this.media_id + '/toptracks'
+ const api_url = this.$globals.apiAddress + 'artists/' + this.media_id + '/toptracks'
axios
.get(api_url, { params: { provider: this.provider }})
.then(result => {
},
getArtistAlbums () {
- const api_url = '/api/artists/' + this.media_id + '/albums'
+ const api_url = this.$globals.apiAddress + 'artists/' + this.media_id + '/albums'
console.log('loading ' + api_url);
axios
.get(api_url, { params: { provider: this.provider }})
methods: {
getItems () {
this.$globals.loading = true
- const api_url = '/api/' + this.mediatype;
+ const api_url = this.$globals.apiAddress + this.mediatype;
axios
.get(api_url, { params: { offset: this.offset, limit: 50, provider: this.provider }})
.then(result => {
methods: {
getConfig () {
axios
- .get('/api/config')
+ .get(this.$globals.apiAddress + 'config')
.then(result => {
this.conf = result.data;
})
console.log(key + "/" + subkey + " changed!");
console.log(newvalue);
axios
- .post('/api/config/'+key+'/'+subkey, newvalue)
+ .post(this.$globals.apiAddress + 'config/'+key+'/'+subkey, newvalue)
.then(result => {
console.log(result);
if (result.data.restart_required)
});
},
getPlayers () {
- const api_url = '/api/players';
+ const api_url = this.$globals.apiAddress + 'players';
axios
.get(api_url)
.then(result => {
},
methods: {
getInfo () {
- const api_url = '/api/playlists/' + this.media_id
+ const api_url = this.$globals.apiAddress + 'playlists/' + this.media_id
axios
.get(api_url, { params: { provider: this.provider }})
.then(result => {
},
getPlaylistTracks () {
this.$globals.loading = true
- const api_url = '/api/playlists/' + this.media_id + '/tracks'
+ const api_url = this.$globals.apiAddress + 'playlists/' + this.media_id + '/tracks'
axios
.get(api_url, { params: { offset: this.offset, limit: 25, provider: this.provider}})
.then(result => {
methods: {
getQueueTracks (offset, limit) {
- const api_url = '/api/players/' + this.player_id + '/queue'
+ const api_url = this.$globals.apiAddress + 'players/' + this.player_id + '/queue'
return axios.get(api_url, { params: { offset: offset, limit: limit}})
.then(response => {
if (response.data.length < 1 )
if (this.searchQuery) {
this.$globals.loading = true;
console.log(this.searchQuery);
- const api_url = '/api/search'
+ const api_url = this.$globals.apiAddress + 'search'
console.log('loading ' + api_url);
axios
.get(api_url, {
methods: {
getInfo () {
this.$globals.loading = true;
- const api_url = '/api/tracks/' + this.media_id
+ const api_url = this.$globals.apiAddress + 'tracks/' + this.media_id
axios
.get(api_url, { params: { provider: this.provider }})
.then(result => {
});
},
getTrackVersions () {
- const api_url = '/api/search';
+ const api_url = this.$globals.apiAddress + 'search';
var searchstr = this.info.artists[0].name + " - " + this.info.name
axios
.get(api_url, { params: { query: searchstr, limit: 50, media_types: 'tracks', online: true}})