[FIX] deliver new system
This commit is contained in:
parent
859011e9a6
commit
44b4fa37d3
@ -103,7 +103,7 @@ WORKDIR /application/
|
||||
|
||||
EXPOSE 80
|
||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
||||
HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
|
||||
# HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
|
||||
# CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
|
||||
|
||||
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karso.WebLauncher"]
|
||||
|
@ -1,93 +1,55 @@
|
||||
import { Box, Flex, Image, Text, Button } from '@chakra-ui/react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { Box, Flex, Image, Text } from '@chakra-ui/react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import avatar from '@/assets/images/avatar_generic.svg';
|
||||
import { PageLayout } from '@/components/Layout/PageLayout';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useSessionService } from '@/service/session';
|
||||
import { ApplicationResource } from '@/back-api';
|
||||
import { toasterAPIError, toaster } from '@/components/ui/toaster';
|
||||
import { TopBar } from '@/components/TopBar/TopBar';
|
||||
import { useEffect } from 'react';
|
||||
import { ApplicationService } from '@/service/application';
|
||||
|
||||
export const SignInDonePage = () => {
|
||||
const { getRestConfig, clearToken } = useSessionService();
|
||||
const { applicationName, applicationData } = useParams();
|
||||
const { transferToApplication } = ApplicationService.useTransferApplication();
|
||||
|
||||
const transferToApplication = (): void => {
|
||||
ApplicationResource.getClientToken({
|
||||
restConfig: getRestConfig(),
|
||||
queries: { application:applicationName ?? '' },
|
||||
}).then((response)=> {
|
||||
if (!response.url || !response.jwt) {
|
||||
toaster.create({
|
||||
title: "Error data",
|
||||
description: "Fail to retrieve data",
|
||||
type: 'error'
|
||||
});
|
||||
} else {
|
||||
toaster.create({
|
||||
title: "Request transfer",
|
||||
type:"success"
|
||||
});
|
||||
transferToApplicationThatRequiredTheSSO(response.url, response.jwt);
|
||||
}
|
||||
}).catch((error)=> {
|
||||
toasterAPIError(error);
|
||||
if (error.status == 401) {
|
||||
// Authentication error ==> auto_disconnect
|
||||
clearToken();
|
||||
toaster.create({
|
||||
title: "Disconnected by server",
|
||||
description: "Token is no more available",
|
||||
type:"error"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const transferToApplicationThatRequiredTheSSO = (url: string, token: string): void => {
|
||||
if (url.slice(-1) === '/') {
|
||||
url = url.slice(0, -1);
|
||||
}
|
||||
let ssoApplicationReturnUrl;
|
||||
if (applicationData === undefined) {
|
||||
ssoApplicationReturnUrl = `${url}/aG9tZQ/false/`;
|
||||
} else {
|
||||
ssoApplicationReturnUrl = `${url}/${applicationData}/false/`;
|
||||
}
|
||||
console.log(`generate in new URL: ${ssoApplicationReturnUrl + token}`);
|
||||
//window.location.href = ssoApplicationReturnUrl + token;
|
||||
}
|
||||
useEffect(() => {
|
||||
transferToApplication();
|
||||
transferToApplication(applicationName ?? '', applicationData);
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<TopBar title="Login" />
|
||||
<PageLayout>
|
||||
<Flex
|
||||
marginX="auto"
|
||||
width="full"
|
||||
height="90%"
|
||||
direction="column"
|
||||
>
|
||||
<Flex marginX="auto" width="full" height="90%" direction="column">
|
||||
<Box
|
||||
bg="white"
|
||||
padding="30px"
|
||||
shadow="md"
|
||||
width="400px"
|
||||
margin="auto"
|
||||
background={{ _light: "gray.50", _dark: "gray.800" }}
|
||||
background={{ _light: 'gray.50', _dark: 'gray.800' }}
|
||||
>
|
||||
<Text
|
||||
width="100%"
|
||||
textAlign="center"
|
||||
fontWeight="bold"
|
||||
fontSize="25px"
|
||||
>
|
||||
<Text width="100%" textAlign="center" fontWeight="bold" fontSize="25px">
|
||||
Connected
|
||||
</Text>
|
||||
<Image marginX="auto"
|
||||
marginY="10px" src={avatar} width="128px" height="128px" borderRadius="100%" />
|
||||
<Image
|
||||
marginX="auto"
|
||||
marginY="10px"
|
||||
src={avatar}
|
||||
width="128px"
|
||||
height="128px"
|
||||
borderRadius="100%"
|
||||
/>
|
||||
|
||||
<Flex align="center" justify="center" direction="column">
|
||||
<Text>Connection done...</Text>
|
||||
{applicationName && <Text>Will redirect to: {applicationName}</Text>}
|
||||
{applicationName && (
|
||||
<Text>Will redirect to: {applicationName}</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Box>
|
||||
</Flex>
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { Center, Flex, HStack, Text } from '@chakra-ui/react';
|
||||
import { LuCrown } from 'react-icons/lu';
|
||||
|
||||
import { Application } from '@/back-api';
|
||||
import { PageLayout } from '@/components/Layout/PageLayout';
|
||||
import { TopBar } from '@/components/TopBar/TopBar';
|
||||
|
||||
import { useColorModeValue } from '@/components/ui/color-mode';
|
||||
import { Application } from '@/back-api';
|
||||
import { ApplicationService } from '@/service/application';
|
||||
|
||||
|
||||
export const HomePage = () => {
|
||||
const { transferToApplication } = ApplicationService.useTransferApplication();
|
||||
const onSelectItem = (data: Application) => {
|
||||
window.location.href = data.redirect;
|
||||
transferToApplication(data.name ?? '');
|
||||
//window.location.href = data.redirect;
|
||||
};
|
||||
const { data: dataApplication } = ApplicationService.useGets();
|
||||
console.log(`ppp: ${JSON.stringify(dataApplication, null, 2)}`);
|
||||
@ -19,9 +19,16 @@ export const HomePage = () => {
|
||||
<>
|
||||
<TopBar title="Home" />
|
||||
<PageLayout>
|
||||
<HStack wrap="wrap" gap="20px" marginX="auto" padding="20px" justify="center">
|
||||
<HStack
|
||||
wrap="wrap"
|
||||
gap="20px"
|
||||
marginX="auto"
|
||||
padding="20px"
|
||||
justify="center"
|
||||
>
|
||||
{dataApplication?.map((data) => (
|
||||
<Flex align="flex-start"
|
||||
<Flex
|
||||
align="flex-start"
|
||||
width="200px"
|
||||
height="190px"
|
||||
border="1px"
|
||||
@ -37,7 +44,9 @@ export const HomePage = () => {
|
||||
onClick={() => onSelectItem(data)}
|
||||
>
|
||||
<Flex direction="column" width="full" height="full">
|
||||
<Center height="full"><LuCrown style={{ width: "100px", height: "100px" }} /></Center>
|
||||
<Center height="full">
|
||||
<LuCrown style={{ width: '100px', height: '100px' }} />
|
||||
</Center>
|
||||
<Center>
|
||||
<Text
|
||||
fontSize="25px"
|
||||
@ -56,4 +65,3 @@ export const HomePage = () => {
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -3,21 +3,19 @@
|
||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||
* @license PROPRIETARY (see license file)
|
||||
*/
|
||||
import { ApplicationResource, ClientToken, Long } from '@/back-api';
|
||||
import { toaster, toasterAPIError } from '@/components/ui/toaster';
|
||||
import { useQuery, useQueryCall, useQueryCallProps } from '@/utils/query';
|
||||
|
||||
import { Long, ApplicationResource, ClientToken } from "@/back-api";
|
||||
import { useSessionService } from "./session";
|
||||
import { useQuery, useQueryCall, useQueryCallProps } from "@/utils/query";
|
||||
|
||||
|
||||
import { useSessionService } from './session';
|
||||
|
||||
export namespace ApplicationService {
|
||||
|
||||
export const useGets = () => {
|
||||
const { getRestConfig } = useSessionService();
|
||||
return useQuery({
|
||||
queryFunction: () => {
|
||||
return ApplicationResource.gets({
|
||||
restConfig: getRestConfig()
|
||||
restConfig: getRestConfig(),
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -29,7 +27,7 @@ export namespace ApplicationService {
|
||||
return ApplicationResource.getRightsDescription({
|
||||
restConfig: getRestConfig(),
|
||||
params: {
|
||||
id
|
||||
id,
|
||||
},
|
||||
});
|
||||
},
|
||||
@ -43,7 +41,7 @@ export namespace ApplicationService {
|
||||
return ApplicationResource.getClientToken({
|
||||
restConfig: getRestConfig(),
|
||||
queries: {
|
||||
application: applicationName
|
||||
application: applicationName,
|
||||
},
|
||||
});
|
||||
},
|
||||
@ -58,16 +56,23 @@ export namespace ApplicationService {
|
||||
// });
|
||||
// }
|
||||
|
||||
export const useGetClientToken = ({ config }: { config?: Omit<useQueryCallProps<ClientToken, any>, 'queryFunction'> }) => {
|
||||
export const useGetClientToken = ({
|
||||
config,
|
||||
}: {
|
||||
config?: Omit<useQueryCallProps<ClientToken, any>, 'queryFunction'>;
|
||||
}) => {
|
||||
const { getRestConfig } = useSessionService();
|
||||
const { call, ...rest } = useQueryCall<ClientToken, { application: string }>({
|
||||
const { call, ...rest } = useQueryCall<
|
||||
ClientToken,
|
||||
{ application: string }
|
||||
>({
|
||||
queryFunction: (data) => {
|
||||
return ApplicationResource.getClientToken({
|
||||
restConfig: getRestConfig(),
|
||||
queries: { ...data },
|
||||
});
|
||||
},
|
||||
...config
|
||||
...config,
|
||||
});
|
||||
return { getClientToken: call, ...rest };
|
||||
};
|
||||
@ -166,4 +171,68 @@ export namespace ApplicationService {
|
||||
},
|
||||
});
|
||||
}*/
|
||||
|
||||
export const useTransferApplication = () => {
|
||||
const { getRestConfig, clearToken } = useSessionService();
|
||||
const transferToApplicationThatRequiredTheSSO = (
|
||||
url: string,
|
||||
token: string,
|
||||
applicationData?: string
|
||||
): void => {
|
||||
if (url.slice(-1) === '/') {
|
||||
url = url.slice(0, -1);
|
||||
}
|
||||
let ssoApplicationReturnUrl;
|
||||
if (applicationData === undefined) {
|
||||
ssoApplicationReturnUrl = `${url}/aG9tZQ/false/`;
|
||||
} else {
|
||||
ssoApplicationReturnUrl = `${url}/${applicationData}/false/`;
|
||||
}
|
||||
console.log(`generate in new URL: ${ssoApplicationReturnUrl + token}`);
|
||||
window.location.href = ssoApplicationReturnUrl + token;
|
||||
};
|
||||
|
||||
const transferToApplication = (
|
||||
appName: string,
|
||||
applicationData?: string
|
||||
): void => {
|
||||
ApplicationResource.getClientToken({
|
||||
restConfig: getRestConfig(),
|
||||
queries: { application: appName },
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.url || !response.jwt) {
|
||||
toaster.create({
|
||||
title: 'Error data',
|
||||
description: 'Fail to retrieve data',
|
||||
type: 'error',
|
||||
});
|
||||
} else {
|
||||
toaster.create({
|
||||
title: 'Request transfer',
|
||||
type: 'success',
|
||||
});
|
||||
transferToApplicationThatRequiredTheSSO(
|
||||
response.url,
|
||||
response.jwt,
|
||||
applicationData
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
toasterAPIError(error);
|
||||
if (error.status == 401) {
|
||||
// Authentication error ==> auto_disconnect
|
||||
clearToken();
|
||||
toaster.create({
|
||||
title: 'Disconnected by server',
|
||||
description: 'Token is no more available',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return { transferToApplication };
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user