Merge branch 'master' into add-context-menu

This commit is contained in:
Omar Hussein 2024-03-11 21:44:43 -04:00 committed by GitHub
commit 37e72b5c80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 79 additions and 30 deletions

View File

@ -87,16 +87,23 @@ func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
data := pythonData{hadDB: true} data := pythonData{hadDB: true}
path := getParam(cmd.Flags(), "database") path := getParam(cmd.Flags(), "database")
absPath, err := filepath.Abs(path)
if err != nil {
panic(err)
}
exists, err := dbExists(path) exists, err := dbExists(path)
if err != nil { if err != nil {
panic(err) panic(err)
} else if exists && cfg.noDB { } else if exists && cfg.noDB {
log.Fatal(path + " already exists") log.Fatal(absPath + " already exists")
} else if !exists && !cfg.noDB && !cfg.allowNoDB { } else if !exists && !cfg.noDB && !cfg.allowNoDB {
log.Fatal(path + " does not exist. Please run 'filebrowser config init' first.") log.Fatal(absPath + " does not exist. Please run 'filebrowser config init' first.")
} else if !exists && !cfg.noDB {
log.Println("Warning: filebrowser.db can't be found. Initialing in " + strings.TrimSuffix(absPath, "filebrowser.db"))
} }
log.Println("Using database: " + absPath)
data.hadDB = exists data.hadDB = exists
db, err := storm.Open(path) db, err := storm.Open(path)
checkErr(err) checkErr(err)

View File

