Passed
Push — master ( 669be3...4762c7 )
by Guangyu
19:25 queued 10s
created

src/components/MyEMS/CombinedEquipment/CombinedEquipmentOutput.js   A

Complexity

Total Complexity 25
Complexity/F 0

Size

Lines of Code 624
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 25
eloc 548
mnd 25
bc 25
fnc 0
dl 0
loc 624
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
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
35
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
36
37
const CombinedEquipmentOutput = ({ 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 [combinedEquipmentList, setCombinedEquipmentList] = useState([]);
62
  const [selectedCombinedEquipment, setSelectedCombinedEquipment] = useState(undefined);
63
  const [comparisonType, setComparisonType] = useState('month-on-month');
64
  const [periodType, setPeriodType] = useState('daily');
65
  const [basePeriodBeginsDatetime, setBasePeriodBeginsDatetime] = useState(current_moment.clone().subtract(1, 'months').startOf('month'));
66
  const [basePeriodEndsDatetime, setBasePeriodEndsDatetime] = useState(current_moment.clone().subtract(1, 'months'));
67
  const [basePeriodBeginsDatetimeDisabled, setBasePeriodBeginsDatetimeDisabled] = useState(true);
68
  const [basePeriodEndsDatetimeDisabled, setBasePeriodEndsDatetimeDisabled] = useState(true);
69
  const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month'));
70
  const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment);
71
  const [cascaderOptions, setCascaderOptions] = useState(undefined);
72
    
73
  // buttons
74
  const [submitButtonDisabled, setSubmitButtonDisabled] = useState(true);
75
  const [spinnerHidden, setSpinnerHidden] = useState(true);
76
  const [exportButtonHidden, setExportButtonHidden] = useState(true);
77
  
78
  //Results
79
  const [cardSummaryList, setCardSummaryList] = useState([]);
80
  const [combinedEquipmentLineChartLabels, setCombinedEquipmentLineChartLabels] = useState([]);
81
  const [combinedEquipmentLineChartData, setCombinedEquipmentLineChartData] = useState({});
82
  const [combinedEquipmentLineChartOptions, setCombinedEquipmentLineChartOptions] = useState([]);
83
84
  const [parameterLineChartLabels, setParameterLineChartLabels] = useState([]);
85
  const [parameterLineChartData, setParameterLineChartData] = useState({});
86
  const [parameterLineChartOptions, setParameterLineChartOptions] = useState([]);
87
88
  const [detailedDataTableData, setDetailedDataTableData] = useState([]);
89
  const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
90
  const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
91
  
92
  useEffect(() => {
93
    let isResponseOK = false;
94
    fetch(APIBaseURL + '/spaces/tree', {
95
      method: 'GET',
96
      headers: {
97
        "Content-type": "application/json",
98
        "User-UUID": getCookieValue('user_uuid'),
99
        "Token": getCookieValue('token')
100
      },
101
      body: null,
102
103
    }).then(response => {
104
      console.log(response)
105
      if (response.ok) {
106
        isResponseOK = true;
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
        // get Combined Equipments by root Space ID
118
        let isResponseOK = false;
119
        fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/combinedequipments', {
120
          method: 'GET',
121
          headers: {
122
            "Content-type": "application/json",
123
            "User-UUID": getCookieValue('user_uuid'),
124
            "Token": getCookieValue('token')
125
          },
126
          body: null,
127
128
        }).then(response => {
129
          if (response.ok) {
130
            isResponseOK = true;
131
          }
132
          return response.json();
133
        }).then(json => {
134
          if (isResponseOK) {
135
            json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
136
            console.log(json);
137
            setCombinedEquipmentList(json[0]);
138
            if (json[0].length > 0) {
139
              setSelectedCombinedEquipment(json[0][0].value);
140
              // enable submit button
141
              setSubmitButtonDisabled(false);
142
            } else {
143
              setSelectedCombinedEquipment(undefined);
144
              // disable submit button
145
              setSubmitButtonDisabled(true);
146
            }
147
          } else {
148
            toast.error(json.description)
149
          }
150
        }).catch(err => {
151
          console.log(err);
152
        });
153
        // end of get Combined Equipments by root Space ID
154
      } else {
155
        toast.error(json.description)
156
      }
157
    }).catch(err => {
158
      console.log(err);
159
    });
160
161
  }, []);
162
163
  const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0';
