Update search behavior (#195)
This commit is contained in:
parent
5f185597c9
commit
74ccfab070
|
@ -26,6 +26,13 @@ jobs:
|
|||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: gtstef/filebrowser
|
||||
- name: Get latest release tag and commit SHA
|
||||
id: get_tag_and_sha
|
||||
run: |
|
||||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||
latest_commit=$(git rev-list -n 1 $latest_tag)
|
||||
echo "latest_tag=${latest_tag}" >> $GITHUB_ENV
|
||||
echo "latest_commit=${latest_commit}" >> $GITHUB_ENV
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
|
|
|
@ -360,7 +360,6 @@ func resolveSymlinks(path string) (string, error) {
|
|||
// addContent reads and sets content based on the file type.
|
||||
func (i *FileInfo) addContent(path string) error {
|
||||
if !i.IsDir {
|
||||
fmt.Println("getting content for ", path)
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -65,7 +65,7 @@ func (si *Index) Search(search string, scope string, sourceSession string) ([]st
|
|||
if count > maxSearchResults {
|
||||
break
|
||||
}
|
||||
fullName := pathName + file
|
||||
fullName := strings.TrimLeft(pathName+file, "/")
|
||||
fileTypes := map[string]bool{}
|
||||
|
||||
matches, fileType := containsSearchTerm(fullName, searchTerm, *searchOptions, isDir, fileTypes)
|
||||
|
|
|
@ -2,7 +2,6 @@ package http
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -86,7 +85,6 @@ var rawHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data)
|
|||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
fmt.Println("realpath", realPath, err)
|
||||
file, err := files.FileInfoFaster(files.FileOptions{
|
||||
Path: realPath,
|
||||
Modify: d.user.Perm.Modify,
|
||||
|
|
|
@ -152,7 +152,6 @@ var resourcePutHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
|||
ReadHeader: d.server.TypeDetectionByHeader,
|
||||
Checker: d,
|
||||
}
|
||||
fmt.Println("realPath", realPath)
|
||||
err = files.WriteFile(fileOpts, r.Body)
|
||||
return errToStatus(err), err
|
||||
})
|
||||
|
|
|
@ -15,11 +15,6 @@ export default async function search(base, query) {
|
|||
|
||||
data = data.map((item) => {
|
||||
item.url = `/files${base}` + url.encodePath(item.path);
|
||||
|
||||
if (item.dir) {
|
||||
item.url += "/";
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div id="search" @click="open" :class="{ active, ongoing, 'dark-mode': isDarkMode }">
|
||||
<div id="search" :class="{ active, ongoing, 'dark-mode': isDarkMode }">
|
||||
<!-- Search input section -->
|
||||
<div id="input">
|
||||
<div id="input" @click="open">
|
||||
<!-- Close button visible when search is active -->
|
||||
<button
|
||||
v-if="active"
|
||||
|
@ -34,13 +34,8 @@
|
|||
<div class="button" style="width: 100%">Search Context: {{ getContext }}</div>
|
||||
<!-- List of search results -->
|
||||
<ul v-show="results.length > 0">
|
||||
<li
|
||||
v-for="(s, k) in results"
|
||||
:key="k"
|
||||
@click.stop.prevent="navigateTo(s.url)"
|
||||
style="cursor: pointer"
|
||||
>
|
||||
<router-link to="#" event="">
|
||||
<li v-for="(s, k) in results" :key="k" style="cursor: pointer">
|
||||
<router-link :to="s.url">
|
||||
<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.image" class="material-icons image-icons"> photo </i>
|
||||
|
@ -177,13 +172,8 @@
|
|||
</div>
|
||||
<!-- List of search results -->
|
||||
<ul v-show="results.length > 0">
|
||||
<li
|
||||
v-for="(s, k) in results"
|
||||
:key="k"
|
||||
@click.stop.prevent="navigateTo(s.url)"
|
||||
style="cursor: pointer"
|
||||
>
|
||||
<router-link to="#" event="">
|
||||
<li v-for="(s, k) in results" :key="k" style="cursor: pointer">
|
||||
<router-link :to="s.url">
|
||||
<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.image" class="material-icons image-icons"> photo </i>
|
||||
|
@ -267,25 +257,6 @@ export default {
|
|||
resultList.classList.add("active");
|
||||
}, 100);
|
||||
},
|
||||
currentPrompt(val, old) {
|
||||
this.active = val?.prompt === "search";
|
||||
if (old?.prompt === "search" && !this.active) {
|
||||
if (this.reload) {
|
||||
this.setReload(true);
|
||||
}
|
||||
|
||||
document.body.style.overflow = "auto";
|
||||
this.ongoing = false;
|
||||
this.results = [];
|
||||
this.value = "";
|
||||
this.active = false;
|
||||
this.$refs.input.blur();
|
||||
} else if (this.active) {
|
||||
this.reload = false;
|
||||
this.$refs.input.focus();
|
||||
document.body.style.overflow = "hidden";
|
||||
}
|
||||
},
|
||||
value() {
|
||||
if (this.results.length) {
|
||||
this.ongoing = false;
|
||||
|
@ -303,9 +274,6 @@ export default {
|
|||
active() {
|
||||
return getters.currentPromptName() == "search";
|
||||
},
|
||||
showOverlay() {
|
||||
return getters.currentPrompt() !== null && getters.currentPromptName() !== "more";
|
||||
},
|
||||
isDarkMode() {
|
||||
return getters.isDarkMode();
|
||||
},
|
||||
|
@ -342,11 +310,6 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
async navigateTo(url) {
|
||||
mutations.closeHovers();
|
||||
await this.$nextTick();
|
||||
setTimeout(() => this.$router.push(url), 10);
|
||||
},
|
||||
basePath(str, isDir) {
|
||||
let parts = str.replace(/(\/$|^\/)/, "").split("/");
|
||||
if (parts.length <= 1) {
|
||||
|
@ -360,6 +323,7 @@ export default {
|
|||
if (isDir) {
|
||||
parts = "/" + parts; // fix weird rtl thing
|
||||
}
|
||||
|
||||
return parts;
|
||||
},
|
||||
baseName(str) {
|
||||
|
@ -367,7 +331,9 @@ export default {
|
|||
return parts.pop();
|
||||
},
|
||||
open() {
|
||||
if (!this.active) {
|
||||
mutations.showHover("search");
|
||||
}
|
||||
},
|
||||
close(event) {
|
||||
this.value = "";
|
||||
|
|
|
@ -87,7 +87,6 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isLoaded() {
|
||||
console.log(state.loading);
|
||||
return !("preview-img" in state.loading);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<div class="card clickable" style="min-height: 4em">
|
||||
<div class="card-wrapper user-card">
|
||||
<div @click="navigateTo('/settings#profile-main')" class="inner-card">
|
||||
<i class="material-icons">person</i>
|
||||
{{ user.username }}
|
||||
<i class="material-icons">settings</i>
|
||||
</div>
|
||||
|
@ -208,7 +209,6 @@ export default {
|
|||
if (this.disableUsedPercentage) {
|
||||
return usageStats;
|
||||
}
|
||||
console.log("Fetching usage for", path, state.user);
|
||||
try {
|
||||
let usage = await files.usage(path);
|
||||
usageStats = {
|
||||
|
|
|
@ -134,6 +134,7 @@ async function initAuth() {
|
|||
}
|
||||
|
||||
router.beforeResolve(async (to, from, next) => {
|
||||
mutations.closeHovers()
|
||||
const title = i18n.global.t(titles[to.name as keyof typeof titles]);
|
||||
document.title = title + " - " + name;
|
||||
mutations.setRoute(to)
|
||||
|
|
Loading…
Reference in New Issue