Passed
Push — master ( ad9069...21ae26 )
by Guangyu
04:09 queued 10s
created

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

Complexity

Total Complexity 23
Complexity/F 0

Size

Lines of Code 638
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 23
eloc 564
mnd 23
bc 23
fnc 0
dl 0
loc 638
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
} from 'reactstrap';
17
import CountUp from 'react-countup';
18
import Datetime from 'react-datetime';
19
import moment from 'moment';
20
import Cascader from 'rc-cascader';
21
import CardSummary from '../common/CardSummary';
22
import LineChart from '../common/LineChart';
23
import loadable from '@loadable/component';
24
import { getCookieValue, createCookie } from '../../../helpers/utils';
25
import withRedirect from '../../../hoc/withRedirect';
26
import { withTranslation } from 'react-i18next';
27
import { periodTypeOptions } from '../common/PeriodTypeOptions';
28
import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
29
import { toast } from 'react-toastify';
30
import { APIBaseURL } from '../../../config';
31
32
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
33
34
const CombinedEquipmentEnergyItem = ({ setRedirect, setRedirectUrl, t }) => {
35
  let current_moment = moment();
36
  useEffect(() => {
37
    let is_logged_in = getCookieValue('is_logged_in');
38
    let user_name = getCookieValue('user_name');
39
    let user_display_name = getCookieValue('user_display_name');
40
    let user_uuid = getCookieValue('user_uuid');
41
    let token = getCookieValue('token');
42
    if (is_logged_in === null || !is_logged_in) {
43
      setRedirectUrl(`/authentication/basic/login`);
44
      setRedirect(true);
45
    } else {
46
      //update expires time of cookies
47
      createCookie('is_logged_in', true, 1000 * 60 * 60 * 8);
48
      createCookie('user_name', user_name, 1000 * 60 * 60 * 8);
49
      createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8);
50
      createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8);
51
      createCookie('token', token, 1000 * 60 * 60 * 8);
52
    }
53
  });
54
  // State
55
  // Query Parameters
56
  const [selectedSpaceName, setSelectedSpaceName] = useState(undefined);
57
  const [selectedSpaceID, setSelectedSpaceID] = useState(undefined);
58
  const [combinedEquipmentList, setCombinedEquipmentList] = useState([]);
59
  const [selectedCombinedEquipment, setSelectedCombinedEquipment] = useState(undefined);
60
  const [comparisonType, setComparisonType] = useState('month-on-month');
61
  const [periodType, setPeriodType] = useState('daily');
62
  const [basePeriodBeginsDatetime, setBasePeriodBeginsDatetime] = useState(current_moment.clone().subtract(1, 'months').startOf('month'));
63
  const [basePeriodEndsDatetime, setBasePeriodEndsDatetime] = useState(current_moment.clone().subtract(1, 'months'));
64
  const [basePeriodBeginsDatetimeDisabled, setBasePeriodBeginsDatetimeDisabled] = useState(true);
65
  const [basePeriodEndsDatetimeDisabled, setBasePeriodEndsDatetimeDisabled] = useState(true);
66
  const [reportingPeriodBeginsDatetime, setReportingPeriodBeginsDatetime] = useState(current_moment.clone().startOf('month'));
67
  const [reportingPeriodEndsDatetime, setReportingPeriodEndsDatetime] = useState(current_moment);
68
  const [cascaderOptions, setCascaderOptions] = useState(undefined);
69
  const [isDisabled, setIsDisabled] = useState(true);
70
  //Results
71
  const [combinedEquipmentLineChartLabels, setCombinedEquipmentLineChartLabels] = useState([]);
72
  const [combinedEquipmentLineChartData, setCombinedEquipmentLineChartData] = useState({});
73
  const [combinedEquipmentLineChartOptions, setCombinedEquipmentLineChartOptions] = useState([]);
74
75
  const [parameterLineChartLabels, setParameterLineChartLabels] = useState([]);
76
  const [parameterLineChartData, setParameterLineChartData] = useState({});
77
  const [parameterLineChartOptions, setParameterLineChartOptions] = useState([]);
78
79
  const [detailedDataTableData, setDetailedDataTableData] = useState([]);
80
  const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
81
82
  useEffect(() => {
83
    let isResponseOK = false;
84
    fetch(APIBaseURL + '/spaces/tree', {
85
      method: 'GET',
86
      headers: {
87
        "Content-type": "application/json",
88
        "User-UUID": getCookieValue('user_uuid'),
89
        "Token": getCookieValue('token')
90
      },
91
      body: null,
92
93
    }).then(response => {
94
      console.log(response)
95
      if (response.ok) {
96
        isResponseOK = true;
97
      }
98
      return response.json();
99
    }).then(json => {
100
      console.log(json)
101
      if (isResponseOK) {
102
        // rename keys 
103
        json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
104
        setCascaderOptions(json);
105
        setSelectedSpaceName([json[0]].map(o => o.label));
106
        setSelectedSpaceID([json[0]].map(o => o.value));
107
        // get Combined Equipments by root Space ID
108
        let isResponseOK = false;
109
        fetch(APIBaseURL + '/spaces/' + [json[0]].map(o => o.value) + '/combinedequipments', {
110
          method: 'GET',
111
          headers: {
112
            "Content-type": "application/json",
113
            "User-UUID": getCookieValue('user_uuid'),
114
            "Token": getCookieValue('token')
115
          },
116
          body: null,
117
118
        }).then(response => {
119
          if (response.ok) {
120
            isResponseOK = true;
121
          }
122
          return response.json();
123
        }).then(json => {
124
          if (isResponseOK) {
125
            json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
126
            console.log(json);
127
            setCombinedEquipmentList(json[0]);
128
            if (json[0].length > 0) {
129
              setSelectedCombinedEquipment(json[0][0].value);
130
              setIsDisabled(false);
131
            } else {
132
              setSelectedCombinedEquipment(undefined);
133
              setIsDisabled(true);
134
            }
135
          } else {
136
            toast.error(json.description)
137
          }
138
        }).catch(err => {
139
          console.log(err);
140
        });
141
        // end of get Combined Equipments by root Space ID
142
      } else {
143
        toast.error(json.description)
144
      }
145
    }).catch(err => {
146
      console.log(err);
147
    });
148
149
  }, []);
150
  const labelClasses = 'ls text-uppercase text-600 font-weight-semi-bold mb-0';
151
152
  let onSpaceCascaderChange = (value, selectedOptions) => {
153
    setSelectedSpaceName(selectedOptions.map(o => o.label).join('/'));
154
    setSelectedSpaceID(value[value.length - 1]);
155
156
    let isResponseOK = false;
157
    fetch(APIBaseURL + '/spaces/' + value[value.length - 1] + '/combinedequipments', {
158
      method: 'GET',
159
      headers: {
160
        "Content-type": "application/json",
161
        "User-UUID": getCookieValue('user_uuid'),
162
        "Token": getCookieValue('token')
163
      },
164
      body: null,
165
166
    }).then(response => {
167
      if (response.ok) {
168
        isResponseOK = true;
169
      }
170
      return response.json();
171
    }).then(json => {
172
      if (isResponseOK) {
173
        json = JSON.parse(JSON.stringify([json]).split('"id":').join('"value":').split('"name":').join('"label":'));
174
        console.log(json)
175
        setCombinedEquipmentList(json[0]);
176
        if (json[0].length > 0) {
177
          setSelectedCombinedEquipment(json[0][0].value);
178
          setIsDisabled(false);
179
        } else {
180
          setSelectedCombinedEquipment(undefined);
181
          setIsDisabled(true);
182
        }
183
      } else {
184
        toast.error(json.description)
185
      }
186
    }).catch(err => {
187
      console.log(err);
188
    });
189
  }
190
191
192
  let onComparisonTypeChange = ({ target }) => {
193
    console.log(target.value);
194
    setComparisonType(target.value);
195
    if (target.value === 'year-over-year') {
196
      setBasePeriodBeginsDatetimeDisabled(true);
197
      setBasePeriodEndsDatetimeDisabled(true);
198
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'years'));
199
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'years'));
200
    } else if (target.value === 'month-on-month') {
201
      setBasePeriodBeginsDatetimeDisabled(true);
202
      setBasePeriodEndsDatetimeDisabled(true);
203
      setBasePeriodBeginsDatetime(moment(reportingPeriodBeginsDatetime).subtract(1, 'months'));
204
      setBasePeriodEndsDatetime(moment(reportingPeriodEndsDatetime).subtract(1, 'months'));
205
    } else if (target.value === 'free-comparison') {
206
      setBasePeriodBeginsDatetimeDisabled(false);
207
      setBasePeriodEndsDatetimeDisabled(false);
208
    } else if (target.value === 'none-comparison') {
209
      setBasePeriodBeginsDatetime(undefined);
210
      setBasePeriodEndsDatetime(undefined);
211
      setBasePeriodBeginsDatetimeDisabled(true);
212
      setBasePeriodEndsDatetimeDisabled(true);
213
    }
214
  }
215
216
  let onBasePeriodBeginsDatetimeChange = (newDateTime) => {
217
    setBasePeriodBeginsDatetime(newDateTime);
218
  }
219
220
  let onBasePeriodEndsDatetimeChange = (newDateTime) => {
221
    setBasePeriodEndsDatetime(newDateTime);
222
  }
223
224
  let onReportingPeriodBeginsDatetimeChange = (newDateTime) => {
225
    setReportingPeriodBeginsDatetime(newDateTime);
226
    if (comparisonType === 'year-over-year') {
227
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'years'));
228
    } else if (comparisonType === 'month-on-month') {
229
      setBasePeriodBeginsDatetime(newDateTime.clone().subtract(1, 'months'));
230
    }
231
  }
232
233
  let onReportingPeriodEndsDatetimeChange = (newDateTime) => {
234
    setReportingPeriodEndsDatetime(newDateTime);
235
    if (comparisonType === 'year-over-year') {
236
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'years'));
237
    } else if (comparisonType === 'month-on-month') {
238
      setBasePeriodEndsDatetime(newDateTime.clone().subtract(1, 'months'));
239
    }
240
  }
241
242
  var getValidBasePeriodBeginsDatetimes = function (currentDate) {
243
    return currentDate.isBefore(moment(basePeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
244
  }
245
246
  var getValidBasePeriodEndsDatetimes = function (currentDate) {
247
    return currentDate.isAfter(moment(basePeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
248
  }
249
250
  var getValidReportingPeriodBeginsDatetimes = function (currentDate) {
251
    return currentDate.isBefore(moment(reportingPeriodEndsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
252
  }
253
254
  var getValidReportingPeriodEndsDatetimes = function (currentDate) {
255
    return currentDate.isAfter(moment(reportingPeriodBeginsDatetime, 'MM/DD/YYYY, hh:mm:ss a'));
256
  }
257
258
  // Handler
259
  const handleSubmit = e => {
260
    e.preventDefault();
261
    console.log('handleSubmit');
262
    console.log(selectedSpaceID);
263
    console.log(selectedCombinedEquipment);
264
    console.log(periodType);
265
    console.log(basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
266
    console.log(basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : undefined);
267
    console.log(reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
268
    console.log(reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'));
269
270
    // Reinitialize tables
271
    setDetailedDataTableData([]);
272
    
273
    let isResponseOK = false;
274
    fetch(APIBaseURL + '/reports/combinedequipmentenergyitem?' +
275
      'combinedequipmentid=' + selectedCombinedEquipment +
276
      '&periodtype=' + periodType +
277
      '&baseperiodstartdatetime=' + (basePeriodBeginsDatetime != null ? basePeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
278
      '&baseperiodenddatetime=' + (basePeriodEndsDatetime != null ? basePeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss') : '') +
279
      '&reportingperiodstartdatetime=' + reportingPeriodBeginsDatetime.format('YYYY-MM-DDTHH:mm:ss') +
280
      '&reportingperiodenddatetime=' + reportingPeriodEndsDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
281
      method: 'GET',
282
      headers: {
283
        "Content-type": "application/json",
284
        "User-UUID": getCookieValue('user_uuid'),
285
        "Token": getCookieValue('token')
286
      },
287
      body: null,
288
289
    }).then(response => {
290
      if (response.ok) {
291
        isResponseOK = true;
292
      }
293
      return response.json();
294
    }).then(json => {
295
      if (isResponseOK) {
296
        console.log(json)
297
        
298
        setCombinedEquipmentLineChartLabels({
299
          a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
300
          a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
301
          a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
302
          a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
303
        });
304
305
        setCombinedEquipmentLineChartData({
306
          a0: [4, 1, 6, 2, 7, 12, 4, 6, 5, 4, 5, 10],
307
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
308
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
309
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
310
        });
311
312
        setCombinedEquipmentLineChartOptions([
313
          { value: 'a0', label: '空调水' },
314
          { value: 'a1', label: '空调风' },
315
          { value: 'a2', label: '照明及插座' },
316
          { value: 'a3', label: '电梯' }
317
        ]);
318
319
        setParameterLineChartLabels({
320
          a0: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
321
          a1: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
322
          a2: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
323
          a3: ['2020-07-01','2020-07-02', '2020-07-03', '2020-07-04', '2020-07-05', '2020-07-06', '2020-07-07', '2020-07-08', '2020-07-09','2020-07-10','2020-07-11','2020-07-12'],
324
        });
325
326
        setParameterLineChartData({
327
          a0: [40, 31, 36, 32, 27, 32, 34, 26, 25, 24, 25, 30],
328
          a1: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8],
329
          a2: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
330
          a3: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2],
331
          a4: [1, 0, 2, 1, 2, 1, 1, 0, 0, 1, 0, 2]
332
        });
333
334
        setParameterLineChartOptions([
335
          { value: 'a0', label: '室外温度' },
336
          { value: 'a1', label: '相对湿度' },
337
          { value: 'a2', label: '电费率' },
338
          { value: 'a3', label: '自来水费率' },
339
          { value: 'a4', label: '天然气费率' }
340
        ]);
341
342
        setDetailedDataTableData([
343
          {
344
            id: 1,
345
            startdatetime: '2020-07-01',
346
            a0: '9872',
347
            a1: '3457',
348
            a2: '567',
349
            a3: '567',
350
          },
351
          {
352
            id: 2,
353
            startdatetime: '2020-07-02',
354
            a0: '9872',
355
            a1: '3457',
356
            a2: '567',
357
            a3: '567',
358
          },
359
          {
360
            id: 3,
361
            startdatetime: '2020-07-03',
362
            a0: '9872',
363
            a1: '3457',
364
            a2: '567',
365
            a3: '567',
366
          },
367
          {
368
            id: 4,
369
            startdatetime: '2020-07-04',
370
            a0: '9872',
371
            a1: '3457',
372
            a2: '567',
373
            a3: '567',
374
          },
375
          {
376
            id: 5,
377
            startdatetime: '2020-07-05',
378
            a0: '9872',
379
            a1: '3457',
380
            a2: '567',
381
            a3: '567',
382
          },
383
          {
384
            id: 6,
385
            startdatetime: '2020-07-06',
386
            a0: '9872',
387
            a1: '3457',
388
            a2: '567',
389
            a3: '567',
390
          },
391
          {
392
            id: 7,
393
            startdatetime: '2020-07-07',
394
            a0: '9872',
395
            a1: '3457',
396
            a2: '567',
397
            a3: '567',
398
          },
399
          {
400
            id: 8,
401
            startdatetime: '2020-07-08',
402
            a0: '9872',
403
            a1: '3457',
404
            a2: '567',
405
            a3: '567',
406
          },
407
          {
408
            id: 9,
409
            startdatetime: '2020-07-09',
410
            a0: '9872',
411
            a1: '3457',
412
            a2: '567',
413
            a3: '567',
414
          },
415
          {
416
            id: 10,
417
            startdatetime: '2020-07-10',
418
            a0: '9872',
419
            a1: '3457',
420
            a2: '567',
421
            a3: '567',
422
          },
423
          {
424
            id: 11,
425
            startdatetime: t('Total'),
426
            a0: '98720',
427
            a1: '34570',
428
            a2: '5670',
429
            a3: '5670',
430
          }
431
        ]);
432
433
        setDetailedDataTableColumns([
434
          {
435
            dataField: 'startdatetime',
436
            text: t('Datetime'),
437
            sort: true
438
          }, {
439
            dataField: 'a0',
440
            text: '空调水 (kWh)',
441
            sort: true
442
          }, {
443
            dataField: 'a1',
444
            text: '空调风 (kWh)',
445
            sort: true
446
          }, {
447
            dataField: 'a2',
448
            text: '照明及插座 (kWh)',
449
            sort: true
450
          }, {
451
            dataField: 'a3',
452
            text: '电梯 (kWh)',
453
            sort: true
454
          }
455
        ]);
456
      } else {
457
        toast.error(json.description)
458
      }
459
    }).catch(err => {
460
      console.log(err);
461
    });
462
   
463
  };
464
465
  return (
466
    <Fragment>
467
      <div>
468
        <Breadcrumb>
469
          <BreadcrumbItem>{t('Combined Equipment Data')}</BreadcrumbItem><BreadcrumbItem active>{t('Energy Item Data')}</BreadcrumbItem>
470
        </Breadcrumb>
471
      </div>
472
      <Card className="bg-light mb-3">
473
        <CardBody className="p-3">
474
          <Form onSubmit={handleSubmit}>
475
            <Row form>
476
              <Col xs="auto">
477
                <FormGroup className="form-group">
478
                  <Label className={labelClasses} for="space">
479
                    {t('Space')}
480
                  </Label>
481
482
                  <br />
483
                  <Cascader options={cascaderOptions}
484
                    onChange={onSpaceCascaderChange}
485
                    changeOnSelect
486
                    expandTrigger="hover">
487
                    <Input value={selectedSpaceName || ''} readOnly />
488
                  </Cascader>
489
                </FormGroup>
490
              </Col>
491
              <Col xs="auto">
492
                <FormGroup>
493
                  <Label className={labelClasses} for="combinedEquipmentSelect">
494
                    {t('Combined Equipment')}
495
                  </Label>
496
                  <CustomInput type="select" id="combinedEquipmentSelect" name="combinedEquipmentSelect" onChange={({ target }) => setSelectedCombinedEquipment(target.value)}
497
                  >
498
                    {combinedEquipmentList.map((combinedEquipment, index) => (
499
                      <option value={combinedEquipment.value} key={combinedEquipment.value}>
500
                        {combinedEquipment.label}
501
                      </option>
502
                    ))}
503
                  </CustomInput>
504
                </FormGroup>
505
              </Col>
506
              <Col xs="auto">
507
                <FormGroup>
508
                  <Label className={labelClasses} for="comparisonType">
509
                    {t('Comparison Types')}
510
                  </Label>
511
                  <CustomInput type="select" id="comparisonType" name="comparisonType"
512
                    defaultValue="month-on-month"
513
                    onChange={onComparisonTypeChange}
514
                  >
515
                    {comparisonTypeOptions.map((comparisonType, index) => (
516
                      <option value={comparisonType.value} key={comparisonType.value} >
517
                        {t(comparisonType.label)}
518
                      </option>
519
                    ))}
520
                  </CustomInput>
521
                </FormGroup>
522
              </Col>
523
              <Col xs="auto">
524
                <FormGroup>
525
                  <Label className={labelClasses} for="periodType">
526
                    {t('Period Types')}
527
                  </Label>
528
                  <CustomInput type="select" id="periodType" name="periodType" defaultValue="daily" onChange={({ target }) => setPeriodType(target.value)}
529
                  >
530
                    {periodTypeOptions.map((periodType, index) => (
531
                      <option value={periodType.value} key={periodType.value} >
532
                        {t(periodType.label)}
533
                      </option>
534
                    ))}
535
                  </CustomInput>
536
                </FormGroup>
537
              </Col>
538
              <Col xs="auto">
539
                <FormGroup className="form-group">
540
                  <Label className={labelClasses} for="basePeriodBeginsDatetime">
541
                    {t('Base Period Begins')}{t('(Optional)')}
542
                  </Label>
543
                  <Datetime id='basePeriodBeginsDatetime'
544
                    value={basePeriodBeginsDatetime}
545
                    inputProps={{ disabled: basePeriodBeginsDatetimeDisabled }}
546
                    onChange={onBasePeriodBeginsDatetimeChange}
547
                    isValidDate={getValidBasePeriodBeginsDatetimes}
548
                    closeOnSelect={true} />
549
                </FormGroup>
550
              </Col>
551
              <Col xs="auto">
552
                <FormGroup className="form-group">
553
                  <Label className={labelClasses} for="basePeriodEndsDatetime">
554
                    {t('Base Period Ends')}{t('(Optional)')}
555
                  </Label>
556
                  <Datetime id='basePeriodEndsDatetime'
557
                    value={basePeriodEndsDatetime}
558
                    inputProps={{ disabled: basePeriodEndsDatetimeDisabled }}
559
                    onChange={onBasePeriodEndsDatetimeChange}
560
                    isValidDate={getValidBasePeriodEndsDatetimes}
561
                    closeOnSelect={true} />
562
                </FormGroup>
563
              </Col>
564
              <Col xs="auto">
565
                <FormGroup className="form-group">
566
                  <Label className={labelClasses} for="reportingPeriodBeginsDatetime">
567
                    {t('Reporting Period Begins')}
568
                  </Label>
569
                  <Datetime id='reportingPeriodBeginsDatetime'
570
                    value={reportingPeriodBeginsDatetime}
571
                    onChange={onReportingPeriodBeginsDatetimeChange}
572
                    isValidDate={getValidReportingPeriodBeginsDatetimes}
573
                    closeOnSelect={true} />
574
                </FormGroup>
575
              </Col>
576
              <Col xs="auto">
577
                <FormGroup className="form-group">
578
                  <Label className={labelClasses} for="reportingPeriodEndsDatetime">
579
                    {t('Reporting Period Ends')}
580
                  </Label>
581
                  <Datetime id='reportingPeriodEndsDatetime'
582
                    value={reportingPeriodEndsDatetime}
583
                    onChange={onReportingPeriodEndsDatetimeChange}
584
                    isValidDate={getValidReportingPeriodEndsDatetimes}
585
                    closeOnSelect={true} />
586
                </FormGroup>
587
              </Col>
588
              <Col xs="auto">
589
                <FormGroup>
590
                  <br></br>
591
                  <ButtonGroup id="submit">
592
                    <Button color="success" disabled={isDisabled} >{t('Submit')}</Button>
593
                  </ButtonGroup>
594
                </FormGroup>
595
              </Col>
596
            </Row>
597
          </Form>
598
        </CardBody>
599
      </Card>
600
      <div className="card-deck">
601
        <CardSummary rate="-0.23%" title={t('Reporting Period Consumption ITEM CATEGORY UNIT', { 'ITEM': '空调水', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
602
          color="success"  >
603
          <CountUp end={5890863} duration={2} prefix="" separator="," decimals={2} decimal="." />
604
        </CardSummary>
605
        <CardSummary rate="0.0%" title={t('Reporting Period Consumption ITEM CATEGORY UNIT', { 'ITEM': '空调风', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
606
          color="info" >
607
          <CountUp end={29878} duration={2} prefix="" separator="," decimals={2} decimal="." />
608
        </CardSummary>
609
        <CardSummary rate="0.0%" title={t('Reporting Period Consumption ITEM CATEGORY UNIT', { 'ITEM': '照明及插座', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
610
          color="info" >
611
          <CountUp end={9887} duration={2} prefix="" separator="," decimals={2} decimal="." />
612
        </CardSummary>
613
        <CardSummary rate="+9.54%" title={t('Reporting Period Consumption ITEM CATEGORY UNIT', { 'ITEM': '电梯', 'CATEGORY': '电', 'UNIT': '(kWh)' })}
614
          color="warning" >
615
          <CountUp end={43594} duration={2} prefix="" separator="," decimals={2} decimal="." />
616
        </CardSummary>
617
      </div>
618
      <LineChart reportingTitle={t('Reporting Period Consumption ITEM CATEGORY VALUE UNIT', { 'ITEM': '空调水', 'CATEGORY': '电', 'VALUE': 764.39, 'UNIT': '(kWh)' })}
619
        baseTitle={t('Base Period Consumption ITEM CATEGORY VALUE UNIT', { 'ITEM': '空调水', 'CATEGORY': '电', 'VALUE': 684.87, 'UNIT': '(kWh)' })}
620
        labels={combinedEquipmentLineChartLabels}
621
        data={combinedEquipmentLineChartData}
622
        options={combinedEquipmentLineChartOptions}>
623
      </LineChart>
624
      <LineChart reportingTitle={t('Related Parameters')}
625
        baseTitle=''
626
        labels={parameterLineChartLabels}
627
        data={parameterLineChartData}
628
        options={parameterLineChartOptions}>
629
      </LineChart>
630
      <br />
631
      <DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={31} >
632
      </DetailedDataTable>
633
    </Fragment>
634
  );
635
};
636
637
export default withTranslation()(withRedirect(CombinedEquipmentEnergyItem));
638