Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/data export #815

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b808620
updated exported file name
kasimhelil Jun 7, 2021
bfec355
Added export file name for search result
kasimhelil Jun 7, 2021
c3d5cf1
title case headers
kasimhelil Jun 7, 2021
ce3b95c
Remove export button if data export isn't required
kasimhelil Jun 7, 2021
c7a51a5
data export is not required on file download
kasimhelil Jun 7, 2021
4ce149a
added date comparator fxn for sorting date cols
kasimhelil Jun 9, 2021
950cbbb
Allow columns to accept sort fxn
kasimhelil Jun 9, 2021
0cb1419
used enums for file export name
kasimhelil Jun 9, 2021
061c47a
Simple string comparator fxn
kasimhelil Jun 9, 2021
9db6ff3
clean up grids' data so that they can be exported
kasimhelil Jun 9, 2021
24a0a3e
fixed missing export file name
kasimhelil Jun 10, 2021
97c8ed4
Merge branch 'dev' of https://github.com/US-CBP/GTAS-UI into fix/data…
kasimhelil Jun 10, 2021
f930780
Added flight and biographic info to exported data
kasimhelil Jun 13, 2021
c933fa5
Merge branch 'dev' of https://github.com/US-CBP/GTAS-UI into fix/data…
kasimhelil Jun 14, 2021
9c331cf
Renamed column headers
kasimhelil Jun 14, 2021
54a790d
Removed sortType from biographic info col
kasimhelil Jun 14, 2021
8670dc1
Added hits column to exported data
kasimhelil Jun 14, 2021
05c6006
disable data export from attachements grid
kasimhelil Jun 14, 2021
38ef98f
Merge branch 'dev' of https://github.com/US-CBP/GTAS-UI into fix/data…
kasimhelil Jun 15, 2021
459417a
Converted Boolean fields Yes/No and Number to txt
kasimhelil Jun 15, 2021
b408116
added dob, gender, direction to the exported data
kasimhelil Jun 16, 2021
59d0823
Merge branch 'dev' of https://github.com/US-CBP/GTAS-UI into fix/data…
kasimhelil Jun 21, 2021
b87675f
Merge branch 'dev' of https://github.com/US-CBP/GTAS-UI into fix/data…
kasimhelil Jul 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 71 additions & 70 deletions src/components/kanban/Kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Please see license.txt for details.

import React, {useEffect, useState} from "react";
import React, { useEffect, useState } from "react";
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
import CountdownBadge from "../../components/countdownBadge/CountdownBadge";
import { CardDeck, Col } from "react-bootstrap";
Expand All @@ -11,31 +11,30 @@ import { asArray, hasData } from "../../utils/utils";
import "./Kanban.css";
import { poe } from "../../services/serviceWrapper";
import Loading from "../../components/loading/Loading";
import {LK} from "../../utils/constants";
import { LK } from "../../utils/constants";
import ToolTipWrapper from "../tooltipWrapper/TooltipWrapper";

