Add: Force user to use https in config UI if Home Assistant accessed through https

pull/30/head 2.0.4
Juraj Nyíri 3 years ago
parent 80210945fd
commit e49f43faf7

@ -19621,7 +19621,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.content.appendChild(plexTitle);
this.protocol.innerHTML = '';
const protocolItems = document.createElement('paper-listbox');
// eslint-disable-next-line no-restricted-globals
const pageProtocol = location.protocol;
if (lodash.isEqual(pageProtocol, 'http:')) {
protocolItems.appendChild(addDropdownItem('http'));
}
protocolItems.appendChild(addDropdownItem('https'));
protocolItems.slot = 'dropdown-content';
this.protocol.label = 'Plex Protocol';
@ -19629,8 +19633,13 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.protocol.style.width = '100%';
this.protocol.addEventListener('value-changed', this.valueUpdated);
if (lodash.isEmpty(this.config.protocol)) {
if (lodash.isEqual(pageProtocol, 'http:')) {
this.protocol.value = 'http';
}
else {
this.protocol.value = 'https';
}
}
else {
this.protocol.value = this.config.protocol;
}
@ -19945,12 +19954,17 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
else {
this.plexPort = false;
}
// eslint-disable-next-line no-restricted-globals
const pageProtocol = location.protocol;
if (config.protocol) {
this.plexProtocol = config.protocol;
}
else {
else if (lodash.isEqual(pageProtocol, 'http:')) {
this.config.protocol = 'http';
}
else {
this.config.protocol = 'https';
}
if (!config.sort) {
this.config.sort = 'titleSort:asc';
}

@ -219,7 +219,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.protocol.innerHTML = '';
const protocolItems: any = document.createElement('paper-listbox');
// eslint-disable-next-line no-restricted-globals
const pageProtocol = location.protocol;
if (_.isEqual(pageProtocol, 'http:')) {
protocolItems.appendChild(addDropdownItem('http'));
}
protocolItems.appendChild(addDropdownItem('https'));
protocolItems.slot = 'dropdown-content';
this.protocol.label = 'Plex Protocol';
@ -227,7 +231,11 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.protocol.style.width = '100%';
this.protocol.addEventListener('value-changed', this.valueUpdated);
if (_.isEmpty(this.config.protocol)) {
if (_.isEqual(pageProtocol, 'http:')) {
this.protocol.value = 'http';
} else {
this.protocol.value = 'https';
}
} else {
this.protocol.value = this.config.protocol;
}
@ -556,10 +564,14 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.plexPort = false;
}
// eslint-disable-next-line no-restricted-globals
const pageProtocol = location.protocol;
if (config.protocol) {
this.plexProtocol = config.protocol;
} else {
} else if (_.isEqual(pageProtocol, 'http:')) {
this.config.protocol = 'http';
} else {
this.config.protocol = 'https';
}
if (!config.sort) {

Loading…
Cancel
Save