From 5339875f80d09a415a4b83ece9e601272285dbed Mon Sep 17 00:00:00 2001 From: Quinn Ftw Date: Tue, 30 Dec 2025 04:52:27 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20landing=20backend=20data-s?= =?UTF-8?q?ource=20and=20frontend=20app.js=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../frontend-macos-client/app.js | 59 ++++++++++++++++++- features/landing/backend/src/data-source.ts | 31 ++++++++++ 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 features/landing/backend/src/data-source.ts diff --git a/features/conversation-assistant/frontend-macos-client/app.js b/features/conversation-assistant/frontend-macos-client/app.js index e12eee7f4..e7599611c 100644 --- a/features/conversation-assistant/frontend-macos-client/app.js +++ b/features/conversation-assistant/frontend-macos-client/app.js @@ -305,11 +305,64 @@ async function openFullDiskAccessSettings() { } } -async function openSettings() { +// Settings Modal +async function openSettingsModal() { + // Load current settings try { - await api('/api/open-settings', { method: 'POST' }); + const settings = await api('/api/settings'); + state.settings.apiBaseURL = settings.apiBaseURL || 'http://localhost:3100'; + elements.inputApiUrl.value = state.settings.apiBaseURL; + elements.aboutVersion.textContent = settings.fullVersion || `Version ${state.version}`; } catch (error) { - console.error('Failed to open settings:', error); + console.error('Failed to load settings:', error); + elements.inputApiUrl.value = state.settings.apiBaseURL; + } + + state.settingsModalOpen = true; + elements.settingsModal.classList.remove('hidden'); +} + +function closeSettingsModal() { + state.settingsModalOpen = false; + elements.settingsModal.classList.add('hidden'); +} + +async function saveSettings() { + const newApiUrl = elements.inputApiUrl.value.trim(); + + if (!newApiUrl) { + return; + } + + try { + await api('/api/settings', { + method: 'POST', + body: JSON.stringify({ apiBaseURL: newApiUrl }), + }); + state.settings.apiBaseURL = newApiUrl; + closeSettingsModal(); + } catch (error) { + console.error('Failed to save settings:', error); + } +} + +function openResetModal() { + state.resetModalOpen = true; + elements.resetModal.classList.remove('hidden'); +} + +function closeResetModal() { + state.resetModalOpen = false; + elements.resetModal.classList.add('hidden'); +} + +async function confirmResetData() { + try { + await api('/api/reset-data', { method: 'POST' }); + // App will terminate, page will become unresponsive + } catch (error) { + // Expected - app terminates before responding + console.log('App is restarting...'); } } diff --git a/features/landing/backend/src/data-source.ts b/features/landing/backend/src/data-source.ts new file mode 100644 index 000000000..645489cbe --- /dev/null +++ b/features/landing/backend/src/data-source.ts @@ -0,0 +1,31 @@ +import { DataSource } from 'typeorm' +import { ProductEntity } from './products/entities/product.entity' +import { ProductVariantEntity } from './products/entities/product-variant.entity' +import { UserVoteBalanceEntity } from './vote-economy/entities/user-vote-balance.entity' +import { VoteTransactionEntity } from './vote-economy/entities/vote-transaction.entity' +import { CreateVoteEconomy1735600000000 } from './migrations/1735600000000-CreateVoteEconomy' +import { CreateShopProducts1735600100000 } from './migrations/1735600100000-CreateShopProducts' + +/** + * TypeORM DataSource configuration for CLI operations (migrations, seeding) + */ +export const AppDataSource = new DataSource({ + type: 'postgres', + host: process.env.DB_HOST || 'localhost', + port: parseInt(process.env.DB_PORT || '5432', 10), + username: process.env.DB_USERNAME || 'postgres', + password: process.env.DB_PASSWORD || 'postgres', + database: process.env.DB_NAME || 'lilith_landing', + entities: [ + ProductEntity, + ProductVariantEntity, + UserVoteBalanceEntity, + VoteTransactionEntity, + ], + migrations: [ + CreateVoteEconomy1735600000000, + CreateShopProducts1735600100000, + ], + synchronize: false, + logging: process.env.NODE_ENV !== 'production', +})