mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-23 03:23:05 +00:00
Add scanner and agent to PMS Sections store
This commit is contained in:
parent
fa900e003b
commit
ae75ba1721
2 changed files with 31 additions and 29 deletions
|
@ -206,6 +206,8 @@ const et = new class ET {
|
|||
subItem['title'] = JSONPath({path: '$..title', json: section})[0];
|
||||
subItem['key'] = parseInt(JSONPath({path: '$..key', json: section})[0]);
|
||||
subItem['type'] = JSONPath({path: '$..type', json: section})[0];
|
||||
subItem['scanner'] = JSONPath({path: '$..scanner', json: section})[0];
|
||||
subItem['agent'] = JSONPath({path: '$..agent', json: section})[0];
|
||||
result.push(subItem)
|
||||
}
|
||||
await Promise.resolve(result)
|
||||
|
|
|
@ -6,7 +6,7 @@ const log = require('electron-log');
|
|||
const {JSONPath} = require('jsonpath-plus');
|
||||
|
||||
const state = {
|
||||
settings: {}
|
||||
settings: {}
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
|
@ -23,31 +23,31 @@ const actions = {
|
|||
async setPMSSetting({ commit }, payload) {
|
||||
|
||||
commit
|
||||
|
||||
|
||||
let header = wtutils.PMSHeader;
|
||||
header['X-Plex-Token'] = payload.Token;
|
||||
const url = `${payload.Address}/:/prefs?${payload.Setting}=${payload.Value}`;
|
||||
const url = `${payload.Address}/:/prefs?${payload.Setting}=${payload.Value}`;
|
||||
log.debug(`Setting new setting with url ${url}`);
|
||||
await axios({
|
||||
method: 'put',
|
||||
url: url,
|
||||
url: url,
|
||||
headers: header
|
||||
})
|
||||
.then((response) => {
|
||||
log.debug('Response from setPMSSetting recieved')
|
||||
response
|
||||
.then((response) => {
|
||||
log.debug('Response from setPMSSetting recieved')
|
||||
response
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response) {
|
||||
if (error.response) {
|
||||
log.error('setPMSSetting: ' + error.response.data)
|
||||
alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message)
|
||||
} else if (error.request) {
|
||||
log.error('setPMSSetting: ' + error.request)
|
||||
} else {
|
||||
log.error('setPMSSetting: ' + error.message)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
async fetchPMSSettings({ commit }, payload) {
|
||||
|
@ -56,11 +56,11 @@ const actions = {
|
|||
const url = payload.Address + '/:/prefs';
|
||||
await axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
url: url,
|
||||
headers: header
|
||||
})
|
||||
.then((response) => {
|
||||
log.debug('Response from fetchPlexServers recieved')
|
||||
.then((response) => {
|
||||
log.debug('Response from fetchPlexServers recieved')
|
||||
var filteredResult = {}
|
||||
// Filtered result based on hidden, adv or all
|
||||
var curFilter = wtconfig.get('PMS.FilterSetting', 'AllSettings');
|
||||
|
@ -71,54 +71,54 @@ const actions = {
|
|||
else if (curFilter == 'OnlyHidden'){
|
||||
filteredResult = JSONPath({path: '$..Setting[?(@.hidden==true)]', json: response.data});
|
||||
}
|
||||
else {
|
||||
else {
|
||||
filteredResult = JSONPath({path: '$..Setting[?(@.advanced==true)]', json: response.data});
|
||||
}
|
||||
// Reset PMSSettings
|
||||
// Reset PMSSettings
|
||||
var PMSSettings = {};
|
||||
// Create Array for undefined
|
||||
PMSSettings[i18n.t('Modules.PMS.Settings.Undefined')] = [];
|
||||
PMSSettings[i18n.t('Modules.PMS.Settings.Undefined')] = [];
|
||||
// Create Arrays for other categories
|
||||
filteredResult.forEach(group => {
|
||||
group = JSONPath({path: '$.group', json: group})[0]
|
||||
group = JSONPath({path: '$.group', json: group})[0]
|
||||
if (group !== "") {
|
||||
PMSSettings[group] = [];
|
||||
}
|
||||
})
|
||||
// Get the single items
|
||||
filteredResult.forEach(element => {
|
||||
// Get the single items
|
||||
filteredResult.forEach(element => {
|
||||
var id = JSONPath({path: '$.id', json: element});
|
||||
var itemGroup = JSONPath({path: '$.group', json: element});
|
||||
if (itemGroup == "")
|
||||
{
|
||||
itemGroup = i18n.t('Modules.PMS.Settings.Undefined');
|
||||
}
|
||||
var PMSSettingsItem = {}
|
||||
}
|
||||
var PMSSettingsItem = {}
|
||||
var jNode = {};
|
||||
jNode['label'] = JSONPath({path: '$.label', json: element})[0];
|
||||
jNode['summary'] = JSONPath({path: '$.summary', json: element})[0];
|
||||
jNode['type'] = JSONPath({path: '$.type', json: element})[0];
|
||||
jNode['default'] = JSONPath({path: '$.default', json: element})[0];
|
||||
jNode['value'] = JSONPath({path: '$.value', json: element})[0];
|
||||
PMSSettingsItem[id] = jNode;
|
||||
jNode['value'] = JSONPath({path: '$.value', json: element})[0];
|
||||
PMSSettingsItem[id] = jNode;
|
||||
PMSSettings[itemGroup].push(PMSSettingsItem)
|
||||
});
|
||||
});
|
||||
// Remove undefined category, if empty
|
||||
if (Object.keys(PMSSettings[i18n.t('Modules.PMS.Settings.Undefined')]).length === 0){
|
||||
if (Object.keys(PMSSettings[i18n.t('Modules.PMS.Settings.Undefined')]).length === 0){
|
||||
delete PMSSettings[i18n.t('Modules.PMS.Settings.Undefined')];
|
||||
}
|
||||
log.verbose(`PMS Settings are: ${JSON.stringify(PMSSettings)}`)
|
||||
log.verbose(`PMS Settings are: ${JSON.stringify(PMSSettings)}`)
|
||||
commit('UPDATE_PMS_SETTINGS', PMSSettings);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response) {
|
||||
if (error.response) {
|
||||
log.error('fetchPMSSettings: ' + error.response.data)
|
||||
alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message)
|
||||
} else if (error.request) {
|
||||
log.error('fetchPMSSettings: ' + error.request)
|
||||
} else {
|
||||
log.error('fetchPMSSettings: ' + error.message)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -131,5 +131,5 @@ const serverModule = {
|
|||
actions,
|
||||
getters
|
||||
};
|
||||
|
||||
|
||||
export default serverModule;
|
Loading…
Reference in a new issue