-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: evol/drawer
Are you sure you want to change the base?
Evol/log api #6
Changes from 28 commits
1364929
4c8c494
f7507c6
2623ae9
d0bd4b1
8d96127
b22f0aa
4259ac3
467076b
652cd0f
4b02b09
454faad
bb4153d
347167b
5c6eed1
86bd602
dc83335
24d5896
b1a27df
fb9e326
3170d3e
c874a49
568b433
e85c71a
5abaf91
c2be5ea
582811b
1f5a056
1919d58
4e81d25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@forward 'login'; | ||
@forward 'log-api'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@use 'assets/scss/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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ça doit dépendre de la taille de la police je pense |
||
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; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -83,7 +84,8 @@ | |
"eslint": "eslint src --ext .ts,.tsx", | ||
"typescript": "tsc --project tsconfig.json --noEmit", | ||
"test": "jest --config jest.config.js", | ||
"coverage": "jest --config jest.config.js --coverage --watchAll=false" | ||
"coverage": "jest --config jest.config.js --coverage --watchAll=false", | ||
"lint": "yarn typescript && yarn eslint" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const HOME = '/home'; | ||
export const USERS = '/users'; | ||
export const LOG_API = '/log-api'; | ||
|
||
export const LOGIN = '/login'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -56,6 +56,19 @@ export default function Navigation() { | |
</NestedListItem> | ||
) | ||
} | ||
{ | ||
sessionService.hasPermission(Permission.MANAGE_SYSTEM) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. La permission c'est pas plutôt MANAGE_API_LOGS ? Ou les deux ? |
||
&& ( | ||
<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> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Dayjs } from 'dayjs'; | ||
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: Dayjs | null) => { | ||
field.onChange(value); | ||
if (value && 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,94 @@ | ||
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, | ||
locale, | ||
onDateChange, | ||
showTodayButton, | ||
disableFuture, | ||
}: InputDateRangeProps, | ||
) { | ||
const fieldId: string = (useNameAsId ? name : (id ?? name)) || ''; | ||
|
||
const { field } = useController({ | ||
name: fieldId, | ||
control, | ||
rules, | ||
defaultValue: defaultValue || [], | ||
}); | ||
|
||
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} | ||
/> | ||
<Icon>arrow_forward</Icon> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} | ||
/> | ||
</> | ||
)} | ||
/> | ||
</LocalizationProvider> | ||
); | ||
} | ||
|
||
export default (InputDateRangePicker); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On pourrait reprendre les couleurs qu'on a déjà non ? Et limite eclaircir ou foncer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faudrait aussi déclarer les variable dans le scope de log api, sinon elles sont globales