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:desktop getResource API and optimize alert icon #5172

Merged
merged 2 commits into from
Oct 28, 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 docs/website/src/pages/components/Header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
justify-content: center;
align-items: center;
flex-direction: column;
padding-top: 48px; // sale
// padding-top: 48px; // sale

.header-img {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Home = () => {
</Helmet>
<Layout>
<div className="home">
<SaleBanner />
{/* <SaleBanner /> */}
<HomeHeader isPc={isPc} />
<Capability isPc={isPc} />
<Introduce isPc={isPc} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/desktop/src/components/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default function Account() {

<CustomTooltip placement={'bottom'} label={t('common:notification')}>
<Center cursor={'pointer'} {...baseItemStyle} onClick={() => showDisclosure.onOpen()}>
<NotificationIcon />
<NotificationIcon color={'white'} />
</Center>
</CustomTooltip>
<Notification key={'notification'} disclosure={showDisclosure} onAmount={onAmount} />
Expand Down
15 changes: 13 additions & 2 deletions frontend/desktop/src/components/notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import request from '@/services/request';
import useAppStore from '@/stores/app';
import { formatTime } from '@/utils/tools';
import { Box, Button, Flex, Text, UseDisclosureReturn } from '@chakra-ui/react';
import { ClearOutlineIcon, CloseIcon, WarnIcon, useMessage } from '@sealos/ui';
import { ClearOutlineIcon, CloseIcon, NotificationIcon, WarnIcon, useMessage } from '@sealos/ui';
import { useMutation, useQuery } from '@tanstack/react-query';
import clsx from 'clsx';
import { produce } from 'immer';
Expand Down Expand Up @@ -143,6 +143,17 @@ export default function Notification(props: NotificationProps) {
}
}, [i18n.language, refetch]);

const getNotificationIcon = (from: string | undefined) => {
switch (from) {
case 'Debt-System':
return <WarnIcon />;
case 'Active-System':
return '🎉';
default:
return <NotificationIcon color={'brightBlue.300'} />;
}
};

return disclosure.isOpen ? (
<>
<Box className={styles.bg} onClick={resetMessageState} cursor={'auto'}></Box>
Expand Down Expand Up @@ -316,7 +327,7 @@ export default function Notification(props: NotificationProps) {
color={'white'}
>
<Flex alignItems={'center'}>
<WarnIcon />
{getNotificationIcon(MessageConfig.popupMessage?.i18n['en']?.from)}
<Text fontSize={'16px'} fontWeight={600} ml="10px">
{MessageConfig.popupMessage?.i18n[i18n.language]?.title}
</Text>
Expand Down
11 changes: 6 additions & 5 deletions frontend/desktop/src/pages/api/desktop/getResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)

for (const pod of result.body.items) {
if (pod.status?.phase === 'Succeeded') continue;
if (!pod?.spec) continue;

totalPodCount++;

if (pod.status?.phase === 'Running') {
runningPodCount++;
}
if (!pod?.spec) continue;
if (pod.status?.phase !== 'Running') continue;

runningPodCount++;

for (const container of pod.spec.containers) {
for (const container of pod?.spec.containers) {
if (!container?.resources) continue;
const limits = container?.resources.limits as {
cpu: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/desktop/src/types/crd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export type TNotification = {
desktopPopup: boolean;
i18n: {
[key in string]: {
from: string;
from: string; // Debt-System Active-System
message: string;
title: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export default function NotificationIcon(props: IconProps) {
width="21px"
height="20px"
viewBox="0 0 21 20"
fill="none"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M10.6247 2.81193C9.96309 2.81193 9.42672 3.3483 9.42672 4.00993C9.42672 4.18651 9.46461 4.35374 9.53298 4.5044C9.89085 4.44143 10.2565 4.40927 10.6247 4.40927C10.993 4.40927 11.3586 4.44143 11.7165 4.5044C11.7848 4.35374 11.8227 4.18651 11.8227 4.00993C11.8227 3.3483 11.2864 2.81193 10.6247 2.81193ZM13.2449 4.98549C13.3581 4.68167 13.4201 4.35287 13.4201 4.00993C13.4201 2.46611 12.1685 1.2146 10.6247 1.2146C9.0809 1.2146 7.82939 2.46611 7.82939 4.00993C7.82939 4.35287 7.89136 4.68167 8.00455 4.98549C7.53661 5.20494 7.10096 5.48473 6.71319 5.8208C5.65525 6.73768 5.03405 8.00783 5.03405 9.361C5.03405 11.0443 4.61854 12.2361 4.12939 13.0634L4.12128 13.0771C3.80675 13.609 3.5611 14.0245 3.39633 14.3227C3.31398 14.4718 3.24151 14.6099 3.18883 14.7282C3.1627 14.7869 3.13388 14.8574 3.11143 14.9322C3.09468 14.9879 3.05348 15.1325 3.07062 15.3078C3.08002 15.4041 3.10161 15.5952 3.21289 15.7903C3.32417 15.9853 3.4777 16.1012 3.55575 16.1583C3.68293 16.2513 3.8102 16.2912 3.87358 16.3087C3.94839 16.3294 4.02108 16.3417 4.08135 16.3497C4.20185 16.3659 4.34216 16.3741 4.48841 16.3792C4.77993 16.3893 5.18754 16.3893 5.70115 16.3893H7.5307C7.88534 17.7672 9.13614 18.7853 10.6247 18.7853C12.1133 18.7853 13.3641 17.7672 13.7187 16.3893H15.5483C16.0619 16.3893 16.4695 16.3893 16.761 16.3792C16.9073 16.3741 17.0476 16.3659 17.1681 16.3497C17.2284 16.3417 17.3011 16.3294 17.3759 16.3087C17.4392 16.2912 17.5665 16.2513 17.6937 16.1583C17.7717 16.1012 17.9253 15.9853 18.0366 15.7903C18.1478 15.5952 18.1694 15.4041 18.1788 15.3078C18.196 15.1325 18.1548 14.9879 18.138 14.9322C18.1156 14.8574 18.0867 14.7869 18.0606 14.7282C18.0079 14.6099 17.9355 14.4718 17.8531 14.3227C17.6883 14.0245 17.4427 13.609 17.1281 13.077L17.1201 13.0634C16.6309 12.2361 16.2154 11.0443 16.2154 9.361C16.2154 8.00783 15.5942 6.73768 14.5363 5.8208C14.1485 5.48473 13.7128 5.20494 13.2449 4.98549ZM11.834 6.16481C11.8442 6.16777 11.8543 6.17053 11.8645 6.17309C12.479 6.34249 13.0377 6.63576 13.4901 7.02788C14.2295 7.6687 14.6181 8.51125 14.6181 9.361C14.6181 11.3225 15.1064 12.7963 15.7451 13.8764C15.9648 14.2479 16.1429 14.5491 16.2821 14.7903C16.075 14.7919 15.8264 14.7919 15.53 14.7919H5.71946C5.42304 14.7919 5.1744 14.7919 4.96732 14.7903C5.10659 14.5491 5.28465 14.2479 5.50434 13.8764C6.14302 12.7963 6.63139 11.3225 6.63139 9.361C6.63139 8.51125 7.01993 7.6687 7.75934 7.02788C8.21179 6.63576 8.7704 6.34249 9.38493 6.17309C9.39513 6.17054 9.40529 6.16777 9.41541 6.16481C9.80105 6.06138 10.2083 6.0066 10.6247 6.0066C11.0412 6.0066 11.4484 6.06138 11.834 6.16481ZM9.24108 16.3893C9.51727 16.8667 10.0335 17.1879 10.6247 17.1879C11.216 17.1879 11.7322 16.8667 12.0084 16.3893H9.24108Z"
fill="white"
fill="currentColor"
/>
</Icon>
);
Expand Down
Loading