Remove refresh icon and fix Safari/WebKit runtime errors

- Removed manual refresh button from frontend (kept auto-refresh functionality)
- Fixed WebKit 'object cannot be found' error by replacing absolute positioning with flexbox
- Added lazy loading to images to prevent preload warnings
- Cleaned up unused imports and variables:
  - Removed unused useRef import
  - Removed unused colors state variable and colorService
  - Removed unused ColorSwatch import from FilamentTableV2
  - Removed unused getModifierIcon function from MaterialBadge
- Updated tests to match current implementation
- Improved layout stability for better cross-browser compatibility
- Removed temporary migration scripts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
DaX
2025-06-30 22:37:30 +02:00
parent 58b3ff2dec
commit 12e91d4c3e
33 changed files with 1646 additions and 668 deletions

74
scripts/add-basic-refills.sh Executable file
View File

@@ -0,0 +1,74 @@
#!/bin/bash
# Script to add 1 refill for each color in the database
# Run this on the API server or container with database access
# Create temporary Node.js script
cat > /tmp/add-refills.js << 'EOF'
const { Pool } = require('pg');
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: process.env.DATABASE_URL?.includes('amazonaws.com') ? { rejectUnauthorized: false } : false
});
async function addRefills() {
try {
console.log('Adding 1 refill for each color as PLA Basic filaments...\n');
// First, get all colors
const colorsResult = await pool.query('SELECT name, hex FROM colors ORDER BY name');
console.log(`Found ${colorsResult.rows.length} colors in database\n`);
let inserted = 0;
let updated = 0;
for (const color of colorsResult.rows) {
// Check if PLA Basic already exists for this color
const existing = await pool.query(
'SELECT id, refill FROM filaments WHERE tip = $1 AND finish = $2 AND boja = $3',
['PLA', 'Basic', color.name]
);
if (existing.rows.length === 0) {
// Insert new filament
await pool.query(
`INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
['PLA', 'Basic', color.name, color.hex, '1', '0 vakuum', '0 otvorena', 1, '3999']
);
console.log(`✓ Added PLA Basic ${color.name}`);
inserted++;
} else if (!existing.rows[0].refill || existing.rows[0].refill === '0') {
// Update existing to have 1 refill
await pool.query(
'UPDATE filaments SET refill = $1 WHERE id = $2',
['1', existing.rows[0].id]
);
console.log(`✓ Updated PLA Basic ${color.name} to have 1 refill`);
updated++;
} else {
console.log(`- PLA Basic ${color.name} already has ${existing.rows[0].refill} refill(s)`);
}
}
console.log(`\nSummary:`);
console.log(`- Inserted ${inserted} new PLA Basic filaments`);
console.log(`- Updated ${updated} existing filaments to have 1 refill`);
console.log(`- Total colors processed: ${colorsResult.rows.length}`);
await pool.end();
process.exit(0);
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}
addRefills();
EOF
# Run the script
cd /app && node /tmp/add-refills.js
# Clean up
rm /tmp/add-refills.js

View File

@@ -0,0 +1,56 @@
-- Add 1 refill and 1 spulna for each color as PLA Basic filaments
-- Run this with: psql $DATABASE_URL -f scripts/add-basic-refills.sql
-- First show what colors we have
SELECT name, hex FROM colors ORDER BY name;
-- Insert PLA Basic filaments with 1 refill and 1 spulna for each color that doesn't already have one
INSERT INTO filaments (tip, finish, boja, boja_hex, refill, spulna, kolicina, cena)
SELECT
'PLA' as tip,
'Basic' as finish,
c.name as boja,
c.hex as boja_hex,
1 as refill,
1 as spulna,
2 as kolicina, -- 1 refill + 1 spulna
'3999' as cena
FROM colors c
WHERE NOT EXISTS (
SELECT 1 FROM filaments f
WHERE f.tip = 'PLA'
AND f.finish = 'Basic'
AND f.boja = c.name
)
ON CONFLICT DO NOTHING;
-- Update any existing PLA Basic filaments to have 1 refill and 1 spulna
UPDATE filaments
SET refill = 1,
spulna = 1,
kolicina = 2 -- Update quantity to reflect 1 refill + 1 spulna
WHERE tip = 'PLA'
AND finish = 'Basic'
AND (refill = 0 OR spulna = 0);
-- Show summary
SELECT
'Total PLA Basic filaments with refills and spulna' as description,
COUNT(*) as count
FROM filaments
WHERE tip = 'PLA'
AND finish = 'Basic'
AND refill = 1
AND spulna = 1;
-- Show all PLA Basic filaments
SELECT
boja as color,
refill,
spulna,
kolicina as quantity,
cena as price
FROM filaments
WHERE tip = 'PLA'
AND finish = 'Basic'
ORDER BY boja;

88
scripts/update-db-via-aws.sh Executable file
View File

@@ -0,0 +1,88 @@
#!/bin/bash
# Script to update database via AWS
# Get RDS endpoint from AWS
echo "Getting RDS instance information..."
RDS_ENDPOINT=$(aws rds describe-db-instances --db-instance-identifier filamenteka --query 'DBInstances[0].Endpoint.Address' --output text)
RDS_PORT=$(aws rds describe-db-instances --db-instance-identifier filamenteka --query 'DBInstances[0].Endpoint.Port' --output text)
# Get database credentials from Secrets Manager
echo "Getting database credentials from AWS Secrets Manager..."
DB_CREDS=$(aws secretsmanager get-secret-value --secret-id filamenteka-db-credentials --query 'SecretString' --output text)
DB_USER=$(echo $DB_CREDS | jq -r '.username')
DB_PASS=$(echo $DB_CREDS | jq -r '.password')
DB_NAME=$(echo $DB_CREDS | jq -r '.database')
# Construct database URL
DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@${RDS_ENDPOINT}:${RDS_PORT}/${DB_NAME}"
echo "Connecting to database..."
echo ""
# Run the SQL script
psql "$DATABASE_URL" << 'EOF'
-- Add 1 refill for each color as PLA Basic filaments
-- First show what colors we have
\echo 'Existing colors:'
SELECT name, hex FROM colors ORDER BY name;
\echo ''
-- Insert PLA Basic filaments with 1 refill for each color that doesn't already have one
\echo 'Adding PLA Basic filaments with 1 refill for each color...'
INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena)
SELECT
'PLA' as tip,
'Basic' as finish,
c.name as boja,
c.hex as boja_hex,
'1' as refill,
'0 vakuum' as vakum,
'0 otvorena' as otvoreno,
1 as kolicina,
'3999' as cena
FROM colors c
WHERE NOT EXISTS (
SELECT 1 FROM filaments f
WHERE f.tip = 'PLA'
AND f.finish = 'Basic'
AND f.boja = c.name
)
ON CONFLICT DO NOTHING;
-- Update any existing PLA Basic filaments to have 1 refill if they don't have any
UPDATE filaments
SET refill = '1'
WHERE tip = 'PLA'
AND finish = 'Basic'
AND (refill IS NULL OR refill = '0' OR refill = '');
-- Show summary
\echo ''
\echo 'Summary:'
SELECT
'Total PLA Basic filaments with refills' as description,
COUNT(*) as count
FROM filaments
WHERE tip = 'PLA'
AND finish = 'Basic'
AND refill = '1';
-- Show all PLA Basic filaments
\echo ''
\echo 'All PLA Basic filaments:'
SELECT
boja as color,
refill,
vakum as vacuum,
otvoreno as opened,
kolicina as quantity,
cena as price
FROM filaments
WHERE tip = 'PLA'
AND finish = 'Basic'
ORDER BY boja;
EOF
echo ""
echo "Database update completed!"