2.0
Juraj Nyíri 3 years ago
parent ab60645c52
commit 0dc051fac1

@ -19659,37 +19659,52 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
} }
this.plexValidSection.appendChild(this.sortOrder); this.plexValidSection.appendChild(this.sortOrder);
const devicesTitle = document.createElement('h2'); let hasUIConfig = true;
devicesTitle.innerHTML = `Devices Configuration`;
devicesTitle.style.lineHeight = '29px';
devicesTitle.style.marginBottom = '0px';
devicesTitle.style.marginTop = '20px';
const addDeviceButton = document.createElement('button');
addDeviceButton.style.float = 'right';
addDeviceButton.style.fontSize = '20px';
addDeviceButton.style.cursor = 'pointer';
addDeviceButton.innerHTML = '+';
addDeviceButton.addEventListener('click', () => {
const entitiesDropdown = createEntitiesDropdown('', this.valueUpdated);
if (entitiesDropdown) {
this.content.appendChild(entitiesDropdown);
}
});
devicesTitle.appendChild(addDeviceButton);
this.plexValidSection.appendChild(devicesTitle);
if (lodash.isString(this.config.entity)) {
this.config.entity = [this.config.entity];
}
if (lodash.isArray(this.config.entity)) { if (lodash.isArray(this.config.entity)) {
// eslint-disable-next-line consistent-return
lodash.forEach(this.config.entity, entity => { lodash.forEach(this.config.entity, entity => {
if (lodash.isString(entity)) { if (lodash.isObjectLike(entity)) {
const entitiesDropdown = createEntitiesDropdown(entity, this.valueUpdated); hasUIConfig = false;
if (entitiesDropdown) { return false;
this.plexValidSection.appendChild(entitiesDropdown);
}
} }
}); });
} }
else if (lodash.isObjectLike(this.config.entity)) {
hasUIConfig = false;
}
if (hasUIConfig) {
const devicesTitle = document.createElement('h2');
devicesTitle.innerHTML = `Devices Configuration`;
devicesTitle.style.lineHeight = '29px';
devicesTitle.style.marginBottom = '0px';
devicesTitle.style.marginTop = '20px';
const addDeviceButton = document.createElement('button');
addDeviceButton.style.float = 'right';
addDeviceButton.style.fontSize = '20px';
addDeviceButton.style.cursor = 'pointer';
addDeviceButton.innerHTML = '+';
addDeviceButton.addEventListener('click', () => {
const entitiesDropdown = createEntitiesDropdown('', this.valueUpdated);
if (entitiesDropdown) {
this.content.appendChild(entitiesDropdown);
}
});
devicesTitle.appendChild(addDeviceButton);
this.plexValidSection.appendChild(devicesTitle);
if (lodash.isString(this.config.entity)) {
this.config.entity = [this.config.entity];
}
if (lodash.isArray(this.config.entity)) {
lodash.forEach(this.config.entity, entity => {
if (lodash.isString(entity)) {
const entitiesDropdown = createEntitiesDropdown(entity, this.valueUpdated);
if (entitiesDropdown) {
this.plexValidSection.appendChild(entitiesDropdown);
}
}
});
}
}
if (!lodash.isEmpty(this.sections)) { if (!lodash.isEmpty(this.sections)) {
lodash.forEach(this.sections, (section) => { lodash.forEach(this.sections, (section) => {
libraryItems.appendChild(addDropdownItem(section.title)); libraryItems.appendChild(addDropdownItem(section.title));

@ -266,39 +266,55 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
this.plexValidSection.appendChild(this.sortOrder); this.plexValidSection.appendChild(this.sortOrder);
const devicesTitle = document.createElement('h2'); let hasUIConfig = true;
devicesTitle.innerHTML = `Devices Configuration`;
devicesTitle.style.lineHeight = '29px';
devicesTitle.style.marginBottom = '0px';
devicesTitle.style.marginTop = '20px';
const addDeviceButton = document.createElement('button');
addDeviceButton.style.float = 'right';
addDeviceButton.style.fontSize = '20px';
addDeviceButton.style.cursor = 'pointer';
addDeviceButton.innerHTML = '+';
addDeviceButton.addEventListener('click', () => {
const entitiesDropdown = createEntitiesDropdown('', this.valueUpdated);
if (entitiesDropdown) {
this.content.appendChild(entitiesDropdown);
}
});
devicesTitle.appendChild(addDeviceButton);
this.plexValidSection.appendChild(devicesTitle);
if (_.isString(this.config.entity)) {
this.config.entity = [this.config.entity];
}
if (_.isArray(this.config.entity)) { if (_.isArray(this.config.entity)) {
// eslint-disable-next-line consistent-return
_.forEach(this.config.entity, entity => { _.forEach(this.config.entity, entity => {
if (_.isString(entity)) { if (_.isObjectLike(entity)) {
const entitiesDropdown = createEntitiesDropdown(entity, this.valueUpdated); hasUIConfig = false;
if (entitiesDropdown) { return false;
this.plexValidSection.appendChild(entitiesDropdown);
}
} }
}); });
} else if (_.isObjectLike(this.config.entity)) {
hasUIConfig = false;
} }
if (hasUIConfig) {
const devicesTitle = document.createElement('h2');
devicesTitle.innerHTML = `Devices Configuration`;
devicesTitle.style.lineHeight = '29px';
devicesTitle.style.marginBottom = '0px';
devicesTitle.style.marginTop = '20px';
const addDeviceButton = document.createElement('button');
addDeviceButton.style.float = 'right';
addDeviceButton.style.fontSize = '20px';
addDeviceButton.style.cursor = 'pointer';
addDeviceButton.innerHTML = '+';
addDeviceButton.addEventListener('click', () => {
const entitiesDropdown = createEntitiesDropdown('', this.valueUpdated);
if (entitiesDropdown) {
this.content.appendChild(entitiesDropdown);
}
});
devicesTitle.appendChild(addDeviceButton);
this.plexValidSection.appendChild(devicesTitle);
if (_.isString(this.config.entity)) {
this.config.entity = [this.config.entity];
}
if (_.isArray(this.config.entity)) {
_.forEach(this.config.entity, entity => {
if (_.isString(entity)) {
const entitiesDropdown = createEntitiesDropdown(entity, this.valueUpdated);
if (entitiesDropdown) {
this.plexValidSection.appendChild(entitiesDropdown);
}
}
});
}
}
if (!_.isEmpty(this.sections)) { if (!_.isEmpty(this.sections)) {
_.forEach(this.sections, (section: Record<string, any>) => { _.forEach(this.sections, (section: Record<string, any>) => {
libraryItems.appendChild(addDropdownItem(section.title)); libraryItems.appendChild(addDropdownItem(section.title));

Loading…
Cancel
Save