Skip to content
Snippets Groups Projects
Commit 593f092c authored by Benoît Besnard's avatar Benoît Besnard
Browse files

Add period parameter

parent b7d42203
No related branches found
No related tags found
1 merge request!5Ajout d'une page de prévisions de sorties
......@@ -62,6 +62,10 @@
"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",
......@@ -152,6 +156,10 @@
"previsions": {
"pardate": "Forecasts by dates",
"parmembre": "Forecasts by members",
"period": {
"title": "Search period",
"desc": "Select the desired number of days between 1 and 30"
},
"title": "Forecasts"
},
"pubkey": "Public key",
......
......@@ -62,6 +62,10 @@
"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",
......@@ -152,6 +156,10 @@
"previsions": {
"pardate": "Previsiones por fecha",
"parmembre": "Previsiones por miembros",
"period": {
"title": "Período de búsqueda",
"desc": "Seleccione el número de días deseado entre 1 y 30"
},
"title": "Pronósticos"
},
"pubkey": "Llave pública",
......
......@@ -62,6 +62,10 @@
"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",
......@@ -152,6 +156,10 @@
"previsions": {
"pardate": "Prévisions par date",
"parmembre": "Prévisions par membres",
"period": {
"title": "Période de recherche",
"desc": "Sélectionnez le nombre de jours souhaités entre 1 et 30"
},
"title": "Prévisions"
},
"pubkey": "Clef publique",
......
<template>
<main class="container">
<h2 class="text-center my-5 font-weight-light">{{ $t("futureexits") }}</h2>
<div class="row mb-4">
<div class="col-6 m-auto text-center">
<label for="period" class="form-label">{{ $t("previsions.period.title") }}</label>
<input
type="number"
class="form-control"
:class="{ invalid:periodIsInvalid() }"
id="period"
aria-describedby="periodHelp"
v-model="period"
autocomplete="off"
min="1" max="30"
@keyup="save" />
<small id="periodHelp" class="form-text text-muted">{{ $t("previsions.period.desc") }}</small>
</div>
</div>
<NavigationLoader :isLoading="$apollo.queries.wwResult.loading" />
<transition name="fade">
<div class="alert alert-danger" v-if="error">{{ error }}</div>
<div class="alert alert-danger" v-if="error && !$apollo.queries.wwResult.loading">{{ error }}</div>
</transition>
<transition name="fade">
<div v-if="wwResult">
<h2 class="text-center my-5 font-weight-light">{{ $t("futureexits") }}</h2>
<div v-if="wwResult && !$apollo.queries.wwResult.loading">
<div class="row text-center">
<div class="col-md-6 col-lg-6">
<h2 class="h4 text-danger">{{ $t("statut.renew") }}</h2>
......@@ -34,34 +50,38 @@
<script>
import { NEXT_EXITS } from "@/graphql/queries.js"
const defaultPeriod = 30*24*60*60;
const day = 24*60*60
const defaultPeriod = 30*day
export default {
data() {
return {
breadcrumb: [
{
text: this.$t('accueil'),
to: '/'
},
{
text: this.$t('previsions.title'),
to: '/previsions'
},
{
text: this.$t('futureexits'),
active: true
data() {
return {
breadcrumb: [
{
text: this.$t('accueil'),
to: '/'
},
{
text: this.$t('previsions.title'),
to: '/previsions'
},
{
text: this.$t('futureexits'),
active: true
}
],
error: null,
period: 30,
display: 'forecastsByNames'
}
],
error: null,
display: 'forecastsByNames'
}
},
methods: {
save() {
localStorage.setItem('previsions_sorties', this.group)
},
addValue(arr, val) {
methods: {
save() {
this.error = null
localStorage.setItem('previsions_sorties', this.display)
localStorage.setItem('previsions_period', this.getPeriod()/day)
},
addValue(arr, val) {
if (
arr.filter(function (e) {
return e.uid === val.uid
......@@ -70,57 +90,80 @@ export default {
arr.push(val)
}
return arr
},
getPeriod() {
if( this.period != "") {
let tempPeriod = parseInt(this.period)
if(tempPeriod < 1) {
this.error = this.$t("error.tooSmall", [ tempPeriod, 1, 30 ])
return day
}
if(tempPeriod > 30) {
this.error = this.$t('error.tooBig', [ tempPeriod, 1, 30 ])
return 30 * day
}
return this.period*day
}
return defaultPeriod
},
periodIsInvalid() {
return this.period != "" && (this.period < 1 || this.period > 30)
}
},
apollo: {
wwResult : {
query: NEXT_EXITS,
},
apollo: {
wwResult : {
query: NEXT_EXITS,
variables() {
return { period: defaultPeriod }
return { period: this.getPeriod()}
},
update (data) {
let result = { membership: [], outOfCerts: [] }
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)
}
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')
this.period = localStorage.getItem('previsions_period')
}
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);
}
background: transparent;
&:hover {
background: rgba(0, 0, 255, 0.075);
color: var(--text-primary-color);
}
}
.forecast_date {
min-width: 150px;
min-width: 150px;
}
.invalid {
border: 4px solid #ec0404;
}
</style>
\ No newline at end of file
</style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment