Skip to content

Commit

Permalink
Use .NET API for editing stratigraphies
Browse files Browse the repository at this point in the history
  • Loading branch information
danjov committed Jan 10, 2024
1 parent dc3bfdc commit 0827e2f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 264 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Updated layer management to use the .NET API.
- Update stratigraphy management to use the .NET API.

## v2.0.506 - 2023-12-21

Expand Down
1 change: 0 additions & 1 deletion src/api-legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

# Profiles's ACTION Handlers
from bms.v1.borehole.profile.viewer import ProfileViewerHandler
from bms.v1.borehole.profile.producer import ProfileProducerHandler

# Profiles layers's ACTION Handlers
from bms.v1.borehole.profile.layer.viewer import ProfileLayerViewerHandler
Expand Down
3 changes: 0 additions & 3 deletions src/api-legacy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ async def close(application):

# Profile handlers
ProfileViewerHandler,
ProfileProducerHandler,

# Layer handlers
ProfileLayerViewerHandler,
Expand Down Expand Up @@ -221,11 +220,9 @@ async def close(application):

# Profile handlers
(r'/api/v1/borehole/profile', ProfileViewerHandler),
(r'/api/v1/borehole/profile/edit', ProfileProducerHandler),

# Profile Layer handlers
(r'/api/v1/borehole/profile/layer', ProfileLayerViewerHandler),
(r'/api/v1/borehole/profile/layer/edit', ProfileProducerHandler),

# Other handlers
(r'/api/v1/borehole/codes', CodeListHandler),
Expand Down
190 changes: 0 additions & 190 deletions src/api-legacy/v1/borehole/profile/patch.py

This file was deleted.

49 changes: 0 additions & 49 deletions src/api-legacy/v1/borehole/profile/producer.py

This file was deleted.

8 changes: 1 addition & 7 deletions src/client/src/api-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ import {
getLayers,
} from "./actions/stratigraphy";

import {
getProfile,
getProfiles,
getProfileLayers,
patchProfile,
} from "./actions/profile";
import { getProfile, getProfiles, getProfileLayers } from "./actions/profile";

import { loadDomains, patchCodeConfig } from "./actions/domains";

Expand Down Expand Up @@ -167,7 +162,6 @@ export {
getProfile,
getProfiles,
getProfileLayers,
patchProfile,
loadDomains,
patchCodeConfig,
getWms,
Expand Down
12 changes: 12 additions & 0 deletions src/client/src/api/fetchApiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export const deleteFaciesDescription = async id => {
export const fetchUsers = async () => await fetchApiV2("user", "GET");

// stratigraphy
export const fetchStratigraphy = async id => {
return await fetchApiV2(`stratigraphy/${id}`, "GET");
};

export const copyStratigraphy = async id => {
return await fetchApiV2(`stratigraphy/copy?id=${id}`, "POST");
};
Expand All @@ -190,6 +194,14 @@ export const addBedrock = async id => {
return await fetchApiV2(`stratigraphy/addbedrock?id=${id}`, "POST");
};

export const updateStratigraphy = async stratigraphy => {
// remove derived objects
delete stratigraphy.createdBy;
delete stratigraphy.updatedBy;

return await fetchApiV2("stratigraphy", "PUT", stratigraphy);
};

// Enable using react-query outputs across the application.

// eslint-disable-next-line react-hooks/rules-of-hooks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { getProfile, patchProfile } from "../../../../../../api-lib/index";
import { getProfile } from "../../../../../../api-lib/index";
import {
fetchStratigraphy,
updateStratigraphy,
} from "../../../../../../api/fetchApiV2";

let data = [];
export const getData = async id => {
Expand All @@ -17,19 +21,20 @@ export const getData = async id => {
return data;
};

let isSendProfile = false;
export const sendProfile = async (id, attribute, value) => {
await patchProfile(id, attribute, value)
.then(response => {
if (response.data.success) {
isSendProfile = true;
} else {
alert(response.data.message);
}
})
.catch(function (error) {
console.error(error);
});
let success = false;
await fetchStratigraphy(id).then(async stratigraphy => {
if (stratigraphy) {
stratigraphy[attribute] = value;
await updateStratigraphy(stratigraphy).then(response => {
if (response) {
success = true;
}
});
} else {
alert("Failed to get stratigraphy data for update.");
}
});

return isSendProfile;
return success;
};

0 comments on commit 0827e2f

Please sign in to comment.