Merge pull request 'add CodeMirror and Template options' (#6) from codemirror-option into pages

Reviewed-on: https://codeberg.org/macchiato/settings/pulls/6
pages
bat 3 years ago
commit e33b7195b9

@ -1,11 +1,17 @@
export class PageSettings extends HTMLElement { export class PageSettings extends HTMLElement {
textEn = { textEn = {
general: 'General',
template: 'Template',
codeMirror: 'CodeMirror',
outbound: 'Outbound connections', outbound: 'Outbound connections',
inbound: 'Inbound connections', inbound: 'Inbound connections',
netAccess: 'Direct network access (CSP)', netAccess: 'Direct network access (CSP)',
} }
textEs = { textEs = {
general: 'General',
template: 'Template',
codeMirror: 'CodeMirror',
outbound: 'Conexiones salientes', outbound: 'Conexiones salientes',
inbound: 'Conexiones entrantes', inbound: 'Conexiones entrantes',
netAccess: 'Acceso directo a la red (CSP)', netAccess: 'Acceso directo a la red (CSP)',
@ -15,6 +21,26 @@ export class PageSettings extends HTMLElement {
super() super()
this.attachShadow({mode: 'open'}) this.attachShadow({mode: 'open'})
this.language = navigator.language this.language = navigator.language
const generalHeading = document.createElement('div')
generalHeading.classList.add('heading')
generalHeading.innerText = this.text.general
const templateLabel = document.createElement('label')
templateLabel.innerText = this.text.template
this.templateEl = document.createElement('input')
this.templateEl.type = 'checkbox'
templateLabel.prepend(this.templateEl)
const codeMirrorLabel = document.createElement('label')
codeMirrorLabel.innerText = this.text.codeMirror
this.codeMirrorEl = document.createElement('input')
this.codeMirrorEl.type = 'checkbox'
codeMirrorLabel.prepend(this.codeMirrorEl)
const generalDiv = document.createElement('div')
generalDiv.append(templateLabel, codeMirrorLabel)
const outboundHeading = document.createElement('div') const outboundHeading = document.createElement('div')
outboundHeading.classList.add('heading') outboundHeading.classList.add('heading')
outboundHeading.innerText = this.text.outbound outboundHeading.innerText = this.text.outbound
@ -36,6 +62,8 @@ export class PageSettings extends HTMLElement {
'm-settings-network-settings' 'm-settings-network-settings'
) )
this.shadowRoot.append( this.shadowRoot.append(
generalHeading,
generalDiv,
outboundHeading, outboundHeading,
this.outbound, this.outbound,
inboundHeading, inboundHeading,
@ -79,10 +107,14 @@ export class PageSettings extends HTMLElement {
outbound: this.outbound.data, outbound: this.outbound.data,
inbound: this.inbound.data, inbound: this.inbound.data,
}, },
template: this.templateEl.checked,
codeMirror: this.codeMirrorEl.checked,
} }
} }
set data(value) { set data(value) {
this.templateEl.checked = !!value.template
this.codeMirrorEl.checked = !!value.codeMirror
this.outbound.data = value.connections?.outbound || {} this.outbound.data = value.connections?.outbound || {}
this.inbound.data = value.connections?.inbound || {} this.inbound.data = value.connections?.inbound || {}
this.network.data = { this.network.data = {

Loading…
Cancel
Save