2018-02-01 12:17:04 +00:00
|
|
|
<template>
|
2021-03-21 11:51:58 +00:00
|
|
|
<nav :class="{ active }">
|
2019-01-05 16:12:09 +00:00
|
|
|
<template v-if="isLogged">
|
2023-07-31 23:48:51 +00:00
|
|
|
<button class="action" @click="toRoot" :aria-label="$t('sidebar.myFiles')" :title="$t('sidebar.myFiles')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">folder</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.myFiles") }}</span>
|
2021-10-19 16:37:12 +00:00
|
|
|
</button>
|
2019-01-05 16:12:09 +00:00
|
|
|
<div v-if="user.perm.create">
|
2023-07-31 23:48:51 +00:00
|
|
|
<button @click="$store.commit('showHover', 'newDir')" class="action" :aria-label="$t('sidebar.newFolder')"
|
|
|
|
:title="$t('sidebar.newFolder')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">create_new_folder</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.newFolder") }}</span>
|
2018-02-01 12:17:04 +00:00
|
|
|
</button>
|
2023-07-31 23:48:51 +00:00
|
|
|
<button @click="$store.commit('showHover', 'newFile')" class="action" :aria-label="$t('sidebar.newFile')"
|
|
|
|
:title="$t('sidebar.newFile')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">note_add</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.newFile") }}</span>
|
2019-01-05 16:12:09 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div>
|
2023-07-31 23:48:51 +00:00
|
|
|
<button class="action" @click="toSettings" :aria-label="$t('sidebar.settings')" :title="$t('sidebar.settings')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">settings_applications</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.settings") }}</span>
|
2021-10-19 16:37:12 +00:00
|
|
|
</button>
|
2018-02-01 12:17:04 +00:00
|
|
|
|
2023-07-31 23:48:51 +00:00
|
|
|
<button v-if="canLogout" @click="logout" class="action" id="logout" :aria-label="$t('sidebar.logout')"
|
|
|
|
:title="$t('sidebar.logout')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">exit_to_app</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.logout") }}</span>
|
2019-01-05 16:12:09 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
2023-07-31 23:48:51 +00:00
|
|
|
<router-link class="action" to="/login" :aria-label="$t('sidebar.login')" :title="$t('sidebar.login')">
|
2018-02-01 12:17:04 +00:00
|
|
|
<i class="material-icons">exit_to_app</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.login") }}</span>
|
2019-01-05 16:12:09 +00:00
|
|
|
</router-link>
|
2023-07-31 23:48:51 +00:00
|
|
|
<router-link v-if="signup" class="action" to="/login" :aria-label="$t('sidebar.signup')"
|
|
|
|
:title="$t('sidebar.signup')">
|
2019-01-05 16:12:09 +00:00
|
|
|
<i class="material-icons">person_add</i>
|
2021-03-21 11:51:58 +00:00
|
|
|
<span>{{ $t("sidebar.signup") }}</span>
|
2019-01-05 16:12:09 +00:00
|
|
|
</router-link>
|
|
|
|
</template>
|
2023-07-31 23:48:51 +00:00
|
|
|
<div class="credits" v-if="$router.currentRoute.path.includes('/files/') && !disableUsedPercentage
|
|
|
|
">
|
|
|
|
<progress-bar :val="usage.usedPercentage" size="medium"></progress-bar>
|
|
|
|
<span style="text-align:center">{{ usage.usedPercentage }}%</span>
|
|
|
|
<span>{{ usage.used }} of {{ usage.total }} used</span>
|
|
|
|
<br>
|
|
|
|
<span v-if="disableExternal">File Browser</span>
|
|
|
|
<span v-else>
|
|
|
|
<a rel="noopener noreferrer" target="_blank" href="https://github.com/gtsteffaniak/filebrowser">
|
|
|
|
File Browser
|
|
|
|
</a>
|
2019-01-05 16:12:09 +00:00
|
|
|
</span>
|
2023-07-31 23:48:51 +00:00
|
|
|
<span>{{ version }}</span>
|
2022-06-13 10:50:39 +00:00
|
|
|
<span>
|
|
|
|
<a @click="help">{{ $t("sidebar.help") }}</a>
|
|
|
|
</span>
|
2023-07-31 23:48:51 +00:00
|
|
|
</div>
|
2018-02-01 12:17:04 +00:00
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
<script>
|
2021-03-21 11:51:58 +00:00
|
|
|
import { mapState, mapGetters } from "vuex";
|
|
|
|
import * as auth from "@/utils/auth";
|
|
|
|
import {
|
|
|
|
version,
|
|
|
|
signup,
|
|
|
|
disableExternal,
|
2023-02-15 22:30:48 +00:00
|
|
|
disableUsedPercentage,
|
2021-03-21 11:51:58 +00:00
|
|
|
noAuth,
|
2021-09-13 13:47:06 +00:00
|
|
|
loginPage,
|
2021-03-21 11:51:58 +00:00
|
|
|
} from "@/utils/constants";
|
2022-06-02 10:52:24 +00:00
|
|
|
import { files as api } from "@/api";
|
|
|
|
import ProgressBar from "vue-simple-progress";
|
|
|
|
import prettyBytes from "pretty-bytes";
|
2018-02-01 12:17:04 +00:00
|
|
|
|
|
|
|
export default {
|
2021-03-21 11:51:58 +00:00
|
|
|
name: "sidebar",
|
2022-06-02 10:52:24 +00:00
|
|
|
components: {
|
|
|
|
ProgressBar,
|
|
|
|
},
|
2018-02-01 12:17:04 +00:00
|
|
|
computed: {
|
2021-03-21 11:51:58 +00:00
|
|
|
...mapState(["user"]),
|
|
|
|
...mapGetters(["isLogged"]),
|
|
|
|
active() {
|
|
|
|
return this.$store.state.show === "sidebar";
|
2019-01-05 16:12:09 +00:00
|
|
|
},
|
|
|
|
signup: () => signup,
|
|
|
|
version: () => version,
|
|
|
|
disableExternal: () => disableExternal,
|
2023-02-15 22:30:48 +00:00
|
|
|
disableUsedPercentage: () => disableUsedPercentage,
|
2021-09-13 13:47:06 +00:00
|
|
|
canLogout: () => !noAuth && loginPage,
|
2018-02-01 12:17:04 +00:00
|
|
|
},
|
2022-06-02 10:52:24 +00:00
|
|
|
asyncComputed: {
|
|
|
|
usage: {
|
|
|
|
async get() {
|
|
|
|
let path = this.$route.path.endsWith("/")
|
|
|
|
? this.$route.path
|
|
|
|
: this.$route.path + "/";
|
|
|
|
let usageStats = { used: 0, total: 0, usedPercentage: 0 };
|
2023-02-15 22:30:48 +00:00
|
|
|
if (this.disableUsedPercentage) {
|
|
|
|
return usageStats;
|
|
|
|
}
|
2022-06-02 10:52:24 +00:00
|
|
|
try {
|
|
|
|
let usage = await api.usage(path);
|
|
|
|
usageStats = {
|
2023-07-31 23:48:51 +00:00
|
|
|
used: prettyBytes(usage.used / 1024, { binary: true }),
|
|
|
|
total: prettyBytes(usage.total / 1024, { binary: true }),
|
2022-06-02 10:52:24 +00:00
|
|
|
usedPercentage: Math.round((usage.used / usage.total) * 100),
|
|
|
|
};
|
|
|
|
} catch (error) {
|
|
|
|
this.$showError(error);
|
|
|
|
}
|
|
|
|
return usageStats;
|
|
|
|
},
|
|
|
|
default: { used: "0 B", total: "0 B", usedPercentage: 0 },
|
|
|
|
shouldUpdate() {
|
|
|
|
return this.$router.currentRoute.path.includes("/files/");
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-02-01 12:17:04 +00:00
|
|
|
methods: {
|
2021-10-19 16:37:12 +00:00
|
|
|
toRoot() {
|
2023-07-31 23:48:51 +00:00
|
|
|
this.$router.push({ path: "/files/" }, () => { });
|
2021-10-19 16:37:12 +00:00
|
|
|
this.$store.commit("closeHovers");
|
|
|
|
},
|
|
|
|
toSettings() {
|
2023-07-31 23:48:51 +00:00
|
|
|
this.$router.push({ path: "/settings" }, () => { });
|
2021-10-19 16:37:12 +00:00
|
|
|
this.$store.commit("closeHovers");
|
|
|
|
},
|
2021-03-21 11:51:58 +00:00
|
|
|
help() {
|
|
|
|
this.$store.commit("showHover", "help");
|
2018-02-01 12:17:04 +00:00
|
|
|
},
|
2021-03-21 11:51:58 +00:00
|
|
|
logout: auth.logout,
|
|
|
|
},
|
|
|
|
};
|
2018-02-01 12:17:04 +00:00
|
|
|
</script>
|