Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
})
})
}
const isDocument = subject.uri && !subject.uri.includes('#')
if (isDocument) {
const controls = div.appendChild(dom.createElement('table'))
controls.style.width = '100%'
controls.style.margin = '1em'
const controlRow = controls.appendChild(dom.createElement('tr'))
const deleteCell = controlRow.appendChild(dom.createElement('td'))
const isFolder =
(subject.uri && subject.uri.endsWith('/')) ||
store.holds(subject, ns.rdf('type'), ns.ldp('Container'))
const noun = isFolder ? 'folder' : 'file'
if (!isProtectedUri(subject)) {
console.log(subject)
var deleteButton = widgets.deleteButtonWithCheck(
dom,
deleteCell,
noun,
function () {
if (
!confirm(
`Are you sure you want to delete ${subject}? This cannot be undone.`
)
) {
return
}
// @@ TODO Remove casing of store.fetcher
)
})
})
}
const isDocument = subject.uri && !subject.uri.includes('#')
if (isDocument) {
const controls = div.appendChild(dom.createElement('table'))
controls.style.width = '100%'
controls.style.margin = '1em'
const controlRow = controls.appendChild(dom.createElement('tr'))
const deleteCell = controlRow.appendChild(dom.createElement('td'))
const isFolder =
(subject.uri && subject.uri.endsWith('/')) ||
store.holds(subject, ns.rdf('type'), ns.ldp('Container'))
const noun = isFolder ? 'folder' : 'file'
if (!isProtectedUri(subject)) {
console.log(subject)
var deleteButton = widgets.deleteButtonWithCheck(
dom,
deleteCell,
noun,
function () {
if (
!confirm(
`Are you sure you want to delete ${subject}? This cannot be undone.`
)
) {
return
}
// @@ TODO Remove casing of store.fetcher
const promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file as NamedNode)
} else {
console.log('deleteRecursive leaf file: ' + file)
return fetcher.webOperation('DELETE', (file as NamedNode).uri)
}
})
Promise.all(promises).then(
fetcher.load(folder).then(function () {
const promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file as NamedNode)
} else {
console.log('deleteRecursive leaf file: ' + file)
return fetcher.webOperation('DELETE', (file as NamedNode).uri)
}
})
Promise.all(promises).then(
() => {
console.log('deleteRecursive empty folder: ' + folder)
fetcher
.webOperation('DELETE', folder.uri)
.then(() => {
console.log('Deleted Ok: ' + folder)
resolve()
})
const promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file as NamedNode)
} else {
console.log('deleteRecursive leaf file: ' + file)
return fetcher.webOperation('DELETE', (file as NamedNode).uri)
}
})
Promise.all(promises).then(
fetcher.load(folder).then(function () {
const promises = kb.each(folder, ns.ldp('contains')).map(file => {
if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
return deleteRecursive(kb, file as NamedNode)
} else {
console.log('deleteRecursive leaf file: ' + file)
return fetcher.webOperation('DELETE', (file as NamedNode).uri)
}
})
Promise.all(promises).then(
() => {
console.log('deleteRecursive empty folder: ' + folder)
fetcher
.webOperation('DELETE', folder.uri)
.then(() => {
console.log('Deleted Ok: ' + folder)
resolve()
})