Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evol/log api #6

Open
wants to merge 30 commits into
base: evol/drawer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1364929
start implem log api
lucas-amiaud Feb 18, 2022
4c8c494
start implem log api
lucas-amiaud Feb 18, 2022
f7507c6
add route for log API
lucas-amiaud Feb 18, 2022
2623ae9
implem log API filters
lucas-amiaud Feb 18, 2022
d0bd4b1
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Feb 18, 2022
8d96127
add log api sorting
lucas-amiaud Feb 18, 2022
b22f0aa
add log api js filter
lucas-amiaud Feb 21, 2022
4259ac3
merge evols
lucas-amiaud Apr 13, 2022
467076b
add message and titles
lucas-amiaud Apr 13, 2022
652cd0f
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Apr 20, 2022
4b02b09
merge new libraries
lucas-amiaud Apr 20, 2022
454faad
wip add radio buttons
lucas-amiaud Apr 27, 2022
bb4153d
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Apr 27, 2022
347167b
clean single choice filter menu
lucas-amiaud Apr 27, 2022
5c6eed1
clean log API
lucas-amiaud Apr 29, 2022
86bd602
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Apr 29, 2022
dc83335
clean log API
lucas-amiaud Apr 29, 2022
24d5896
add date pickers
lucas-amiaud May 3, 2022
b1a27df
fix style pickers
lucas-amiaud May 3, 2022
fb9e326
esling fixes
lucas-amiaud May 3, 2022
3170d3e
merge drawer
lucas-amiaud May 3, 2022
c874a49
merge drawer branch
lucas-amiaud May 25, 2022
568b433
add readonly props on inputs
lucas-amiaud May 25, 2022
e85c71a
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Jun 9, 2022
5abaf91
merge evol/drawer
lucas-amiaud Jun 14, 2022
c2be5ea
eslint fix
lucas-amiaud Jun 14, 2022
582811b
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Jun 14, 2022
1f5a056
eslint fix
lucas-amiaud Jun 14, 2022
1919d58
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Oct 17, 2023
4e81d25
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/admin/assets/scss/components/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'user-tile';
@import 'log-api';
48 changes: 48 additions & 0 deletions templates/admin/assets/scss/components/_log-api.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@use '../variables' as *;

$log-api-ok: #49cc90;
$log-api-warning: #fca130;
$log-api-error: #f93e3e;

.log-api-tile {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
cursor: pointer;

* {
flex-shrink: 0;
}

.log-api-data {
height: 100%;
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
font-size: $font-size-normal;

.data {
display: flex;
width: 15%;
height: 40px;
flex-direction: column;
align-items: flex-start;
justify-content: center;
padding: 0 $spacer-2;
margin-left: $spacer-3;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;

&--large {
width: 40%;
}
&--small {
width: 30px;
}
}
}
}
1 change: 1 addition & 0 deletions templates/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@fontsource/roboto": "^4.5.0",
"@mui/lab": "5.0.0-alpha.49",
"@mui/material": "^5.0.6",
"@mui/styles": "^5.0.2",
"@mui/system": "^5.0.6",
Expand Down
1 change: 1 addition & 0 deletions templates/admin/src/components/Routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const HOME = '/home';
export const USERS = '/users';
export const LOG_API = '/log-api';

export const LOGIN = '/login'
export const FORGOT_PASSWORD = '/forgot-password';
15 changes: 14 additions & 1 deletion templates/admin/src/components/layout/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MessageService from '../../i18n/messages/MessageService';
import useToggle from '../../lib/react-hook-toggle/ReactHookToggle';
import Permission from '../../services/session/Permission';
import SessionService from '../../services/session/SessionService';
import { HOME, USERS } from '../Routes';
import { HOME, LOG_API, USERS } from '../Routes';
import LinkListItem from './LinkListItem';
import NestedListItem from './NestedListItem';
import plumeLogo from "../../../assets/icons/plume_logo.png";
Expand Down Expand Up @@ -56,6 +56,19 @@ export default function Navigation() {
</NestedListItem>
)
}
{
sessionService.hasPermission(Permission.MANAGE_SYSTEM)
&& (
<NestedListItem icon="settings" label={messages.nav.settings} drawerOpen={isDrawerOpened}>
<LinkListItem
icon="http"
route={LOG_API}
label={messages.nav.log_api}
drawerOpen={isDrawerOpened}
/>
</NestedListItem>
)
}
</List>
</nav>
);
Expand Down
7 changes: 6 additions & 1 deletion templates/admin/src/components/layout/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ import {
Redirect,
} from 'react-router-dom';
import { getGlobalInstance } from 'plume-ts-di';
import LogApi from '../../lib/plume-admin-log-api/pages/LogApi';
import Home from '../pages/Home';
import Users from '../../lib/plume-admin-users/pages/Users';
import PermissionRoute from '../theme/routes/PermissionRoute';
import Permission from '../../services/session/Permission';
import { HOME, USERS } from '../Routes';
import { HOME, LOG_API, USERS } from '../Routes';

export default function Router() {
const users = getGlobalInstance(Users);
const logApi = getGlobalInstance(LogApi);

return (
<Switch>
<PermissionRoute permission={Permission.MANAGE_USERS} path={USERS}>
<users.render />
</PermissionRoute>
<PermissionRoute permission={Permission.MANAGE_API_LOGS} path={LOG_API}>
<logApi.render />
</PermissionRoute>
<Route path={HOME}>
<Home />
</Route>
Expand Down
16 changes: 15 additions & 1 deletion templates/admin/src/components/theme/AdminTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import PlumeAdminTheme from '../../lib/plume-admin-theme/PlumeAdminTheme';
import { ActionButton, ActionLink, ActionsContainer } from './action/Actions';
import Drawer from './drawer/Drawer';
import UncontrolledDrawer from './drawer/UncontrolledDrawer';
import InputDatePicker from './form/fields/InputDatePicker';
import InputDateRangePicker from './form/fields/InputDateRangePicker';
import InputDateTimePicker from './form/fields/InputDateTimePicker';
import InputSelect from './form/fields/InputSelect';
import InputText from './form/fields/InputText';
import FormField from './form/FormField';
import { PageBloc, PageBlocColumn } from './layout/PageBloc';
import PageTitle from './layout/PageTitle';
import { Panel, PanelSeparator } from './layout/Panel';
import StatusDot from './layout/StatusDot';
import { ListElements, ListSingleElement } from './list/ListElements';
import MultipleChoiceFilterMenu, { MultipleChoiceObjectFilterMenu } from './list/filter/MultipleChoiceFilterMenu';
import SingleChoiceFilterMenu, { SingleObjectChoiceFilterMenu, } from './list/filter/SingleChoiceFilterMenu';
import { ListElements, ListSingleElement } from './list/ListElements';
import ListHeader from './list/ListHeader';
import SearchBar from './list/search/SearchBar';
import SortMenu from './list/sort/SortMenu';
Expand Down Expand Up @@ -41,6 +45,10 @@ export default class AdminTheme implements PlumeAdminTheme {

multipleChoiceObjectFilterMenu = MultipleChoiceObjectFilterMenu;

singleChoiceFilterMenu = SingleChoiceFilterMenu;

singleChoiceObjectFilterMenu = SingleObjectChoiceFilterMenu;

listHeader = ListHeader;

listElements = ListElements;
Expand All @@ -62,4 +70,10 @@ export default class AdminTheme implements PlumeAdminTheme {
inputText = InputText;

inputSelect = InputSelect;

inputDate = InputDatePicker;

inputDateTime = InputDateTimePicker;

inputDateRange = InputDateRangePicker;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import { DatePicker, LocalizationProvider } from '@mui/lab';
import DateAdapter from '@mui/lab/AdapterDayjs';
import { MuiTextFieldProps } from '@mui/lab/internal/pickers/PureDateInput';
import { TextField } from '@mui/material';
import { useController } from 'react-hook-form';
import en from '../../../../i18n/translations/en';
import fr from '../../../../i18n/translations/fr';
import { Translations } from '../../../../i18n/translations/Translations';
import {
InputDateProps
} from '../../../../lib/plume-admin-theme/form/FormInputProps';

function InputDatePicker(
{
placeholder,
label,
name,
id,
useNameAsId,
control,
rules,
disabled,
defaultValue,
onDateChange,
autoComplete,
showTodayButton,
disableFuture,
disableOpenPicker,
locale,
}: InputDateProps) {
const fieldId: string = (useNameAsId ? name : (id ?? name)) || '';

const localeMap = {
en,
fr,
};

const { field } = useController({
name: fieldId,
control,
rules,
defaultValue: defaultValue || null,
});

const onChangeCombined = (value: any) => {
field.onChange(value);
if (onDateChange) {
onDateChange(value);
}
};

const currentLocale: Translations = localeMap[locale as 'fr' | 'en'];

return (
<LocalizationProvider dateAdapter={DateAdapter} locale={currentLocale}>
<DatePicker
onChange={onChangeCombined}
value={field.value}
disableOpenPicker={disableOpenPicker}
showTodayButton={showTodayButton ?? false}
disableFuture={disableFuture ?? false}
inputFormat={currentLocale.format.date}
mask={currentLocale.format.date_mask}
renderInput={(params: MuiTextFieldProps) => (
<TextField
// eslint-disable-next-line react/jsx-props-no-spreading
{...params}
ref={params.inputRef}
inputRef={field.ref}
id={fieldId}
name={name}
label={label}
inputProps={{
...params.inputProps,
placeholder: placeholder || currentLocale.format.date,
}}
autoComplete={autoComplete}
disabled={disabled ?? false}
onBlur={field.onBlur}
required
/>
)}
/>
</LocalizationProvider>
);
}

export default (InputDatePicker);
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { DateRangePicker, LocalizationProvider } from '@mui/lab';
import DateAdapter from '@mui/lab/AdapterDayjs';
import { DateRange } from '@mui/lab/DateRangePicker/RangeTypes';
import { MuiTextFieldProps } from '@mui/lab/internal/pickers/PureDateInput';
import { Icon, TextField } from '@mui/material';
import { Dayjs } from 'dayjs';
import React from 'react';
import { useController } from 'react-hook-form';
import en from '../../../../i18n/translations/en';
import fr from '../../../../i18n/translations/fr';
import { Translations } from '../../../../i18n/translations/Translations';
import { InputDateRangeProps } from '../../../../lib/plume-admin-theme/form/FormInputProps';

function InputDateRangePicker(
{
name,
id,
useNameAsId,
control,
rules,
disabled,
defaultValue,
onBlur,
locale,
onDateChange,
showTodayButton,
disableFuture,
}: InputDateRangeProps
) {
const fieldId: string = (useNameAsId ? name : (id ?? name)) || '';

const { field } = useController({
name: fieldId,
control,
rules,
defaultValue: defaultValue || [],
});

const onBlurCombined = (value: any) => {
field.onBlur();
if (onBlur) {
onBlur(value);
}
};

const onCustomChange = (val: DateRange<Dayjs>, keyboardInputValue?: string) => {
// Update the date when it has been updated using the datepicker and not the text fields
if (!keyboardInputValue) {
field.onChange(val);
if (onDateChange) {
onDateChange(val);
}
}
};

const localeMap = {
en,
fr,
};

const currentLocale: Translations = localeMap[locale as 'fr' | 'en'];

return (
<LocalizationProvider dateAdapter={DateAdapter} locale={currentLocale}>
<DateRangePicker
startText="Debut"
endText="Fin"
value={field.value}
mask={currentLocale.format.date_mask}
inputFormat={currentLocale.format.date}
showTodayButton={showTodayButton ?? false}
disableFuture={disableFuture ?? false}
onChange={(date: DateRange<Dayjs>, keyboardInputValue?: string) => {
onCustomChange(date, keyboardInputValue);
}}
renderInput={(startProps: MuiTextFieldProps, endProps: MuiTextFieldProps) => (
<>
<TextField
// eslint-disable-next-line react/jsx-props-no-spreading
{...startProps}
type="date"
name={name}
id={fieldId}
disabled={disabled ?? false}
onBlur={onBlurCombined}
/>
<Icon>arrow_forward</Icon>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est une icône material ça ? est-ce qu'il vaut pas mieux utiliser un composant qui contient l'icône spécifique plutôt qu'utiliser le composant Icon, puis spécifier dedans le type d'icone ?

import ArrowForwardIcon from '@mui/icons-material/ArrowForward';

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pour l'instant on utilise pas icons-material non

<TextField
// eslint-disable-next-line react/jsx-props-no-spreading
{...endProps}
type="date"
name={name}
id={fieldId}
disabled={disabled ?? false}
onBlur={onBlurCombined}
/>
</>
)}
/>
</LocalizationProvider>
);
}

export default (InputDateRangePicker);
Loading