@ -45,6 +45,7 @@ export default {
submit: async function () { submit: async function () {
buttons.loading("delete"); buttons.loading("delete");
window.sessionStorage.setItem("modified", "true");
try { try {
if (!this.isListing) { if (!this.isListing) {
await api.remove(this.$route.path); await api.remove(this.$route.path);

View File

@ -88,6 +88,7 @@ export default {
newLink = newLink =
url.removeLastDir(oldLink) + "/" + encodeURIComponent(this.name); url.removeLastDir(oldLink) + "/" + encodeURIComponent(this.name);
window.sessionStorage.setItem("modified", "true");
try { try {
await api.move([{ from: oldLink, to: newLink }]); await api.move([{ from: oldLink, to: newLink }]);
if (!this.isListing) { if (!this.isListing) {

View File

@ -2,10 +2,6 @@
nav { nav {
width: 10em width: 10em
} }
/* Mobile Only fix div hidden by bottom navigation bar of mobile browser when using height: 100vh */
#previewer .preview {
height: calc(100% - 4em) !important;
}
} }
@media (max-width: 1024px) { @media (max-width: 1024px) {

View File

@ -153,8 +153,7 @@ main .spinner .bounce2 {
/* PREVIEWER */ /* PREVIEWER */
#previewer { #previewer {
background-color: rgba(0, 0, 0, 0.9); background-color: rgba(0, 0, 0, 0.99);
padding-top: 4em;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -167,15 +166,25 @@ main .spinner .bounce2 {
#previewer header { #previewer header {
background: none; background: none;
color: #fff; color: #fff;
border-bottom: 0px;
box-shadow: 0px 0px 0px;
z-index: 19999;
} }
#previewer header > .action i { #previewer header > .action i {
color: #fff; color: #fff;
text-shadow: 1px 1px 1px #000000;
}
#previewer header > title {
white-space: nowrap;
text-shadow: 1px 1px 1px #000000;
} }
@media (min-width: 738px) { @media (min-width: 738px) {
#previewer header #dropdown .action i { #previewer header #dropdown .action i {
color: #fff; color: #fff;
text-shadow: 1px 1px 1px #000000;
} }
} }
@ -189,7 +198,7 @@ main .spinner .bounce2 {
#previewer .preview { #previewer .preview {
text-align: center; text-align: center;
height: calc(100vh - 4em); height: 100%;
} }
#previewer .preview pre { #previewer .preview pre {
@ -204,6 +213,12 @@ main .spinner .bounce2 {
margin: 0; margin: 0;
} }
#previewer .preview audio {
width: 95%;
height: 88%;
}
#previewer .preview video { #previewer .preview video {
height: 100%; height: 100%;
} }
@ -248,7 +263,7 @@ main .spinner .bounce2 {
#previewer > button { #previewer > button {
margin: 0; margin: 0;
position: fixed; position: fixed;
top: calc(50% + 1.85em); top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
background-color: rgba(80, 80, 80, 0.5); background-color: rgba(80, 80, 80, 0.5);
color: white; color: white;

View File

@ -3,10 +3,10 @@
<header-bar v-if="error || req.type == null" showMenu showLogo /> <header-bar v-if="error || req.type == null" showMenu showLogo />
<breadcrumbs base="/files" /> <breadcrumbs base="/files" />
<listing />
<errors v-if="error" :errorCode="error.status" /> <errors v-if="error" :errorCode="error.status" />
<component v-else-if="currentView" :is="currentView"></component> <component v-else-if="currentView" :is="currentView"></component>
<div v-else> <div v-else-if="currentView !== null">
<h2 class="message delayed"> <h2 class="message delayed">
<div class="spinner"> <div class="spinner">
<div class="bounce1"></div> <div class="bounce1"></div>
@ -52,12 +52,8 @@ export default {
computed: { computed: {
...mapState(["req", "reload", "loading"]), ...mapState(["req", "reload", "loading"]),
currentView() { currentView() {
if (this.req.type == undefined) { if (this.req.type == undefined || this.req.isDir) {
return null; return null;
}
if (this.req.isDir) {
return "listing";
} else if ( } else if (
this.req.type === "text" || this.req.type === "text" ||
this.req.type === "textImmutable" this.req.type === "textImmutable"
@ -72,7 +68,26 @@ export default {
this.fetchData(); this.fetchData();
}, },
watch: { watch: {
$route: "fetchData", $route: function (to, from) {
if (from.path.endsWith("/")) {
if (to.path.endsWith("/")) {
window.sessionStorage.setItem("listFrozen", "false");
this.fetchData();
return;
} else {
window.sessionStorage.setItem("listFrozen", "true");
this.fetchData();
return;
}
} else if (to.path.endsWith("/")) {
this.$store.commit("updateRequest", {});
this.fetchData();
return;
} else {
this.fetchData();
return;
}
},
reload: function (value) { reload: function (value) {
if (value === true) { if (value === true) {
this.fetchData(); this.fetchData();
@ -101,7 +116,9 @@ export default {
this.$store.commit("closeHovers"); this.$store.commit("closeHovers");
// Set loading to true and reset the error. // Set loading to true and reset the error.
this.setLoading(true); if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
this.setLoading(true);
}
this.error = null; this.error = null;
let url = this.$route.path; let url = this.$route.path;

View File

@ -1,5 +1,9 @@
<template> <template>
<div id="editor-container"> <div
id="editor-container"
@touchmove.prevent.stop
@wheel.prevent.stop
>
<header-bar> <header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" /> <action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ req.name }}</title> <title>{{ req.name }}</title>

View File

@ -436,17 +436,23 @@ export default {
}, },
watch: { watch: {
req: function () { req: function () {
// Reset the show value if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
this.showLimit = 50; // Reset the show value
this.showLimit = 50;
// Ensures that the listing is displayed // Ensures that the listing is displayed
Vue.nextTick(() => { Vue.nextTick(() => {
// How much every listing item affects the window height // How much every listing item affects the window height
this.setItemWeight(); this.setItemWeight();
// Fill and fit the window with listing items // Fill and fit the window with listing items
this.fillWindow(true); this.fillWindow(true);
}); });
}
if (this.req.isDir) {
window.sessionStorage.setItem("listFrozen", "false");
window.sessionStorage.setItem("modified", "false");
}
}, },
}, },
mounted: function () { mounted: function () {

View File

@ -1,10 +1,12 @@
<template> <template>
<div <div
id="previewer" id="previewer"
@touchmove.prevent.stop
@wheel.prevent.stop
@mousemove="toggleNavigation" @mousemove="toggleNavigation"
@touchstart="toggleNavigation" @touchstart="toggleNavigation"
> >
<header-bar> <header-bar v-if="showNav">
<action icon="close" :label="$t('buttons.close')" @action="close()" /> <action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ name }}</title> <title>{{ name }}</title>
<action <action