164
165
  let onSpaceCascaderChange = (value, selectedOptions) => {
166
    setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
167
    setSelectedSpaceID(value[value.length - 1]);
168
169
    let isResponseOK = false;
170
    fetch(APIBaseURL + '/spaces/' + value[value.length - 1] + '/combinedequipments', {
171
      method: 'GET',
172
      headers: {
173
        "Content-type": "application/json",
174
        "User-UUID": getCookieValue('user_uuid'),
175
        "Token": getCookieValue('token')
176
      },
177
      body: null,
178
179
    }).then(response => {
180
      if (response.ok) {
181
        isResponseOK = true;
182
      }
183
      return response.json();
184
    }).then(json => {
185
      if (isResponseOK) {
186
        json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
187
        console.log(json)
188
        setCombinedEquipmentList(json[0]);
189
        if (json[0].length > 0) {
190
          setSelectedCombinedEquipment(json[0][0].value);
191
          // enable submit button
192
          setSubmitButtonDisabled(false);
193
        } else {
194
          setSelectedCombinedEquipment(undefined);
195
          // disable submit button
196
          setSubmitButtonDisabled(true);
197
        }
198
      } else {
199
        toast.error(json.description)
200
      }
201
    }).catch(err => {
202
      console.log(err);
203
    });
204
  }
205
206
  let onComparisonTypeChange = ({ target }) => {
207
    console.log(target.value);
208
    setComparisonType(target.value);
209
    if (target.value === 'year-over-year') {
210
      setBasePeriodBeginsDatetimeDisabled(true);
211
      setBasePeriodEndsDatetimeDisabled(true);
212
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'years'));
213
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'years'));
214
    } else if (target.value === 'month-on-month') {
215
      setBasePeriodBeginsDatetimeDisabled(true);
216
      setBasePeriodEndsDatetimeDisabled(true);
217
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'months'));
218
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'months'));
219
    } else if (target.value === 'free-comparison') {
220
      setBasePeriodBeginsDatetimeDisabled(false);
221
      setBasePeriodEndsDatetimeDisabled(false);
222
    } else if (target.value === 'none-comparison') {
223
      setBasePeriodBeginsDatetime(undefined);
224
      setBasePeriodEndsDatetime(undefined);
225
      setBasePeriodBeginsDatetimeDisabled(true);
226
      setBasePeriodEndsDatetimeDisabled(true);
227
    }
228
  }
229
230
  let onBasePeriodBeginsDatetimeChange = (newDateTime) => {
231
    setBasePeriodBeginsDatetime(newDateTime);
232
  }
233
234
  let onBasePeriodEndsDatetimeChange = (newDateTime) => {
235
    setBasePeriodEndsDatetime(newDateTime);
236
  }
237
238
  let onReportingPeriodBeginsDatetimeChange = (newDateTime) => {
239
    setReportingPeriodBeginsDatetime(newDateTime);
240
    if (comparisonType === 'year-over-year') {
241
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'years'));
242
    } else if (comparisonType === 'month-on-month') {
243
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'months'));
244
    }
245
  }
246
247
  let onReportingPeriodEndsDatetimeChange = (newDateTime) => {
248
    setReportingPeriodEndsDatetime(newDateTime);
249
    if (comparisonType === 'year-over-year') {
250
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'years'));
251
    } else if (comparisonType === 'month-on-month') {
252
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'months'));
253
    }
254
  }
