From a01d054af174b788cfade5714855acfb6335dac2 Mon Sep 17 00:00:00 2001 From: jingyang <3161362058@qq.com> Date: Wed, 7 Aug 2024 11:41:59 +0800 Subject: [PATCH 1/4] update container status reason --- .../src/pages/app/detail/components/Pods.tsx | 15 +++++++----- .../providers/applaunchpad/src/types/app.d.ts | 2 +- .../providers/applaunchpad/src/utils/adapt.ts | 24 ++++++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx b/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx index 26b3b80c050..3660cdb194a 100644 --- a/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx @@ -98,14 +98,12 @@ const Pods = ({ {item.status.label} {!!item.status.reason && ( @@ -117,9 +115,14 @@ const Pods = ({ title: 'Restarts Num', key: 'restarts', render: (item: PodDetailType) => ( - + {item.restarts} - + {!!item.containerStatus.reason && ( + + ({item.containerStatus?.reason}) + + )} + ) }, { diff --git a/frontend/providers/applaunchpad/src/types/app.d.ts b/frontend/providers/applaunchpad/src/types/app.d.ts index 89d4a08340c..18200eec8a5 100644 --- a/frontend/providers/applaunchpad/src/types/app.d.ts +++ b/frontend/providers/applaunchpad/src/types/app.d.ts @@ -127,7 +127,6 @@ export interface PodStatusMapType { color: string; reason?: string; message?: string; - lastStateReason?: string; } export interface PodDetailType extends V1Pod { podName: string; @@ -142,6 +141,7 @@ export interface PodDetailType extends V1Pod { memory: number; podReason?: string; podMessage?: string; + containerStatus: PodStatusMapType; } export interface PodMetrics { podName: string; diff --git a/frontend/providers/applaunchpad/src/utils/adapt.ts b/frontend/providers/applaunchpad/src/utils/adapt.ts index 6c983109a35..3b7f5ad86e9 100644 --- a/frontend/providers/applaunchpad/src/utils/adapt.ts +++ b/frontend/providers/applaunchpad/src/utils/adapt.ts @@ -90,23 +90,18 @@ export const adaptPod = (pod: V1Pod): PodDetailType => { return { ...pod, podName: pod.metadata?.name || 'pod name', - // @ts-ignore status: (() => { const container = pod.status?.containerStatuses || []; if (container.length > 0) { const stateObj = container[0].state; - const lasteStateObj = container[0].lastState; if (stateObj) { const stateKeys = Object.keys(stateObj); - const key = stateKeys?.[0] as `${PodStatusEnum}`; + const key = stateKeys[0] as `${PodStatusEnum}`; if (key === PodStatusEnum.running) { return podStatusMap[PodStatusEnum.running]; } if (key && podStatusMap[key]) { - const lastStateReason = - lasteStateObj && lasteStateObj[key] ? lasteStateObj[key]?.reason : ''; return { - lastStateReason, ...podStatusMap[key], ...stateObj[key] }; @@ -115,6 +110,23 @@ export const adaptPod = (pod: V1Pod): PodDetailType => { } return podStatusMap.waiting; })(), + containerStatus: (() => { + const container = pod.status?.containerStatuses || []; + if (container.length > 0) { + const lastStateObj = container[0].lastState; + if (lastStateObj) { + const lastStateKeys = Object.keys(lastStateObj); + const key = lastStateKeys[0] as `${PodStatusEnum}`; + if (key && podStatusMap[key]) { + return { + ...podStatusMap[key], + ...lastStateObj[key] + }; + } + } + } + return podStatusMap.waiting; + })(), nodeName: pod.spec?.nodeName || 'node name', ip: pod.status?.podIP || 'pod ip', restarts: pod.status?.containerStatuses ? pod.status?.containerStatuses[0].restartCount : 0, From 4be51e6b1e8e43ae74199a6d371d7d5fbac85b9f Mon Sep 17 00:00:00 2001 From: jingyang <3161362058@qq.com> Date: Wed, 7 Aug 2024 11:59:36 +0800 Subject: [PATCH 2/4] update color --- .../applaunchpad/src/pages/app/detail/components/Pods.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx b/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx index 3660cdb194a..a500b890879 100644 --- a/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx +++ b/frontend/providers/applaunchpad/src/pages/app/detail/components/Pods.tsx @@ -118,7 +118,7 @@ const Pods = ({ {item.restarts} {!!item.containerStatus.reason && ( - + ({item.containerStatus?.reason}) )} From 3e7ec501986518dcf4910889511957710a69bb93 Mon Sep 17 00:00:00 2001 From: jingyang <3161362058@qq.com> Date: Wed, 7 Aug 2024 14:30:54 +0800 Subject: [PATCH 3/4] update uploadConvertData --- .../src/pages/self-hosting/product/index.tsx | 7 ++----- service/license/src/api/system.ts | 4 ++-- service/license/src/components/login/index.tsx | 18 +----------------- service/license/src/pages/signin.tsx | 3 +-- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/docs/website/src/pages/self-hosting/product/index.tsx b/docs/website/src/pages/self-hosting/product/index.tsx index f29c955a864..6e6b529412f 100644 --- a/docs/website/src/pages/self-hosting/product/index.tsx +++ b/docs/website/src/pages/self-hosting/product/index.tsx @@ -1,4 +1,3 @@ -import Link from '@docusaurus/Link'; import useWindow from '@site/src/hooks/useWindow'; import CheckIcon from '@site/static/price/check.svg'; import StarIcon from '@site/static/price/star.svg'; @@ -43,7 +42,7 @@ export default function Product() {
window.open('https://license.sealos.io/')} + onClick={() => window.open(`https://license.sealos.io/signin?bd_vid=${bd_vid}`)} className="rounded-md cursor-pointer hover:no-underline text-[#FFFFFFCC] hover:text-[#FFFFFFCC] bg-[#B7D8FF26] flex justify-center items-center font-semibold text-lg gap-2 py-3 px-4 lg:text-sm" > - window.open(`https://license.sealos.io/signin?external=true&bd_vid=${bd_vid}`) - } + onClick={() => window.open(`https://license.sealos.io/signin?bd_vid=${bd_vid}`)} > 获取
diff --git a/service/license/src/api/system.ts b/service/license/src/api/system.ts index 125b64fda38..5baaae3ba99 100644 --- a/service/license/src/api/system.ts +++ b/service/license/src/api/system.ts @@ -14,9 +14,9 @@ export const getPriceBonus = () => // handle baidu export const uploadConvertData = (newType: number[], url?: string) => { - const defaultUrl = 'https://sealos.run/'; + const defaultUrl = 'https://sealos.run/self-hosting'; const main_url = url || defaultUrl; - const bd_vid = sessionStorage.getItem('bd_vid'); + const bd_vid = localStorage.getItem('bd_vid'); if (!bd_vid) { return Promise.reject('upload convert data params error'); } diff --git a/service/license/src/components/login/index.tsx b/service/license/src/components/login/index.tsx index f8f350ada67..b7e2887dee9 100644 --- a/service/license/src/components/login/index.tsx +++ b/service/license/src/components/login/index.tsx @@ -15,7 +15,6 @@ import { TabIndicator, TabList, Tabs, - Image, useDisclosure } from '@chakra-ui/react'; import { useQuery } from '@tanstack/react-query'; @@ -106,22 +105,7 @@ export default function SigninComponent() { }, 500); return ( - + Sealos Cloud diff --git a/service/license/src/pages/signin.tsx b/service/license/src/pages/signin.tsx index c638eda3e69..a7bbc4f4234 100644 --- a/service/license/src/pages/signin.tsx +++ b/service/license/src/pages/signin.tsx @@ -22,9 +22,8 @@ export default function SigninPage() { useEffect(() => { const { bd_vid } = router.query; if (bd_vid) { - sessionStorage.setItem('bd_vid', bd_vid as string); + localStorage.setItem('bd_vid', bd_vid as string); } - // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ; From 1e8b284f59a13afc0962b4609aea7345c0064262 Mon Sep 17 00:00:00 2001 From: jingyang <3161362058@qq.com> Date: Wed, 7 Aug 2024 14:39:28 +0800 Subject: [PATCH 4/4] fix mock app --- .../providers/applaunchpad/src/mock/apps.ts | 176 +----------------- 1 file changed, 4 insertions(+), 172 deletions(-) diff --git a/frontend/providers/applaunchpad/src/mock/apps.ts b/frontend/providers/applaunchpad/src/mock/apps.ts index d86a981a69b..9b77b73fa2d 100644 --- a/frontend/providers/applaunchpad/src/mock/apps.ts +++ b/frontend/providers/applaunchpad/src/mock/apps.ts @@ -196,7 +196,8 @@ export const MOCK_PODS: PodDetailType[] = [ yData: new Array(30).fill('0') }, cpu: 0, - memory: 0 + memory: 0, + containerStatus: podStatusMap.running }, { podName: '2', @@ -216,177 +217,8 @@ export const MOCK_PODS: PodDetailType[] = [ yData: new Array(30).fill('0') }, cpu: 0, - memory: 0 - }, - { - podName: '3', - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - - { - podName: '4', - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - - { - podName: '5', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - { - podName: '6', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - { - podName: '7', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - { - podName: '8', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - - { - podName: '9', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 - }, - - { - podName: 'dafsdd2sgsd6gsdg', - - nodeName: 'dafda-fasd-fas', - ip: '311.241.41.41', - restarts: 10, - age: '22', - status: podStatusMap.running, - usedCpu: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - usedMemory: { - name: '', - xData: new Array(30).fill(0), - yData: new Array(30).fill('0') - }, - cpu: 0, - memory: 0 + memory: 0, + containerStatus: podStatusMap.running } ];