mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-23 11:33:14 +00:00
#16 clean up in store comments, now uses electron-log. Data from export no longer overwrites libary data
This commit is contained in:
parent
7ce3db98d3
commit
cc5090417d
2 changed files with 25 additions and 17 deletions
|
@ -1,8 +1,11 @@
|
|||
import axios from 'axios';
|
||||
const log = require('electron-log');
|
||||
|
||||
|
||||
|
||||
const state = {
|
||||
sections: [],
|
||||
mediaData: [],
|
||||
selectedSection : "",
|
||||
selectedExportLevel: ""
|
||||
};
|
||||
|
@ -10,18 +13,23 @@ const state = {
|
|||
const mutations = {
|
||||
UPDATE_SECTIONS(state, payload) {
|
||||
state.sections = payload;
|
||||
log.info("UPDATE_SECTIONS called")
|
||||
},
|
||||
UPDATE_SELECTEDSECTION(state, payload) {
|
||||
state.selectedSection = payload
|
||||
log.info("UPDATE_SELECTEDSECTION called")
|
||||
},
|
||||
UPDATE_EXPORTLEVEL(state, payload) {
|
||||
state.selectedExportLevel = payload
|
||||
},
|
||||
UPDATE_MEDIADATA(state, payload) {
|
||||
state.mediaData = payload
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
fetchSections({ commit, getters }) {
|
||||
console.log("calling fetchSections")
|
||||
log.info("fetchSections called")
|
||||
var baseURL = getters.getSlectedServerAddress
|
||||
|
||||
axios({
|
||||
|
@ -34,8 +42,10 @@ const actions = {
|
|||
'X-Plex-Token': getters.getAuthToken
|
||||
}
|
||||
}).then((response) => {
|
||||
console.log("fetchSection is status " + response.status)
|
||||
log.info("fetchSection is status " + response.status)
|
||||
commit('UPDATE_SECTIONS', response.data.MediaContainer.Directory)
|
||||
log.verbose("verbose log fetchSection is status " + response.status)
|
||||
|
||||
|
||||
}
|
||||
).catch((error) => {
|
||||
|
@ -44,6 +54,7 @@ const actions = {
|
|||
// that falls out of the range of 2xx
|
||||
console.log(error.response.data)
|
||||
console.log("fetching is error status", error.response.status)
|
||||
|
||||
alert(error.response.data.error)
|
||||
//this.danger(error.response.status, error.response.data.error);
|
||||
} else if (error.request) {
|
||||
|
@ -83,9 +94,7 @@ const actions = {
|
|||
}
|
||||
}).then((response) => {
|
||||
console.log("getMedia is status " + response.status)
|
||||
console.log(response.data)
|
||||
console.log(response.data.MediaContainer.Metadata)
|
||||
commit('UPDATE_SECTIONS', response.data.MediaContainer.Metadata)
|
||||
commit('UPDATE_MEDIADATA', response.data.MediaContainer.Metadata)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -53,31 +53,30 @@ const actions = {
|
|||
.then((response) => {
|
||||
let result=[];
|
||||
log.info('Response from fetchPlexServers recieved')
|
||||
log.verbose(response)
|
||||
// console.log("response from fetchPlexServers", response)
|
||||
response.data.forEach((req) => {
|
||||
// if (req.owned == true && req.product == "Plex Media Server") {
|
||||
if (req.product == "Plex Media Server") {
|
||||
console.log('GED&NUGGA ser ikke owned')
|
||||
log.warn('GED&NUGGA : fetchPlexServers : ser ikke owned')
|
||||
log.debug(req)
|
||||
result.push(req);
|
||||
}
|
||||
})
|
||||
commit('UPDATE_PLEX_SERVERS', result)
|
||||
//this.$store.dispatch('fetchSections')
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response) {
|
||||
console.log(error.response.data)
|
||||
log.error('fetchPlexServers: ' + error.response.data)
|
||||
alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message)
|
||||
} else if (error.request) {
|
||||
console.log(error.request);
|
||||
log.error('fetchPlexServers: ' + error.request)
|
||||
|
||||
} else {
|
||||
console.log('Error on fetchPlexServers', error.message);
|
||||
log.error('fetchPlexServers: ' + error.message)
|
||||
}
|
||||
});
|
||||
},
|
||||
loginToPlex({ commit }, payload){
|
||||
log.info("loginToPlex called")
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: 'https://plex.tv/users/sign_in.json',
|
||||
|
@ -93,29 +92,29 @@ const actions = {
|
|||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
log.info('loginToPlex: Response from fetchPlexServers recieved')
|
||||
commit('UPDATE_AUTHTOKEN', response.data.user.authToken)
|
||||
commit('UPDATE_AUTHENTICATED', true)
|
||||
commit('UPDATE_AVATAR', response.data.user.thumb)
|
||||
commit('UPDATE_PLEXNAME', response.data.user.username)
|
||||
|
||||
router.replace({name: "home"});
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response) {
|
||||
// The request was made and the server responded with a status code
|
||||
// that falls out of the range of 2xx
|
||||
console.log(error.response.data)
|
||||
console.log(error.response.status)
|
||||
log.error('loginToPlex: ' + error.response.status)
|
||||
log.error('loginToPlex: ' + error.response.data)
|
||||
alert(error.response.data.error)
|
||||
//this.danger(error.response.status, error.response.data.error);
|
||||
} else if (error.request) {
|
||||
// The request was made but no response was received
|
||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
||||
// http.ClientRequest in node.js
|
||||
console.log(error.request);
|
||||
log.error('loginToPlex: ' + error.request)
|
||||
} else {
|
||||
// Something happened in setting up the request that triggered an Error
|
||||
console.log('Error', error.message);
|
||||
log.error('loginToPlex: ' + error.message)
|
||||
}})
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue