Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
makamekm committed Apr 17, 2020
1 parent 9b0a7a9 commit 134b69b
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 86 deletions.
File renamed without changes.
26 changes: 0 additions & 26 deletions git-log-config.yml__

This file was deleted.

89 changes: 48 additions & 41 deletions src/app/Error404.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { useLocation } from "react-router";
import { Link } from "react-router-dom";
import {
Form,
Expand All @@ -14,44 +15,50 @@ import {
import { HeaderPanel } from "~/app/HeaderPanel";
import { FooterPanel } from "~/app/FooterPanel";

export const Error404 = () => (
<EmptyLayout>
<EmptyLayoutSection center>
{/* START Header */}
<HeaderPanel title="Error 404" />
{/* END Header */}
{/* START Form */}
<Form className="mb-3">
<FormGroup>
<Label for="search">Search</Label>
<InputGroup>
<Input
type="text"
name="text"
id="search"
placeholder="Enter search phrase here..."
className="bg-white"
/>
<InputGroupAddon addonType="append">
<Button tag={Link} to="/">
<i className="fa fa-search"></i>
</Button>
</InputGroupAddon>
</InputGroup>
</FormGroup>
</Form>
{/* END Form */}
{/* START Bottom Links */}
<div className="d-flex mb-5">
<Link to="/">Back to Home</Link>
<Link to="/help" className="ml-auto text-decoration-none">
Support
</Link>
</div>
{/* END Bottom Links */}
{/* START Footer */}
<FooterPanel />
{/* END Footer */}
</EmptyLayoutSection>
</EmptyLayout>
);
export const Error404 = () => {
let { pathname } = useLocation();
return (
<EmptyLayout>
<EmptyLayoutSection center>
{/* START Header */}
<HeaderPanel title="Error 404" />
{/* END Header */}
{/* START Form */}

<div className="mb-3">{pathname}</div>

<Form className="mb-3">
<FormGroup>
<Label for="search">Search</Label>
<InputGroup>
<Input
type="text"
name="text"
id="search"
placeholder="Enter search phrase here..."
className="bg-white"
/>
<InputGroupAddon addonType="append">
<Button tag={Link} to="/">
<i className="fa fa-search"></i>
</Button>
</InputGroupAddon>
</InputGroup>
</FormGroup>
</Form>
{/* END Form */}
{/* START Bottom Links */}
<div className="d-flex mb-5">
<Link to="/">Back to Home</Link>
<Link to="/help" className="ml-auto text-decoration-none">
Support
</Link>
</div>
{/* END Bottom Links */}
{/* START Footer */}
<FooterPanel />
{/* END Footer */}
</EmptyLayoutSection>
</EmptyLayout>
);
};
5 changes: 3 additions & 2 deletions src/electron/handlers/collect-stats.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
47 changes: 32 additions & 15 deletions src/electron/handlers/get-config.handler.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion src/routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const RoutedContent = () => {
return (
<Switch>
<Redirect from="/" to="/dashboard" exact />
<Redirect from="/index.html" to="/dashboard" exact />

<Route path="/login/:loginFrom" exact component={AuthScreen} />
<LogoutRoute path="/logout/:loginFrom" exact />
Expand Down Expand Up @@ -381,7 +382,8 @@ export const RoutedContent = () => {
<ProtectedRoute isWIP path="/icons" exact component={Icons} />

{/* 404 */}
<Redirect to="/404" />
<Route component={Error404} />
{/* <Redirect to="/404" /> */}
</Switch>
);
};
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.electron.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"target": "es5",
"target": "es2020",
"allowJs": true,
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down

0 comments on commit 134b69b

Please sign in to comment.