Footer.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <footer class="footer">
  3. <a :href="logout" v-if="connected">Se déconnecter</a>
  4. <a :href="adminPage" v-if="isAdmin">Admninistration</a>
  5. <span>© 2021 - {{ year }} par Clovis Jaquin 1.3.5</span>
  6. </footer>
  7. </template>
  8. <script lang="ts">
  9. import { defineComponent } from "vue";
  10. const API_URL = process.env.VUE_APP_API_URL;
  11. export default defineComponent({
  12. props: { protected: { type: Boolean, default: true } },
  13. data() {
  14. return {
  15. roles: [] as Array<string>,
  16. connected: false,
  17. logout: API_URL + "logout",
  18. adminPage: API_URL + "admin",
  19. year: new Date().getFullYear() + "",
  20. };
  21. },
  22. computed: {
  23. isAdmin(): boolean {
  24. return this.roles.includes("ADMIN");
  25. },
  26. },
  27. mounted() {
  28. fetch(API_URL + "roles/current")
  29. .then((res) => {
  30. if (res.status == 200) {
  31. return res.json();
  32. } else {
  33. throw new Error(res.statusText);
  34. }
  35. })
  36. .then((data: Array<string>) => {
  37. this.roles = data;
  38. this.connected = true;
  39. });
  40. },
  41. });
  42. </script>
  43. <style scoped>
  44. .footer {
  45. display: flex;
  46. justify-content: center;
  47. gap: 16px;
  48. border-top: 1px solid var(--color-neutral-800);
  49. padding: 16px;
  50. margin-top: 16px;
  51. background: #fff;
  52. z-index: 1;
  53. }
  54. .footer > a {
  55. text-decoration: none;
  56. color: var(--color-primary-400);
  57. }
  58. @media print {
  59. .footer {
  60. display: none !important;
  61. }
  62. }
  63. </style>