Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:db auth & template develop #4445

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 55 additions & 44 deletions frontend/providers/applaunchpad/src/components/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,65 @@ interface Props extends BoxProps {
const Table = ({ columns, data, itemClass = '' }: Props) => {
const { t } = useTranslation();
return (
<Grid templateColumns={`repeat(${columns.length},1fr)`} overflowX={'auto'}>
{columns.map((item, i) => (
<Box
mb={2}
px={3}
py={3}
<>
<Grid templateColumns={`repeat(${columns.length},1fr)`} overflowX={'auto'}>
{columns.map((item, i) => (
<Box
mb={2}
px={3}
py={3}
bg={'white'}
key={item.key}
color={'myGray.700'}
whiteSpace={'nowrap'}
_first={{
borderLeftRadius: 'md',
pl: 7
}}
_last={{
borderRightRadius: 'md'
}}
>
{t(item.title)}
</Box>
))}
</Grid>
{data.map((item: any, index1) => (
<Grid
key={index1}
templateColumns={`repeat(${columns.length},1fr)`}
overflowX={'auto'}
bg={'white'}
key={item.key}
color={'myGray.700'}
whiteSpace={'nowrap'}
_first={{
borderLeftRadius: 'md',
pl: 7
}}
_last={{
borderRightRadius: 'md'
_hover={{
bg: '#FBFBFC'
}}
>
{t(item.title)}
</Box>
{columns.map((col, index2) => (
<Flex
className={index2 === 0 ? itemClass : ''}
data-id={item.id}
key={col.key}
alignItems={'center'}
px={3}
py={4}
fontSize={'sm'}
fontWeight={'bold'}
color={'myGray.700'}
borderBottom={'1px solid'}
borderBottomColor={index1 !== data.length - 1 ? 'myGray.100' : 'transparent'}
borderTopLeftRadius={index1 === 0 && index2 === 0 ? 'md' : ''}
borderTopRightRadius={index1 === 0 && index2 === columns.length - 1 ? 'md' : ''}
borderBottomLeftRadius={index1 === data.length - 1 && index2 === 0 ? 'md' : ''}
borderBottomEndRadius={
index1 === data.length - 1 && index2 === columns.length - 1 ? 'md' : ''
}
>
{col.render ? col.render(item) : col.dataIndex ? `${item[col.dataIndex]}` : ''}
</Flex>
))}
</Grid>
))}
{data.map((item: any, index1) =>
columns.map((col, index2) => (
<Flex
className={index2 === 0 ? itemClass : ''}
data-id={item.id}
key={col.key}
alignItems={'center'}
bg={'white'}
px={3}
py={4}
fontSize={'sm'}
fontWeight={'bold'}
color={'myGray.700'}
borderBottom={'1px solid'}
borderBottomColor={index1 !== data.length - 1 ? 'myGray.100' : 'transparent'}
borderTopLeftRadius={index1 === 0 && index2 === 0 ? 'md' : ''}
borderTopRightRadius={index1 === 0 && index2 === columns.length - 1 ? 'md' : ''}
borderBottomLeftRadius={index1 === data.length - 1 && index2 === 0 ? 'md' : ''}
borderBottomEndRadius={
index1 === data.length - 1 && index2 === columns.length - 1 ? 'md' : ''
}
>
{col.render ? col.render(item) : col.dataIndex ? `${item[col.dataIndex]}` : ''}
</Flex>
))
)}
</Grid>
</>
);
};

Expand Down
56 changes: 25 additions & 31 deletions frontend/providers/applaunchpad/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { theme } from '@/constants/theme';
import { useConfirm } from '@/hooks/useConfirm';
import { useLoading } from '@/hooks/useLoading';
import { useGlobalStore } from '@/store/global';
import { loadInitData } from '@/store/static';
import { SEALOS_DOMAIN, loadInitData } from '@/store/static';
import { useUserStore } from '@/store/user';
import { getLangStore, setLangStore } from '@/utils/cookieUtils';
import { ChakraProvider } from '@chakra-ui/react';
Expand Down Expand Up @@ -50,7 +50,6 @@ const App = ({ Component, pageProps }: AppProps) => {
});

useEffect(() => {
NProgress.start();
const response = createSealosApp();
(async () => {
const { SEALOS_DOMAIN, FORM_SLIDER_LIST_CONFIG } = await (() => loadInitData())();
Expand All @@ -69,14 +68,12 @@ const App = ({ Component, pageProps }: AppProps) => {
console.log('App is not running in desktop');
if (!process.env.NEXT_PUBLIC_MOCK_USER) {
localStorage.removeItem('session');

openConfirm(() => {
window.open(`https://${SEALOS_DOMAIN}`, '_self');
})();
}
}
})();
NProgress.done();
return response;
}, []);

Expand Down Expand Up @@ -133,35 +130,32 @@ const App = ({ Component, pageProps }: AppProps) => {
i18n?.changeLanguage?.(lang);
}, [refresh, router.pathname]);

// InternalAppCall
const setupInternalAppCallListener = async () => {
try {
const envs = await getPlatformEnv();
const event = async (e: MessageEvent) => {
const whitelist = [`https://${envs?.domain}`];
if (!whitelist.includes(e.origin)) {
return;
}
try {
if (e.data?.type === 'InternalAppCall' && e.data?.name) {
router.push({
pathname: '/app/detail',
query: {
name: e.data.name
}
});
}
} catch (error) {
console.log(error, 'error');
}
};
window.addEventListener('message', event);
return () => window.removeEventListener('message', event);
} catch (error) {}
};
useEffect(() => {
const setupInternalAppCallListener = async () => {
try {
const event = async (e: MessageEvent) => {
const whitelist = [`https://${SEALOS_DOMAIN}`];
if (!whitelist.includes(e.origin)) {
return;
}
try {
if (e.data?.type === 'InternalAppCall' && e.data?.name) {
router.push({
pathname: '/app/detail',
query: {
name: e.data.name
}
});
}
} catch (error) {
console.log(error, 'error');
}
};
window.addEventListener('message', event);
return () => window.removeEventListener('message', event);
} catch (error) {}
};
setupInternalAppCallListener();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ const Empty = () => {
>
<MyIcon name={'noEvents'} color={'transparent'} width={'80px'} height={'80px'} />
<Box py={8}>{t("You haven't created any application yet.")}</Box>
<Button
w={155}
mt={5}
variant={'primary'}
leftIcon={<MyIcon name="plus" />}
onClick={() => router.push('/app/edit')}
>
<Button w={155} mt={5} variant={'primary'} onClick={() => router.push('/app/edit')}>
{t('Create Application')}
</Button>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const jsonRes = <T = any>(
} else if (error?.code && error.code in ERROR_TEXT) {
msg = ERROR_TEXT[error.code];
}
console.log('error:', error);
console.log('error message:', msg);
console.error('===jsonRes error===\n ', error);
}

res.json({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ const Empty = () => {
>
<MyIcon name={'noEvents'} color={'transparent'} width={'80px'} height={'80px'} />
<Box py={8}>{t('job.You have no tasks yet')}</Box>
<Button
w={155}
mt={5}
variant={'primary'}
leftIcon={<MyIcon name="plus" />}
onClick={() => router.push('/job/edit')}
>
<Button w={155} mt={5} variant={'primary'} onClick={() => router.push('/job/edit')}>
{t('job.create')}
</Button>
</Box>
Expand Down
12 changes: 10 additions & 2 deletions frontend/providers/dbprovider/src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Menu, MenuList, MenuItem } from '@chakra-ui/react';
import { Menu, MenuList, MenuItem, MenuItemProps } from '@chakra-ui/react';

interface Props {
width: number;
Expand All @@ -8,18 +8,25 @@ interface Props {
isActive?: boolean;
child: React.ReactNode;
onClick: () => void;
isDisabled?: boolean;
}[];
}

const MyMenu = ({ width, Button, menuList }: Props) => {
const menuItemStyles = {
const menuItemStyles: MenuItemProps = {
borderRadius: 'sm',
py: 2,
display: 'flex',
alignItems: 'center',
_hover: {
backgroundColor: 'myWhite.600',
color: 'hover.blue'
},
_disabled: {
_hover: {
color: '#485264',
cursor: 'not-allowed'
}
}
};

Expand All @@ -34,6 +41,7 @@ const MyMenu = ({ width, Button, menuList }: Props) => {
>
{menuList.map((item, i) => (
<MenuItem
isDisabled={item?.isDisabled || false}
key={i}
{...menuItemStyles}
onClick={item.onClick}
Expand Down
20 changes: 5 additions & 15 deletions frontend/providers/dbprovider/src/components/RangeDate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import {
Flex,
Input,
Popover,
PopoverTrigger,
Img,
PopoverContent,
Button,
Box,
useTheme
} from '@chakra-ui/react';
import { format, parse, isValid, isAfter, isBefore } from 'date-fns';
import { useState, ChangeEventHandler, useEffect, useMemo } from 'react';
import { DateRange, SelectRangeEventHandler, DayPicker } from 'react-day-picker';
import { useQueryClient } from '@tanstack/react-query';
import { CalendarIcon } from '@chakra-ui/icons';
import { Box, Button, Popover, PopoverContent, PopoverTrigger, useTheme } from '@chakra-ui/react';
import { format } from 'date-fns';
import { useState } from 'react';
import { DateRange, DayPicker } from 'react-day-picker';
import 'react-day-picker/dist/style.css';

export default function RangeDate({
isDisabled = false,
Expand Down