Added option to set custom day and month

This commit is contained in:
Paweł Malak 2021-11-05 17:16:19 +01:00
parent 7febd59ad7
commit bce51bb2c4
12 changed files with 99 additions and 9 deletions

View file

@ -1,5 +1,5 @@
### v1.7.4 (TBA) ### v1.7.4 (TBA)
- [WIP] Added option to set custom greetings and date ([#103](https://github.com/pawelmalak/flame/issues/103)) - Added option to set custom greetings and date ([#103](https://github.com/pawelmalak/flame/issues/103))
- Added iOS "Add to homescreen" icon ([#131](https://github.com/pawelmalak/flame/issues/131)) - Added iOS "Add to homescreen" icon ([#131](https://github.com/pawelmalak/flame/issues/131))
- Added 3 new themes - Added 3 new themes

View file

@ -1,5 +1,5 @@
export const getDateTime = (): string => { export const getDateTime = (): string => {
const days = [ const days = localStorage.getItem('daySchema')?.split(';') || [
'Sunday', 'Sunday',
'Monday', 'Monday',
'Tuesday', 'Tuesday',
@ -8,7 +8,8 @@ export const getDateTime = (): string => {
'Friday', 'Friday',
'Saturday', 'Saturday',
]; ];
const months = [
const months = localStorage.getItem('monthSchema')?.split(';') || [
'January', 'January',
'February', 'February',
'March', 'March',

View file

@ -81,6 +81,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<form onSubmit={(e) => formSubmitHandler(e)}> <form onSubmit={(e) => formSubmitHandler(e)}>
{/* OTHER OPTIONS */} {/* OTHER OPTIONS */}
<SettingsHeadline text="Miscellaneous" /> <SettingsHeadline text="Miscellaneous" />
{/* PAGE TITLE */}
<InputGroup> <InputGroup>
<label htmlFor="customTitle">Custom page title</label> <label htmlFor="customTitle">Custom page title</label>
<input <input
@ -92,6 +93,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
onChange={(e) => inputChangeHandler(e)} onChange={(e) => inputChangeHandler(e)}
/> />
</InputGroup> </InputGroup>
{/* DATE FORMAT */}
<InputGroup> <InputGroup>
<label htmlFor="useAmericanDate">Date formatting</label> <label htmlFor="useAmericanDate">Date formatting</label>
<select <select
@ -107,6 +110,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* BEAHVIOR OPTIONS */} {/* BEAHVIOR OPTIONS */}
<SettingsHeadline text="App Behavior" /> <SettingsHeadline text="App Behavior" />
{/* PIN APPS */}
<InputGroup> <InputGroup>
<label htmlFor="pinAppsByDefault"> <label htmlFor="pinAppsByDefault">
Pin new applications by default Pin new applications by default
@ -121,6 +125,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* PIN CATEGORIES */}
<InputGroup> <InputGroup>
<label htmlFor="pinCategoriesByDefault"> <label htmlFor="pinCategoriesByDefault">
Pin new categories by default Pin new categories by default
@ -135,6 +141,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* SORT TYPE */}
<InputGroup> <InputGroup>
<label htmlFor="useOrdering">Sorting type</label> <label htmlFor="useOrdering">Sorting type</label>
<select <select
@ -148,6 +156,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value="orderId">Custom order</option> <option value="orderId">Custom order</option>
</select> </select>
</InputGroup> </InputGroup>
{/* APPS OPPENING */}
<InputGroup> <InputGroup>
<label htmlFor="appsSameTab">Open applications in the same tab</label> <label htmlFor="appsSameTab">Open applications in the same tab</label>
<select <select
@ -160,6 +170,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* BOOKMARKS OPPENING */}
<InputGroup> <InputGroup>
<label htmlFor="bookmarksSameTab">Open bookmarks in the same tab</label> <label htmlFor="bookmarksSameTab">Open bookmarks in the same tab</label>
<select <select
@ -175,6 +187,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* MODULES OPTIONS */} {/* MODULES OPTIONS */}
<SettingsHeadline text="Modules" /> <SettingsHeadline text="Modules" />
{/* HIDE HEADER */}
<InputGroup> <InputGroup>
<label htmlFor="hideHeader">Hide greeting and date</label> <label htmlFor="hideHeader">Hide greeting and date</label>
<select <select
@ -187,6 +200,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* CUSTOM GREETINGS */}
<InputGroup> <InputGroup>
<label htmlFor="greetingsSchema">Custom greetings</label> <label htmlFor="greetingsSchema">Custom greetings</label>
<input <input
@ -202,6 +217,36 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
used used
</span> </span>
</InputGroup> </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>
{/* HIDE APPS */}
<InputGroup> <InputGroup>
<label htmlFor="hideApps">Hide applications</label> <label htmlFor="hideApps">Hide applications</label>
<select <select
@ -214,6 +259,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* HIDE CATEGORIES */}
<InputGroup> <InputGroup>
<label htmlFor="hideCategories">Hide categories</label> <label htmlFor="hideCategories">Hide categories</label>
<select <select
@ -229,6 +276,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* DOCKER SETTINGS */} {/* DOCKER SETTINGS */}
<SettingsHeadline text="Docker" /> <SettingsHeadline text="Docker" />
{/* CUSTOM DOCKER SOCKET HOST */}
<InputGroup> <InputGroup>
<label htmlFor="dockerHost">Docker Host</label> <label htmlFor="dockerHost">Docker Host</label>
<input <input
@ -240,6 +288,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
onChange={(e) => inputChangeHandler(e)} onChange={(e) => inputChangeHandler(e)}
/> />
</InputGroup> </InputGroup>
{/* USE DOCKER API */}
<InputGroup> <InputGroup>
<label htmlFor="dockerApps">Use Docker API</label> <label htmlFor="dockerApps">Use Docker API</label>
<select <select
@ -252,6 +302,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
<option value={0}>False</option> <option value={0}>False</option>
</select> </select>
</InputGroup> </InputGroup>
{/* UNPIN DOCKER APPS */}
<InputGroup> <InputGroup>
<label htmlFor="unpinStoppedApps"> <label htmlFor="unpinStoppedApps">
Unpin stopped containers / other apps Unpin stopped containers / other apps
@ -269,6 +321,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* KUBERNETES SETTINGS */} {/* KUBERNETES SETTINGS */}
<SettingsHeadline text="Kubernetes" /> <SettingsHeadline text="Kubernetes" />
{/* USE KUBERNETES */}
<InputGroup> <InputGroup>
<label htmlFor="kubernetesApps">Use Kubernetes Ingress API</label> <label htmlFor="kubernetesApps">Use Kubernetes Ingress API</label>
<select <select

