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