Fix usage progressbar not showing
This commit is contained in:
parent
fe3ed4a9b3
commit
a1ca679c3c
@ -82,9 +82,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="credits"
|
class="credits"
|
||||||
v-if="
|
v-if="isFiles && !disableUsedPercentage"
|
||||||
$router.currentRoute.path?.includes('/files/') && !disableUsedPercentage
|
|
||||||
"
|
|
||||||
style="width: 90%; margin: 2em 2.5em 3em 2.5em"
|
style="width: 90%; margin: 2em 2.5em 3em 2.5em"
|
||||||
>
|
>
|
||||||
<progress-bar :val="usage.usedPercentage" size="small"></progress-bar>
|
<progress-bar :val="usage.usedPercentage" size="small"></progress-bar>
|
||||||
@ -112,8 +110,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { reactive } from "vue";
|
||||||
import { mapActions, mapState } from "pinia";
|
import { mapActions, mapState } from "pinia";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
import { useFileStore } from "@/stores/file";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
|
||||||
import * as auth from "@/utils/auth";
|
import * as auth from "@/utils/auth";
|
||||||
@ -129,14 +129,21 @@ import { files as api } from "@/api";
|
|||||||
import ProgressBar from "vue-simple-progress";
|
import ProgressBar from "vue-simple-progress";
|
||||||
import prettyBytes from "pretty-bytes";
|
import prettyBytes from "pretty-bytes";
|
||||||
|
|
||||||
|
const USAGE_DEFAULT = { used: "0 B", total: "0 B", usedPercentage: 0 };
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "sidebar",
|
name: "sidebar",
|
||||||
|
setup() {
|
||||||
|
const usage = reactive(USAGE_DEFAULT);
|
||||||
|
return { usage };
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
},
|
},
|
||||||
inject: ["$showError"],
|
inject: ["$showError"],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(useAuthStore, ["user", "isLoggedIn"]),
|
...mapState(useAuthStore, ["user", "isLoggedIn"]),
|
||||||
|
...mapState(useFileStore, ["isFiles", "reload"]),
|
||||||
...mapState(useLayoutStore, ["show"]),
|
...mapState(useLayoutStore, ["show"]),
|
||||||
active() {
|
active() {
|
||||||
return this.show === "sidebar";
|
return this.show === "sidebar";
|
||||||
@ -147,15 +154,15 @@ export default {
|
|||||||
disableUsedPercentage: () => disableUsedPercentage,
|
disableUsedPercentage: () => disableUsedPercentage,
|
||||||
canLogout: () => !noAuth && loginPage,
|
canLogout: () => !noAuth && loginPage,
|
||||||
},
|
},
|
||||||
asyncComputed: {
|
methods: {
|
||||||
usage: {
|
...mapActions(useLayoutStore, ["closeHovers", "showHover"]),
|
||||||
async get() {
|
async fetchUsage() {
|
||||||
let path = this.$route.path.endsWith("/")
|
let path = this.$route.path.endsWith("/")
|
||||||
? this.$route.path
|
? this.$route.path
|
||||||
: this.$route.path + "/";
|
: this.$route.path + "/";
|
||||||
let usageStats = { used: 0, total: 0, usedPercentage: 0 };
|
let usageStats = USAGE_DEFAULT;
|
||||||
if (this.disableUsedPercentage) {
|
if (this.disableUsedPercentage) {
|
||||||
return usageStats;
|
return Object.assign(this.usage, usageStats);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let usage = await api.usage(path);
|
let usage = await api.usage(path);
|
||||||
@ -167,16 +174,8 @@ export default {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$showError(error);
|
this.$showError(error);
|
||||||
}
|
}
|
||||||
return usageStats;
|
return Object.assign(this.usage, usageStats);
|
||||||
},
|
},
|
||||||
default: { used: "0 B", total: "0 B", usedPercentage: 0 },
|
|
||||||
shouldUpdate() {
|
|
||||||
return this.$router.currentRoute.path.includes("/files/");
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapActions(useLayoutStore, ["closeHovers", "showHover"]),
|
|
||||||
toRoot() {
|
toRoot() {
|
||||||
this.$router.push({ path: "/files" });
|
this.$router.push({ path: "/files" });
|
||||||
this.closeHovers();
|
this.closeHovers();
|
||||||
@ -190,5 +189,10 @@ export default {
|
|||||||
},
|
},
|
||||||
logout: auth.logout,
|
logout: auth.logout,
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
isFiles(newValue) {
|
||||||
|
newValue && this.fetchUsage();
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,68 +0,0 @@
|
|||||||
import Vue from "vue";
|
|
||||||
import Noty from "noty";
|
|
||||||
import VueLazyload from "vue-lazyload";
|
|
||||||
import i18n from "@/i18n";
|
|
||||||
import { disableExternal } from "@/utils/constants";
|
|
||||||
import AsyncComputed from "vue-async-computed";
|
|
||||||
|
|
||||||
Vue.use(VueLazyload);
|
|
||||||
Vue.use(AsyncComputed);
|
|
||||||
|
|
||||||
Vue.config.productionTip = true;
|
|
||||||
|
|
||||||
const notyDefault = {
|
|
||||||
type: "info",
|
|
||||||
layout: "bottomRight",
|
|
||||||
timeout: 1000,
|
|
||||||
progressBar: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
Vue.prototype.$noty = (opts) => {
|
|
||||||
new Noty(Object.assign({}, notyDefault, opts)).show();
|
|
||||||
};
|
|
||||||
|
|
||||||
Vue.prototype.$showSuccess = (message) => {
|
|
||||||
new Noty(
|
|
||||||
Object.assign({}, notyDefault, {
|
|
||||||
text: message,
|
|
||||||
type: "success",
|
|
||||||
})
|
|
||||||
).show();
|
|
||||||
};
|
|
||||||
|
|
||||||
Vue.prototype.$showError = (error, displayReport = true) => {
|
|
||||||
let btns = [
|
|
||||||
Noty.button(i18n.t("buttons.close"), "", function () {
|
|
||||||
n.close();
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!disableExternal && displayReport) {
|
|
||||||
btns.unshift(
|
|
||||||
Noty.button(i18n.t("buttons.reportIssue"), "", function () {
|
|
||||||
window.open(
|
|
||||||
"https://github.com/filebrowser/filebrowser/issues/new/choose"
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let n = new Noty(
|
|
||||||
Object.assign({}, notyDefault, {
|
|
||||||
text: error.message || error,
|
|
||||||
type: "error",
|
|
||||||
timeout: null,
|
|
||||||
buttons: btns,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
n.show();
|
|
||||||
};
|
|
||||||
|
|
||||||
Vue.directive("focus", {
|
|
||||||
inserted: function (el) {
|
|
||||||
el.focus();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Vue;
|
|
||||||
Loading…
Reference in New Issue
Block a user