(
+ Boolean(config.data.metadata && !config.loading && !config.error.has)
+ );
+
+ useEffect(() => {
+ if (!configPresent) {
+ setConfigPresent(true);
+ dispatch(
+ getPartialConfigAsync(configNum === "latest" ? undefined : Number(configNum))
+ );
+ }
+ const appNum =
+ (config.data.config.locationRules ? Object.keys(config.data.config.locationRules).length : 0) +
+ (config.data.config.samlSPMetaDataXML
+ ? Object.keys(config.data.config.samlSPMetaDataXML).length
+ : 0) +
+ (config.data.config.oidcRPMetaDataOptions
+ ? Object.keys(config.data.config.oidcRPMetaDataOptions).length
+ : 0) +
+ (config.data.config.casAppMetaDataOptions
+ ? Object.keys(config.data.config.casAppMetaDataOptions).length
+ : 0);
+ if (appNum === 1) {
+ const name = config.data.config.locationRules || config.data.config.samlSPMetaDataXML || config.data.config.oidcRPMetaDataOptions || config.data.config.casAppMetaDataOptions
+ const type = config.data.config.locationRules ? "native" : false || config.data.config.samlSPMetaDataXML ? "SPsaml" : false || config.data.config.oidcRPMetaDataOptions ? "RPoidc" : false || config.data.config.casAppMetaDataOptions ? "AppCas" : false
+ console.log(Object.keys(name ? name : {})[0])
+ dispatch(push(`#app/${type}/${Object.keys(name ? name : {})[0]}`))
+ }
+ }, [dispatch, configNum, config.data.metadata, location, configPresent]);
+ try {
+ if (config.loading) {
+ return (
+
+ {t("currentConfiguration")}
+ {t("loading")}
+
+ );
+ } else if (config.error.has) {
+ return (
+
+ {t("currentConfiguration")}
+ {t("failedLoading")}
+ {config.error.errorContent}
+
+ );
+ } else {
+ const renderedData: JSX.Element[] = [];
+ if (config.data.config.locationRules) {
+ renderedData.push(
+ ...Object.keys(config.data.config.locationRules).map((key) => (
+
+ ))
+ );
+ }
+ if (config.data.config.samlSPMetaDataXML) {
+ renderedData.push(
+ ...Object.keys(config.data.config.samlSPMetaDataXML).map((key) => (
+
+ ))
+ );
+ }
+ if (config.data.config.oidcRPMetaDataOptions) {
+ renderedData.push(
+ ...Object.keys(config.data.config.oidcRPMetaDataOptions).map(
+ (key) => (
+
+ )
+ )
+ );
+ }
+ if (config.data.config.casAppMetaDataOptions) {
+ renderedData.push(
+ ...Object.keys(config.data.config.casAppMetaDataOptions).map(
+ (key) => (
+
+ )
+ )
+ );
+ }
+ renderedData.filter((el) => {
+ return String(el.props.info.name).includes(filters.search);
+ });
+
+ if (filters.alpha) {
+ renderedData.sort((el1, el2) =>
+ el1.props.info.name > el2.props.info.name ? 1 : -1
+ );
+ }
+ const pageLimit = 12;
+ const pageNb = Math.ceil(renderedData.length / pageLimit);
+ const pages = Array.from(
+ { length: Math.ceil(renderedData.length / pageLimit) },
+ (v, i) => renderedData.slice(i * pageLimit, i * pageLimit + pageLimit)
+ );
+ const handleChangePage = (event: ChangeEvent, value: number) => {
+ setPage(value);
+ };
+
+ return (
+ <>
+ {t("currentConfiguration")}
+
+ {false && }
+ {false && }
+
+
+ {pages[page - 1]}
+
+
+ >
+ );
+ }
+ } catch (e) {
+ console.debug(e);
+ if (e instanceof Error) {
+ dispatch(setError(`${e.name} : ${e.message}`));
+ dispatch(removeError());
+ }
+ return {config.error.errorContent}
;
+ }
+}
diff --git a/src/features/config/configAPI.ts b/src/features/config/configAPI.ts
index 77c841a..9025c7c 100644
--- a/src/features/config/configAPI.ts
+++ b/src/features/config/configAPI.ts
@@ -1,9 +1,10 @@
-import axios from "axios";
import { llngConfig } from "../../utils/types";
+const baseUrl = "http://manager.example.com:19876"
+
export function getMetadataConfig(num?: number) {
try {
- const response = axios.get(`/confs/${num ? num : "latest"}`);
+ const response = window.fetch(`${baseUrl}/confs/${num ? num : "latest"}`);
return response;
} catch (error) {
// console.error(error)
@@ -13,7 +14,16 @@ export function getMetadataConfig(num?: number) {
export function getConfig(num: number) {
try {
- const response = axios.get(`/manager.fcgi/confs/${num}?full=1`);
+ const response = window.fetch(`${baseUrl}/manager.fcgi/confs/${num}?full=1`);
+ return response;
+ } catch (error) {
+ throw new Error(JSON.stringify(error));
+ }
+}
+
+export function getPartialConfig(num: number) {
+ try {
+ const response = window.fetch(`${baseUrl}/partial`);
return response;
} catch (error) {
throw new Error(JSON.stringify(error));
@@ -22,9 +32,34 @@ export function getConfig(num: number) {
export function saveConfig(config: llngConfig) {
try {
- const response = axios.post("/manager.fcgi/confs/raw", config);
+
+ const response = window.fetch(`${baseUrl}/manager.fcgi/confs/raw`,
+ {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(config),
+ // credentials: "include"
+ });
+ return response;
+ } catch (error) {
+ console.log(error)
+ throw new Error(JSON.stringify(error));
+ }
+}
+
+export function savePartialConfig(config: llngConfig) {
+ try {
+
+ const response = window.fetch(`${baseUrl}/partial/raw`,
+ {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(config),
+ // credentials: "include"
+ });
return response;
} catch (error) {
+ console.log(error)
throw new Error(JSON.stringify(error));
}
}
diff --git a/src/features/config/configSlice.ts b/src/features/config/configSlice.ts
index 1b101c6..3b4888b 100644
--- a/src/features/config/configSlice.ts
+++ b/src/features/config/configSlice.ts
@@ -8,7 +8,7 @@ import attributes from "../../static/attributes.json";
import { treeFormat } from "../../utils/recursTree";
import { changeElementInConf } from "../../utils/searchIntree";
import { MetaData, llngConfig } from "../../utils/types";
-import { getConfig, getMetadataConfig, saveConfig } from "./configAPI";
+import { getConfig, getMetadataConfig, getPartialConfig, saveConfig, savePartialConfig } from "./configAPI";
export interface ConfigState {
loading: boolean;
@@ -26,25 +26,46 @@ export const initialState: ConfigState = {
export const getConfigAsync = createAsyncThunk(
"config/fetchConfig",
async (num?: number): Promise