updated a bit

This commit is contained in:
Graham Steffaniak 2023-07-31 17:20:14 -05:00
parent a3652a772d
commit f39e561af7
4 changed files with 53 additions and 74 deletions

View File

@ -184,6 +184,7 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption
fileTypes := map[string]bool{} fileTypes := map[string]bool{}
fileSize := getFileSize(pathName) fileSize := getFileSize(pathName)
matchesCondition := false matchesCondition := false
matchesAllConditions := true
extension := filepath.Ext(strings.ToLower(path)) extension := filepath.Ext(strings.ToLower(path))
mimetype := mime.TypeByExtension(extension) mimetype := mime.TypeByExtension(extension)
fileTypes["audio"] = strings.HasPrefix(mimetype, "audio") fileTypes["audio"] = strings.HasPrefix(mimetype, "audio")
@ -192,7 +193,7 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption
fileTypes["doc"] = isDoc(extension) fileTypes["doc"] = isDoc(extension)
fileTypes["archive"] = isArchive(extension) fileTypes["archive"] = isArchive(extension)
fileTypes["dir"] = isDir fileTypes["dir"] = isDir
anyFilter := false
for t,v := range conditions { for t,v := range conditions {
switch t { switch t {
case "exact" : continue case "exact" : continue
@ -200,12 +201,12 @@ func containsSearchTerm(pathName string, searchTerm string, options searchOption
case "smaller" : matchesCondition = fileSize < int64(options.Size) * 1000000 case "smaller" : matchesCondition = fileSize < int64(options.Size) * 1000000
default : matchesCondition = v == fileTypes[t] default : matchesCondition = v == fileTypes[t]
} }
anyFilter = true if (!matchesCondition) {
matchesAllConditions = false
}
} }
if !anyFilter {
matchesCondition = true return matchesAllConditions, fileTypes
}
return matchesCondition, fileTypes
} }
return false, map[string]bool{} return false, map[string]bool{}
} }

View File

