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