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:workorder overflow issue #5160

Merged
merged 5 commits into from
Oct 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions frontend/providers/template/src/pages/api/resource/delJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { jsonRes } from '@/services/backend/response';
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
const { instanceName } = req.query as { instanceName: string };

if (!instanceName) {
throw new Error('Job name is empty');
}
Expand All @@ -15,10 +16,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
kubeconfig: await authSession(req.headers)
});

// 删除 Job
const result = await k8sBatch.deleteNamespacedJob(instanceName, namespace);
const deleteOptions = {
propagationPolicy: 'Foreground'
};

const result = await k8sBatch.deleteNamespacedJob(
instanceName,
namespace,
undefined,
undefined,
undefined,
undefined,
deleteOptions.propagationPolicy,
deleteOptions
);

jsonRes(res, { data: result });
jsonRes(res, { data: 'success' });
} catch (err: any) {
jsonRes(res, {
code: 500,
Expand Down
5 changes: 3 additions & 2 deletions frontend/providers/workorder/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"userId": "userId",
"other": "other",
"fastgpt": "FastGPT",
"account_center": "Account Center"
}
"account_center": "Account Center",
"input_placeholder": "Enter your message here, you can paste the picture and upload it directly"
}
5 changes: 3 additions & 2 deletions frontend/providers/workorder/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"userId": "用户ID",
"other": "其他",
"fastgpt": "FastGPT",
"account_center": "账号中心"
}
"account_center": "账号中心",
"input_placeholder": "在此输入消息,可粘贴图片直接上传"
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const AppBaseInfo = ({ app }: { app: WorkOrderDB }) => {
</Icon>
<Text>{t('Description')}</Text>
</Flex>
<Flex mt="12px" p={'16px'} borderRadius={'4px'} bg="#F8FAFB">
<Text color={'#24282C'}>{app?.description} </Text>
<Flex mt="12px" p={'16px'} borderRadius={'4px'} bg="#F8FAFB" overflow={'hidden'}>
<Text color={'#24282C'}>{app?.description}</Text>
</Flex>
</Box>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { fetchEventSource } from '@fortaine/fetch-event-source';
import { throttle } from 'lodash';
import { useTranslation } from 'next-i18next';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';

const statusAnimation = keyframes`
0% {
Expand Down Expand Up @@ -331,6 +331,25 @@ const AppMainInfo = ({
}
}, [app?.dialogs, isManuallyHandled]);

const handlePaste = useCallback(async (e: React.ClipboardEvent) => {
const items = e.clipboardData.items;
const files: File[] = [];

for (let i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
const blob = items[i].getAsFile();
if (blob) {
files.push(blob);
}
}
}

if (files.length > 0) {
e.preventDefault();
await uploadFiles(files);
}
}, []);

return (
<>
<Text fontSize={'18px'} fontWeight={500} color={'#24282C'} mt="24px" ml="36px">
Expand Down Expand Up @@ -449,6 +468,7 @@ const AppMainInfo = ({
}
border={'1px solid #EAEBF0'}
flexDirection={'column'}
onPaste={handlePaste}
>
{uploadedFiles && (
<Flex alignItems={'center'} gap={'4px'} wrap={'wrap'} mb={'4px'}>
Expand Down Expand Up @@ -517,7 +537,7 @@ const AppMainInfo = ({

<Textarea
ref={TextareaDom}
placeholder="在这里输入你的消息..."
placeholder={t('input_placeholder')}
variant={'unstyled'}
value={text}
p={'0'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ const Header = ({
alignItems={'center'}
cursor={'pointer'}
onClick={() => {
router.replace({
router.push({
pathname: '/workorders',
query: {
page: router.query?.page,
status: router.query?.status
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default function OrderDetail({ orderId }: { orderId: string }) {
border={'1px solid #DEE0E2'}
borderRadius={'md'}
flexDirection={'column'}
overflow={'hidden'}
>
{workOrderDetail && workOrderDetail.dialogs?.length ? (
<AppMainInfo
Expand Down
19 changes: 15 additions & 4 deletions frontend/providers/workorder/src/pages/workorders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ function Home() {
const { Loading } = useLoading();
const { t } = useTranslation();
const [initialized, setInitialized] = useState(false);
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const router = useRouter();
const [page, setPage] = useState(() => {
const queryPage = Number(router.query.page);
return !isNaN(queryPage) && queryPage > 0 ? queryPage : 1;
});
const [pageSize, setPageSize] = useState(10);
const [orderStatus, setOrderStatus] = useState<WorkOrderStatus>(
(router.query?.status as WorkOrderStatus) || WorkOrderStatus.All
);
Expand Down Expand Up @@ -169,9 +172,17 @@ function Home() {
{!!data?.totalCount && (
<Pagination
totalItems={data?.totalCount || 0}
itemsPerPage={10}
itemsPerPage={pageSize}
currentPage={page}
setCurrentPage={setPage}
setCurrentPage={(page) => {
router.push({
query: {
...router.query,
page: page.toString()
}
});
setPage(page);
}}
/>
)}
</Flex>
Expand Down
Loading