Skip to content

Commit

Permalink
style: rename the plugin from Monitor to Kube Panel and update UI sty…
Browse files Browse the repository at this point in the history
…le (#4269)

* feat: lens demo of web version

* chore: add & remove some packages

* fix: connect to desktop bug and change icon

* init: plugin Monitor init

* style: restore frontend/pnpm-workspace.yaml & pnpm-lock.yaml and create new ones in plugins/monitor

* restore: frontend/Makefile

* restore: frontend/pnpm-workspace.yaml

* restore

* style: rename the plugin from Monitor to Kube Panel

* style: update ui style
  • Loading branch information
Wishrem authored Nov 9, 2023
1 parent f21b7c9 commit d822323
Show file tree
Hide file tree
Showing 188 changed files with 425 additions and 362 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "monitor",
"name": "kubepanel",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down Expand Up @@ -40,10 +40,11 @@
"react-dom": "^18",
"request": "^2.88.2",
"rfc6902": "^5.0.1",
"sealos-desktop-sdk": "workspace:*",
"type-fest": "^4.4.0",
"typed-regex": "^0.0.8",
"zustand": "^4.3.9",
"sealos-desktop-sdk": "workspace:*"
"uuid": "^9.0.1",
"zustand": "^4.3.9"
},
"devDependencies": {
"@types/js-yaml": "^4.0.8",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const PieChart = ({ title, data, color }: PieChartProps) => {
}
}
},
label: {
type: 'inner'
},
label: false,
legend: {
layout: 'vertical' as 'vertical',
position: 'bottom' as 'bottom'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const KubeRecord = ({

return (
<div
className={`grid border-b border-solid border-color-border ${
className={`grid border-b border-solid border-zinc-400 ${
padding ? 'py-2' : ''
} last:border-b-0`}
style={{ gridTemplateColumns: 'minmax(30%, min-content) auto' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
const NonePage = () => {
const router = useRouter();
useEffect(() => {
router.push('/monitor');
router.push('/kubepanel');
}, [router]);

return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>Sealos Monitor Plugin</title>
<title>Kube Panel</title>
<meta name="description" content="Generated by Sealos Team" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function Document() {
return (
<Html lang="en">
<Head>
<meta name="application-name" content="Sealos Desktop App Demo" />
<meta name="application-name" content="Kube Panel" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { KubeObjectInfoList } from '@/components/kube/object/detail/kube-object-
import DrawerTitle from '../../drawer/drawer-title';
import { entries } from 'lodash';
import { Input } from 'antd';
import DrawerPanel from '../../drawer/drawer-panel';

interface Props {
configMap?: ConfigMap;
Expand All @@ -26,24 +27,25 @@ const ConfigMapDetail = ({ configMap, open, onClose }: Props) => {

return (
<Drawer open={open} title={`ConfigMap: ${configMap.getName()}`} onClose={onClose}>
<KubeObjectInfoList obj={configMap} />
<DrawerPanel>
<KubeObjectInfoList obj={configMap} />
</DrawerPanel>
<div className="m-8" />
{data.length > 0 && (
<>
<DrawerTitle>Data</DrawerTitle>
<DrawerPanel title="Data">
{data.map(([name, value = '']) => (
<div key={name} className="mb-2">
<div className="text-zinc-300 font-bold pb-0.5">{name}</div>
{name && <div className="text-black font-medium pb-0.5">{name}</div>}
<Input.TextArea
classNames={{ textarea: 'font-mono' }}
classNames={{ textarea: 'w-full font-mono' }}
wrap="off"
rows={6}
rows={10}
disabled
value={value}
/>
</div>
))}
</>
</DrawerPanel>
)}
</Drawer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { KubeObjectAge } from '@/components/kube/object/kube-object-age';
import { ConfigMap } from '@/k8slens/kube-object';
import { ColumnsType } from 'antd/es/table';
import { observer } from 'mobx-react';
import { Table } from 'antd';
import { useState } from 'react';
import { CONFIG_MAP_STORE } from '@/store/static';
import { useQuery } from '@tanstack/react-query';
import ConfigMapDetail from './config-map-detail';
import Table from '../../table/table';
interface DataType {
key: string;
name: string;
Expand Down Expand Up @@ -55,10 +55,9 @@ const ConfigMapOverviewPage = () => {
return (
<>
<Table
title={() => <span className="p-4 mb-4 text-xl font-light">Config Maps</span>}
title={"Config Maps"}
columns={columns}
dataSource={dataSource}
scroll={{ x: true }}
onRow={(record) => ({
onClick: () => {
const { key } = record;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import DrawerTitle from './drawer-title';

interface Props {
title?: React.ReactNode;
children: React.ReactNode;
}

const DrawerPanel = ({ title, children }: Props) => {
return (
<div className="pb-2">
{title && typeof title === 'string' ? <DrawerTitle>{title}</DrawerTitle> : title}
<div className="px-7">{children}</div>
</div>
);
};

export default DrawerPanel;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface Props {
}

const DrawerTitle = ({ children }: Props) => {
return <div className="p-2 bg-gray-600 text-white font-bold text-sm">{children}</div>;
return <div className="p-3 bg-gray-600 text-white font-medium text-base">{children}</div>;
};

export default DrawerTitle;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Drawer = ({ title, children, open, onClose }: Props) => {
return (
<AntdDrawer
classNames={{ body: 'bg-gray-300', header: 'bg-zinc-600' }}
styles={{ body: { padding: 0 } }}
open={open}
title={<span className="text-white">{title}</span>}
width="60vh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ interface Props {
export default function AppLayout({ children, onClickSideNavItem }: Props) {
return (
<Layout>
{/* <Header>Header</Header> */}
<Layout hasSider>
<Sider width={256} theme="light" breakpoint="lg" collapsedWidth="0">
<ResourceSideNav onClick={onClickSideNavItem} />
</Sider>
<Sider width={256} theme="light" breakpoint="lg" collapsedWidth="0">
<ResourceSideNav onClick={onClickSideNavItem} />
</Sider>
<Layout>
<Content style={{ margin: '24px' }}>{children}</Content>
</Layout>
{/* <Footer>Footer</Footer> */}
</Layout>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ function getItem(
const items: MenuProps['items'] = [
getItem('Workload', 'workload', <DashboardOutlined rev={undefined} />, [
getItem('Overview', SideNavItemKey.Overview),
getItem('Pod', SideNavItemKey.Pod),
getItem('Deployment', SideNavItemKey.Deployment),
getItem('StatefulSet', SideNavItemKey.StatefulSet)
getItem('Pods', SideNavItemKey.Pod),
getItem('Deployments', SideNavItemKey.Deployment),
getItem('Stateful Sets', SideNavItemKey.StatefulSet)
]),
getItem('Config', 'config', <SettingOutlined rev={undefined} />, [
getItem('ConfigMap', SideNavItemKey.ConfigMap)
getItem('Config Maps', SideNavItemKey.ConfigMap)
]),
getItem('Storage', 'storage', <DatabaseOutlined rev={undefined} />, [
getItem('Persistent Volume Claim', SideNavItemKey.PersistentVolumeClaim)
getItem('Persistent Volume Claims', SideNavItemKey.PersistentVolumeClaim)
])
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { PersistentVolumeClaim, Pod } from '@/k8slens/kube-object';
import Drawer from '../../drawer/drawer';
import { KubeObjectInfoList } from '@/components/kube/object/detail/kube-object-detail-info-list';
import { KubeRecord } from '@/components/kube/kube-record';
import { KubeBadge } from '@/components/kube/kube-badge';
import React from 'react';
import DrawerPanel from '../../drawer/drawer-panel';

interface Props {
volumeClaim?: PersistentVolumeClaim;
pods: Pod[];
open: boolean;
onClose: () => void;
}
const PersistentVolumeClaimDetail = ({ volumeClaim, pods, open, onClose }: Props) => {
if (!volumeClaim) return null;

if (!(volumeClaim instanceof PersistentVolumeClaim)) {
// logger.error("[PersistentVolumeClaimDetail]: passed object that is not an instanceof PersistentVolumeClaim", volumeClaim);

return null;
}

const { storageClassName, accessModes } = volumeClaim.spec;

// const storageClassDetailsUrl = getDetailsUrl(storageClassApi.formatUrlForNotListing({
// name: storageClassName,
// }));

return (
<Drawer open={open} title={`PersistentVolumeClaim: ${volumeClaim.getName()}`} onClose={onClose}>
<DrawerPanel>
<KubeObjectInfoList obj={volumeClaim} />
<KubeRecord name={'Access Modes'} value={accessModes?.join(', ')} />
<KubeRecord name="Storage Class Names" value={storageClassName} />
<KubeRecord name="Storage" value={volumeClaim.getStorage()} />
<KubeRecord
name="Pods"
value={volumeClaim.getPods(pods).map((pod) => (
<span key={pod.getName()} className="mr-1">
{pod.getName()}
</span>
))}
/>
<KubeRecord name="Status" value={volumeClaim.getStatus()} />
</DrawerPanel>

<DrawerPanel title="Selector">
<KubeRecord
name="Match Labels"
value={volumeClaim.getMatchLabels().map((label) => (
<KubeBadge key={label} label={label} />
))}
/>
<KubeRecord
name="Match Expressions"
value={volumeClaim.getMatchExpressions().map(({ key, operator, values }, i) => (
<React.Fragment key={i}>
<KubeRecord name="Key" value={key} />
<KubeRecord name="Operator" value={operator} />
<KubeRecord name="Values" value={values?.join(', ')} />
</React.Fragment>
))}
/>
</DrawerPanel>
</Drawer>
);
};

export default PersistentVolumeClaimDetail;
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { PersistentVolumeClaim, Pod } from '@/k8slens/kube-object';
import { PERSISTENT_VOLUME_CLAIM_STORE, POD_STORE } from '@/store/static';
import { RequestController } from '@/utils/request-controller';
import { useQuery } from '@tanstack/react-query';
import { Table } from 'antd';
import { ColumnsType } from 'antd/es/table';
import { observer } from 'mobx-react';
import { useRef, useState } from 'react';
import PersistentVolumeClaimDetail from './volume-claim-detail';
import Table from '../../table/table';

interface DataType {
key: string;
Expand Down Expand Up @@ -51,6 +51,7 @@ const columns: ColumnsType<DataType> = [
title: 'Pods',
dataIndex: 'podsNames',
key: 'pods',
ellipsis: true,
render: (podsNames: string[]) =>
podsNames.map((name) => (
<span key={name} className="text-blue-300 mr-1">
Expand Down Expand Up @@ -93,10 +94,9 @@ const PersistentVolumeClaimOverviewPage = () => {
return (
<>
<Table
title={() => <span className="p-4 mb-4 text-xl font-light">Persistent Volume Claims</span>}
title={'Persistent Volume Claims'}
columns={columns}
dataSource={dataSource}
scroll={{ x: true }}
onRow={(record) => ({
onClick: () => {
const { key } = record;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ConfigProvider, TableProps } from 'antd';
import { Table as AntdTable } from 'antd';
import { blue } from '@ant-design/colors';

type DefaultRecordType = Record<string, any>;
type PanelRender<RecordType> = (data: readonly RecordType[]) => React.ReactNode;

interface Props<RecordType = unknown> extends Omit<TableProps<RecordType>, 'title'> {
title?: string | PanelRender<RecordType>;
}

const TableStringTile = ({ title }: { title: string }) => {
return <span className="p-4 mb-4 text-xl font-light">{title}</span>;
};

function Table<RecordType extends DefaultRecordType>(tableProps: Props<RecordType>) {
const { scroll = { x: true }, pagination = false, title } = tableProps;

return (
<ConfigProvider
theme={{
components: {
Table: {
rowHoverBg: blue[0]
}
}
}}
>
<AntdTable
{...tableProps}
rowClassName="cursor-pointer"
title={typeof title === 'string' ? () => <TableStringTile title={title} /> : title}
scroll={scroll}
pagination={pagination}
/>
</ConfigProvider>
);
}

export default Table;
Loading

0 comments on commit d822323

Please sign in to comment.