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

update:dbprovider Pause Hint message #4902

Merged
merged 5 commits into from
Jul 19, 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
2 changes: 1 addition & 1 deletion frontend/desktop/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"expected_to_use_next_month": "Expected to use next month",
"expected_used": "Expected used",
"failed_to_generate_invitation_link": "Failed to generate invitation link",
"flow": "Flow",
"flow": "Traffic",
"from": "From",
"generate_invitation_link": "Generate invitation link",
"get_code": "verification",
Expand Down
42 changes: 22 additions & 20 deletions frontend/desktop/src/components/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,26 +405,28 @@ export default function Notification(props: TNotification) {
>
{t('common:detail')}
</Button>
<Button
w="78px"
h="32px"
variant={'unstyled'}
bg={'white'}
color={'grayModern.900'}
borderRadius={'4px'}
onClick={() => {
const temp = MessageConfig.popupMessage;
setMessageConfig(
produce((draft) => {
draft.popupMessage = undefined;
})
);
readMsgMutation.mutate([temp?.metadata?.name || '']);
handleCharge();
}}
>
{t('common:charge')}
</Button>
{MessageConfig.msgDetail?.spec?.from === 'Debt-System' && (
<Button
w="78px"
h="32px"
variant={'unstyled'}
bg={'white'}
color={'grayModern.900'}
borderRadius={'4px'}
onClick={() => {
const temp = MessageConfig.popupMessage;
setMessageConfig(
produce((draft) => {
draft.popupMessage = undefined;
})
);
readMsgMutation.mutate([temp?.metadata?.name || '']);
handleCharge();
}}
>
{t('common:charge')}
</Button>
)}
</Flex>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
if (global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
if (!global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
const kubeconfig = await authSession(req.headers);
const domain = global.AppConfig.cloud.domain;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
if (global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
if (!global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
const { k8sCore, namespace } = await getK8s({
kubeconfig: await authSession(req.headers)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type UpdateUserGuideParams = {

export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
if (global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
if (!global.AppConfig.common.guideEnabled) return jsonRes(res, { data: null });
const { activityType, phase, phasePage, shouldSendGift } = req.body as UpdateUserGuideParams;

if (!activityType || !phase || !phasePage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"Password": "Password",
"Pause": "Pause",
"Pause Error": "Failed to pause the database",
"Pause Hint": "Please note that the database cannot be modified while paused, but storage fees will still apply. Please confirm to proceed.",
"Pause Hint": "Pausing the service will stop the calculation of charges for CPU and memory, but charges for storage and external network ports will still apply. Would you like to pause now?",
"Pause Success": "Database paused",
"Paused": "Paused",
"Pausing": "Pausing",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"Password": "密码",
"Pause": "暂停",
"Pause Error": "数据库暂停失败",
"Pause Hint": "请注意,暂停状态下无法变更数据库,并且存储券仍会收费,请确认!",
"Pause Hint": "暂停服务将停止计算 CPU 和内存等费用,但存储和外网端口仍将产生费用。是否现在暂停?",
"Pause Success": "数据库已暂停",
"Paused": "已暂停",
"Pausing": "暂停中",
Expand Down
6 changes: 3 additions & 3 deletions frontend/providers/workorder/src/pages/api/cronjob/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jsonRes } from '@/services/backend/response';
import type { NextApiRequest, NextApiResponse } from 'next';
import { Cron } from 'croner';

const adminToken = process.env.ADMIN_API_TOKEN;
const adminId = process.env.ADMIN_API_TOKEN;

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
Expand All @@ -14,10 +14,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
process.env.NODE_ENV === 'production' ? '0,30 10-17 * * 1-5' : '* * * * *',
async () => {
const result = await (
await fetch(`${baseurl}/api/workorder/check`, {
await fetch(`${baseurl}/api/workorder/check?adminId=${adminId}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${adminToken}`,
Authorization: `Bearer ${adminId}`,
'Content-Type': 'application/json'
}
})
Expand Down
23 changes: 9 additions & 14 deletions frontend/providers/workorder/src/pages/api/workorder/check.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { verifyDesktopToken } from '@/services/backend/auth';
import { jsonRes } from '@/services/backend/response';
import { getUserById } from '@/services/db/user';
import { fetchPendingOrders, fetchProcessingOrders, updateOrder } from '@/services/db/workorder';
import { WorkOrderDB, WorkOrderStatus } from '@/types/workorder';
import { WithId } from 'mongodb';
import { NextApiRequest, NextApiResponse } from 'next';

const feishuUrl = process.env.ADMIN_FEISHU_URL;
Expand Down Expand Up @@ -98,21 +96,18 @@ const getFeishuForm = ({

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const adminToken = req.headers['authorization']?.split(' ')[1];
if (!adminToken) {
return jsonRes(res, {
code: 401,
message: "'token is invaild'"
});
}
const payload = await verifyDesktopToken(adminToken);
if (!payload?.userId) {
const { adminId } = req.query as {
adminId: string;
};

if (!adminId) {
return jsonRes(res, {
code: 401,
message: "'token is invaild'"
});
}
const user = await getUserById(payload?.userId);

const user = await getUserById(adminId);
if (!user?.isAdmin) {
return jsonRes(res, {
code: 403,
Expand Down Expand Up @@ -150,14 +145,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...overdueAutoCloseIn7Days.map((order) =>
updateOrder({
orderId: order.orderId,
userId: payload.userId,
userId: user.userId,
updates: { status: WorkOrderStatus.Completed }
})
),
...recentUnresponded.map((order) =>
updateOrder({
orderId: order.orderId,
userId: payload.userId,
userId: user.userId,
updates: { status: WorkOrderStatus.Pending }
})
)
Expand Down
Loading