2020-02-18 12:31:11 +02:00
|
|
|
<template>
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkContainer :show-header="props.showHeader" :naked="props.transparent">
|
2021-04-20 17:22:59 +03:00
|
|
|
<template #header><i class="fas fa-chart-bar"></i>{{ $ts._widgets.activity }}</template>
|
|
|
|
<template #func><button @click="toggleView()" class="_button"><i class="fas fa-sort"></i></button></template>
|
2020-02-18 12:31:11 +02:00
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
<div>
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkLoading v-if="fetching"/>
|
2020-07-11 04:13:11 +03:00
|
|
|
<template v-else>
|
2020-10-17 14:12:00 +03:00
|
|
|
<XCalendar v-show="props.view === 0" :data="[].concat(activity)"/>
|
|
|
|
<XChart v-show="props.view === 1" :data="[].concat(activity)"/>
|
2020-07-11 04:13:11 +03:00
|
|
|
</template>
|
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkContainer>
|
2020-02-18 12:31:11 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
2020-02-18 12:31:11 +02:00
|
|
|
import define from './define';
|
|
|
|
import XCalendar from './activity.calendar.vue';
|
|
|
|
import XChart from './activity.chart.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2020-02-18 12:31:11 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const widget = define({
|
2020-02-18 12:31:11 +02:00
|
|
|
name: 'activity',
|
|
|
|
props: () => ({
|
2020-07-11 04:13:11 +03:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
transparent: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
hidden: true,
|
|
|
|
},
|
2020-02-18 12:31:11 +02:00
|
|
|
})
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-02-18 12:31:11 +02:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
XCalendar,
|
|
|
|
XChart,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
activity: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.api('charts/user/notes', {
|
2020-12-19 03:55:52 +02:00
|
|
|
userId: this.$i.id,
|
2020-02-18 12:31:11 +02:00
|
|
|
span: 'day',
|
|
|
|
limit: 7 * 21
|
|
|
|
}).then(activity => {
|
|
|
|
this.activity = activity.diffs.normal.map((_, i) => ({
|
|
|
|
total: activity.diffs.normal[i] + activity.diffs.reply[i] + activity.diffs.renote[i],
|
|
|
|
notes: activity.diffs.normal[i],
|
|
|
|
replies: activity.diffs.reply[i],
|
|
|
|
renotes: activity.diffs.renote[i]
|
|
|
|
}));
|
|
|
|
this.fetching = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleView() {
|
2020-04-04 02:46:54 +03:00
|
|
|
if (this.props.view === 1) {
|
2020-02-18 12:31:11 +02:00
|
|
|
this.props.view = 0;
|
|
|
|
} else {
|
|
|
|
this.props.view++;
|
|
|
|
}
|
|
|
|
this.save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|