255
256
  var getValidBasePeriodBeginsDatetimes = function (currentDate) {
257
    return currentDate.isBefore(moment(basePeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
258
  }
259
260
  var getValidBasePeriodEndsDatetimes = function (currentDate) {
261
    return currentDate.isAfter(moment(basePeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
262
  }
263
264
  var getValidReportingPeriodBeginsDatetimes = function (currentDate) {
265
    return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
266
  }
267
268
  var getValidReportingPeriodEndsDatetimes = function (currentDate) {
269
    return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
270
  }
271
272
  // Handler
273
  const handleSubmit = e => {
274
    e.preventDefault();
275
    console.log('handleSubmit');
276
    console.log(selectedSpaceID);
277
    console.log(selectedCombinedEquipment);
278
    console.log(periodType);
279
    console.log(basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
280
    console.log(basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
281
    console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
282
    console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
283
284
    // disable submit button
285
    setSubmitButtonDisabled(true);
286
    // show spinner
287
    setSpinnerHidden(false);
288
    // hide export buttion
289
    setExportButtonHidden(true)
290
291
    // Reinitialize tables
292
    setDetailedDataTableData([]);
293
    
294
    let isResponseOK = false;
295
    fetch(APIBaseURL + '/reports/combinedequipmentoutput?' +
296
      'combinedequipmentid=' + selectedCombinedEquipment +
297
      '&periodtype=' + periodType +
298
      '&baseperiodstartdatetime=' + (basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
299
      '&baseperiodenddatetime=' + (basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
300
      '&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') +
301
      '&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
302
      method: 'GET',
303
      headers: {
304
        "Content-type": "application/json",
305
        "User-UUID": getCookieValue('user_uuid'),
306
        "Token": getCookieValue('token')
307
      },
308
      body: null,
309
310
    }).then(response => {
311
      if (response.ok) {
312
        isResponseOK = true;
313
      };
314
      return response.json();
315
    }).then(json => {
316
      if (isResponseOK) {
317
        console.log(json)
318
                    
319
        let cardSummaryArray = []
320
        json['reporting_period']['names'].forEach((currentValue, index) => {
321
          let cardSummaryItem = {}
322
          cardSummaryItem['name'] = json['reporting_period']['names'][index];
323
          cardSummaryItem['unit'] = json['reporting_period']['units'][index];
324
          cardSummaryItem['subtotal'] = json['reporting_period']['subtotals'][index];
325
          cardSummaryItem['increment_rate'] = parseFloat(json['reporting_period']['increment_rates'][index] * 100).toFixed(2) + "%";
326
          cardSummaryArray.push(cardSummaryItem);
327
        });
328
        setCardSummaryList(cardSummaryArray);
329
330
        let timestamps = {}
331
        json['reporting_period']['timestamps'].forEach((currentValue, index) => {
332
          timestamps['a' + index] = currentValue;
333
        });
334
        setCombinedEquipmentLineChartLabels(timestamps);
335
        
336
        let values = {}
337
        json['reporting_period']['values'].forEach((currentValue, index) => {
338
          values['a' + index] = currentValue;
339
        });
340
        setCombinedEquipmentLineChartData(values);
341
        
342
        let names = Array();
343
        json['reporting_period']['names'].forEach((currentValue, index) => {
344
          let unit = json['reporting_period']['units'][index];
345
          names.push({ 'value': 'a' + index, 'label': currentValue + ' (' + unit + ')'});
346
        });
347
        setCombinedEquipmentLineChartOptions(names);
348
       
349
        timestamps = {}
350
        json['parameters']['timestamps'].forEach((currentValue, index) => {
351
          timestamps['a' + index] = currentValue;
352
        });
353
        setParameterLineChartLabels(timestamps);
354
355
        values = {}
356
        json['parameters']['values'].forEach((currentValue, index) => {
357
          values['a' + index] = currentValue;
358
        });
359
        setParameterLineChartData(values);
360
      
361
        names = Array();
362
        json['parameters']['names'].forEach((currentValue, index) => {
363
          if (currentValue.startsWith('TARIFF-')) {
364
            currentValue = t('Tariff') + currentValue.replace('TARIFF-', '-');
365
          }
366
          
367
          names.push({ 'value': 'a' + index, 'label': currentValue });
368
        });
369
        setParameterLineChartOptions(names);
370
      
371
        let detailed_value_list = [];
372
        if (json['reporting_period']['timestamps'].length > 0) {
373
          json['reporting_period']['timestamps'][0].forEach((currentTimestamp, timestampIndex) => {
374
            let detailed_value = {};
375
            detailed_value['id'] = timestampIndex;
376
            detailed_value['startdatetime'] = currentTimestamp;
377
            json['reporting_period']['values'].forEach((currentValue, energyCategoryIndex) => {
378
              detailed_value['a' + energyCategoryIndex] = json['reporting_period']['values'][energyCategoryIndex][timestampIndex].toFixed(2);
379
            });
380
            detailed_value_list.push(detailed_value);
381
          });
382
        };
383
384
        let detailed_value = {};
385
        detailed_value['id'] = detailed_value_list.length;
386
        detailed_value['startdatetime'] = t('Subtotal');
387
        json['reporting_period']['subtotals'].forEach((currentValue, index) => {
388
            detailed_value['a' + index] = currentValue.toFixed(2);
389
          });
390
        detailed_value_list.push(detailed_value);
391
        setDetailedDataTableData(detailed_value_list);
392
        
393
        let detailed_column_list = [];
394
        detailed_column_list.push({
395
          dataField: 'startdatetime',
396
          text: t('Datetime'),
397
          sort: true
398
        })
399
        json['reporting_period']['names'].forEach((currentValue, index) => {
400
          let unit = json['reporting_period']['units'][index];
401
          detailed_column_list.push({
402
            dataField: 'a' + index,
403
            text: currentValue + ' (' + unit + ')',
404
            sort: true
405
          })
406
        });
407
        setDetailedDataTableColumns(detailed_column_list);
408
        
409
        setExcelBytesBase64(json['excel_bytes_base64']);
410
411
        // enable submit button
412
        setSubmitButtonDisabled(false);
413
        // hide spinner
414
        setSpinnerHidden(true);
415
        // show export buttion
416
        setExportButtonHidden(false);
417
        
418
      } else {
419
        toast.error(json.description)
420
      }
421
    }).catch(err => {
422
      console.log(err);
423
    });
424
425
  };
426
  
427
  const handleExport = e => {
428
    e.preventDefault();
429
    const mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
430
    const fileName = 'combinedequipmentoutput.xlsx'
431
    var fileUrl = "data:" + mimeType + ";base64," + excelBytesBase64;
432
    fetch(fileUrl)
433
        .then(response => response.blob())
434
        .then(blob => {
435
            var link = window.document.createElement("a");
436
            link.href = window.URL.createObjectURL(blob, { type: mimeType });
437
            link.download = fileName;
438
            document.body.appendChild(link);
439
            link.click();
440
            document.body.removeChild(link);
441
        });
442
  };
443
  
444
445
  return (
446
    <Fragment>
447
      <div>
448
        <Breadcrumb>
449
          <BreadcrumbItem>{t('Combined Equipment Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Output')}</BreadcrumbItem>
450
        </Breadcrumb>
451
      </div>
452
      <Card className="bg-light mb-3">
453
        <CardBody className="p-3">
454
          <Form onSubmit={handleSubmit}>
455
            <Row form>
456
              <Col xs="auto">
457
                <FormGroup className="form-group">
458
                  <Label className={labelClasses} for="space">
459
                    {t('Space')}
460
                  </Label>
461
                  <br />
462
                  <Cascader options={cascaderOptions}
463
                    onChange={onSpaceCascaderChange}
464
                    changeOnSelect
465
                    expandTrigger="hover">
466
                    <Input value={selectedSpaceName || ''} readOnly />
467
                  </Cascader>
468
                </FormGroup>
469
              </Col>
470
              <Col xs="auto">
471
                <FormGroup>
472
                  <Label className={labelClasses} for="combinedEquipmentSelect">
473
                    {t('Combined Equipment')}
474
                  </Label>
475
                  <CustomInput type="select" id="combinedEquipmentSelect" name="combinedEquipmentSelect" onChange={({ target }) => setSelectedCombinedEquipment(target.value)}
476
                  >
477
                    {combinedEquipmentList.map((combinedEquipment, index) => (
478
                      <option value={combinedEquipment.value} key={combinedEquipment.value}>
479
                        {combinedEquipment.label}
480
                      </option>
481
                    ))}
482
                  </CustomInput>
483
                </FormGroup>
484
              </Col>
485
              <Col xs="auto">
486
                <FormGroup>
487
                  <Label className={labelClasses} for="comparisonType">
488
                    {t('Comparison Types')}
489
                  </Label>
490
                  <CustomInput type="select" id="comparisonType" name="comparisonType"
491
                    defaultValue="month-on-month"
492
                    onChange={onComparisonTypeChange}
493
                  >
494
                    {comparisonTypeOptions.map((comparisonType, index) => (
495
                      <option value={comparisonType.value} key={comparisonType.value} >
496
                        {t(comparisonType.label)}
497
                      </option>
498
                    ))}
499
                  </CustomInput>
500
                </FormGroup>
501
              </Col>
502
              <Col xs="auto">
503
                <FormGroup>
504
                  <Label className={labelClasses} for="periodType">
505
                    {t('Period Types')}
506
                  </Label>
507
                  <CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)}
508
                  >
509
                    {periodTypeOptions.map((periodType, index) => (
510
                      <option value={periodType.value} key={periodType.value} >
511
                        {t(periodType.label)}
512
                      </option>
513
                    ))}
514
                  </CustomInput>
515
                </FormGroup>
516
              </Col>
517
              <Col xs="auto">
518
                <FormGroup className="form-group">
519
                  <Label className={labelClasses} for="basePeriodBeginsDatetime">
520
                    {t('Base Period Begins')}{t('(Optional)')}
521
                  </Label>
522
                  <Datetime id='basePeriodBeginsDatetime'
523
                    value={basePeriodBeginsDatetime}
524
                    inputProps={{ disabled: basePeriodBeginsDatetimeDisabled }}
525
                    onChange={onBasePeriodBeginsDatetimeChange}
526
                    isValidDate={getValidBasePeriodBeginsDatetimes}
527
                    closeOnSelect={true} />
528
                </FormGroup>
529
              </Col>
530
              <Col xs="auto">
531
                <FormGroup className="form-group">
532
                  <Label className={labelClasses} for="basePeriodEndsDatetime">
533
                    {t('Base Period Ends')}{t('(Optional)')}
534
                  </Label>
535
                  <Datetime id='basePeriodEndsDatetime'
536
                    value={basePeriodEndsDatetime}
537
                    inputProps={{ disabled: basePeriodEndsDatetimeDisabled }}
538
                    onChange={onBasePeriodEndsDatetimeChange}
539
                    isValidDate={getValidBasePeriodEndsDatetimes}
540
                    closeOnSelect={true} />
541
                </FormGroup>
542
              </Col>
543
              <Col xs="auto">
544
                <FormGroup className="form-group">
545
                  <Label className={labelClasses} for="reportingPeriodBeginsDatetime">
546
                    {t('Reporting Period Begins')}
547
                  </Label>
548
                  <Datetime id='reportingPeriodBeginsDatetime'
549
                    value={reportingPeriodBeginsDatetime}
550
                    onChange={onReportingPeriodBeginsDatetimeChange}
551
                    isValidDate={getValidReportingPeriodBeginsDatetimes}
552
                    closeOnSelect={true} />
553
                </FormGroup>
554
              </Col>
555
              <Col xs="auto">
556
                <FormGroup className="form-group">
557
                  <Label className={labelClasses} for="reportingPeriodEndsDatetime">
558
                    {t('Reporting Period Ends')}
559
                  </Label>
560
                  <Datetime id='reportingPeriodEndsDatetime'
561
                    value={reportingPeriodEndsDatetime}
562
                    onChange={onReportingPeriodEndsDatetimeChange}
563
                    isValidDate={getValidReportingPeriodEndsDatetimes}
564
                    closeOnSelect={true} />
565
                </FormGroup>
566
              </Col>
567
              <Col xs="auto">
568
                <FormGroup>
569
                  <br></br>
570
                  <ButtonGroup id="submit">
571
                    <Button color="success" disabled={submitButtonDisabled} >{t('Submit')}</Button>
572
                  </ButtonGroup>
573
                </FormGroup>
574
              </Col>
575
              <Col xs="auto">
576
                <FormGroup>
577
                  <br></br>
578
                  <Spinner color="primary" hidden={spinnerHidden}  />
579
                </FormGroup>
580
              </Col>
581
              <Col xs="auto">
582
                  <br></br>
583
                  <ButtonIcon icon="external-link-alt" transform="shrink-3 down-2" color="falcon-default" 
584
                  hidden={exportButtonHidden}
585
                  onClick={handleExport} >
586
                    {t('Export')}
587
                  </ButtonIcon>
588
              </Col>
589
            </Row>
590
          </Form>
591
        </CardBody>
592
      </Card>
593
      <div className="card-deck">
594
      {cardSummaryList.map(cardSummaryItem => (
595
          <CardSummary key={cardSummaryItem['name']}
596
            rate={cardSummaryItem['increment_rate']}
597
            title={t('Reporting Period Output CATEGORY UNIT', { 'CATEGORY': cardSummaryItem['name'], 'UNIT': '(' + cardSummaryItem['unit'] + ')' })}
598
            color="success" >
599
            {cardSummaryItem['subtotal'] && <CountUp end={cardSummaryItem['subtotal']} duration={2} prefix="" separator="," decimal="." decimals={2} />}
600
          </CardSummary>
601
        ))}
602
      </div>
603
      <LineChart reportingTitle={t('Reporting Period Output CATEGORY VALUE UNIT', { 'CATEGORY': null, 'VALUE': null, 'UNIT': null })}
604
        baseTitle=''
605
        labels={combinedEquipmentLineChartLabels}
606
        data={combinedEquipmentLineChartData}
607
        options={combinedEquipmentLineChartOptions}>
608
      </LineChart>
609
      <LineChart reportingTitle={t('Related Parameters')}
610
        baseTitle=''
611
        labels={parameterLineChartLabels}
612
        data={parameterLineChartData}
613
        options={parameterLineChartOptions}>
614
      </LineChart>
615
      <br />
616
      <DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} >
617
      </DetailedDataTable>
618
619
    </Fragment>
620
  );
621
};
622
623
export default withTranslation()(withRedirect(CombinedEquipmentOutput));
624