mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
.
This commit is contained in:
@@ -1,34 +1,19 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import DateService, { type Slice } from '@services/DateService';
|
||||
|
||||
const data = ref<number[]>([]);
|
||||
const labels = ref<string[]>([]);
|
||||
const ready = ref<boolean>(false);
|
||||
const props = defineProps<{ slice: SliceName, referrer: string }>();
|
||||
|
||||
const activeProject = useActiveProject();
|
||||
const props = defineProps<{ slice: Slice, referrer: string }>();
|
||||
|
||||
async function loadData() {
|
||||
|
||||
const response = await $fetch(`/api/metrics/${activeProject.value?._id.toString()}/timeline/referrers`, {
|
||||
method: 'POST',
|
||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({
|
||||
slice: 'hour',
|
||||
from: Date.now() - 1000 * 60 * 60 * 12,
|
||||
to: Date.now(),
|
||||
referrer: props.referrer
|
||||
})
|
||||
});
|
||||
|
||||
const response = await useReferrersTimeline(props.referrer, props.slice);
|
||||
if (!response) return;
|
||||
|
||||
data.value = response.map(e => e.count);
|
||||
labels.value = response.map(e => dayjs(e._id).locale(navigator.language));
|
||||
labels.value = response.map(e => DateService.getChartLabelFromISO(e._id, navigator.language, props.slice));
|
||||
ready.value = true;
|
||||
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
Reference in New Issue
Block a user