|
|
|
@ -80,7 +80,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
download() {
|
|
|
|
download() {
|
|
|
|
const text = localStorage.getItem(this.path)
|
|
|
|
const text = this.storage.getItem(this.path)
|
|
|
|
const sp = this.path.split('/')
|
|
|
|
const sp = this.path.split('/')
|
|
|
|
const filename = sp[sp.length - 1]
|
|
|
|
const filename = sp[sp.length - 1]
|
|
|
|
const el = document.createElement('a')
|
|
|
|
const el = document.createElement('a')
|
|
|
|
@ -111,7 +111,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
bGroup.addPrimary(this.text.rename, () => {
|
|
|
|
bGroup.addPrimary(this.text.rename, () => {
|
|
|
|
const newPath = input.value
|
|
|
|
const newPath = input.value
|
|
|
|
const v = localStorage.getItem(newPath)
|
|
|
|
const v = this.storage.getItem(newPath)
|
|
|
|
if (v !== null || newPath === this.path) {
|
|
|
|
if (v !== null || newPath === this.path) {
|
|
|
|
if (!errorEl) {
|
|
|
|
if (!errorEl) {
|
|
|
|
errorEl = document.createElement('p')
|
|
|
|
errorEl = document.createElement('p')
|
|
|
|
@ -124,10 +124,10 @@ export class PageActions extends HTMLElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const sKeyOld = 'settings/page:' + this.path
|
|
|
|
const sKeyOld = 'settings/page:' + this.path
|
|
|
|
const sKeyNew = 'settings/page:' + newPath
|
|
|
|
const sKeyNew = 'settings/page:' + newPath
|
|
|
|
const settingsJson = localStorage.getItem(sKeyOld)
|
|
|
|
const settingsJson = this.storage.getItem(sKeyOld)
|
|
|
|
if (settingsJson ?? true === true) {
|
|
|
|
if (settingsJson ?? true === true) {
|
|
|
|
localStorage.setItem(sKeyNew, settingsJson)
|
|
|
|
this.storage.setItem(sKeyNew, settingsJson)
|
|
|
|
localStorage.removeItem(sKeyOld)
|
|
|
|
this.storage.removeItem(sKeyOld)
|
|
|
|
let settingsData
|
|
|
|
let settingsData
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
settingsData = JSON.parse(settingsJson)
|
|
|
|
settingsData = JSON.parse(settingsJson)
|
|
|
|
@ -145,13 +145,13 @@ export class PageActions extends HTMLElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem(sKeyNew)
|
|
|
|
this.storage.removeItem(sKeyNew)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
localStorage.setItem(
|
|
|
|
this.storage.setItem(
|
|
|
|
newPath,
|
|
|
|
newPath,
|
|
|
|
localStorage.getItem(this.path)
|
|
|
|
this.storage.getItem(this.path)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
localStorage.removeItem(this.path)
|
|
|
|
this.storage.removeItem(this.path)
|
|
|
|
dialog.close()
|
|
|
|
dialog.close()
|
|
|
|
location.hash = newPath
|
|
|
|
location.hash = newPath
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -178,7 +178,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
const btnText = this.text.duplicate
|
|
|
|
const btnText = this.text.duplicate
|
|
|
|
bGroup.addPrimary(btnText, () => {
|
|
|
|
bGroup.addPrimary(btnText, () => {
|
|
|
|
const newPath = input.value
|
|
|
|
const newPath = input.value
|
|
|
|
const v = localStorage.getItem(newPath)
|
|
|
|
const v = this.storage.getItem(newPath)
|
|
|
|
if (v !== null || newPath === this.path) {
|
|
|
|
if (v !== null || newPath === this.path) {
|
|
|
|
if (!errorEl) {
|
|
|
|
if (!errorEl) {
|
|
|
|
errorEl = document.createElement('p')
|
|
|
|
errorEl = document.createElement('p')
|
|
|
|
@ -189,13 +189,13 @@ export class PageActions extends HTMLElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
localStorage.setItem(
|
|
|
|
this.storage.setItem(
|
|
|
|
newPath,
|
|
|
|
newPath,
|
|
|
|
localStorage.getItem(this.path)
|
|
|
|
this.storage.getItem(this.path)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
localStorage.setItem(
|
|
|
|
this.storage.setItem(
|
|
|
|
'settings/page:' + newPath,
|
|
|
|
'settings/page:' + newPath,
|
|
|
|
localStorage.getItem(this.path) ?? '{}'
|
|
|
|
this.storage.getItem(this.path) ?? '{}'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
dialog.close()
|
|
|
|
dialog.close()
|
|
|
|
location.hash = newPath
|
|
|
|
location.hash = newPath
|
|
|
|
@ -222,8 +222,8 @@ export class PageActions extends HTMLElement {
|
|
|
|
'm-forms-button-group'
|
|
|
|
'm-forms-button-group'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
bGroup.addPrimary(this.text.delete_, () => {
|
|
|
|
bGroup.addPrimary(this.text.delete_, () => {
|
|
|
|
localStorage.removeItem(this.path)
|
|
|
|
this.storage.removeItem(this.path)
|
|
|
|
localStorage.removeItem(
|
|
|
|
this.storage.removeItem(
|
|
|
|
'settings/page:' + this.path
|
|
|
|
'settings/page:' + this.path
|
|
|
|
)
|
|
|
|
)
|
|
|
|
location.hash = '/'
|
|
|
|
location.hash = '/'
|
|
|
|
@ -246,6 +246,9 @@ export class PageActions extends HTMLElement {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
settingsEl.cspProfiles = this.cspProfiles
|
|
|
|
settingsEl.cspProfiles = this.cspProfiles
|
|
|
|
settingsEl.path = this.path
|
|
|
|
settingsEl.path = this.path
|
|
|
|
|
|
|
|
settingsEl.checkExists = path => (
|
|
|
|
|
|
|
|
this.storage.getItem(path) !== null
|
|
|
|
|
|
|
|
)
|
|
|
|
settingsEl.data = this.page.settings
|
|
|
|
settingsEl.data = this.page.settings
|
|
|
|
const h = document.createElement('h2')
|
|
|
|
const h = document.createElement('h2')
|
|
|
|
h.innerText = this.text.settings
|
|
|
|
h.innerText = this.text.settings
|
|
|
|
@ -283,7 +286,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for (const [path, access] of selfEntries) {
|
|
|
|
for (const [path, access] of selfEntries) {
|
|
|
|
const key = 'settings/page:' + path
|
|
|
|
const key = 'settings/page:' + path
|
|
|
|
let val = localStorage.getItem(key)
|
|
|
|
let val = this.storage.getItem(key)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (val !== null) {
|
|
|
|
if (val !== null) {
|
|
|
|
val = JSON.parse(val)
|
|
|
|
val = JSON.parse(val)
|
|
|
|
@ -297,7 +300,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
data.connections[otherDir] ?? {}
|
|
|
|
data.connections[otherDir] ?? {}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
data.connections[otherDir][this.path] = access
|
|
|
|
data.connections[otherDir][this.path] = access
|
|
|
|
localStorage.setItem(
|
|
|
|
this.storage.setItem(
|
|
|
|
key, JSON.stringify(data)
|
|
|
|
key, JSON.stringify(data)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -311,7 +314,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for (const [path, access] of selfEntries) {
|
|
|
|
for (const [path, access] of selfEntries) {
|
|
|
|
const key = 'settings/page:' + path
|
|
|
|
const key = 'settings/page:' + path
|
|
|
|
let val = localStorage.getItem(key)
|
|
|
|
let val = this.storage.getItem(key)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (val !== null) {
|
|
|
|
if (val !== null) {
|
|
|
|
val = JSON.parse(val)
|
|
|
|
val = JSON.parse(val)
|
|
|
|
@ -327,7 +330,7 @@ export class PageActions extends HTMLElement {
|
|
|
|
const accessValue = data.connections[otherDir][oldPath]
|
|
|
|
const accessValue = data.connections[otherDir][oldPath]
|
|
|
|
data.connections[otherDir][newPath] = accessValue
|
|
|
|
data.connections[otherDir][newPath] = accessValue
|
|
|
|
data.connections[otherDir][oldPath] = undefined
|
|
|
|
data.connections[otherDir][oldPath] = undefined
|
|
|
|
localStorage.setItem(
|
|
|
|
this.storage.setItem(
|
|
|
|
key, JSON.stringify(data)
|
|
|
|
key, JSON.stringify(data)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|