const Kanban = props => {
const [poeTiles, setPoeTiles] = useState([]);
const [showPending, setIsPending] = useState(false);


useEffect( () =>{
useEffect(() => {
const tiles = [];
const lanes = {};
if(hasData(props.tiles)){
asArray(props.tiles).map(tile =>{
if (hasData(props.tiles)) {
asArray(props.tiles).map(tile => {
tiles.push(createPOETile(tile)); //creates tile, adds to tile array
});
}
if(hasData(props.lanes)){
asArray(props.lanes).map(lane =>{
if (hasData(props.lanes)) {
asArray(props.lanes).map(lane => {
lanes[lane.ord] = createPOELane(lane, tiles); //creates lane, associates tile, adds to lane object
});
}
setColumns(lanes);
setPoeTiles(tiles);
setIsPending(false);
},[])
}, []);

const convertTileToData = (tile, status) => {
const req = {
Expand All @@ -57,15 +56,19 @@ const Kanban = props => {
content: (
<div>
<div className="font-weight-bolder">
<a href={"paxDetail/"+tileData.flightId + "/" + tileData.paxId}>{tileData.paxLastName}, {tileData.paxFirstName}</a>
<a href={"paxDetail/" + tileData.flightId + "/" + tileData.paxId}>
{tileData.paxLastName}, {tileData.paxFirstName}
</a>
</div>
<div>Flight #:
<div>
Flight #:
<ToolTipWrapper
data={{
val: tileData.flightNumber,
lkup: LK.CARRIER
}}
></ToolTipWrapper> </div>
></ToolTipWrapper>{" "}
</div>
<div> Doc #: {tileData.document.documentNumber}</div>
<div>Reason: {tileData.hitCategory}</div>
<div>&nbsp;</div>
Expand Down Expand Up @@ -145,65 +148,63 @@ const Kanban = props => {

return (
<>
{(props.isLoading || showPending) && <Loading></Loading>}
<CardDeck className="poe-page-deck">
<DragDropContext onDragEnd={result => onDragEnd(result, columns, setColumns)}>
{Object.entries(columns).map(([columnId, column], index) => {
return (
<div className="poe-drag-drop"
key={columnId}
>
<h5>{column.name}</h5>
<div className="poe-droppable-div">
<Droppable droppableId={columnId} key={columnId}>
{(provided, snapshot) => {
return (
<div
{...provided.droppableProps}
ref={provided.innerRef}
className="poe-droppable"
style={{
background: snapshot.isDraggingOver
? column.dragbackground
: column.background,
}}
>
{column.items.map((item, index) => {
return (
<Draggable
key={item.id}
draggableId={item.id}
index={index}
>
{(provided, snapshot) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
className="poe-draggable"
style={{
...provided.draggableProps.style,
}}
>
{item.content}
</div>
);
}}
</Draggable>
);
})}
{provided.placeholder}
</div>
);
}}
</Droppable>
</div>
{(props.isLoading || showPending) && <Loading></Loading>}
<CardDeck className="poe-page-deck">
<DragDropContext onDragEnd={result => onDragEnd(result, columns, setColumns)}>
{Object.entries(columns).map(([columnId, column], index) => {
return (
<div className="poe-drag-drop" key={columnId}>
<h5>{column.name}</h5>
<div className="poe-droppable-div">
<Droppable droppableId={columnId} key={columnId}>
{(provided, snapshot) => {
return (
<div
{...provided.droppableProps}
ref={provided.innerRef}
className="poe-droppable"
style={{
background: snapshot.isDraggingOver
? column.dragbackground
: column.background
}}
>
{column.items.map((item, index) => {
return (
<Draggable
key={item.id}
draggableId={item.id}
index={index}
>
{(provided, snapshot) => {
return (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
className="poe-draggable"
style={{
...provided.draggableProps.style
}}
>
{item.content}
</div>
);
}}
</Draggable>
);
})}
{provided.placeholder}
</div>
);
}}
</Droppable>
</div>
);
})}
</DragDropContext>
</CardDeck>
</div>
);
})}
</DragDropContext>
</CardDeck>
</>
);
};
Expand Down
33 changes: 24 additions & 9 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,16 @@ const Table = props => {
</option>
))}
</select>
<Button
className="export-btn"
variant="light"
size="sm"
onClick={() => exportData("csv", true)}
>
{<Xl8 xid="tab004">Export</Xl8>}
</Button>
{!props.disableTableDataExport && (
<Button
className="export-btn"
variant="light"
size="sm"
onClick={() => exportData("csv", true)}
>
{<Xl8 xid="tab004">Export</Xl8>}
</Button>
)}
<span className="tagrightpag">
<h3 className="title-default">
<i>{isPopulated ? rows.length : 0}</i>
Expand Down Expand Up @@ -404,6 +406,18 @@ const Table = props => {
cellconfig.Filter = BooleanFilter;
}

if (element.sortType !== undefined) {
cellconfig.sortType = element.sortType;
}
//Overrides the cell values
if (element.getCellExportValue !== undefined) {
cellconfig.getCellExportValue = element.getCellExportValue;
}
//Override the column headr
if (element.getColumnExportValue !== undefined) {
cellconfig.getColumnExportValue = element.getColumnExportValue;
}

columns.push(cellconfig);
}
});
Expand Down Expand Up @@ -463,7 +477,8 @@ Table.propTypes = {
stateVals: PropTypes.func,
ignoredFields: PropTypes.arrayOf(PropTypes.string),
enableColumnFilter: PropTypes.bool,
exportFileName: PropTypes.string
exportFileName: PropTypes.string,
sortType: PropTypes.func
};

export default Table;
3 changes: 2 additions & 1 deletion src/components/table/table-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Please see license.txt for details.
import React from "react";
import { jsonToCSV } from "react-papaparse";
import { titleCase } from "../../utils/utils";

export const ColumnFilter = ({ column: { filterValue, setFilter } }) => {
return (
Expand Down Expand Up @@ -34,7 +35,7 @@ export const BooleanFilter = ({ column: { filterValue, setFilter } }) => {

export const getExportFileBlob = ({ columns, data, fileType, fileName }) => {
if (fileType === "csv") {
const headerNames = columns.map(col => col.exportValue);
const headerNames = columns.map(col => titleCase(col.exportValue));
const csvString = jsonToCSV({ fields: headerNames, data });
return new Blob([csvString], { type: "text/csv" });
}
Expand Down
18 changes: 15 additions & 3 deletions src/pages/admin/auditLog/AuditLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import SidenavContainer from "../../../components/sidenavContainer/SidenavContai
import FilterForm from "../../../components/filterForm2/FilterForm";
import LabelledInput from "../../../components/labelledInput/LabelledInput";
import Main from "../../../components/main/Main";
import { addMinutes, asArray, localeDateWithSeconds } from "../../../utils/utils";
import {
addMinutes,
asArray,
dateComparator,
localeDateWithSeconds
} from "../../../utils/utils";
import { EXPORTFILENAME } from "../../../utils/constants";

const AuditLog = ({ name }) => {
const cb = () => {};
Expand Down Expand Up @@ -97,12 +103,17 @@ const AuditLog = ({ name }) => {
Accessor: "timestamp",
Xl8: true,
Header: ["al009", "Timestamp"],
Cell: ({ row }) => localeDateWithSeconds(row.original.timestamp)
sortType: (row1, row2) =>
dateComparator(row1.original.timestamp, row2.original.timestamp)
}
];

const setDataWrapper = res => {
setData(res);
const parsedData = asArray(res).map(log => {
return { ...log, timestamp: localeDateWithSeconds(log.timestamp) };
});

setData(parsedData);
setRefreshKey(refreshKey + 1);
setIsLoading(false);
};
Expand Down Expand Up @@ -171,6 +182,7 @@ const AuditLog = ({ name }) => {
callback={cb}
header={headers}
isLoading={isLoading}
exportFileName={EXPORTFILENAME.AUDITLOG}
></Table>
</Main>
</>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/admin/codeEditor/airport/Airport.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AirportModal from "./AirportModal";
import ConfirmationModal from "../../../../components/confirmationModal/ConfirmationModal";
import { codeEditor } from "../../../../services/lookupService";
import { LookupContext } from "../../../../context/data/LookupContext";
import { ACTION, LK } from "../../../../utils/constants";
import { ACTION, EXPORTFILENAME, LK } from "../../../../utils/constants";
import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";

Expand Down Expand Up @@ -103,6 +103,7 @@ const Airports = () => {
Xl8: true,
Header: ["edit001", "Edit"],
disableFilters: true,
disableExport: true,
disableSortBy: true,
Cell: ({ row }) => {
return (
Expand Down Expand Up @@ -149,6 +150,7 @@ const Airports = () => {
header={headers}
key={refreshKey}
enableColumnFilter={true}
exportFileName={EXPORTFILENAME.CODEEDITOR.AIRPORT}
></Table>
<Fab icon={<i className="fa fa-plus" />} variant="info">
<Action
Expand Down
12 changes: 10 additions & 2 deletions src/pages/admin/codeEditor/carrier/Carrier.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import CarrierModal from "./CarrierModal";
import ConfirmationModal from "../../../../components/confirmationModal/ConfirmationModal";
import { codeEditor } from "../../../../services/lookupService";
import { LookupContext } from "../../../../context/data/LookupContext";
import { ACTION, LK } from "../../../../utils/constants";
import { ACTION, EXPORTFILENAME, LK } from "../../../../utils/constants";
import { Fab, Action } from "react-tiny-fab";
import "react-tiny-fab/dist/styles.css";
import { getNumberExportValue } from "../../../../utils/utils";

const Carriers = () => {
const cb = function() {};
Expand Down Expand Up @@ -101,6 +102,7 @@ const Carriers = () => {
Header: ["edit001", "Edit"],
disableFilters: true,
disableSortBy: true,
disableExport: true,
Cell: ({ row }) => {
return (
<div className="icon-col">
Expand All @@ -112,7 +114,12 @@ const Carriers = () => {
);
}
},
{ Accessor: "iata", Xl8: true, Header: ["iata001", "IATA"] },
{
Accessor: "iata",
Xl8: true,
Header: ["iata001", "IATA"],
getCellExportValue: row => getNumberExportValue(row.original.iata)
},
{ Accessor: "icao", Xl8: true, Header: ["icao001", "ICAO"] },
{ Accessor: "name", Xl8: true, Header: ["car005", "Name"] }
];
Expand Down Expand Up @@ -142,6 +149,7 @@ const Carriers = () => {
header={headers}
key={refreshKey}
enableColumnFilter={true}
exportFileName={EXPORTFILENAME.CODEEDITOR.CARRIER}
></Table>
<Fab icon={<i className="fa fa-plus" />} variant="info">
<Action
Expand Down
Loading