2.0
Juraj Nyíri 3 years ago
parent cb9f0cbab0
commit f2a870cc50

@ -19468,6 +19468,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.sections = [];
this.entitiesRegistry = false;
this.plexValidSection = document.createElement('div');
this.loaded = false;
this.fireEvent = (node, type, detail, options = {}) => {
// eslint-disable-next-line no-param-reassign
detail = detail === null || detail === undefined ? {} : detail;
@ -19481,69 +19482,71 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
return event;
};
this.valueUpdated = () => {
const originalConfig = lodash.clone(this.config);
this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value;
this.config.token = this.token.value;
this.config.port = this.port.value;
if (!this.config.entity) {
this.config.entity = [];
}
if (!lodash.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value;
let sortOrderValue = '';
if (lodash.isEqual(this.sortOrder.value, 'Ascending')) {
sortOrderValue = 'asc';
}
else if (lodash.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
if (!lodash.isEmpty(sortOrderValue) && !lodash.isEmpty(this.sort.value)) {
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
}
else {
this.config.sort = ``;
}
if (lodash.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
}
else {
this.config.maxCount = this.maxCount.value;
}
if (!lodash.isEmpty(this.entities)) {
if (this.loaded) {
const originalConfig = lodash.clone(this.config);
this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value;
this.config.token = this.token.value;
this.config.port = this.port.value;
if (!this.config.entity) {
this.config.entity = [];
lodash.forEach(this.entities, entity => {
if (!lodash.isEmpty(entity.value) && !lodash.includes(this.config.entity, entity.value)) {
this.config.entity.push(entity.value);
}
});
}
if (lodash.isEqual(this.playTrailer.value, 'Yes')) {
this.config.playTrailer = true;
}
else if (lodash.isEqual(this.playTrailer.value, 'No')) {
this.config.playTrailer = false;
}
else if (lodash.isEqual(this.playTrailer.value, 'Muted')) {
this.config.playTrailer = 'muted';
}
if (lodash.isEqual(this.showExtras.value, 'Yes')) {
this.config.showExtras = true;
}
else if (lodash.isEqual(this.showExtras.value, 'No')) {
this.config.showExtras = false;
}
if (lodash.isEqual(this.showSearch.value, 'Yes')) {
this.config.showSearch = true;
if (!lodash.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value;
let sortOrderValue = '';
if (lodash.isEqual(this.sortOrder.value, 'Ascending')) {
sortOrderValue = 'asc';
}
else if (lodash.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
if (!lodash.isEmpty(sortOrderValue) && !lodash.isEmpty(this.sort.value)) {
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
}
else {
this.config.sort = ``;
}
if (lodash.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
}
else {
this.config.maxCount = this.maxCount.value;
}
if (!lodash.isEmpty(this.entities)) {
this.config.entity = [];
lodash.forEach(this.entities, entity => {
if (!lodash.isEmpty(entity.value) && !lodash.includes(this.config.entity, entity.value)) {
this.config.entity.push(entity.value);
}
});
}
if (lodash.isEqual(this.playTrailer.value, 'Yes')) {
this.config.playTrailer = true;
}
else if (lodash.isEqual(this.playTrailer.value, 'No')) {
this.config.playTrailer = false;
}
else if (lodash.isEqual(this.playTrailer.value, 'Muted')) {
this.config.playTrailer = 'muted';
}
if (lodash.isEqual(this.showExtras.value, 'Yes')) {
this.config.showExtras = true;
}
else if (lodash.isEqual(this.showExtras.value, 'No')) {
this.config.showExtras = false;
}
if (lodash.isEqual(this.showSearch.value, 'Yes')) {
this.config.showSearch = true;
}
else if (lodash.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false;
}
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
}
else if (lodash.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false;
if (!lodash.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config });
}
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
}
if (!lodash.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config });
}
};
this.render = async () => {
@ -19910,6 +19913,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
}
this.plexValidSection.style.display = 'block';
}
this.loaded = true;
this.content.appendChild(this.plexValidSection);
};
this.setConfig = (config) => {

@ -60,6 +60,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
plexValidSection = document.createElement('div');
loaded = false;
fireEvent = (
node: HTMLElement,
type: string,
@ -79,65 +81,67 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
};
valueUpdated = (): void => {
const originalConfig = _.clone(this.config);
this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value;
this.config.token = this.token.value;
this.config.port = this.port.value;
if (!this.config.entity) {
this.config.entity = [];
}
if (!_.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value;
let sortOrderValue = '';
if (_.isEqual(this.sortOrder.value, 'Ascending')) {
sortOrderValue = 'asc';
} else if (_.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
if (!_.isEmpty(sortOrderValue) && !_.isEmpty(this.sort.value)) {
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
} else {
this.config.sort = ``;
if (this.loaded) {
const originalConfig = _.clone(this.config);
this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value;
this.config.token = this.token.value;
this.config.port = this.port.value;
if (!this.config.entity) {
this.config.entity = [];
}
if (!_.isEmpty(this.libraryName.value)) {
this.config.libraryName = this.libraryName.value;
let sortOrderValue = '';
if (_.isEqual(this.sortOrder.value, 'Ascending')) {
sortOrderValue = 'asc';
} else if (_.isEqual(this.sortOrder.value, 'Descending')) {
sortOrderValue = 'desc';
}
if (!_.isEmpty(sortOrderValue) && !_.isEmpty(this.sort.value)) {
this.config.sort = `${this.sort.value}:${sortOrderValue}`;
} else {
this.config.sort = ``;
}
if (_.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
} else {
this.config.maxCount = this.maxCount.value;
}
if (_.isEmpty(this.maxCount.value)) {
this.config.maxCount = '';
} else {
this.config.maxCount = this.maxCount.value;
}
if (!_.isEmpty(this.entities)) {
this.config.entity = [];
_.forEach(this.entities, entity => {
if (!_.isEmpty(entity.value) && !_.includes(this.config.entity, entity.value)) {
this.config.entity.push(entity.value);
}
});
}
if (_.isEqual(this.playTrailer.value, 'Yes')) {
this.config.playTrailer = true;
} else if (_.isEqual(this.playTrailer.value, 'No')) {
this.config.playTrailer = false;
} else if (_.isEqual(this.playTrailer.value, 'Muted')) {
this.config.playTrailer = 'muted';
}
if (_.isEqual(this.showExtras.value, 'Yes')) {
this.config.showExtras = true;
} else if (_.isEqual(this.showExtras.value, 'No')) {
this.config.showExtras = false;
if (!_.isEmpty(this.entities)) {
this.config.entity = [];
_.forEach(this.entities, entity => {
if (!_.isEmpty(entity.value) && !_.includes(this.config.entity, entity.value)) {
this.config.entity.push(entity.value);
}
});
}
if (_.isEqual(this.playTrailer.value, 'Yes')) {
this.config.playTrailer = true;
} else if (_.isEqual(this.playTrailer.value, 'No')) {
this.config.playTrailer = false;
} else if (_.isEqual(this.playTrailer.value, 'Muted')) {
this.config.playTrailer = 'muted';
}
if (_.isEqual(this.showExtras.value, 'Yes')) {
this.config.showExtras = true;
} else if (_.isEqual(this.showExtras.value, 'No')) {
this.config.showExtras = false;
}
if (_.isEqual(this.showSearch.value, 'Yes')) {
this.config.showSearch = true;
} else if (_.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false;
}
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
}
if (_.isEqual(this.showSearch.value, 'Yes')) {
this.config.showSearch = true;
} else if (_.isEqual(this.showSearch.value, 'No')) {
this.config.showSearch = false;
if (!_.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config });
}
this.config.runBefore = this.runBefore.value;
this.config.runAfter = this.runAfter.value;
}
if (!_.isEqual(this.config, originalConfig)) {
this.fireEvent(this, 'config-changed', { config: this.config });
}
};
@ -522,6 +526,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.plexValidSection.style.display = 'block';
}
this.loaded = true;
this.content.appendChild(this.plexValidSection);
};

Loading…
Cancel
Save