mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
chore: run formatter (#145)
This commit is contained in:
16
index.js
16
index.js
@@ -1,14 +1,14 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {config} from './lib/utils.js';
|
import { config } from './lib/utils.js';
|
||||||
import * as similarityCache from './lib/services/similarity-check/similarityCache.js';
|
import * as similarityCache from './lib/services/similarity-check/similarityCache.js';
|
||||||
import { setLastJobExecution } from './lib/services/storage/listingsStorage.js';
|
import { setLastJobExecution } from './lib/services/storage/listingsStorage.js';
|
||||||
import * as jobStorage from './lib/services/storage/jobStorage.js';
|
import * as jobStorage from './lib/services/storage/jobStorage.js';
|
||||||
import FredyRuntime from './lib/FredyRuntime.js';
|
import FredyRuntime from './lib/FredyRuntime.js';
|
||||||
import { duringWorkingHoursOrNotSet } from './lib/utils.js';
|
import { duringWorkingHoursOrNotSet } from './lib/utils.js';
|
||||||
import './lib/api/api.js';
|
import './lib/api/api.js';
|
||||||
import {track} from './lib/services/tracking/Tracker.js';
|
import { track } from './lib/services/tracking/Tracker.js';
|
||||||
import {handleDemoUser} from './lib/services/storage/userStorage.js';
|
import { handleDemoUser } from './lib/services/storage/userStorage.js';
|
||||||
import {cleanupDemoAtMidnight} from './lib/services/demoCleanup.js';
|
import { cleanupDemoAtMidnight } from './lib/services/demoCleanup.js';
|
||||||
//if db folder does not exist, ensure to create it before loading anything else
|
//if db folder does not exist, ensure to create it before loading anything else
|
||||||
if (!fs.existsSync('./db')) {
|
if (!fs.existsSync('./db')) {
|
||||||
fs.mkdirSync('./db');
|
fs.mkdirSync('./db');
|
||||||
@@ -19,13 +19,13 @@ const provider = fs.readdirSync(path).filter((file) => file.endsWith('.js'));
|
|||||||
const INTERVAL = config.interval * 60 * 1000;
|
const INTERVAL = config.interval * 60 * 1000;
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log(`Started Fredy successfully. Ui can be accessed via http://localhost:${config.port}`);
|
console.log(`Started Fredy successfully. Ui can be accessed via http://localhost:${config.port}`);
|
||||||
if(config.demoMode){
|
if (config.demoMode) {
|
||||||
console.info('Running in demo mode');
|
console.info('Running in demo mode');
|
||||||
cleanupDemoAtMidnight();
|
cleanupDemoAtMidnight();
|
||||||
}
|
}
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
const fetchedProvider = await Promise.all(
|
const fetchedProvider = await Promise.all(
|
||||||
provider.filter((provider) => provider.endsWith('.js')).map(async (pro) => import(`${path}/${pro}`))
|
provider.filter((provider) => provider.endsWith('.js')).map(async (pro) => import(`${path}/${pro}`)),
|
||||||
);
|
);
|
||||||
|
|
||||||
handleDemoUser();
|
handleDemoUser();
|
||||||
@@ -33,7 +33,7 @@ handleDemoUser();
|
|||||||
setInterval(
|
setInterval(
|
||||||
(function exec() {
|
(function exec() {
|
||||||
const isDuringWorkingHoursOrNotSet = duringWorkingHoursOrNotSet(config, Date.now());
|
const isDuringWorkingHoursOrNotSet = duringWorkingHoursOrNotSet(config, Date.now());
|
||||||
if(!config.demoMode) {
|
if (!config.demoMode) {
|
||||||
if (isDuringWorkingHoursOrNotSet) {
|
if (isDuringWorkingHoursOrNotSet) {
|
||||||
track();
|
track();
|
||||||
config.lastRun = Date.now();
|
config.lastRun = Date.now();
|
||||||
@@ -58,5 +58,5 @@ setInterval(
|
|||||||
}
|
}
|
||||||
return exec;
|
return exec;
|
||||||
})(),
|
})(),
|
||||||
INTERVAL
|
INTERVAL,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import restana from 'restana';
|
|||||||
import files from 'serve-static';
|
import files from 'serve-static';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { getDirName } from '../utils.js';
|
import { getDirName } from '../utils.js';
|
||||||
import {demoRouter} from './routes/demoRouter.js';
|
import { demoRouter } from './routes/demoRouter.js';
|
||||||
const service = restana();
|
const service = restana();
|
||||||
const staticService = files(path.join(getDirName(), '../ui/public'));
|
const staticService = files(path.join(getDirName(), '../ui/public'));
|
||||||
const PORT = config.port || 9998;
|
const PORT = config.port || 9998;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const adapter = await Promise.all(
|
|||||||
fs
|
fs
|
||||||
.readdirSync('./lib/notification/adapter')
|
.readdirSync('./lib/notification/adapter')
|
||||||
.filter((file) => file.endsWith('.js'))
|
.filter((file) => file.endsWith('.js'))
|
||||||
.map(async (integPath) => await import(`${path}/${integPath}`))
|
.map(async (integPath) => await import(`${path}/${integPath}`)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (adapter.length === 0) {
|
if (adapter.length === 0) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import utils, {buildHash} from '../utils.js';
|
import utils, { buildHash } from '../utils.js';
|
||||||
let appliedBlackList = [];
|
let appliedBlackList = [];
|
||||||
function shortenLink(link) {
|
function shortenLink(link) {
|
||||||
return link.substring(0, link.indexOf('?'));
|
return link.substring(0, link.indexOf('?'));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import utils, {buildHash} from '../utils.js';
|
import utils, { buildHash } from '../utils.js';
|
||||||
|
|
||||||
let appliedBlackList = [];
|
let appliedBlackList = [];
|
||||||
let appliedBlacklistedDistricts = [];
|
let appliedBlacklistedDistricts = [];
|
||||||
@@ -7,7 +7,7 @@ function normalize(o) {
|
|||||||
const size = o.size || '--- m²';
|
const size = o.size || '--- m²';
|
||||||
const id = buildHash(o.id, o.price);
|
const id = buildHash(o.id, o.price);
|
||||||
const link = `https://www.kleinanzeigen.de${o.link}`;
|
const link = `https://www.kleinanzeigen.de${o.link}`;
|
||||||
return Object.assign(o, {id, size, link});
|
return Object.assign(o, { id, size, link });
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyBlacklist(o) {
|
function applyBlacklist(o) {
|
||||||
@@ -47,4 +47,4 @@ export const init = (sourceConfig, blacklist, blacklistedDistricts) => {
|
|||||||
appliedBlacklistedDistricts = blacklistedDistricts || [];
|
appliedBlacklistedDistricts = blacklistedDistricts || [];
|
||||||
appliedBlackList = blacklist || [];
|
appliedBlackList = blacklist || [];
|
||||||
};
|
};
|
||||||
export {config};
|
export { config };
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import utils, {buildHash} from '../utils.js';
|
import utils, { buildHash } from '../utils.js';
|
||||||
|
|
||||||
let appliedBlackList = [];
|
let appliedBlackList = [];
|
||||||
|
|
||||||
@@ -7,9 +7,11 @@ function nullOrEmpty(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalize(o) {
|
function normalize(o) {
|
||||||
const link = nullOrEmpty(o.link) ? 'NO LINK' : `https://www.neubaukompass.de${o.link.substring(o.link.indexOf('/neubau'))}`;
|
const link = nullOrEmpty(o.link)
|
||||||
|
? 'NO LINK'
|
||||||
|
: `https://www.neubaukompass.de${o.link.substring(o.link.indexOf('/neubau'))}`;
|
||||||
const id = buildHash(o.link, o.price);
|
const id = buildHash(o.link, o.price);
|
||||||
return Object.assign(o, {id, link});
|
return Object.assign(o, { id, link });
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyBlacklist(o) {
|
function applyBlacklist(o) {
|
||||||
@@ -41,4 +43,4 @@ export const metaInformation = {
|
|||||||
baseUrl: 'https://www.neubaukompass.de/',
|
baseUrl: 'https://www.neubaukompass.de/',
|
||||||
id: 'neubauKompass',
|
id: 'neubauKompass',
|
||||||
};
|
};
|
||||||
export {config};
|
export { config };
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import utils, {buildHash} from '../utils.js';
|
import utils, { buildHash } from '../utils.js';
|
||||||
|
|
||||||
let appliedBlackList = [];
|
let appliedBlackList = [];
|
||||||
|
|
||||||
@@ -40,4 +40,4 @@ export const metaInformation = {
|
|||||||
baseUrl: 'https://www.wg-gesucht.de/',
|
baseUrl: 'https://www.wg-gesucht.de/',
|
||||||
id: 'wgGesucht',
|
id: 'wgGesucht',
|
||||||
};
|
};
|
||||||
export {config};
|
export { config };
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as similarityCache from '../../lib/services/similarity-check/similarityCache.js';
|
import * as similarityCache from '../../lib/services/similarity-check/similarityCache.js';
|
||||||
import {get} from '../mocks/mockNotification.js';
|
import { get } from '../mocks/mockNotification.js';
|
||||||
import {mockFredy, providerConfig} from '../utils.js';
|
import { mockFredy, providerConfig } from '../utils.js';
|
||||||
import {expect} from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as provider from '../../lib/provider/immonet.js';
|
import * as provider from '../../lib/provider/immonet.js';
|
||||||
|
|
||||||
describe('#immonet testsuite()', () => {
|
describe('#immonet testsuite()', () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as similarityCache from '../../lib/services/similarity-check/similarityCache.js';
|
import * as similarityCache from '../../lib/services/similarity-check/similarityCache.js';
|
||||||
import {get} from '../mocks/mockNotification.js';
|
import { get } from '../mocks/mockNotification.js';
|
||||||
import {mockFredy, providerConfig} from '../utils.js';
|
import { mockFredy, providerConfig } from '../utils.js';
|
||||||
import {expect} from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as provider from '../../lib/provider/neubauKompass.js';
|
import * as provider from '../../lib/provider/neubauKompass.js';
|
||||||
|
|
||||||
describe('#neubauKompass testsuite()', () => {
|
describe('#neubauKompass testsuite()', () => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import {buildHash} from '../../lib/utils.js';
|
import { buildHash } from '../../lib/utils.js';
|
||||||
|
|
||||||
describe('utilsCheck', () => {
|
describe('utilsCheck', () => {
|
||||||
describe('#utilsCheck()', () => {
|
describe('#utilsCheck()', () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, {useEffect} from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import InsufficientPermission from './components/permission/InsufficientPermission';
|
import InsufficientPermission from './components/permission/InsufficientPermission';
|
||||||
import PermissionAwareRoute from './components/permission/PermissionAwareRoute';
|
import PermissionAwareRoute from './components/permission/PermissionAwareRoute';
|
||||||
@@ -6,19 +6,19 @@ import GeneralSettings from './views/generalSettings/GeneralSettings';
|
|||||||
import JobMutation from './views/jobs/mutation/JobMutation';
|
import JobMutation from './views/jobs/mutation/JobMutation';
|
||||||
import UserMutator from './views/user/mutation/UserMutator';
|
import UserMutator from './views/user/mutation/UserMutator';
|
||||||
import JobInsight from './views/jobs/insights/JobInsight.jsx';
|
import JobInsight from './views/jobs/insights/JobInsight.jsx';
|
||||||
import {useDispatch, useSelector} from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import {Switch, Redirect} from 'react-router-dom';
|
import { Switch, Redirect } from 'react-router-dom';
|
||||||
import Logout from './components/logout/Logout';
|
import Logout from './components/logout/Logout';
|
||||||
import Logo from './components/logo/Logo';
|
import Logo from './components/logo/Logo';
|
||||||
import Menu from './components/menu/Menu';
|
import Menu from './components/menu/Menu';
|
||||||
import Login from './views/login/Login';
|
import Login from './views/login/Login';
|
||||||
import Users from './views/user/Users';
|
import Users from './views/user/Users';
|
||||||
import Jobs from './views/jobs/Jobs';
|
import Jobs from './views/jobs/Jobs';
|
||||||
import {Route} from 'react-router';
|
import { Route } from 'react-router';
|
||||||
|
|
||||||
import './App.less';
|
import './App.less';
|
||||||
import TrackingModal from './components/tracking/TrackingModal.jsx';
|
import TrackingModal from './components/tracking/TrackingModal.jsx';
|
||||||
import {Banner} from '@douyinfe/semi-ui';
|
import { Banner } from '@douyinfe/semi-ui';
|
||||||
|
|
||||||
export default function FredyApp() {
|
export default function FredyApp() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -50,8 +50,8 @@ export default function FredyApp() {
|
|||||||
|
|
||||||
const login = () => (
|
const login = () => (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route name="Login" path={'/login'} component={Login}/>
|
<Route name="Login" path={'/login'} component={Login} />
|
||||||
<Redirect from="*" to={'/login'}/>
|
<Redirect from="*" to={'/login'} />
|
||||||
</Switch>
|
</Switch>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -60,48 +60,50 @@ export default function FredyApp() {
|
|||||||
) : (
|
) : (
|
||||||
<div className="app">
|
<div className="app">
|
||||||
<div className="app__container">
|
<div className="app__container">
|
||||||
<Logout/>
|
<Logout />
|
||||||
<Logo width={190} white/>
|
<Logo width={190} white />
|
||||||
<Menu isAdmin={isAdmin()}/>
|
<Menu isAdmin={isAdmin()} />
|
||||||
|
|
||||||
{settings.demoMode && (
|
{settings.demoMode && (
|
||||||
<>
|
<>
|
||||||
<Banner fullMode={true}
|
<Banner
|
||||||
|
fullMode={true}
|
||||||
type="info"
|
type="info"
|
||||||
bordered
|
bordered
|
||||||
closeIcon={null}
|
closeIcon={null}
|
||||||
description="You're currently viewing the demo version of Fredy. Jobs won't scrape websites, and any changes you make will be reverted at midnight."
|
description="You're currently viewing the demo version of Fredy. Jobs won't scrape websites, and any changes you make will be reverted at midnight."
|
||||||
/>
|
/>
|
||||||
<br/>
|
<br />
|
||||||
</>)}
|
</>
|
||||||
{(settings.analyticsEnabled === null && !settings.demoMode) && <TrackingModal/>}
|
)}
|
||||||
|
{settings.analyticsEnabled === null && !settings.demoMode && <TrackingModal />}
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route name="Insufficient Permission" path={'/403'} component={InsufficientPermission}/>
|
<Route name="Insufficient Permission" path={'/403'} component={InsufficientPermission} />
|
||||||
<Route name="Create new Job" path={'/jobs/new'} component={JobMutation}/>
|
<Route name="Create new Job" path={'/jobs/new'} component={JobMutation} />
|
||||||
<Route name="Edit a Job" path={'/jobs/edit/:jobId'} component={JobMutation}/>
|
<Route name="Edit a Job" path={'/jobs/edit/:jobId'} component={JobMutation} />
|
||||||
<Route name="Insights into a Job" path={'/jobs/insights/:jobId'} component={JobInsight}/>
|
<Route name="Insights into a Job" path={'/jobs/insights/:jobId'} component={JobInsight} />
|
||||||
<Route name="Job overview" path={'/jobs'} component={Jobs}/>
|
<Route name="Job overview" path={'/jobs'} component={Jobs} />
|
||||||
<PermissionAwareRoute
|
<PermissionAwareRoute
|
||||||
name="Create new User"
|
name="Create new User"
|
||||||
path="/users/new"
|
path="/users/new"
|
||||||
component={<UserMutator/>}
|
component={<UserMutator />}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
/>
|
/>
|
||||||
<PermissionAwareRoute
|
<PermissionAwareRoute
|
||||||
name="Edit a user"
|
name="Edit a user"
|
||||||
path="/users/edit/:userId"
|
path="/users/edit/:userId"
|
||||||
component={<UserMutator/>}
|
component={<UserMutator />}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
/>
|
/>
|
||||||
<PermissionAwareRoute name="Users" path="/users" component={<Users/>} currentUser={currentUser}/>
|
<PermissionAwareRoute name="Users" path="/users" component={<Users />} currentUser={currentUser} />
|
||||||
<PermissionAwareRoute
|
<PermissionAwareRoute
|
||||||
name="General Settings"
|
name="General Settings"
|
||||||
path="/generalSettings"
|
path="/generalSettings"
|
||||||
component={<GeneralSettings/>}
|
component={<GeneralSettings />}
|
||||||
currentUser={currentUser}
|
currentUser={currentUser}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Redirect from="/" to={'/jobs'}/>
|
<Redirect from="/" to={'/jobs'} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,5 +23,5 @@ root.render(
|
|||||||
<App />
|
<App />
|
||||||
</LocaleProvider>
|
</LocaleProvider>
|
||||||
</HashRouter>
|
</HashRouter>
|
||||||
</Provider>
|
</Provider>,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Modal} from '@douyinfe/semi-ui';
|
import { Modal } from '@douyinfe/semi-ui';
|
||||||
import Logo from '../logo/Logo.jsx';
|
import Logo from '../logo/Logo.jsx';
|
||||||
import {xhrPost} from '../../services/xhr.js';
|
import { xhrPost } from '../../services/xhr.js';
|
||||||
|
|
||||||
import './TrackingModal.less';
|
import './TrackingModal.less';
|
||||||
import inDevelopment from '../../services/developmentMode.js';
|
import inDevelopment from '../../services/developmentMode.js';
|
||||||
|
|
||||||
const saveResponse = async (analyticsEnabled) => {
|
const saveResponse = async (analyticsEnabled) => {
|
||||||
await xhrPost('/api/admin/generalSettings', {
|
await xhrPost('/api/admin/generalSettings', {
|
||||||
analyticsEnabled
|
analyticsEnabled,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TrackingModal() {
|
export default function TrackingModal() {
|
||||||
if(inDevelopment()){
|
if (inDevelopment()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Modal
|
return (
|
||||||
|
<Modal
|
||||||
visible={true}
|
visible={true}
|
||||||
onOk={async () => {
|
onOk={async () => {
|
||||||
await saveResponse(true);
|
await saveResponse(true);
|
||||||
@@ -32,21 +33,24 @@ export default function TrackingModal() {
|
|||||||
okText="Yes! I want to help"
|
okText="Yes! I want to help"
|
||||||
cancelText="No, thanks"
|
cancelText="No, thanks"
|
||||||
>
|
>
|
||||||
<Logo white/>
|
<Logo white />
|
||||||
<div className="trackingModal__description">
|
<div className="trackingModal__description">
|
||||||
<p>Hey 👋</p>
|
<p>Hey 👋</p>
|
||||||
<p>Fed up with popups? Yeah, me too. But this one’s important, and I promise it will only appear once ;)</p>
|
<p>Fed up with popups? Yeah, me too. But this one’s important, and I promise it will only appear once ;)</p>
|
||||||
<p>Fredy is completely free (and will always remain free). If you’d like, you can support me by donating
|
<p>
|
||||||
through my GitHub, but there’s absolutely no obligation to do so.</p>
|
Fredy is completely free (and will always remain free). If you’d like, you can support me by donating through
|
||||||
<p>However, it would be a huge
|
my GitHub, but there’s absolutely no obligation to do so.
|
||||||
help if you’d allow me to collect some analytical data. Wait, before you click "no", let me explain. If
|
</p>
|
||||||
you
|
<p>
|
||||||
agree, Fredy will send a ping to my Mixpanel project each time it runs.</p>
|
However, it would be a huge help if you’d allow me to collect some analytical data. Wait, before you click
|
||||||
<p>The data includes: names of
|
"no", let me explain. If you agree, Fredy will send a ping to my Mixpanel project each time it runs.
|
||||||
active adapters/providers, OS, architecture, Node version, and language. The information is entirely
|
</p>
|
||||||
anonymous and helps me understand which adapters/providers are most frequently used.</p>
|
<p>
|
||||||
|
The data includes: names of active adapters/providers, OS, architecture, Node version, and language. The
|
||||||
|
information is entirely anonymous and helps me understand which adapters/providers are most frequently used.
|
||||||
|
</p>
|
||||||
<p>Thanks🤘</p>
|
<p>Thanks🤘</p>
|
||||||
</div>
|
</div>
|
||||||
</Modal>;
|
</Modal>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {useDispatch, useSelector} from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
|
||||||
import {Divider, TimePicker, Button, Checkbox} from '@douyinfe/semi-ui';
|
import { Divider, TimePicker, Button, Checkbox } from '@douyinfe/semi-ui';
|
||||||
import {InputNumber} from '@douyinfe/semi-ui';
|
import { InputNumber } from '@douyinfe/semi-ui';
|
||||||
import Headline from '../../components/headline/Headline';
|
import Headline from '../../components/headline/Headline';
|
||||||
import {xhrPost} from '../../services/xhr';
|
import { xhrPost } from '../../services/xhr';
|
||||||
import {SegmentPart} from '../../components/segment/SegmentPart';
|
import { SegmentPart } from '../../components/segment/SegmentPart';
|
||||||
import {Banner, Toast} from '@douyinfe/semi-ui';
|
import { Banner, Toast } from '@douyinfe/semi-ui';
|
||||||
import {IconSave, IconCalendar, IconRefresh, IconSignal, IconLineChartStroked, IconSearch} from '@douyinfe/semi-icons';
|
import {
|
||||||
|
IconSave,
|
||||||
|
IconCalendar,
|
||||||
|
IconRefresh,
|
||||||
|
IconSignal,
|
||||||
|
IconLineChartStroked,
|
||||||
|
IconSearch,
|
||||||
|
} from '@douyinfe/semi-icons';
|
||||||
import './GeneralSettings.less';
|
import './GeneralSettings.less';
|
||||||
|
|
||||||
function formatFromTimestamp(ts) {
|
function formatFromTimestamp(ts) {
|
||||||
@@ -97,19 +104,19 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
to: workingHourTo,
|
to: workingHourTo,
|
||||||
},
|
},
|
||||||
demoMode,
|
demoMode,
|
||||||
analyticsEnabled
|
analyticsEnabled,
|
||||||
});
|
});
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
console.error(exception);
|
console.error(exception);
|
||||||
if(exception?.json?.message != null){
|
if (exception?.json?.message != null) {
|
||||||
throwMessage(exception.json.message, 'error');
|
throwMessage(exception.json.message, 'error');
|
||||||
}else {
|
} else {
|
||||||
throwMessage('Error while trying to store settings.', 'error');
|
throwMessage('Error while trying to store settings.', 'error');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throwMessage('Settings stored successfully. We will reload your browser in 3 seconds.', 'success');
|
throwMessage('Settings stored successfully. We will reload your browser in 3 seconds.', 'success');
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
};
|
};
|
||||||
@@ -118,7 +125,7 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
<div>
|
<div>
|
||||||
{!loading && (
|
{!loading && (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Headline text="General Settings"/>
|
<Headline text="General Settings" />
|
||||||
<div>
|
<div>
|
||||||
<SegmentPart
|
<SegmentPart
|
||||||
name="Interval"
|
name="Interval"
|
||||||
@@ -135,7 +142,7 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
suffix={'minutes'}
|
suffix={'minutes'}
|
||||||
/>
|
/>
|
||||||
</SegmentPart>
|
</SegmentPart>
|
||||||
<Divider margin="1rem"/>
|
<Divider margin="1rem" />
|
||||||
<SegmentPart name="Port" helpText="Port on which Fredy is running." Icon={IconSignal}>
|
<SegmentPart name="Port" helpText="Port on which Fredy is running." Icon={IconSignal}>
|
||||||
<InputNumber
|
<InputNumber
|
||||||
min={0}
|
min={0}
|
||||||
@@ -146,7 +153,7 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
onChange={(value) => setPort(value)}
|
onChange={(value) => setPort(value)}
|
||||||
/>
|
/>
|
||||||
</SegmentPart>
|
</SegmentPart>
|
||||||
<Divider margin="1rem"/>
|
<Divider margin="1rem" />
|
||||||
<SegmentPart
|
<SegmentPart
|
||||||
name="Working hours"
|
name="Working hours"
|
||||||
helpText="During this hours, Fredy will search for new apartments. If nothing is configured, Fredy will search around the clock."
|
helpText="During this hours, Fredy will search for new apartments. If nothing is configured, Fredy will search around the clock."
|
||||||
@@ -173,26 +180,20 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SegmentPart>
|
</SegmentPart>
|
||||||
<Divider margin="1rem"/>
|
<Divider margin="1rem" />
|
||||||
|
|
||||||
<SegmentPart
|
<SegmentPart name="Analytics" helpText="Insights into the usage of Fredy." Icon={IconLineChartStroked}>
|
||||||
name="Analytics"
|
|
||||||
helpText="Insights into the usage of Fredy."
|
|
||||||
Icon={IconLineChartStroked}
|
|
||||||
>
|
|
||||||
<Banner
|
<Banner
|
||||||
fullMode={false}
|
fullMode={false}
|
||||||
type="info"
|
type="info"
|
||||||
closeIcon={null}
|
closeIcon={null}
|
||||||
title={
|
title={<div style={{ fontWeight: 600, fontSize: '14px', lineHeight: '20px' }}>Explanation</div>}
|
||||||
<div style={{fontWeight: 600, fontSize: '14px', lineHeight: '20px'}}>
|
style={{ marginBottom: '1rem' }}
|
||||||
Explanation
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
style={{marginBottom: '1rem'}}
|
|
||||||
description={
|
description={
|
||||||
<div>
|
<div>
|
||||||
Analytics are disabled by default. If you choose to enable them, we will begin tracking the following:<br/>
|
Analytics are disabled by default. If you choose to enable them, we will begin tracking the
|
||||||
|
following:
|
||||||
|
<br />
|
||||||
<ul>
|
<ul>
|
||||||
<li>Name of active provider (e.g. Immoscout)</li>
|
<li>Name of active provider (e.g. Immoscout)</li>
|
||||||
<li>Name of active adapter (e.g. Console)</li>
|
<li>Name of active adapter (e.g. Console)</li>
|
||||||
@@ -201,36 +202,27 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
<li>node version</li>
|
<li>node version</li>
|
||||||
<li>arch</li>
|
<li>arch</li>
|
||||||
</ul>
|
</ul>
|
||||||
The data is sent anonymously and helps me understand which providers or adapters are being used the most. In the end it helps me to improve fredy.
|
The data is sent anonymously and helps me understand which providers or adapters are being used the
|
||||||
|
most. In the end it helps me to improve fredy.
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Checkbox
|
<Checkbox checked={analyticsEnabled} onChange={(e) => setAnalyticsEnabled(e.target.checked)}>
|
||||||
checked={analyticsEnabled}
|
{' '}
|
||||||
onChange={(e) => setAnalyticsEnabled(e.target.checked)}
|
Enabled
|
||||||
> Enabled
|
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|
||||||
</SegmentPart>
|
</SegmentPart>
|
||||||
|
|
||||||
<Divider margin="1rem"/>
|
<Divider margin="1rem" />
|
||||||
|
|
||||||
<SegmentPart
|
<SegmentPart name="Demo Mode" helpText="If enabled, Fredy runs in demo mode." Icon={IconSearch}>
|
||||||
name="Demo Mode"
|
|
||||||
helpText="If enabled, Fredy runs in demo mode."
|
|
||||||
Icon={IconSearch}
|
|
||||||
>
|
|
||||||
<Banner
|
<Banner
|
||||||
fullMode={false}
|
fullMode={false}
|
||||||
type="info"
|
type="info"
|
||||||
closeIcon={null}
|
closeIcon={null}
|
||||||
title={
|
title={<div style={{ fontWeight: 600, fontSize: '14px', lineHeight: '20px' }}>Explanation</div>}
|
||||||
<div style={{fontWeight: 600, fontSize: '14px', lineHeight: '20px'}}>
|
style={{ marginBottom: '1rem' }}
|
||||||
Explanation
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
style={{marginBottom: '1rem'}}
|
|
||||||
description={
|
description={
|
||||||
<div>
|
<div>
|
||||||
In demo mode, Fredy will not (really) search for any real estates. Fredy is in a lockdown mode. Also
|
In demo mode, Fredy will not (really) search for any real estates. Fredy is in a lockdown mode. Also
|
||||||
@@ -239,16 +231,14 @@ const GeneralSettings = function GeneralSettings() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Checkbox
|
<Checkbox checked={demoMode} onChange={(e) => setDemoMode(e.target.checked)}>
|
||||||
checked={demoMode}
|
{' '}
|
||||||
onChange={(e) => setDemoMode(e.target.checked)}
|
Enabled
|
||||||
> Enabled
|
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|
||||||
</SegmentPart>
|
</SegmentPart>
|
||||||
|
|
||||||
<Divider margin="1rem"/>
|
<Divider margin="1rem" />
|
||||||
<Button type="primary" theme="solid" onClick={onStore} icon={<IconSave/>}>
|
<Button type="primary" theme="solid" onClick={onStore} icon={<IconSave />}>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {format} from '../../services/time/timeService';
|
import { format } from '../../services/time/timeService';
|
||||||
import {Descriptions} from '@douyinfe/semi-ui';
|
import { Descriptions } from '@douyinfe/semi-ui';
|
||||||
|
|
||||||
export default function ProcessingTimes({processingTimes = {}}) {
|
export default function ProcessingTimes({ processingTimes = {} }) {
|
||||||
if (Object.keys(processingTimes).length === 0) {
|
if (Object.keys(processingTimes).length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const validate = (selectedAdapter) => {
|
|||||||
}
|
}
|
||||||
if (uiElement.type === 'number') {
|
if (uiElement.type === 'number') {
|
||||||
const numberValue = parseFloat(uiElement.value);
|
const numberValue = parseFloat(uiElement.value);
|
||||||
if(isNaN(numberValue) || numberValue < 0) {
|
if (isNaN(numberValue) || numberValue < 0) {
|
||||||
results.push('A number field cannot contain anything else and must be > 0.');
|
results.push('A number field cannot contain anything else and must be > 0.');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ export default function NotificationAdapterMutator({
|
|||||||
id: selectedAdapter.id,
|
id: selectedAdapter.id,
|
||||||
name: selectedAdapter.name,
|
name: selectedAdapter.name,
|
||||||
fields: selectedAdapter.fields || {},
|
fields: selectedAdapter.fields || {},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
setSelectedAdapter(null);
|
setSelectedAdapter(null);
|
||||||
@@ -114,7 +114,7 @@ export default function NotificationAdapterMutator({
|
|||||||
setSuccessMessage('It seems like it worked! Please check your service.');
|
setSuccessMessage('It seems like it worked! Please check your service.');
|
||||||
})
|
})
|
||||||
.catch((error) =>
|
.catch((error) =>
|
||||||
setValidationMessage(`This did not work :-( I've received the following error: ${error.json.message}`)
|
setValidationMessage(`This did not work :-( I've received the following error: ${error.json.message}`),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ export default function NotificationAdapterMutator({
|
|||||||
.filter((option) =>
|
.filter((option) =>
|
||||||
editNotificationAdapter != null
|
editNotificationAdapter != null
|
||||||
? true
|
? true
|
||||||
: selected.find((selectedOption) => selectedOption.id === option.key) == null
|
: selected.find((selectedOption) => selectedOption.id === option.key) == null,
|
||||||
)
|
)
|
||||||
.sort(sortAdapter)}
|
.sort(sortAdapter)}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default function ProviderMutator({ onVisibilityChanged, visible = false,
|
|||||||
url: providerUrl,
|
url: providerUrl,
|
||||||
id: selectedProvider.id,
|
id: selectedProvider.id,
|
||||||
name: selectedProvider.name,
|
name: selectedProvider.name,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
setProviderUrl(null);
|
setProviderUrl(null);
|
||||||
setSelectedProvider(null);
|
setSelectedProvider(null);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import React, {useEffect} from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import cityBackground from '../../assets/city_background.jpg';
|
import cityBackground from '../../assets/city_background.jpg';
|
||||||
import Logo from '../../components/logo/Logo';
|
import Logo from '../../components/logo/Logo';
|
||||||
import {xhrPost} from '../../services/xhr';
|
import { xhrPost } from '../../services/xhr';
|
||||||
import {useHistory} from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
import {useDispatch, useSelector} from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import {Input, Button, Banner} from '@douyinfe/semi-ui';
|
import { Input, Button, Banner } from '@douyinfe/semi-ui';
|
||||||
|
|
||||||
import './login.less';
|
import './login.less';
|
||||||
import {IconUser, IconLock} from '@douyinfe/semi-icons';
|
import { IconUser, IconLock } from '@douyinfe/semi-icons';
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -47,18 +47,18 @@ export default function Login() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="login">
|
<div className="login">
|
||||||
<div className="login__bgImage" style={{background: `url("${cityBackground}")`}}/>
|
<div className="login__bgImage" style={{ background: `url("${cityBackground}")` }} />
|
||||||
<Logo/>
|
<Logo />
|
||||||
<form>
|
<form>
|
||||||
<div className="login__loginWrapper">
|
<div className="login__loginWrapper">
|
||||||
{error && <Banner type="danger" closeIcon={null} description={error}/>}
|
{error && <Banner type="danger" closeIcon={null} description={error} />}
|
||||||
<Input
|
<Input
|
||||||
size="large"
|
size="large"
|
||||||
prefix={<IconUser/>}
|
prefix={<IconUser />}
|
||||||
placeholder="Username"
|
placeholder="Username"
|
||||||
value={username}
|
value={username}
|
||||||
showClear
|
showClear
|
||||||
style={{marginTop: error ? '1rem' : '4rem'}}
|
style={{ marginTop: error ? '1rem' : '4rem' }}
|
||||||
autoFocus
|
autoFocus
|
||||||
onChange={(value) => setUserName(value)}
|
onChange={(value) => setUserName(value)}
|
||||||
onKeyPress={async (e) => {
|
onKeyPress={async (e) => {
|
||||||
@@ -71,10 +71,10 @@ export default function Login() {
|
|||||||
<Input
|
<Input
|
||||||
size="large"
|
size="large"
|
||||||
mode="password"
|
mode="password"
|
||||||
prefix={<IconLock/>}
|
prefix={<IconLock />}
|
||||||
value={password}
|
value={password}
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
style={{marginTop: '2rem'}}
|
style={{ marginTop: '2rem' }}
|
||||||
onChange={(value) => setPassword(value)}
|
onChange={(value) => setPassword(value)}
|
||||||
onKeyPress={async (e) => {
|
onKeyPress={async (e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
@@ -83,16 +83,19 @@ export default function Login() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button type="primary" onClick={tryLogin} theme="solid" style={{marginTop: '3rem'}}>
|
<Button type="primary" onClick={tryLogin} theme="solid" style={{ marginTop: '3rem' }}>
|
||||||
Login
|
Login
|
||||||
</Button>
|
</Button>
|
||||||
<br/>
|
<br />
|
||||||
{demoMode && <Banner fullMode={true}
|
{demoMode && (
|
||||||
|
<Banner
|
||||||
|
fullMode={true}
|
||||||
type="info"
|
type="info"
|
||||||
bordered
|
bordered
|
||||||
closeIcon={null}
|
closeIcon={null}
|
||||||
description="This is the demo version of Fredy. Use 'demo' as both the username and password to log in."
|
description="This is the demo version of Fredy. Use 'demo' as both the username and password to log in."
|
||||||
/>}
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user