From e8f9a6c6e339603a6e63b7cb669060f85285b7e4 Mon Sep 17 00:00:00 2001 From: DaX Date: Mon, 23 Jun 2025 22:54:47 +0200 Subject: [PATCH] Remove brand functionality and update Bambu Lab colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove brand field from entire codebase (frontend, backend, database) - Update Bambu Lab colors to official list with correct hex values - Clean up unused code and type definitions - Add database migration to drop brand column - Update search and filters to exclude brand references - Ensure data persistence across all application layers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: DaX --- __tests__/ui-features.test.ts | 2 +- api/migrate.js | 5 +- api/server.js | 18 +- app/upadaj/dashboard/page.tsx | 89 +++++---- .../migrations/004_remove_brand_column.sql | 2 + database/schema.sql | 2 - src/components/FilamentTableV2.tsx | 4 +- src/data/bambuLabColors.ts | 180 +++++++++++++----- src/types/filament.ts | 1 - src/types/filament.v2.ts | 1 - 10 files changed, 199 insertions(+), 105 deletions(-) create mode 100644 database/migrations/004_remove_brand_column.sql diff --git a/__tests__/ui-features.test.ts b/__tests__/ui-features.test.ts index 109b3a5..1136681 100644 --- a/__tests__/ui-features.test.ts +++ b/__tests__/ui-features.test.ts @@ -57,7 +57,7 @@ describe('UI Features Tests', () => { const dashboardContent = readFileSync(adminDashboardPath, 'utf-8'); // Check for admin header - expect(dashboardContent).toContain('Admin Dashboard'); + expect(dashboardContent).toContain('Admin'); expect(dashboardContent).toContain('Nazad na sajt'); expect(dashboardContent).toContain('Odjava'); }); diff --git a/api/migrate.js b/api/migrate.js index 2a17788..bfa5501 100644 --- a/api/migrate.js +++ b/api/migrate.js @@ -61,10 +61,9 @@ async function migrate() { // Import filaments for (const item of legacyData) { await pool.query( - `INSERT INTO filaments (brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`, + `INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`, [ - item.brand, item.tip, item.finish, item.boja, diff --git a/api/server.js b/api/server.js index f2cb9b1..8b43ead 100644 --- a/api/server.js +++ b/api/server.js @@ -132,13 +132,13 @@ app.get('/api/filaments', async (req, res) => { }); app.post('/api/filaments', authenticateToken, async (req, res) => { - const { brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena } = req.body; + const { tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena } = req.body; try { const result = await pool.query( - `INSERT INTO filaments (brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *`, - [brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina || 1, cena] + `INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *`, + [tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina || 1, cena] ); res.json(result.rows[0]); } catch (error) { @@ -149,16 +149,16 @@ app.post('/api/filaments', authenticateToken, async (req, res) => { app.put('/api/filaments/:id', authenticateToken, async (req, res) => { const { id } = req.params; - const { brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena } = req.body; + const { tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena } = req.body; try { const result = await pool.query( `UPDATE filaments - SET brand = $1, tip = $2, finish = $3, boja = $4, boja_hex = $5, - refill = $6, vakum = $7, otvoreno = $8, kolicina = $9, cena = $10, + SET tip = $1, finish = $2, boja = $3, boja_hex = $4, + refill = $5, vakum = $6, otvoreno = $7, kolicina = $8, cena = $9, updated_at = CURRENT_TIMESTAMP - WHERE id = $11 RETURNING *`, - [brand, tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina || 1, cena, id] + WHERE id = $10 RETURNING *`, + [tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina || 1, cena, id] ); res.json(result.rows[0]); } catch (error) { diff --git a/app/upadaj/dashboard/page.tsx b/app/upadaj/dashboard/page.tsx index 3323960..ed4e553 100644 --- a/app/upadaj/dashboard/page.tsx +++ b/app/upadaj/dashboard/page.tsx @@ -156,7 +156,7 @@ export default function AdminDashboard() {
-

Admin Dashboard

+

Admin

{!showAddForm && !editingFilament && (
@@ -465,13 +470,26 @@ function FilamentForm({ className="custom-select w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500" > + + + + - - - - + + + + + - + + + + + + + + +
@@ -484,12 +502,10 @@ function FilamentForm({ const selectedColorName = e.target.value; let hexValue = formData.bojaHex; - // Only use Bambu Lab colors if BambuLab brand is selected - if (formData.brand === 'Bambu Lab') { - const bambuHex = getColorHex(selectedColorName); - if (bambuHex !== "#000000") { - hexValue = bambuHex; - } + // Use Bambu Lab colors + const bambuHex = getColorHex(selectedColorName); + if (bambuHex !== "#000000") { + hexValue = bambuHex; } // Check available colors from database @@ -508,8 +524,8 @@ function FilamentForm({ className="custom-select w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500" > - {/* Show Bambu Lab colors only when BambuLab brand is selected */} - {formData.brand === 'Bambu Lab' && formData.finish && colorsByFinish[formData.finish as keyof typeof colorsByFinish] && ( + {/* Show Bambu Lab colors based on finish */} + {formData.finish && colorsByFinish[formData.finish as keyof typeof colorsByFinish] && ( {colorsByFinish[formData.finish as keyof typeof colorsByFinish].map(colorName => ( + {availableColors.map(color => (
- {/* Cena and Checkboxes on same line */} -
-
- - -
- - {/* Checkboxes grouped together horizontally */} -
+
+ + +
+ + {/* Checkboxes grouped together horizontally */} +
-
diff --git a/database/migrations/004_remove_brand_column.sql b/database/migrations/004_remove_brand_column.sql new file mode 100644 index 0000000..3e86692 --- /dev/null +++ b/database/migrations/004_remove_brand_column.sql @@ -0,0 +1,2 @@ +-- Migration to remove brand column from filaments table +ALTER TABLE filaments DROP COLUMN IF EXISTS brand CASCADE; \ No newline at end of file diff --git a/database/schema.sql b/database/schema.sql index d39e2f7..0262a55 100644 --- a/database/schema.sql +++ b/database/schema.sql @@ -15,7 +15,6 @@ CREATE TABLE colors ( -- Filaments table CREATE TABLE filaments ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), - brand VARCHAR(100) NOT NULL, tip VARCHAR(50) NOT NULL, finish VARCHAR(50) NOT NULL, boja VARCHAR(100) NOT NULL, @@ -31,7 +30,6 @@ CREATE TABLE filaments ( ); -- Create indexes for better performance -CREATE INDEX idx_filaments_brand ON filaments(brand); CREATE INDEX idx_filaments_tip ON filaments(tip); CREATE INDEX idx_filaments_boja ON filaments(boja); CREATE INDEX idx_filaments_created_at ON filaments(created_at); diff --git a/src/components/FilamentTableV2.tsx b/src/components/FilamentTableV2.tsx index 2d9fdfe..5753403 100644 --- a/src/components/FilamentTableV2.tsx +++ b/src/components/FilamentTableV2.tsx @@ -45,7 +45,6 @@ export const FilamentTableV2: React.FC = ({ filaments, loa return { id: legacy.id || `legacy-${Math.random().toString(36).substr(2, 9)}`, - brand: legacy.brand, type: legacy.tip as any || 'PLA', material, color: { name: legacy.boja, hex: legacy.bojaHex || legacy.boja_hex || '#000000' }, @@ -91,7 +90,6 @@ export const FilamentTableV2: React.FC = ({ filaments, loa // Search filter const searchLower = searchTerm.toLowerCase(); const matchesSearch = - filament.brand.toLowerCase().includes(searchLower) || filament.material.base.toLowerCase().includes(searchLower) || (filament.material.modifier?.toLowerCase().includes(searchLower)) || filament.color.name.toLowerCase().includes(searchLower) || @@ -152,7 +150,7 @@ export const FilamentTableV2: React.FC = ({ filaments, loa
setSearchTerm(e.target.value)} className="w-full px-4 py-2 pl-10 pr-4 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:border-blue-500" diff --git a/src/data/bambuLabColors.ts b/src/data/bambuLabColors.ts index d085410..15ed9f3 100644 --- a/src/data/bambuLabColors.ts +++ b/src/data/bambuLabColors.ts @@ -4,42 +4,142 @@ export interface ColorMapping { } export const bambuLabColors: Record = { - // PLA Basic Colors - 'Mistletoe Green': { hex: '#4F6359' }, - 'Indigo Purple': { hex: '#482960' }, + 'Alpine Green Sparkle': { hex: '#3F5443' }, + 'Apple Green': { hex: '#C6E188' }, + 'Arctic Whisper': { hex: '#ECF7F8' }, + 'Ash Grey': { hex: '#9B9EA0' }, + 'Aurora Purple': { hex: '#285BB7' }, + 'Azure': { hex: '#489FDF' }, + 'Baby Blue': { hex: '#AEC3ED' }, + 'Bambu Green': { hex: '#00AE42' }, + 'Beige': { hex: '#F7E6DE' }, 'Black': { hex: '#000000' }, - 'Jade White': { hex: '#F5F5F5' }, - 'Gray': { hex: '#8C9091' }, - 'Grey': { hex: '#8C9091' }, - 'Red': { hex: '#C33F45' }, - 'Hot Pink': { hex: '#F5547C' }, + 'Black Walnut': { hex: '#4D4229' }, + 'Blaze': { hex: '#E78390' }, + 'Blue': { hex: '#0A2989' }, + 'Blue Grey': { hex: '#5B6579' }, + 'Blue Hawaii': { hex: '#739FE6' }, + 'Blueberry Bubblegum': { hex: '#BADCF4' }, + 'Bone White': { hex: '#C8C5B6' }, + 'Bright Green': { hex: '#BDCF00' }, + 'Brick Red': { hex: '#9F332A' }, + 'Bronze': { hex: '#847D48' }, + 'Brown': { hex: '#9D432C' }, + 'Burgundy Red': { hex: '#951E23' }, + 'Candy Green': { hex: '#408619' }, + 'Candy Red': { hex: '#BB3A2E' }, + 'Caramel': { hex: '#A4845C' }, + 'Champagne': { hex: '#EBD0B1' }, + 'Charcoal': { hex: '#000000' }, + 'Cherry Pink': { hex: '#E9B6CC' }, + 'Chocolate': { hex: '#4A3729' }, + 'Clay Brown': { hex: '#8E621A' }, + 'Clear': { hex: '#FAFAFA' }, + 'Clear Black': { hex: '#5A5161' }, + 'Cobalt Blue': { hex: '#0055B8' }, + 'Cobalt Blue Metallic': { hex: '#39699E' }, 'Cocoa Brown': { hex: '#6F5034' }, + 'Copper Brown Metallic': { hex: '#AA6443' }, + 'Cotton Candy Cloud': { hex: '#E9E2EC' }, + 'Cream': { hex: '#F3E0B8' }, + 'Crimson Red Sparkle': { hex: '#792B36' }, + 'Cyan': { hex: '#0086D6' }, + 'Dark Blue': { hex: '#042F56' }, + 'Dark Brown': { hex: '#7D6556' }, + 'Dark Chocolate': { hex: '#4A3729' }, + 'Dark Gray': { hex: '#555555' }, + 'Dark Green': { hex: '#68724D' }, + 'Dark Red': { hex: '#BB3D43' }, + 'Dawn Radiance': { hex: '#C472A1' }, + 'Desert Tan': { hex: '#E8DBB7' }, + 'Dusk Glare': { hex: '#F6B790' }, + 'Forest Green': { hex: '#415520' }, + 'Frozen': { hex: '#A6DEF3' }, + 'Gilded Rose': { hex: '#ED982C' }, + 'Glow Blue': { hex: '#7AC0E9' }, + 'Glow Green': { hex: '#A1FFAC' }, + 'Glow Orange': { hex: '#FF9D5B' }, + 'Glow Pink': { hex: '#F17B8F' }, + 'Glow Yellow': { hex: '#F8FF80' }, + 'Gold': { hex: '#E4BD68' }, + 'Gray': { hex: '#8E9089' }, + 'Green': { hex: '#3B665E' }, + 'Hot Pink': { hex: '#F5547D' }, + 'Ice Blue': { hex: '#A3D8E1' }, + 'Indigo Blue': { hex: '#324585' }, + 'Indigo Purple': { hex: '#482A60' }, + 'Iridium Gold Metallic': { hex: '#B39B84' }, + 'Iris Purple': { hex: '#69398E' }, + 'Ivory White': { hex: '#FFFFFF' }, + 'Jade White': { hex: '#FFFFFF' }, + 'Jeans Blue': { hex: '#6E88BC' }, + 'Lake Blue': { hex: '#4672E4' }, + 'Latte Brown': { hex: '#D3B7A7' }, + 'Lava Gray': { hex: '#4D5054' }, + 'Lavender': { hex: '#B5AAD5' }, + 'Lemon Yellow': { hex: '#F7D959' }, + 'Light Blue': { hex: '#61B0FF' }, + 'Light Cyan': { hex: '#B9E3DF' }, + 'Light Gray': { hex: '#D0D2D4' }, + 'Light Jade': { hex: '#A4D6AD' }, + 'Lilac Purple': { hex: '#AE96D4' }, + 'Lime': { hex: '#C5ED48' }, + 'Lime Green': { hex: '#8EE43D' }, + 'Magenta': { hex: '#EC008C' }, + 'Malachite Green': { hex: '#16B08E' }, + 'Mandarin Orange': { hex: '#F99963' }, + 'Marine Blue': { hex: '#0078BF' }, + 'Maroon Red': { hex: '#0A2989' }, + 'Matcha Green': { hex: '#5C9748' }, + 'Mellow Yellow': { hex: '#EFDCAA' }, + 'Midnight Blaze': { hex: '#0047BB' }, + 'Mint': { hex: '#A5DAB7' }, + 'Mint Lime': { hex: '#BAF382' }, + 'Mistletoe Green': { hex: '#3F8E43' }, + 'Nardo Gray': { hex: '#747474' }, + 'Navy Blue': { hex: '#0C2340' }, + 'Nebulae': { hex: '#424379' }, + 'Neon City': { hex: '#0047BB' }, + 'Neon Green': { hex: '#ABFF1E' }, + 'Neon Orange': { hex: '#F68A1B' }, + 'Ochre Yellow': { hex: '#BC8B39' }, + 'Ocean to Meadow': { hex: '#A1E4CA' }, + 'Olive': { hex: '#748C45' }, + 'Onyx Black Sparkle': { hex: '#2D2B28' }, + 'Orange': { hex: '#FF6A13' }, + 'Oxide Green Metallic': { hex: '#1D7C6A' }, + 'Peanut Brown': { hex: '#7E5A1F' }, + 'Pink': { hex: '#F55A74' }, + 'Pink Citrus': { hex: '#F8C4BC' }, + 'Plum': { hex: '#851A52' }, + 'Pumpkin Orange': { hex: '#FF8E16' }, + 'Purple': { hex: '#5E43B7' }, + 'Red': { hex: '#C12E1F' }, + 'Red Granite': { hex: '#AD4E38' }, + 'Rose Gold': { hex: '#B29593' }, + 'Rosewood': { hex: '#472A22' }, + 'Royal Blue': { hex: '#2842AD' }, + 'Royal Purple Sparkle': { hex: '#483D8B' }, + 'Sakura Pink': { hex: '#E8AFCF' }, + 'Scarlet Red': { hex: '#DE4343' }, + 'Silver': { hex: '#A6A9AA' }, + 'Sky Blue': { hex: '#73B2E5' }, + 'Slate Gray Sparkle': { hex: '#8E9089' }, + 'Solar Breeze': { hex: '#F3D9D5' }, + 'South Beach': { hex: '#468791' }, + 'Sunflower Yellow': { hex: '#FEC601' }, + 'Tangerine Yellow': { hex: '#FFC72C' }, + 'Teal': { hex: '#77EDD7' }, + 'Terracotta': { hex: '#A25A37' }, + 'Titan Gray': { hex: '#606367' }, + 'Transparent': { hex: '#FFFFFF' }, + 'Turquoise': { hex: '#00B1B7' }, + 'Velvet Eclipse': { hex: '#000000' }, + 'Violet Purple': { hex: '#583061' }, 'White': { hex: '#FFFFFF' }, - 'Cotton Candy Cloud': { hex: ['#E7C1D5', '#8EC9E9'], isGradient: true }, - 'Sunflower Yellow': { hex: '#FEC600' }, - 'Yellow': { hex: '#FFD700' }, - 'Magenta': { hex: '#FF00FF' }, - 'Beige': { hex: '#F5DEB3' }, - 'Cyan': { hex: '#00FFFF' }, - - // PLA Matte Colors - 'Scarlet Red': { hex: '#FF2400' }, - 'Mandarin Orange': { hex: '#FF8C00' }, - 'Marine Blue': { hex: '#000080' }, - 'Charcoal': { hex: '#36454F' }, - 'Ivory White': { hex: '#FFFFF0' }, - - // Additional colors from filamentcolors.xyz - 'Orange': { hex: '#FF7146' }, - 'Blue': { hex: '#4F9CCC' }, - 'Green': { hex: '#4F6359' }, - 'Dark Green': { hex: '#656A4D' }, - 'Alpine Green': { hex: '#4F6359' }, - 'Dark Gray': { hex: '#616364' }, - 'Dark Grey': { hex: '#616364' }, - 'Blue Gray': { hex: '#647988' }, - 'Blue Grey': { hex: '#647988' }, - 'Translucent Orange': { hex: '#EF8E5B' }, + 'White Marble': { hex: '#F7F3F0' }, + 'White Oak': { hex: '#D2CCA2' }, + 'Yellow': { hex: '#F4EE2A' }, // Default fallback 'Unknown': { hex: '#CCCCCC' } @@ -84,18 +184,4 @@ export function getColorStyle(colorMapping: ColorMapping): React.CSSProperties { return { backgroundColor: Array.isArray(colorMapping.hex) ? colorMapping.hex[0] : colorMapping.hex }; -} - -export function getContrastColor(hexColor: string): string { - // Convert hex to RGB - const hex = hexColor.replace('#', ''); - const r = parseInt(hex.substr(0, 2), 16); - const g = parseInt(hex.substr(2, 2), 16); - const b = parseInt(hex.substr(4, 2), 16); - - // Calculate relative luminance - const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255; - - // Return black or white based on luminance - return luminance > 0.5 ? '#000000' : '#FFFFFF'; } \ No newline at end of file diff --git a/src/types/filament.ts b/src/types/filament.ts index 8d419fb..b39bd86 100644 --- a/src/types/filament.ts +++ b/src/types/filament.ts @@ -1,6 +1,5 @@ export interface Filament { id?: string; - brand: string; tip: string; finish: string; boja: string; diff --git a/src/types/filament.v2.ts b/src/types/filament.v2.ts index 2637c9e..18511e4 100644 --- a/src/types/filament.v2.ts +++ b/src/types/filament.v2.ts @@ -67,7 +67,6 @@ export interface FilamentV2 { id: string; // Product Info - brand: string; type: MaterialBase; material: Material; color: Color;