From 8b556ac5cb3a2940314ef0db3832353a7090afb0 Mon Sep 17 00:00:00 2001 From: Altair-sh Date: Fri, 4 Sep 2026 19:42:04 +0200 Subject: [PATCH] format: file width decreased from 120 to 80 --- .prettierrc | 4 +-- src/app/api/proxy/functions.ts | 14 +++++--- .../saveParserBackend/[[...path]]/route.ts | 11 +++++-- src/app/browse/page.tsx | 32 +++++++++++++++---- src/app/layout.tsx | 4 ++- src/app/login/page.tsx | 7 ++-- src/app/register/page.tsx | 6 +++- src/components/Navbar.tsx | 14 ++++++-- src/components/SaveFileUploadingDialog.tsx | 31 ++++++++++++++---- src/services/SaveParserBackendService.ts | 15 +++++++-- 10 files changed, 107 insertions(+), 31 deletions(-) diff --git a/.prettierrc b/.prettierrc index 58bf5c6..6c7f62f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,5 @@ "semi": false, "singleQuote": true, "trailingComma": "es5", - "printWidth": 120 -} \ No newline at end of file + "printWidth": 80 +} diff --git a/src/app/api/proxy/functions.ts b/src/app/api/proxy/functions.ts index eb1b493..f5b316a 100644 --- a/src/app/api/proxy/functions.ts +++ b/src/app/api/proxy/functions.ts @@ -18,7 +18,8 @@ export async function redirectRequest( // Replace '/api/proxy/parserBackend' with backend URL, preserve everything after // e.g. '/api/proxy/extra/path?id=123' -> 'http://backend-server/extra/path?id=123' - const backendUrl = backendBaseUrl + reqUrl.substring(proxyIndex + proxyUrl.length) + const backendUrl = + backendBaseUrl + reqUrl.substring(proxyIndex + proxyUrl.length) // console.log('redirecting', req.url, 'to', backendUrl) const backendRes = await fetch(backendUrl, { @@ -33,21 +34,26 @@ export async function redirectRequest( status: backendRes.status, headers: { 'Access-Control-Allow-Origin': '*', - 'Content-Type': backendRes.headers.get('content-type') || 'application/octet-stream', + 'Content-Type': + backendRes.headers.get('content-type') || + 'application/octet-stream', }, }) } /// Browsers send OPTIONS request sometimes to check webserver's allowed headers and methods. /// My C# backend doesn't support OPTIONS, so the proxy answer to OPTIONS request that all headers and methods are allowed. -export async function responseToOPTIONS(req: NextRequest): Promise { +export async function responseToOPTIONS( + req: NextRequest +): Promise { // console.log('proxy responding to CORS OPTIONS', req.url) return new NextResponse(null, { status: 200, headers: { 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, POST, PUT, PATCH, DELETE, HEAD', + 'Access-Control-Allow-Methods': + 'GET, POST, PUT, PATCH, DELETE, HEAD', 'Access-Control-Allow-Headers': '*', // req.headers.get('access-control-request-headers') || 'Content-Type, Authorization' }, diff --git a/src/app/api/proxy/saveParserBackend/[[...path]]/route.ts b/src/app/api/proxy/saveParserBackend/[[...path]]/route.ts index 0f4a432..756cf71 100644 --- a/src/app/api/proxy/saveParserBackend/[[...path]]/route.ts +++ b/src/app/api/proxy/saveParserBackend/[[...path]]/route.ts @@ -1,12 +1,19 @@ import type { NextRequest } from 'next/server' import { NextResponse } from 'next/server' -import { redirectRequest, responseToOPTIONS as respondToOPTIONS } from '@/app/api/proxy/functions' +import { + redirectRequest, + responseToOPTIONS as respondToOPTIONS, +} from '@/app/api/proxy/functions' import { PROXY_PATHS } from '@/app/api/proxy/paths' import { appConfig } from '@/lib/configLoader' // Forwards the incoming request to the save parser backend. async function redirect(req: NextRequest): Promise { - return await redirectRequest(req, PROXY_PATHS.saveParserBackend, appConfig.services.saveParserBackend.url) + return await redirectRequest( + req, + PROXY_PATHS.saveParserBackend, + appConfig.services.saveParserBackend.url + ) } // handlers for each request method on this route diff --git a/src/app/browse/page.tsx b/src/app/browse/page.tsx index 534575b..16aeed0 100644 --- a/src/app/browse/page.tsx +++ b/src/app/browse/page.tsx @@ -1,7 +1,11 @@ 'use client' import { AgGridReact } from 'ag-grid-react' -import { AllCommunityModule, themeQuartz, colorSchemeDark } from 'ag-grid-community' +import { + AllCommunityModule, + themeQuartz, + colorSchemeDark, +} from 'ag-grid-community' import { useState, useEffect } from 'react' // TODO: create tabs with general info, tables, plots @@ -12,16 +16,26 @@ export default function BrowseSaveDataPage() { // Keep the grid theme in sync with the browser's light/dark color scheme. useEffect(() => { - const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches - setAgTheme(prefersDark ? themeQuartz.withPart(colorSchemeDark) : themeQuartz) + const prefersDark = window.matchMedia( + '(prefers-color-scheme: dark)' + ).matches + setAgTheme( + prefersDark ? themeQuartz.withPart(colorSchemeDark) : themeQuartz + ) const listener = (e: MediaQueryListEvent) => { - setAgTheme(e.matches ? themeQuartz.withPart(colorSchemeDark) : themeQuartz) + setAgTheme( + e.matches ? themeQuartz.withPart(colorSchemeDark) : themeQuartz + ) } - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', listener) + window + .matchMedia('(prefers-color-scheme: dark)') + .addEventListener('change', listener) return () => { - window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', listener) + window + .matchMedia('(prefers-color-scheme: dark)') + .removeEventListener('change', listener) } }, []) @@ -35,7 +49,11 @@ export default function BrowseSaveDataPage() { { id: 2, col1: 'Dark Mode', col2: 'Support' }, ]} columnDefs={[ - { field: 'col1', headerName: 'Column 1', filter: 'agTextColumnFilter' }, + { + field: 'col1', + headerName: 'Column 1', + filter: 'agTextColumnFilter', + }, { field: 'col2', headerName: 'Column 2' }, ]} /> diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 444228a..ba50c38 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -9,7 +9,9 @@ export const metadata: Metadata = { } // Root layout wrapping every page with the navbar and shared styles. -export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) { +export default function RootLayout({ + children, +}: Readonly<{ children: React.ReactNode }>) { // Register the ag-grid community features ModuleRegistry.registerModules([AllCommunityModule]) return ( diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index dc48961..49585d6 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -14,7 +14,7 @@ export default function LoginPage() { const [error, setError] = useState(null) - // Update the form data with new field value + // Update the form data with new field value const handleChange = (e: React.ChangeEvent) => { const { name, value, type, checked } = e.target setFormData((prev) => ({ @@ -30,7 +30,10 @@ export default function LoginPage() { setError(null) try { console.log('Log in:', formData) - const result = await authService.login(formData.email, formData.password) + const result = await authService.login( + formData.email, + formData.password + ) console.log('Logged in:', result) } catch (err: any) { console.error(err.message) diff --git a/src/app/register/page.tsx b/src/app/register/page.tsx index 5d91360..fec1a16 100644 --- a/src/app/register/page.tsx +++ b/src/app/register/page.tsx @@ -36,7 +36,11 @@ export default function RegisterPage() { } console.log('Register', formData) - const result = await authService.register(formData.name, formData.email, formData.password) + const result = await authService.register( + formData.name, + formData.email, + formData.password + ) console.log('Registered:', result) router.push('/login') // Redirect after success } catch (err: any) { diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index af9c9f3..cdd5bc9 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -6,7 +6,9 @@ import { font_Hack } from '@/lib/myFonts' // Top navigation bar with a home link and login/register buttons. export default function Navbar() { return ( -