diff --git a/frontend/desktop/src/pages/index.tsx b/frontend/desktop/src/pages/index.tsx index 6b23c4deaf3..d7dd16e9bb4 100644 --- a/frontend/desktop/src/pages/index.tsx +++ b/frontend/desktop/src/pages/index.tsx @@ -52,7 +52,10 @@ export default function Home({ sealos_cloud_domain }: { sealos_cloud_domain: str const { appkey, appQuery } = parseOpenappQuery((query?.openapp as string) || ''); // sealos_inside=true internal call if (whitelistApps.includes(appkey) && appQuery.indexOf('sealos_inside=true') === -1) { - window.open(`https://fastdeploy.${sealos_cloud_domain}/deploy?${appQuery}`, '_self'); + sessionStorage.setItem( + 'accessTemplatesNoLogin', + `https://template.${sealos_cloud_domain}/deploy?${appQuery}` + ); return; } if (appkey && typeof appQuery === 'string') setAutoLaunch(appkey, { raw: appQuery }); diff --git a/frontend/desktop/src/pages/signin.tsx b/frontend/desktop/src/pages/signin.tsx index d79457e7852..39b4b2de147 100644 --- a/frontend/desktop/src/pages/signin.tsx +++ b/frontend/desktop/src/pages/signin.tsx @@ -1,8 +1,17 @@ import SigninComponent from '@/components/signin'; import { compareFirstLanguages } from '@/utils/tools'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { useEffect } from 'react'; export default function SigninPage() { + useEffect(() => { + const url = sessionStorage.getItem('accessTemplatesNoLogin'); + if (url) { + sessionStorage.clear(); + window.location.replace(url); + } + }, []); + return ; } diff --git a/frontend/providers/dbprovider/src/constants/db.ts b/frontend/providers/dbprovider/src/constants/db.ts index c342112ddde..dd664c5be02 100644 --- a/frontend/providers/dbprovider/src/constants/db.ts +++ b/frontend/providers/dbprovider/src/constants/db.ts @@ -168,7 +168,7 @@ export const DBTypeList = [ export const DBComponentNameMap = { [DBTypeEnum.postgresql]: 'postgresql', - [DBTypeEnum.mongodb]: 'mongo', + [DBTypeEnum.mongodb]: 'mongodb', [DBTypeEnum.mysql]: 'mysql', [DBTypeEnum.redis]: 'redis', [DBTypeEnum.kafka]: 'kafka', diff --git a/frontend/providers/dbprovider/src/pages/api/minio/upload.ts b/frontend/providers/dbprovider/src/pages/api/minio/upload.ts index caf351b91c0..a35b2ef8549 100644 --- a/frontend/providers/dbprovider/src/pages/api/minio/upload.ts +++ b/frontend/providers/dbprovider/src/pages/api/minio/upload.ts @@ -65,8 +65,8 @@ const upload = new UploadModel(); const minioClient = new Minio.Client({ endPoint: process.env?.MINIO_URL || 'minioapi.dev.sealos.top', - port: Number(process.env?.MINIO_PORT) || 80, - useSSL: false, + port: Number(process.env?.MINIO_PORT) || 443, + useSSL: Boolean(process.env?.MINIO_USE_SSL) || true, accessKey: process.env?.MINIO_ACCESS_KEY || 'database', secretKey: process.env?.MINIO_SECRET_KEY || 'database' }); diff --git a/frontend/providers/template/.dockerignore b/frontend/providers/template/.dockerignore index d16526bf068..fe2add7d3e0 100644 --- a/frontend/providers/template/.dockerignore +++ b/frontend/providers/template/.dockerignore @@ -5,9 +5,9 @@ npm-debug.log README.md .next .git -!./FastDeployTemplates/.git +!./templates/.git .yalc/ yalc.lock -FastDeployTemplates -fast_deploy_template.json \ No newline at end of file +templates +templates.json \ No newline at end of file diff --git a/frontend/providers/template/.gitignore b/frontend/providers/template/.gitignore index 69b6478ab58..2fcf9ab4d70 100644 --- a/frontend/providers/template/.gitignore +++ b/frontend/providers/template/.gitignore @@ -40,5 +40,5 @@ platform.json .yalc/ yalc.lock -FastDeployTemplates -fast_deploy_template.json +templates +templates.json diff --git a/frontend/providers/template/deploy/manifests/deploy.yaml.tmpl b/frontend/providers/template/deploy/manifests/deploy.yaml.tmpl index a8dcf624018..42206046736 100644 --- a/frontend/providers/template/deploy/manifests/deploy.yaml.tmpl +++ b/frontend/providers/template/deploy/manifests/deploy.yaml.tmpl @@ -91,6 +91,8 @@ metadata: namespace: template-frontend name: template-static spec: + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 schedule: "0 0 * * *" jobTemplate: spec: diff --git a/frontend/providers/template/src/pages/api/getTemplateSource.ts b/frontend/providers/template/src/pages/api/getTemplateSource.ts index d2df0e50ec8..d8ce7d50274 100644 --- a/frontend/providers/template/src/pages/api/getTemplateSource.ts +++ b/frontend/providers/template/src/pages/api/getTemplateSource.ts @@ -74,9 +74,9 @@ export async function GetTemplateByName({ }; const originalPath = process.cwd(); - const targetPath = path.resolve(originalPath, 'FastDeployTemplates', targetFolder); + const targetPath = path.resolve(originalPath, 'templates', targetFolder); // Query by file name in template details - const jsonPath = path.resolve(originalPath, 'fast_deploy_template.json'); + const jsonPath = path.resolve(originalPath, 'templates.json'); const jsonData: TemplateType[] = JSON.parse(fs.readFileSync(jsonPath, 'utf8')); const _tempalte = jsonData.find((item) => item.metadata.name === templateName); const _tempalteName = _tempalte ? _tempalte.spec.fileName : `${templateName}.yaml`; diff --git a/frontend/providers/template/src/pages/api/listTemplate.ts b/frontend/providers/template/src/pages/api/listTemplate.ts index d02dcdc8749..af9cd429508 100644 --- a/frontend/providers/template/src/pages/api/listTemplate.ts +++ b/frontend/providers/template/src/pages/api/listTemplate.ts @@ -18,7 +18,7 @@ export function replaceRawWithCDN(url: string, cdnUrl: string) { export default async function handler(req: NextApiRequest, res: NextApiResponse) { const originalPath = process.cwd(); - const jsonPath = path.resolve(originalPath, 'fast_deploy_template.json'); + const jsonPath = path.resolve(originalPath, 'templates.json'); const cdnUrl = process.env.CDN_URL; try { if (fs.existsSync(jsonPath)) { diff --git a/frontend/providers/template/src/pages/api/updateRepo.ts b/frontend/providers/template/src/pages/api/updateRepo.ts index bb9fea03fa9..2e466097088 100644 --- a/frontend/providers/template/src/pages/api/updateRepo.ts +++ b/frontend/providers/template/src/pages/api/updateRepo.ts @@ -69,8 +69,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< process.env.TEMPLATE_REPO_URL || 'https://github.com/labring-actions/templates'; const targetFolder = process.env.TEMPLATE_REPO_FOLDER || 'template'; const originalPath = process.cwd(); - const targetPath = path.resolve(originalPath, 'FastDeployTemplates'); - const jsonPath = path.resolve(originalPath, 'fast_deploy_template.json'); + const targetPath = path.resolve(originalPath, 'templates'); + const jsonPath = path.resolve(originalPath, 'templates.json'); try { const timeoutPromise = new Promise((resolve, reject) => { diff --git a/frontend/providers/template/src/pages/api/v1alpha/listTemplate.ts b/frontend/providers/template/src/pages/api/v1alpha/listTemplate.ts index 013f3524e06..e271e0fff4e 100644 --- a/frontend/providers/template/src/pages/api/v1alpha/listTemplate.ts +++ b/frontend/providers/template/src/pages/api/v1alpha/listTemplate.ts @@ -7,7 +7,7 @@ import path from 'path'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { const originalPath = process.cwd(); - const jsonPath = path.resolve(originalPath, 'fast_deploy_template.json'); + const jsonPath = path.resolve(originalPath, 'templates.json'); try { if (fs.existsSync(jsonPath)) { diff --git a/frontend/providers/template/src/pages/develop/index.tsx b/frontend/providers/template/src/pages/develop/index.tsx index 798d2dfedf9..be3a1930133 100644 --- a/frontend/providers/template/src/pages/develop/index.tsx +++ b/frontend/providers/template/src/pages/develop/index.tsx @@ -94,8 +94,10 @@ export default function Develop() { try { const result = getYamlSource(str); const defaultInputes = getTemplateDefaultValues(result); + const formInputs = formHook.getValues(); + setYamlSource(result); - const correctYamlList = generateCorrectYamlList(result, defaultInputes); + const correctYamlList = generateCorrectYamlList(result, formInputs); setYamlList(correctYamlList); } catch (error: any) { toast({ @@ -114,13 +116,9 @@ export default function Develop() { }); // watch form change, compute new yaml - useEffect( - () => - formHook.watch((data: any) => { - data && formOnchangeDebounce(data); - }).unsubscribe, - [formHook.watch] - ); + formHook.watch((data: any) => { + data && formOnchangeDebounce(data); + }); const formOnchangeDebounce = debounce((data: any) => { try { @@ -220,8 +218,7 @@ export default function Develop() { borderRadius={'8px'} overflowY={'hidden'} overflowX={'scroll'} - flex={1} - > + flex={1}> {/* left */} + borderRadius={'8px 8px 0px 0px '}> {t('develop.Development')} @@ -262,8 +258,7 @@ export default function Develop() { alignItems={'center'} backgroundColor={'#F8FAFB'} pl="42px" - borderRadius={'8px 8px 0px 0px '} - > + borderRadius={'8px 8px 0px 0px '}> {t('develop.Preview')} @@ -275,8 +270,7 @@ export default function Develop() { pt="26px" pr={{ sm: '20px', md: '60px' }} borderBottom={'1px solid #EFF0F1'} - flexDirection={'column'} - > + flexDirection={'column'}> {t('develop.Configure Form')} @@ -292,8 +286,7 @@ export default function Develop() { minW={'100px'} h={'34px'} variant={'link'} - onClick={handleExportYaml} - > + onClick={handleExportYaml}> {t('Export')} Yaml diff --git a/frontend/providers/template/src/pages/index.tsx b/frontend/providers/template/src/pages/index.tsx index f6f956c96ba..c42f2e4be1a 100644 --- a/frontend/providers/template/src/pages/index.tsx +++ b/frontend/providers/template/src/pages/index.tsx @@ -4,7 +4,18 @@ import { useCachedStore } from '@/store/cached'; import { useSearchStore } from '@/store/search'; import { TemplateType } from '@/types/app'; import { serviceSideProps } from '@/utils/i18n'; -import { Avatar, AvatarGroup, Box, Flex, Grid, Icon, Image, Text, Tooltip } from '@chakra-ui/react'; +import { + Avatar, + AvatarGroup, + Box, + Flex, + Grid, + Icon, + Image, + Spinner, + Text, + Tooltip +} from '@chakra-ui/react'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'next-i18next'; import { useRouter } from 'next/router'; @@ -19,16 +30,21 @@ export default function AppList() { const { searchValue } = useSearchStore(); const { setInsideCloud, insideCloud } = useCachedStore(); - const { data: FastDeployTemplates } = useQuery(['listTemplte'], () => GET('/api/listTemplate'), { - refetchInterval: 5 * 60 * 1000, - staleTime: 5 * 60 * 1000 - }); + const { data: FastDeployTemplates, refetch } = useQuery( + ['listTemplte'], + () => GET('/api/listTemplate'), + { + refetchInterval: 5 * 60 * 1000, + staleTime: 5 * 60 * 1000 + } + ); - useQuery(['updateRepo'], () => updateRepo(), { + const { isLoading } = useQuery(['updateRepo'], () => updateRepo(), { refetchInterval: 5 * 60 * 1000, staleTime: 5 * 60 * 1000, onSettled(data) { console.log(data); + refetch(); } }); @@ -77,103 +93,109 @@ export default function AppList() { background={'linear-gradient(180deg, #FFF 0%, rgba(255, 255, 255, 0.70) 100%)'} py={'36px'} px="42px"> - - {filterData && - filterData?.map((item: TemplateType) => { - return ( - goDeploy(item?.metadata?.name)} - _hover={{ - borderColor: '#36ADEF', - boxShadow: '0px 4px 5px 0px rgba(185, 196, 205, 0.25)' - }} - key={item?.metadata?.name} - flexDirection={'column'} - minH={'214px'} - h="214px" - p={'24px'} - borderRadius={'8px'} - backgroundColor={'#fff'} - boxShadow={'0px 2px 4px 0px rgba(187, 196, 206, 0.25)'} - border={'1px solid #EAEBF0'}> - - - - - {item.spec?.deployCount && item.spec?.deployCount > 6 && ( - - - - - - - - +{formatStarNumber(item.spec.deployCount)} - - - )} - - - - {item?.spec?.title} - - + {!!FastDeployTemplates?.length ? ( + + {filterData && + filterData?.map((item: TemplateType) => { + return ( + goDeploy(item?.metadata?.name)} + _hover={{ + borderColor: '#36ADEF', + boxShadow: '0px 4px 5px 0px rgba(185, 196, 205, 0.25)' + }} + key={item?.metadata?.name} + flexDirection={'column'} + minH={'214px'} + h="214px" + p={'24px'} + borderRadius={'8px'} + backgroundColor={'#fff'} + boxShadow={'0px 2px 4px 0px rgba(187, 196, 206, 0.25)'} + border={'1px solid #EAEBF0'}> + + + + + {item.spec?.deployCount && item.spec?.deployCount > 6 && ( + + + + + + + + +{formatStarNumber(item.spec.deployCount)} + + + )} + + + + {item?.spec?.title} + + - - {item?.spec?.description} - - - - By - {item?.spec?.author} + + {item?.spec?.description} + + + + By + {item?.spec?.author} + + goGithub(e, item?.spec?.gitRepo)}> + + + + + - goGithub(e, item?.spec?.gitRepo)}> - - - - - - - ); - })} - + ); + })} + + ) : ( + + + + )} ); }