diff --git a/client/public/locales/cs/common.json b/client/public/locales/cs/common.json index 36a21a9..bcbe56f 100644 --- a/client/public/locales/cs/common.json +++ b/client/public/locales/cs/common.json @@ -118,6 +118,15 @@ "showSpoolComment": "Poznámka k cívce", "showFilamentComment": "Poznámka k filamentu", "showVendorComment": "Poznámka k výrobci", + "useHTTPUrl": { + "label": "Odkaz na QR kód", + "tooltip": "Použije proprietární odkaz, který bude fungovat pouze v případě, že bude skenován pomocí funkce skenování Spoolman (výchozí). Adresa URL používá buď základní adresu URL zadanou v nastavení, nebo adresu URL aktuální stránky, pokud není nastavena.", + "options": { + "default": "Výchozí", + "url": "URL" + }, + "preview": "Náhled:" + }, "template": "Šablona štítku", "templateHelp": "Pomocí {} vložíte hodnoty objektu cívky jako text. Například {id} bude nahrazeno ID cívky nebo {filament.material} bude nahrazeno materiálem cívky. Text uzavřete dvojitou hvězdičkou **, aby byl tučný. Kliknutím na tlačítko zobrazíte seznam všech dostupných značek.", "showQRCode": "Tisk QR kódu", @@ -374,6 +383,10 @@ "tab": "Obecné", "currency": { "label": "Měna" + }, + "base_url": { + "label": "Základní URL", + "tooltip": "Základní adresa URL, která se má použít při generování funkcí, jako jsou QR kódy" } }, "settings": "Nastavení" diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json index f587379..9eeec7f 100644 --- a/client/public/locales/en/common.json +++ b/client/public/locales/en/common.json @@ -109,6 +109,15 @@ "templateHelp": "Use {} to insert values of the spool object as text. For example {id} will be replaced with the spool id, or {filament.material} will be replaced with the material of the spool. Enclose text with double asterix ** to make it bold. Click the button to view a list of all available tags.", "textSize": "Label Text Size", "showContent": "Print Label", + "useHTTPUrl": { + "label": "QR code link", + "tooltip": "Will use proprietary link that will work only if scanned from Spoolman's scanning feature (default). URL uses either the base URL specified in settings, or the current page URL if not set.", + "options": { + "default": "Default", + "url": "URL" + }, + "preview": "Preview:" + }, "showQRCode": "Print QR Code", "showQRCodeMode": { "no": "No", @@ -300,6 +309,10 @@ "tab": "General", "currency": { "label": "Currency" + }, + "base_url": { + "label": "Base URL", + "tooltip": "The base URL to use when generating features such as QR codes." } }, "extra_fields": { diff --git a/client/src/components/qrCodeScanner.tsx b/client/src/components/qrCodeScanner.tsx index 6f786cb..bd138a3 100644 --- a/client/src/components/qrCodeScanner.tsx +++ b/client/src/components/qrCodeScanner.tsx @@ -18,6 +18,11 @@ const QRCodeScannerModal: React.FC = () => { setVisible(false); navigate(`/spool/show/${match.groups.id}`); } + const fullURLmatch = result.match(/^https?:\/\/[^/]+\/spool\/show\/(?[0-9]+)$/); + if (fullURLmatch && fullURLmatch.groups) { + setVisible(false); + navigate(`/spool/show/${fullURLmatch.groups.id}`); + } }; return ( diff --git a/client/src/pages/printing/qrCodePrintingDialog.tsx b/client/src/pages/printing/qrCodePrintingDialog.tsx index bf2fd6f..7e6fc34 100644 --- a/client/src/pages/printing/qrCodePrintingDialog.tsx +++ b/client/src/pages/printing/qrCodePrintingDialog.tsx @@ -1,8 +1,10 @@ import { useTranslate } from "@refinedev/core"; -import { Col, Form, InputNumber, QRCode, Radio, RadioChangeEvent, Row, Slider, Switch } from "antd"; +import { Col, Form, InputNumber, QRCode, Radio, RadioChangeEvent, Row, Slider, Switch, Typography } from "antd"; import { QRCodePrintSettings } from "./printing"; import PrintingDialog from "./printingDialog"; +const { Text } = Typography; + interface QRCodeData { value: string; label?: JSX.Element; @@ -16,6 +18,9 @@ interface QRCodePrintingDialogProps { extraSettings?: JSX.Element; extraSettingsStart?: JSX.Element; extraButtons?: JSX.Element; + baseUrlRoot: string; + useHTTPUrl: boolean; + setUseHTTPUrl: (value: boolean) => void; } const QRCodePrintingDialog: React.FC = ({ @@ -25,6 +30,9 @@ const QRCodePrintingDialog: React.FC = ({ extraSettings, extraSettingsStart, extraButtons, + baseUrlRoot, + useHTTPUrl, + setUseHTTPUrl, }) => { const t = useTranslate(); @@ -87,6 +95,23 @@ const QRCodePrintingDialog: React.FC = ({ buttonStyle="solid" /> + {showQRCodeMode !== "no" && ( + <> + + setUseHTTPUrl(e.target.value)} value={useHTTPUrl}> + {t("printing.qrcode.useHTTPUrl.options.default")} + {t("printing.qrcode.useHTTPUrl.options.url")} + + + + {useHTTPUrl ? `${baseUrlRoot}/spool/show/{id}` : `web+spoolman:s-{id}`} + + + )} = ({ spoolIds }) => { const t = useTranslate(); + const baseUrlSetting = useGetSetting("base_url"); + const baseUrlRoot = + baseUrlSetting.data?.value !== undefined && JSON.parse(baseUrlSetting.data?.value) !== "" + ? JSON.parse(baseUrlSetting.data?.value) + : window.location.origin; const [messageApi, contextHolder] = message.useMessage(); + const [useHTTPUrl, setUseHTTPUrl] = useSavedState("print-useHTTPUrl", false); const itemQueries = useGetSpoolsByIds(spoolIds); const items = itemQueries @@ -231,6 +238,9 @@ Lot Nr: {lot_nr} curPreset.labelSettings = newSettings; updateCurrentPreset(curPreset); }} + baseUrlRoot={baseUrlRoot} + useHTTPUrl={useHTTPUrl} + setUseHTTPUrl={setUseHTTPUrl} extraSettingsStart={ <> @@ -290,7 +300,7 @@ Lot Nr: {lot_nr} } items={items.map((spool) => ({ - value: `web+spoolman:s-${spool.id}`, + value: useHTTPUrl ? `${baseUrlRoot}/spool/show/${spool.id}` : `web+spoolman:s-${spool.id}`, label: (

{ + const onFinish = (values: { currency: string; base_url: string }) => { // Check if the currency has changed if (settings.data?.currency.value !== JSON.stringify(values.currency)) { setCurrency.mutate(values.currency); } + // Check if the base URL has changed + if (settings.data?.base_url.value !== JSON.stringify(values.base_url)) { + setBaseUrl.mutate(values.base_url); + } }; return ( @@ -64,6 +70,22 @@ export function GeneralSettings() { + + + +