2020-04-06 04:31:11 +03:00
|
|
|
<template>
|
2020-11-08 00:04:40 +03:00
|
|
|
<div class="heatmap-container">
|
2020-11-07 18:11:09 +03:00
|
|
|
<div v-show="isLoading">
|
|
|
|
<slot name="loading"/>
|
2020-04-06 04:31:11 +03:00
|
|
|
</div>
|
2020-11-08 00:04:40 +03:00
|
|
|
<div v-if="!isLoading" class="total-contributions">
|
|
|
|
{{ values.length }} contributions in the last 12 months
|
|
|
|
</div>
|
2020-11-07 18:11:09 +03: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-06 04:31:11 +03:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import {CalendarHeatmap} from 'vue-calendar-heatmap';
|
|
|
|
const {AppSubUrl, heatmapUser} = window.config;
|
|
|
|
|
|
|
|
export default {
|
2020-11-07 18:11:09 +03:00
|
|
|
name: 'ActivityHeatmap',
|
|
|
|
components: {CalendarHeatmap},
|
|
|
|
data: () => ({
|
|
|
|
isLoading: true,
|
2020-11-08 00:04:40 +03:00
|
|
|
colorRange: [
|
|
|
|
'var(--color-secondary-alpha-70)',
|
2020-11-13 22:49:46 +03:00
|
|
|
'var(--color-primary-light-4)',
|
|
|
|
'var(--color-primary-light-2)',
|
2020-11-08 00:04:40 +03:00
|
|
|
'var(--color-primary)',
|
2020-11-13 22:49:46 +03:00
|
|
|
'var(--color-primary-dark-2)',
|
|
|
|
'var(--color-primary-dark-4)',
|
2020-11-08 00:04:40 +03:00
|
|
|
],
|
|
|
|
endDate: new Date(),
|
2020-11-07 18:11:09 +03:00
|
|
|
values: [],
|
|
|
|
locale: {
|
|
|
|
contributions: 'contributions',
|
|
|
|
no_contributions: 'No contributions',
|
2020-04-06 04:31:11 +03:00
|
|
|
},
|
2020-11-07 18:11:09 +03:00
|
|
|
}),
|
2020-11-08 00:04:40 +03: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 18:11:09 +03:00
|
|
|
},
|
|
|
|
};
|
2020-04-06 04:31:11 +03:00
|
|
|
</script>
|
2020-11-07 18:11:09 +03:00
|
|
|
<style scoped/>
|