Skip to content

Commit

Permalink
Merge pull request #404 from kbss-cvut/feature/add-api-to-update-syst…
Browse files Browse the repository at this point in the history
…em-op-data-filter

Implement call to server api update operational data filter
  • Loading branch information
blcham authored Jun 12, 2024
2 parents 5487fd9 + 5fa79bc commit 11c9508
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/services/systemService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { extractFragment } from "@services/utils/uriIdentifierUtils";
import { deepOmit } from "@utils/lodashUtils";
import { handleServerError } from "@services/utils/responseUtils";
import { FailureMode } from "@models/failureModeModel";
import { OperationalDataFilter, CONTEXT as FILTER_CONTEXT } from "@models/operationalDataFilterModel";

export const findAll = async (): Promise<System[]> => {
try {
Expand Down Expand Up @@ -70,6 +71,26 @@ export const rename = async (system: System): Promise<System> => {
}
};

export const updateFilter = async (
systemUri: string,
operationDataFilter: OperationalDataFilter,
): Promise<OperationalDataFilter> => {
try {
const systemFragment = extractFragment(systemUri);
const updateRequest = Object.assign({}, operationDataFilter, { "@context": FILTER_CONTEXT });

const response = await axiosClient.put(`/operational-data-filter/system/${systemFragment}`, updateRequest, {
headers: authHeaders(),
});

return JsonLdUtils.compactAndResolveReferences<OperationalDataFilter>(response.data, FILTER_CONTEXT);
} catch (e) {
console.log("System Service - Failed to call /operational-data-filter/system/${systemFragment}");
const defaultMessage = "Failed to operational data filter";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
}
};

export const remove = async (systemIri: string): Promise<void> => {
try {
const fragment = extractFragment(systemIri);
Expand Down

0 comments on commit 11c9508

Please sign in to comment.