Added check box for '\''show hidden files'\'' and hard coded hidden files pruning from the file api results

This commit is contained in:
Tiger Nie 2020-09-17 00:45:03 +08:00
parent 1529e796df
commit a361fcda60

View File

@ -9,6 +9,12 @@
<span class="chevron"><i class="material-icons">keyboard_arrow_right</i></span>
<router-link :to="link.url">{{ link.name }}</router-link>
</span>
<span style="margin-left:auto;">
<input type="checkbox">
Show hidden files
</span>
</div>
<div v-if="error">
@ -40,6 +46,27 @@ function clean (path) {
return path.endsWith('/') ? path.slice(0, -1) : path
}
// pruneHiddenFiles removes files that start
// with a dot and update numDirs and numFiles
function pruneHiddenFiles(data) {
let numDirs = 0
let numFiles = 0
data.items = data.items.filter((item) => {
if (item.name[0] == ".") {
return false
}
if (item.isDir) {
numDirs++
} else {
numFiles++
}
return true
})
data.numDirs = numDirs
data.numFiles = numFiles
return data
}
export default {
name: 'files',
components: {
@ -145,12 +172,17 @@ export default {
if (url[0] !== '/') url = '/' + url
try {
const res = await api.fetch(url)
let res = await api.fetch(url)
if (clean(res.path) !== clean(`/${this.$route.params.pathMatch}`)) {
return
}
let showHiddenFiles = false
if (!showHiddenFiles) {
res = pruneHiddenFiles(res)
}
this.$store.commit('updateRequest', res)
document.title = res.name
} catch (e) {