1 Commits

Author SHA1 Message Date
Toni
3fc28af508 Refactor UI auth flow, remove uploads app files
Rework client UI state: move and update showLogin/showApp in public/app.js to explicitly set display styles when toggling screens and ensure user info and file load on app show. Remove the theme toggle from public/index.html and simplify CSS by collapsing color variable definitions (dark-theme-focused) in public/style.css. Add a VS Code workspace file. Remove the old uploads/Think app (Dockerfile, package.json, server.js and associated lockfile).
2026-02-09 11:08:59 +01:00
8 changed files with 31 additions and 2296 deletions

View File

@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

View File

@@ -65,18 +65,7 @@ document.getElementById('logout-btn').addEventListener('click', async () => {
window.location.reload(); window.location.reload();
}); });
function showLogin() {
loginScreen.classList.remove('hidden');
appScreen.classList.add('hidden');
}
function showApp() {
loginScreen.classList.add('hidden');
appScreen.classList.remove('hidden');
document.getElementById('user-display').textContent = currentUser.username;
loadFiles();
updateViewIcon();
}
// --- View Mode --- // --- View Mode ---
function toggleView() { function toggleView() {
@@ -94,6 +83,27 @@ function updateViewIcon() {
} }
viewToggleBtn.addEventListener('click', toggleView); viewToggleBtn.addEventListener('click', toggleView);
// --- Auth / UI State ---
function showLogin() {
// Force style to ensure hidden/visible
loginScreen.classList.remove('hidden');
loginScreen.style.display = 'flex';
appScreen.classList.add('hidden');
}
function showApp() {
loginScreen.classList.add('hidden');
loginScreen.style.display = 'none'; // Force hide
appScreen.classList.remove('hidden');
document.getElementById('user-display').textContent = currentUser.username;
loadFiles();
updateViewIcon();
}
// --- Files --- // --- Files ---
async function loadFiles(path = currentPath) { async function loadFiles(path = currentPath) {
try { try {

View File

@@ -40,9 +40,7 @@
</div> </div>
<div class="controls"> <div class="controls">
<span id="user-display"></span> <span id="user-display"></span>
<button id="theme-toggle" class="btn secondary" aria-label="Toggle Dark Mode">
<span class="icon">🌓</span>
</button>
<button id="logout-btn" class="btn secondary">Logout</button> <button id="logout-btn" class="btn secondary">Logout</button>
</div> </div>
</header> </header>

View File

@@ -1,17 +1,4 @@
:root { :root {
--bg-color: #f8f9fa;
--card-bg: #ffffff;
--text-color: #1f2937;
--text-secondary: #6b7280;
--primary-color: #3b82f6;
--primary-hover: #2563eb;
--border-color: #e5e7eb;
--danger-color: #ef4444;
--modal-bg: rgba(0, 0, 0, 0.8);
}
/* Dark Mode Variables */
[data-theme="dark"] {
--bg-color: #111827; --bg-color: #111827;
--card-bg: #1f2937; --card-bg: #1f2937;
--text-color: #f9fafb; --text-color: #f9fafb;
@@ -19,22 +6,10 @@
--primary-color: #60a5fa; --primary-color: #60a5fa;
--primary-hover: #3b82f6; --primary-hover: #3b82f6;
--border-color: #374151; --border-color: #374151;
--danger-color: #ef4444;
--modal-bg: rgba(0, 0, 0, 0.9); --modal-bg: rgba(0, 0, 0, 0.9);
} }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg-color: #111827;
--card-bg: #1f2937;
--text-color: #f9fafb;
--text-secondary: #9ca3af;
--primary-color: #60a5fa;
--primary-hover: #3b82f6;
--border-color: #374151;
--modal-bg: rgba(0, 0, 0, 0.9);
}
}
body { body {
font-family: 'Inter', sans-serif; font-family: 'Inter', sans-serif;
background-color: var(--bg-color); background-color: var(--bg-color);

View File

@@ -1,16 +0,0 @@
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
# Expose port 3000
EXPOSE 3000
# Create uploads directory
RUN mkdir -p uploads
CMD ["node", "server.js"]

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +0,0 @@
{
"name": "simple-file-server",
"version": "1.0.0",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"adm-zip": "^0.5.16",
"archiver": "^7.0.1",
"bcryptjs": "^3.0.3",
"cors": "^2.8.6",
"dotenv": "^17.2.4",
"express": "^5.2.1",
"express-session": "^1.19.0",
"mariadb": "^3.4.5",
"multer": "^2.0.2"
}
}

View File

@@ -1,51 +0,0 @@
const express = require('express');
const cors = require('cors');
const path = require('path');
const session = require('express-session');
require('dotenv').config();
const { initUserTable } = require('./db/connection');
const authRoutes = require('./routes/auth');
const fileRoutes = require('./routes/files');
const app = express();
const PORT = process.env.PORT || 3000;
// Initialize DB
initUserTable();
// Middleware
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Session
app.use(session({
secret: process.env.SESSION_SECRET || 'supersecretkey',
resave: false,
saveUninitialized: false,
cookie: { secure: false } // Set to true if using HTTPS
}));
// Auth Middleware
const requireAuth = (req, res, next) => {
if (req.session.user) {
next();
} else {
res.status(401).json({ error: 'Unauthorized' });
}
};
// Routes
app.use('/api/auth', authRoutes);
app.use('/api', requireAuth, fileRoutes);
// Static files (public) - protect if needed, but for now let's allow loading the app
// We can protect specific assets if we want, but the API is protected.
// Actually, if we want to force login, we can serve a login page or handle it in specific separate file.
// The main `index.html` handles the login UI, so it should be public.
app.use(express.static('public'));
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});