From 134b69be584ff0cf94e1166a24998467d80754c1 Mon Sep 17 00:00:00 2001 From: makame Date: Fri, 17 Apr 2020 21:49:14 +0200 Subject: [PATCH] fixes --- git-log-config.yml => git-log-config.yml+ | 0 git-log-config.yml__ | 26 ------ src/app/Error404.tsx | 89 ++++++++++--------- .../handlers/collect-stats.handler.ts | 5 +- src/electron/handlers/get-config.handler.ts | 47 ++++++---- src/routing.tsx | 4 +- tsconfig.electron.json | 2 +- 7 files changed, 87 insertions(+), 86 deletions(-) rename git-log-config.yml => git-log-config.yml+ (100%) delete mode 100644 git-log-config.yml__ diff --git a/git-log-config.yml b/git-log-config.yml+ similarity index 100% rename from git-log-config.yml rename to git-log-config.yml+ diff --git a/git-log-config.yml__ b/git-log-config.yml__ deleted file mode 100644 index 5ed293d..0000000 --- a/git-log-config.yml__ +++ /dev/null @@ -1,26 +0,0 @@ -branch: master -cleanTmp: false -debug: true -tmpDir: /Users/mkarpov/projects/git-log-ui/repositories -statsDir: /Users/mkarpov/projects/git-log-ui -evaluate: function (item) { return item.linesChanged; } -collectInterval: 15 -repositories: - - branch: master - exclude: [] - name: gc - url: https://github.com/makamekm/git-log-calendar-teams.git -teams: - - invert: false - name: ttt - users: - - makamekm -users: - - associations: - - makamekm - - makame - - makame@mail.ru - - Maxim Karpov - - Karpov Maxim - name: makamekm -path: /Users/mkarpov/projects/git-log-ui/git-log-config.yml diff --git a/src/app/Error404.tsx b/src/app/Error404.tsx index 79b1ab8..fd644d2 100755 --- a/src/app/Error404.tsx +++ b/src/app/Error404.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { useLocation } from "react-router"; import { Link } from "react-router-dom"; import { Form, @@ -14,44 +15,50 @@ import { import { HeaderPanel } from "~/app/HeaderPanel"; import { FooterPanel } from "~/app/FooterPanel"; -export const Error404 = () => ( - - - {/* START Header */} - - {/* END Header */} - {/* START Form */} -
- - - - - - - - - -
- {/* END Form */} - {/* START Bottom Links */} -
- Back to Home - - Support - -
- {/* END Bottom Links */} - {/* START Footer */} - - {/* END Footer */} -
-
-); +export const Error404 = () => { + let { pathname } = useLocation(); + return ( + + + {/* START Header */} + + {/* END Header */} + {/* START Form */} + +
{pathname}
+ +
+ + + + + + + + + +
+ {/* END Form */} + {/* START Bottom Links */} +
+ Back to Home + + Support + +
+ {/* END Bottom Links */} + {/* START Footer */} + + {/* END Footer */} +
+
+ ); +}; diff --git a/src/electron/handlers/collect-stats.handler.ts b/src/electron/handlers/collect-stats.handler.ts index cacff51..4319ec5 100644 --- a/src/electron/handlers/collect-stats.handler.ts +++ b/src/electron/handlers/collect-stats.handler.ts @@ -37,9 +37,10 @@ ipcMain.handle( isCollecting = true; ipc.sends.ON_COLLECT_STATS(true); console.log("collecting started!"); + const config = await ipc.handlers.GET_CONFIG(); try { - await collect(); - await clean(); + await collect(config); + await clean(config); } catch (error) { console.error(error); } diff --git a/src/electron/handlers/get-config.handler.ts b/src/electron/handlers/get-config.handler.ts index 6250ffc..c100b85 100644 --- a/src/electron/handlers/get-config.handler.ts +++ b/src/electron/handlers/get-config.handler.ts @@ -1,5 +1,5 @@ -import { ipcMain } from "electron"; -import { writeFileSync } from "fs"; +import { ipcMain, app } from "electron"; +import { writeFileSync, readFileSync, existsSync } from "fs"; import path from "path"; import YAML from "yaml"; import { nameofHandler, Ipc, ipc } from "~/shared/ipc"; @@ -12,25 +12,42 @@ const REFRESH_CONFIG_TIMEOUT = 1000 * 10; let config: Config = null; let date = new Date(); +const readConfigFromHome = async () => { + const configPath = path.resolve(app.getPath("home"), "./git-log-config.yml"); + let config = { + branch: "master", + cleanTmp: false, + debug: true, + tmpDir: path.resolve(app.getPath("home"), "./repositories"), + statsDir: path.resolve(app.getPath("home")), + evaluate: "item => item.linesChanged", + collectInterval: 15, + repositories: [], + teams: [], + users: [], + path: configPath, + }; + if (existsSync(configPath)) { + try { + const file = readFileSync(configPath, "utf8"); + config = YAML.parse(file); + config.path = configPath; + } catch (error) { + console.error(error); + } + } + // eslint-disable-next-line no-new-func + config.evaluate = Function('"use strict";return (' + config.evaluate + ")")(); + return config; +}; + const tryGetConfig = async () => { let config: Config = null; try { config = await getConfig(); } catch (error) { console.error(error); - config = { - branch: "master", - cleanTmp: false, - debug: true, - tmpDir: path.resolve(process.cwd(), "./repositories"), - statsDir: path.resolve(process.cwd(), "./"), - evaluate: (item) => item.linesChanged, - collectInterval: 15, - repositories: [], - teams: [], - users: [], - path: path.resolve(process.cwd(), "./git-log-config.yml"), - }; + config = await readConfigFromHome(); } return config; }; diff --git a/src/routing.tsx b/src/routing.tsx index 8dee9ef..04a5ff6 100755 --- a/src/routing.tsx +++ b/src/routing.tsx @@ -106,6 +106,7 @@ export const RoutedContent = () => { return ( + @@ -381,7 +382,8 @@ export const RoutedContent = () => { {/* 404 */} - + + {/* */} ); }; diff --git a/tsconfig.electron.json b/tsconfig.electron.json index 4ffad71..c2f735f 100644 --- a/tsconfig.electron.json +++ b/tsconfig.electron.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.paths.json", "compilerOptions": { - "target": "es5", + "target": "es2020", "allowJs": true, "esModuleInterop": true, "skipLibCheck": true,