filebrowser/frontend/src/components/Sidebar.vue

135 lines
3.3 KiB
Vue
Raw Normal View History

2018-02-01 12:17:04 +00:00
<template>
2021-03-21 11:51:58 +00:00
<nav :class="{ active }">
<template v-if="isLogged">
2021-03-21 11:51:58 +00:00
<router-link
class="action"
to="/files/"
:aria-label="$t('sidebar.myFiles')"
:title="$t('sidebar.myFiles')"
>
<i class="material-icons">folder</i>
2021-03-21 11:51:58 +00:00
<span>{{ $t("sidebar.myFiles") }}</span>
2018-02-01 12:17:04 +00:00
</router-link>
<div v-if="user.perm.create">
2021-03-21 11:51:58 +00:00
<button
@click="$store.commit('showHover', 'newDir')"
class="action"
:aria-label="$t('sidebar.newFolder')"
:title="$t('sidebar.newFolder')"
>
<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>
2021-03-21 11:51:58 +00:00
<button
@click="$store.commit('showHover', 'newFile')"
class="action"
:aria-label="$t('sidebar.newFile')"
:title="$t('sidebar.newFile')"
>
<i class="material-icons">note_add</i>
2021-03-21 11:51:58 +00:00
<span>{{ $t("sidebar.newFile") }}</span>
</button>
</div>
2018-02-01 12:17:04 +00:00
<div>
2021-03-21 11:51:58 +00:00
<router-link
class="action"
to="/settings"
:aria-label="$t('sidebar.settings')"
:title="$t('sidebar.settings')"
>
<i class="material-icons">settings_applications</i>
2021-03-21 11:51:58 +00:00
<span>{{ $t("sidebar.settings") }}</span>
</router-link>
2018-02-01 12:17:04 +00:00
2021-03-21 11:51:58 +00:00
<button
v-if="authMethod == 'json'"
@click="logout"
class="action"
id="logout"
:aria-label="$t('sidebar.logout')"
:title="$t('sidebar.logout')"
>
<i class="material-icons">exit_to_app</i>
2021-03-21 11:51:58 +00:00
<span>{{ $t("sidebar.logout") }}</span>
</button>
</div>
</template>
<template v-else>
2021-03-21 11:51:58 +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>
</router-link>
2021-03-21 11:51:58 +00:00
<router-link
v-if="signup"
class="action"
to="/login"
:aria-label="$t('sidebar.signup')"
:title="$t('sidebar.signup')"
>
<i class="material-icons">person_add</i>
2021-03-21 11:51:58 +00:00
<span>{{ $t("sidebar.signup") }}</span>
</router-link>
</template>
2018-02-01 12:17:04 +00:00
<p class="credits">
<span>
<span v-if="disableExternal">File Browser</span>
2021-03-21 11:51:58 +00:00
<a
v-else
rel="noopener noreferrer"
target="_blank"
href="https://github.com/filebrowser/filebrowser"
>File Browser</a
>
2019-01-26 11:21:10 +00:00
<span> {{ version }}</span>
</span>
2021-03-21 11:51:58 +00:00
<span
><a @click="help">{{ $t("sidebar.help") }}</a></span
>
2018-02-01 12:17:04 +00:00
</p>
</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,
noAuth,
authMethod,
} from "@/utils/constants";
2018-02-01 12:17:04 +00:00
export default {
2021-03-21 11:51:58 +00:00
name: "sidebar",
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";
},
signup: () => signup,
version: () => version,
disableExternal: () => disableExternal,
noAuth: () => noAuth,
2021-03-21 11:51:58 +00:00
authMethod: () => authMethod,
2018-02-01 12:17:04 +00:00
},
methods: {
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>