fix(db): added access log and small addition to systemd service

This commit is contained in:
kilyabin
2026-03-09 23:43:58 +04:00
parent 0508333aeb
commit bb24bf9aa1
4 changed files with 26 additions and 6 deletions

View File

@@ -26,6 +26,15 @@ async function handler(
// Обновление настроек // Обновление настроек
const { weekNavigationEnabled, showAddGroupButton, showTeachersButton, vacationModeEnabled, vacationModeContent, debug } = req.body const { weekNavigationEnabled, showAddGroupButton, showTeachersButton, vacationModeEnabled, vacationModeContent, debug } = req.body
console.log('[Settings API] Received settings update:', {
weekNavigationEnabled,
showAddGroupButton,
showTeachersButton,
vacationModeEnabled,
vacationModeContent,
hasDebug: debug !== undefined
})
if (typeof weekNavigationEnabled !== 'boolean') { if (typeof weekNavigationEnabled !== 'boolean') {
res.status(400).json({ error: 'weekNavigationEnabled must be a boolean' }) res.status(400).json({ error: 'weekNavigationEnabled must be a boolean' })
return return

View File

@@ -419,6 +419,8 @@ export function getSettings(): AppSettings {
export function updateSettings(settings: AppSettings): void { export function updateSettings(settings: AppSettings): void {
const database = getDatabase() const database = getDatabase()
console.log('[Database] updateSettings called, DB path:', DB_PATH)
const defaultSettings: AppSettings = { const defaultSettings: AppSettings = {
weekNavigationEnabled: false, weekNavigationEnabled: false,
showAddGroupButton: true, showAddGroupButton: true,
@@ -441,9 +443,16 @@ export function updateSettings(settings: AppSettings): void {
...settingsWithoutDebug ...settingsWithoutDebug
} }
database console.log('[Database] Saving merged settings:', mergedSettings)
.prepare('INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)')
.run('app', JSON.stringify(mergedSettings)) try {
const stmt = database.prepare('INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)')
const result = stmt.run('app', JSON.stringify(mergedSettings))
console.log('[Database] Settings save result:', result)
} catch (error) {
console.error('[Database] Error executing SQL:', error)
throw error
}
} }
// ==================== Функции для работы с паролем ==================== // ==================== Функции для работы с паролем ====================

View File

@@ -62,12 +62,14 @@ export function loadSettings(forceRefresh: boolean = false): AppSettings {
*/ */
export function saveSettings(settings: AppSettings): void { export function saveSettings(settings: AppSettings): void {
try { try {
console.log('[Settings] Saving settings to database:', settings)
updateSettingsInDB(settings) updateSettingsInDB(settings)
console.log('[Settings] Settings saved successfully')
// Сбрасываем кеш и timestamp // Сбрасываем кеш и timestamp
cachedSettings = null cachedSettings = null
cacheTimestamp = 0 cacheTimestamp = 0
} catch (error) { } catch (error) {
console.error('Error saving settings to database:', error) console.error('[Settings] Error saving settings to database:', error)
throw new Error('Failed to save settings') throw new Error('Failed to save settings')
} }
} }

View File

@@ -32,7 +32,7 @@ NoNewPrivileges=true
PrivateTmp=true PrivateTmp=true
ProtectSystem=strict ProtectSystem=strict
ProtectHome=true ProtectHome=true
ReadWritePaths=/opt/kspguti-schedule ReadWritePaths=/opt/kspguti-schedule /opt/kspguti-schedule/db
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target