mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-08 03:28:36 +00:00
fix/feat: primary photo auto set and auto-set primary photo (#651)
* fix error when item doesn't have photo attachment
* automatically detect image types and set primary photo if first
* remove charts.js from libs
Former-commit-id: 321a83b634
This commit is contained in:
parent
bd1a241be1
commit
81e76d9dd4
13 changed files with 41 additions and 424 deletions
|
@ -1,71 +0,0 @@
|
|||
import { TChartData } from "vue-chartjs/dist/types";
|
||||
import { UserClient } from "~~/lib/api/user";
|
||||
|
||||
export function purchasePriceOverTimeChart(api: UserClient) {
|
||||
const { data: timeseries } = useAsyncData(async () => {
|
||||
const { data } = await api.stats.totalPriceOverTime();
|
||||
return data;
|
||||
});
|
||||
|
||||
const primary = useCssVar("--p");
|
||||
|
||||
return computed(() => {
|
||||
if (!timeseries.value) {
|
||||
return {
|
||||
labels: ["Purchase Price"],
|
||||
datasets: [
|
||||
{
|
||||
label: "Purchase Price",
|
||||
data: [],
|
||||
backgroundColor: primary.value,
|
||||
borderColor: primary.value,
|
||||
},
|
||||
],
|
||||
} as TChartData<"line", number[], unknown>;
|
||||
}
|
||||
|
||||
let start = timeseries.value?.valueAtStart;
|
||||
|
||||
return {
|
||||
labels: timeseries?.value.entries.map(t => new Date(t.date).toDateString()) || [],
|
||||
datasets: [
|
||||
{
|
||||
label: "Purchase Price",
|
||||
data:
|
||||
timeseries.value?.entries.map(t => {
|
||||
start += t.value;
|
||||
return start;
|
||||
}) || [],
|
||||
backgroundColor: primary.value,
|
||||
borderColor: primary.value,
|
||||
},
|
||||
],
|
||||
} as TChartData<"line", number[], unknown>;
|
||||
});
|
||||
}
|
||||
|
||||
export function inventoryByLocationChart(api: UserClient) {
|
||||
const { data: donutSeries } = useAsyncData(async () => {
|
||||
const { data } = await api.stats.locations();
|
||||
return data;
|
||||
});
|
||||
|
||||
const primary = useCssVar("--p");
|
||||
const secondary = useCssVar("--s");
|
||||
const neutral = useCssVar("--n");
|
||||
|
||||
return computed(() => {
|
||||
return {
|
||||
labels: donutSeries.value?.map(l => l.name) || [],
|
||||
datasets: [
|
||||
{
|
||||
label: "Value",
|
||||
data: donutSeries.value?.map(l => l.total) || [],
|
||||
backgroundColor: [primary.value, secondary.value, neutral.value],
|
||||
borderColor: [primary.value, secondary.value, neutral.value],
|
||||
hoverOffset: 4,
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
}
|
|
@ -22,55 +22,11 @@
|
|||
|
||||
const itemTable = itemsTable(api);
|
||||
const stats = statCardData(api);
|
||||
|
||||
// const purchasePriceOverTime = purchasePriceOverTimeChart(api);
|
||||
|
||||
// const inventoryByLocation = inventoryByLocationChart(api);
|
||||
|
||||
// const refDonutEl = ref<HTMLDivElement>();
|
||||
|
||||
// const donutElWidth = computed(() => {
|
||||
// return refDonutEl.value?.clientWidth || 0;
|
||||
// });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<BaseContainer class="flex flex-col gap-12 pb-16">
|
||||
<!-- <section class="grid grid-cols-6 gap-6">
|
||||
<article class="col-span-4">
|
||||
<Subtitle> Inventory Value Over Time </Subtitle>
|
||||
<BaseCard>
|
||||
<div class="p-10 h-[300px]">
|
||||
<ClientOnly>
|
||||
<ChartLine :chart-data="purchasePriceOverTime" />
|
||||
</ClientOnly>
|
||||
</div>
|
||||
</BaseCard>
|
||||
</article>
|
||||
<article class="col-span-2">
|
||||
<Subtitle>
|
||||
Inventory By
|
||||
<span class="btn-group">
|
||||
<button class="btn btn-xs btn-active text-no-transform">Locations</button>
|
||||
<button class="btn btn-xs text-no-transform">Labels</button>
|
||||
</span>
|
||||
</Subtitle>
|
||||
<BaseCard class="h-[300px]">
|
||||
<div ref="refDonutEl" class="grid place-content-center h-full">
|
||||
<ClientOnly>
|
||||
<ChartDonut
|
||||
chart-id="donut"
|
||||
:width="donutElWidth - 50"
|
||||
:height="265"
|
||||
:chart-data="inventoryByLocation"
|
||||
/>
|
||||
</ClientOnly>
|
||||
</div>
|
||||
</BaseCard>
|
||||
</article>
|
||||
</section> -->
|
||||
|
||||
<section>
|
||||
<Subtitle> Quick Statistics </Subtitle>
|
||||
<div class="grid grid-cols-2 gap-2 md:grid-cols-4 md:gap-6">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue