mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 03:29:37 +02:00
commit
fd7d8e65c8
44 changed files with 480 additions and 232 deletions
2
.env
2
.env
|
@ -1,5 +1,5 @@
|
||||||
PORT=5005
|
PORT=5005
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=2.0.0
|
VERSION=2.0.1
|
||||||
PASSWORD=flame_password
|
PASSWORD=flame_password
|
||||||
SECRET=e02eb43d69953658c6d07311d6313f2d4467672cb881f96b29368ba1f3f4da4b
|
SECRET=e02eb43d69953658c6d07311d6313f2d4467672cb881f96b29368ba1f3f4da4b
|
|
@ -1,3 +1,11 @@
|
||||||
|
### v2.0.1 (2021-11-19)
|
||||||
|
- Added option to display humidity in the weather widget ([#136](https://github.com/pawelmalak/flame/issues/136))
|
||||||
|
- Added option to set default theme for all new users ([#165](https://github.com/pawelmalak/flame/issues/165))
|
||||||
|
- Added option to hide header greetings and date separately ([#200](https://github.com/pawelmalak/flame/issues/200))
|
||||||
|
- Fixed bug with broken basic auth ([#202](https://github.com/pawelmalak/flame/issues/202))
|
||||||
|
- Fixed bug with parsing visibility value for apps and bookmarks when custom icon was used ([#203](https://github.com/pawelmalak/flame/issues/203))
|
||||||
|
- Fixed bug with custom icons not working with apps when "pin by default" was disabled
|
||||||
|
|
||||||
### v2.0.0 (2021-11-15)
|
### v2.0.0 (2021-11-15)
|
||||||
- Added authentication system:
|
- Added authentication system:
|
||||||
- Only logged in user can access settings ([#33](https://github.com/pawelmalak/flame/issues/33))
|
- Only logged in user can access settings ([#33](https://github.com/pawelmalak/flame/issues/33))
|
||||||
|
|
|
@ -11,7 +11,7 @@ Flame is self-hosted startpage for your server. Its design is inspired (heavily)
|
||||||
- 📌 Pin your favourite items to the homescreen for quick and easy access
|
- 📌 Pin your favourite items to the homescreen for quick and easy access
|
||||||
- 🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own
|
- 🔍 Integrated search bar with local filtering, 11 web search providers and ability to add your own
|
||||||
- 🔑 Authentication system to protect your settings, apps and bookmarks
|
- 🔑 Authentication system to protect your settings, apps and bookmarks
|
||||||
- 🔨 Dozens of option to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes
|
- 🔨 Dozens of options to customize Flame interface to your needs, including support for custom CSS and 15 built-in color themes
|
||||||
- ☀️ Weather widget with current temperature, cloud coverage and animated weather status
|
- ☀️ Weather widget with current temperature, cloud coverage and animated weather status
|
||||||
- 🐳 Docker integration to automatically pick and add apps based on their labels
|
- 🐳 Docker integration to automatically pick and add apps based on their labels
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
REACT_APP_VERSION=2.0.0
|
REACT_APP_VERSION=2.0.1
|
|
@ -1,7 +1,13 @@
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
||||||
|
import 'external-svg-loader';
|
||||||
|
|
||||||
|
// Redux
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
import { autoLogin, getConfig } from './store/action-creators';
|
import { autoLogin, getConfig } from './store/action-creators';
|
||||||
import { actionCreators, store } from './store';
|
import { actionCreators, store } from './store';
|
||||||
import 'external-svg-loader';
|
import { State } from './store/reducers';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { checkVersion, decodeToken } from './utility';
|
import { checkVersion, decodeToken } from './utility';
|
||||||
|
@ -12,9 +18,6 @@ import { Apps } from './components/Apps/Apps';
|
||||||
import { Settings } from './components/Settings/Settings';
|
import { Settings } from './components/Settings/Settings';
|
||||||
import { Bookmarks } from './components/Bookmarks/Bookmarks';
|
import { Bookmarks } from './components/Bookmarks/Bookmarks';
|
||||||
import { NotificationCenter } from './components/NotificationCenter/NotificationCenter';
|
import { NotificationCenter } from './components/NotificationCenter/NotificationCenter';
|
||||||
import { useDispatch } from 'react-redux';
|
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
store.dispatch<any>(getConfig());
|
store.dispatch<any>(getConfig());
|
||||||
|
@ -25,6 +28,8 @@ if (localStorage.token) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const App = (): JSX.Element => {
|
export const App = (): JSX.Element => {
|
||||||
|
const { config, loading } = useSelector((state: State) => state.config);
|
||||||
|
|
||||||
const dispath = useDispatch();
|
const dispath = useDispatch();
|
||||||
const { fetchQueries, setTheme, logout, createNotification } =
|
const { fetchQueries, setTheme, logout, createNotification } =
|
||||||
bindActionCreators(actionCreators, dispath);
|
bindActionCreators(actionCreators, dispath);
|
||||||
|
@ -46,7 +51,7 @@ export const App = (): JSX.Element => {
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// set theme
|
// set user theme if present
|
||||||
if (localStorage.theme) {
|
if (localStorage.theme) {
|
||||||
setTheme(localStorage.theme);
|
setTheme(localStorage.theme);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +65,13 @@ export const App = (): JSX.Element => {
|
||||||
return () => window.clearInterval(tokenIsValid);
|
return () => window.clearInterval(tokenIsValid);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// If there is no user theme, set the default one
|
||||||
|
useEffect(() => {
|
||||||
|
if (!loading && !localStorage.theme) {
|
||||||
|
setTheme(config.defaultTheme, false);
|
||||||
|
}
|
||||||
|
}, [loading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
|
|
@ -61,7 +61,7 @@ export const AppForm = ({ app, modalHandler }: Props): JSX.Element => {
|
||||||
}
|
}
|
||||||
data.append('name', formData.name);
|
data.append('name', formData.name);
|
||||||
data.append('url', formData.url);
|
data.append('url', formData.url);
|
||||||
data.append('isPublic', `${formData.isPublic}`);
|
data.append('isPublic', `${formData.isPublic ? 1 : 0}`);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,7 +77,7 @@ export const BookmarksForm = ({
|
||||||
data.append('name', formData.name);
|
data.append('name', formData.name);
|
||||||
data.append('url', formData.url);
|
data.append('url', formData.url);
|
||||||
data.append('categoryId', `${formData.categoryId}`);
|
data.append('categoryId', `${formData.categoryId}`);
|
||||||
data.append('isPublic', `${formData.isPublic}`);
|
data.append('isPublic', `${formData.isPublic ? 1 : 0}`);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
// Redux
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { State } from '../../../store/reducers';
|
||||||
|
|
||||||
// CSS
|
// CSS
|
||||||
import classes from './Header.module.css';
|
import classes from './Header.module.css';
|
||||||
|
|
||||||
|
@ -12,6 +16,10 @@ import { getDateTime } from './functions/getDateTime';
|
||||||
import { greeter } from './functions/greeter';
|
import { greeter } from './functions/greeter';
|
||||||
|
|
||||||
export const Header = (): JSX.Element => {
|
export const Header = (): JSX.Element => {
|
||||||
|
const { hideHeader, hideDate, showTime } = useSelector(
|
||||||
|
(state: State) => state.config.config
|
||||||
|
);
|
||||||
|
|
||||||
const [dateTime, setDateTime] = useState<string>(getDateTime());
|
const [dateTime, setDateTime] = useState<string>(getDateTime());
|
||||||
const [greeting, setGreeting] = useState<string>(greeter());
|
const [greeting, setGreeting] = useState<string>(greeter());
|
||||||
|
|
||||||
|
@ -28,14 +36,18 @@ export const Header = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={classes.Header}>
|
<header className={classes.Header}>
|
||||||
<p>{dateTime}</p>
|
{(!hideDate || showTime) && <p>{dateTime}</p>}
|
||||||
|
|
||||||
<Link to="/settings" className={classes.SettingsLink}>
|
<Link to="/settings" className={classes.SettingsLink}>
|
||||||
Go to Settings
|
Go to Settings
|
||||||
</Link>
|
</Link>
|
||||||
<span className={classes.HeaderMain}>
|
|
||||||
<h1>{greeting}</h1>
|
{!hideHeader && (
|
||||||
<WeatherWidget />
|
<span className={classes.HeaderMain}>
|
||||||
</span>
|
<h1>{greeting}</h1>
|
||||||
|
<WeatherWidget />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,22 +30,42 @@ export const getDateTime = (): string => {
|
||||||
|
|
||||||
const useAmericanDate = localStorage.useAmericanDate === 'true';
|
const useAmericanDate = localStorage.useAmericanDate === 'true';
|
||||||
const showTime = localStorage.showTime === 'true';
|
const showTime = localStorage.showTime === 'true';
|
||||||
|
const hideDate = localStorage.hideDate === 'true';
|
||||||
|
|
||||||
const p = parseTime;
|
// Date
|
||||||
|
let dateEl = '';
|
||||||
|
|
||||||
const time = `${p(now.getHours())}:${p(now.getMinutes())}:${p(
|
if (!hideDate) {
|
||||||
now.getSeconds()
|
if (!useAmericanDate) {
|
||||||
)}`;
|
dateEl = `${days[now.getDay()]}, ${now.getDate()} ${
|
||||||
|
months[now.getMonth()]
|
||||||
const timeEl = showTime ? ` - ${time}` : '';
|
} ${now.getFullYear()}`;
|
||||||
|
} else {
|
||||||
if (!useAmericanDate) {
|
dateEl = `${days[now.getDay()]}, ${
|
||||||
return `${days[now.getDay()]}, ${now.getDate()} ${
|
months[now.getMonth()]
|
||||||
months[now.getMonth()]
|
} ${now.getDate()} ${now.getFullYear()}`;
|
||||||
} ${now.getFullYear()}${timeEl}`;
|
}
|
||||||
} else {
|
|
||||||
return `${days[now.getDay()]}, ${
|
|
||||||
months[now.getMonth()]
|
|
||||||
} ${now.getDate()} ${now.getFullYear()}${timeEl}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time
|
||||||
|
const p = parseTime;
|
||||||
|
let timeEl = '';
|
||||||
|
|
||||||
|
if (showTime) {
|
||||||
|
const time = `${p(now.getHours())}:${p(now.getMinutes())}:${p(
|
||||||
|
now.getSeconds()
|
||||||
|
)}`;
|
||||||
|
|
||||||
|
timeEl = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Separator
|
||||||
|
let separator = '';
|
||||||
|
|
||||||
|
if (!hideDate && showTime) {
|
||||||
|
separator = ' - ';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output
|
||||||
|
return `${dateEl}${separator}${timeEl}`;
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,7 @@ export const Home = (): JSX.Element => {
|
||||||
<div></div>
|
<div></div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!config.hideHeader ? <Header /> : <div></div>}
|
<Header />
|
||||||
|
|
||||||
{!config.hideApps ? (
|
{!config.hideApps ? (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const DockerSettings = (): JSX.Element => {
|
||||||
<SettingsHeadline text="Docker" />
|
<SettingsHeadline text="Docker" />
|
||||||
{/* CUSTOM DOCKER SOCKET HOST */}
|
{/* CUSTOM DOCKER SOCKET HOST */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="dockerHost">Docker Host</label>
|
<label htmlFor="dockerHost">Docker host</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="dockerHost"
|
id="dockerHost"
|
||||||
|
|
|
@ -70,7 +70,7 @@ export const SearchSettings = (): JSX.Element => {
|
||||||
>
|
>
|
||||||
<SettingsHeadline text="General" />
|
<SettingsHeadline text="General" />
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="defaultSearchProvider">Default Search Provider</label>
|
<label htmlFor="defaultSearchProvider">Default search provider</label>
|
||||||
<select
|
<select
|
||||||
id="defaultSearchProvider"
|
id="defaultSearchProvider"
|
||||||
name="defaultSearchProvider"
|
name="defaultSearchProvider"
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { Route as SettingsRoute } from '../../interfaces';
|
||||||
import classes from './Settings.module.css';
|
import classes from './Settings.module.css';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { Themer } from '../Themer/Themer';
|
import { Themer } from './Themer/Themer';
|
||||||
import { WeatherSettings } from './WeatherSettings/WeatherSettings';
|
import { WeatherSettings } from './WeatherSettings/WeatherSettings';
|
||||||
import { UISettings } from './UISettings/UISettings';
|
import { UISettings } from './UISettings/UISettings';
|
||||||
import { AppDetails } from './AppDetails/AppDetails';
|
import { AppDetails } from './AppDetails/AppDetails';
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
color: var(--color-primary);
|
color: var(--color-primary);
|
||||||
/* align-self: flex-start; */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ColorsPreview {
|
.ColorsPreview {
|
|
@ -1,4 +1,4 @@
|
||||||
import { Theme } from '../../interfaces/Theme';
|
import { Theme } from '../../../interfaces/Theme';
|
||||||
import classes from './ThemePreview.module.css';
|
import classes from './ThemePreview.module.css';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
101
client/src/components/Settings/Themer/Themer.tsx
Normal file
101
client/src/components/Settings/Themer/Themer.tsx
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
import { ChangeEvent, FormEvent, Fragment, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
// Redux
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
import { actionCreators } from '../../../store';
|
||||||
|
|
||||||
|
// Typescript
|
||||||
|
import { Theme, ThemeSettingsForm } from '../../../interfaces';
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import { ThemePreview } from './ThemePreview';
|
||||||
|
import { Button, InputGroup, SettingsHeadline } from '../../UI';
|
||||||
|
|
||||||
|
// Other
|
||||||
|
import classes from './Themer.module.css';
|
||||||
|
import { themes } from './themes.json';
|
||||||
|
import { State } from '../../../store/reducers';
|
||||||
|
import { inputHandler, themeSettingsTemplate } from '../../../utility';
|
||||||
|
|
||||||
|
export const Themer = (): JSX.Element => {
|
||||||
|
const {
|
||||||
|
auth: { isAuthenticated },
|
||||||
|
config: { loading, config },
|
||||||
|
} = useSelector((state: State) => state);
|
||||||
|
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { setTheme, updateConfig } = bindActionCreators(
|
||||||
|
actionCreators,
|
||||||
|
dispatch
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initial state
|
||||||
|
const [formData, setFormData] = useState<ThemeSettingsForm>(
|
||||||
|
themeSettingsTemplate
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get config
|
||||||
|
useEffect(() => {
|
||||||
|
setFormData({
|
||||||
|
...config,
|
||||||
|
});
|
||||||
|
}, [loading]);
|
||||||
|
|
||||||
|
// Form handler
|
||||||
|
const formSubmitHandler = async (e: FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Save settings
|
||||||
|
await updateConfig(formData);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Input handler
|
||||||
|
const inputChangeHandler = (
|
||||||
|
e: ChangeEvent<HTMLInputElement | HTMLSelectElement>,
|
||||||
|
options?: { isNumber?: boolean; isBool?: boolean }
|
||||||
|
) => {
|
||||||
|
inputHandler<ThemeSettingsForm>({
|
||||||
|
e,
|
||||||
|
options,
|
||||||
|
setStateHandler: setFormData,
|
||||||
|
state: formData,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<SettingsHeadline text="Set theme" />
|
||||||
|
<div className={classes.ThemerGrid}>
|
||||||
|
{themes.map(
|
||||||
|
(theme: Theme, idx: number): JSX.Element => (
|
||||||
|
<ThemePreview key={idx} theme={theme} applyTheme={setTheme} />
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isAuthenticated && (
|
||||||
|
<form onSubmit={formSubmitHandler}>
|
||||||
|
<SettingsHeadline text="Other settings" />
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="defaultTheme">Default theme (for new users)</label>
|
||||||
|
<select
|
||||||
|
id="defaultTheme"
|
||||||
|
name="defaultTheme"
|
||||||
|
value={formData.defaultTheme}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
>
|
||||||
|
{themes.map((theme: Theme, idx) => (
|
||||||
|
<option key={idx} value={theme.name}>
|
||||||
|
{theme.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
<Button>Save changes</Button>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
|
@ -66,7 +66,7 @@ export const UISettings = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => formSubmitHandler(e)}>
|
<form onSubmit={(e) => formSubmitHandler(e)}>
|
||||||
{/* OTHER OPTIONS */}
|
{/* === OTHER OPTIONS === */}
|
||||||
<SettingsHeadline text="Miscellaneous" />
|
<SettingsHeadline text="Miscellaneous" />
|
||||||
{/* PAGE TITLE */}
|
{/* PAGE TITLE */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -81,6 +81,50 @@ export const UISettings = (): JSX.Element => {
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* === HEADER OPTIONS === */}
|
||||||
|
<SettingsHeadline text="Header" />
|
||||||
|
{/* HIDE HEADER */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="hideHeader">Hide greetings</label>
|
||||||
|
<select
|
||||||
|
id="hideHeader"
|
||||||
|
name="hideHeader"
|
||||||
|
value={formData.hideHeader ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* HIDE DATE */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="hideDate">Hide date</label>
|
||||||
|
<select
|
||||||
|
id="hideDate"
|
||||||
|
name="hideDate"
|
||||||
|
value={formData.hideDate ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* HIDE TIME */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="showTime">Hide time</label>
|
||||||
|
<select
|
||||||
|
id="showTime"
|
||||||
|
name="showTime"
|
||||||
|
value={formData.showTime ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={0}>True</option>
|
||||||
|
<option value={1}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
{/* DATE FORMAT */}
|
{/* DATE FORMAT */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="useAmericanDate">Date formatting</label>
|
<label htmlFor="useAmericanDate">Date formatting</label>
|
||||||
|
@ -95,7 +139,52 @@ export const UISettings = (): JSX.Element => {
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* BEAHVIOR OPTIONS */}
|
{/* CUSTOM GREETINGS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="greetingsSchema">Custom greetings</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="greetingsSchema"
|
||||||
|
name="greetingsSchema"
|
||||||
|
placeholder="Good day;Hi;Bye!"
|
||||||
|
value={formData.greetingsSchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
Greetings must be separated with semicolon. Only 4 messages can be
|
||||||
|
used
|
||||||
|
</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* CUSTOM DAYS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="daySchema">Custom weekday names</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="daySchema"
|
||||||
|
name="daySchema"
|
||||||
|
placeholder="Sunday;Monday;Tuesday"
|
||||||
|
value={formData.daySchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>Names must be separated with semicolon</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* CUSTOM MONTHS */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="monthSchema">Custom month names</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="monthSchema"
|
||||||
|
name="monthSchema"
|
||||||
|
placeholder="January;February;March"
|
||||||
|
value={formData.monthSchema}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
/>
|
||||||
|
<span>Names must be separated with semicolon</span>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* === BEAHVIOR OPTIONS === */}
|
||||||
<SettingsHeadline text="App Behavior" />
|
<SettingsHeadline text="App Behavior" />
|
||||||
{/* PIN APPS */}
|
{/* PIN APPS */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
@ -172,82 +261,7 @@ export const UISettings = (): JSX.Element => {
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* HEADER OPTIONS */}
|
{/* === MODULES OPTIONS === */}
|
||||||
<SettingsHeadline text="Header" />
|
|
||||||
{/* HIDE HEADER */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="hideHeader">Hide greeting and date</label>
|
|
||||||
<select
|
|
||||||
id="hideHeader"
|
|
||||||
name="hideHeader"
|
|
||||||
value={formData.hideHeader ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM GREETINGS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="greetingsSchema">Custom greetings</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="greetingsSchema"
|
|
||||||
name="greetingsSchema"
|
|
||||||
placeholder="Good day;Hi;Bye!"
|
|
||||||
value={formData.greetingsSchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>
|
|
||||||
Greetings must be separated with semicolon. Only 4 messages can be
|
|
||||||
used
|
|
||||||
</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM DAYS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="daySchema">Custom weekday names</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="daySchema"
|
|
||||||
name="daySchema"
|
|
||||||
placeholder="Sunday;Monday;Tuesday"
|
|
||||||
value={formData.daySchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>Names must be separated with semicolon</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* CUSTOM MONTHS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="monthSchema">Custom month names</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="monthSchema"
|
|
||||||
name="monthSchema"
|
|
||||||
placeholder="January;February;March"
|
|
||||||
value={formData.monthSchema}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
/>
|
|
||||||
<span>Names must be separated with semicolon</span>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* SHOW TIME */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="showTime">Show time</label>
|
|
||||||
<select
|
|
||||||
id="showTime"
|
|
||||||
name="showTime"
|
|
||||||
value={formData.showTime ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* MODULES OPTIONS */}
|
|
||||||
<SettingsHeadline text="Modules" />
|
<SettingsHeadline text="Modules" />
|
||||||
{/* HIDE APPS */}
|
{/* HIDE APPS */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { State } from '../../../store/reducers';
|
||||||
import { ApiResponse, Weather, WeatherForm } from '../../../interfaces';
|
import { ApiResponse, Weather, WeatherForm } from '../../../interfaces';
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
import { InputGroup, Button } from '../../UI';
|
import { InputGroup, Button, SettingsHeadline } from '../../UI';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { inputHandler, weatherSettingsTemplate } from '../../../utility';
|
import { inputHandler, weatherSettingsTemplate } from '../../../utility';
|
||||||
|
@ -84,6 +84,8 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => formSubmitHandler(e)}>
|
<form onSubmit={(e) => formSubmitHandler(e)}>
|
||||||
|
<SettingsHeadline text="API" />
|
||||||
|
{/* API KEY */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="WEATHER_API_KEY">API key</label>
|
<label htmlFor="WEATHER_API_KEY">API key</label>
|
||||||
<input
|
<input
|
||||||
|
@ -104,8 +106,10 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
</span>
|
</span>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
<SettingsHeadline text="Location" />
|
||||||
|
{/* LAT */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="lat">Location latitude</label>
|
<label htmlFor="lat">Latitude</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="lat"
|
id="lat"
|
||||||
|
@ -128,8 +132,9 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
</span>
|
</span>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* LONG */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="long">Location longitude</label>
|
<label htmlFor="long">Longitude</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="long"
|
id="long"
|
||||||
|
@ -142,6 +147,8 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
<SettingsHeadline text="Other" />
|
||||||
|
{/* TEMPERATURE */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="isCelsius">Temperature unit</label>
|
<label htmlFor="isCelsius">Temperature unit</label>
|
||||||
<select
|
<select
|
||||||
|
@ -155,6 +162,20 @@ export const WeatherSettings = (): JSX.Element => {
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* WEATHER DATA */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="weatherData">Additional weather data</label>
|
||||||
|
<select
|
||||||
|
id="weatherData"
|
||||||
|
name="weatherData"
|
||||||
|
value={formData.weatherData}
|
||||||
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
|
>
|
||||||
|
<option value="cloud">Cloud coverage</option>
|
||||||
|
<option value="humidity">Humidity</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
<Button>Save changes</Button>
|
<Button>Save changes</Button>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
import { Fragment } from 'react';
|
|
||||||
import { useDispatch } from 'react-redux';
|
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { actionCreators } from '../../store';
|
|
||||||
|
|
||||||
import classes from './Themer.module.css';
|
|
||||||
|
|
||||||
import { themes } from './themes.json';
|
|
||||||
import { Theme } from '../../interfaces/Theme';
|
|
||||||
import { ThemePreview } from './ThemePreview';
|
|
||||||
|
|
||||||
export const Themer = (): JSX.Element => {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const { setTheme } = bindActionCreators(actionCreators, dispatch);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
<div>
|
|
||||||
<div className={classes.ThemerGrid}>
|
|
||||||
{themes.map(
|
|
||||||
(theme: Theme, idx: number): JSX.Element => (
|
|
||||||
<ThemePreview key={idx} theme={theme} applyTheme={setTheme} />
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -13,22 +13,14 @@ import classes from './WeatherWidget.module.css';
|
||||||
// UI
|
// UI
|
||||||
import { WeatherIcon } from '../../UI';
|
import { WeatherIcon } from '../../UI';
|
||||||
import { State } from '../../../store/reducers';
|
import { State } from '../../../store/reducers';
|
||||||
|
import { weatherTemplate } from '../../../utility/templateObjects/weatherTemplate';
|
||||||
|
|
||||||
export const WeatherWidget = (): JSX.Element => {
|
export const WeatherWidget = (): JSX.Element => {
|
||||||
const { loading, config } = useSelector((state: State) => state.config);
|
const { loading: configLoading, config } = useSelector(
|
||||||
|
(state: State) => state.config
|
||||||
|
);
|
||||||
|
|
||||||
const [weather, setWeather] = useState<Weather>({
|
const [weather, setWeather] = useState<Weather>(weatherTemplate);
|
||||||
externalLastUpdate: '',
|
|
||||||
tempC: 0,
|
|
||||||
tempF: 0,
|
|
||||||
isDay: 1,
|
|
||||||
cloud: 0,
|
|
||||||
conditionText: '',
|
|
||||||
conditionCode: 1000,
|
|
||||||
id: -1,
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date(),
|
|
||||||
});
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
// Initial request to get data
|
// Initial request to get data
|
||||||
|
@ -65,8 +57,7 @@ export const WeatherWidget = (): JSX.Element => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.WeatherWidget}>
|
<div className={classes.WeatherWidget}>
|
||||||
{isLoading ||
|
{configLoading ||
|
||||||
loading ||
|
|
||||||
(config.WEATHER_API_KEY && weather.id > 0 && (
|
(config.WEATHER_API_KEY && weather.id > 0 && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<div className={classes.WeatherIcon}>
|
<div className={classes.WeatherIcon}>
|
||||||
|
@ -76,12 +67,15 @@ export const WeatherWidget = (): JSX.Element => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.WeatherDetails}>
|
<div className={classes.WeatherDetails}>
|
||||||
|
{/* TEMPERATURE */}
|
||||||
{config.isCelsius ? (
|
{config.isCelsius ? (
|
||||||
<span>{weather.tempC}°C</span>
|
<span>{weather.tempC}°C</span>
|
||||||
) : (
|
) : (
|
||||||
<span>{weather.tempF}°F</span>
|
<span>{weather.tempF}°F</span>
|
||||||
)}
|
)}
|
||||||
<span>{weather.cloud}%</span>
|
|
||||||
|
{/* ADDITIONAL DATA */}
|
||||||
|
<span>{weather[config.weatherData]}%</span>
|
||||||
</div>
|
</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { WeatherData } from '../types';
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
WEATHER_API_KEY: string;
|
WEATHER_API_KEY: string;
|
||||||
lat: number;
|
lat: number;
|
||||||
|
@ -25,4 +27,8 @@ export interface Config {
|
||||||
daySchema: string;
|
daySchema: string;
|
||||||
monthSchema: string;
|
monthSchema: string;
|
||||||
showTime: boolean;
|
showTime: boolean;
|
||||||
|
defaultTheme: string;
|
||||||
|
isKilometer: boolean;
|
||||||
|
weatherData: WeatherData;
|
||||||
|
hideDate: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
import { WeatherData } from '../types';
|
||||||
|
|
||||||
export interface WeatherForm {
|
export interface WeatherForm {
|
||||||
WEATHER_API_KEY: string;
|
WEATHER_API_KEY: string;
|
||||||
lat: number;
|
lat: number;
|
||||||
long: number;
|
long: number;
|
||||||
isCelsius: boolean;
|
isCelsius: boolean;
|
||||||
|
weatherData: WeatherData;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchForm {
|
export interface SearchForm {
|
||||||
|
@ -27,6 +30,7 @@ export interface OtherSettingsForm {
|
||||||
daySchema: string;
|
daySchema: string;
|
||||||
monthSchema: string;
|
monthSchema: string;
|
||||||
showTime: boolean;
|
showTime: boolean;
|
||||||
|
hideDate: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DockerSettingsForm {
|
export interface DockerSettingsForm {
|
||||||
|
@ -35,3 +39,7 @@ export interface DockerSettingsForm {
|
||||||
kubernetesApps: boolean;
|
kubernetesApps: boolean;
|
||||||
unpinStoppedApps: boolean;
|
unpinStoppedApps: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ThemeSettingsForm {
|
||||||
|
defaultTheme: string;
|
||||||
|
}
|
||||||
|
|
|
@ -8,4 +8,7 @@ export interface Weather extends Model {
|
||||||
cloud: number;
|
cloud: number;
|
||||||
conditionText: string;
|
conditionText: string;
|
||||||
conditionCode: number;
|
conditionCode: number;
|
||||||
|
humidity: number;
|
||||||
|
windK: number;
|
||||||
|
windM: number;
|
||||||
}
|
}
|
|
@ -8,17 +8,10 @@ import {
|
||||||
UpdateQueryAction,
|
UpdateQueryAction,
|
||||||
} from '../actions/config';
|
} from '../actions/config';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import {
|
import { ApiResponse, Config, Query } from '../../interfaces';
|
||||||
ApiResponse,
|
|
||||||
Config,
|
|
||||||
DockerSettingsForm,
|
|
||||||
OtherSettingsForm,
|
|
||||||
Query,
|
|
||||||
SearchForm,
|
|
||||||
WeatherForm,
|
|
||||||
} from '../../interfaces';
|
|
||||||
import { ActionType } from '../action-types';
|
import { ActionType } from '../action-types';
|
||||||
import { storeUIConfig, applyAuth } from '../../utility';
|
import { storeUIConfig, applyAuth } from '../../utility';
|
||||||
|
import { ConfigFormData } from '../../types';
|
||||||
|
|
||||||
const keys: (keyof Config)[] = [
|
const keys: (keyof Config)[] = [
|
||||||
'useAmericanDate',
|
'useAmericanDate',
|
||||||
|
@ -26,6 +19,7 @@ const keys: (keyof Config)[] = [
|
||||||
'daySchema',
|
'daySchema',
|
||||||
'monthSchema',
|
'monthSchema',
|
||||||
'showTime',
|
'showTime',
|
||||||
|
'hideDate',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
||||||
|
@ -50,9 +44,7 @@ export const getConfig = () => async (dispatch: Dispatch<GetConfigAction>) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateConfig =
|
export const updateConfig =
|
||||||
(
|
(formData: ConfigFormData) =>
|
||||||
formData: WeatherForm | OtherSettingsForm | SearchForm | DockerSettingsForm
|
|
||||||
) =>
|
|
||||||
async (dispatch: Dispatch<UpdateConfigAction>) => {
|
async (dispatch: Dispatch<UpdateConfigAction>) => {
|
||||||
try {
|
try {
|
||||||
const res = await axios.put<ApiResponse<Config>>(
|
const res = await axios.put<ApiResponse<Config>>(
|
||||||
|
|
|
@ -2,14 +2,18 @@ import { Dispatch } from 'redux';
|
||||||
import { SetThemeAction } from '../actions/theme';
|
import { SetThemeAction } from '../actions/theme';
|
||||||
import { ActionType } from '../action-types';
|
import { ActionType } from '../action-types';
|
||||||
import { Theme } from '../../interfaces/Theme';
|
import { Theme } from '../../interfaces/Theme';
|
||||||
import { themes } from '../../components/Themer/themes.json';
|
import { themes } from '../../components/Settings/Themer/themes.json';
|
||||||
|
|
||||||
export const setTheme =
|
export const setTheme =
|
||||||
(name: string) => (dispatch: Dispatch<SetThemeAction>) => {
|
(name: string, remeberTheme: boolean = true) =>
|
||||||
|
(dispatch: Dispatch<SetThemeAction>) => {
|
||||||
const theme = themes.find((theme) => theme.name === name);
|
const theme = themes.find((theme) => theme.name === name);
|
||||||
|
|
||||||
if (theme) {
|
if (theme) {
|
||||||
localStorage.setItem('theme', name);
|
if (remeberTheme) {
|
||||||
|
localStorage.setItem('theme', name);
|
||||||
|
}
|
||||||
|
|
||||||
loadTheme(theme);
|
loadTheme(theme);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
14
client/src/types/ConfigFormData.ts
Normal file
14
client/src/types/ConfigFormData.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import {
|
||||||
|
DockerSettingsForm,
|
||||||
|
OtherSettingsForm,
|
||||||
|
SearchForm,
|
||||||
|
ThemeSettingsForm,
|
||||||
|
WeatherForm,
|
||||||
|
} from '../interfaces';
|
||||||
|
|
||||||
|
export type ConfigFormData =
|
||||||
|
| WeatherForm
|
||||||
|
| SearchForm
|
||||||
|
| DockerSettingsForm
|
||||||
|
| OtherSettingsForm
|
||||||
|
| ThemeSettingsForm;
|
1
client/src/types/WeatherData.ts
Normal file
1
client/src/types/WeatherData.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export type WeatherData = 'cloud' | 'humidity';
|
2
client/src/types/index.ts
Normal file
2
client/src/types/index.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './ConfigFormData';
|
||||||
|
export * from './WeatherData';
|
|
@ -1,4 +1,4 @@
|
||||||
export const applyAuth = () => {
|
export const applyAuth = () => {
|
||||||
const token = localStorage.getItem('token') || '';
|
const token = localStorage.getItem('token') || '';
|
||||||
return { Authorization: `Bearer ${token}` };
|
return { 'Authorization-Flame': `Bearer ${token}` };
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,4 +28,8 @@ export const configTemplate: Config = {
|
||||||
monthSchema:
|
monthSchema:
|
||||||
'January;February;March;April;May;June;July;August;September;October;November;December',
|
'January;February;March;April;May;June;July;August;September;October;November;December',
|
||||||
showTime: false,
|
showTime: false,
|
||||||
|
defaultTheme: 'tron',
|
||||||
|
isKilometer: true,
|
||||||
|
weatherData: 'cloud',
|
||||||
|
hideDate: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {
|
||||||
DockerSettingsForm,
|
DockerSettingsForm,
|
||||||
OtherSettingsForm,
|
OtherSettingsForm,
|
||||||
SearchForm,
|
SearchForm,
|
||||||
|
ThemeSettingsForm,
|
||||||
WeatherForm,
|
WeatherForm,
|
||||||
} from '../../interfaces';
|
} from '../../interfaces';
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ export const otherSettingsTemplate: OtherSettingsForm = {
|
||||||
monthSchema:
|
monthSchema:
|
||||||
'January;February;March;April;May;June;July;August;September;October;November;December',
|
'January;February;March;April;May;June;July;August;September;October;November;December',
|
||||||
showTime: false,
|
showTime: false,
|
||||||
|
hideDate: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const weatherSettingsTemplate: WeatherForm = {
|
export const weatherSettingsTemplate: WeatherForm = {
|
||||||
|
@ -28,6 +30,7 @@ export const weatherSettingsTemplate: WeatherForm = {
|
||||||
lat: 0,
|
lat: 0,
|
||||||
long: 0,
|
long: 0,
|
||||||
isCelsius: true,
|
isCelsius: true,
|
||||||
|
weatherData: 'cloud',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const searchSettingsTemplate: SearchForm = {
|
export const searchSettingsTemplate: SearchForm = {
|
||||||
|
@ -43,3 +46,7 @@ export const dockerSettingsTemplate: DockerSettingsForm = {
|
||||||
kubernetesApps: true,
|
kubernetesApps: true,
|
||||||
unpinStoppedApps: true,
|
unpinStoppedApps: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const themeSettingsTemplate: ThemeSettingsForm = {
|
||||||
|
defaultTheme: 'tron',
|
||||||
|
};
|
||||||
|
|
17
client/src/utility/templateObjects/weatherTemplate.ts
Normal file
17
client/src/utility/templateObjects/weatherTemplate.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { Weather } from '../../interfaces';
|
||||||
|
|
||||||
|
export const weatherTemplate: Weather = {
|
||||||
|
externalLastUpdate: '',
|
||||||
|
tempC: 0,
|
||||||
|
tempF: 0,
|
||||||
|
isDay: 1,
|
||||||
|
cloud: 0,
|
||||||
|
conditionText: '',
|
||||||
|
conditionCode: 1000,
|
||||||
|
id: -1,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
humidity: 0,
|
||||||
|
windK: 0,
|
||||||
|
windM: 0,
|
||||||
|
};
|
|
@ -8,25 +8,20 @@ const loadConfig = require('../../utils/loadConfig');
|
||||||
const createApp = asyncWrapper(async (req, res, next) => {
|
const createApp = asyncWrapper(async (req, res, next) => {
|
||||||
const { pinAppsByDefault } = await loadConfig();
|
const { pinAppsByDefault } = await loadConfig();
|
||||||
|
|
||||||
let app;
|
let body = { ...req.body };
|
||||||
let _body = { ...req.body };
|
|
||||||
|
|
||||||
if (_body.icon) {
|
if (body.icon) {
|
||||||
_body.icon = _body.icon.trim();
|
body.icon = body.icon.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
_body.icon = req.file.filename;
|
body.icon = req.file.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pinAppsByDefault) {
|
const app = await App.create({
|
||||||
app = await App.create({
|
...body,
|
||||||
..._body,
|
isPinned: pinAppsByDefault,
|
||||||
isPinned: true,
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
app = await App.create(req.body);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
@ -18,17 +18,17 @@ const updateApp = asyncWrapper(async (req, res, next) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _body = { ...req.body };
|
let body = { ...req.body };
|
||||||
|
|
||||||
if (_body.icon) {
|
if (body.icon) {
|
||||||
_body.icon = _body.icon.trim();
|
body.icon = body.icon.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
_body.icon = req.file.filename;
|
body.icon = req.file.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
app = await app.update(_body);
|
app = await app.update(body);
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
@ -7,20 +7,20 @@ const Bookmark = require('../../models/Bookmark');
|
||||||
const createBookmark = asyncWrapper(async (req, res, next) => {
|
const createBookmark = asyncWrapper(async (req, res, next) => {
|
||||||
let bookmark;
|
let bookmark;
|
||||||
|
|
||||||
let _body = {
|
let body = {
|
||||||
...req.body,
|
...req.body,
|
||||||
categoryId: parseInt(req.body.categoryId),
|
categoryId: parseInt(req.body.categoryId),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_body.icon) {
|
if (body.icon) {
|
||||||
_body.icon = _body.icon.trim();
|
body.icon = body.icon.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
_body.icon = req.file.filename;
|
body.icon = req.file.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmark = await Bookmark.create(_body);
|
bookmark = await Bookmark.create(body);
|
||||||
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
@ -19,20 +19,20 @@ const updateBookmark = asyncWrapper(async (req, res, next) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _body = {
|
let body = {
|
||||||
...req.body,
|
...req.body,
|
||||||
categoryId: parseInt(req.body.categoryId),
|
categoryId: parseInt(req.body.categoryId),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_body.icon) {
|
if (body.icon) {
|
||||||
_body.icon = _body.icon.trim();
|
body.icon = body.icon.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
_body.icon = req.file.filename;
|
body.icon = req.file.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmark = await bookmark.update(_body);
|
bookmark = await bookmark.update(body);
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
@ -8,16 +8,10 @@ const loadConfig = require('../../utils/loadConfig');
|
||||||
const createCategory = asyncWrapper(async (req, res, next) => {
|
const createCategory = asyncWrapper(async (req, res, next) => {
|
||||||
const { pinCategoriesByDefault: pinCategories } = await loadConfig();
|
const { pinCategoriesByDefault: pinCategories } = await loadConfig();
|
||||||
|
|
||||||
let category;
|
const category = await Category.create({
|
||||||
|
...req.body,
|
||||||
if (pinCategories) {
|
isPinned: pinCategories,
|
||||||
category = await Category.create({
|
});
|
||||||
...req.body,
|
|
||||||
isPinned: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
category = await Category.create(req.body);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
35
db/migrations/03_weather.js
Normal file
35
db/migrations/03_weather.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
const { DataTypes } = require('sequelize');
|
||||||
|
const { INTEGER, FLOAT } = DataTypes;
|
||||||
|
const loadConfig = require('../../utils/loadConfig');
|
||||||
|
const getExternalWeather = require('../../utils/getExternalWeather');
|
||||||
|
|
||||||
|
const up = async (query) => {
|
||||||
|
await query.addColumn('weather', 'humidity', {
|
||||||
|
type: INTEGER,
|
||||||
|
});
|
||||||
|
|
||||||
|
await query.addColumn('weather', 'windK', {
|
||||||
|
type: FLOAT,
|
||||||
|
});
|
||||||
|
|
||||||
|
await query.addColumn('weather', 'windM', {
|
||||||
|
type: FLOAT,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { WEATHER_API_KEY: secret } = await loadConfig();
|
||||||
|
|
||||||
|
if (secret) {
|
||||||
|
await getExternalWeather();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const down = async (query) => {
|
||||||
|
await query.removeColumn('weather', 'humidity');
|
||||||
|
await query.removeColumn('weather', 'windK');
|
||||||
|
await query.removeColumn('weather', 'windM');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up,
|
||||||
|
down,
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
|
||||||
const auth = (req, res, next) => {
|
const auth = (req, res, next) => {
|
||||||
const authHeader = req.header('Authorization');
|
const authHeader = req.header('Authorization-Flame');
|
||||||
let token;
|
let token;
|
||||||
let tokenIsValid = false;
|
let tokenIsValid = false;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
const { DataTypes } = require('sequelize');
|
const { DataTypes } = require('sequelize');
|
||||||
const { sequelize } = require('../db');
|
const { sequelize } = require('../db');
|
||||||
|
|
||||||
const Weather = sequelize.define('Weather', {
|
const Weather = sequelize.define(
|
||||||
externalLastUpdate: DataTypes.STRING,
|
'Weather',
|
||||||
tempC: DataTypes.FLOAT,
|
{
|
||||||
tempF: DataTypes.FLOAT,
|
externalLastUpdate: DataTypes.STRING,
|
||||||
isDay: DataTypes.INTEGER,
|
tempC: DataTypes.FLOAT,
|
||||||
cloud: DataTypes.INTEGER,
|
tempF: DataTypes.FLOAT,
|
||||||
conditionText: DataTypes.TEXT,
|
isDay: DataTypes.INTEGER,
|
||||||
conditionCode: DataTypes.INTEGER
|
cloud: DataTypes.INTEGER,
|
||||||
}, {
|
conditionText: DataTypes.TEXT,
|
||||||
tableName: 'weather'
|
conditionCode: DataTypes.INTEGER,
|
||||||
});
|
humidity: DataTypes.INTEGER,
|
||||||
|
windK: DataTypes.FLOAT,
|
||||||
|
windM: DataTypes.FLOAT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tableName: 'weather',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = Weather;
|
module.exports = Weather;
|
|
@ -21,6 +21,9 @@ const getExternalWeather = async () => {
|
||||||
cloud: cursor.cloud,
|
cloud: cursor.cloud,
|
||||||
conditionText: cursor.condition.text,
|
conditionText: cursor.condition.text,
|
||||||
conditionCode: cursor.condition.code,
|
conditionCode: cursor.condition.code,
|
||||||
|
humidity: cursor.humidity,
|
||||||
|
windK: cursor.wind_kph,
|
||||||
|
windM: cursor.wind_mph,
|
||||||
});
|
});
|
||||||
return weatherData;
|
return weatherData;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -24,5 +24,9 @@
|
||||||
"greetingsSchema": "Good evening!;Good afternoon!;Good morning!;Good night!",
|
"greetingsSchema": "Good evening!;Good afternoon!;Good morning!;Good night!",
|
||||||
"daySchema": "Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday",
|
"daySchema": "Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday",
|
||||||
"monthSchema": "January;February;March;April;May;June;July;August;September;October;November;December",
|
"monthSchema": "January;February;March;April;May;June;July;August;September;October;November;December",
|
||||||
"showTime": false
|
"showTime": false,
|
||||||
|
"defaultTheme": "tron",
|
||||||
|
"isKilometer": true,
|
||||||
|
"weatherData": "cloud",
|
||||||
|
"hideDate": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue