2020-04-05 21:31:11 -04:00
|
|
|
<template>
|
2020-11-07 16:04:40 -05:00
|
|
|
<div class="heatmap-container">
|
2020-11-07 10:11:09 -05:00
|
|
|
<div v-show="isLoading">
|
|
|
|
<slot name="loading"/>
|
2020-04-05 21:31:11 -04:00
|
|
|
</div>
|
2020-11-07 16:04:40 -05:00
|
|
|
<div v-if="!isLoading" class="total-contributions">
|
|
|
|
{{ values.length }} contributions in the last 12 months
|
|
|
|
</div>
|
2020-11-07 10:11:09 -05:00
|
|
|
<calendar-heatmap
|
|
|
|
v-show="!isLoading"
|
|
|
|
:locale="locale"
|
|
|
|
:no-data-text="locale.no_contributions"
|
|
|
|
:tooltip-unit="locale.contributions"
|
|
|
|
:end-date="endDate"
|
|
|
|
:values="values"
|
|
|
|
:range-color="colorRange"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-04-05 21:31:11 -04:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import {CalendarHeatmap} from 'vue-calendar-heatmap';
|
|
|
|
const {AppSubUrl, heatmapUser} = window.config;
|
|
|
|
|
|
|
|
export default {
|
2020-11-07 10:11:09 -05:00
|
|
|
name: 'ActivityHeatmap',
|
|
|
|
components: {CalendarHeatmap},
|
|
|
|
data: () => ({
|
|
|
|
isLoading: true,
|
2020-11-07 16:04:40 -05:00
|
|
|
colorRange: [
|
|
|
|
'var(--color-secondary-alpha-70)',
|
|
|
|
'var(--color-primary-alpha-50)',
|
|
|
|
'var(--color-primary-alpha-60)',
|
|
|
|
'var(--color-primary-alpha-70)',
|
|
|
|
'var(--color-primary-alpha-80)',
|
|
|
|
'var(--color-primary)',
|
|
|
|
],
|
|
|
|
endDate: new Date(),
|
2020-11-07 10:11:09 -05:00
|
|
|
values: [],
|
|
|
|
locale: {
|
|
|
|
contributions: 'contributions',
|
|
|
|
no_contributions: 'No contributions',
|
2020-04-05 21:31:11 -04:00
|
|
|
},
|
2020-11-07 10:11:09 -05:00
|
|
|
}),
|
2020-11-07 16:04:40 -05:00
|
|
|
async mounted() {
|
|
|
|
const res = await fetch(`${AppSubUrl}/api/v1/users/${heatmapUser}/heatmap`);
|
|
|
|
const data = await res.json();
|
|
|
|
this.values = data.map(({contributions, timestamp}) => {
|
|
|
|
return {date: new Date(timestamp * 1000), count: contributions};
|
|
|
|
});
|
|
|
|
this.isLoading = false;
|
2020-11-07 10:11:09 -05:00
|
|
|
},
|
|
|
|
};
|
2020-04-05 21:31:11 -04:00
|
|
|
</script>
|
2020-11-07 10:11:09 -05:00
|
|
|
<style scoped/>
|