diff --git a/components/badge/Date.vue b/components/badge/Date.vue new file mode 100644 index 0000000000000000000000000000000000000000..dccb6400457d32500e8acd34b0682781aa2019a3 --- /dev/null +++ b/components/badge/Date.vue @@ -0,0 +1,24 @@ +<template> + <small> + <span + class="badge" + :class="'badge-' + $options.filters.dateStatus(date)"> + {{ $d(new Date(date * 1000), styleDate) }} + </span> + </small> +</template> + +<script> +export default { + props: { + date: { + type: Number, + required: true + }, + styleDate: { + type: String, + required: true + }, + } +} +</script> diff --git a/components/certif/List.vue b/components/certif/List.vue index 0d83217a08755d9aa7d5061b4c8bbee5d8a13e18..ef7285939d49dad6a231381f3ef00ec95e95ffaf 100644 --- a/components/certif/List.vue +++ b/components/certif/List.vue @@ -34,20 +34,12 @@ </div> </th> <td class="text-right py-1"> - <small - ><span - class="badge" - :class=" - 'badge-' + $options.filters.dateStatus(certif.expires_on) - " - >{{ $d(new Date(certif.expires_on * 1000), "short") }}</span - ></small - > - <small class="d-block" - ><span class="badge badge-secondary">{{ - $t("traitement") - }}</span></small - > + <BadgeDate + :date="certif.expires_on" + :styleDate="'short'" /> + <small class="d-block"> + <span class="badge badge-secondary">{{ $t("traitement")}}</span> + </small> </td> </tr> </tbody> @@ -134,15 +126,9 @@ </div> </th> <td class="text-right py-1"> - <small - ><span - class="badge" - :class=" - 'badge-' + $options.filters.dateStatus(certif.expires_on) - " - >{{ $d(new Date(certif.expires_on * 1000), "long") }}</span - ></small - > + <BadgeDate + :date="certif.expires_on" + :styleDate="'long'" /> </td> </tr> </tbody> diff --git a/components/member/List.vue b/components/member/List.vue index c6137ee28e32a2896c24ba987d4b087ea325d5f7..9eb49d6007292b5825d20305651f3704d54ea5ea 100644 --- a/components/member/List.vue +++ b/components/member/List.vue @@ -23,9 +23,15 @@ :limitDate=" Math.min(member.received_certifications.limit, member.limitDate) " - :memberStatus="member.status" /> - <BadgeStatus :membre="member" /> + :memberStatus="member.status" + v-if="!displayOnlyDate" /> + <BadgeStatus :membre="member" v-if="!displayOnlyDate"/> </th> + <td class="d-none d-xl-table-cell" v-if="displayOnlyDate"> + <BadgeDate + :date="adhesion ? member.limitDate : member.received_certifications.limit" + :styleDate="'long'" /> + </td> <td class="d-none d-xl-table-cell" v-if="displayPubkey"> {{ member.pubkey.substring(0, 10) }} </td> @@ -57,7 +63,15 @@ export default { displayDate: { type: Boolean, default: true - } + }, + displayOnlyDate: { + type: Boolean, + default: false + }, + adhesion: { + type: Boolean, + default: true + }, }, methods: { redirect(hash) { diff --git a/graphql/doc/graphQLschema.txt b/graphql/doc/graphQLschema.txt index a4ce243ccb6e89b62c274c3c6a4fe0943bd8558d..bfa30d15060df51340fb233c1474d26bb420f0a6 100644 --- a/graphql/doc/graphQLschema.txt +++ b/graphql/doc/graphQLschema.txt @@ -595,7 +595,7 @@ type Forecast { "Entry or exit of an identity" type EventId { - id: Identity! + member: Identity! "Entry or exit; true if entry" inOut: Boolean! diff --git a/graphql/queries.js b/graphql/queries.js index 3585f5be469180649efb8a69e8a48d8b4518cc70..1aae22226bd331751aad2f95e26e1c6329d6c4e0 100644 --- a/graphql/queries.js +++ b/graphql/queries.js @@ -206,3 +206,21 @@ export const FAVORIS = gql` } } ` + +// Pour la page index +export const NEXT_EXITS = gql` + query NextExits($group: [String!], $start: Int64, $period: Int64) { + memEnds (group: $group, startFromNow: $start, period: $period) { + __typename + pubkey + uid + status + hash + limitDate + received_certifications { + __typename + limit + } + } + } +` diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 2d2967b2de30b0f203fd033b80171ccdb3ca5c63..a93e474fa2872f412ed37cce81742a22c60cf36c 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -69,6 +69,7 @@ "title": "My favourites" }, "futuremembers": "Future members", + "futureexits": "Future exits", "infos": "Informations", "inout": "Entries and exits of the web of trust for the last 2 days", "inpreparation": "In preparation", diff --git a/i18n/locales/es.json b/i18n/locales/es.json index 158f517d3b89e09cabd5c032f4d7f265bbdfe0df..85558b452d4f7bcfd99d6dc73a8a738e642171be 100644 --- a/i18n/locales/es.json +++ b/i18n/locales/es.json @@ -69,6 +69,7 @@ "title": "Mis favoritos" }, "futuremembers": "Futuros miembros", + "futureexits": "Futuras salidas", "infos": "Informaciones", "inout": "Entradas y salidas de la red de confianza en los últimos 2 dÃas", "inpreparation": "En preparación", diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json index 043e0e242e2c05130a71c39a1b7468bcced64a64..03f2185606d1dd561e7dad8158d9a92faca3c597 100644 --- a/i18n/locales/fr.json +++ b/i18n/locales/fr.json @@ -69,6 +69,7 @@ "title": "Mes favoris" }, "futuremembers": "Futurs membres", + "futureexits": "Futures sorties", "infos": "Informations", "inout": "Entrées et sorties de la toile de confiance des 2 derniers jours", "inpreparation": "En préparation", diff --git a/layouts/default.vue b/layouts/default.vue index 651572ffc0ca15a236d8ca5dedb4809645c36ad2..6061a0cbb5811cd2db9e76f7b7760d9697f4143c 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -21,7 +21,10 @@ export default { }, { title: "previsions.title", - items: [{ path: "/previsions", title: "futuremembers" }] + items: [ + { path: "/previsions", title: "futuremembers" }, + { path: "/previsions/futures_sorties", title: "futureexits" }, + ] }, { title: "infos", diff --git a/pages/previsions/futures_sorties.vue b/pages/previsions/futures_sorties.vue new file mode 100644 index 0000000000000000000000000000000000000000..333d95f486b34646b0c43f6a1b0f26eb302b363c --- /dev/null +++ b/pages/previsions/futures_sorties.vue @@ -0,0 +1,128 @@ +<template> + <main class="container"> + <NavigationLoader :isLoading="$apollo.queries.wwResult.loading" /> + <transition name="fade"> + <div class="alert alert-danger" v-if="error">{{ error }}</div> + </transition> + <transition name="fade"> + <div v-if="wwResult"> + <h2 class="text-center my-5 font-weight-light">{{ $t("futureexits") }}</h2> + <div class="row text-center"> + <div class="col-md-6 col-lg-6"> + <h2 class="h4 text-danger">{{ $t("statut.renew") }}</h2> + <MemberList + :members="wwResult['membership']" + :displayPubkey="false" + :displayHead="false" + :displayOnlyDate="true" + :displayDate="false" /> + </div> + <div class="col-md-6 col-lg-6"> + <h2 class="h4 text-danger">{{ $t("statut.manquecertif") }}</h2> + <MemberList + :members="wwResult['outOfCerts']" + :displayPubkey="false" + :displayHead="false" + :displayOnlyDate="true" + :displayDate="false" + :adhesion="false" /> + </div> + </div> + </div> + </transition> + </main> +</template> + +<script> +import { NEXT_EXITS } from "@/graphql/queries.js" + +const defaultPeriod = 30*24*60*60; + +export default { + data() { + return { + breadcrumb: [ + { + text: this.$t('accueil'), + to: '/' + }, + { + text: this.$t('previsions.title'), + to: '/previsions' + }, + { + text: this.$t('futureexits'), + active: true + } + ], + error: null, + display: 'forecastsByNames' + } + }, + methods: { + save() { + localStorage.setItem('previsions_sorties', this.group) + }, + addValue(arr, val) { + if ( + arr.filter(function (e) { + return e.uid === val.uid + }).length == 0 + ) { + arr.push(val) + } + return arr + } + }, + apollo: { + wwResult : { + query: NEXT_EXITS, + variables() { + return { period: defaultPeriod } + }, + update (data) { + let result = { membership: [], outOfCerts: [] } + + for (let i = 0; i < data.memEnds.length; i++) { + let identity = data.memEnds[i] + if(['danger', 'warning'].includes(this.$options.filters.dateStatus(identity.limitDate))) { + this.addValue(result["membership"], identity) + } + if(['danger', 'warning'].includes(this.$options.filters.dateStatus(identity.received_certifications.limit))) { + this.addValue(result["outOfCerts"], identity) + } + } + return result + }, + error (err) {this.error = err.message} + } + }, + nuxtI18n: { + paths: { + fr: '/previsions/futures_sorties', + en: '/forecasts/future_exits', + es: '/pronosticos/futuras_salidas' + } + }, + mounted () { + $nuxt.$emit('changeRoute',this.breadcrumb) + if (localStorage.previsions_sorties) { + this.display = localStorage.getItem('previsions_sorties') + } + } +} +</script> + +<style lang="scss" scoped> +.list-group-item { + background: transparent; + &:hover { + background: rgba(0, 0, 255, 0.075); + color: var(--text-primary-color); + } +} + +.forecast_date { + min-width: 150px; +} +</style> \ No newline at end of file