Verified Commit cac67268 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Added donation service filter

parent 2d9069c4
Pipeline #4237 passed with stages
in 1 minute and 24 seconds
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
<input v-model="maxDays" id="maxDays" placeholder="60" type="number" min="1" step="1" max="365" class="validate"> <input v-model="maxDays" id="maxDays" placeholder="60" type="number" min="1" step="1" max="365" class="validate">
<label class="active" for="maxDays">Period (in days)</label> <label class="active" for="maxDays">Period (in days)</label>
</div> </div>
<div class="input-field col l6">
<select multiple v-model="filters.providers">
<option value="" disabled selected>All</option>
<option v-for="provider in providers" :key="provider.id" :value="provider.id">{{ provider.label }}</option>
</select>
<label>Donation services</label>
</div>
</div> </div>
<div v-if="isLoading" class="progress"> <div v-if="isLoading" class="progress">
<div class="indeterminate"></div> <div class="indeterminate"></div>
...@@ -60,7 +67,7 @@ ...@@ -60,7 +67,7 @@
rel="noopener noreferrer" rel="noopener noreferrer"
:class="['waves-effect', 'waves-light', 'btn-small']"> :class="['waves-effect', 'waves-light', 'btn-small']">
<span :title="mean.summary">{{ mean.provider }}</span> <span :title="mean.summary">{{ mean.provider }}</span>
</a> </a>&nbsp;
</template> </template>
</div> </div>
...@@ -90,8 +97,10 @@ export default { ...@@ -90,8 +97,10 @@ export default {
retributeProfiles: this.$store.state.cache.retributeProfiles || {}, retributeProfiles: this.$store.state.cache.retributeProfiles || {},
loadingRetributeProfiles: [], loadingRetributeProfiles: [],
filters: { filters: {
retributeOnly: true retributeOnly: true,
} providers: [],
},
providers: this.$store.state.cache.providers || []
} }
}, },
computed: { computed: {
...@@ -109,7 +118,13 @@ export default { ...@@ -109,7 +118,13 @@ export default {
let suggestions = this.allSuggestions.filter((s) => { let suggestions = this.allSuggestions.filter((s) => {
let f = true let f = true
if (self.filters.retributeOnly != null) { if (self.filters.retributeOnly != null) {
f = !!this.retributeProfiles[s.fullId] === self.filters.retributeOnly f = f && !!this.retributeProfiles[s.fullId] === self.filters.retributeOnly
}
if (self.filters.providers.length > 0) {
let p = this.retributeProfiles[s.fullId]
f = f && p && p.means.filter((m) => {
return self.filters.providers.indexOf(m.provider) > -1
}).length > 0
} }
return f return f
}) })
...@@ -129,6 +144,7 @@ export default { ...@@ -129,6 +144,7 @@ export default {
this.isLoadingSources = false this.isLoadingSources = false
this.isLoadingRetribute = false this.isLoadingRetribute = false
this.results = {} this.results = {}
this.providers = null
this.aggregatedSuggestions = {} this.aggregatedSuggestions = {}
this.retributeProfiles = {} this.retributeProfiles = {}
this.loadingRetributeProfiles = {} this.loadingRetributeProfiles = {}
...@@ -161,9 +177,11 @@ export default { ...@@ -161,9 +177,11 @@ export default {
} else { } else {
accounts = this.accounts accounts = this.accounts
this.retributeProfiles = {} this.retributeProfiles = {}
this.providers = null
this.loadingRetributeProfiles = [] this.loadingRetributeProfiles = []
} }
this.isLoadingSources = true this.isLoadingSources = true
await this.fetchProviders()
accounts.forEach((a) => { accounts.forEach((a) => {
let r = {isLoading: true, progress: 'indeterminate', status: ''} let r = {isLoading: true, progress: 'indeterminate', status: ''}
let promise = a._source.fetch({account: a, store: this.$store, results: r, vue: this, maxDays: this.maxDays}) let promise = a._source.fetch({account: a, store: this.$store, results: r, vue: this, maxDays: this.maxDays})
...@@ -175,6 +193,12 @@ export default { ...@@ -175,6 +193,12 @@ export default {
} }
this.isLoadingSources = false this.isLoadingSources = false
}, },
async fetchProviders () {
const client = axios.create()
let url = config.RetributeAPIUrl + `v1/providers`
const response = await axios.get(url)
this.providers = response.data
},
async lookupAll () { async lookupAll () {
let self = this let self = this
const toLoad = this.missingRetributeProfiles.filter((p) => { const toLoad = this.missingRetributeProfiles.filter((p) => {
...@@ -265,6 +289,16 @@ export default { ...@@ -265,6 +289,16 @@ export default {
this.$store.commit('setRecursiveState', {key: 'cache.retributeProfiles', value: this.retributeProfiles}) this.$store.commit('setRecursiveState', {key: 'cache.retributeProfiles', value: this.retributeProfiles})
}, },
deep: true deep: true
},
providers: {
handler (v) {
this.$store.commit('setRecursiveState', {key: 'cache.providers', value: this.providers})
this.$nextTick(()=> {
let elems = document.querySelectorAll('select')
M.FormSelect.init(elems, {})
})
},
immediate: true
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment