fix: file manager load (2)

pull/6078/head
Nicolas Giard 2 years ago
parent 18e80a9525
commit 5c1b9b667a
No known key found for this signature in database
GPG Key ID: 85061B8F9D55B7C8

@ -1,11 +0,0 @@
{
"baseUrl": "http://localhost:3000",
"projectId": "r7qxah",
"fixturesFolder": false,
"integrationFolder": "dev/cypress/integration",
"pluginsFile": "dev/cypress/plugins/index.js",
"screenshotsFolder": "dev/cypress/screenshots",
"supportFile": "dev/cypress/support/index.js",
"videosFolder": "dev/cypress/videos",
"numTestsKeptInMemory": 1
}

@ -1,22 +0,0 @@
{
"folders": [
{
"name": "server",
"path": "server"
},
{
"name": "ux",
"path": "ux"
},
{
"path": "."
}
],
"settings": {
"i18n-ally.localesPaths": [
"src/i18n",
"src/i18n/locales"
],
"i18n-ally.keystyle": "nested"
}
}

@ -40,6 +40,7 @@ router.get('/_site/:siteId?/:resource', async (req, res, next) => {
if (!site) { if (!site) {
return res.status(404).send('Site Not Found') return res.status(404).send('Site Not Found')
} }
console.info(req.params)
switch (req.params.resource) { switch (req.params.resource) {
case 'logo': { case 'logo': {
if (site.config.assets.logo) { if (site.config.assets.logo) {
@ -74,6 +75,35 @@ router.get('/_site/:siteId?/:resource', async (req, res, next) => {
} }
}) })
/**
* Asset Thumbnails / Download
*/
router.get('/_asset/:siteId/:mode/*', async (req, res, next) => {
const site = req.params.siteId ? WIKI.sites[req.params.siteId] : await WIKI.db.sites.getSiteByHostname({ hostname: req.hostname })
if (!site) {
return res.status(404).send('Site Not Found')
}
const filePath = req.params[0]
console.info(filePath)
switch (req.params.mode) {
case 'thumb': {
try {
} catch (err) {
}
break
}
case 'download': {
break
}
default: {
return res.status(404).send('Invalid Site Resource')
}
}
return res.send('BOB').end()
})
/** /**
* New v3 vue app * New v3 vue app
*/ */

@ -250,10 +250,23 @@ q-layout.fileman(view='hHh lpR lFr', container)
q-item-section(side) q-item-section(side)
q-icon(name='las la-eye', color='primary') q-icon(name='las la-eye', color='primary')
q-item-section View q-item-section View
template(v-if='item.type === `asset` && item.imageEdit')
q-item(clickable)
q-item-section(side)
q-icon(name='las la-edit', color='orange')
q-item-section Edit Image...
q-item(clickable)
q-item-section(side)
q-icon(name='las la-crop', color='orange')
q-item-section Resize Image...
q-item(clickable, v-if='item.type !== `folder`', @click='copyItemURL(item)') q-item(clickable, v-if='item.type !== `folder`', @click='copyItemURL(item)')
q-item-section(side) q-item-section(side)
q-icon(name='las la-clipboard', color='primary') q-icon(name='las la-clipboard', color='primary')
q-item-section Copy URL q-item-section Copy URL
q-item(clickable, v-if='item.type !== `folder`', @click='')
q-item-section(side)
q-icon(name='las la-download', color='primary')
q-item-section Download
q-item(clickable) q-item(clickable)
q-item-section(side) q-item-section(side)
q-icon(name='las la-copy', color='teal') q-icon(name='las la-copy', color='teal')
@ -411,6 +424,7 @@ const files = computed(() => {
case 'asset': { case 'asset': {
f.icon = fileTypes[f.fileExt]?.icon ?? '' f.icon = fileTypes[f.fileExt]?.icon ?? ''
f.side = filesize(f.fileSize, { round: 0 }) f.side = filesize(f.fileSize, { round: 0 })
f.imageEdit = fileTypes[f.fileExt]?.imageEdit
if (fileTypes[f.fileExt]) { if (fileTypes[f.fileExt]) {
f.caption = t(`fileman.${f.fileExt}FileType`) f.caption = t(`fileman.${f.fileExt}FileType`)
} else { } else {
@ -489,8 +503,8 @@ function close () {
siteStore.overlay = null siteStore.overlay = null
} }
async function treeLazyLoad (nodeId, { done, fail }) { async function treeLazyLoad (nodeId, isCurrent, { done, fail }) {
await loadTree({ parentId: nodeId, types: ['folder'] }) await loadTree({ parentId: nodeId, types: isCurrent ? null : ['folder'] })
done() done()
} }
@ -792,6 +806,7 @@ async function uploadNewFiles () {
} }
} }
state.uploadPercentage = 100 state.uploadPercentage = 100
loadTree({ parentId: state.currentFolderId })
$q.notify({ $q.notify({
type: 'positive', type: 'positive',
message: t('fileman.uploadSuccess') message: t('fileman.uploadSuccess')
@ -859,7 +874,8 @@ async function copyItemURL (item) {
break break
} }
case 'asset': { case 'asset': {
// TODO: Copy asset URL to clibpard const assetPath = item.folderPath ? `${item.folderPath}/${item.fileName}` : item.fileName
await navigator.clipboard.writeText(`${window.location.origin}/${assetPath}`)
break break
} }
default: { default: {

@ -67,7 +67,6 @@ const $q = useQuasar()
const roots = inject('roots') const roots = inject('roots')
const nodes = inject('nodes') const nodes = inject('nodes')
const selection = inject('selection') const selection = inject('selection')
const emitContextAction = inject('emitContextAction')
const contextActionList = inject('contextActionList') const contextActionList = inject('contextActionList')
// COMPUTED // COMPUTED
@ -103,8 +102,4 @@ function setRoot () {
selection.value = null selection.value = null
} }
function createRootFolder () {
emitContextAction(null, 'newFolder')
}
</script> </script>

@ -108,18 +108,14 @@ const selection = computed({
// METHODS // METHODS
function emitLazyLoad (nodeId, clb) { function emitLazyLoad (nodeId, isCurrent, clb) {
if (props.useLazyLoad) { if (props.useLazyLoad) {
emit('lazyLoad', nodeId, clb) emit('lazyLoad', nodeId, isCurrent, clb)
} else { } else {
clb.done() clb.done()
} }
} }
function emitContextAction (nodeId, action) {
emit('contextAction', nodeId, action)
}
function setOpened (nodeId) { function setOpened (nodeId) {
state.opened[nodeId] = true state.opened[nodeId] = true
} }
@ -142,7 +138,6 @@ provide('opened', state.opened)
provide('displayMode', toRef(props, 'displayMode')) provide('displayMode', toRef(props, 'displayMode'))
provide('selection', selection) provide('selection', selection)
provide('emitLazyLoad', emitLazyLoad) provide('emitLazyLoad', emitLazyLoad)
provide('emitContextAction', emitContextAction)
// EXPOSE // EXPOSE

@ -5,7 +5,7 @@ li.treeview-node
q-icon( q-icon(
:name='icon' :name='icon'
size='sm' size='sm'
@click.stop='hasChildren ? toggleNode() : openNode()' @click.stop='toggleNode()'
) )
.treeview-label-text {{displayMode === 'path' ? node.fileName : node.title}} .treeview-label-text {{displayMode === 'path' ? node.fileName : node.title}}
q-spinner.q-mr-xs( q-spinner.q-mr-xs(
@ -82,7 +82,6 @@ const opened = inject('opened')
const displayMode = inject('displayMode') const displayMode = inject('displayMode')
const selection = inject('selection') const selection = inject('selection')
const emitLazyLoad = inject('emitLazyLoad') const emitLazyLoad = inject('emitLazyLoad')
const emitContextAction = inject('emitContextAction')
const contextActionList = inject('contextActionList') const contextActionList = inject('contextActionList')
// DATA // DATA
@ -113,13 +112,13 @@ const isActive = computed(() => {
// METHODS // METHODS
async function toggleNode () { async function toggleNode (isCurrent = false) {
opened[props.node.id] = !(opened[props.node.id] === true) opened[props.node.id] = !(opened[props.node.id] === true)
if (opened[props.node.id] && !loaded[props.node.id]) { if (opened[props.node.id] && !loaded[props.node.id]) {
state.isLoading = true state.isLoading = true
await Promise.race([ await Promise.race([
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
emitLazyLoad(props.node.id, { done: resolve, fail: reject }) emitLazyLoad(props.node.id, isCurrent, { done: resolve, fail: reject })
}), }),
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
setTimeout(() => reject(new Error('Async tree loading timeout')), 30000) setTimeout(() => reject(new Error('Async tree loading timeout')), 30000)
@ -135,11 +134,7 @@ function openNode () {
if (selection.value !== props.node.id && opened[props.node.id]) { if (selection.value !== props.node.id && opened[props.node.id]) {
return return
} }
toggleNode() toggleNode(true)
}
function contextAction (action) {
emitContextAction(props.node.id, action)
} }
</script> </script>

@ -69,10 +69,12 @@ export default {
icon: 'img:/_assets/icons/color-cd.svg' icon: 'img:/_assets/icons/color-cd.svg'
}, },
jpg: { jpg: {
icon: 'img:/_assets/icons/color-jpg.svg' icon: 'img:/_assets/icons/color-jpg.svg',
imageEdit: true
}, },
jpeg: { jpeg: {
icon: 'img:/_assets/icons/color-jpg.svg' icon: 'img:/_assets/icons/color-jpg.svg',
imageEdit: true
}, },
json: { json: {
icon: 'img:/_assets/icons/color-json.svg' icon: 'img:/_assets/icons/color-json.svg'
@ -111,7 +113,8 @@ export default {
icon: 'img:/_assets/icons/color-pdf.svg' icon: 'img:/_assets/icons/color-pdf.svg'
}, },
png: { png: {
icon: 'img:/_assets/icons/color-png.svg' icon: 'img:/_assets/icons/color-png.svg',
imageEdit: true
}, },
pptx: { pptx: {
icon: 'img:/_assets/icons/color-ppt.svg' icon: 'img:/_assets/icons/color-ppt.svg'

Loading…
Cancel
Save