Skip to content

Commit

Permalink
Merge pull request #15 from KubeLilin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yoyofx authored Oct 7, 2023
2 parents cf682af + ec3d6ca commit 2d1c94b
Show file tree
Hide file tree
Showing 68 changed files with 4,400 additions and 616 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 yoyofxteam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM kubelilin/nginx_container:v1.23.1
FROM registry.cn-beijing.aliyuncs.com/kubelilin/nginx:alpine3.17

COPY src/dist/ /usr/share/nginx/html/
COPY src/default.conf /etc/nginx/conf.d/default.conf
37 changes: 34 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ export default defineConfig({
{
name: "clusters",
path: "/resources/clusters",
component:"./resources/clusters/clusters"
component:"./resources/clusters/clusters",
},
{
name: "clusterinfo",
path: "/resources/clusterinfo",
component:"./resources/clusterinfo",
},
{
name: "workloads",
path: "/resources/workloads",
component:"./resources/workloads",
},
{
name: "namespaces",
Expand All @@ -141,7 +151,12 @@ export default defineConfig({
name: "buildimagelist",
path: "/resources/buildimagelist",
component:"./resources/buildimagelist"
}
},
{
name: "components",
path: "/resources/dapr-components",
component:"./resources/dapr-components"
},
]
},
{
Expand Down Expand Up @@ -170,6 +185,22 @@ export default defineConfig({
},
]
},
{
name:'runtime',
path:'/runtime',
routes:[
{
name: "namespace",
path: "/runtime/namespace",
component:"./runtime/namespace"
},
{
name: "components",
path: "/runtime/dapr-components",
component:"./runtime/dapr-components"
},
]
},
{
name:'devops',
path:'/devops',
Expand Down Expand Up @@ -279,7 +310,7 @@ export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
mfsu: {},
// mfsu: {},
webpack5: {},
exportStatic: {},
define: {
Expand Down
7 changes: 3 additions & 4 deletions src/config/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ const Settings: LayoutSettings & {
pwa?: boolean;
logo?: string;
} = {
navTheme: 'dark',
primaryColor: '#722ED1',
navTheme: 'realDark',
primaryColor: '#FAAD14',
layout: 'mix',
contentWidth: 'Fluid',
fixedHeader: true,
fixSiderbar: true,
colorWeak: false,
headerHeight:24,
headerHeight:43,
title: 'KubeLilin',
pwa: false,
logo: '/icon.svg',
iconfontUrl: '',
menu: {
locale: false,
defaultOpenAll: true,

}
};

Expand Down
4 changes: 2 additions & 2 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"lodash": "^4.17.11",
"lodash-decorators": "^6.0.0",
"moment": "^2.25.3",
"moment-duration-format": "^2.3.2",
"numeral": "^2.0.6",
"nzh": "^1.0.3",
"omit.js": "^2.0.2",
Expand Down Expand Up @@ -130,6 +131,5 @@
},
"gitHooks": {
"commit-msg": "fabric verify-commit"
},
"__npminstall_done": false
}
}
Binary file added src/public/git_v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/src/components/RightContent/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
.right {
display: flex;
float: right;
height: 48px;
height: 68px;
margin-left: auto;
overflow: hidden;
.action {
display: flex;
align-items: center;
height: 48px;
height: 68px;
padding: 0 12px;
cursor: pointer;
transition: all 0.3s;
Expand Down
2 changes: 1 addition & 1 deletion src/src/components/RightContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const GlobalHeaderRight: React.FC = () => {
defaultValue="Lilin"
options={[
{
label: <a href="http://sgr.yoyogo.run">sgr</a>,
label: <a href="">kubelilin</a>,
value: 'Lilin',
},

Expand Down
2 changes: 1 addition & 1 deletion src/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"short_name": "Ant Design Pro",
"display": "standalone",
"start_url": "./?utm_source=homescreen",
"theme_color": "#002140",
"theme_color": "#FAAD14",
"background_color": "#001529",
"icons": [
{
Expand Down
11 changes: 3 additions & 8 deletions src/src/pages/account/tenant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,9 @@ const Tenant: React.FC = () => {
valueType: 'option',
render: (_, record) => [
<a key="id" onClick={async ()=>{
let res=await changeTenantStatus(record);
console.log(res);
if ( res?.success){
actionRef.current?.reload();

}else{

}
let res=await changeTenantStatus(record)
console.log(res)
actionRef.current?.reload()
}}>{record.status==0?"启用":"停用"}</a>
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import ProForm, {
DrawerForm, ModalForm, ProFormGroup, ProFormInstance,
ProFormSwitch, ProFormTextArea, ProFormSelect, ProFormText,ProFormRadio
} from '@ant-design/pro-form';
import ProCard from '@ant-design/pro-card';
import { Checkbox, Divider, InputNumber, Switch, Input, notification, message,Space,Button,Upload, Popconfirm} from 'antd';
import Form from 'antd/lib/form';
import { CloseCircleTwoTone, SmileOutlined ,MinusCircleOutlined, PlusOutlined,UploadOutlined} from '@ant-design/icons';
import React, { SetStateAction, useState, Dispatch, useEffect, useRef, } from 'react';
const { TextArea } = Input;


import { DeploymentStep } from '../../devlopment_data'
import { applyConfigmap,getConfigmap,clearConfigmap } from './service'

export interface ConfigMapFormProps {
deploymentId: number,
isEdit:boolean,
tableRef: any,
visibleFunc:Function,
deployment?:DeploymentStep
}

const ConfigMapForm: React.FC<ConfigMapFormProps> = (props: ConfigMapFormProps) => {
const [previewInfo, previewInfoHandle] = useState<any>();
const [configFile, configFileHandel] = useState<any>();
const form = useRef<ProFormInstance>();


function previewConfig(file: any,callback:Function) {
let reader = new FileReader();
reader.onload = () => {
callback(reader.result)
}
reader.readAsText(file)
}

return (
<ProForm formRef={form} submitter={{ resetButtonProps:{},searchConfig:{ resetText:'取消',submitText:'提交'} }}
request={async(r)=>{
let deployId = 0
console.log(props.deployment)
if(props.deploymentId > 0) {
deployId = props.deploymentId
} else {
deployId = Number(props.deployment?.id)
}
const configmapName = props.deployment?.name + '-configmap'

let result = {
name: configmapName,
items: [{
key:'',value:''
}]
}

if(props.isEdit) {
const res = await getConfigmap({ name:configmapName, clusterId:props.deployment?.clusterId , namespaceId:props.deployment?.namespaceId })
console.log(res)
if (res.success) {
result.items = res.data!=''?res.data.items:[{ key:'',value:'' }]
}
}

return result
}}
onFinish={async(fromData)=>{
fromData.deployId = props.deployment?.id
fromData.clusterId = props.deployment?.clusterId
fromData.appId = props.deployment?.appId
fromData.namespaceId = props.deployment?.namespaceId
console.log(fromData)
const res = await applyConfigmap(fromData)
if (res.success){
message.success("部署配置已生效.")
return true
}
return false
}}
onReset={()=>{ props.visibleFunc(false) }}>
<ProCard title="部署配置(ConfigMap)" bordered headerBordered
collapsible style={{ marginBlockEnd: 16, minWidth: 800, maxWidth: '100%', }} >
<ProForm.Group>
<Form.Item name="name" label="配置名称">
<Input value={props.deployment?.name + '-configmap'} disabled style={{width:500}} ></Input>
</Form.Item>
</ProForm.Group>
<ProForm.Group>

<Form.List name="items">
{(fields, { add, remove }) => (
<>
{fields.map(({ key, name, ...restField }) => (
<Space key={key} style={{ marginBottom: 8 }} align='start' >
<Form.Item
{...restField}
name={[name, 'key']}
rules={[{ required: true, message: 'key 不可为空' }]}
>
<Input placeholder="key" style={{width:300}} />
</Form.Item>
=
<Form.Item
{...restField}
name={[name, 'value']}
rules={[{ required: true, message: 'value 不可为空' }]}
>
<TextArea rows={1} placeholder="value" style={{width:700}} />
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)} />
</Space>
))}
<Form.Item>
<Space direction="horizontal">
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}>
手动添加
</Button>

<Upload showUploadList={false} accept=".yaml,.yml,.json"
onChange={(fileInfo) => {
console.log(fileInfo)
if(fileInfo.file.status=='done') {
previewConfig(fileInfo.file.originFileObj,(text:string)=>{
let items:[] = form.current?.getFieldValue('items')
const item = { key: String(fileInfo.file.originFileObj?.name), value: text}
items.push(item)
form.current?.setFieldsValue({
items:items
})
console.log(items)
})
}
}}
>
<Button icon={<UploadOutlined />}>文件导入</Button>
</Upload>
<Popconfirm title="确定要清除此配置吗?" onConfirm={async()=>{
const configmapName = props.deployment?.name + '-configmap'
const res = await clearConfigmap({ name:configmapName, clusterId:props.deployment?.clusterId , namespaceId:props.deployment?.namespaceId })
if (res.success) {
form.current?.setFieldsValue({ items:[{ key:'',value:'' }] })
message.success('配置清除成功')
}
}} >
<Button danger block > 清空配置 </Button>
</Popconfirm>
</Space>

</Form.Item>
</>
)}
</Form.List>
</ProForm.Group>
</ProCard>
</ProForm>
)
}



export default ConfigMapForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ApiResponse } from '@/services/public/service';
import { request } from 'umi';


export async function applyConfigmap(formData: any){
let resData = await request<ApiResponse<boolean>>("/v1/configmap/apply", {
method: 'POST',
headers:{
'Content-Type': 'application/json',
},
data:formData
})
return resData
}

export async function getConfigmap(params: any) {
let req= await request<ApiResponse<any>>('/v1/configmap/configmap',{
method:'GET',
params: params
})
return req
}


export async function getList(params: any) {
let req= await request<ApiResponse<any>>('/v1/configmap/list',{
method:'GET',
params: params
})
return req
}

export async function clearConfigmap(params: any) {
let req= await request<ApiResponse<any>>('/v1/configmap/configmap',{
method:'DELETE',
params: params
})
return req
}
Loading

0 comments on commit 2d1c94b

Please sign in to comment.