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