Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
Ecolyo
Commits
a832ff5d
Commit
a832ff5d
authored
2 years ago
by
Rémi PAILHAREY
Browse files
Options
Downloads
Patches
Plain Diff
feat(export): added max power
parent
23934529
No related branches found
No related tags found
1 merge request
!916
feat(export): include max power
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Export/exportLoadingModal.tsx
+40
-11
40 additions, 11 deletions
src/components/Export/exportLoadingModal.tsx
src/locales/fr.json
+1
-0
1 addition, 0 deletions
src/locales/fr.json
with
41 additions
and
11 deletions
src/components/Export/exportLoadingModal.tsx
+
40
−
11
View file @
a832ff5d
...
...
@@ -11,6 +11,7 @@ import * as FileSaver from 'file-saver'
import
{
Datachart
,
TimePeriod
}
from
'
models
'
import
React
,
{
useCallback
,
useEffect
}
from
'
react
'
import
ConsumptionDataManager
from
'
services/consumption.service
'
import
EnedisMonthlyAnalysisDataService
from
'
services/enedisMonthlyAnalysisData.service
'
import
*
as
XLSX
from
'
xlsx
'
import
'
./exportLoadingModal.scss
'
...
...
@@ -21,6 +22,15 @@ interface ExportLoadingModalProps {
selectedFluids
:
FluidType
[]
}
interface
ExportDataSheet
{
fluidName
:
string
data
:
ExportDataRow
[]
}
interface
ExportDataRow
{
[
key
:
string
]:
string
|
number
}
const
ExportLoadingModal
:
React
.
FC
<
ExportLoadingModalProps
>
=
({
open
,
handleCloseClick
,
...
...
@@ -34,7 +44,10 @@ const ExportLoadingModal: React.FC<ExportLoadingModalProps> = ({
'
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8
'
const
fileExtension
=
'
.xlsx
'
const
exportToXlsx
=
(
exportDataSheets
:
any
,
fileName
:
string
)
=>
{
const
exportToXlsx
=
(
exportDataSheets
:
ExportDataSheet
[],
fileName
:
string
)
=>
{
const
wb
=
XLSX
.
utils
.
book_new
()
for
(
const
dataSheet
of
exportDataSheets
)
{
const
ws
=
XLSX
.
utils
.
json_to_sheet
(
dataSheet
.
data
)
...
...
@@ -46,7 +59,7 @@ const ExportLoadingModal: React.FC<ExportLoadingModalProps> = ({
}
const
getExportDataFluid
=
useCallback
(
async
(
fluidType
:
FluidType
):
Promise
<
any
>
=>
{
async
(
fluidType
:
FluidType
):
Promise
<
ExportDataSheet
|
null
>
=>
{
const
consumptionService
=
new
ConsumptionDataManager
(
client
)
const
firstDataDate
=
await
consumptionService
.
fetchAllFirstDateData
(
[
fluidType
],
...
...
@@ -74,15 +87,14 @@ const ExportLoadingModal: React.FC<ExportLoadingModalProps> = ({
)
if
(
dataLoad
?.
actualData
)
{
const
exportDataFluid
:
any
=
{}
exportDataFluid
.
fluidName
=
t
(
'
FLUID.
'
+
FluidType
[
fluidType
]
+
'
.LABEL
'
)
exportDataFluid
.
data
=
[]
const
exportDataSheet
:
ExportDataSheet
=
{
fluidName
:
t
(
'
FLUID.
'
+
FluidType
[
fluidType
]
+
'
.LABEL
'
),
data
:
[],
}
for
(
const
data
of
dataLoad
.
actualData
)
{
if
(
data
.
value
!=
-
1
)
{
const
dataRow
:
any
=
{}
const
dataRow
:
ExportDataRow
=
{}
dataRow
[
t
(
'
export.month
'
)]
=
data
.
date
.
month
.
toString
()
.
padStart
(
2
,
'
0
'
)
...
...
@@ -92,10 +104,27 @@ const ExportLoadingModal: React.FC<ExportLoadingModalProps> = ({
'
FLUID.
'
+
FluidType
[
fluidType
]
+
'
.UNIT
'
)}
)`
]
=
data
.
value
exportDataFluid
.
data
.
push
(
dataRow
)
if
(
fluidType
===
FluidType
.
ELECTRICITY
)
{
const
emas
=
new
EnedisMonthlyAnalysisDataService
(
client
)
const
maxPowerEntities
=
await
emas
.
getMaxPowerByDate
(
data
.
date
.
year
,
data
.
date
.
month
)
if
(
maxPowerEntities
)
{
const
maxLoad
=
maxPowerEntities
.
reduce
((
max
,
entity
)
=>
{
if
(
entity
.
load
>
max
)
{
return
entity
.
load
}
return
max
},
0
)
dataRow
[
t
(
'
export.maxpower
'
)]
=
maxLoad
}
}
exportDataSheet
.
data
.
push
(
dataRow
)
}
}
return
exportDataFluid
console
.
log
(
exportDataSheet
)
return
exportDataSheet
}
return
null
},
...
...
@@ -108,7 +137,7 @@ const ExportLoadingModal: React.FC<ExportLoadingModalProps> = ({
async
function
exportData
():
Promise
<
void
>
{
try
{
const
exportDataSheets
:
any
[]
=
[]
const
exportDataSheets
:
ExportDataSheet
[]
=
[]
for
(
const
fluidType
of
selectedFluids
)
{
const
exportDataFluid
=
await
getExportDataFluid
(
fluidType
)
if
(
exportDataFluid
)
exportDataSheets
.
push
(
exportDataFluid
)
...
...
This diff is collapsed.
Click to expand it.
src/locales/fr.json
+
1
−
0
View file @
a832ff5d
...
...
@@ -1178,6 +1178,7 @@
"month"
:
"Mois"
,
"year"
:
"Année"
,
"consumption"
:
"Consommation"
,
"maxpower"
:
"Puissance max (kVA)"
,
"button_close"
:
"Fermer la fenêtre"
,
"modal_start"
:
{
"accessibility_title"
:
"Commencer le téléchargement"
,
...
...
This diff is collapsed.
Click to expand it.
Rémi PAILHAREY
@rpailharey
mentioned in commit
359c788c
·
2 years ago
mentioned in commit
359c788c
mentioned in commit 359c788ceb551ab60a2c595540fdc1d545f09dd6
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment