Skip to content

Commit

Permalink
Finishes the feature to scale and increase the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
lupusA committed Dec 17, 2023
1 parent 91204d8 commit 8b453ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
18 changes: 4 additions & 14 deletions src/contexts/UIPreferencesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ const PREFERENCES_URL = '/api/v1/ui-preferences';

export type Theme = "light" | "dark" | "pastel" | "ocean";
export type PageSize = 10 | 20 | 30 | 40 | 50 | 100;
export type fontSize = "fs-6" | "fs-5" | "fs-4" | "fs-3";
export type fontSize = "fs-6" | "fs-5" | "fs-4";

export interface UIPreferences {
get pageSize(): PageSize
get theme(): Theme
get bytesStringBase2(): boolean
get defaultSnapshotViewAll(): boolean
get preferWebDav(): boolean
get fontSize(): fontSize
setTheme: (theme: Theme) => void
setPageSize: (pageSize: number) => void
setByteStringBase: (bytesStringBase2: String) => void
setDefaultSnapshotViewAll: (defaultSnapshotView: boolean) => void
setPreferWebDav: (preferWebDav: String) => void
setFontSize: (size: String) => void
}

Expand All @@ -31,7 +29,6 @@ interface SerializedUIPreferences {
bytesStringBase2?: boolean
defaultSnapshotView?: boolean
theme: Theme
preferWebDav?: boolean
fontSize: fontSize
}

Expand Down Expand Up @@ -77,7 +74,7 @@ export function UIPreferenceProvider(props: UIPreferenceProviderProps) {
const setTheme = useCallback((theme: Theme) => setPreferences(oldPreferences => {
syncTheme(theme, oldPreferences.theme);
return { ...oldPreferences, theme };
}),[]);
}), []);

const setPageSize = (pageSize: PageSize) => setPreferences(oldPreferences => {
return { ...oldPreferences, pageSize };
Expand All @@ -92,15 +89,10 @@ export function UIPreferenceProvider(props: UIPreferenceProviderProps) {
return { ...oldPreferences, input };
});

const setPreferWebDav = (input: String) => setPreferences(oldPreferences => {
var preferWebDav = input === "true";
return { ...oldPreferences, preferWebDav };
});

const setFontSize = useCallback((fontSize: fontSize) => setPreferences(oldPreferences => {
syncFontSize(fontSize, oldPreferences.fontSize);
return { ...oldPreferences, fontSize };
}),[]);
}), []);

useEffect(() => {
axios.get(PREFERENCES_URL).then(result => {
Expand Down Expand Up @@ -153,9 +145,7 @@ export function UIPreferenceProvider(props: UIPreferenceProviderProps) {
}
}



const providedValue = { ...preferences, setTheme, setPageSize, setByteStringBase, setDefaultSnapshotViewAll, setPreferWebDav, setFontSize } as UIPreferences;
const providedValue = { ...preferences, setTheme, setPageSize, setByteStringBase, setDefaultSnapshotViewAll, setFontSize } as UIPreferences;

return <UIPreferencesContext.Provider value={providedValue}>
{props.children}
Expand Down
7 changes: 4 additions & 3 deletions src/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ body {
}

.providerIcon {
width: 120px;
height: 110px;
min-width: 120px;
max-width: 240px;
min-height: 110px;
margin: 10px;
vertical-align: middle;
}
Expand Down Expand Up @@ -320,7 +321,7 @@ div.tab-body {

.logs-table {
font-family: monospace;
font-size: 11px;
font-size: 70%;
overflow: auto;
max-height: 400px;
border: 1px solid #aaa;
Expand Down
16 changes: 3 additions & 13 deletions src/pages/Preferences.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { UIPreferencesContext } from '../contexts/UIPreferencesContext';
*/
export class Preferences extends Component {
render() {
const { pageSize, theme, bytesStringBase2, preferWebDav, fontSize, setByteStringBase, setTheme, setPreferWebDav, setFontSize} = this.context;
const { pageSize, theme, bytesStringBase2, fontSize, setByteStringBase, setTheme, setFontSize} = this.context;
return <>
<form>
<div className='form-group'>
Expand All @@ -30,23 +30,13 @@ export class Preferences extends Component {
</div>
<br />
<div className='form-group'>
<label className='label-description'>Preferred filesystem for mounts</label>
<select className="form-select form-select-sm" title='Select filesystem type for mounts' id='mountOptionInput' value={preferWebDav} onChange={e => setPreferWebDav(e.target.value)}>
<option value="false">Fuse</option>
<option value="true">WebDav</option>
</select>
<small hmtlfor="mountOptionInput" id='mountOptionHelp' className='form-text text-muted'>Specifies the filesystem that KopiaUI uses to mount snapshots</small>
</div>
<br />
<div className='form-group'>
<label className='label-description'>Appereance</label>
<label className='label-description'>Appearance</label>
<select className="form-select form-select-sm" title='Select font size' id='fontSizeInput' value={fontSize} onChange={e => setFontSize(e.target.value)}>
<option value="fs-6">small</option>
<option value="fs-5">medium</option>
<option value="fs-4">large</option>
<option value="fs-3">larger</option>
</select>
<small hmtlfor="fontSizeInput" id='fontSizeHelp' className='form-text text-muted'>Specifies the font size</small>
<small hmtlfor="fontSizeInput" id='fontSizeHelp' className='form-text text-muted'>Specifies the appearance of the user interface</small>
</div>
<br />
<div className='form-group'>
Expand Down

0 comments on commit 8b453ef

Please sign in to comment.