Skip to content

Commit

Permalink
#464 Early Geodatasets
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed May 20, 2024
1 parent bd69188 commit e46b87f
Show file tree
Hide file tree
Showing 5 changed files with 456 additions and 8 deletions.
52 changes: 47 additions & 5 deletions API/Backend/Geodatasets/routes/geodatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const router = express.Router();
const { sequelize } = require("../../../connection");

const logger = require("../../../logger");
const Utils = require("../../../utils");
const geodatasets = require("../models/geodatasets");
const Geodatasets = geodatasets.Geodatasets;
const makeNewGeodatasetTable = geodatasets.makeNewGeodatasetTable;
Expand Down Expand Up @@ -206,10 +207,51 @@ router.post("/entries", function (req, res, next) {
for (let i = 0; i < sets.length; i++) {
entries.push({ name: sets[i].name, updated: sets[i].updatedAt });
}
res.send({
status: "success",
body: { entries: entries },
});
// For each entry, list all occurrences in latest configuration objects
sequelize
.query(
"SELECT DISTINCT ON (mission) mission, version, config FROM configs ORDER BY mission ASC"
)
.then(([results]) => {
// Populate occurrences
results.forEach((m) => {
Utils.traverseLayers([m.config.layers], (layer, path) => {
entries.forEach((entry) => {
entry.occurrences = entry.occurrences || {};
entry.occurrences[m.mission] =
entry.occurrences[m.mission] || [];

if (layer.url === `geodatasets:${entry.name}`) {
entry.occurrences[m.mission].push({
name: layer.name,
uuid: layer.uuid,
path: path,
});
}
});
});
});

res.send({
status: "success",
body: { entries: entries },
});
return null;
})
.catch((err) => {
logger(
"error",
"Failed to find missions.",
req.originalUrl,
req,
err
);
res.send({
status: "failure",
message: "Failed to find missions.",
});
return null;
});
} else {
res.send({
status: "failure",
Expand Down Expand Up @@ -330,7 +372,7 @@ router.post("/recreate", function (req, res, next) {
}

let drop_qry = "TRUNCATE TABLE " + result.table + " RESTART IDENTITY";
if (req.body.hasOwnProperty("action") && req.body.action=="append") {
if (req.body.hasOwnProperty("action") && req.body.action == "append") {
drop_qry = "";
}

Expand Down
4 changes: 4 additions & 0 deletions configure/src/components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Time from "../Tabs/Time/Time";
import UserInterface from "../Tabs/UserInterface/UserInterface";

import APITokens from "../../pages/APITokens/APITokens";
import GeoDatasets from "../../pages/GeoDatasets/GeoDatasets";

const useStyles = makeStyles((theme) => ({
Main: {
Expand Down Expand Up @@ -126,6 +127,9 @@ export default function Main() {

let Page = null;
switch (page) {
case "geodatasets":
Page = <GeoDatasets />;
break;
case "api_tokens":
Page = <APITokens />;
break;
Expand Down
6 changes: 3 additions & 3 deletions configure/src/components/Panel/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default function Panel() {
disableElevation
startIcon={<ShapeLineIcon size="small" />}
onClick={() => {
dispatch(setModal({ name: "newMission" }));
dispatch(setPage({ page: "geodatasets" }));
}}
>
GeoDatasets
Expand All @@ -173,7 +173,7 @@ export default function Panel() {
disableElevation
startIcon={<TextSnippetIcon size="small" />}
onClick={() => {
dispatch(setModal({ name: "newMission" }));
dispatch(setPage({ page: "newMission" }));
}}
>
Datasets
Expand All @@ -195,7 +195,7 @@ export default function Panel() {
disableElevation
startIcon={<PhishingIcon size="small" />}
onClick={() => {
dispatch(setModal({ name: "newMission" }));
dispatch(setPage({ page: "newMission" }));
}}
>
WebHooks
Expand Down
5 changes: 5 additions & 0 deletions configure/src/core/ConfigureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const ConfigureStore = createSlice({
mission: null,
configuration: "{}",
toolConfiguration: {},
geodatasets: [],
page: null,
modal: {
newMission: false,
Expand All @@ -31,6 +32,9 @@ export const ConfigureStore = createSlice({
setToolConfiguration: (state, action) => {
state.toolConfiguration = action.payload;
},
setGeodatasets: (state, action) => {
state.geodatasets = action.payload;
},
setPage: (state, action) => {
state.page = action.payload.page;
},
Expand Down Expand Up @@ -66,6 +70,7 @@ export const {
setMission,
setConfiguration,
setToolConfiguration,
setGeodatasets,
setPage,
setModal,
setSnackBarText,
Expand Down
Loading

0 comments on commit e46b87f

Please sign in to comment.