Merge pull request #715 from JakobGue/spool_count

Add Spoolcount in Locations Page
This commit is contained in:
Donkie
2026-01-04 20:05:27 +01:00
committed by GitHub
3 changed files with 69 additions and 61 deletions

View File

@@ -396,4 +396,4 @@
"no_location": "No Location", "no_location": "No Location",
"no_locations_help": "This page lets you organize your spools in locations, add some spools to get started!" "no_locations_help": "This page lets you organize your spools in locations, add some spools to get started!"
} }
} }

View File

@@ -9,6 +9,7 @@ import { ISpool } from "../../spools/model";
import { DragItem, ItemTypes, SpoolDragItem } from "../dnd"; import { DragItem, ItemTypes, SpoolDragItem } from "../dnd";
import { EMPTYLOC } from "../functions"; import { EMPTYLOC } from "../functions";
import { SpoolList } from "./spoolList"; import { SpoolList } from "./spoolList";
import { useGetSetting } from "../../../utils/querySettings";
const { useToken } = theme; const { useToken } = theme;
@@ -139,6 +140,9 @@ export function Location({
const titleStyle = { const titleStyle = {
color: canEditTitle ? undefined : token.colorTextTertiary, color: canEditTitle ? undefined : token.colorTextTertiary,
}; };
const spoolCountStyle = {
color: token.colorTextQuaternary,
};
return ( return (
<div <div
@@ -171,6 +175,7 @@ export function Location({
style={titleStyle} style={titleStyle}
> >
{displayTitle} {displayTitle}
{<span style={spoolCountStyle}> ({spools.length})</span>}
</span> </span>
)} )}
{showDelete && <Button icon={<DeleteOutlined />} size="small" type="text" onClick={onDelete} />} {showDelete && <Button icon={<DeleteOutlined />} size="small" type="text" onClick={onDelete} />}

View File

@@ -31,7 +31,7 @@ export function GeneralSettings() {
}, [setCurrency.isSuccess, messageApi, t]); }, [setCurrency.isSuccess, messageApi, t]);
// Handle form submit // Handle form submit
const onFinish = (values: { currency: string; base_url: string, round_prices: boolean }) => { const onFinish = (values: { currency: string; base_url: string; round_prices: boolean }) => {
// Check if the currency has changed // Check if the currency has changed
if (settings.data?.currency.value !== JSON.stringify(values.currency)) { if (settings.data?.currency.value !== JSON.stringify(values.currency)) {
setCurrency.mutate(values.currency); setCurrency.mutate(values.currency);
@@ -47,67 +47,70 @@ export function GeneralSettings() {
} }
}; };
return (<> return (
<Form <>
form={form} <Form
labelCol={{ span: 8 }} form={form}
wrapperCol={{ span: 16 }} labelCol={{ span: 8 }}
initialValues={{ wrapperCol={{ span: 16 }}
currency: settings.data?.currency.value, initialValues={{
round_prices: settings.data?.round_prices.value, currency: settings.data?.currency.value,
}} round_prices: settings.data?.round_prices.value,
onFinish={onFinish} base_url: settings.data?.base_url.value,
style={{ }}
maxWidth: "600px", onFinish={onFinish}
margin: "0 auto", style={{
}} maxWidth: "600px",
> margin: "0 auto",
<Form.Item }}
label={t("settings.general.currency.label")}
name="currency"
rules={[
{
required: true,
},
{
pattern: /^[A-Z]{3}$/,
},
]}
> >
<Input /> <Form.Item
</Form.Item> label={t("settings.general.currency.label")}
name="currency"
rules={[
{
required: true,
},
{
pattern: /^[A-Z]{3}$/,
},
]}
>
<Input />
</Form.Item>
<Form.Item <Form.Item
label={t("settings.general.base_url.label")} label={t("settings.general.base_url.label")}
tooltip={t("settings.general.base_url.tooltip")} tooltip={t("settings.general.base_url.tooltip")}
name="base_url" name="base_url"
rules={[ rules={[
{ {
required: false, required: false,
}, },
{ {
pattern: /^https?:\/\/.+(?<!\/)$/, pattern: /^https?:\/\/.+(?<!\/)$/,
}, },
]} ]}
> >
<Input placeholder="https://example.com:8000" /> <Input placeholder="https://example.com:8000" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label={t("settings.general.round_prices.label")} label={t("settings.general.round_prices.label")}
tooltip={t("settings.general.round_prices.tooltip")} tooltip={t("settings.general.round_prices.tooltip")}
name="round_prices" name="round_prices"
valuePropName="checked" valuePropName="checked"
> >
<Checkbox /> <Checkbox />
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 16 }}> <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
<Button type="primary" htmlType="submit" loading={settings.isFetching || setCurrency.isLoading}> <Button type="primary" htmlType="submit" loading={settings.isFetching || setCurrency.isLoading}>
{t("buttons.save")} {t("buttons.save")}
</Button> </Button>
</Form.Item> </Form.Item>
</Form> </Form>
{contextHolder} {contextHolder}
</>); </>
);
} }