forked from BLC/sgeUpdated
few translation edits and changing it to use vmEmission query
This commit is contained in:
@@ -3,7 +3,7 @@ import { MaterialReactTable } from "material-react-table";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardHeader, CardTitle, Alert } from "reactstrap";
|
||||
import { getMainDataTablesWithPaginate } from "../../redux/actions/mainDataTables/index";
|
||||
import { getVMEmissionSummary } from "../../redux/actions/mainDataTables/index";
|
||||
import { editNumbers } from "../../components/edit-numbers";
|
||||
|
||||
function MainDataTables() {
|
||||
@@ -16,7 +16,7 @@ function MainDataTables() {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await dispatch(getMainDataTablesWithPaginate());
|
||||
await dispatch(getVMEmissionSummary());
|
||||
} catch (err) {
|
||||
console.error('Error in MainDataTables:', err);
|
||||
setError(err.message);
|
||||
@@ -35,74 +35,21 @@ function MainDataTables() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
header: t("ID"),
|
||||
accessorKey: "id",
|
||||
Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Year"),
|
||||
accessorKey: "year",
|
||||
Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Sector"),
|
||||
accessorKey: "sector",
|
||||
Cell: ({ cell, row }) => <span>{row.original?.sector?.tag || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Sub Sector"),
|
||||
accessorKey: "subSector",
|
||||
Cell: ({ cell, row }) => <span>{row.original?.subSector?.tag || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Activity Sub Unit"),
|
||||
accessorKey: "activitySubUnit",
|
||||
Cell: ({ cell, row }) => <span>{row.original?.activitySubUnit?.tag || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Emission Source"),
|
||||
accessorKey: "emissionSource",
|
||||
Cell: ({ cell, row }) => <span>{row.original?.emissionSource?.tag || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Emission Scope"),
|
||||
accessorKey: "emissionScope",
|
||||
Cell: ({ cell, row }) => <span>{row.original?.emissionScope?.tag || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Total Emission"),
|
||||
accessorKey: "totalEmission",
|
||||
Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: "CO2",
|
||||
accessorKey: "co2",
|
||||
Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: "CH4",
|
||||
accessorKey: "ch4",
|
||||
Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: "N2O",
|
||||
accessorKey: "n2o",
|
||||
Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span>,
|
||||
},
|
||||
{
|
||||
header: t("Created Date"),
|
||||
accessorKey: "createdDate",
|
||||
Cell: ({ cell }) => (
|
||||
<span>
|
||||
{cell.getValue() ? new Date(cell.getValue()).toLocaleString() : "-"}
|
||||
</span>
|
||||
),
|
||||
sortable: true,
|
||||
},
|
||||
{ header: t("VM ID"), accessorKey: "vmId", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: t("VM Name"), accessorKey: "vmName", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: t("VM Power"), accessorKey: "vmPower", Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span> },
|
||||
{ header: t("VM Status"), accessorKey: "vmStatus", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: t("Total Emission"), accessorKey: "totalEmission", Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span> },
|
||||
{ header: t("Created Date"), accessorKey: "createdDate", Cell: ({ cell }) => (<span>{cell.getValue() ? new Date(cell.getValue()).toLocaleString() : "-"}</span>), sortable: true },
|
||||
{ header: t("Physical Machine"), accessorKey: "physicalMachine", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: t("Project"), accessorKey: "project", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: t("Data Center"), accessorKey: "dataCenter", Cell: ({ cell }) => <span>{cell.getValue() || "-"}</span> },
|
||||
{ header: "CO2", accessorKey: "co2", Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span> },
|
||||
{ header: "CH4", accessorKey: "ch4", Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span> },
|
||||
{ header: "N2O", accessorKey: "n2o", Cell: ({ cell }) => <span>{editNumbers(cell.getValue()) || "-"}</span> },
|
||||
];
|
||||
|
||||
const tableData = mainDataTablesStore?.mainDataTablesWithPaginate?.content || [];
|
||||
const tableData = mainDataTablesStore?.vmEmissionSummary || [];
|
||||
console.log('VM Emission data:', tableData);
|
||||
|
||||
if (error) {
|
||||
@@ -140,7 +87,7 @@ function MainDataTables() {
|
||||
pageIndex: 0
|
||||
},
|
||||
sorting: [
|
||||
{ id: 'dataCenter', desc: false }
|
||||
{ id: 'createdDate', desc: true }
|
||||
],
|
||||
density: 'compact'
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user