mirror of
https://github.com/filegator/filegator.git
synced 2025-08-01 23:00:19 +02:00
add a way to hide certain files and folders (#169)
* add a way to hide certain files and folders (#76) * move file/folder filter to front-end * add checkbox to show all files/folders and remove debug outputs * spaces, quotes and no-useless-escape * improve wording
This commit is contained in:
@@ -19,6 +19,7 @@ return [
|
|||||||
'editable' => ['.txt', '.css', '.js', '.ts', '.html', '.php', '.json', '.md'],
|
'editable' => ['.txt', '.css', '.js', '.ts', '.html', '.php', '.json', '.md'],
|
||||||
'date_format' => 'YY/MM/DD hh:mm:ss', // see: https://momentjs.com/docs/#/displaying/format/
|
'date_format' => 'YY/MM/DD hh:mm:ss', // see: https://momentjs.com/docs/#/displaying/format/
|
||||||
'guest_redirection' => '', // useful for external auth adapters
|
'guest_redirection' => '', // useful for external auth adapters
|
||||||
|
'filter_entries' => [],
|
||||||
],
|
],
|
||||||
|
|
||||||
'services' => [
|
'services' => [
|
||||||
|
@@ -144,11 +144,17 @@
|
|||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
</b-table-column>
|
</b-table-column>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template slot="bottom-left">
|
|
||||||
<span>{{ lang('Selected', checked.length, totalCount) }}</span>
|
|
||||||
</template>
|
|
||||||
</b-table>
|
</b-table>
|
||||||
|
|
||||||
|
<section class="is-flex is-justify-between">
|
||||||
|
<div>
|
||||||
|
<span>{{ lang('Selected', checked.length, totalCount) }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="(showAllEntries || hasFilteredEntries) ">
|
||||||
|
<input type="checkbox" id="checkbox" v-model="showAllEntries" @click="loadFiles">
|
||||||
|
<label for="checkbox"> {{ lang('Show hidden') }}</label>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -181,6 +187,8 @@ export default {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
defaultSort: ['data.name', 'asc'],
|
defaultSort: ['data.name', 'asc'],
|
||||||
files: [],
|
files: [],
|
||||||
|
hasFilteredEntries: false,
|
||||||
|
showAllEntries: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -216,6 +224,7 @@ export default {
|
|||||||
to: to.query.cd
|
to: to.query.cd
|
||||||
})
|
})
|
||||||
.then(ret => {
|
.then(ret => {
|
||||||
|
ret.files = this.filterEntries(ret.files)
|
||||||
this.$store.commit('setCwd', {
|
this.$store.commit('setCwd', {
|
||||||
content: ret.files,
|
content: ret.files,
|
||||||
location: ret.location,
|
location: ret.location,
|
||||||
@@ -234,11 +243,45 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
filterEntries(files){
|
||||||
|
var filter_entries = this.$store.state.config.filter_entries
|
||||||
|
this.hasFilteredEntries = false
|
||||||
|
if (!this.showAllEntries && typeof filter_entries !== 'undefined' && filter_entries.length > 0){
|
||||||
|
let filteredFiles = []
|
||||||
|
_.forEach(files, (file) => {
|
||||||
|
let filterContinue = false
|
||||||
|
_.forEach(filter_entries, (ffilter_Entry) => {
|
||||||
|
if (typeof ffilter_Entry !== 'undefined' && ffilter_Entry.length > 0){
|
||||||
|
let filter_Entry = ffilter_Entry
|
||||||
|
let filterEntry_type = filter_Entry.endsWith('/')? 'dir':'file'
|
||||||
|
filter_Entry = filter_Entry.replace(/\/$/, '')
|
||||||
|
let filterEntry_isFullPath = filter_Entry.startsWith('/')
|
||||||
|
let filterEntry_tmpName = filterEntry_isFullPath? '/'+file.path : file.name
|
||||||
|
filter_Entry = filterEntry_isFullPath? '/'+filter_Entry : filter_Entry
|
||||||
|
filter_Entry = filter_Entry.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.$&')
|
||||||
|
let thisRegex = new RegExp('^'+filter_Entry+'$', 'iu')
|
||||||
|
if(file.type == filterEntry_type && thisRegex.test(filterEntry_tmpName))
|
||||||
|
{
|
||||||
|
filterContinue = true
|
||||||
|
this.hasFilteredEntries = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(!filterContinue){
|
||||||
|
filteredFiles.push(file)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return filteredFiles
|
||||||
|
}
|
||||||
|
return files
|
||||||
|
},
|
||||||
loadFiles() {
|
loadFiles() {
|
||||||
api.getDir({
|
api.getDir({
|
||||||
to: '',
|
to: '',
|
||||||
})
|
})
|
||||||
.then(ret => {
|
.then(ret => {
|
||||||
|
ret.files = this.filterEntries(ret.files)
|
||||||
this.$store.commit('setCwd', {
|
this.$store.commit('setCwd', {
|
||||||
content: ret.files,
|
content: ret.files,
|
||||||
location: ret.location,
|
location: ret.location,
|
||||||
|
Reference in New Issue
Block a user