forked from Coreoz/create-plume-react-project
-
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
Open
lucas-amiaud
wants to merge
30
commits into
evol/drawer
Choose a base branch
from
evol/log-api
base: evol/drawer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Evol/log api #6
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 4c8c494
start implem log api
lucas-amiaud f7507c6
add route for log API
lucas-amiaud 2623ae9
implem log API filters
lucas-amiaud d0bd4b1
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 8d96127
add log api sorting
lucas-amiaud b22f0aa
add log api js filter
lucas-amiaud 4259ac3
merge evols
lucas-amiaud 467076b
add message and titles
lucas-amiaud 652cd0f
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 4b02b09
merge new libraries
lucas-amiaud 454faad
wip add radio buttons
lucas-amiaud bb4153d
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 347167b
clean single choice filter menu
lucas-amiaud 5c6eed1
clean log API
lucas-amiaud 86bd602
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud dc83335
clean log API
lucas-amiaud 24d5896
add date pickers
lucas-amiaud b1a27df
fix style pickers
lucas-amiaud fb9e326
esling fixes
lucas-amiaud 3170d3e
merge drawer
lucas-amiaud c874a49
merge drawer branch
lucas-amiaud 568b433
add readonly props on inputs
lucas-amiaud e85c71a
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 5abaf91
merge evol/drawer
lucas-amiaud c2be5ea
eslint fix
lucas-amiaud 582811b
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 1f5a056
eslint fix
lucas-amiaud 1919d58
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud 4e81d25
Merge branch 'evol/drawer' into evol/log-api
lucas-amiaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import 'user-tile'; | ||
@import 'log-api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
templates/admin/src/components/theme/form/fields/InputDatePicker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
104 changes: 104 additions & 0 deletions
104
templates/admin/src/components/theme/form/fields/InputDateRangePicker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
<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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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';
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.
pour l'instant on utilise pas icons-material non