diff --git a/app/src/components/Map.js b/app/src/components/Map.js
index 8ea5849f..63d4d1b5 100644
--- a/app/src/components/Map.js
+++ b/app/src/components/Map.js
@@ -19,16 +19,14 @@ import {
Divider,
Icon as SIcon,
Loader as SLoader,
- PlaceholderLine,
- TableBody,
TableCell,
TableFooter,
- TableHeader,
TableHeaderCell,
TableRow
} from "semantic-ui-react";
+import {SortableTable} from "./SortableTable";
import Message from "semantic-ui-react/dist/commonjs/collections/Message";
-import {Header, Loader, Placeholder, Segment, Table} from "./Theme";
+import {Header, Loader, Segment} from "./Theme";
import {StatusContext} from "../contexts/contexts";
import _ from "lodash";
import {MAP_VIEWER_URI} from "./Vars";
@@ -178,34 +176,6 @@ class ManageMap extends React.Component {
this.setState({selectedPaths});
}
- tableRow = (pbf, disabled) => {
- let ref = React.createRef();
- const {size, path, imported, time_to_import} = pbf;
- let sizeCells = (<>
- {humanFileSize(size)}
- {humanFileSize(size * 25)}
- {time_to_import}
- >);
- return
-
- this.handleCheckbox(data.checked, pbf)}
- />
-
-
- {path}
-
-
- {this.state.pending && this.state.pending.indexOf(path) >= 0 ?
- :
- imported ? 'yes' : 'no'}
-
- {size !== null ? sizeCells : }
-
- }
-
render() {
const {files, selectedPaths, import_running, pending, dockerized} = this.state;
@@ -222,33 +192,72 @@ class ManageMap extends React.Component {
{!_.isEmpty(selectedPaths) ? 'Import Selected' : 'Import All'}
;
- let rows =
-
-
-
-
-
-
-
- ;
- if (files && files.length === 0) {
- rows =
- No PBF map files were found in map/pbf
- ;
- } else if (files && files.length >= 1) {
- rows = files.map(i => this.tableRow(i, disabled));
- } else if (files === undefined) {
- rows =
-
- Could not fetch map files
-
-
- }
-
let spaceInfoPopup = ;
let timeInfoPopup = ;
+ const tableHeaders = [
+ {key: 'select', text: '', sortBy: null},
+ {key: 'path', text: 'PBF File', sortBy: i => i.path.toLowerCase()},
+ {key: 'imported', text: 'Imported', sortBy: i => i.imported ? 1 : 0},
+ {key: 'size', text: 'Size', sortBy: i => i.size || 0},
+ {key: 'space', text: <>Space Required {spaceInfoPopup}>, sortBy: i => i.size || 0},
+ {key: 'time', text: <>Time to Import {timeInfoPopup}>, sortBy: i => i.seconds_to_import || 0},
+ ];
+
+ const rowFunc = (pbf) => {
+ let ref = React.createRef();
+ const {size, path, imported, time_to_import} = pbf;
+ let sizeCells = (<>
+ {humanFileSize(size)}
+ {humanFileSize(size * 25)}
+ {time_to_import}
+ >);
+ return
+
+ this.handleCheckbox(data.checked, pbf)}
+ />
+
+
+ {path}
+
+
+ {pending && pending.indexOf(path) >= 0 ?
+ :
+ imported ? 'yes' : 'no'}
+
+ {size !== null ? sizeCells : }
+ ;
+ };
+
+ const emptyRow =
+ No PBF map files were found in map/pbf
+ ;
+
+ const footer =
+
+
+
+ {importButton}
+
+
+ ;
+
+ // Handle error state (files === undefined)
+ if (files === undefined) {
+ return
+
+
+
+ Could not fetch map files
+
+
+ ;
+ }
+
return
@@ -256,29 +265,15 @@ class ManageMap extends React.Component {
{importingMessage}
-
-
-
-
- PBF File
- Imported
- Size
- Space Required {spaceInfoPopup}
- Time to Import {timeInfoPopup}
-
-
-
- {rows}
-
-
-
-
-
- {importButton}
-
-
-
-
+