Frontend created and rewritten a few times, with some backend fixes #1
|
@ -45,21 +45,28 @@ export const useDocumentStore = defineStore({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setActualDocument(location: string){
|
setActualDocument(location: string){
|
||||||
this.loading = true;
|
|
||||||
let data = this.root
|
|
||||||
const dataMapped = [];
|
|
||||||
const locations = location.split('/').slice(1)
|
|
||||||
// Get data target location
|
|
||||||
locations.forEach(location => {
|
|
||||||
location = decodeURIComponent(location)
|
location = decodeURIComponent(location)
|
||||||
if(data && data.dir){
|
this.loading = true
|
||||||
for (const key in data.dir) {
|
let data = this.root
|
||||||
if(key === location) data = data.dir[key]
|
const actualDirArr = []
|
||||||
|
try {
|
||||||
|
// Navigate to target folder
|
||||||
|
for (const dirname of location.split('/').slice(1)) {
|
||||||
|
if (!dirname) continue
|
||||||
|
actualDirArr.push(dirname)
|
||||||
|
data = data.dir[dirname]
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Cannot show requested folder", location, actualDirArr.join('/'), error)
|
||||||
|
}
|
||||||
|
if (data.dir === undefined) {
|
||||||
|
// Target folder not available
|
||||||
|
this.document = []
|
||||||
|
this.loading = false // ???
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
// Transform data
|
// Transform data
|
||||||
|
const dataMapped = []
|
||||||
for (const [name, attr] of Object.entries(data.dir)) {
|
for (const [name, attr] of Object.entries(data.dir)) {
|
||||||
const {id, size, mtime, dir} = attr
|
const {id, size, mtime, dir} = attr
|
||||||
const element: Document = {
|
const element: Document = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user