2020-02-18 10:31:11 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkContainer :show-header="props.showHeader" :naked="props.transparent">
|
2021-04-20 14:22:59 +00: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 10:31:11 +00:00
|
|
|
|
2020-07-11 01:13:11 +00:00
|
|
|
<div>
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkLoading v-if="fetching"/>
|
2020-07-11 01:13:11 +00:00
|
|
|
<template v-else>
|
2020-10-17 11:12:00 +00:00
|
|
|
<XCalendar v-show="props.view === 0" :data="[].concat(activity)"/>
|
|
|
|
<XChart v-show="props.view === 1" :data="[].concat(activity)"/>
|
2020-07-11 01:13:11 +00:00
|
|
|
</template>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkContainer>
|
2020-02-18 10:31:11 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
2020-02-18 10:31:11 +00:00
|
|
|
import define from './define';
|
|
|
|
import XCalendar from './activity.calendar.vue';
|
|
|
|
import XChart from './activity.chart.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import * as os from '@client/os';
|
2020-02-18 10:31:11 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
const widget = define({
|
2020-02-18 10:31:11 +00:00
|
|
|
name: 'activity',
|
|
|
|
props: () => ({
|
2020-07-11 01:13:11 +00:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
|
|
|
transparent: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
type: 'number',
|
|
|
|
default: 0,
|
|
|
|
hidden: true,
|
|
|
|
},
|
2020-02-18 10:31:11 +00:00
|
|
|
})
|
2020-10-17 11:12:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-02-18 10:31:11 +00:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
XCalendar,
|
|
|
|
XChart,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
activity: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('charts/user/notes', {
|
2020-12-19 01:55:52 +00:00
|
|
|
userId: this.$i.id,
|
2020-02-18 10:31:11 +00: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-03 23:46:54 +00:00
|
|
|
if (this.props.view === 1) {
|
2020-02-18 10:31:11 +00:00
|
|
|
this.props.view = 0;
|
|
|
|
} else {
|
|
|
|
this.props.view++;
|
|
|
|
}
|
|
|
|
this.save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|