feat: add tech stack information and app version display in SettingsScreen

This commit is contained in:
Gabriel20xx committed 2026-07-31 09:38:54 +02:00
1 parent 10815300aa
commit 9559acf79a
5 files changed
+136 -36

No files matched your search

@@ -64,6 +64,18 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
private val TECH_STACK =
listOf(
"Language" to "Kotlin 2.2.21",
"UI Toolkit" to "Jetpack Compose (BOM 2024.06.00)",
"Design System" to "Material 3",
"Local Database" to "Room 2.7.0",
"Networking" to "Retrofit 2.9.0 / OkHttp 4.12.0",
"Concurrency" to "Kotlin Coroutines 1.7.3",
"Background Work" to "WorkManager 2.9.0",
"Navigation" to "Navigation Compose 2.7.5",
)
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun SettingsScreen( fun SettingsScreen(
@@ -91,6 +103,14 @@ fun SettingsScreen(
val syncIntervalMs by preferencesManager.syncPollIntervalMs.collectAsState() val syncIntervalMs by preferencesManager.syncPollIntervalMs.collectAsState()
var syncIntervalInput by remember(syncIntervalMs) { mutableStateOf(syncIntervalMs.toString()) } var syncIntervalInput by remember(syncIntervalMs) { mutableStateOf(syncIntervalMs.toString()) }
var syncIntervalError by remember { mutableStateOf<String?>(null) } var syncIntervalError by remember { mutableStateOf<String?>(null) }
val appVersion =
remember {
try {
context.packageManager.getPackageInfo(context.packageName, 0).versionName ?: "unknown"
} catch (e: PackageManager.NameNotFoundException) {
"unknown"
}
}
// Authentication UI removed // Authentication UI removed
// Permission launcher for Android 13+ notification permission // Permission launcher for Android 13+ notification permission
@@ -466,6 +486,49 @@ fun SettingsScreen(
} }
} }
// About / Tech Stack
Text(
text = stringResource(R.string.about),
style = MaterialTheme.typography.titleMedium,
)
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
) {
Column(
modifier = Modifier.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = stringResource(R.string.app_version, appVersion),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = stringResource(R.string.tech_stack),
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
TECH_STACK.forEach { (label, value) ->
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Text(
text = label,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Text(
text = value,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)
}
}
}
}
// Leave Server section // Leave Server section
Text( Text(
text = stringResource(R.string.leave_server_section), text = stringResource(R.string.leave_server_section),
@@ -48,6 +48,9 @@
<string name="notify_list_removed_desc">Notify when a list/table is deleted</string> <string name="notify_list_removed_desc">Notify when a list/table is deleted</string>
<string name="notifications_footer">Notifications fire only when the app is in background or not visible.</string> <string name="notifications_footer">Notifications fire only when the app is in background or not visible.</string>
<string name="open_logs">Open Logs</string> <string name="open_logs">Open Logs</string>
<string name="about">About</string>
<string name="app_version">App version %1$s</string>
<string name="tech_stack">Tech Stack</string>
<string name="leave_server_section">Leave Server</string> <string name="leave_server_section">Leave Server</string>
<string name="leaving_removes_local_data">Leaving removes local data</string> <string name="leaving_removes_local_data">Leaving removes local data</string>
<string name="disconnects_and_clears_db">Disconnects and clears local database</string> <string name="disconnects_and_clears_db">Disconnects and clears local database</string>
+1 -34
View File
@@ -18,8 +18,7 @@
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"express": "^4.18.2", "express": "^4.18.2",
"pg": "^8.11.3", "pg": "^8.11.3",
"prettier": "^3.3.3", "prettier": "^3.3.3"
"ws": "^8.16.0"
}, },
"devDependencies": { "devDependencies": {
"@types/better-sqlite3": "^7.6.11", "@types/better-sqlite3": "^7.6.11",
@@ -27,7 +26,6 @@
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/node": "^20.10.6", "@types/node": "^20.10.6",
"@types/pg": "^8.10.2", "@types/pg": "^8.10.2",
"@types/ws": "^8.5.10",
"ts-node-dev": "^2.0.0", "ts-node-dev": "^2.0.0",
"typescript": "^5.3.3" "typescript": "^5.3.3"
} }
@@ -452,16 +450,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/ws": {
"version": "8.18.1",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "7.18.0", "version": "7.18.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.18.0.tgz",
@@ -3717,27 +3705,6 @@
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/ws": {
"version": "8.18.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/xtend": { "node_modules/xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
+3 -1
View File
@@ -291,7 +291,9 @@ class PostgresAdapter implements DBAdapter {
} }
const clientType = (process.env.DB_CLIENT || process.env.DB_TYPE || 'sqlite').toLowerCase(); const clientType = (process.env.DB_CLIENT || process.env.DB_TYPE || 'sqlite').toLowerCase();
export const dbAdapter: DBAdapter = clientType === 'postgres' || clientType === 'postgresql' const isPostgres = clientType === 'postgres' || clientType === 'postgresql';
export const dbEngine = isPostgres ? 'PostgreSQL' : 'SQLite';
export const dbAdapter: DBAdapter = isPostgres
? new PostgresAdapter() ? new PostgresAdapter()
: new SqliteAdapter(); : new SqliteAdapter();
+66 -1
View File
@@ -1,8 +1,28 @@
import { Router, Request, Response } from 'express'; import { Router, Request, Response } from 'express';
import { dbAdapter } from '../db'; import fs from 'fs';
import path from 'path';
import { dbAdapter, dbEngine } from '../db';
const router = Router(); const router = Router();
interface PackageJson {
version?: string;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
}
let packageJson: PackageJson = {};
try {
packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8'));
} catch (error) {
console.error('Error reading package.json:', error);
}
function depVersion(name: string): string {
const deps = { ...packageJson.devDependencies, ...packageJson.dependencies };
return deps[name] ? deps[name].replace(/^[^\d]*/, '') : 'unknown';
}
// Serve the web UI // Serve the web UI
router.get('/', (req: Request, res: Response) => { router.get('/', (req: Request, res: Response) => {
res.send(` res.send(`
@@ -196,6 +216,15 @@ router.get('/', (req: Request, res: Response) => {
</div> </div>
</div> </div>
<div class="stats">
<h2 style="margin-bottom: 10px;">Tech Stack</h2>
<div class="stat-grid" id="tech-stack-grid">
<div class="stat-card">
<div class="stat-label">Loading...</div>
</div>
</div>
</div>
<div id="lists-container" class="lists-container"> <div id="lists-container" class="lists-container">
<div class="no-data">Loading...</div> <div class="no-data">Loading...</div>
</div> </div>
@@ -325,8 +354,30 @@ router.get('/', (req: Request, res: Response) => {
} }
} }
async function loadTechStack() {
try {
const response = await fetch('/web/info');
if (!response.ok) {
throw new Error('HTTP ' + response.status + ': ' + response.statusText);
}
const info = await response.json();
const grid = document.getElementById('tech-stack-grid');
grid.innerHTML = info.stack.map(entry => \`
<div class="stat-card">
<div class="stat-label">\${entry.label}</div>
<div class="stat-value" style="font-size: 16px;">\${entry.value}</div>
</div>
\`).join('');
} catch (error) {
console.error('Error loading tech stack:', error);
const grid = document.getElementById('tech-stack-grid');
grid.innerHTML = '<div class="stat-card"><div class="stat-label" style="color: #dc3545;">Failed to load tech stack</div></div>';
}
}
// Load data on page load // Load data on page load
loadData(); loadData();
loadTechStack();
// Auto-refresh every 5 seconds // Auto-refresh every 5 seconds
setInterval(loadData, 5000); setInterval(loadData, 5000);
@@ -336,6 +387,20 @@ router.get('/', (req: Request, res: Response) => {
`); `);
}); });
// API endpoint to get server tech stack info (no auth required for web UI)
router.get('/web/info', (req: Request, res: Response) => {
res.json({
appVersion: packageJson.version ?? 'unknown',
stack: [
{ label: 'Runtime', value: `Node.js ${process.version}` },
{ label: 'Language', value: `TypeScript ${depVersion('typescript')}` },
{ label: 'Web Framework', value: `Express ${depVersion('express')}` },
{ label: 'Database', value: `${dbEngine} (${dbEngine === 'PostgreSQL' ? 'pg ' + depVersion('pg') : 'better-sqlite3 ' + depVersion('better-sqlite3')})` },
{ label: 'CORS', value: `cors ${depVersion('cors')}` },
],
});
});
// API endpoint to get all data (no auth required for web UI) // API endpoint to get all data (no auth required for web UI)
router.get('/web/data', async (req: Request, res: Response) => { router.get('/web/data', async (req: Request, res: Response) => {
try { try {