mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Export hosts to CSV with selected columns (#5841)
This commit is contained in:
parent
44eb7c1b3f
commit
b1028465e1
3 changed files with 29 additions and 4 deletions
1
changes/5168-export-hosts-to-csv
Normal file
1
changes/5168-export-hosts-to-csv
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Export hosts to csv with selected columns only.
|
||||
|
|
@ -1280,6 +1280,27 @@ const ManageHostsPage = ({
|
|||
) => {
|
||||
evt.preventDefault();
|
||||
|
||||
const hiddenColumnsStorage = localStorage.getItem("hostHiddenColumns");
|
||||
let currentHiddenColumns;
|
||||
let visibleColumns;
|
||||
if (hiddenColumnsStorage) {
|
||||
currentHiddenColumns = JSON.parse(hiddenColumnsStorage);
|
||||
}
|
||||
|
||||
if (config && currentUser) {
|
||||
const tableColumns = generateVisibleTableColumns(
|
||||
currentHiddenColumns,
|
||||
config,
|
||||
currentUser,
|
||||
currentTeam
|
||||
);
|
||||
|
||||
const columnAccessors = tableColumns
|
||||
.map((column) => (column.accessor ? column.accessor : ""))
|
||||
.filter((element) => element);
|
||||
visibleColumns = columnAccessors.join(",");
|
||||
}
|
||||
|
||||
let options = {
|
||||
selectedLabels: selectedFilters,
|
||||
globalFilter: searchQuery,
|
||||
|
|
@ -1288,6 +1309,7 @@ const ManageHostsPage = ({
|
|||
policyId,
|
||||
policyResponse,
|
||||
softwareId,
|
||||
visibleColumns,
|
||||
};
|
||||
|
||||
options = {
|
||||
|
|
@ -1500,9 +1522,6 @@ const ManageHostsPage = ({
|
|||
currentTeam
|
||||
);
|
||||
|
||||
const columnAccessors = tableColumns.map((column) => column.accessor);
|
||||
columnAccessors.shift();
|
||||
|
||||
return (
|
||||
<TableContainer
|
||||
columns={tableColumns}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export interface ILoadHostsOptions {
|
|||
softwareId?: number;
|
||||
device_mapping?: boolean;
|
||||
columns?: string;
|
||||
visibleColumns?: string;
|
||||
}
|
||||
|
||||
export type ILoadHostDetailsExtension = "device_mapping" | "macadmins";
|
||||
|
|
@ -61,7 +62,7 @@ export default {
|
|||
const policyId = options?.policyId || null;
|
||||
const policyResponse = options?.policyResponse || null;
|
||||
const softwareId = options?.softwareId || null;
|
||||
const columns = options?.columns || null;
|
||||
const visibleColumns = options?.visibleColumns || null;
|
||||
|
||||
let orderKeyParam = "";
|
||||
let orderDirection = "";
|
||||
|
|
@ -113,6 +114,10 @@ export default {
|
|||
path += `&software_id=${softwareId}`;
|
||||
}
|
||||
|
||||
if (visibleColumns) {
|
||||
path += `&columns=${visibleColumns}`;
|
||||
}
|
||||
|
||||
path += "&format=csv";
|
||||
|
||||
return sendRequest("GET", path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue