added AssociatedEquipmentTable to CombinedEquipmentSaving report in web UI
parent
3efce5f620
commit
d82f1eb829
|
@ -34,6 +34,7 @@ import { comparisonTypeOptions } from '../common/ComparisonTypeOptions';
|
||||||
|
|
||||||
|
|
||||||
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
|
const DetailedDataTable = loadable(() => import('../common/DetailedDataTable'));
|
||||||
|
const AssociatedEquipmentTable = loadable(() => import('../common/AssociatedEquipmentTable'));
|
||||||
|
|
||||||
const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
let current_moment = moment();
|
let current_moment = moment();
|
||||||
|
@ -93,6 +94,10 @@ const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
|
|
||||||
const [detailedDataTableData, setDetailedDataTableData] = useState([]);
|
const [detailedDataTableData, setDetailedDataTableData] = useState([]);
|
||||||
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
|
const [detailedDataTableColumns, setDetailedDataTableColumns] = useState([{dataField: 'startdatetime', text: t('Datetime'), sort: true}]);
|
||||||
|
|
||||||
|
const [associatedEquipmentTableData, setAssociatedEquipmentTableData] = useState([]);
|
||||||
|
const [associatedEquipmentTableColumns, setAssociatedEquipmentTableColumns] = useState([{dataField: 'name', text: t('Associated Equipment'), sort: true }]);
|
||||||
|
|
||||||
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
|
const [excelBytesBase64, setExcelBytesBase64] = useState(undefined);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -297,6 +302,7 @@ const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
|
|
||||||
// Reinitialize tables
|
// Reinitialize tables
|
||||||
setDetailedDataTableData([]);
|
setDetailedDataTableData([]);
|
||||||
|
setAssociatedEquipmentTableData([]);
|
||||||
|
|
||||||
let isResponseOK = false;
|
let isResponseOK = false;
|
||||||
fetch(APIBaseURL + '/reports/combinedequipmentsaving?' +
|
fetch(APIBaseURL + '/reports/combinedequipmentsaving?' +
|
||||||
|
@ -445,6 +451,38 @@ const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
});
|
});
|
||||||
setDetailedDataTableColumns(detailed_column_list);
|
setDetailedDataTableColumns(detailed_column_list);
|
||||||
|
|
||||||
|
let associated_equipment_value_list = [];
|
||||||
|
if (json['associated_equipment']['associated_equipment_names_array'].length > 0) {
|
||||||
|
json['associated_equipment']['associated_equipment_names_array'][0].forEach((currentEquipmentName, spaceIndex) => {
|
||||||
|
let associated_equipment_value = {};
|
||||||
|
associated_equipment_value['id'] = spaceIndex;
|
||||||
|
associated_equipment_value['name'] = currentEquipmentName;
|
||||||
|
json['associated_equipment']['energy_category_names'].forEach((currentValue, energyCategoryIndex) => {
|
||||||
|
associated_equipment_value['a' + energyCategoryIndex] = json['associated_equipment']['subtotals_saving_array'][energyCategoryIndex][spaceIndex].toFixed(2);
|
||||||
|
});
|
||||||
|
associated_equipment_value_list.push(associated_equipment_value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
setAssociatedEquipmentTableData(associated_equipment_value_list);
|
||||||
|
|
||||||
|
let associated_equipment_column_list = [];
|
||||||
|
associated_equipment_column_list.push({
|
||||||
|
dataField: 'name',
|
||||||
|
text: t('Associated Equipment'),
|
||||||
|
sort: true
|
||||||
|
});
|
||||||
|
json['associated_equipment']['energy_category_names'].forEach((currentValue, index) => {
|
||||||
|
let unit = json['associated_equipment']['units'][index];
|
||||||
|
associated_equipment_column_list.push({
|
||||||
|
dataField: 'a' + index,
|
||||||
|
text: currentValue + ' (' + unit + ')',
|
||||||
|
sort: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
setAssociatedEquipmentTableColumns(associated_equipment_column_list);
|
||||||
|
|
||||||
setExcelBytesBase64(json['excel_bytes_base64']);
|
setExcelBytesBase64(json['excel_bytes_base64']);
|
||||||
|
|
||||||
// enable submit button
|
// enable submit button
|
||||||
|
@ -676,6 +714,9 @@ const CombinedEquipmentSaving = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
<br />
|
<br />
|
||||||
<DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} >
|
<DetailedDataTable data={detailedDataTableData} title={t('Detailed Data')} columns={detailedDataTableColumns} pagesize={50} >
|
||||||
</DetailedDataTable>
|
</DetailedDataTable>
|
||||||
|
<br />
|
||||||
|
<AssociatedEquipmentTable data={associatedEquipmentTableData} title={t('Associated Equipment Data')} columns={associatedEquipmentTableColumns}>
|
||||||
|
</AssociatedEquipmentTable>
|
||||||
|
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue