Skip to content

Commit

Permalink
fix:template redirection problem (#4472)
Browse files Browse the repository at this point in the history
* fix:template redirection problem

Signed-off-by: jingyang <[email protected]>

* add loading

* fix db file upload

---------

Signed-off-by: jingyang <[email protected]>
  • Loading branch information
zjy365 authored Jan 8, 2024
1 parent fee8721 commit d7269a9
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 133 deletions.
5 changes: 4 additions & 1 deletion frontend/desktop/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
9 changes: 9 additions & 0 deletions frontend/desktop/src/pages/signin.tsx
Original file line number Diff line number Diff line change
@@ -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 <SigninComponent />;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/providers/dbprovider/src/constants/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions frontend/providers/dbprovider/src/pages/api/minio/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/providers/template/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ npm-debug.log
README.md
.next
.git
!./FastDeployTemplates/.git
!./templates/.git
.yalc/
yalc.lock

FastDeployTemplates
fast_deploy_template.json
templates
templates.json
4 changes: 2 additions & 2 deletions frontend/providers/template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ platform.json
.yalc/
yalc.lock

FastDeployTemplates
fast_deploy_template.json
templates
templates.json
2 changes: 2 additions & 0 deletions frontend/providers/template/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ metadata:
namespace: template-frontend
name: template-static
spec:
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
schedule: "0 0 * * *"
jobTemplate:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
2 changes: 1 addition & 1 deletion frontend/providers/template/src/pages/api/listTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function replaceRawWithCDN(url: string, cdnUrl: string) {

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
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)) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/providers/template/src/pages/api/updateRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from 'path';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
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)) {
Expand Down
29 changes: 11 additions & 18 deletions frontend/providers/template/src/pages/develop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 {
Expand Down Expand Up @@ -220,8 +218,7 @@ export default function Develop() {
borderRadius={'8px'}
overflowY={'hidden'}
overflowX={'scroll'}
flex={1}
>
flex={1}>
{/* left */}
<Flex flexDirection={'column'} w="50%" borderRight={'1px solid #EFF0F1'}>
<Flex
Expand All @@ -231,8 +228,7 @@ export default function Develop() {
alignItems={'center'}
backgroundColor={'#F8FAFB'}
px="36px"
borderRadius={'8px 8px 0px 0px '}
>
borderRadius={'8px 8px 0px 0px '}>
<MyIcon name="dev" color={'#24282C'} w={'24px'} h={'24px'}></MyIcon>
<Text fontWeight={'500'} fontSize={'16px'} color={'#24282C'} ml="8px">
{t('develop.Development')}
Expand Down Expand Up @@ -262,8 +258,7 @@ export default function Develop() {
alignItems={'center'}
backgroundColor={'#F8FAFB'}
pl="42px"
borderRadius={'8px 8px 0px 0px '}
>
borderRadius={'8px 8px 0px 0px '}>
<MyIcon name="eyeShow" color={'#24282C'} w={'24px'} h={'24px'}></MyIcon>
<Text fontWeight={'500'} fontSize={'16px'} color={'#24282C'} ml="8px">
{t('develop.Preview')}
Expand All @@ -275,8 +270,7 @@ export default function Develop() {
pt="26px"
pr={{ sm: '20px', md: '60px' }}
borderBottom={'1px solid #EFF0F1'}
flexDirection={'column'}
>
flexDirection={'column'}>
<Text fontWeight={'500'} fontSize={'18px'} color={'#24282C'}>
{t('develop.Configure Form')}
</Text>
Expand All @@ -292,8 +286,7 @@ export default function Develop() {
minW={'100px'}
h={'34px'}
variant={'link'}
onClick={handleExportYaml}
>
onClick={handleExportYaml}>
{t('Export')} Yaml
</Button>
</Flex>
Expand Down
Loading

0 comments on commit d7269a9

Please sign in to comment.