From f6656672d12ebe2a0929dc20a1798ac99a9c8f78 Mon Sep 17 00:00:00 2001
From: paidge <paidge_cs@hotmail.com>
Date: Tue, 11 Jan 2022 19:58:09 +0100
Subject: [PATCH] v0.01

---
 components/badge/CertifStatus.vue      | 10 +++-
 components/badge/Dispo.vue             | 25 +++++++++
 components/certif/List.vue             | 19 ++++---
 components/member/Card.vue             |  8 +--
 components/navigation/menu/Sidebar.vue | 18 ++++++-
 graphql/queries.js                     | 63 ++++------------------
 i18n/locales/dateTimeFormats.js        | 12 ++---
 i18n/locales/en.json                   |  3 ++
 i18n/locales/es.json                   |  3 ++
 i18n/locales/fr.json                   |  3 ++
 layouts/default.vue                    |  8 +--
 pages/membres/_hash.vue                | 11 ++--
 pages/previsions/_hash.vue             | 74 --------------------------
 pages/previsions/futurs_membres.vue    |  4 +-
 14 files changed, 103 insertions(+), 158 deletions(-)
 create mode 100644 components/badge/Dispo.vue
 delete mode 100644 pages/previsions/_hash.vue

diff --git a/components/badge/CertifStatus.vue b/components/badge/CertifStatus.vue
index b3ceae8..26538d7 100644
--- a/components/badge/CertifStatus.vue
+++ b/components/badge/CertifStatus.vue
@@ -1,5 +1,5 @@
 <template>
-    <span class="font-weight-normal" :class="classWarning" :title="textWarning" v-if="($options.filters.dateStatus(limitDate) != 'success') && (['MEMBER', 'MISSING'].includes(memberStatus))">âš 
+    <span class="danger font-weight-normal" :class="classWarning" :title="textWarning" v-if="($options.filters.dateStatus(limitDate) != 'success') && (['MEMBER', 'MISSING'].includes(memberStatus))">âš 
         <span class="sr-only">{{ textWarning }}</span>
     </span>
 </template>
@@ -25,4 +25,10 @@ export default {
         }
     }
 }
-</script>
\ No newline at end of file
+</script>
+
+<style lang="scss" scoped>
+.danger {
+    cursor: default;
+}
+</style>
\ No newline at end of file
diff --git a/components/badge/Dispo.vue b/components/badge/Dispo.vue
new file mode 100644
index 0000000..ad18eb3
--- /dev/null
+++ b/components/badge/Dispo.vue
@@ -0,0 +1,25 @@
+<template>
+    <small>
+        <span class="badge"
+          :class="{
+              'badge-success': isDispo,
+              'badge-danger': !isDispo,
+          }">
+            {{ isDispo ? $t('membre.dispo') : $t('membre.nodispo') + ' >&nbsp;' + $d(new Date(dateDispo*1000), 'short') }}
+        </span>
+    </small>
+</template>
+
+<script>
+export default {
+    props: {
+        isDispo: {
+            type: Boolean,
+            required: true
+        },
+        dateDispo: {
+            type: Number
+        }
+    }
+}
+</script>
\ No newline at end of file
diff --git a/components/certif/List.vue b/components/certif/List.vue
index 48d5fa4..434aa38 100644
--- a/components/certif/List.vue
+++ b/components/certif/List.vue
@@ -4,14 +4,19 @@
             <tbody>
                 <tr v-for="certif in certifsTriees" :key="getNeighbor(certif).uid"
                     @click="$router.push(localePath({name:'membres-hash', params: {hash: getNeighbor(certif).hash}}))">
-                    <th scope="row">
-                        {{ getNeighbor(certif).uid }}
-                        <BadgeCertifStatus :limitDate="getNeighbor(certif).received_certifications.limit" :memberStatus="getNeighbor(certif).status" />
-                        <BadgeStatus :membre="getNeighbor(certif)" />
-                        <BadgeQuality :quality="getNeighbor(certif).quality.ratio" v-if="getNeighbor(certif).status != 'REVOKED'" />
+                    <th scope="row" class="py-1">
+                        <div>
+                            {{ getNeighbor(certif).uid }}
+                            <BadgeCertifStatus :limitDate="getNeighbor(certif).received_certifications.limit" :memberStatus="getNeighbor(certif).status" />
+                            <BadgeQuality :quality="getNeighbor(certif).quality.ratio" v-if="getNeighbor(certif).status != 'REVOKED'" />
+                        </div>
+                        <div>
+                            <BadgeStatus :membre="getNeighbor(certif)" />
+                            <BadgeDispo :isDispo="getNeighbor(certif).minDatePassed" :dateDispo="getNeighbor(certif).minDate" v-if="getNeighbor(certif).status == 'MEMBER'" />
+                        </div>
                     </th>
-                    <td class="text-right">
-                        <small><span class="badge" :class="'badge-'+ $options.filters.dateStatus(certif.expires_on)">{{ $t('expire') }} {{ $d(new Date(certif.expires_on*1000), 'long') }}</span></small>
+                    <td class="text-right py-1">
+                        <small><span class="badge" :class="'badge-'+ $options.filters.dateStatus(certif.expires_on)">{{ $t('expire') }} {{ $d(new Date(certif.expires_on*1000), 'short') }}</span></small>
                     </td>
                 </tr>
             </tbody>
diff --git a/components/member/Card.vue b/components/member/Card.vue
index fb91a51..fc0e575 100644
--- a/components/member/Card.vue
+++ b/components/member/Card.vue
@@ -19,12 +19,12 @@
                     'list-group-item-warning': hash.quality.ratio < 80,
                 }">{{ Math.round(hash.quality.ratio*100)/100 }}</td>
             </tr>
-            <tr v-if="hash.status != 'NEWCOMER'">
+            <tr>
                 <th scope="row">{{ $t('membre.distance') }} :</th>
                 <td :class="{
-                    'list-group-item-success': hash.distance.dist_ok,
-                    'list-group-item-danger': !hash.distance.dist_ok,
-                }">{{ Math.round(hash.distance.value.ratio*100)/100 }}</td>
+                    'list-group-item-success':  hash.status != 'NEWCOMER' ? hash.distance.dist_ok : hash.distanceE.dist_ok,
+                    'list-group-item-danger': hash.status != 'NEWCOMER' ? !hash.distance.dist_ok : !hash.distanceE.dist_ok,
+                }">{{ hash.status != 'NEWCOMER' ? Math.round(hash.distance.value.ratio*100)/100 : Math.round(hash.distanceE.value.ratio*100)/100 }}</td>
             </tr>
             <tr>
                 <th scope="row">{{ hash.status != 'MISSING' ? $t('membre.datelimadhesion') : $t('membre.datelimrevoc')}} :</th>
diff --git a/components/navigation/menu/Sidebar.vue b/components/navigation/menu/Sidebar.vue
index 4f599e4..0d1b09c 100644
--- a/components/navigation/menu/Sidebar.vue
+++ b/components/navigation/menu/Sidebar.vue
@@ -1,7 +1,13 @@
 <template>
     <aside class="menu shadow position-fixed">
         <div class="nav_header pb-3 mb-5">
-            <nuxt-link :to="localePath('/')"><h1 class="h2 d-flex"><img src="@/assets/img/logo.png" alt="Accueil" class="logo">&nbsp;Wotwizard</h1></nuxt-link>
+
+
+            <nuxt-link :to="localePath('/')" class="d-flex">
+                <div><img src="@/assets/img/logo.png" alt="Accueil" class="logo"></div>
+                <div><h1 class="h2">Wotwizard</h1><small class="text-muted">{{ $t('slogan') }}</small></div>
+            </nuxt-link>
+
             <button type="button" class="close position-absolute d-xl-none" aria-label="Close" @click="toggleMenu">
                 <span aria-hidden="true">&times;</span>
             </button>
@@ -9,6 +15,7 @@
         <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>
 
@@ -23,4 +30,11 @@ export default {
         }
     }
 }
-</script>
\ No newline at end of file
+</script>
+
+<style lang="scss">
+.version {
+    bottom: 0;
+    right: 0;
+}
+</style>
\ No newline at end of file
diff --git a/graphql/queries.js b/graphql/queries.js
index 933cc50..be78bae 100644
--- a/graphql/queries.js
+++ b/graphql/queries.js
@@ -113,57 +113,6 @@ export const PREVISIONS = gql`query GetDossiers {
     }
   }`
 
-// Pour la page previsions/_hash
-export const PREVISION = gql`query SearchForecast($hash: Hash!) {
-    idFromHash(hash: $hash) {
-        ...memberAttributes
-        pubkey
-        isLeaving
-        sentry
-        minDate
-        minDatePassed
-        membership_pending
-        limitDate
-        distance {
-            __typename
-            value {
-                __typename
-                ratio
-            }
-            dist_ok
-        }
-        received_certifications {
-            __typename
-            certifications {
-                __typename
-                from {
-                    ...memberAttributes
-                }
-                expires_on
-            }
-        }
-        sent_certifications {
-            __typename
-            to {
-                ...memberAttributes
-            }
-            expires_on
-        }
-    }
-}
-fragment memberAttributes on Identity {
-    __typename
-    uid
-    hash
-    status
-    quality {
-        ratio
-    }
-    received_certifications {
-        limit
-    }
-}`
-
 // Pour la page previsions/newcomers
 export const NEWCOMERS = gql`query GetNewcomers{
     wwResult {
@@ -218,10 +167,16 @@ export const SEARCH_MEMBER = gql`query SearchMemberWithHash($hash: Hash!) {
         pubkey
         isLeaving
         sentry
-        minDate
-        minDatePassed
         membership_pending
         limitDate
+        distanceE {
+          __typename
+          value {
+            __typename
+            ratio
+          }
+          dist_ok
+        }
         distance {
           __typename
           value {
@@ -254,6 +209,8 @@ fragment attr on Identity {
   uid
   hash
   status
+  minDate
+  minDatePassed
   quality {
     __typename
     ratio
diff --git a/i18n/locales/dateTimeFormats.js b/i18n/locales/dateTimeFormats.js
index 4f6948e..419d655 100644
--- a/i18n/locales/dateTimeFormats.js
+++ b/i18n/locales/dateTimeFormats.js
@@ -2,8 +2,8 @@ export const dateTimeFormats = {
     'fr': {
         short: {
             day: 'numeric',
-            month: 'long',
-            year: 'numeric'
+            month: 'short',
+            year: '2-digit'
         },
         long: {
             day: 'numeric',
@@ -17,8 +17,8 @@ export const dateTimeFormats = {
     'en': {
         short: {
             day: 'numeric',
-            month: 'long',
-            year: 'numeric'
+            month: 'short',
+            year: '2-digit'
         },
         long: {
             month: 'long',
@@ -32,8 +32,8 @@ export const dateTimeFormats = {
     'es': {
         short: {
             day: 'numeric',
-            month: 'long',
-            year: 'numeric'
+            month: 'short',
+            year: '2-digit'
         },
         long: {
             day: 'numeric',
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index 5449a41..ec79d38 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -16,9 +16,11 @@
         "datelimadhesion": "Membership deadline",
         "datelimrevoc" : "Deadline before revocation ",
         "datemanquecertifs": "Date before running out of certs",
+        "dispo": "Available",
         "dispocertif": "Available to certify",
         "distance": "Distance",
         "nb_certifs": "Nb of available certs",
+        "nodispo": "Unavailable",
         "qualite": "Quality",
         "referent": "Referent"
     },
@@ -38,6 +40,7 @@
         "title": "Your search"
     },
     "revoila": "Here they are again",
+    "slogan": "The Web of Trust’s wizard",
     "statut" : {
         "bientotmanquecertif": "Needs certifications soon",
         "manquecertif": "Needs certifications",
diff --git a/i18n/locales/es.json b/i18n/locales/es.json
index c3c419c..fc3654c 100644
--- a/i18n/locales/es.json
+++ b/i18n/locales/es.json
@@ -16,9 +16,11 @@
         "datelimadhesion": "Fecha límite de membresía",
         "datelimrevoc" : "Fecha límite de la autorevocación",
         "datemanquecertifs": "Fecha antes de quedarse sin certificaciones",
+        "dispo": "Disponible",
         "dispocertif": "Disponible para certificar",
         "distance": "Distancia",
         "nb_certifs": "Núm. de certificaciones disponibles",
+        "nodispo": "Indisponible",
         "qualite": "Calidad de enlace",
         "referent": "Referente o de control"
     },
@@ -38,6 +40,7 @@
         "title": "Buscar"
     },
     "revoila": "Regresan",
+    "slogan": "El mago de la Red de Confianza",
     "statut" : {
         "bientotmanquecertif": "Pronto necesitará certificaciones",
         "manquecertif": "Faltan certificaciones",
diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json
index 7b76b09..efb889a 100644
--- a/i18n/locales/fr.json
+++ b/i18n/locales/fr.json
@@ -16,9 +16,11 @@
         "datelimadhesion": "Date limite d'adhésion",
         "datelimrevoc" : "Date limite avant révocation ",
         "datemanquecertifs": "Date avant de manquer de certifs",
+        "dispo": "Disponible",
         "dispocertif": "Disponible pour certifier",
         "distance": "Distance",
         "nb_certifs": "Nbre de certifs disponibles",
+        "nodispo": "Indisponible",
         "qualite": "Qualité",
         "referent": "Référent"
     },
@@ -38,6 +40,7 @@
         "title": "Votre recherche"
     },
     "revoila": "Les revoilà",
+    "slogan": "Le magicien de la Toile de Confiance",
     "statut" : {
         "bientotmanquecertif": "Bientôt en manque de certifications",
         "manquecertif": "En manque de certifications",
diff --git a/layouts/default.vue b/layouts/default.vue
index 2252d3b..83dc434 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -13,15 +13,15 @@ export default {
       // Les title correspondent aux chaînes de traduction dans /i18n/locales
       menus : [
         {
-          title: 'previsions.title',
+          title: 'wot',
           items : [
-            {path: '/previsions/futurs_membres',title: 'futuremembers'}
+            {path: '/membres',title: 'membres'}
           ]
         },
         {
-          title: 'wot',
+          title: 'previsions.title',
           items : [
-            {path: '/membres',title: 'membres'}
+            {path: '/previsions/futurs_membres',title: 'futuremembers'}
           ]
         }
       ]
diff --git a/pages/membres/_hash.vue b/pages/membres/_hash.vue
index f7be2fb..d7d454f 100644
--- a/pages/membres/_hash.vue
+++ b/pages/membres/_hash.vue
@@ -12,14 +12,17 @@
           </div>
         </div>
         <div class="row mt-3" v-if="idFromHash.status != 'REVOKED'">
-          <div class="col-12 col-md-6 mb-3">
-            <h3>{{ $t('certifications.recues') }} ({{ idFromHash.received_certifications.certifications.length }})
+          <div class="col-sm-8 col-lg-5 mb-3 mx-auto">
+            <h3 class="h4" :class="{
+              'text-success' : ['NEWCOMER','MISSING'].includes(idFromHash.status) && idFromHash.received_certifications.certifications.length>=5,
+              'text-danger' : ['NEWCOMER','MISSING'].includes(idFromHash.status) && idFromHash.received_certifications.certifications.length<5,
+            }">{{ $t('certifications.recues') }} ({{ idFromHash.received_certifications.certifications.length }})
               <BadgeCertifStatus :limitDate="idFromHash.received_certifications.limit" :memberStatus="idFromHash.status" />
             </h3>
             <CertifList :certifs="idFromHash.received_certifications.certifications" type="received" />
           </div>
-          <div class="col-12 col-md-6">
-            <h3>{{ $t('certifications.envoyees') }} ({{ idFromHash.sent_certifications.length }})</h3>
+          <div class="col-sm-8 col-lg-5 mx-auto" v-if="['MISSING','MEMBER'].includes(idFromHash.status)">
+            <h3 class="h4">{{ $t('certifications.envoyees') }} ({{ idFromHash.sent_certifications.length }})</h3>
             <CertifList :certifs="idFromHash.sent_certifications" type="sent" />
           </div>
         </div>
diff --git a/pages/previsions/_hash.vue b/pages/previsions/_hash.vue
deleted file mode 100644
index d25fde5..0000000
--- a/pages/previsions/_hash.vue
+++ /dev/null
@@ -1,74 +0,0 @@
-<template>
-  <main class="content container">
-    <NavigationLoader :isLoading="$apollo.queries.idFromHash.loading" />
-    <transition name="fade">
-      <div class="alert alert-danger" v-if="error">{{ error }}</div>
-    </transition>
-    <transition name="fade">
-      <div v-if="idFromHash">
-        <div class="row">
-          <div class="col-md-10 col-lg-8 col-xl-6 mx-auto mt-3">
-            <h2 class="text-center mb-5 font-weight-light">Prévisions <small><span class="badge badge-secondary">{{ idFromHash.uid }}</span></small></h2>
-            <MemberCard :hash="idFromHash" />
-          </div>
-        </div>
-      </div>
-    </transition>
-  </main>
-</template>
-
-<script>
-import {PREVISION} from "@/graphql/queries"
-
-export default {
-  data() {
-    return {
-      breadcrumb: [
-        {
-          text: this.$t('accueil'),
-          to: '/'
-        },
-        {
-          text: this.$t('previsions.title'),
-          to: '/previsions'
-        },
-        {
-          text: '',
-          active: true
-        }
-      ],
-      error: null
-    };
-  },
-  apollo: {
-    idFromHash: {
-      query: PREVISION,
-      variables() {return { hash: this.$route.params.hash }},
-      error (err) {this.error = err.message}
-    },
-  },
-  nuxtI18n: {
-    paths: {
-      fr: '/previsions/:hash',
-      en: '/forecasts/:hash',
-      es: '/pronosticos/:hash'
-    }
-  },
-  computed: {
-    classWarning: function() {
-      return {
-        'text-danger' : !this.idFromHash.received_certifications.limit,
-        'text-warning' : this.$options.filters.dateStatus(this.idFromHash.received_certifications.limit) == 'warning'
-      }
-    }
-  },
-  watch: {
-    idFromHash: {
-      handler(n,o) {
-          this.breadcrumb[2].text = this.idFromHash.uid
-          $nuxt.$emit("changeRoute", this.breadcrumb);
-      }
-    }
-  }
-};
-</script>
\ No newline at end of file
diff --git a/pages/previsions/futurs_membres.vue b/pages/previsions/futurs_membres.vue
index 5d74fa1..8108d35 100644
--- a/pages/previsions/futurs_membres.vue
+++ b/pages/previsions/futurs_membres.vue
@@ -34,7 +34,7 @@
             <div class="table-responsive">
               <table class="table table-striped table-hover">
                 <tbody>
-                  <tr v-for="forecast in wwResult.forecastsByNames" :key="forecast.member.uid" @click="$router.push(localePath({name:'previsions-hash', params:{hash:forecast.member.hash}}))">
+                  <tr v-for="forecast in wwResult.forecastsByNames" :key="forecast.member.uid" @click="$router.push(localePath({name:'membres-hash', params:{hash:forecast.member.hash}}))">
                     <th scope="row">
                       {{ forecast.member.uid }}
                       <BadgeStatus :membre="forecast.member" />
@@ -59,7 +59,7 @@
                     <th scope="row">{{ $d(new Date(forecast.date*1000), 'long') }} {{ $t('time.a') }} {{ $d(new Date(forecast.date*1000), 'hour') }}</th>
                     <td class="p-0">
                       <div class="list-group rounded-0">
-                        <nuxt-link class="list-group-item list-group-item-action border-0 d-flex justify-content-between" :to="localePath('/previsions/' + member.member.hash)" v-for="member in forecast.forecasts" :key="member.member.uid">
+                        <nuxt-link class="list-group-item list-group-item-action border-0 d-flex justify-content-between" :to="localePath('/membres/' + member.member.hash)" v-for="member in forecast.forecasts" :key="member.member.uid">
                           <div>{{ member.member.uid }} <BadgeStatus :membre="member.member" /></div>
                           <div>{{ member.proba * 100 }} %</div>
                         </nuxt-link>
-- 
GitLab