Verified Commit 34a14ae4 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Added tooltip with score detail

parent 3aa54a83
Pipeline #4232 passed with stages
in 1 minute and 27 seconds
......@@ -40,7 +40,11 @@
<li class="collection-item avatar" v-for="suggestion in filteredSuggestions" :key="suggestion.fullId">
<img v-if="suggestion.avatar" :src="suggestion.avatar" alt="" class="circle">
<a target="_blank" rel="noopener noreferrer" :href="suggestion.url" class="title">{{ suggestion.name }}</a>
<p>Score: {{ suggestion.weight }}</p>
<br>
<span class="tooltipped" v-tooltip :data-tooltip="getScoreTooltip(suggestion)">
Weight: {{ suggestion.weight }}
<i class="tiny material-icons">help</i>
</span>
<a v-if="retributeProfiles[suggestion.fullId] === undefined" @click="lookup(suggestion.fullId)" class="secondary-content"><i class="material-icons">search</i></a>
<div v-else-if="retributeProfiles[suggestion.fullId]">
<h6>Donation platforms</h6>
......@@ -225,6 +229,21 @@ export default {
this.$set(this.retributeProfiles, id, null)
}
pull(this.loadingRetributeProfiles, [id])
},
getScoreTooltip (suggestion) {
let detailPerSource = Object.entries(suggestion.detail || {}).map((e) => {
let s = sources.sources[e[0]]
if (!e[1]) {
return
}
return s.getDetailMessage(e[1])
}).filter((d) => {
return !!d
}).map((d) => {
return `- ${d}`
})
let detail = detailPerSource.join('<br>')
return `Weight is computed based on your interactions with this creator's content:<br>${detail}`
}
},
watch: {
......
import Vue from 'vue'
Vue.directive('tooltip', {
inserted: function (el) {
let elems = document.querySelectorAll('.tooltipped')
M.Tooltip.init(elems, {})
}
})
......@@ -4,8 +4,11 @@ import router from './router'
import store from './store'
import "materialize-css/dist/css/materialize.min.css"
import "materialize-css/dist/js/materialize.js"
import "material-icons/iconfont/material-icons.css"
import "@/directives"
Vue.config.productionTip = false
new Vue({
......
......@@ -2,6 +2,7 @@ import axios from 'axios'
import moment from 'moment'
import Form from '../components/MastodonForm.vue'
import parseLink from 'parse-link-header'
import get from 'lodash/get'
export const SCOPES = "read:accounts read:favourites read:follows"
......@@ -110,8 +111,23 @@ export default {
let account = `webfinger:${f.account.acct}`
if (results.accounts[account]) {
results.accounts[account].weight += 1
let detail = get(results.accounts[account], 'detail', {})
let mastodonDetail = get(detail, 'mastodon', {favorites: 0})
mastodonDetail.favorites += 1
} else {
results.accounts[account] = {weight: 1, source: 'webfinger', id: f.account.acct, avatar: f.account.avatar, name: f.account.display_name, url: f.account.url}
results.accounts[account] = {
weight: 1,
source: 'webfinger',
id: f.account.acct,
avatar: f.account.avatar,
name: f.account.display_name,
url: f.account.url,
detail: {
mastodon: {
favorites: 1
}
}
}
}
// results.progress = Math.min(100, handledFavorites / maxFavorites * 100)
})
......@@ -126,5 +142,12 @@ export default {
}
results.isLoading = false
return results
},
getDetailMessage (detail) {
if (!detail) {
return
}
let favorites = detail.favorites || 0
return `Mastodon: ${favorites} favorites`
}
}
Markdown is supported
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