Skip to content

Commit

Permalink
feat(client): Implement federation widget chart
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Jul 25, 2020
1 parent e1f2e36 commit bd54e44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
File renamed without changes.
20 changes: 11 additions & 9 deletions src/client/widgets/federation.vue
Expand Up @@ -5,12 +5,12 @@
<div class="wbrkwalb">
<mk-loading v-if="fetching"/>
<transition-group tag="div" name="chart" class="instances" v-else>
<div v-for="instance in instances" :key="instance.id">
<div v-for="(instance, i) in instances" :key="instance.id">
<div class="instance">
<a class="a" :href="'https://' + instance.host" target="_blank" :title="instance.host">#{{ instance.host }}</a>
<p>{{ instance.softwareName }} {{ instance.softwareVersion }}</p>
</div>
<!-- TODO: <x-chart class="chart" :src="stat.chart"/> -->
<mk-mini-chart class="chart" :src="charts[i].requests.received"/>
</div>
</transition-group>
</div>
Expand All @@ -21,7 +21,7 @@
import { faGlobe } from '@fortawesome/free-solid-svg-icons';
import MkContainer from '../components/ui/container.vue';
import define from './define';
import XChart from './trends.chart.vue';
import MkMiniChart from '../components/mini-chart.vue';
export default define({
name: 'federation',
Expand All @@ -33,11 +33,12 @@ export default define({
})
}).extend({
components: {
MkContainer, XChart
MkContainer, MkMiniChart
},
data() {
return {
instances: [],
charts: [],
fetching: true,
faGlobe
};
Expand All @@ -50,14 +51,15 @@ export default define({
clearInterval(this.clock);
},
methods: {
fetch() {
this.$root.api('federation/instances', {
async fetch() {
const instances = await this.$root.api('federation/instances', {
sort: '+lastCommunicatedAt',
limit: 5
}).then(instances => {
this.instances = instances;
this.fetching = false;
});
const charts = await Promise.all(instances.map(i => this.$root.api('charts/instance', { host: i.host, limit: 16, span: 'hour' })));
this.instances = instances;
this.charts = charts;
this.fetching = false;
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/client/widgets/trends.vue
Expand Up @@ -10,7 +10,7 @@
<router-link class="a" :to="`/tags/${ encodeURIComponent(stat.tag) }`" :title="stat.tag">#{{ stat.tag }}</router-link>
<p>{{ $t('nUsersMentioned', { n: stat.usersCount }) }}</p>
</div>
<x-chart class="chart" :src="stat.chart"/>
<mk-mini-chart class="chart" :src="stat.chart"/>
</div>
</transition-group>
</div>
Expand All @@ -21,7 +21,7 @@
import { faHashtag } from '@fortawesome/free-solid-svg-icons';
import MkContainer from '../components/ui/container.vue';
import define from './define';
import XChart from './trends.chart.vue';
import MkMiniChart from '../components/mini-chart.vue';
export default define({
name: 'hashtags',
Expand All @@ -33,7 +33,7 @@ export default define({
})
}).extend({
components: {
MkContainer, XChart
MkContainer, MkMiniChart
},
data() {
return {
Expand Down

0 comments on commit bd54e44

Please sign in to comment.