View file

@ -22,4 +22,6 @@ export interface Config {
useAmericanDate: boolean; useAmericanDate: boolean;
disableAutofocus: boolean; disableAutofocus: boolean;
greetingsSchema: string; greetingsSchema: string;
daySchema: string;
monthSchema: string;
} }

View file

@ -28,4 +28,6 @@ export interface OtherSettingsForm {
unpinStoppedApps: boolean; unpinStoppedApps: boolean;
useAmericanDate: boolean; useAmericanDate: boolean;
greetingsSchema: string; greetingsSchema: string;
daySchema: string;
monthSchema: string;
} }

View file

@ -3,6 +3,7 @@ import { Dispatch } from 'redux';
import { ActionTypes } from './actionTypes'; import { ActionTypes } from './actionTypes';
import { Config, ApiResponse, Query } from '../../interfaces'; import { Config, ApiResponse, Query } from '../../interfaces';
import { CreateNotificationAction } from './notification'; import { CreateNotificationAction } from './notification';
import { storeUIConfig } from '../../utility';
export interface GetConfigAction { export interface GetConfigAction {
type: ActionTypes.getConfig; type: ActionTypes.getConfig;
@ -22,8 +23,15 @@ export const getConfig = () => async (dispatch: Dispatch) => {
document.title = res.data.data.customTitle; document.title = res.data.data.customTitle;
// Store settings for priority UI elements // Store settings for priority UI elements
localStorage.setItem('useAmericanDate', `${res.data.data.useAmericanDate}`); const keys: (keyof Config)[] = [
localStorage.setItem('greetingsSchema', `${res.data.data.greetingsSchema}`); 'useAmericanDate',
'greetingsSchema',
'daySchema',
'monthSchema',
];
for (let key of keys) {
storeUIConfig(key, res.data.data);
}
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
@ -52,8 +60,15 @@ export const updateConfig = (formData: any) => async (dispatch: Dispatch) => {
}); });
// Store settings for priority UI elements // Store settings for priority UI elements
localStorage.setItem('useAmericanDate', `${res.data.data.useAmericanDate}`); const keys: (keyof Config)[] = [
localStorage.setItem('greetingsSchema', `${res.data.data.greetingsSchema}`); 'useAmericanDate',
'greetingsSchema',
'daySchema',
'monthSchema',
];
for (let key of keys) {
storeUIConfig(key, res.data.data);
}
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }

View file

@ -10,7 +10,7 @@ export interface State {
const initialState: State = { const initialState: State = {
loading: true, loading: true,
config: configTemplate, config: { ...configTemplate },
customQueries: [], customQueries: [],
}; };

View file

@ -6,3 +6,4 @@ export * from './searchParser';
export * from './redirectUrl'; export * from './redirectUrl';
export * from './templateObjects'; export * from './templateObjects';
export * from './inputHandler'; export * from './inputHandler';
export * from './storeUIConfig';

View file

@ -0,0 +1,8 @@
import { Config } from '../interfaces';
export const storeUIConfig = <K extends keyof Config>(
key: K,
config: Config
) => {
localStorage.setItem(key, `${config[key]}`);
};

View file

@ -24,4 +24,7 @@ export const configTemplate: Config = {
useAmericanDate: false, useAmericanDate: false,
disableAutofocus: false, disableAutofocus: false,
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',
monthSchema:
'January;February;March;April;May;June;July;August;September;October;November;December',
}; };

View file

@ -16,6 +16,9 @@ export const otherSettingsTemplate: OtherSettingsForm = {
unpinStoppedApps: true, unpinStoppedApps: true,
useAmericanDate: false, useAmericanDate: false,
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',
monthSchema:
'January;February;March;April;May;June;July;August;September;October;November;December',
}; };
export const weatherSettingsTemplate: WeatherForm = { export const weatherSettingsTemplate: WeatherForm = {

View file

@ -21,5 +21,7 @@
"unpinStoppedApps": false, "unpinStoppedApps": false,
"useAmericanDate": false, "useAmericanDate": false,
"disableAutofocus": false, "disableAutofocus": false,
"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",
"monthSchema": "January;February;March;April;May;June;July;August;September;October;November;December"
} }