mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-28 21:40:58 +01:00
- Created EntityTable component for displaying test entities with expandable rows for releases. - Implemented ReleaseTable component to manage and display test releases with actions for editing and deleting. - Added ReleaseModal component for creating and editing releases - Introduced types for TestEntity, TestRelease, and related evaluations - Enhanced general settings page to include TMDB API configuration with connection testing functionality. - Added TMDBSettings component for managing TMDB API access token with reset and test connection features.
71 lines
1.3 KiB
TypeScript
71 lines
1.3 KiB
TypeScript
import { db } from '../db.ts';
|
|
|
|
/**
|
|
* Types for tmdb_settings table
|
|
*/
|
|
export interface TMDBSettings {
|
|
id: number;
|
|
api_key: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface UpdateTMDBSettingsInput {
|
|
apiKey?: string;
|
|
}
|
|
|
|
/**
|
|
* All queries for tmdb_settings table
|
|
* Singleton pattern - only one settings record exists
|
|
*/
|
|
export const tmdbSettingsQueries = {
|
|
/**
|
|
* Get the TMDB settings (singleton)
|
|
*/
|
|
get(): TMDBSettings | undefined {
|
|
return db.queryFirst<TMDBSettings>('SELECT * FROM tmdb_settings WHERE id = 1');
|
|
},
|
|
|
|
/**
|
|
* Update TMDB settings
|
|
*/
|
|
update(input: UpdateTMDBSettingsInput): boolean {
|
|
const updates: string[] = [];
|
|
const params: (string | number)[] = [];
|
|
|
|
if (input.apiKey !== undefined) {
|
|
updates.push('api_key = ?');
|
|
params.push(input.apiKey);
|
|
}
|
|
|
|
if (updates.length === 0) {
|
|
return false;
|
|
}
|
|
|
|
// Add updated_at
|
|
updates.push('updated_at = CURRENT_TIMESTAMP');
|
|
params.push(1); // id is always 1
|
|
|
|
const affected = db.execute(
|
|
`UPDATE tmdb_settings SET ${updates.join(', ')} WHERE id = ?`,
|
|
...params
|
|
);
|
|
|
|
return affected > 0;
|
|
},
|
|
|
|
/**
|
|
* Reset TMDB settings to defaults
|
|
*/
|
|
reset(): boolean {
|
|
const affected = db.execute(`
|
|
UPDATE tmdb_settings SET
|
|
api_key = '',
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = 1
|
|
`);
|
|
|
|
return affected > 0;
|
|
}
|
|
};
|