export class PageSettings extends HTMLElement { textEn = { outbound: 'Outbound connections', inbound: 'Inbound connections', netAccess: 'Direct network access (CSP)', } textEs = { outbound: 'Conexiones salientes', inbound: 'Conexiones entrantes', netAccess: 'Acceso directo a la red (CSP)', } constructor() { super() this.attachShadow({mode: 'open'}) this.language = navigator.language const outboundHeading = document.createElement('div') outboundHeading.classList.add('heading') outboundHeading.innerText = this.text.outbound this.outbound = document.createElement( 'm-settings-connections' ) this.outbound.type = 'outbound' const inboundHeading = document.createElement('div') inboundHeading.classList.add('heading') inboundHeading.innerText = this.text.inbound this.inbound = document.createElement( 'm-settings-connections' ) this.inbound.type = 'inbound' const netSelectHeading = document.createElement('div') netSelectHeading.classList.add('heading') netSelectHeading.innerText = this.text.netAccess this.network = document.createElement( 'm-settings-network-settings' ) this.shadowRoot.append( outboundHeading, this.outbound, inboundHeading, this.inbound, netSelectHeading, this.network, ) } connectedCallback() { const style = document.createElement('style') style.textContent = ` :host { max-height: 55vh; display: flex; flex-direction: column; align-items: stretch; overflow-y: auto; } * { padding-left: 10px; } div.heading { display: flex; flex-direction: row; justify-content: flex-start; background: #f2dbd8; padding: 3px; margin-bottom: 10px; margin-top: 10px; font-weight: bold; } ` this.shadowRoot.append(style) } get data() { return { ...this.network.data, connections: { outbound: this.outbound.data, inbound: this.inbound.data, }, } } set data(value) { this.outbound.data = value.connections?.outbound || {} this.inbound.data = value.connections?.inbound || {} this.network.data = { networkAccess: value.networkAccess } } set path(value) { this._path = value this.outbound.path = value this.inbound.path = value } get path() { return this._path } set cspProfiles(value) { this.network.cspProfiles = value } get language() { return this._language } set language(language) { this._language = language this.text = this.langEs ? this.textEs : this.textEn } get langEs() { return /^es\b/.test(this.language) } get lang() { return this.language.split('-')[0] } }