Skip to content

Commit 3ba4206

Browse files
committed
Fix geodataset append and update backward compatibility
1 parent 464a57a commit 3ba4206

File tree

4 files changed

+342
-82
lines changed

4 files changed

+342
-82
lines changed

API/Backend/Geodatasets/models/geodatasets.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ function makeNewGeodatasetTable(
109109
Geodatasets.findOne({ where: { name: name } })
110110
.then((result) => {
111111
if (result) {
112+
// Ignore some columns if they're unused/nonexistent
113+
if (result.dataValues.start_time_field == null)
114+
delete attributes.start_time;
115+
if (result.dataValues.end_time_field == null)
116+
delete attributes.end_time;
117+
if (result.dataValues.group_id_field == null)
118+
delete attributes.group_id;
119+
if (result.dataValues.feature_id_field == null)
120+
delete attributes.feature_id;
121+
112122
let GeodatasetTable = sequelize.define(
113123
result.dataValues.table,
114124
attributes,

API/logger.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,44 @@ const logger = function (level, message, caller, req, err) {
4545
user: req && req.user ? req.user : "HOST",
4646
};
4747

48-
let crop = 512;
49-
if (req && req.body) {
50-
let cleanBody = JSON.parse(JSON.stringify(req.body));
51-
if (cleanBody.password) {
52-
cleanBody.password = "_redacted_";
48+
try {
49+
let crop = 512;
50+
if (req && req.body) {
51+
let cleanBody = JSON.parse(JSON.stringify(req.body));
52+
if (cleanBody.password) {
53+
cleanBody.password = "_redacted_";
54+
}
55+
for (let k in cleanBody) {
56+
if (JSON.stringify(cleanBody[k]).length > crop)
57+
cleanBody[k] = "[Too Long...]";
58+
}
59+
if (Object.keys(cleanBody).length > 0) {
60+
log.req = log.req || {};
61+
log.req.body = cleanBody;
62+
}
5363
}
54-
for (let k in cleanBody) {
55-
if (JSON.stringify(cleanBody[k]).length > crop)
56-
cleanBody[k] = "[Too Long...]";
64+
if (req && req.query) {
65+
let cleanQuery = JSON.parse(JSON.stringify(req.query));
66+
if (cleanQuery.password) {
67+
cleanQuery.password = "_redacted_";
68+
}
69+
for (let k in cleanQuery) {
70+
if (JSON.stringify(cleanQuery[k]).length > crop)
71+
cleanQuery[k] = "[Too Long...]";
72+
}
73+
if (Object.keys(cleanQuery).length > 0) {
74+
log.req = log.req || {};
75+
log.req.query = cleanQuery;
76+
}
5777
}
58-
if (Object.keys(cleanBody).length > 0) {
59-
log.req = log.req || {};
60-
log.req.body = cleanBody;
78+
if (err) {
79+
log.err = err;
6180
}
62-
}
63-
if (req && req.query) {
64-
let cleanQuery = JSON.parse(JSON.stringify(req.query));
65-
if (cleanQuery.password) {
66-
cleanQuery.password = "_redacted_";
67-
}
68-
for (let k in cleanQuery) {
69-
if (JSON.stringify(cleanQuery[k]).length > crop)
70-
cleanQuery[k] = "[Too Long...]";
71-
}
72-
if (Object.keys(cleanQuery).length > 0) {
73-
log.req = log.req || {};
74-
log.req.query = cleanQuery;
75-
}
76-
}
77-
if (err) {
78-
log.err = err;
79-
}
8081

81-
log = JSON.stringify(log);
82+
log = JSON.stringify(log);
83+
} catch (err2) {
84+
log.err = err2;
85+
}
8286

8387
if (process.env.NODE_ENV === "development") {
8488
switch (level) {

configure/src/pages/GeoDatasets/Modals/AppendGeoDatasetModal/AppendGeoDatasetModal.js

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const useStyles = makeStyles((theme) => ({
4545
contents: {
4646
background: theme.palette.primary.main,
4747
height: "100%",
48-
width: "700px",
49-
maxWidth: "700px !important",
48+
width: "1200px",
49+
maxWidth: "1200px !important",
5050
},
5151
heading: {
5252
height: theme.headHeights[2],
@@ -133,7 +133,7 @@ const useStyles = makeStyles((theme) => ({
133133
"& > p:first-child": { fontWeight: "bold", letterSpacing: "1px" },
134134
"& > p:last-child": { fontSize: "14px", fontStyle: "italic" },
135135
},
136-
timeFields: {
136+
fields: {
137137
display: "flex",
138138
"& > div:first-child": {
139139
marginRight: "5px",
@@ -187,13 +187,17 @@ const AppendGeoDatasetModal = (props) => {
187187
const [fileName, setFileName] = useState(null);
188188
const [startTimeField, setStartTimeField] = useState(null);
189189
const [endTimeField, setEndTimeField] = useState(null);
190+
const [groupIdField, setGroupIdField] = useState(null);
191+
const [featureIdField, setFeatureIdField] = useState(null);
190192
const [fileProgress, setFileProgress] = useState(false);
191193
const [progress, setProgress] = useState(false);
192194
const [progressPercent, setProgressPercent] = useState(false);
193195

194196
useEffect(() => {
195197
setStartTimeField(modal?.geoDataset?.start_time_field);
196198
setEndTimeField(modal?.geoDataset?.end_time_field);
199+
setGroupIdField(modal?.geoDataset?.group_id_field);
200+
setFeatureIdField(modal?.geoDataset?.feature_id_field);
197201
}, [JSON.stringify(modal)]);
198202

199203
const handleClose = () => {
@@ -455,19 +459,20 @@ const AppendGeoDatasetModal = (props) => {
455459
<div>{fileName || "No File Selected"}</div>
456460
</div>
457461

458-
<div className={c.timeFields}>
462+
<div className={c.fields}>
459463
<div>
460464
<TextField
461465
className={c.missionNameInput}
462466
label="Start Time Field"
463467
variant="filled"
464468
value={startTimeField}
469+
disabled
465470
onChange={(e) => {
466471
setStartTimeField(e.target.value);
467472
}}
468473
/>
469474
<Typography className={c.subtitle2}>
470-
{`If this GeoDataset already has a Start Time Field attached, the name of that start time field inside each feature's "properties" object for which to create a temporal index for the geodataset. Take care in using time field names for the appended GeoJSON features that are different from that of the existing features.`}
475+
{`The name of a start time field inside each feature's "properties" object for which to create a temporal index for the geodataset. This enables time queries on GeoDatasets.`}
471476
</Typography>
472477
</div>
473478
<div>
@@ -476,12 +481,45 @@ const AppendGeoDatasetModal = (props) => {
476481
label="End Time Field"
477482
variant="filled"
478483
value={endTimeField}
484+
disabled
479485
onChange={(e) => {
480486
setEndTimeField(e.target.value);
481487
}}
482488
/>
483489
<Typography className={c.subtitle2}>
484-
{`If this GeoDataset already has a End Time Field attached, the name of that end time field inside each feature's "properties" object for which to create a temporal index for the geodataset. Take care in using time field names for the appended GeoJSON features that are different from that of the existing features.`}
490+
{`The name of an end time field inside each feature's "properties" object for which to create a temporal index for the geodataset. This enables time queries on GeoDatasets.`}
491+
</Typography>
492+
</div>
493+
</div>
494+
<div className={c.fields}>
495+
<div>
496+
<TextField
497+
className={c.missionNameInput}
498+
label="Group Id Field"
499+
variant="filled"
500+
value={groupIdField}
501+
disabled
502+
onChange={(e) => {
503+
setGroupIdField(e.target.value);
504+
}}
505+
/>
506+
<Typography className={c.subtitle2}>
507+
{`The name of a field inside each feature's "properties" object to serve as a group id. This field cannot be changed after the GeoDataset is created.`}
508+
</Typography>
509+
</div>
510+
<div>
511+
<TextField
512+
className={c.missionNameInput}
513+
label="Feature Id Field"
514+
variant="filled"
515+
value={featureIdField}
516+
disabled
517+
onChange={(e) => {
518+
setFeatureIdField(e.target.value);
519+
}}
520+
/>
521+
<Typography className={c.subtitle2}>
522+
{`The name of a field inside each feature's "properties" object to serve as a feature id. This field cannot be changed after the GeoDataset is created.`}
485523
</Typography>
486524
</div>
487525
</div>

0 commit comments

Comments
 (0)