Remove 3dfilamentprofiles integration (Issue #7)
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled
Some checks failed
CI / style (push) Has been cancelled
CI / build-client (push) Has been cancelled
CI / build-amd64 (push) Has been cancelled
CI / build-tester (push) Has been cancelled
CI / test (cockroachdb) (push) Has been cancelled
CI / test (mariadb) (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / test (sqlite) (push) Has been cancelled
CI / build-arm64 (push) Has been cancelled
CI / build-armv7 (push) Has been cancelled
CI / publish-images (push) Has been cancelled
CI / publish-release (push) Has been cancelled
3dfilamentprofiles.com has Vercel bot protection blocking automated requests. Their GitHub repo only has sample data (~3 filaments). SpoolmanDB already has 6,957+ filaments, making this unnecessary. Removed: - spoolman/externaldb.py: ExternalSource enum, Filament3DFP model, 3dfp sync - client/src/utils/queryExternalDB.ts: ExternalSource enum, source field - client/src/components/filamentImportModal.tsx: Source filter tabs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { useTranslate } from "@refinedev/core";
|
||||
import { Form, Modal, Select, Tabs } from "antd";
|
||||
import { useMemo, useState } from "react";
|
||||
import { Form, Modal, Select } from "antd";
|
||||
import { useMemo } from "react";
|
||||
import { Trans } from "react-i18next";
|
||||
import { formatFilamentLabel } from "../pages/spools/functions";
|
||||
import { searchMatches } from "../utils/filtering";
|
||||
import { ExternalFilament, ExternalSource, useGetExternalDBFilaments } from "../utils/queryExternalDB";
|
||||
import { ExternalFilament, useGetExternalDBFilaments } from "../utils/queryExternalDB";
|
||||
|
||||
export function FilamentImportModal(props: {
|
||||
isOpen: boolean;
|
||||
@@ -13,25 +13,14 @@ export function FilamentImportModal(props: {
|
||||
}) {
|
||||
const [form] = Form.useForm();
|
||||
const t = useTranslate();
|
||||
const [selectedSource, setSelectedSource] = useState<ExternalSource | "all">("all");
|
||||
|
||||
const externalFilaments = useGetExternalDBFilaments();
|
||||
|
||||
// Filter and format filaments based on selected source
|
||||
// Format filaments for the select dropdown
|
||||
const filamentOptions = useMemo(() => {
|
||||
const filtered = externalFilaments.data?.filter((item) => {
|
||||
if (selectedSource === "all") return true;
|
||||
return item.source === selectedSource;
|
||||
}) ?? [];
|
||||
|
||||
const options = filtered.map((item) => {
|
||||
// Add source indicator to label if showing all
|
||||
const sourceIndicator = selectedSource === "all" && item.source === ExternalSource.FILAMENT_PROFILES_3D
|
||||
? "[3DFP] "
|
||||
: "";
|
||||
|
||||
const options = (externalFilaments.data ?? []).map((item) => {
|
||||
return {
|
||||
label: sourceIndicator + formatFilamentLabel(
|
||||
label: formatFilamentLabel(
|
||||
item.name,
|
||||
item.diameter,
|
||||
item.manufacturer,
|
||||
@@ -46,20 +35,8 @@ export function FilamentImportModal(props: {
|
||||
|
||||
options.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: "base" }));
|
||||
return options;
|
||||
}, [externalFilaments.data, selectedSource]);
|
||||
|
||||
// Count filaments by source
|
||||
const counts = useMemo(() => {
|
||||
const spoolmandb = externalFilaments.data?.filter(f => f.source === ExternalSource.SPOOLMANDB || !f.source).length ?? 0;
|
||||
const threeDFP = externalFilaments.data?.filter(f => f.source === ExternalSource.FILAMENT_PROFILES_3D).length ?? 0;
|
||||
return { spoolmandb, threeDFP, total: spoolmandb + threeDFP };
|
||||
}, [externalFilaments.data]);
|
||||
|
||||
const handleSourceChange = (key: string) => {
|
||||
setSelectedSource(key as ExternalSource | "all");
|
||||
form.resetFields(["filament"]);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t("filament.form.import_external")}
|
||||
@@ -77,25 +54,6 @@ export function FilamentImportModal(props: {
|
||||
/>
|
||||
</p>
|
||||
|
||||
<Tabs
|
||||
activeKey={selectedSource}
|
||||
onChange={handleSourceChange}
|
||||
items={[
|
||||
{
|
||||
key: "all",
|
||||
label: `${t("filament.form.all_sources")} (${counts.total})`,
|
||||
},
|
||||
{
|
||||
key: ExternalSource.SPOOLMANDB,
|
||||
label: `SpoolmanDB (${counts.spoolmandb})`,
|
||||
},
|
||||
{
|
||||
key: ExternalSource.FILAMENT_PROFILES_3D,
|
||||
label: `3D Filament Profiles (${counts.threeDFP})`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
<Form
|
||||
layout="vertical"
|
||||
form={form}
|
||||
@@ -107,7 +65,6 @@ export function FilamentImportModal(props: {
|
||||
props.onImport(filament);
|
||||
props.onClose();
|
||||
form.resetFields();
|
||||
setSelectedSource("all");
|
||||
}}
|
||||
>
|
||||
<Form.Item name="filament" rules={[{ required: true }]}>
|
||||
|
||||
@@ -22,11 +22,6 @@ export enum Pattern {
|
||||
SPARKLE = "sparkle",
|
||||
}
|
||||
|
||||
export enum ExternalSource {
|
||||
SPOOLMANDB = "spoolmandb",
|
||||
FILAMENT_PROFILES_3D = "3dfilamentprofiles",
|
||||
}
|
||||
|
||||
export interface ExternalFilament {
|
||||
id: string;
|
||||
manufacturer: string;
|
||||
@@ -48,7 +43,6 @@ export interface ExternalFilament {
|
||||
pattern?: Pattern;
|
||||
translucent: boolean;
|
||||
glow: boolean;
|
||||
source?: ExternalSource;
|
||||
}
|
||||
|
||||
export interface ExternalMaterial {
|
||||
|
||||
Reference in New Issue
Block a user