1
|
|
|
import React, { Fragment, useEffect, useState } from 'react'; |
2
|
|
|
import { |
3
|
|
|
Breadcrumb, |
4
|
|
|
BreadcrumbItem, |
5
|
|
|
Row, |
6
|
|
|
Col, |
7
|
|
|
Card, |
8
|
|
|
CardBody, |
9
|
|
|
Button, |
10
|
|
|
ButtonGroup, |
11
|
|
|
Form, |
12
|
|
|
FormGroup, |
13
|
|
|
Input, |
14
|
|
|
Label, |
15
|
|
|
CustomInput, |
16
|
|
|
Spinner |
17
|
|
|
} from 'reactstrap'; |
18
|
|
|
import CountUp from 'react-countup'; |
19
|
|
|
import Datetime from 'react-datetime'; |
20
|
|
|
import moment from 'moment'; |
21
|
|
|
import loadable from '@loadable/component'; |
22
|
|
|
import Cascader from 'rc-cascader'; |
23
|
|
|
import CardSummary from '../common/CardSummary'; |
24
|
|
|
import LineChart from '../common/LineChart'; |
25
|
|
|
import { getCookieValue, createCookie } from '../../../helpers/utils'; |
26
|
|
|
import withRedirect from '../../../hoc/withRedirect'; |
27
|
|
|
import { withTranslation } from 'react-i18next'; |
28
|
|
|
import { toast } from 'react-toastify'; |
29
|
|
|
import ButtonIcon from '../../common/ButtonIcon'; |
30
|
|
|
import { APIBaseURL } from '../../../config'; |
31
|
|
|
import { periodTypeOptions } from '../common/PeriodTypeOptions'; |
32
|
|
|
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions'; |
33
|
|
|
|
34
|
|
|
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable')); |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
const SpaceLoad = ({ setRedirect, setRedirectUrl, t }) => { |
38
|
|
|
let current_moment = moment(); |
39
|
|
|
useEffect(() => { |
40
|
|
|
let is_logged_in = getCookieValue('is_logged_in'); |
41
|
|
|
let user_name = getCookieValue('user_name'); |
42
|
|
|
let user_display_name = getCookieValue('user_display_name'); |
43
|
|
|
let user_uuid = getCookieValue('user_uuid'); |
44
|
|
|
let token = getCookieValue('token'); |
45
|
|
|
if (is_logged_in === null || !is_logged_in) { |
46
|
|
|
setRedirectUrl(`/authentication/basic/login`); |
47
|
|
|
setRedirect(true); |
48
|
|
|
} else { |
49
|
|
|
//update expires time of cookies |
50
|
|
|
createCookie('is_logged_in', true, 1000 * 60 * 60 * 8); |
51
|
|
|
createCookie('user_name', user_name, 1000 * 60 * 60 * 8); |
52
|
|
|
createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8); |
53
|
|
|
createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8); |
54
|
|
|
createCookie('token', token, 1000 * 60 * 60 * 8); |
55
|
|
|
} |
56
|
|
|
}); |
57
|
|
|
// State |
58
|
|
|
// Query Parameters |
59
|
|
|
const [selectedSpaceName, setSelectedSpaceName] = useState(undefined); |
60
|
|
|
const [selectedSpaceID, setSelectedSpaceID] = useState(undefined); |
61
|
|
|
const [comparisonType, setComparisonType] = useState('month-on-month'); |
62
|
|
|
const [periodType, setPeriodType] = useState('daily'); |
63
|
|
|
const [basePeriodBeginsDatetime, setBasePeriodBeginsDatetime] = useState(current_moment.clone().subtract(1, 'months').startOf('month')); |
64
|
|
|
const [basePeriodEndsDatetime, setBasePeriodEndsDatetime] = useState(current_moment.clone().subtract(1, 'months')); |
65
|
|
|
const [basePeriodBeginsDatetimeDisabled, setBasePeriodBeginsDatetimeDisabled] = useState(true); |
66
|
|
|
const [basePeriodEndsDatetimeDisabled, setBasePeriodEndsDatetimeDisabled] = useState(true); |
67
|
|
|
const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month')); |
68
|
|
|
const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment); |
69
|
|
|
const [cascaderOptions, setCascaderOptions] = useState(undefined); |
70
|
|
|
|
71
|
|
|
// buttons |
72
|
|
|
const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true); |
73
|
|
|
const [spinnerHidden, setSpinnerHidden] = useState(true); |
74
|
|
|
const [exportButtonHidden, setExportButtonHidden] = useState(true); |
75
|
|
|
|
76
|
|
|
//Results |
77
|
|
|
const [cardSummaryList, setCardSummaryList] = useState([]); |
78
|
|
|
const [spaceLineChartLabels, setSpaceLineChartLabels] = useState([]); |
79
|
|
|
const [spaceLineChartData, setSpaceLineChartData] = useState({}); |
80
|
|
|
const [spaceLineChartOptions, setSpaceLineChartOptions] = useState([]); |
81
|
|
|
|
82
|
|
|
const [parameterLineChartLabels, setParameterLineChartLabels] = useState([]); |
83
|
|
|
const [parameterLineChartData, setParameterLineChartData] = useState({}); |
84
|
|
|
const [parameterLineChartOptions, setParameterLineChartOptions] = useState([]); |
85
|
|
|
|
86
|
|
|
const [detailedDataTableData, setDetailedDataTableData] = useState([]); |
87
|
|
|
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]); |
88
|
|
|
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined); |
89
|
|
|
|
90
|
|
|
useEffect(() => { |
91
|
|
|
let isResponseOK = false; |
92
|
|
|
fetch(APIBaseURL + '/spaces/tree', { |
93
|
|
|
method: 'GET', |
94
|
|
|
headers: { |
95
|
|
|
"Content-type": "application/json", |
96
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
97
|
|
|
"Token": getCookieValue('token') |
98
|
|
|
}, |
99
|
|
|
body: null, |
100
|
|
|
|
101
|
|
|
}).then(response => { |
102
|
|
|
console.log(response); |
103
|
|
|
if (response.ok) { |
104
|
|
|
isResponseOK = true; |
105
|
|
|
// enable submit button |
106
|
|
|
setSubmitButtonDisabled(false); |
107
|
|
|
} |
108
|
|
|
return response.json(); |
109
|
|
|
}).then(json => { |
110
|
|
|
console.log(json); |
111
|
|
|
if (isResponseOK) { |
112
|
|
|
// rename keys |
113
|
|
|
json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":')); |
114
|
|
|
setCascaderOptions(json); |
115
|
|
|
setSelectedSpaceName([json[0]].map(o => o.label)); |
116
|
|
|
setSelectedSpaceID([json[0]].map(o => o.value)); |
117
|
|
|
} else { |
118
|
|
|
toast.error(json.description); |
119
|
|
|
} |
120
|
|
|
}).catch(err => { |
121
|
|
|
console.log(err); |
122
|
|
|
}); |
123
|
|
|
|
124
|
|
|
}, []); |
125
|
|
|
const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0'; |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
let onSpaceCascaderChange = (value, selectedOptions) => { |
129
|
|
|
console.log(value, selectedOptions); |
130
|
|
|
setSelectedSpaceName(selectedOptions.map(o => o.label).join('/')); |
131
|
|
|
setSelectedSpaceID(value[value.length - 1]); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
let onComparisonTypeChange = ({ target }) => { |
136
|
|
|
console.log(target.value); |
137
|
|
|
setComparisonType(target.value); |
138
|
|
|
if (target.value === 'year-over-year') { |
139
|
|
|
setBasePeriodBeginsDatetimeDisabled(true); |
140
|
|
|
setBasePeriodEndsDatetimeDisabled(true); |
141
|
|
|
setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'years')); |
142
|
|
|
setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'years')); |
143
|
|
|
} else if (target.value === 'month-on-month') { |
144
|
|
|
setBasePeriodBeginsDatetimeDisabled(true); |
145
|
|
|
setBasePeriodEndsDatetimeDisabled(true); |
146
|
|
|
setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'months')); |
147
|
|
|
setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'months')); |
148
|
|
|
} else if (target.value === 'free-comparison') { |
149
|
|
|
setBasePeriodBeginsDatetimeDisabled(false); |
150
|
|
|
setBasePeriodEndsDatetimeDisabled(false); |
151
|
|
|
} else if (target.value === 'none-comparison') { |
152
|
|
|
setBasePeriodBeginsDatetime(undefined); |
153
|
|
|
setBasePeriodEndsDatetime(undefined); |
154
|
|
|
setBasePeriodBeginsDatetimeDisabled(true); |
155
|
|
|
setBasePeriodEndsDatetimeDisabled(true); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
let onBasePeriodBeginsDatetimeChange = (newDateTime) => { |
160
|
|
|
setBasePeriodBeginsDatetime(newDateTime); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
let onBasePeriodEndsDatetimeChange = (newDateTime) => { |
164
|
|
|
setBasePeriodEndsDatetime(newDateTime); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
let onReportingPeriodBeginsDatetimeChange = (newDateTime) => { |
168
|
|
|
setReportingPeriodBeginsDatetime(newDateTime); |
169
|
|
|
if (comparisonType === 'year-over-year') { |
170
|
|
|
setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'years')); |
171
|
|
|
} else if (comparisonType === 'month-on-month') { |
172
|
|
|
setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'months')); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
let onReportingPeriodEndsDatetimeChange = (newDateTime) => { |
177
|
|
|
setReportingPeriodEndsDatetime(newDateTime); |
178
|
|
|
if (comparisonType === 'year-over-year') { |
179
|
|
|
setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'years')); |
180
|
|
|
} else if (comparisonType === 'month-on-month') { |
181
|
|
|
setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'months')); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
var getValidBasePeriodBeginsDatetimes = function (currentDate) { |
186
|
|
|
return currentDate.isBefore(moment(basePeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
var getValidBasePeriodEndsDatetimes = function (currentDate) { |
190
|
|
|
return currentDate.isAfter(moment(basePeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
var getValidReportingPeriodBeginsDatetimes = function (currentDate) { |
194
|
|
|
return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
var getValidReportingPeriodEndsDatetimes = function (currentDate) { |
198
|
|
|
return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a')); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
// Handler |
202
|
|
|
const handleSubmit = e => { |
203
|
|
|
e.preventDefault(); |
204
|
|
|
console.log('handleSubmit'); |
205
|
|
|
console.log(selectedSpaceID); |
206
|
|
|
console.log(comparisonType); |
207
|
|
|
console.log(periodType); |
208
|
|
|
console.log(basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined); |
209
|
|
|
console.log(basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined); |
210
|
|
|
console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss')); |
211
|
|
|
console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss')); |
212
|
|
|
|
213
|
|
|
// disable submit button |
214
|
|
|
setSubmitButtonDisabled(true); |
215
|
|
|
// show spinner |
216
|
|
|
setSpinnerHidden(false); |
217
|
|
|
// hide export buttion |
218
|
|
|
setExportButtonHidden(true) |
219
|
|
|
|
220
|
|
|
// Reinitialize tables |
221
|
|
|
setDetailedDataTableData([]); |
222
|
|
|
|
223
|
|
|
let isResponseOK = false; |
224
|
|
|
fetch(APIBaseURL + '/reports/spaceload?' + |
225
|
|
|
'spaceid=' + selectedSpaceID + |
226
|
|
|
'&periodtype=' + periodType + |
227
|
|
|
'&baseperiodstartdatetime=' + (basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') + |
228
|
|
|
'&baseperiodenddatetime=' + (basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') + |
229
|
|
|
'&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') + |
230
|
|
|
'&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), { |
231
|
|
|
method: 'GET', |
232
|
|
|
headers: { |
233
|
|
|
"Content-type": "application/json", |
234
|
|
|
"User-UUID": getCookieValue('user_uuid'), |
235
|
|
|
"Token": getCookieValue('token') |
236
|
|
|
}, |
237
|
|
|
body: null, |
238
|
|
|
|
239
|
|
|
}).then(response => { |
240
|
|
|
if (response.ok) { |
241
|
|
|
isResponseOK = true; |
242
|
|
|
} |
243
|
|
|
return response.json(); |
244
|
|
|
}).then(json => { |
245
|
|
|
if (isResponseOK) { |
246
|
|
|
console.log(json) |
247
|
|
|
|
248
|
|
|
let cardSummaryArray = [] |
249
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
250
|
|
|
let cardSummaryItem = {} |
251
|
|
|
cardSummaryItem['name'] = json['reporting_period']['names'][index]; |
252
|
|
|
cardSummaryItem['unit'] = json['reporting_period']['units'][index]; |
253
|
|
|
cardSummaryItem['average'] = json['reporting_period']['averages'][index]; |
254
|
|
|
cardSummaryItem['average_increment_rate'] = parseFloat(json['reporting_period']['averages_increment_rate'][index] * 100).toFixed(2) + "%"; |
255
|
|
|
cardSummaryItem['average_per_unit_area'] = json['reporting_period']['averages_per_unit_area'][index]; |
256
|
|
|
cardSummaryItem['maximum'] = json['reporting_period']['maximums'][index]; |
257
|
|
|
cardSummaryItem['maximum_increment_rate'] = parseFloat(json['reporting_period']['maximums_increment_rate'][index] * 100).toFixed(2) + "%"; |
258
|
|
|
cardSummaryItem['maximum_per_unit_area'] = json['reporting_period']['maximums_per_unit_area'][index]; |
259
|
|
|
cardSummaryItem['factor'] = json['reporting_period']['factors'][index]; |
260
|
|
|
cardSummaryItem['factor_increment_rate'] = parseFloat(json['reporting_period']['factors_increment_rate'][index] * 100).toFixed(2) + "%"; |
261
|
|
|
cardSummaryArray.push(cardSummaryItem); |
262
|
|
|
}); |
263
|
|
|
setCardSummaryList(cardSummaryArray); |
264
|
|
|
|
265
|
|
|
let timestamps = {} |
266
|
|
|
json['reporting_period']['timestamps'].forEach((currentValue, index) => { |
267
|
|
|
timestamps['a' + index] = currentValue; |
268
|
|
|
}); |
269
|
|
|
setSpaceLineChartLabels(timestamps); |
270
|
|
|
|
271
|
|
|
let values = {} |
272
|
|
|
json['reporting_period']['sub_maximums'].forEach((currentValue, index) => { |
273
|
|
|
values['a' + index] = currentValue; |
274
|
|
|
}); |
275
|
|
|
setSpaceLineChartData(values); |
276
|
|
|
|
277
|
|
|
let names = Array(); |
278
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
279
|
|
|
let unit = json['reporting_period']['units'][index]; |
280
|
|
|
names.push({ 'value': 'a' + index, 'label': currentValue + ' (' + unit + '/H)'}); |
281
|
|
|
}); |
282
|
|
|
setSpaceLineChartOptions(names); |
283
|
|
|
|
284
|
|
|
timestamps = {} |
285
|
|
|
json['parameters']['timestamps'].forEach((currentValue, index) => { |
286
|
|
|
timestamps['a' + index] = currentValue; |
287
|
|
|
}); |
288
|
|
|
setParameterLineChartLabels(timestamps); |
289
|
|
|
|
290
|
|
|
values = {} |
291
|
|
|
json['parameters']['values'].forEach((currentValue, index) => { |
292
|
|
|
values['a' + index] = currentValue; |
293
|
|
|
}); |
294
|
|
|
setParameterLineChartData(values); |
295
|
|
|
|
296
|
|
|
names = Array(); |
297
|
|
|
json['parameters']['names'].forEach((currentValue, index) => { |
298
|
|
|
if (currentValue.startsWith('TARIFF-')) { |
299
|
|
|
currentValue = t('Tariff') + currentValue.replace('TARIFF-', '-'); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
names.push({ 'value': 'a' + index, 'label': currentValue }); |
303
|
|
|
}); |
304
|
|
|
setParameterLineChartOptions(names); |
305
|
|
|
|
306
|
|
|
let detailed_value_list = []; |
307
|
|
|
if (json['reporting_period']['timestamps'].length > 0) { |
308
|
|
|
json['reporting_period']['timestamps'][0].forEach((currentTimestamp, timestampIndex) => { |
309
|
|
|
let detailed_value = {}; |
310
|
|
|
detailed_value['id'] = timestampIndex; |
311
|
|
|
detailed_value['startdatetime'] = currentTimestamp; |
312
|
|
|
json['reporting_period']['sub_averages'].forEach((currentValue, energyCategoryIndex) => { |
313
|
|
|
if (json['reporting_period']['sub_averages'][energyCategoryIndex][timestampIndex] != null) { |
314
|
|
|
detailed_value['a' + 2 * energyCategoryIndex] = json['reporting_period']['sub_averages'][energyCategoryIndex][timestampIndex].toFixed(2); |
315
|
|
|
} else { |
316
|
|
|
detailed_value['a' + 2 * energyCategoryIndex] = ''; |
317
|
|
|
}; |
318
|
|
|
|
319
|
|
|
if (json['reporting_period']['sub_maximums'][energyCategoryIndex][timestampIndex] != null) { |
320
|
|
|
detailed_value['a' + (2 * energyCategoryIndex + 1)] = json['reporting_period']['sub_maximums'][energyCategoryIndex][timestampIndex].toFixed(2); |
321
|
|
|
} else { |
322
|
|
|
detailed_value['a' + (2 * energyCategoryIndex + 1)] = ''; |
323
|
|
|
}; |
324
|
|
|
}); |
325
|
|
|
detailed_value_list.push(detailed_value); |
326
|
|
|
}); |
327
|
|
|
}; |
328
|
|
|
|
329
|
|
|
setDetailedDataTableData(detailed_value_list); |
330
|
|
|
|
331
|
|
|
let detailed_column_list = []; |
332
|
|
|
detailed_column_list.push({ |
333
|
|
|
dataField: 'startdatetime', |
334
|
|
|
text: t('Datetime'), |
335
|
|
|
sort: true |
336
|
|
|
}) |
337
|
|
|
json['reporting_period']['names'].forEach((currentValue, index) => { |
338
|
|
|
let unit = json['reporting_period']['units'][index]; |
339
|
|
|
detailed_column_list.push({ |
340
|
|
|
dataField: 'a' + 2 * index, |
341
|
|
|
text: currentValue + ' ' + t('Average Load') + ' (' + unit + '/H)', |
342
|
|
|
sort: true |
343
|
|
|
}); |
344
|
|
|
detailed_column_list.push({ |
345
|
|
|
dataField: 'a' + (2 * index + 1), |
346
|
|
|
text: currentValue + ' ' + t('Maximum Load') + ' (' + unit + '/H)', |
347
|
|
|
sort: true |
348
|
|
|
}); |
349
|
|
|
}); |
350
|
|
|
setDetailedDataTableColumns(detailed_column_list); |
351
|
|
|
|
352
|
|
|
setExcelBytesBase64(json['excel_bytes_base64']); |
353
|
|
|
|
354
|
|
|
// enable submit button |
355
|
|
|
setSubmitButtonDisabled(false); |
356
|
|
|
// hide spinner |
357
|
|
|
setSpinnerHidden(true); |
358
|
|
|
// show export buttion |
359
|
|
|
setExportButtonHidden(false) |
360
|
|
|
|
361
|
|
|
|
362
|
|
|
} else { |
363
|
|
|
toast.error(json.description) |
364
|
|
|
} |
365
|
|
|
}).catch(err => { |
366
|
|
|
console.log(err); |
367
|
|
|
}); |
368
|
|
|
}; |
369
|
|
|
|
370
|
|
|
const handleExport = e => { |
371
|
|
|
e.preventDefault(); |
372
|
|
|
const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
373
|
|
|
const fileName = 'spaceload.xlsx' |
374
|
|
|
var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64; |
375
|
|
|
fetch(fileUrl) |
376
|
|
|
.then(response => response.blob()) |
377
|
|
|
.then(blob => { |
378
|
|
|
var link = window.document.createElement("a"); |
379
|
|
|
link.href = window.URL.createObjectURL(blob, { type: mimeType }); |
380
|
|
|
link.download = fileName; |
381
|
|
|
document.body.appendChild(link); |
382
|
|
|
link.click(); |
383
|
|
|
document.body.removeChild(link); |
384
|
|
|
}); |
385
|
|
|
}; |
386
|
|
|
|
387
|
|
|
|
388
|
|
|
|
389
|
|
|
return ( |
390
|
|
|
<Fragment> |
391
|
|
|
<div> |
392
|
|
|
<Breadcrumb> |
393
|
|
|
<BreadcrumbItem>{t('Space Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Load')}</BreadcrumbItem> |
394
|
|
|
</Breadcrumb> |
395
|
|
|
</div> |
396
|
|
|
<Card className="bg-light mb-3"> |
397
|
|
|
<CardBody className="p-3"> |
398
|
|
|
<Form onSubmit={handleSubmit}> |
399
|
|
|
<Row form> |
400
|
|
|
<Col xs="auto"> |
401
|
|
|
<FormGroup className="form-group"> |
402
|
|
|
<Label className={labelClasses} for="space"> |
403
|
|
|
{t('Space')} |
404
|
|
|
</Label> |
405
|
|
|
<br /> |
406
|
|
|
<Cascader options={cascaderOptions} |
407
|
|
|
onChange={onSpaceCascaderChange} |
408
|
|
|
changeOnSelect |
409
|
|
|
expandTrigger="hover"> |
410
|
|
|
<Input value={selectedSpaceName || ''} readOnly /> |
411
|
|
|
</Cascader> |
412
|
|
|
</FormGroup> |
413
|
|
|
</Col> |
414
|
|
|
<Col xs="auto"> |
415
|
|
|
<FormGroup> |
416
|
|
|
<Label className={labelClasses} for="comparisonType"> |
417
|
|
|
{t('Comparison Types')} |
418
|
|
|
</Label> |
419
|
|
|
<CustomInput type="select" id="comparisonType" name="comparisonType" |
420
|
|
|
defaultValue="month-on-month" |
421
|
|
|
onChange={onComparisonTypeChange} |
422
|
|
|
> |
423
|
|
|
{comparisonTypeOptions.map((comparisonType, index) => ( |
424
|
|
|
<option value={comparisonType.value} key={comparisonType.value} > |
425
|
|
|
{t(comparisonType.label)} |
426
|
|
|
</option> |
427
|
|
|
))} |
428
|
|
|
</CustomInput> |
429
|
|
|
</FormGroup> |
430
|
|
|
</Col> |
431
|
|
|
<Col xs="auto"> |
432
|
|
|
<FormGroup> |
433
|
|
|
<Label className={labelClasses} for="periodType"> |
434
|
|
|
{t('Period Types')} |
435
|
|
|
</Label> |
436
|
|
|
<CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)} |
437
|
|
|
> |
438
|
|
|
{periodTypeOptions.map((periodType, index) => ( |
439
|
|
|
<option value={periodType.value} key={periodType.value} > |
440
|
|
|
{t(periodType.label)} |
441
|
|
|
</option> |
442
|
|
|
))} |
443
|
|
|
</CustomInput> |
444
|
|
|
</FormGroup> |
445
|
|
|
</Col> |
446
|
|
|
<Col xs="auto"> |
447
|
|
|
<FormGroup className="form-group"> |
448
|
|
|
<Label className={labelClasses} for="basePeriodBeginsDatetime"> |
449
|
|
|
{t('Base Period Begins')}{t('(Optional)')} |
450
|
|
|
</Label> |
451
|
|
|
<Datetime id='basePeriodBeginsDatetime' |
452
|
|
|
value={basePeriodBeginsDatetime} |
453
|
|
|
inputProps={{ disabled: basePeriodBeginsDatetimeDisabled }} |
454
|
|
|
onChange={onBasePeriodBeginsDatetimeChange} |
455
|
|
|
isValidDate={getValidBasePeriodBeginsDatetimes} |
456
|
|
|
closeOnSelect={true} /> |
457
|
|
|
</FormGroup> |
458
|
|
|
</Col> |
459
|
|
|
<Col xs="auto"> |
460
|
|
|
<FormGroup className="form-group"> |
461
|
|
|
<Label className={labelClasses} for="basePeriodEndsDatetime"> |
462
|
|
|
{t('Base Period Ends')}{t('(Optional)')} |
463
|
|
|
</Label> |
464
|
|
|
<Datetime id='basePeriodEndsDatetime' |
465
|
|
|
value={basePeriodEndsDatetime} |
466
|
|
|
inputProps={{ disabled: basePeriodEndsDatetimeDisabled }} |
467
|
|
|
onChange={onBasePeriodEndsDatetimeChange} |
468
|
|
|
isValidDate={getValidBasePeriodEndsDatetimes} |
469
|
|
|
closeOnSelect={true} /> |
470
|
|
|
</FormGroup> |
471
|
|
|
</Col> |
472
|
|
|
<Col xs="auto"> |
473
|
|
|
<FormGroup className="form-group"> |
474
|
|
|
<Label className={labelClasses} for="reportingPeriodBeginsDatetime"> |
475
|
|
|
{t('Reporting Period Begins')} |
476
|
|
|
</Label> |
477
|
|
|
<Datetime id='reportingPeriodBeginsDatetime' |
478
|
|
|
value={reportingPeriodBeginsDatetime} |
479
|
|
|
onChange={onReportingPeriodBeginsDatetimeChange} |
480
|
|
|
isValidDate={getValidReportingPeriodBeginsDatetimes} |
481
|
|
|
closeOnSelect={true} /> |
482
|
|
|
</FormGroup> |
483
|
|
|
</Col> |
484
|
|
|
<Col xs="auto"> |
485
|
|
|
<FormGroup className="form-group"> |
486
|
|
|
<Label className={labelClasses} for="reportingPeriodEndsDatetime"> |
487
|
|
|
{t('Reporting Period Ends')} |
488
|
|
|
</Label> |
489
|
|
|
<Datetime id='reportingPeriodEndsDatetime' |
490
|
|
|
value={reportingPeriodEndsDatetime} |
491
|
|
|
onChange={onReportingPeriodEndsDatetimeChange} |
492
|
|
|
isValidDate={getValidReportingPeriodEndsDatetimes} |
493
|
|
|
closeOnSelect={true} /> |
494
|
|
|
</FormGroup> |
495
|
|
|
</Col> |
496
|
|
|
<Col xs="auto"> |
497
|
|
|
<FormGroup> |
498
|
|
|
<br></br> |
499
|
|
|
<ButtonGroup id="submit"> |
500
|
|
|
<Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button> |
501
|
|
|
</ButtonGroup> |
502
|
|
|
</FormGroup> |
503
|
|
|
</Col> |
504
|
|
|
<Col xs="auto"> |
505
|
|
|
<FormGroup> |
506
|
|
|
<br></br> |
507
|
|
|
<Spinner color="primary" hidden={spinnerHidden} /> |
508
|
|
|
</FormGroup> |
509
|
|
|
</Col> |
510
|
|
|
<Col xs="auto"> |
511
|
|
|
<br></br> |
512
|
|
|
<ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" |
513
|
|
|
hidden={exportButtonHidden} |
514
|
|
|
onClick={handleExport} > |
515
|
|
|
{t('Export')} |
516
|
|
|
</ButtonIcon> |
517
|
|
|
</Col> |
518
|
|
|
</Row> |
519
|
|
|
</Form> |
520
|
|
|
</CardBody> |
521
|
|
|
</Card> |
522
|
|
|
{cardSummaryList.map(cardSummaryItem => ( |
523
|
|
|
<div className="card-deck" key={cardSummaryItem['name']}> |
524
|
|
|
<CardSummary key={cardSummaryItem['name'] + 'average'} |
525
|
|
|
rate={cardSummaryItem['average_increment_rate']} |
526
|
|
|
title={t('Reporting Period CATEGORY Average Load UNIT', { 'CATEGORY': cardSummaryItem['name'], 'UNIT': '(' + cardSummaryItem['unit'] + '/H)' })} |
527
|
|
|
color="success" |
528
|
|
|
footnote={t('Per Unit Area')} |
529
|
|
|
footvalue={cardSummaryItem['average_per_unit_area']} |
530
|
|
|
footunit={"(" + cardSummaryItem['unit'] + "/H/M²)"} > |
531
|
|
|
{cardSummaryItem['average'] && <CountUp end={cardSummaryItem['average']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
532
|
|
|
</CardSummary> |
533
|
|
|
<CardSummary key={cardSummaryItem['name'] + 'maximum'} |
534
|
|
|
rate={cardSummaryItem['maximum_increment_rate']} |
535
|
|
|
title={t('Reporting Period CATEGORY Maximum Load UNIT', { 'CATEGORY': cardSummaryItem['name'], 'UNIT': '(' + cardSummaryItem['unit'] + '/H)' })} |
536
|
|
|
color="success" |
537
|
|
|
footnote={t('Per Unit Area')} |
538
|
|
|
footvalue={cardSummaryItem['maximum_per_unit_area']} |
539
|
|
|
footunit={"(" + cardSummaryItem['unit'] + "/H/M²)"} > |
540
|
|
|
{cardSummaryItem['maximum'] && <CountUp end={cardSummaryItem['maximum']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
541
|
|
|
</CardSummary> |
542
|
|
|
<CardSummary key={cardSummaryItem['name'] + 'factor'} |
543
|
|
|
rate={cardSummaryItem['factor_increment_rate']} |
544
|
|
|
title={t('Reporting Period CATEGORY Load Factor', { 'CATEGORY': cardSummaryItem['name'] })} |
545
|
|
|
color="success" |
546
|
|
|
footnote={t('Ratio of Average Load to Maximum Load')} > |
547
|
|
|
{cardSummaryItem['factor'] && <CountUp end={cardSummaryItem['factor']} duration={2} prefix="" separator="," decimal="." decimals={2} />} |
548
|
|
|
</CardSummary> |
549
|
|
|
</div> |
550
|
|
|
))} |
551
|
|
|
|
552
|
|
|
<LineChart reportingTitle={t('Reporting Period CATEGORY Maximum Load UNIT', { 'CATEGORY': null, 'UNIT': null })} |
553
|
|
|
baseTitle='' |
554
|
|
|
labels={spaceLineChartLabels} |
555
|
|
|
data={spaceLineChartData} |
556
|
|
|
options={spaceLineChartOptions}> |
557
|
|
|
</LineChart> |
558
|
|
|
|
559
|
|
|
<LineChart reportingTitle={t('Related Parameters')} |
560
|
|
|
baseTitle='' |
561
|
|
|
labels={parameterLineChartLabels} |
562
|
|
|
data={parameterLineChartData} |
563
|
|
|
options={parameterLineChartOptions}> |
564
|
|
|
</LineChart> |
565
|
|
|
<DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} > |
566
|
|
|
</DetailedDataTable> |
567
|
|
|
<br /> |
568
|
|
|
|
569
|
|
|
</Fragment> |
570
|
|
|
); |
571
|
|
|
}; |
572
|
|
|
|
573
|
|
|
export default withTranslation()(withRedirect(SpaceLoad)); |
574
|
|
|
|