diff --git a/src/dashboards/PartialManager.tsx b/src/dashboards/PartialManager.tsx index 9509fe4..c6d920f 100644 --- a/src/dashboards/PartialManager.tsx +++ b/src/dashboards/PartialManager.tsx @@ -40,12 +40,12 @@ export default function PartialManager() { useEffect(() => { if (!configPresent) { setConfigPresent(true); - dispatch( - getPartialConfigAsync(configNum === "latest" ? undefined : Number(configNum)) - ); + dispatch(getPartialConfigAsync()); } const appNum = - (config.data.config.locationRules ? Object.keys(config.data.config.locationRules).length : 0) + + (config.data.config.locationRules + ? Object.keys(config.data.config.locationRules).length + : 0) + (config.data.config.samlSPMetaDataXML ? Object.keys(config.data.config.samlSPMetaDataXML).length : 0) + @@ -56,10 +56,22 @@ export default function PartialManager() { ? 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]}`)) + 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 { @@ -200,13 +212,15 @@ export default function PartialManager() { > {config.data.metadata.cfgNum} - {false && { - dispatch(push("#catandapp")); - }} - > - - } + {false && ( + { + dispatch(push("#catandapp")); + }} + > + + + )} {false && } => { - const metaResponse = await getMetadataConfig(num ? num : undefined); - const configMetadata = await metaResponse.json() - const response = await getPartialConfig(num ? num : (configMetadata).cfgNum); - return { metadata: configMetadata, config: await response.json() } + async (): Promise => { + const response = await getPartialConfig(); + const partialConf = await response.json(); + const metadata = { + cfgAuthor: partialConf.cfgAuthor, + cfgAuthorIP: partialConf.cfgAuthorIP, + cfgDate: partialConf.cfgDate, + cfgLog: partialConf.cfgLog, + cfgNum: partialConf.cfgNum, + cfgVersion: partialConf.cfgVersion, + prev: partialConf.prev, + next: partialConf.next, + }; + return { metadata, config: partialConf }; } -) +); export const saveConfigAsync = createAsyncThunk( "config/saveConfig", @@ -61,10 +79,10 @@ export const saveConfigAsync = createAsyncThunk( export const savePartialConfigAsync = createAsyncThunk( "config/savePartialConfig", async (config: llngConfig): Promise => { - const response = await savePartialConfig(config) - return response.json() + const response = await savePartialConfig(config); + return response.json(); } -) +); const configSlice = createSlice({ name: "config", @@ -91,36 +109,39 @@ const configSlice = createSlice({ }, toggleSAML(state) { if (!state.data.config.issuerDBSAMLActivation) { - state.data.config.issuerDBSAMLActivation = 0 + state.data.config.issuerDBSAMLActivation = 0; } state.data.config.issuerDBSAMLActivation = 1 - Number(state.data.config.issuerDBSAMLActivation); }, toggleOIDC(state) { if (!state.data.config.issuerDBOpenIDConnectActivation) { - state.data.config.issuerDBOpenIDConnectActivation = 0 + state.data.config.issuerDBOpenIDConnectActivation = 0; } state.data.config.issuerDBOpenIDConnectActivation = 1 - Number(state.data.config.issuerDBOpenIDConnectActivation); }, toggleCAS(state) { if (!state.data.config.issuerDBCASActivation) { - state.data.config.issuerDBCASActivation = 0 + state.data.config.issuerDBCASActivation = 0; } state.data.config.issuerDBCASActivation = 1 - Number(state.data.config.issuerDBCASActivation); - console.log(state.data.config.issuerDBCASActivation, 1 - Number(state.data.config.issuerDBCASActivation)) + console.log( + state.data.config.issuerDBCASActivation, + 1 - Number(state.data.config.issuerDBCASActivation) + ); }, toggleOID2(state) { if (!state.data.config.issuerDBOpenIDActivation) { - state.data.config.issuerDBOpenIDActivation = 0 + state.data.config.issuerDBOpenIDActivation = 0; } state.data.config.issuerDBOpenIDActivation = 1 - Number(state.data.config.issuerDBOpenIDActivation); }, toggleGET(state) { if (!state.data.config.issuerDBGetActivation) { - state.data.config.issuerDBGetActivation = 0 + state.data.config.issuerDBGetActivation = 0; } state.data.config.issuerDBGetActivation = 1 - Number(state.data.config.issuerDBGetActivation); @@ -963,9 +984,10 @@ const configSlice = createSlice({ if (!state.data.config.combModules[action.payload].over) { state.data.config.combModules[action.payload].over = {}; } - const id: string = `new${Object.keys(state.data.config.combModules[action.payload].over).length + + const id: string = `new${ + Object.keys(state.data.config.combModules[action.payload].over).length + 1 - }`; + }`; ( state.data.config.combModules[action.payload].over as unknown as Record< @@ -1244,11 +1266,11 @@ const configSlice = createSlice({ .map((key) => state.data.config.applicationList ? ( - state.data.config.applicationList as Record< - string, - Record - > - )[key].order + state.data.config.applicationList as Record< + string, + Record + > + )[key].order : 0 ) .filter((el) => typeof el === "number"), @@ -1290,18 +1312,19 @@ const configSlice = createSlice({ .map((key) => state.data.config.applicationList ? ( - state.data.config.applicationList[action.payload] as Record< - string, - Record - > - )[key].order + state.data.config.applicationList[action.payload] as Record< + string, + Record + > + )[key].order : 0 ) .filter((el) => typeof el === "number"), 0 ); state.data.config.applicationList[action.payload][ - `new_application${Object.keys(state.data.config.applicationList[action.payload]).length + `new_application${ + Object.keys(state.data.config.applicationList[action.payload]).length }` ] = { options: { name: "New Application" }, @@ -1355,11 +1378,11 @@ const configSlice = createSlice({ .filter((key: string) => state.data.config.applicationList ? ( - state.data.config.applicationList as Record< - string, - Record - > - )[key].order + state.data.config.applicationList as Record< + string, + Record + > + )[key].order ? true : false : false @@ -1395,15 +1418,20 @@ const configSlice = createSlice({ console.log(state); if (appIndex === -1) return; if (action.payload.direction === "up" && appIndex > 0) { - console.log((state.data.config.applicationList as Record< - string, - Record - > - )[categories[appIndex]], (state.data.config.applicationList as Record< - string, - Record - > - )[categories[appIndex - 1]]); + console.log( + ( + state.data.config.applicationList as Record< + string, + Record + > + )[categories[appIndex]], + ( + state.data.config.applicationList as Record< + string, + Record + > + )[categories[appIndex - 1]] + ); ( state.data.config.applicationList as Record< string, @@ -1459,10 +1487,10 @@ const configSlice = createSlice({ .filter((key: string) => state.data.config.applicationList ? ( - state.data.config.applicationList[ - action.payload.category - ] as Record> - )[key].order + state.data.config.applicationList[ + action.payload.category + ] as Record> + )[key].order ? true : false : false @@ -1472,12 +1500,12 @@ const configSlice = createSlice({ return ( ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[key1].order - ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[key2].order ); @@ -1497,16 +1525,16 @@ const configSlice = createSlice({ if (action.payload.direction === "up" && appIndex > 0) { ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[action.payload.appName].order = ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[apps[appIndex - 1]].order; ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[apps[appIndex - 1]].order = order; } else if ( @@ -1515,16 +1543,16 @@ const configSlice = createSlice({ ) { ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[action.payload.appName].order = ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[apps[appIndex + 1]].order; ( state.data.config.applicationList[ - action.payload.category + action.payload.category ] as Record> )[apps[appIndex + 1]].order = order; } @@ -1591,7 +1619,8 @@ const configSlice = createSlice({ state.error.errorContent = action.payload.message; } } - ).addCase(getPartialConfigAsync.pending, (state: ConfigState) => { + ) + .addCase(getPartialConfigAsync.pending, (state: ConfigState) => { state.loading = true; }) .addCase( diff --git a/src/pages/PartialConfiguration.tsx b/src/pages/PartialConfiguration.tsx index 55354a3..773f890 100644 --- a/src/pages/PartialConfiguration.tsx +++ b/src/pages/PartialConfiguration.tsx @@ -26,7 +26,11 @@ export function PartialConfiguration({ dispatch(push(``))}>{t("conf")} - dispatch(push(`#conf/${config.data.config.cfgNum}`))}> + + dispatch(push(`#conf/${config.data.config.cfgNum}`)) + } + > {metadata.cfgNum} @@ -47,26 +51,6 @@ export function PartialConfiguration({ ); - case "catandapp": - return ( - - - - dispatch(push(``))}>{t("conf")} - - - dispatch(push(`#conf/${metadata.cfgNum}`))}> - {metadata.cfgNum} - - - - {t("applicationList")} - - - - - - ); default: return ( @@ -76,6 +60,7 @@ export function PartialConfiguration({ + ); }