diff --git a/components/badge/Date.vue b/components/badge/Date.vue index dccb6400457d32500e8acd34b0682781aa2019a3..c3f44dd7cc236953f3feb6b6423817d6b2f7ce7d 100644 --- a/components/badge/Date.vue +++ b/components/badge/Date.vue @@ -1,11 +1,9 @@ <template> <small> - <span - class="badge" - :class="'badge-' + $options.filters.dateStatus(date)"> - {{ $d(new Date(date * 1000), styleDate) }} - </span> - </small> + <span class="badge" :class="'badge-' + $options.filters.dateStatus(date)"> + {{ date == 0 ? "N/A" : $d(new Date(date * 1000), styleDate) }} + </span> + </small> </template> <script> @@ -18,7 +16,7 @@ export default { styleDate: { type: String, required: true - }, - } + } + } } </script> diff --git a/components/btn/Sort.vue b/components/btn/Sort.vue new file mode 100644 index 0000000000000000000000000000000000000000..c0609aad9fa2b5c93848bc891f69bffad1e24072 --- /dev/null +++ b/components/btn/Sort.vue @@ -0,0 +1,44 @@ +<template> + <div class="d-inline-block position-absolute ml-2"> + <div + class="up" + :class="{ + sorted: currentSortDir == 'desc' && currentSort == fieldName, + invisible: currentSortDir == 'asc' && currentSort == fieldName + }"> + â–² + </div> + <div + class="down" + :class="{ + sorted: currentSortDir == 'asc' && currentSort == fieldName, + invisible: currentSortDir == 'desc' && currentSort == fieldName + }"> + â–¼ + </div> + </div> +</template> +<script> +export default { + props: { + fieldName: { + type: String, + required: true + }, + currentSort: { + type: String, + required: true + }, + currentSortDir: { + type: String, + required: true, + validator: function (value) { + return ["asc", "desc"].indexOf(value) !== -1 + } + } + }, + created() { + console.log("created") + } +} +</script> diff --git a/components/certif/List.vue b/components/certif/List.vue index 9dd5e47adc589b6a863d42bc6ad48fe814983b1c..9e498f594b071f92c39054c77a6ca60e443a0c47 100644 --- a/components/certif/List.vue +++ b/components/certif/List.vue @@ -34,7 +34,7 @@ </div> </th> <td class="text-right py-1"> - <BadgeDate :date="certif.expires_on" :styleDate="'short'" /> + <BadgeDate :date="certif.expires_on" styleDate="short" /> <small class="d-block"> <span class="badge badge-secondary">{{ $t("traitement") }}</span> </small> @@ -49,47 +49,17 @@ <thead class="thead-light sortable"> <th class="position-relative" @click="sort('uid')"> {{ $t("membres") }} - <div class="d-inline-block position-absolute ml-2"> - <div - class="up" - :class="{ - sorted: currentSortDir == 'desc' && currentSort == 'uid', - invisible: currentSortDir == 'asc' && currentSort == 'uid' - }"> - â–² - </div> - <div - class="down" - :class="{ - sorted: currentSortDir == 'asc' && currentSort == 'uid', - invisible: currentSortDir == 'desc' && currentSort == 'uid' - }"> - â–¼ - </div> - </div> + <BtnSort + fieldName="uid" + :currentSort="currentSort" + :currentSortDir="currentSortDir" /> </th> <th class="position-relative" @click="sort('expires_on')"> {{ $t("expire") }} - <div class="d-inline-block position-absolute ml-2"> - <div - class="up" - :class="{ - sorted: currentSortDir == 'desc' && currentSort == 'expires_on', - invisible: - currentSortDir == 'asc' && currentSort == 'expires_on' - }"> - â–² - </div> - <div - class="down" - :class="{ - sorted: currentSortDir == 'asc' && currentSort == 'expires_on', - invisible: - currentSortDir == 'desc' && currentSort == 'expires_on' - }"> - â–¼ - </div> - </div> + <BtnSort + fieldName="expires_on" + :currentSort="currentSort" + :currentSortDir="currentSortDir" /> </th> </thead> <tbody> @@ -124,7 +94,7 @@ </div> </th> <td class="text-right py-1"> - <BadgeDate :date="certif.expires_on" :styleDate="'long'" /> + <BadgeDate :date="certif.expires_on" styleDate="long" /> </td> </tr> </tbody> @@ -186,6 +156,7 @@ export default { }, certifsPending() { return this.certifs + .slice() .sort((a, b) => a.expires_on - b.expires_on) .filter((el) => el.pending == true) .map((certif) => ({ diff --git a/components/member/List.vue b/components/member/List.vue index 2ac99d029d40af7865cfd1a455aa94b54fde269d..a35ff113e5cb0e30805db32d06bfd5c9f099049d 100644 --- a/components/member/List.vue +++ b/components/member/List.vue @@ -5,65 +5,32 @@ <tr> <th class="position-relative" scope="col" @click="sort('uid')"> UID - <div class="d-inline-block position-absolute ml-2"> - <div - class="up" - :class="{ - sorted: currentSortDir == 'desc' && currentSort == 'uid', - invisible: currentSortDir == 'asc' && currentSort == 'uid' - }"> - â–² - </div> - <div - class="down" - :class="{ - sorted: currentSortDir == 'asc' && currentSort == 'uid', - invisible: currentSortDir == 'desc' && currentSort == 'uid' - }"> - â–¼ - </div> - </div> + <BtnSort + fieldName="uid" + :currentSort="currentSort" + :currentSortDir="currentSortDir" /> </th> <th scope="col" - class="d-none d-xl-table-cell position-relative" - v-if="displayPubkey && !displayOnlyDate"> + class="d-none d-md-table-cell position-relative" + @click="sort('pubkey')" + v-if="displayPubkey"> {{ $t("cle.publique.title") }} - </th> - <th - scope="col" - class="d-none d-xl-table-cell position-relative" - @click="sort('limit_date')" - v-if="displayOnlyDate"> - {{ $t("limitDate") }} - <div class="d-inline-block position-absolute ml-2"> - <div - class="up" - :class="{ - sorted: - currentSortDir == 'desc' && currentSort == 'limit_date', - invisible: - currentSortDir == 'asc' && currentSort == 'limit_date' - }"> - â–² - </div> - <div - class="down" - :class="{ - sorted: - currentSortDir == 'asc' && currentSort == 'limit_date', - invisible: - currentSortDir == 'desc' && currentSort == 'limit_date' - }"> - â–¼ - </div> - </div> + <BtnSort + fieldName="pubkey" + :currentSort="currentSort" + :currentSortDir="currentSortDir" /> </th> <th scope="col" class="d-none d-sm-table-cell position-relative" + @click="sort('date_sortie')" v-if="displayDate"> {{ $t("membre.datelimpertestatut") }} + <BtnSort + fieldName="date_sortie" + :currentSort="currentSort" + :currentSortDir="currentSortDir" /> </th> </tr> </thead> @@ -78,26 +45,20 @@ :limitDate=" Math.min(member.received_certifications.limit, member.limitDate) " - :memberStatus="member.status" - v-if="!displayOnlyDate" /> - <BadgeStatus :membre="member" v-if="!displayOnlyDate" /> + :memberStatus="member.status" /> + <BadgeStatus :membre="member" /> </th> - <td class="d-none d-xl-table-cell" v-if="displayOnlyDate"> + <td class="d-none d-md-table-cell" v-if="displayPubkey"> + {{ member.pubkey.substring(0, 10) }} + </td> + <td class="d-none d-sm-table-cell" v-if="displayDate"> <BadgeDate :date=" - adhesion - ? member.limitDate - : member.received_certifications.limit + Math.min(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) }} + styleDate="long" + class="d-block text-center" /> </td> - <td - class="d-none d-sm-table-cell" - v-if="displayDate" - v-html="getDatePerteStatus(member)"></td> </tr> </tbody> </table> @@ -117,23 +78,16 @@ export default { type: Array, required: true }, - displayPubkey: { - type: Boolean, - default: true - }, + displayHead: { type: Boolean, default: true }, - displayDate: { + displayPubkey: { type: Boolean, default: true }, - displayOnlyDate: { - type: Boolean, - default: false - }, - adhesion: { + displayDate: { type: Boolean, default: true } @@ -144,19 +98,6 @@ export default { this.localePath({ name: "membres-hash", params: { hash } }) ) }, - getDatePerteStatus(member) { - let date = Math.min( - member.limitDate, - member.received_certifications.limit - ) - return date == 0 - ? "N/A" - : "<span class='badge badge-" + - this.$options.filters.dateStatus(date) + - "'>" + - this.$d(new Date(date * 1000), "long") + - "</span>" - }, sort(s) { if (s === this.currentSort) { this.currentSortDir = this.currentSortDir === "asc" ? "desc" : "asc" @@ -169,27 +110,27 @@ export default { return this.members.slice().sort((a, b) => { let modifier = this.currentSortDir === "desc" ? -1 : 1 - if (this.currentSort == "limit_date") { - if (this.adhesion) { - if (a["limitDate"] < b["limitDate"]) return -1 * modifier - if (a["limitDate"] > b["limitDate"]) return 1 * modifier - } else { - if ( - a["received_certifications"]["limit"] < - b["received_certifications"]["limit"] - ) - return -1 * modifier - if ( - a["received_certifications"]["limit"] > - b["received_certifications"]["limit"] - ) - return 1 * modifier - } - } else { + if (this.currentSort == "uid") { if (a["uid"].toLowerCase() < b["uid"].toLowerCase()) return -1 * modifier if (a["uid"].toLowerCase() > b["uid"].toLowerCase()) return 1 * modifier + } else if (this.currentSort == "pubkey") { + if (a["pubkey"].toLowerCase() < b["pubkey"].toLowerCase()) + return -1 * modifier + if (a["pubkey"].toLowerCase() > b["pubkey"].toLowerCase()) + return 1 * modifier + } else if (this.currentSort == "date_sortie") { + if ( + Math.min(a["limitDate"], a["received_certifications"]["limit"]) < + Math.min(b["limitDate"], b["received_certifications"]["limit"]) + ) + return -1 * modifier + if ( + Math.min(a["limitDate"], a["received_certifications"]["limit"]) > + Math.min(b["limitDate"], b["received_certifications"]["limit"]) + ) + return 1 * modifier } return 0 diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 5048a86ffe8937eaab90c4bfa5c2823737dba285..bb96d8ae5b691be3cdc0ed08a21862ba08ffe04f 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -62,10 +62,6 @@ "title": "Duniter" }, "expire": "Expires", - "error": { - "tooSmall": "{0} is too small. It must be between {1} and {2}. The value used is {1}", - "tooBig": "{0} is too big. It must be between {1} and {2}. The value used is {1}" - }, "favoris": { "enregistre": "Saved to favorites !", "none": "You don't have any favorites yet", @@ -79,7 +75,6 @@ "inpreparation": "In preparation", "jours": "0 days | 1 day | {n} days", "lexique": "Lexicon", - "limitDate": "Deadline", "membre": { "calculant": { "desc": "Member using his private key to forge blocks thanks to Duniter installed on a node accessible on the Internet network", diff --git a/i18n/locales/es.json b/i18n/locales/es.json index 30c63ce14a5ef31d6f62dd9c123fe24d33f8a90e..24591902be319196d2b4c20f23bf2b99ecf54a32 100644 --- a/i18n/locales/es.json +++ b/i18n/locales/es.json @@ -62,10 +62,6 @@ "title": "Duniter" }, "expire": "Expira el", - "error": { - "tooSmall": "{0} es demasiado pequeño. Debe estar entre {1} y {2}. El valor utilizado es {1}", - "tooBig": "{0} es demasiado grande. Debe estar entre {1} y {2}. El valor utilizado es {1}" - }, "favoris": { "enregistre": "¡Guardado en favoritos!", "none": "Aún no tienes favoritos", @@ -79,7 +75,6 @@ "inpreparation": "En preparación", "jours": "0 dÃas | 1 dÃa | {n} dÃas", "lexique": "Léxico", - "limitDate": "Fecha lÃmite", "membre": { "calculant": { "desc": "Miembro usando su clave privada para falsificar bloques gracias a Duniter instalado en un nodo accesible en la red de Internet", diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json index 131ea07c4df9577d70811a3353fdd92fc249d317..cae2dd1481efbd298ab09da79e6595d6f2a6256f 100644 --- a/i18n/locales/fr.json +++ b/i18n/locales/fr.json @@ -62,10 +62,6 @@ "title": "Duniter" }, "expire": "Expire le", - "error": { - "tooSmall": "{0} est trop petit. Il doit être compris entre {1} et {2}. La valeur utilisée est {1}", - "tooBig": "{0} est trop grand. Il doit être compris entre {1} et {2}. La valeur utilisée est {2}" - }, "favoris": { "enregistre": "Enregistré dans les favoris !", "none": "Vous n'avez pas encore de favoris", @@ -79,7 +75,6 @@ "inpreparation": "En préparation", "jours": "0 jours | 1 jour | {n} jours", "lexique": "Lexique", - "limitDate": "Date limite", "membre": { "calculant": { "desc": "Membre utilisant sa clé privée pour forger des blocs grâce à Duniter installé sur un noeud accessible sur le réseau Internet", diff --git a/pages/membres/index.vue b/pages/membres/index.vue index 47ef31c382af29245a5a49003b762b6d43a20e49..480e75fc65181ff0acad38bef1b0c1ac64050ea8 100644 --- a/pages/membres/index.vue +++ b/pages/membres/index.vue @@ -28,7 +28,7 @@ idSearch && param.length > 2 && !$apollo.queries.idSearch.loading "> <div class="col-8 m-auto"> - <MemberList :members="idSearch.ids" /> + <MemberList :members="idSearch.ids" :displayDate="false" /> </div> </div> </transition> diff --git a/pages/previsions/futures_sorties.vue b/pages/previsions/futures_sorties.vue index fbe498996679885349f33debc7a0d6d97a6c0132..41c10694c961c691dd6f2b4b047e48703a5936aa 100644 --- a/pages/previsions/futures_sorties.vue +++ b/pages/previsions/futures_sorties.vue @@ -6,7 +6,6 @@ <label for="period" class="form-label">{{ $t("previsions.period.title") }}</label> - <select class="form-control" id="period" @@ -17,7 +16,6 @@ {{ $tc("jours", index) }} </option> </select> - <small id="periodHelp" class="form-text text-muted">{{ $t("previsions.period.desc") }}</small> @@ -38,20 +36,15 @@ <h2 class="h4 text-danger text-center">{{ $t("statut.renew") }}</h2> <MemberList :members="wwResult['membership']" - :displayPubkey="false" - :displayOnlyDate="true" - :displayDate="false" /> + :displayPubkey="false" /> </div> <div class="col-md-6 col-lg-6"> <h2 class="h4 text-danger text-center"> - {{ $t("statut.manquecertif") }} + {{ $t("statut.bientotmanquecertif") }} </h2> <MemberList :members="wwResult['outOfCerts']" - :displayPubkey="false" - :displayOnlyDate="true" - :displayDate="false" - :adhesion="false" /> + :displayPubkey="false" /> </div> </div> </div> @@ -83,14 +76,12 @@ export default { } ], error: null, - period: 30, - display: "forecastsByNames" + period: 30 } }, methods: { save() { this.error = null - localStorage.setItem("previsions_sorties", this.display) localStorage.setItem("previsions_period", this.getPeriod() / day) }, addValue(arr, val) { @@ -128,25 +119,26 @@ export default { update(data) { let result = { membership: [], outOfCerts: [] } - for (let i = 0; i < data.memEnds.length; i++) { - let identity = data.memEnds[i] + data.memEnds.forEach((member) => { if ( ["danger", "warning"].includes( - this.$options.filters.dateStatus(identity.limitDate) + this.$options.filters.dateStatus(member.limitDate) ) ) { - this.addValue(result["membership"], identity) + result.membership.push(member) } + if ( ["danger", "warning"].includes( this.$options.filters.dateStatus( - identity.received_certifications.limit + member.received_certifications.limit ) ) ) { - this.addValue(result["outOfCerts"], identity) + result.outOfCerts.push(member) } - } + }) + return result }, error(err) { @@ -164,7 +156,6 @@ export default { mounted() { $nuxt.$emit("changeRoute", this.breadcrumb) if (localStorage.previsions_sorties) { - this.display = localStorage.getItem("previsions_sorties") this.period = localStorage.getItem("previsions_period") } } diff --git a/plugins/filters.js b/plugins/filters.js index 1654212a42b4033f0edbc265e390b44a38c6ac81..97e8c7163bdf7fa503f2e7231601b87f85c48a44 100644 --- a/plugins/filters.js +++ b/plugins/filters.js @@ -1,13 +1,14 @@ -import Vue from 'vue' +import Vue from "vue" -Vue.filter('dateStatus', (val) => { - const diff = val - (Date.now() / 1000) - switch (true) { - case diff < 0: - return 'danger' - case diff < 2635200: - return 'warning' - case diff >= 2635200: - return 'success' - } -}) \ No newline at end of file +Vue.filter("dateStatus", (val) => { + if (val == 0) return "info" + const diff = val - Date.now() / 1000 + switch (true) { + case diff < 0: + return "danger" + case diff < 2635200: + return "warning" + case diff >= 2635200: + return "success" + } +})