Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.map(origin => ({
appModes: store.each(app, ns.acl('mode'), undefined, undefined),
origin
}))
})
.sort((a: any, b: any) => (a.origin.value < b.origin.value ? -1 : 1))
.forEach(
({ appModes, origin }: { appModes: NamedNode[]; origin: NamedNode }) =>
applicationsTable.appendChild(
createApplicationEntry(subject, origin, appModes, updateTable)
)
)
// adding a row for new applications
applicationsTable.appendChild(
createApplicationEntry(subject, null, [ns.acl('Read')], updateTable)
)
return applicationsTable
function updateTable () {
applicationsTable.parentElement!.replaceChild(
createApplicationTable(subject),
applicationsTable
)
}
}
function createApplicationTable (subject: NamedNode) {
const applicationsTable = createElement('table', {
class: 'results'
})
// creating headers
const header = createContainer('tr', [
createText('th', 'Application URL'),
createText('th', 'Access modes'),
createText('th', 'Actions')
])
applicationsTable.appendChild(header)
// creating rows
;(store.each(subject, ns.acl('trustedApp'), undefined, undefined) as any)
.flatMap((app: any) => {
return store
.each(app, ns.acl('origin'), undefined, undefined)
.map(origin => ({
appModes: store.each(app, ns.acl('mode'), undefined, undefined),
origin
}))
})
.sort((a: any, b: any) => (a.origin.value < b.origin.value ? -1 : 1))
.forEach(
({ appModes, origin }: { appModes: NamedNode[]; origin: NamedNode }) =>
applicationsTable.appendChild(
createApplicationEntry(subject, origin, appModes, updateTable)
)
)
.flatMap((app: any) => {
return store
.each(app, ns.acl('origin'), undefined, undefined)
.map(origin => ({
appModes: store.each(app, ns.acl('mode'), undefined, undefined),
origin
}))
})
.sort((a: any, b: any) => (a.origin.value < b.origin.value ? -1 : 1))
.map(origin => ({
appModes: store.each(app, ns.acl('mode'), undefined, undefined),
origin
}))
})
return ['Read', 'Write', 'Append', 'Control'].map(mode => {
const isChecked = appModes.some(
appMode => appMode.value === ns.acl(mode).value
)
return createContainer('label', [
createElement(
'input',
{
type: 'checkbox',
...(isChecked ? { checked: '' } : {}),
value: ns.acl(mode).uri
},
{},
element => formElements.modes.push(element)
),
createText('span', mode)
])
})
}
appMode => appMode.value === ns.acl(mode).value
)