From be6441b7f5d1993c790406f2b186e4803db7881c Mon Sep 17 00:00:00 2001
From: Pierre-Jean CHANCELLIER <paidge_cs@hotmail.com>
Date: Thu, 20 Jan 2022 11:54:56 +0100
Subject: [PATCH] add block number in the menu

---
 assets/css/style.scss                  |  1 +
 components/navigation/Bar.vue          |  8 ++++++--
 components/navigation/menu/Group.vue   |  2 +-
 components/navigation/menu/Sidebar.vue | 26 +++++++++++++++-----------
 graphql/queries.js                     |  9 +++++++++
 i18n/locales/en.json                   |  1 +
 i18n/locales/es.json                   |  1 +
 i18n/locales/fr.json                   |  1 +
 8 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/assets/css/style.scss b/assets/css/style.scss
index a210275..3b2926a 100644
--- a/assets/css/style.scss
+++ b/assets/css/style.scss
@@ -27,6 +27,7 @@ $list-group-active-bg: rgba(0, 0, 255, 0.075);
 $list-group-active-color: var(--text-primary-color);
 $list-group-action-hover-color: var(--text-secondary-color);
 $list-group-action-color: var(--text-primary-color);
+$list-group-border-width: 0;
 
 // Cards
 $card-bg: var(--background-color-secondary);
diff --git a/components/navigation/Bar.vue b/components/navigation/Bar.vue
index 5b02697..d83bd37 100644
--- a/components/navigation/Bar.vue
+++ b/components/navigation/Bar.vue
@@ -23,13 +23,17 @@ export default {
   methods: {
     toggleMenu() {
       document.querySelector('.app').classList.toggle('open')
+      console.log(this.isOpen)
+
       this.isOpen = !this.isOpen
+      console.log(this.isOpen)
+
       localStorage.setItem("menu-open", this.isOpen)
     }
   },
   mounted() {
-    this.isOpen = localStorage.getItem("menu-open")
-    if (this.isOpen == 'true') {
+    this.isOpen = (localStorage.getItem("menu-open") == "true")
+    if (this.isOpen) {
       document.querySelector('.app').classList.add('open')
     }
   }
diff --git a/components/navigation/menu/Group.vue b/components/navigation/menu/Group.vue
index 967668c..59b285b 100644
--- a/components/navigation/menu/Group.vue
+++ b/components/navigation/menu/Group.vue
@@ -1,6 +1,6 @@
 <template>
     <div class="mb-4">
-        <h2 class="small text-muted text-uppercase ml-4 mb-3 pb-3 border-bottom">{{ $t(menu.title) }}</h2>
+        <h2 class="small text-muted text-uppercase ml-4 mb-2 pb-3 border-bottom">{{ $t(menu.title) }}</h2>
         <div class="nav navbar-nav list-group list-group-flush">
             <NuxtLink class="list-group-item list-group-item-action p-0 pl-3" :to="localePath(item.path)" v-for="item in menu.items" :key="item.path">
                 <div class="position-relative py-3">{{ $t(item.title) }}</div>
diff --git a/components/navigation/menu/Sidebar.vue b/components/navigation/menu/Sidebar.vue
index 431c5f6..882d101 100644
--- a/components/navigation/menu/Sidebar.vue
+++ b/components/navigation/menu/Sidebar.vue
@@ -1,10 +1,14 @@
 <template>
     <aside class="menu shadow position-fixed">
-        <div class="nav_header pb-3 mb-5">
+        <div class="nav_header pb-3 mb-4">
             <nuxt-link :to="localePath('/')" class="d-flex">
                 <img src="@/assets/img/logo.png" alt="Accueil" class="logo">
                 <div><h1 class="h2">Wotwizard</h1><small class="text-muted">{{ $t('slogan') }}</small></div>
             </nuxt-link>
+            <div class="d-flex text-info justify-content-between align-items-baseline mt-3 mx-2">
+                <div class="">v0.02</div>
+                <div class="small" v-if="countMax">Bloc n°<span class="font-weight-bold">{{ countMax.number }}</span> ({{ $d(new Date(countMax.utc0*1000), 'short') }} {{ $t('time.a') }} {{ $d(new Date(countMax.utc0*1000), 'hour') }})</div>
+            </div>
             <button type="button" class="close position-absolute d-xl-none" aria-label="Close" @click="toggleMenu">
                 <span aria-hidden="true">&times;</span>
             </button>
@@ -12,11 +16,12 @@
         <nav>
             <NavigationMenuGroup v-for="menu in menus" :key="menu.title" :menu="menu"/>
         </nav>
-        <div class="version position-absolute p-3 text-muted"><br>v0.01</div>
     </aside>
 </template>
 
 <script>
+import {LAST_BLOCK} from '@/graphql/queries.js'
+
 export default {
     props: {
         menus: Array
@@ -25,13 +30,12 @@ export default {
         toggleMenu() {
             this.$emit('toggleMenu')
         }
-    }
-}
-</script>
-
-<style lang="scss">
-.version {
-    bottom: 0;
-    right: 0;
+    },
+    apollo: {
+        countMax : {
+            query: LAST_BLOCK,
+            error (err) {this.error = err.message}
+        }
+    },
 }
-</style>
\ No newline at end of file
+</script>
\ No newline at end of file
diff --git a/graphql/queries.js b/graphql/queries.js
index cc96804..0df3c0f 100644
--- a/graphql/queries.js
+++ b/graphql/queries.js
@@ -1,5 +1,14 @@
 import gql from "graphql-tag"
 
+// Pour la sidebar
+export const LAST_BLOCK = gql`query LastBlock{
+	countMax {
+    number
+    bct
+    utc0
+  }
+}`
+
 // Pour la page index
 export const LAST_EVENTS = gql`query LastEvents($start: Int64, $end: Int64) {
   membersCount(start: $start, end: $end) {
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index cdf3623..4691a36 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -2,6 +2,7 @@
     "accueil": "Home",
     "aurevoir": "Goodbye to",
     "bienvenue": "Welcome to",
+    "bloc": "Block",
     "certifications": {
         "envoyees" : "Certificates sent",
         "recues" : "Certificates received "
diff --git a/i18n/locales/es.json b/i18n/locales/es.json
index 8a5ff90..271c25c 100644
--- a/i18n/locales/es.json
+++ b/i18n/locales/es.json
@@ -2,6 +2,7 @@
     "accueil": "Página principal",
     "aurevoir": "Salen",
     "bienvenue": "Entran",
+    "bloc": "Bloque",
     "certifications": {
         "envoyees" : "Certificaciones enviadas",
         "recues" : "Certificaciones recibidas "
diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json
index ffadcf6..a48e931 100644
--- a/i18n/locales/fr.json
+++ b/i18n/locales/fr.json
@@ -2,6 +2,7 @@
     "accueil": "Accueil",
     "aurevoir": "Au revoir à",
     "bienvenue": "Bienvenue à",
+    "bloc": "Bloc",
     "certifications": {
         "envoyees" : "Certifications envoyées",
         "recues" : "Certifications reçues "
-- 
GitLab