@ -1,26 +1,12 @@
<template> <template>
<div id="search" @click="open" v-bind:class="{ active, ongoing }"> <div id="search" @click="open" v-bind:class="{ active, ongoing }">
<div id="input"> <div id="input">
<button <button v-if="active" class="action" @click="close" :aria-label="$t('buttons.close')" :title="$t('buttons.close')">
v-if="active"
class="action"
@click="close"
:aria-label="$t('buttons.close')"
:title="$t('buttons.close')"
>
<i class="material-icons">close</i> <i class="material-icons">close</i>
</button> </button>
<i v-else class="material-icons">search</i> <i v-else class="material-icons">search</i>
<input <input type="text" @keyup.exact="keyup" @input="submit" ref="input" :autofocus="active" v-model.trim="value"
type="text" :aria-label="$t('search.search')" :placeholder="$t('search.search')" />
@keyup.exact="keyup"
@input="submit"
ref="input"
:autofocus="active"
v-model.trim="value"
:aria-label="$t('search.search')"
:placeholder="$t('search.search')"
/>
</div> </div>
<div v-if="isMobile && active" id="result" :class="{ hidden: !active }" ref="result"> <div v-if="isMobile && active" id="result" :class="{ hidden: !active }" ref="result">
<div id="result-list"> <div id="result-list">
@ -28,12 +14,7 @@
Search Context: {{ getContext(this.$route.path) }} Search Context: {{ getContext(this.$route.path) }}
</div> </div>
<ul v-show="results.length > 0"> <ul v-show="results.length > 0">
<li <li v-for="(s, k) in results" :key="k" @click.stop.prevent="navigateTo(s.url)" style="cursor: pointer">
v-for="(s, k) in results"
:key="k"
@click.stop.prevent="navigateTo(s.url)"
style="cursor: pointer"
>
<router-link to="#" event=""> <router-link to="#" event="">
<i v-if="s.dir" class="material-icons folder-icons"> folder </i> <i v-if="s.dir" class="material-icons folder-icons"> folder </i>
<i v-else-if="s.audio" class="material-icons audio-icons"> volume_up </i> <i v-else-if="s.audio" class="material-icons audio-icons"> volume_up </i>
@ -47,20 +28,17 @@
</router-link> </router-link>
</li> </li>
</ul> </ul>
<p v-show="isEmpty && isRunning" id="renew">
<i class="material-icons spin">autorenew</i>
</p>
<p v-show="isEmpty && !isRunning">{{ text }}</p>
<template v-if="isEmpty"> <template v-if="isEmpty">
<p >{{ text }}</p>
<template v-if="value.length === 0"> <template v-if="value.length === 0">
<div class="boxes"> <div class="boxes">
<h3>{{ $t("search.types") }}</h3> <h3>{{ $t("search.types") }}</h3>
<div> <div>
<div <div tabindex="0" v-for="(v, k) in boxes" :key="k" role="button" @click="init('type:' + k)"
tabindex="0" :aria-label="v.label">
v-for="(v, k) in boxes"
:key="k"
role="button"
@click="init('type:' + k)"
:aria-label="v.label"
>
<i class="material-icons">{{ v.icon }}</i> <i class="material-icons">{{ v.icon }}</i>
<p>{{ v.label }}</p> <p>{{ v.label }}</p>
</div> </div>
@ -76,12 +54,7 @@
Search Context: {{ getContext(this.$route.path) }} Search Context: {{ getContext(this.$route.path) }}
</div> </div>
<ul v-show="results.length > 0"> <ul v-show="results.length > 0">
<li <li v-for="(s, k) in results" :key="k" @click.stop.prevent="navigateTo(s.url)" style="cursor: pointer">
v-for="(s, k) in results"
:key="k"
@click.stop.prevent="navigateTo(s.url)"
style="cursor: pointer"
>
<router-link to="#" event=""> <router-link to="#" event="">
<i v-if="s.dir" class="material-icons folder-icons"> folder </i> <i v-if="s.dir" class="material-icons folder-icons"> folder </i>
<i v-else-if="s.audio" class="material-icons audio-icons"> volume_up </i> <i v-else-if="s.audio" class="material-icons audio-icons"> volume_up </i>
@ -95,25 +68,16 @@
</router-link> </router-link>
</li> </li>
</ul> </ul>
<template > <template>
<p v-show="isEmpty" >{{ text }}</p> <p v-show="isEmpty && isRunning" id="renew">
<template > <i class="material-icons spin">autorenew</i>
</p>
<p v-show="isEmpty && !isRunning">{{ text }}</p>
<template>
<div v-show="results.length == 0" class="boxes"> <div v-show="results.length == 0" class="boxes">
<ButtonGroup <ButtonGroup :buttons="folderSelect" @button-clicked="init" @remove-button-clicked="removeInit" />
:buttons="folderSelect" <ButtonGroup :buttons="typeSelect" @button-clicked="init" @remove-button-clicked="removeInit" />
@button-clicked="init" <ButtonGroup :buttons="sizeSelect" @button-clicked="init" @remove-button-clicked="removeInit" />
@remove-button-clicked="removeInit"
/>
<ButtonGroup
:buttons="typeSelect"
@button-clicked="init"
@remove-button-clicked="removeInit"
/>
<ButtonGroup
:buttons="sizeSelect"
@button-clicked="init"
@remove-button-clicked="removeInit"
/>
</div> </div>
</template> </template>
</template> </template>
@ -151,10 +115,11 @@ export default {
{ label: "Only Files", value: "type:file" }, { label: "Only Files", value: "type:file" },
], ],
typeSelect: [ typeSelect: [
{ label: "Archives", value: "type:archive" }, { label: "Photos", value: "type:image" },
{ label: "Audio Files", value: "type:audio" }, { label: "Audio", value: "type:audio" },
{ label: "Videos", value: "type:video" }, { label: "Videos", value: "type:video" },
{ label: "Documents", value: "type:docs" }, { label: "Documents", value: "type:docs" },
{ label: "Archives", value: "type:archive" },
], ],
sizeSelect: [ sizeSelect: [
{ label: "Smaller than 100MB", value: "type:smaller=100" }, { label: "Smaller than 100MB", value: "type:smaller=100" },
@ -215,6 +180,9 @@ export default {
isMobile() { isMobile() {
return this.width <= 800; return this.width <= 800;
}, },
isRunning() {
return this.ongoing;
}
}, },
mounted() { mounted() {
window.addEventListener("resize", this.handleResize); window.addEventListener("resize", this.handleResize);
@ -266,20 +234,20 @@ export default {
this.results.length === 0; this.results.length === 0;
}, },
init(string) { init(string) {
if (string == null || string == ""){ if (string == null || string == "") {
return false return false
} }
this.value = `${string} ${this.value}`; this.value = `${string} ${this.value}`;
if (this.isMobile){ if (this.isMobile) {
this.$refs.input.focus(); this.$refs.input.focus();
} }
}, },
removeInit(string) { removeInit(string) {
if (string == null || string == ""){ if (string == null || string == "") {
return false return false
} }
this.value = this.value.replace(string+" ", ""); this.value = this.value.replace(string + " ", "");
if (this.isMobile){ if (this.isMobile) {
this.$refs.input.focus(); this.$refs.input.focus();
} }
}, },
@ -301,7 +269,6 @@ export default {
} catch (error) { } catch (error) {
this.$showError(error); this.$showError(error);
} }
this.ongoing = false; this.ongoing = false;
}, },
}, },

View File

@ -188,6 +188,7 @@ body.rtl .breadcrumbs a {
/* File Selection */ /* File Selection */
#file-selection { #file-selection {
box-shadow: rgba(0, 0, 0, 0.3) 0px 2em 50px 10px;
position: fixed; position: fixed;
bottom: 1em; bottom: 1em;
left: 50%; left: 50%;
@ -196,10 +197,8 @@ body.rtl .breadcrumbs a {
-ms-flex-align: center; -ms-flex-align: center;
align-items: center; align-items: center;
background: #fff; background: #fff;
-webkit-box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px;
box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px;
width: 95%; width: 95%;
max-width: 25em; max-width: 30em;
z-index: 1; z-index: 1;
} }

View File

@ -171,7 +171,7 @@ body.rtl #search #result ul>* {
width: 100%; width: 100%;
text-align: center; text-align: center;
display: none; display: none;
margin: 0; margin: 1em;
max-width: none; max-width: none;
} }
@ -179,6 +179,18 @@ body.rtl #search #result ul>* {
display: block; display: block;
} }
#search #result-desktop #renew {
width: 100%;
text-align: center;
display: none;
margin: 1em;
max-width: none;
}
#search.ongoing #result-desktop #renew {
display: block;
}
/* Icon Colors */ /* Icon Colors */
.folder-icons { .folder-icons {
color: var(--icon-blue); color: var(--icon-blue);