diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 066560e..66d6bbd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,20 +7,20 @@ assignees: wellemut --- -**Describe the bug** -A clear and concise description of what the bug is. +## Problem +A clear and concise description of the bug. -**To Reproduce** +#### To Reproduce Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error -**Expected behavior** +## Expected behavior A clear and concise description of what you expected to happen. -**Screenshots** +### Screenshots If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** diff --git a/api/endpoints/BasicsEndpoints.ts b/api/endpoints/BasicsEndpoints.ts index 8cf99af..7156db1 100644 --- a/api/endpoints/BasicsEndpoints.ts +++ b/api/endpoints/BasicsEndpoints.ts @@ -1,4 +1,6 @@ // todo: should eliminate self_api because it causes troubles with the hosting domain + + // todo: use SWR instead export const BASICS_API_URL: string | undefined = process.env.NEXT_PUBLIC_BASICS_API export const SELF_API_URL: string | undefined= process.env.NEXT_PUBLIC_SELF_API @@ -20,4 +22,6 @@ export const BASICS_ENDPOINTS = { postEntryRating: (): string => `${BASICS_API_URL}/ratings`, getMainCheckboxes: (group: string): string => `${SELF_API_URL}/checkboxes/${group}/main-checkboxes`, getTagMarkerColors: (project: string): string => `${SELF_API_URL}/maps/${project}/tags/markers/colors`, + postSubscription: (): string => `${BASICS_API_URL}/subscribe`, + getVersion: (): string => `${SELF_API_URL}/version`, } diff --git a/components/BurgerMenu.tsx b/components/BurgerMenu.tsx index 4de5d04..dd9a85b 100644 --- a/components/BurgerMenu.tsx +++ b/components/BurgerMenu.tsx @@ -22,6 +22,12 @@ const Menu: FC = () => { const { t } = useTranslation('map') + const { data: versionResponse, error: _versionError } = useRequest<{ version: string }>({ + url: API_ENDPOINTS.getVersion(), + }) + + const version = versionResponse?.version ?? '' + const { data: linksWithIcon, error } = useRequest({ url: API_ENDPOINTS.getBurgerMenuLinks(projectName), }) @@ -100,6 +106,17 @@ const Menu: FC = () => { )) } + +
+ {version} +
) } diff --git a/consts/version.ts b/consts/version.ts index 73f8269..e1ea95b 100644 --- a/consts/version.ts +++ b/consts/version.ts @@ -1,5 +1,4 @@ -const version = 'v1.2.0' +const version = 'v1.2.4' export default version - diff --git a/pages/_documents.tsx b/pages/_documents.tsx deleted file mode 100644 index 95c321b..0000000 --- a/pages/_documents.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import Document, { - Html, - Head, - Main, - NextScript, - DocumentContext, -} from "next/document"; -import { StyleProvider, createCache, extractStyle } from "@ant-design/cssinjs"; - -const MyDocument = () => ( - - - -
- - - -) - -MyDocument.getInitialProps = async (ctx: DocumentContext) => { - const cache = createCache(); - const originalRenderPage = ctx.renderPage; - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => (props) => - ( - - - - ), - }); - - const initialProps = await Document.getInitialProps(ctx); - // 1.1 extract style which had been used - const style = extractStyle(cache, true); - return { - ...initialProps, - styles: ( - <> - {initialProps.styles} - {/* 1.2 inject css */} - - - ), - }; -} - -export default MyDocument; diff --git a/pages/api/v0/maps/[project]/config/index.ts b/pages/api/v0/maps/[project]/config/index.ts index cc054f8..34a982a 100644 --- a/pages/api/v0/maps/[project]/config/index.ts +++ b/pages/api/v0/maps/[project]/config/index.ts @@ -3,12 +3,65 @@ import path from 'path' import { NextApiRequest, NextApiResponse } from 'next' import MapPageConfigs from '../../../../../../dtos/MapPageConfigs' +import { MapColorModes } from '../../../../../../components/MapColorStyle' const getPath = (project: string = 'main'): string => { return `./public/projects/${project}/config.json` } + +export const parseConfigFile = (project: string = 'main'): MapPageConfigs => { + let mapPageConfigs: MapPageConfigs = { + "map": { + "location": { + "lat": 50.8129, + "lng": 5.6030, + "zoom": 6 + }, + "colorStyle": MapColorModes.GRAY + }, + "popularTags": { + "min_count": 2 + }, + "sidebar": { + "title": "Kartevonmorgen" + } + } + + let fileContent: string = '' + try { + fileContent = fs.readFileSync( + path.resolve(getPath(project as string)), + 'utf8', + ) + } catch (e) { + console.error('api map config: failed to read config file for project: ', project) + console.error(e) + try { + console.log('api map config: trying to read default config file') + fileContent = fs.readFileSync( + path.resolve(getPath()), + 'utf8', + ) + } catch (e) { + console.error('api map config: failed to read default config file') + console.error(e) + } + } + + try { + mapPageConfigs = JSON.parse(fileContent.toString()) + } catch(e) { + console.error('api map config: failed to parse config file for project: ', project) + console.error(e) + } + + console.log(mapPageConfigs) + return mapPageConfigs +} + + export default (req: NextApiRequest, res: NextApiResponse) => { const { query: { project }, @@ -23,22 +76,8 @@ export default (req: NextApiRequest, res: NextApiResponse) => { return } - // todo: eighter move it to env or consts - // todo: catch the error if the file is not found - - let fileContent: string = '' - try { - fileContent = fs.readFileSync( - path.resolve(getPath(project as string)), - 'utf8', - ) - } catch (e) { - fileContent = fs.readFileSync( - path.resolve(getPath()), - 'utf8', - ) - } - const mapPageConfigs: MapPageConfigs = JSON.parse(fileContent.toString()) + + const mapPageConfigs: MapPageConfigs = parseConfigFile(project as string) res .status(200) diff --git a/pages/api/v0/version/index.ts b/pages/api/v0/version/index.ts new file mode 100644 index 0000000..f6f1411 --- /dev/null +++ b/pages/api/v0/version/index.ts @@ -0,0 +1,12 @@ +import { NextApiRequest, NextApiResponse } from 'next' +import version from 'consts/version' + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + try { + // Return the version + res.status(200).json({ version }) + } catch (error) { + // Handle any errors that occur + res.status(500).json({ error: 'Internal Server Error' }) + } +} diff --git a/pages/m/[...slug].tsx b/pages/m/[...slug].tsx index 78cc0da..3affab1 100644 --- a/pages/m/[...slug].tsx +++ b/pages/m/[...slug].tsx @@ -12,6 +12,7 @@ import { MapLocationProps } from '../../components/Map' import { TagsCount } from '../../dtos/TagCount' import Sidebar from '../../components/Sidebar' import { MapColorModes } from '../../components/MapColorStyle' +import { parseConfigFile } from '../api/v0/maps/[project]/config' const { Content } = Layout @@ -81,16 +82,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { // we expect to have path always not empty with the first element of project name const project = path[0] - - // set configs - const pageConfigsReq = await AxiosInstance.GetRequest( - API_ENDPOINTS.getMapPageConfigs(project), - { - timeout: 120000, - } - ) - - const pageConfigs = AxiosInstance.GetSuccessData(pageConfigsReq) + + const pageConfigs = parseConfigFile(project as string) const mapLocationProps = pageConfigs.map.location const sidebarConfigs = pageConfigs.sidebar