Merge pull request #206 from WebTools-NG/#195-PMS-Settings

#195 pms settings
This commit is contained in:
Tommy Mikkelsen 2021-01-11 23:29:50 +01:00 committed by GitHub
commit 8302660cbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 32 deletions

View file

@ -131,12 +131,13 @@
"Settings": {
"Settings": "Settings",
"Description": "Here you can define the settings for the selected server",
"Notice": "Note: When changing a server setting you might need to restart the server afterwards",
"SelectSettingsSelection": "Select Settings Group",
"TTSelectSettingsSelection": "Here you select the group the setting you want to alter is in",
"OnlyHidden": "Show only hidden settings",
"OnlyAdvanced": "Show only advanced settings",
"Undefined": "undefined",
"tblCaption": "Settings",
"tblCaption": "Settings - click row to change",
"tblName": "Name",
"tblLabel": "Label",
"tblSummary": "Summary",
@ -146,7 +147,8 @@
"newSettingTitle": "Enter the new setting for: {0}",
"curSetting": "Current Setting",
"defSetting": "Default Setting",
"newSettingValueTXT": "<Enter new value>"
"newSettingValueTXT": "<Enter new value>",
"varning": "Change at your own risk. Any change can lead to malfunction of your plex server"
}
},
"ET": {

View file

@ -2,7 +2,8 @@
<b-container fluid>
<div class="col-lg-10 col-md-12 col-xs-12">
<h1>{{ $t("Modules.PMS.Settings.Settings") }}</h1>
<p>{{ $t("Modules.PMS.Settings.Description") }}</p>
<p>{{ $t("Modules.PMS.Settings.Description") }}</p>
<p>{{ $t("Modules.PMS.Settings.Notice") }}</p>
</div>
<div>
<b-form-group id="b-form-group">
@ -31,9 +32,40 @@
<div>
<b-modal ref="edtSetting" hide-footer v-bind:title=this.newSettingTitle >
<div class="d-block text-center">
{{ $t('Modules.PMS.Settings.curSetting') }}: {{this.curSetting}}
<br>
{{ $t('Modules.PMS.Settings.defSetting') }}: {{this.defSetting}}
<b-alert variant="danger" show>{{ $t('Modules.PMS.Settings.varning') }}</b-alert>
<b-container fluid>
<b-row>
<b-col sm="2">
<label for="textarea-curSetting">{{ $t('Modules.PMS.Settings.curSetting') }}:</label>
</b-col>
<b-col sm="10">
<b-form-textarea
id="textarea-curSetting"
plaintext
size="sm"
v-model=this.curSetting
rows="1"
max-rows="8"
></b-form-textarea>
</b-col>
</b-row>
<br>
<b-row>
<b-col sm="2">
<label for="textarea-defSetting">{{ $t('Modules.PMS.Settings.defSetting') }}:</label>
</b-col>
<b-col sm="10">
<b-form-textarea
id="textarea-defSetting"
plaintext
size="sm"
v-model=this.defSetting
rows="1"
max-rows="8"
></b-form-textarea>
</b-col>
</b-row>
</b-container>
<br>
<b-form-input
v-model="newSettingValue"
@ -109,38 +141,49 @@
methods: {
async saveNewSetting() {
log.debug(`Saving setting ${this.newSettingValue} for setting ${this.edtSettingKey}`);
// Contructing url
const url = this.$store.getters.getSelectedServerAddress + '/:/prefs/set?'
console.log('URL: ' + url)
// Save setting
await store.dispatch('setPMSSetting', {
Token: this.$store.getters.getAuthToken,
Address: this.$store.getters.getSelectedServerAddress,
Setting: this.edtSettingKey,
Value: this.newSettingValue});
// http://127.0.0.1:32400/:/prefs/set?LogNumFiles=30&X-Plex-Token=TOKEN
Value: this.newSettingValue});
this.$refs['edtSetting'].hide();
await this.getServerSettings();
this.updateTbl(this.selSection);
},
tblRowClicked(record) {
console.log('Ged Row clicked')
console.log('Ged2', record)
// Edit Setting
log.debug(`Edit Setting: ${record.name}`);
this.curSetting = record.value;
this.defSetting = record.default;
if (!record.default)
{
this.defSetting = 'false';
}
else if (record.value)
{
this.curSetting = 'true';
}
else{
this.defSetting = record.default;
}
if (!record.value)
{
this.curSetting = 'false';
}
else if (record.value)
{
this.curSetting = 'true';
}
else{
this.curSetting = record.value;
}
this.edtSettingKey = record.name;
this.newSettingTitle = i18n.t('Modules.PMS.Settings.newSettingTitle', [this.edtSettingKey]);
this.newSettingValue = "";
this.$refs['edtSetting'].show();
},
getGroupSelectedItem: function(myarg) {
log.debug(`Group changed to: ${myarg}`);
updateTbl(group) {
// Update the data table with new settings
const filteredResult = JSONPath({path: `$.${myarg}`, json: this.$store.getters.getPMSSettings})[0];
const filteredResult = JSONPath({path: `$.${group}`, json: this.$store.getters.getPMSSettings})[0];
log.verbose(`filtered settings: ${JSON.stringify(filteredResult)}`);
this.settingsItems = [];
for (var i = 0; i < filteredResult.length; i++) {
@ -154,6 +197,24 @@
this.settingsItems.push(entry);
}
},
getGroupSelectedItem: function(myarg) {
log.debug(`Group changed to: ${myarg}`);
this.updateTbl(myarg);
/* // Update the data table with new settings
const filteredResult = JSONPath({path: `$.${myarg}`, json: this.$store.getters.getPMSSettings})[0];
log.verbose(`filtered settings: ${JSON.stringify(filteredResult)}`);
this.settingsItems = [];
for (var i = 0; i < filteredResult.length; i++) {
var entry = {};
entry['name'] = JSONPath({path: `$.*~`, json: filteredResult[i]})[0];
entry['label'] = JSONPath({path: `$..label`, json: filteredResult[i]})[0];
entry['summary'] = JSONPath({path: `$..summary`, json: filteredResult[i]})[0];
entry['type'] = JSONPath({path: `$..type`, json: filteredResult[i]})[0];
entry['default'] = JSONPath({path: `$..default`, json: filteredResult[i]})[0];
entry['value'] = JSONPath({path: `$..value`, json: filteredResult[i]})[0];
this.settingsItems.push(entry);
} */
},
async serverSelected() {
let serverCheck = this.$store.getters.getSelectedServer;
if (serverCheck == "none") {
@ -176,19 +237,20 @@
log.debug('Options are: ' + JSON.stringify(Object.keys(this.$store.getters.getPMSSettings)))
this.selSectionOptions = Object.keys(this.$store.getters.getPMSSettings).sort();
},
changedOptions() {
async changedOptions() {
log.debug('Updating OnlyHidden Setting');
//this.$nextTick(()=>{console.log(this.cbSelected);})
for( var cbItem of ["OnlyHidden", "OnlyAdvanced"]){
wtconfig.set("PMS." + cbItem, (this.cbSelected.includes(cbItem)))
}
this.getServerSettings();
await this.getServerSettings();
this.updateTbl(this.selSection);
},
getcbDefaults() {
log.debug('Get OnlyHidden Setting');
const cbItems = ["OnlyHidden", "OnlyAdvanced"];
for(let i = 0; i < cbItems.length; i++){
if (wtconfig.get("PMS." + cbItems[i], true)){
if (wtconfig.get("PMS." + cbItems[i], false)){
this.cbSelected.push(cbItems[i])
}
}

View file

@ -127,10 +127,7 @@ const actions = {
// that falls out of the range of 2xx
log.error(`loginToPlex status: ${error.response.status}`);
log.error(`loginToPlex data: ${JSON.stringify(error.response.data)}`);
// alert(error.response.data.message)
// alert(error.response.data.message)
var data = JSON.stringify(error.response.data);
var objectValue = JSON.parse(data);
var statusCode = JSON.stringify(objectValue.errors[0].code);