@flowselections/layout-maker 1.45.19 → 1.51.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/ComputerVerwijderenDialog.d.ts +16 -0
- package/dist-lib/components/ComputerVerwijderenDialog.d.ts.map +1 -0
- package/dist-lib/components/ComputerVerwijderenDialog.js +38 -0
- package/dist-lib/components/ComputersLijst.d.ts.map +1 -1
- package/dist-lib/components/ComputersLijst.js +5 -2
- package/dist-lib/components/DocumentenPage.d.ts.map +1 -1
- package/dist-lib/components/DocumentenPage.js +2 -3
- package/dist-lib/components/LayoutPrinterSelect.d.ts +3 -5
- package/dist-lib/components/LayoutPrinterSelect.d.ts.map +1 -1
- package/dist-lib/components/LayoutPrinterSelect.js +40 -17
- package/dist-lib/components/LayoutsPage.d.ts.map +1 -1
- package/dist-lib/components/LayoutsPage.js +28 -18
- package/dist-lib/components/PrintQueuePage.d.ts.map +1 -1
- package/dist-lib/components/PrintQueuePage.js +5 -71
- package/dist-lib/components/PrintenPage.d.ts.map +1 -1
- package/dist-lib/components/PrintenPage.js +2 -3
- package/dist-lib/components/PrinterSetupWizard.d.ts +3 -1
- package/dist-lib/components/PrinterSetupWizard.d.ts.map +1 -1
- package/dist-lib/components/PrinterSetupWizard.js +15 -29
- package/dist-lib/components/PrinterVervangenDialog.d.ts +14 -0
- package/dist-lib/components/PrinterVervangenDialog.d.ts.map +1 -0
- package/dist-lib/components/PrinterVervangenDialog.js +44 -0
- package/dist-lib/components/PrintersPage.d.ts.map +1 -1
- package/dist-lib/components/PrintersPage.js +2 -2
- package/dist-lib/components/PrintplekDetailPage.d.ts.map +1 -1
- package/dist-lib/components/PrintplekDetailPage.js +173 -68
- package/dist-lib/components/PrintplekVerwijderenDialog.d.ts +9 -0
- package/dist-lib/components/PrintplekVerwijderenDialog.d.ts.map +1 -0
- package/dist-lib/components/PrintplekVerwijderenDialog.js +34 -0
- package/dist-lib/components/PrintplekWizard.d.ts.map +1 -1
- package/dist-lib/components/PrintplekWizard.js +3 -85
- package/dist-lib/components/PrintplekkenPage.d.ts.map +1 -1
- package/dist-lib/components/PrintplekkenPage.js +28 -6
- package/dist-lib/components/WerkplekConfiguratiePage.d.ts.map +1 -1
- package/dist-lib/components/WerkplekConfiguratiePage.js +67 -25
- package/dist-lib/index.d.ts +9 -12
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +7 -13
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1414 -24
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +1414 -24
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +1414 -24
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1471 -42
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/aiLayout.functions.d.ts +1414 -24
- package/dist-lib/lib/aiLayout.functions.d.ts.map +1 -1
- package/dist-lib/lib/documentRoutering.d.ts +2 -1
- package/dist-lib/lib/documentRoutering.d.ts.map +1 -1
- package/dist-lib/lib/documentRoutering.js +5 -8
- package/dist-lib/lib/foutTekst.d.ts +3 -0
- package/dist-lib/lib/foutTekst.d.ts.map +1 -0
- package/dist-lib/lib/foutTekst.js +25 -0
- package/dist-lib/lib/printApi.d.ts +0 -2
- package/dist-lib/lib/printApi.d.ts.map +1 -1
- package/dist-lib/lib/printApi.js +13 -60
- package/dist-lib/lib/printQueue.server.d.ts +8 -0
- package/dist-lib/lib/printQueue.server.d.ts.map +1 -1
- package/dist-lib/lib/printQueue.server.js +55 -133
- package/dist-lib/lib/printRoutering.d.ts +34 -0
- package/dist-lib/lib/printRoutering.d.ts.map +1 -0
- package/dist-lib/lib/printRoutering.js +69 -0
- package/dist-lib/lib/printService.functions.d.ts +6980 -30
- package/dist-lib/lib/printService.functions.d.ts.map +1 -1
- package/dist-lib/lib/printplekken.d.ts +67 -2
- package/dist-lib/lib/printplekken.d.ts.map +1 -1
- package/dist-lib/lib/printplekken.js +141 -10
- package/dist-lib/lib/useDocumentData.d.ts +15 -10
- package/dist-lib/lib/useDocumentData.d.ts.map +1 -1
- package/dist-lib/lib/useDocumentData.js +43 -34
- package/dist-lib/lib/voorbeeldPrint.d.ts.map +1 -1
- package/dist-lib/lib/voorbeeldPrint.js +7 -39
- package/package.json +2 -2
- package/dist-lib/components/PdfMapAutoSaver.d.ts +0 -6
- package/dist-lib/components/PdfMapAutoSaver.d.ts.map +0 -1
- package/dist-lib/components/PdfMapAutoSaver.js +0 -12
- package/dist-lib/components/PdfMapGlobaleBanner.d.ts +0 -12
- package/dist-lib/components/PdfMapGlobaleBanner.d.ts.map +0 -1
- package/dist-lib/components/PdfMapGlobaleBanner.js +0 -30
- package/dist-lib/components/PdfMapToestemmingBanner.d.ts +0 -8
- package/dist-lib/components/PdfMapToestemmingBanner.d.ts.map +0 -1
- package/dist-lib/components/PdfMapToestemmingBanner.js +0 -245
- package/dist-lib/lib/pdfJobSaver.d.ts +0 -24
- package/dist-lib/lib/pdfJobSaver.d.ts.map +0 -1
- package/dist-lib/lib/pdfJobSaver.js +0 -405
- package/dist-lib/lib/pdfMap.d.ts +0 -90
- package/dist-lib/lib/pdfMap.d.ts.map +0 -1
- package/dist-lib/lib/pdfMap.js +0 -349
- package/dist-lib/lib/pdfOpslagStatus.d.ts +0 -23
- package/dist-lib/lib/pdfOpslagStatus.d.ts.map +0 -1
- package/dist-lib/lib/pdfOpslagStatus.js +0 -74
- package/dist-lib/lib/pdfPrinter.d.ts +0 -9
- package/dist-lib/lib/pdfPrinter.d.ts.map +0 -1
- package/dist-lib/lib/pdfPrinter.js +0 -34
|
@@ -5,9 +5,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
// ============================================================================
|
|
6
6
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
7
|
import { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Input, Label, toast, } from "@flowselections/core";
|
|
8
|
-
import { Check, CheckCircle2,
|
|
8
|
+
import { Check, CheckCircle2, FileText, Loader2, Printer, RefreshCw, Search, Tag, } from "lucide-react";
|
|
9
9
|
import { supabase } from "../lib/supabaseClient.js";
|
|
10
|
-
import {
|
|
10
|
+
import { wijsPrinterToeAanPrintplek } from "../lib/printplekken.js";
|
|
11
|
+
import { leesbareFout } from "../lib/foutTekst.js";
|
|
11
12
|
import { printHtml, volgJobStatus } from "../lib/printApi.js";
|
|
12
13
|
import { netwerkPrinters } from "../lib/printService.functions.js";
|
|
13
14
|
import { printerFormaatOpties } from "../lib/papierFormaten.js";
|
|
@@ -30,7 +31,7 @@ function Stappenbalk({ stap }) {
|
|
|
30
31
|
? "border-primary text-primary border-2"
|
|
31
32
|
: "bg-muted text-muted-foreground"}`, children: i < stap ? _jsx(Check, { className: "h-4 w-4" }) : i + 1 }), _jsx("span", { className: `hidden text-sm sm:inline ${i === stap ? "text-foreground font-medium" : "text-muted-foreground"}`, children: s }), i < STAPPEN.length - 1 && _jsx("div", { className: "bg-border h-px flex-1" })] }, s))) }));
|
|
32
33
|
}
|
|
33
|
-
export function PrinterSetupWizard({ open, onOpenChange, onKlaar, computerFilter, bekendeExterneIds = [], bekendeLocaties = [], bewerken, }) {
|
|
34
|
+
export function PrinterSetupWizard({ open, onOpenChange, onKlaar, computerFilter, bekendeExterneIds = [], bekendeLocaties = [], bewerken, printPlekId, }) {
|
|
34
35
|
const [stap, setStap] = useState(0);
|
|
35
36
|
const [bezig, setBezig] = useState(false);
|
|
36
37
|
const [zoekt, setZoekt] = useState(false);
|
|
@@ -163,34 +164,19 @@ export function PrinterSetupWizard({ open, onOpenChange, onKlaar, computerFilter
|
|
|
163
164
|
.single();
|
|
164
165
|
if (error)
|
|
165
166
|
throw error;
|
|
166
|
-
|
|
167
|
+
const nieuwId = data?.id ?? null;
|
|
168
|
+
if (nieuwId && printPlekId) {
|
|
169
|
+
await wijsPrinterToeAanPrintplek(printPlekId, nieuwId);
|
|
170
|
+
}
|
|
171
|
+
else if (nieuwId && computerFilter && !printPlekId) {
|
|
172
|
+
toast.warning(`Printer opgeslagen, maar computer ${computerFilter} hoort bij geen printplek. Koppel de computer eerst aan een printplek.`);
|
|
173
|
+
}
|
|
174
|
+
setPrinterId(nieuwId);
|
|
167
175
|
setStap(2);
|
|
168
176
|
onKlaar?.();
|
|
169
177
|
}
|
|
170
|
-
catch {
|
|
171
|
-
toast.error(
|
|
172
|
-
}
|
|
173
|
-
finally {
|
|
174
|
-
setBezig(false);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Voegt de virtuele "Opslaan als PDF"-printer toe. Documenten die hierheen
|
|
179
|
-
* gaan worden niet geprint maar als downloadbare PDF in de wachtrij bewaard.
|
|
180
|
-
* Er is maar één PDF-printer nodig; een tweede wordt niet aangemaakt.
|
|
181
|
-
*/
|
|
182
|
-
const pdfPrinterToevoegen = async () => {
|
|
183
|
-
setBezig(true);
|
|
184
|
-
try {
|
|
185
|
-
const { alAanwezig } = await zorgVoorPdfPrinter();
|
|
186
|
-
toast.success(alAanwezig
|
|
187
|
-
? "'Opslaan als PDF' stond al tussen uw printers"
|
|
188
|
-
: "'Opslaan als PDF' toegevoegd");
|
|
189
|
-
onKlaar?.();
|
|
190
|
-
onOpenChange(false);
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
toast.error("Toevoegen mislukt");
|
|
178
|
+
catch (err) {
|
|
179
|
+
toast.error(leesbareFout(err));
|
|
194
180
|
}
|
|
195
181
|
finally {
|
|
196
182
|
setBezig(false);
|
|
@@ -251,7 +237,7 @@ export function PrinterSetupWizard({ open, onOpenChange, onKlaar, computerFilter
|
|
|
251
237
|
: "Kies uw printer, geef hem een herkenbare naam en druk een testpagina af." })] }), !bewerken && _jsx(Stappenbalk, { stap: stap }), stap === 0 && (_jsxs("div", { className: "space-y-4", children: [lijst.length > 6 && (_jsxs("div", { className: "relative", children: [_jsx(Search, { className: "text-muted-foreground absolute top-2.5 left-3 h-4 w-4" }), _jsx(Input, { className: "pl-9", value: zoekterm, placeholder: "Zoek op printer of computer", onChange: (e) => setZoekterm(e.target.value) })] })), zoekt && (_jsxs("p", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), " Printers zoeken\u2026"] })), !zoekt && fout && _jsx("p", { className: "text-destructive text-sm", children: fout }), !zoekt && zichtbaar.length > 0 && (_jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: zichtbaar.map((p) => {
|
|
252
238
|
const al = bekendeExterneIds.includes(p.id);
|
|
253
239
|
return (_jsx("button", { type: "button", disabled: al, onClick: () => kiesPrinter(p), className: `rounded-xl border p-4 text-left transition ${al ? "opacity-60" : "hover:border-primary/50 hover:bg-accent/40"}`, children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Printer, { className: "text-muted-foreground mt-0.5 h-5 w-5 shrink-0" }), _jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "truncate text-sm font-medium", children: p.naam }), _jsx("p", { className: "text-muted-foreground truncate text-xs", children: p.computer }), _jsxs("span", { className: "mt-2 flex items-center gap-1.5 text-xs", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${p.online ? "bg-primary" : "bg-muted-foreground/40"}` }), al ? "Al toegevoegd" : p.online ? "Beschikbaar" : "Niet aan"] })] })] }) }, p.id));
|
|
254
|
-
}) })), !zoekt && zichtbaar.length === 0 && _jsx(PrintProgrammaUitleg, {}), !zoekt &&
|
|
240
|
+
}) })), !zoekt && zichtbaar.length === 0 && _jsx(PrintProgrammaUitleg, {}), !zoekt && zichtbaar.length > 0 && (_jsxs("div", { className: "space-y-3", children: [_jsx("button", { type: "button", className: "text-muted-foreground hover:text-foreground text-sm underline", onClick: () => setUitlegOpen((v) => !v), children: "Ik zie mijn printer niet" }), uitlegOpen && _jsx(PrintProgrammaUitleg, { compact: true })] })), _jsx("div", { className: "flex justify-between", children: _jsxs(Button, { variant: "ghost", onClick: () => void zoeken(), disabled: zoekt, children: [_jsx(RefreshCw, { className: "mr-2 h-4 w-4" }), " Opnieuw zoeken"] }) })] })), stap === 1 && (_jsxs("div", { className: "grid gap-5 sm:grid-cols-[1fr_200px]", children: [_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Weergavenaam" }), _jsx(Input, { value: naam, placeholder: "Bijvoorbeeld: pakbonprinter voorin", onChange: (e) => setNaam(e.target.value) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Omschrijving (optioneel)" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "Waar staat deze printer? Bijvoorbeeld: magazijn achter." }), _jsx(Input, { value: locatie, placeholder: "Bijvoorbeeld: magazijn achter", onChange: (e) => setLocatie(e.target.value) }), bekendeLocaties.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-2 pt-1", children: bekendeLocaties.slice(0, 6).map((l) => (_jsx("button", { type: "button", onClick: () => setLocatie(l), className: "hover:bg-accent rounded-full border px-3 py-1 text-xs", children: l }, l))) }))] }), formaatOpties.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Standaardformaat van deze printer" }), _jsxs("p", { className: "text-muted-foreground text-xs", children: ["Deze printer kan: ", formaatOpties.map((o) => o.label.split(" (")[0]).join(", "), "."] }), formaatOpties.length === 1 ? (_jsx("p", { className: "text-sm", children: formaatOpties[0].label })) : (_jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: formaatOpties.map((o) => (_jsxs("button", { type: "button", onClick: () => setFormaatCode(o.code), className: `hover:bg-accent rounded-lg border p-3 text-left transition ${formaatCode === o.code ? "border-primary bg-accent" : ""}`, children: [o.breedte <= 120 && o.hoogte <= 220 ? (_jsx(Tag, { className: "text-muted-foreground mb-1 h-4 w-4" })) : (_jsx(FileText, { className: "text-muted-foreground mb-1 h-4 w-4" })), _jsx("p", { className: "text-sm font-medium", children: o.label.split(" (")[0] }), _jsxs("p", { className: "text-muted-foreground text-xs", children: [o.breedte, " \u00D7 ", o.hoogte, " mm"] })] }, o.code))) }))] })) : (_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Wat gaat deze printer afdrukken?" }), _jsx("p", { className: "text-muted-foreground text-xs", children: "De formaten van deze printer konden niet worden opgehaald." }), _jsx("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
255
241
|
{ code: "papier", label: "Papier (A4)", sub: "Gewone documenten", Icon: FileText },
|
|
256
242
|
{ code: "etiket", label: "Etiketten", sub: "Stickers en labels", Icon: Tag },
|
|
257
243
|
].map((o) => (_jsxs("button", { type: "button", onClick: () => setGebruik(o.code), className: `hover:bg-accent rounded-lg border p-4 text-left transition ${gebruik === o.code ? "border-primary bg-accent" : ""}`, children: [_jsx(o.Icon, { className: "text-muted-foreground mb-2 h-5 w-5" }), _jsx("p", { className: "text-sm font-medium", children: o.label }), _jsx("p", { className: "text-muted-foreground text-xs", children: o.sub })] }, o.code))) })] })), _jsxs("div", { className: "flex justify-between", children: [!bewerken ? (_jsx(Button, { variant: "ghost", onClick: () => setStap(0), children: "Terug" })) : (_jsx("span", {})), _jsx(Button, { disabled: bezig, onClick: () => void opslaan(), children: bewerken ? "Opslaan" : "Opslaan en verder" })] })] }), _jsxs("div", { className: "hidden sm:block", children: [_jsx("p", { className: "text-muted-foreground mb-2 text-xs", children: "Zo komt hij in de lijst:" }), _jsxs("div", { className: "bg-card rounded-xl border p-3", children: [_jsx(Printer, { className: "text-muted-foreground mb-2 h-4 w-4" }), _jsx("p", { className: "truncate text-sm font-medium", children: naam || "Naam van de printer" }), _jsx("p", { className: "text-muted-foreground truncate text-xs", children: locatie || gekozen?.computer || "Geen omschrijving" })] })] })] })), stap === 2 && (_jsxs("div", { className: "space-y-4 text-center", children: [_jsx(CheckCircle2, { className: "text-primary mx-auto h-10 w-10" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: "De printer is klaar voor gebruik" }), _jsxs("p", { className: "text-muted-foreground text-sm", children: [naam, " ", locatie ? `bij ${locatie}` : "", " drukt voortaan automatisch af."] })] }), testStatus !== "leeg" && (_jsxs("p", { className: "text-muted-foreground text-sm", children: [testStatus === "bezig" && "Onderweg naar de printer…", testStatus === "gelukt" && (testMelding || "De testpagina is afgedrukt."), testStatus === "fout" &&
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function PrinterVervangenDialog({ open, onOpenChange, printer, printers, onKlaar, }: {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onOpenChange: (v: boolean) => void;
|
|
4
|
+
printer: {
|
|
5
|
+
id: string;
|
|
6
|
+
naam: string;
|
|
7
|
+
} | null;
|
|
8
|
+
printers: {
|
|
9
|
+
id: string;
|
|
10
|
+
naam: string;
|
|
11
|
+
}[];
|
|
12
|
+
onKlaar?: () => void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=PrinterVervangenDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrinterVervangenDialog.d.ts","sourceRoot":"","sources":["../../src/components/PrinterVervangenDialog.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,OAAO,GACR,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7C,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,+BA2EA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// src/components/PrinterVervangenDialog.tsx — laat zien waar een printer
|
|
4
|
+
// gebruikt wordt en zet in één keer alle verwijzingen over naar een andere
|
|
5
|
+
// printer, of expliciet op "geen printer".
|
|
6
|
+
// ============================================================================
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, toast, } from "@flowselections/core";
|
|
9
|
+
import { printerGebruik, vervangPrinterOveral } from "../lib/printplekken.js";
|
|
10
|
+
export function PrinterVervangenDialog({ open, onOpenChange, printer, printers, onKlaar, }) {
|
|
11
|
+
const [gebruik, setGebruik] = useState(null);
|
|
12
|
+
const [nieuw, setNieuw] = useState("");
|
|
13
|
+
const [bezig, setBezig] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!open || !printer)
|
|
16
|
+
return;
|
|
17
|
+
setNieuw("");
|
|
18
|
+
setGebruik(null);
|
|
19
|
+
printerGebruik(printer.id).then(setGebruik).catch(() => setGebruik(null));
|
|
20
|
+
}, [open, printer]);
|
|
21
|
+
const totaal = gebruik
|
|
22
|
+
? gebruik.printplek_regels + gebruik.werkplek_regels + gebruik.layout_koppelingen + gebruik.standaardregels
|
|
23
|
+
: 0;
|
|
24
|
+
const opties = (Array.isArray(printers) ? printers : []).filter((p) => p.id !== printer?.id);
|
|
25
|
+
const uitvoeren = async () => {
|
|
26
|
+
if (!printer)
|
|
27
|
+
return;
|
|
28
|
+
setBezig(true);
|
|
29
|
+
try {
|
|
30
|
+
const r = await vervangPrinterOveral(printer.id, nieuw || null);
|
|
31
|
+
const n = Object.values(r).reduce((a, b) => a + Number(b || 0), 0);
|
|
32
|
+
toast.success(nieuw ? `${n} regels overgezet` : `${n} regels op "geen printer" gezet`);
|
|
33
|
+
onOpenChange(false);
|
|
34
|
+
onKlaar?.();
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
toast.error(e instanceof Error ? e.message : "Vervangen mislukt");
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setBezig(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Printer overal vervangen" }), _jsxs(DialogDescription, { children: [printer?.naam, " wordt gebruikt in ", gebruik ? totaal : "…", " regel", totaal === 1 ? "" : "s", "."] })] }), gebruik ? (_jsxs("ul", { className: "text-sm space-y-1", children: [_jsxs("li", { children: ["Printplekregels: ", gebruik.printplek_regels] }), _jsxs("li", { children: ["Werkplek-uitzonderingen: ", gebruik.werkplek_regels] }), _jsxs("li", { children: ["Layout-koppelingen: ", gebruik.layout_koppelingen] }), _jsxs("li", { children: ["Bedrijfsstandaard: ", gebruik.standaardregels] }), _jsxs("li", { children: ["Gekoppeld aan printplekken: ", gebruik.printplekken] })] })) : null, _jsx("label", { className: "text-sm font-medium", children: "Vervangen door" }), _jsxs("select", { className: "border-input bg-background w-full rounded-md border px-3 py-2 text-sm", value: nieuw, onChange: (e) => setNieuw(e.target.value), children: [_jsx("option", { value: "", children: "Geen printer (regels worden zichtbaar leeg)" }), opties.map((p) => (_jsx("option", { value: p.id, children: p.naam }, p.id)))] }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => onOpenChange(false), children: "Annuleren" }), _jsx(Button, { onClick: () => void uitvoeren(), disabled: bezig || !printer, children: nieuw ? "Overal vervangen" : "Overal leegmaken" })] })] }) }));
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintersPage.d.ts","sourceRoot":"","sources":["../../src/components/PrintersPage.tsx"],"names":[],"mappings":"AA2BA,wBAAgB,YAAY,CAAC,EAAE,OAAe,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,+
|
|
1
|
+
{"version":3,"file":"PrintersPage.d.ts","sourceRoot":"","sources":["../../src/components/PrintersPage.tsx"],"names":[],"mappings":"AA2BA,wBAAgB,YAAY,CAAC,EAAE,OAAe,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,+BAsM3E"}
|
|
@@ -17,7 +17,7 @@ import { PrintStatusBanner } from "./PrintStatusBanner.js";
|
|
|
17
17
|
import { telPrintersPerComputer } from "../lib/printerTelling.js";
|
|
18
18
|
import { WerkplekkenTabel } from "./WerkplekkenTabel.js";
|
|
19
19
|
export function PrintersPage({ ingebed = false } = {}) {
|
|
20
|
-
const { printers,
|
|
20
|
+
const { printers, reload } = usePrinters();
|
|
21
21
|
const { layouts } = useLayouts();
|
|
22
22
|
const navigate = useNavigate();
|
|
23
23
|
const { computers, loading: computersLaden, fout: computersFout, reload: herlaadComputers, } = useComputers();
|
|
@@ -29,7 +29,7 @@ export function PrintersPage({ ingebed = false } = {}) {
|
|
|
29
29
|
const bijgewerkt = useAutoRefresh(async () => {
|
|
30
30
|
await Promise.all([reload(true), herlaadComputers(true), zoek()]);
|
|
31
31
|
}, 10000, computerToevoegen);
|
|
32
|
-
const gekoppeldePrinters = useMemo(() => new Set(
|
|
32
|
+
const gekoppeldePrinters = useMemo(() => new Set(), []);
|
|
33
33
|
const printersPerComputer = useMemo(() => telPrintersPerComputer(printers, gevonden, gekoppeldePrinters), [printers, gevonden, gekoppeldePrinters]);
|
|
34
34
|
const alleRijen = computers.map((c) => {
|
|
35
35
|
const info = printersPerComputer.get(c.naam);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintplekDetailPage.d.ts","sourceRoot":"","sources":["../../src/components/PrintplekDetailPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrintplekDetailPage.d.ts","sourceRoot":"","sources":["../../src/components/PrintplekDetailPage.tsx"],"names":[],"mappings":"AA8DA,wBAAgB,mBAAmB,gCAmmBlC"}
|
|
@@ -1,78 +1,136 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// ============================================================================
|
|
3
|
-
// src/components/PrintplekDetailPage.tsx — één printplek
|
|
4
|
-
// computers
|
|
5
|
-
//
|
|
3
|
+
// src/components/PrintplekDetailPage.tsx — de centrale plek voor één printplek:
|
|
4
|
+
// computers, printers (per computer) en welk document naar welke printer gaat.
|
|
5
|
+
// Alles is hier direct bewerkbaar; de wizard is alleen voor een nieuwe plek.
|
|
6
6
|
// ============================================================================
|
|
7
7
|
import { useEffect, useMemo, useState } from "react";
|
|
8
8
|
import { Badge, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input, toast, } from "@flowselections/core";
|
|
9
|
-
import { Link, useParams } from "@tanstack/react-router";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { Link, useNavigate, useParams } from "@tanstack/react-router";
|
|
10
|
+
import { PrintplekVerwijderenDialog } from "./PrintplekVerwijderenDialog.js";
|
|
11
|
+
import { AlertTriangle, ArrowLeft, Check, Link2, Monitor, Plus, Printer, Trash2, X, } from "lucide-react";
|
|
12
|
+
import { bewerkPrintplek, koppelComputerAanPrintplek, koppelPrinterLosVanPrintplek, ontkoppelBron, usePrintplekken, verplaatsPrinterNaarPrintplek, wijsPrinterToeAanPrintplek, zetPrintplekPrinter, } from "../lib/printplekken.js";
|
|
13
|
+
import { PrinterVervangenDialog } from "./PrinterVervangenDialog.js";
|
|
14
|
+
import { ComputerVerwijderenDialog } from "./ComputerVerwijderenDialog.js";
|
|
12
15
|
import { usePrinters } from "../lib/useDocumentData.js";
|
|
13
16
|
import { useNetwerkPrinters } from "../lib/useNetwerkPrinters.js";
|
|
14
17
|
import { useComputers } from "./ComputersLijst.js";
|
|
15
18
|
import { DOCUMENT_TYPES, documentTypeLabel } from "../lib/documentTypes.js";
|
|
16
|
-
import { pdfMapNaam } from "../lib/pdfMap.js";
|
|
17
19
|
import { drukTestpaginaAf } from "../lib/testpagina.js";
|
|
18
|
-
import { PrintplekWizard } from "./PrintplekWizard.js";
|
|
19
20
|
import { TestprintDialog } from "./TestprintDialog.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
21
|
+
import { leesbareFout } from "../lib/foutTekst.js";
|
|
22
|
+
import { useRouteringOverzicht } from "../lib/printRoutering.js";
|
|
23
|
+
const BRON_LABEL = {
|
|
24
|
+
printplek: "Printplek-eigen",
|
|
25
|
+
werkplek: "Werkplek-uitzondering",
|
|
26
|
+
layout: "Standaardprinter (layout)",
|
|
27
|
+
standaard: "Bedrijfsstandaard",
|
|
28
|
+
geen: "Geen regel",
|
|
29
|
+
};
|
|
30
|
+
const selectKlasse = "border-input bg-background rounded-md border px-2 py-1 text-sm";
|
|
22
31
|
export function PrintplekDetailPage() {
|
|
23
32
|
const params = useParams({ strict: false });
|
|
24
33
|
const plekId = params.printplekId ?? "";
|
|
25
|
-
const
|
|
26
|
-
const
|
|
34
|
+
const navigate = useNavigate();
|
|
35
|
+
const [verwijderOpen, setVerwijderOpen] = useState(false);
|
|
36
|
+
const { plekken, computers: plekComputers, regels, koppelingen, toegewezen, reload } = usePrintplekken();
|
|
37
|
+
const { computers, reload: herlaadComputers } = useComputers();
|
|
27
38
|
const { printers } = usePrinters();
|
|
28
39
|
const { gevonden } = useNetwerkPrinters();
|
|
29
40
|
const [naamBewerken, setNaamBewerken] = useState(false);
|
|
30
41
|
const [naam, setNaam] = useState("");
|
|
31
42
|
const [alleDocumenten, setAlleDocumenten] = useState(false);
|
|
32
|
-
const [wizardOpen, setWizardOpen] = useState(false);
|
|
33
43
|
const [testprintOpen, setTestprintOpen] = useState(false);
|
|
44
|
+
const [vervangen, setVervangen] = useState(null);
|
|
45
|
+
const [toevoegen, setToevoegen] = useState("");
|
|
46
|
+
const [computerToevoegen, setComputerToevoegen] = useState("");
|
|
47
|
+
const [teVerwijderen, setTeVerwijderen] = useState(null);
|
|
34
48
|
const plek = plekken.find((p) => p.id === plekId) ?? null;
|
|
35
49
|
const eigenComputers = plekComputers.filter((c) => c.print_plek_id === plekId);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
const vrijeComputers = computers.filter((c) => !plekComputers.some((pc) => pc.computer_naam === c.naam));
|
|
51
|
+
const andereplekken = plekken.filter((p) => p.id !== plekId);
|
|
52
|
+
// De live scan bepaalt alleen online-status en op welke computer een printer hangt.
|
|
53
|
+
const computerVanExtern = useMemo(() => {
|
|
54
|
+
const m = new Map();
|
|
55
|
+
for (const g of Array.isArray(gevonden) ? gevonden : [])
|
|
56
|
+
if (g.id)
|
|
57
|
+
m.set(String(g.id), g.computer);
|
|
58
|
+
return m;
|
|
44
59
|
}, [gevonden]);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
return
|
|
60
|
+
const externVan = (p) => p.extern_printer_id ?? null;
|
|
61
|
+
const isOnline = (p) => {
|
|
62
|
+
const e = externVan(p);
|
|
63
|
+
return e ? computerVanExtern.has(String(e)) : false;
|
|
64
|
+
};
|
|
65
|
+
const computerVan = (p) => {
|
|
66
|
+
const e = externVan(p);
|
|
67
|
+
return e ? computerVanExtern.get(String(e)) ?? null : null;
|
|
68
|
+
};
|
|
69
|
+
const toegewezenIds = new Set((Array.isArray(toegewezen) ? toegewezen : [])
|
|
70
|
+
.filter((t) => t.print_plek_id === plekId)
|
|
71
|
+
.map((t) => t.printer_id));
|
|
72
|
+
const eigenPrinters = printers.filter((p) => toegewezenIds.has(p.id));
|
|
73
|
+
const nietToegewezen = printers.filter((p) => !toegewezenIds.has(p.id));
|
|
74
|
+
const eigenNamen = new Set(eigenComputers.map((c) => c.computer_naam));
|
|
75
|
+
const printersPerComputer = eigenComputers.map((c) => ({
|
|
76
|
+
naam: c.computer_naam,
|
|
77
|
+
printers: eigenPrinters.filter((p) => computerVan(p) === c.computer_naam),
|
|
78
|
+
}));
|
|
79
|
+
const nietGevonden = eigenPrinters.filter((p) => {
|
|
80
|
+
const c = computerVan(p);
|
|
81
|
+
return !c || !eigenNamen.has(c);
|
|
49
82
|
});
|
|
50
|
-
const
|
|
83
|
+
const pcNamen = eigenComputers.map((c) => c.computer_naam).sort();
|
|
84
|
+
const { uitkomsten, laden: routeringLaden, reload: reloadRoutering } = useRouteringOverzicht(plekId, DOCUMENT_TYPES.map((d) => d.value), pcNamen);
|
|
85
|
+
const uitkomstVoor = (t, pc) => uitkomsten[`${t}::${pc ?? ""}`] ?? null;
|
|
86
|
+
const routeringZichtbaar = DOCUMENT_TYPES.filter((d) => alleDocumenten ||
|
|
87
|
+
(pcNamen.length ? pcNamen : [null]).some((pc) => {
|
|
88
|
+
const u = uitkomstVoor(d.value, pc);
|
|
89
|
+
return !!u && (u.bron !== "geen" || u.overgeslagen.length > 0);
|
|
90
|
+
}));
|
|
51
91
|
useEffect(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
92
|
+
void reloadRoutering();
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, [regels, toegewezen]);
|
|
95
|
+
const printerNaam = (id) => printers.find((p) => p.id === id)?.naam ?? null;
|
|
96
|
+
const printerOnline = (id) => {
|
|
97
|
+
const p = printers.find((x) => x.id === id);
|
|
98
|
+
return p ? isOnline(p) : false;
|
|
99
|
+
};
|
|
100
|
+
const computerId = (n) => computers.find((k) => k.naam === n)?.id ?? null;
|
|
101
|
+
const eigenRegel = (t) => regels.find((r) => r.print_plek_id === plekId && r.documenttype === t) ?? null;
|
|
102
|
+
const vernieuw = async () => {
|
|
103
|
+
await reload(true);
|
|
104
|
+
await reloadRoutering();
|
|
105
|
+
};
|
|
106
|
+
const zetRegel = async (documenttype, waarde) => {
|
|
107
|
+
try {
|
|
108
|
+
await zetPrintplekPrinter(plekId, documenttype, waarde === "standaard" ? null : waarde);
|
|
109
|
+
await vernieuw();
|
|
110
|
+
toast.success("Printer opgeslagen");
|
|
59
111
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
112
|
+
catch (err) {
|
|
113
|
+
toast.error(leesbareFout(err));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function BronLink({ u }) {
|
|
117
|
+
const pcId = computerId(u.werkplek);
|
|
118
|
+
if (u.bron === "werkplek" && pcId)
|
|
119
|
+
return (_jsx(Link, { to: "/layouts-printers/printplekken/computers/$computerId", params: { computerId: pcId }, className: "text-primary text-xs underline", children: "Werkplek-uitzondering" }));
|
|
120
|
+
if (u.bron === "standaard")
|
|
121
|
+
return (_jsx(Link, { to: "/layouts-printers/printplekken", className: "text-primary text-xs underline", children: "Standaard bewerken" }));
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
function RouteringCellen({ u }) {
|
|
125
|
+
if (!u)
|
|
126
|
+
return _jsx("td", { colSpan: 3 });
|
|
127
|
+
const n = printerNaam(u.printer_id);
|
|
128
|
+
const status = !u.printer_id ? "geen" : n ? (printerOnline(u.printer_id) ? "online" : "offline") : "ontbreekt";
|
|
129
|
+
return (_jsxs(_Fragment, { children: [_jsx("td", { className: "py-2 pr-3 text-xs text-muted-foreground", children: u.papierformaat ?? "—" }), _jsxs("td", { className: "py-2 pr-3", children: [_jsxs(Badge, { variant: u.bron === "geen" ? "destructive" : "secondary", "data-bron": u.bron, children: [BRON_LABEL[u.bron], u.bron === "werkplek" && u.werkplek ? ` (${u.werkplek})` : ""] }), u.overgeslagen.map((o) => (_jsxs("div", { className: "text-destructive mt-1 flex items-center gap-1 text-xs", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5" }), " ", BRON_LABEL[o.bron], " overgeslagen: printer", " ", o.reden === "ontbreekt" ? "ontbreekt" : o.reden === "inactief" ? "inactief" : "niet (meer) aan deze plek gekoppeld"] }, o.regel_id)))] }), _jsxs("td", { className: "py-2 pr-3", children: [u.printer_id ? (_jsxs("span", { className: "flex items-center gap-1", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${status === "online" ? "bg-emerald-500" : status === "offline" ? "bg-muted-foreground" : "bg-destructive"}` }), n ?? "Onbekende printer", _jsx("span", { className: "text-muted-foreground text-xs", children: status })] })) : (_jsx("span", { className: "text-destructive text-xs", children: "geen printer \u2014 opdrachten blijven wachten" })), _jsx("div", { children: _jsx(BronLink, { u: u }) })] })] }));
|
|
130
|
+
}
|
|
72
131
|
const bronnen = koppelingen.filter((k) => k.print_plek_id === plekId);
|
|
73
132
|
const bestaandePlekIds = new Set(plekken.map((p) => p.id));
|
|
74
133
|
const weeskoppelingen = koppelingen.filter((k) => !bestaandePlekIds.has(k.print_plek_id));
|
|
75
|
-
const onvolledig = eigenComputers.length === 0 || !regels.some((r) => r.print_plek_id === plekId && r.printer_id);
|
|
76
134
|
const ontkoppel = async (bron, bronId) => {
|
|
77
135
|
try {
|
|
78
136
|
await ontkoppelBron(bron, bronId);
|
|
@@ -83,39 +141,86 @@ export function PrintplekDetailPage() {
|
|
|
83
141
|
toast.error("Ontkoppelen mislukt");
|
|
84
142
|
}
|
|
85
143
|
};
|
|
144
|
+
const loskoppelen = async (p) => {
|
|
145
|
+
const n = regels.filter((r) => r.print_plek_id === plekId && r.printer_id === p.id).length;
|
|
146
|
+
if (n > 0 && !window.confirm(`${n} regel(s) wijzen naar ${p.naam}. Die worden leeg en gemarkeerd. Doorgaan?`))
|
|
147
|
+
return;
|
|
148
|
+
try {
|
|
149
|
+
await koppelPrinterLosVanPrintplek(plekId, p.id);
|
|
150
|
+
await vernieuw();
|
|
151
|
+
toast.success("Printer verwijderd van deze plek");
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
toast.error("Verwijderen mislukt");
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const verplaats = async (p, naarPlek) => {
|
|
158
|
+
try {
|
|
159
|
+
await verplaatsPrinterNaarPrintplek(p.id, plekId, naarPlek);
|
|
160
|
+
await vernieuw();
|
|
161
|
+
toast.success(`${p.naam} verplaatst`);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
toast.error("Verplaatsen mislukt");
|
|
165
|
+
}
|
|
166
|
+
};
|
|
86
167
|
if (!plek) {
|
|
87
168
|
return (_jsxs("main", { className: "space-y-4 p-6", children: [_jsx(Button, { variant: "ghost", asChild: true, children: _jsxs(Link, { to: "/layouts-printers/printplekken", children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Terug"] }) }), _jsx("p", { className: "text-muted-foreground text-sm", children: "Deze printplek bestaat niet (meer)." })] }));
|
|
88
169
|
}
|
|
89
|
-
|
|
170
|
+
const PrinterRij = ({ p }) => (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 rounded-lg border p-2", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${isOnline(p) ? "bg-emerald-500" : "bg-muted-foreground"}` }), _jsx("span", { className: "font-medium", children: p.naam }), p.papierformaat ? _jsx(Badge, { variant: "secondary", children: p.papierformaat }) : null, !isOnline(p) ? _jsx("span", { className: "text-muted-foreground text-xs", children: "offline" }) : null] }), _jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: async () => {
|
|
171
|
+
try {
|
|
172
|
+
await drukTestpaginaAf(p.id, p.naam);
|
|
173
|
+
toast.success("Testpagina verstuurd");
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
toast.error("Testpagina versturen is niet gelukt.");
|
|
177
|
+
}
|
|
178
|
+
}, children: "Testpagina" }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVervangen({ id: p.id, naam: p.naam }), children: "Vervangen" }), andereplekken.length > 0 ? (_jsxs("select", { className: selectKlasse, value: "", "aria-label": `${p.naam} verplaatsen`, onChange: (e) => e.target.value && void verplaats(p, e.target.value), children: [_jsx("option", { value: "", children: "Verplaatsen\u2026" }), andereplekken.map((o) => (_jsxs("option", { value: o.id, children: ["naar ", o.naam] }, o.id)))] })) : null, _jsx(Button, { size: "sm", variant: "ghost", className: "text-destructive", onClick: () => void loskoppelen(p), children: "Verwijderen" })] })] }));
|
|
179
|
+
const teVerwijderenPrinters = teVerwijderen
|
|
180
|
+
? eigenPrinters.filter((p) => computerVan(p) === teVerwijderen).map((p) => ({ id: p.id, naam: p.naam }))
|
|
181
|
+
: [];
|
|
182
|
+
return (_jsxs("main", { className: "space-y-6 p-6", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Button, { variant: "ghost", size: "sm", asChild: true, className: "-ml-2", children: _jsxs(Link, { to: "/layouts-printers/printplekken", children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Alle printplekken"] }) }), naamBewerken ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: naam, onChange: (e) => setNaam(e.target.value), className: "w-64" }), _jsx(Button, { size: "icon", onClick: async () => {
|
|
90
183
|
await bewerkPrintplek(plek.id, { naam: naam.trim() });
|
|
91
184
|
setNaamBewerken(false);
|
|
92
185
|
await reload(true);
|
|
93
186
|
}, children: _jsx(Check, { className: "h-4 w-4" }) }), _jsx(Button, { size: "icon", variant: "ghost", onClick: () => setNaamBewerken(false), children: _jsx(X, { className: "h-4 w-4" }) })] })) : (_jsx("h1", { className: "cursor-pointer text-xl font-semibold", onClick: () => {
|
|
94
187
|
setNaam(plek.naam);
|
|
95
188
|
setNaamBewerken(true);
|
|
96
|
-
}, children: plek.naam })), _jsx("p", { className: "text-muted-foreground text-sm", children: plek.omschrijving ?? "
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
189
|
+
}, children: plek.naam })), _jsx("p", { className: "text-muted-foreground text-sm", children: plek.omschrijving ?? "Hier stel je alles in wat er op deze plek wordt afgedrukt." })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => setTestprintOpen(true), children: [_jsx(Printer, { className: "mr-2 h-4 w-4" }), " Testprint controleren"] }), _jsxs(Button, { variant: "ghost", className: "text-destructive", onClick: () => setVerwijderOpen(true), children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] })] })] }), _jsx(PrintplekVerwijderenDialog, { plek: verwijderOpen ? { id: plek.id, naam: plek.naam } : null, onOpenChange: setVerwijderOpen, onKlaar: () => void navigate({ to: "/layouts-printers/printplekken" }) }), _jsx(TestprintDialog, { open: testprintOpen, onOpenChange: setTestprintOpen, printplekId: plekId, printplekNaam: plek.naam }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsxs(CardTitle, { className: "flex items-center gap-2 text-base", children: [_jsx(Monitor, { className: "h-4 w-4" }), " Computers op deze plek"] }), _jsx(CardDescription, { children: "Het bolletje laat zien of de computer nu aan staat." })] }), vrijeComputers.length > 0 ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("select", { className: selectKlasse, value: computerToevoegen, onChange: (e) => setComputerToevoegen(e.target.value), "aria-label": "Computer kiezen", children: [_jsx("option", { value: "", children: "Computer kiezen\u2026" }), vrijeComputers.map((c) => (_jsx("option", { value: c.naam, children: c.naam }, c.id)))] }), _jsxs(Button, { size: "sm", disabled: !computerToevoegen, onClick: async () => {
|
|
190
|
+
try {
|
|
191
|
+
await koppelComputerAanPrintplek(plekId, computerToevoegen);
|
|
192
|
+
setComputerToevoegen("");
|
|
193
|
+
await vernieuw();
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
toast.error("Toevoegen mislukt");
|
|
197
|
+
}
|
|
198
|
+
}, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Computer toevoegen"] })] })) : null] }), _jsx(CardContent, { className: "space-y-2", children: eigenComputers.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-sm", children: "Nog geen computers gekoppeld." })) : (eigenComputers.map((c) => {
|
|
199
|
+
const aan = computers.find((k) => k.naam === c.computer_naam)?.online ?? false;
|
|
200
|
+
return (_jsxs("div", { className: "flex items-center gap-3 rounded-lg border px-3 py-2 text-sm", children: [_jsx("span", { className: `h-2 w-2 rounded-full ${aan ? "bg-emerald-500" : "bg-muted-foreground"}` }), _jsx("span", { className: "min-w-0 flex-1 truncate font-medium", children: c.computer_naam }), _jsx("span", { className: "text-muted-foreground text-xs", children: aan ? "Aan" : "Uit" }), _jsxs(Button, { size: "sm", variant: "ghost", className: "text-destructive", onClick: () => setTeVerwijderen(c.computer_naam), children: [_jsx(Trash2, { className: "mr-1 h-3.5 w-3.5" }), " Verwijderen"] })] }, c.id));
|
|
201
|
+
})) })] }), _jsx(ComputerVerwijderenDialog, { open: !!teVerwijderen, onOpenChange: (v) => !v && setTeVerwijderen(null), computerNaam: teVerwijderen, printplekId: plekId, printers: teVerwijderenPrinters, andereplekken: andereplekken, onKlaar: () => {
|
|
202
|
+
void herlaadComputers(true);
|
|
203
|
+
void vernieuw();
|
|
204
|
+
} }), _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { className: "flex items-center gap-2 text-base", children: [_jsx(Printer, { className: "h-4 w-4" }), " Printers op deze plek"] }), _jsx(CardDescription, { children: "Gegroepeerd per computer waaraan de printer volgens de live scan hangt." })] }), _jsxs(CardContent, { className: "space-y-4", children: [eigenPrinters.length === 0 ? (_jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [_jsx(AlertTriangle, { className: "text-destructive h-4 w-4" }), "Nog geen printers gekoppeld aan deze plek."] })) : null, printersPerComputer.map((g) => g.printers.length ? (_jsxs("div", { className: "space-y-2", children: [_jsxs("p", { className: "text-muted-foreground flex items-center gap-2 text-xs font-medium", children: [_jsx(Monitor, { className: "h-3.5 w-3.5" }), " ", g.naam] }), g.printers.map((p) => _jsx(PrinterRij, { p: p }, p.id))] }, g.naam)) : null), nietGevonden.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [_jsxs("p", { className: "text-muted-foreground flex items-center gap-2 text-xs font-medium", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5" }), " Niet gevonden op een computer van deze plek"] }), nietGevonden.map((p) => _jsx(PrinterRij, { p: p }, p.id))] })) : null, nietToegewezen.length > 0 ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("select", { className: selectKlasse, value: toevoegen, onChange: (e) => setToevoegen(e.target.value), children: [_jsx("option", { value: "", children: "Printer toevoegen\u2026" }), nietToegewezen.map((p) => (_jsx("option", { value: p.id, children: p.naam }, p.id)))] }), _jsxs(Button, { size: "sm", disabled: !toevoegen, onClick: async () => {
|
|
104
205
|
try {
|
|
105
|
-
await
|
|
106
|
-
|
|
206
|
+
await wijsPrinterToeAanPrintplek(plekId, toevoegen);
|
|
207
|
+
setToevoegen("");
|
|
208
|
+
await vernieuw();
|
|
107
209
|
}
|
|
108
210
|
catch {
|
|
109
|
-
toast.error("
|
|
211
|
+
toast.error("Toevoegen mislukt");
|
|
110
212
|
}
|
|
111
|
-
}, children: "
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
213
|
+
}, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Toevoegen"] })] })) : null, _jsx(PrinterVervangenDialog, { open: !!vervangen, onOpenChange: (v) => !v && setVervangen(null), printer: vervangen, printers: printers, onKlaar: () => void vernieuw() })] })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-start justify-between gap-3", children: [_jsxs("div", { children: [_jsx(CardTitle, { className: "text-base", children: "Welk document gaat naar welke printer?" }), _jsx(CardDescription, { children: "Berekend met dezelfde routering als het echte printen. Kies een printer om voor deze plek een eigen regel te maken, of \"Standaard gebruiken\"." })] }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => setAlleDocumenten((v) => !v), children: alleDocumenten ? "Alleen met printer" : (_jsxs(_Fragment, { children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Alle documenten"] })) })] }), _jsxs(CardContent, { children: [routeringLaden ? _jsx("p", { className: "text-muted-foreground text-sm", children: "Routering berekenen\u2026" }) : null, !routeringLaden && routeringZichtbaar.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-sm", children: "Voor geen enkel document is een printer gevonden. Klik op \"Alle documenten\" om er een in te stellen." })) : null, routeringZichtbaar.length > 0 ? (_jsx("div", { className: "overflow-x-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-muted-foreground border-b text-left text-xs", children: [_jsx("th", { className: "py-2 pr-3", children: "Document" }), _jsx("th", { className: "py-2 pr-3", children: "Formaat" }), _jsx("th", { className: "py-2 pr-3", children: "Winnende regel" }), _jsx("th", { className: "py-2 pr-3", children: "Printer" }), _jsx("th", { className: "py-2", children: "Printer op deze plek" })] }) }), _jsx("tbody", { children: routeringZichtbaar.flatMap((d) => {
|
|
214
|
+
const rijen = pcNamen.length ? pcNamen : [null];
|
|
215
|
+
const hoofd = uitkomstVoor(d.value, rijen[0]);
|
|
216
|
+
const afwijkend = rijen
|
|
217
|
+
.slice(1)
|
|
218
|
+
.map((pc) => ({ pc, u: uitkomstVoor(d.value, pc) }))
|
|
219
|
+
.filter((x) => x.u && (x.u.bron !== hoofd?.bron || x.u.printer_id !== hoofd?.printer_id));
|
|
220
|
+
const regel = eigenRegel(d.value);
|
|
221
|
+
return [
|
|
222
|
+
_jsxs("tr", { className: "border-b align-top", children: [_jsxs("td", { className: "py-2 pr-3 font-medium", children: [documentTypeLabel(d.value), pcNamen.length > 1 ? (_jsxs("div", { className: "text-muted-foreground text-xs font-normal", children: ["op ", rijen[0]] })) : null] }), _jsx(RouteringCellen, { u: hoofd }), _jsx("td", { className: "py-2", children: _jsxs("select", { className: selectKlasse, "aria-label": `Printer voor ${documentTypeLabel(d.value)}`, value: regel?.printer_id ?? "standaard", onChange: (e) => void zetRegel(d.value, e.target.value), children: [_jsx("option", { value: "standaard", children: "Standaard gebruiken" }), eigenPrinters.filter((p) => p.actief).map((p) => (_jsx("option", { value: p.id, children: p.naam }, p.id)))] }) })] }, d.value),
|
|
223
|
+
...afwijkend.map((x) => (_jsxs("tr", { className: "border-b align-top", children: [_jsxs("td", { className: "text-muted-foreground py-2 pr-3 pl-4 text-xs", children: ["op ", x.pc] }), _jsx(RouteringCellen, { u: x.u }), _jsx("td", {})] }, `${d.value}-${x.pc}`))),
|
|
224
|
+
];
|
|
225
|
+
}) })] }) })) : null] })] }), _jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { className: "flex items-center gap-2 text-base", children: [_jsx(Link2, { className: "h-4 w-4" }), " Gekoppeld aan"] }), _jsx(CardDescription, { children: "Andere modules (bijvoorbeeld pickstations) kunnen zich aan deze printplek koppelen." })] }), _jsxs(CardContent, { className: "space-y-4", children: [bronnen.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-sm", children: "Nog niets gekoppeld. Kies deze printplek in de andere module (bijvoorbeeld bij een pickstation); de koppeling verschijnt hier vanzelf." })) : (_jsx("div", { className: "space-y-2", children: bronnen.map((b) => (_jsxs("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border px-3 py-2 text-sm", children: [_jsx(Badge, { variant: "secondary", children: b.bron }), _jsxs("span", { className: "min-w-0 flex-1 truncate", children: [b.label ?? b.bron_id, _jsx("span", { className: "text-muted-foreground ml-2 text-xs", children: b.bron_id })] }), _jsxs(Button, { variant: "ghost", size: "sm", onClick: () => void ontkoppel(b.bron, b.bron_id), children: [_jsx(X, { className: "mr-1 h-3.5 w-3.5" }), " Ontkoppelen"] })] }, b.id))) })), weeskoppelingen.length > 0 ? (_jsxs("div", { className: "space-y-2 rounded-lg border border-dashed p-3", children: [_jsxs("p", { className: "text-muted-foreground flex items-center gap-2 text-xs", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5" }), " Koppelingen zonder bestaande printplek:"] }), weeskoppelingen.map((b) => (_jsxs("div", { className: "flex flex-wrap items-center gap-3 text-sm", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: b.label ?? `${b.bron} ${b.bron_id}` }), _jsxs(Button, { variant: "ghost", size: "sm", onClick: () => void ontkoppel(b.bron, b.bron_id), children: [_jsx(Trash2, { className: "mr-1 h-3.5 w-3.5" }), " Opruimen"] })] }, b.id)))] })) : null] })] })] }));
|
|
121
226
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function PrintplekVerwijderenDialog({ plek, onOpenChange, onKlaar, }: {
|
|
2
|
+
plek: {
|
|
3
|
+
id: string;
|
|
4
|
+
naam: string;
|
|
5
|
+
} | null;
|
|
6
|
+
onOpenChange: (v: boolean) => void;
|
|
7
|
+
onKlaar: () => void;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=PrintplekVerwijderenDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrintplekVerwijderenDialog.d.ts","sourceRoot":"","sources":["../../src/components/PrintplekVerwijderenDialog.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,0BAA0B,CAAC,EACzC,IAAI,EACJ,YAAY,EACZ,OAAO,GACR,EAAE;IACD,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BAmEA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Bevestiging vóór het verwijderen van een hele printplek, met wat er verdwijnt.
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, toast, } from "@flowselections/core";
|
|
5
|
+
import { printplekVerwijderImpact, verwijderPrintplek, } from "../lib/printplekken.js";
|
|
6
|
+
export function PrintplekVerwijderenDialog({ plek, onOpenChange, onKlaar, }) {
|
|
7
|
+
const [impact, setImpact] = useState(null);
|
|
8
|
+
const [bezig, setBezig] = useState(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setImpact(null);
|
|
11
|
+
if (plek)
|
|
12
|
+
void printplekVerwijderImpact(plek.id).then(setImpact).catch(() => setImpact(null));
|
|
13
|
+
}, [plek]);
|
|
14
|
+
const bevestig = async () => {
|
|
15
|
+
if (!plek)
|
|
16
|
+
return;
|
|
17
|
+
setBezig(true);
|
|
18
|
+
try {
|
|
19
|
+
await verwijderPrintplek(plek.id);
|
|
20
|
+
toast.success(`Printplek ${plek.naam} verwijderd`);
|
|
21
|
+
onOpenChange(false);
|
|
22
|
+
onKlaar();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
toast.error("Verwijderen mislukt");
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
setBezig(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const pcs = impact?.computers ?? [];
|
|
32
|
+
const kop = impact?.koppelingen ?? [];
|
|
33
|
+
return (_jsx(Dialog, { open: plek !== null, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: ["Printplek ", plek?.naam, " verwijderen?"] }), _jsx(DialogDescription, { children: "Dit kan niet ongedaan worden gemaakt." })] }), !impact ? (_jsx("p", { className: "text-muted-foreground text-sm", children: "Laden\u2026" })) : (_jsxs("ul", { className: "list-disc space-y-1 pl-5 text-sm", children: [_jsxs("li", { children: [pcs.length, " computer", pcs.length === 1 ? "" : "s", " losgekoppeld", pcs.length ? ` (${pcs.join(", ")})` : "", " \u2014 ze komen terug onder \"Computers zonder printplek\"."] }), _jsxs("li", { children: [impact.regels, " documentregel", impact.regels === 1 ? "" : "s", " van deze plek verwijderd \u2014 die documenten gebruiken voortaan de bedrijfsbrede standaard."] }), _jsxs("li", { children: [impact.printers, " printer", impact.printers === 1 ? "" : "s", " ontkoppeld (de printers zelf blijven bestaan)."] }), kop.length > 0 && (_jsxs("li", { className: "text-destructive", children: ["Gekoppeld aan ", kop.join(", "), ": die schermen weten daarna niet meer naar welke plek ze printen."] }))] })), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Annuleren" }), _jsx(Button, { variant: "destructive", disabled: !impact || bezig, onClick: () => void bevestig(), children: "Definitief verwijderen" })] })] }) }));
|
|
34
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintplekWizard.d.ts","sourceRoot":"","sources":["../../src/components/PrintplekWizard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrintplekWizard.d.ts","sourceRoot":"","sources":["../../src/components/PrintplekWizard.tsx"],"names":[],"mappings":"AA4DA,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,OAAO,GACR,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,+BAiaA"}
|