mirror of https://github.com/openspug/spug
fix issues
parent
5f828b30ad
commit
7750e40069
|
@ -1,6 +1,7 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { Drawer, Descriptions, Table, Button } from 'antd';
|
import { Drawer, Descriptions, Table, Button } from 'antd';
|
||||||
|
import { AuthDiv } from 'components';
|
||||||
import { http } from 'libs';
|
import { http } from 'libs';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
||||||
|
@ -35,10 +36,12 @@ export default observer(function (props) {
|
||||||
visible={props.visible}
|
visible={props.visible}
|
||||||
onClose={() => store.detailVisible = false}
|
onClose={() => store.detailVisible = false}
|
||||||
footer={(
|
footer={(
|
||||||
<div style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-end'}}>
|
<AuthDiv
|
||||||
|
auth="deploy.repository.del"
|
||||||
|
style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'flex-end'}}>
|
||||||
<span style={{color: '#999', fontSize: 12}}>Tips: 已关联发布申请的构建版本无法删除。</span>
|
<span style={{color: '#999', fontSize: 12}}>Tips: 已关联发布申请的构建版本无法删除。</span>
|
||||||
<Button danger loading={loading} disabled={requests.length > 0} onClick={handleDelete}>删除</Button>
|
<Button danger loading={loading} disabled={requests.length > 0} onClick={handleDelete}>删除</Button>
|
||||||
</div>
|
</AuthDiv>
|
||||||
)}>
|
)}>
|
||||||
<Descriptions column={1} title={<span style={{fontSize: 22}}>基本信息</span>}>
|
<Descriptions column={1} title={<span style={{fontSize: 22}}>基本信息</span>}>
|
||||||
<Descriptions.Item label="应用">{record.app_name}</Descriptions.Item>
|
<Descriptions.Item label="应用">{record.app_name}</Descriptions.Item>
|
||||||
|
|
|
@ -45,7 +45,7 @@ function ComTable() {
|
||||||
onReload={store.fetchRecords}
|
onReload={store.fetchRecords}
|
||||||
actions={[
|
actions={[
|
||||||
<AuthButton
|
<AuthButton
|
||||||
auth="config.env.add"
|
auth="deploy.repository.add"
|
||||||
type="primary"
|
type="primary"
|
||||||
icon={<PlusOutlined/>}
|
icon={<PlusOutlined/>}
|
||||||
onClick={store.showForm}>新建</AuthButton>
|
onClick={store.showForm}>新建</AuthButton>
|
||||||
|
@ -68,12 +68,12 @@ function ComTable() {
|
||||||
{hasPermission('deploy.repository.detail|deploy.repository.build|deploy.repository.log') && (
|
{hasPermission('deploy.repository.detail|deploy.repository.build|deploy.repository.log') && (
|
||||||
<Table.Column width={180} title="操作" render={info => (
|
<Table.Column width={180} title="操作" render={info => (
|
||||||
<Action>
|
<Action>
|
||||||
<Action.Button auth="deploy.repository.detail" onClick={() => store.showDetail(info)}>详情</Action.Button>
|
<Action.Button auth="deploy.repository.view" onClick={() => store.showDetail(info)}>详情</Action.Button>
|
||||||
<Action.Button
|
<Action.Button
|
||||||
auth="deploy.repository.build"
|
auth="deploy.repository.build"
|
||||||
loading={loading === info.id}
|
loading={loading === info.id}
|
||||||
onClick={() => handleRebuild(info)}>构建</Action.Button>
|
onClick={() => handleRebuild(info)}>构建</Action.Button>
|
||||||
<Action.Button auth="deploy.repository.log" onClick={() => store.showConsole(info)}>日志</Action.Button>
|
<Action.Button auth="deploy.repository.build" onClick={() => store.showConsole(info)}>日志</Action.Button>
|
||||||
</Action>
|
</Action>
|
||||||
)}/>
|
)}/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default observer(function () {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible
|
visible
|
||||||
width={600}
|
width={700}
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
|
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
|
||||||
onCancel={() => store.ext1Visible = false}
|
onCancel={() => store.ext1Visible = false}
|
||||||
|
|
|
@ -73,7 +73,7 @@ export default observer(function () {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible
|
visible
|
||||||
width={600}
|
width={700}
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
|
title={`${store.record.id ? '编辑' : '新建'}发布申请`}
|
||||||
onCancel={() => store.ext2Visible = false}
|
onCancel={() => store.ext2Visible = false}
|
||||||
|
|
|
@ -44,6 +44,8 @@ export default observer(function (props) {
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
dataSource={props.app_host_ids.map(id => ({id}))}
|
dataSource={props.app_host_ids.map(id => ({id}))}
|
||||||
|
pagination={false}
|
||||||
|
scroll={{y: 480}}
|
||||||
onRow={record => {
|
onRow={record => {
|
||||||
return {
|
return {
|
||||||
onClick: () => handleClickRow(record)
|
onClick: () => handleClickRow(record)
|
||||||
|
|
|
@ -1,123 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) OpenSpug Organization. https://github.com/openspug/spug
|
|
||||||
* Copyright (c) <spug.dev@gmail.com>
|
|
||||||
* Released under the AGPL-3.0 License.
|
|
||||||
*/
|
|
||||||
import React from 'react';
|
|
||||||
import { observer } from 'mobx-react';
|
|
||||||
import { SyncOutlined } from '@ant-design/icons';
|
|
||||||
import { Modal, Table, Input, Button, Select } from 'antd';
|
|
||||||
import { SearchForm } from 'components';
|
|
||||||
import store from '../../host/store';
|
|
||||||
|
|
||||||
@observer
|
|
||||||
class HostSelector extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
selectedRows: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if (store.records.length === 0) {
|
|
||||||
store.fetchRecords()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = (record) => {
|
|
||||||
const {selectedRows} = this.state;
|
|
||||||
const index = selectedRows.indexOf(record);
|
|
||||||
if (index > -1) {
|
|
||||||
selectedRows.splice(index, 1)
|
|
||||||
} else {
|
|
||||||
selectedRows.push(record)
|
|
||||||
}
|
|
||||||
this.setState({selectedRows});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleSubmit = () => {
|
|
||||||
this.props.onOk(this.state.selectedRows);
|
|
||||||
this.props.onCancel()
|
|
||||||
};
|
|
||||||
|
|
||||||
columns = [{
|
|
||||||
title: '类别',
|
|
||||||
dataIndex: 'zone',
|
|
||||||
}, {
|
|
||||||
title: '主机名称',
|
|
||||||
dataIndex: 'name',
|
|
||||||
ellipsis: true
|
|
||||||
}, {
|
|
||||||
title: '连接地址',
|
|
||||||
dataIndex: 'hostname',
|
|
||||||
}, {
|
|
||||||
title: '端口',
|
|
||||||
dataIndex: 'port'
|
|
||||||
}, {
|
|
||||||
title: '备注',
|
|
||||||
dataIndex: 'desc',
|
|
||||||
ellipsis: true
|
|
||||||
}];
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {selectedRows} = this.state;
|
|
||||||
let data = store.permRecords;
|
|
||||||
if (store.f_name) {
|
|
||||||
data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase()))
|
|
||||||
}
|
|
||||||
if (store.f_zone) {
|
|
||||||
data = data.filter(item => item['zone'].toLowerCase().includes(store.f_zone.toLowerCase()))
|
|
||||||
}
|
|
||||||
const dataIds = data.map(x => x.id);
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
visible
|
|
||||||
width={1000}
|
|
||||||
title="选择执行主机"
|
|
||||||
onCancel={this.props.onCancel}
|
|
||||||
onOk={this.handleSubmit}
|
|
||||||
maskClosable={false}>
|
|
||||||
<SearchForm>
|
|
||||||
<SearchForm.Item span={8} title="主机类别">
|
|
||||||
<Select allowClear placeholder="请选择" value={store.f_zone} onChange={v => store.f_zone = v}>
|
|
||||||
{store.zones.map(item => (
|
|
||||||
<Select.Option value={item} key={item}>{item}</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</SearchForm.Item>
|
|
||||||
<SearchForm.Item span={8} title="主机别名">
|
|
||||||
<Input allowClear value={store.f_name} onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
|
|
||||||
</SearchForm.Item>
|
|
||||||
<SearchForm.Item span={4} title="已选">
|
|
||||||
{selectedRows.length} 台
|
|
||||||
</SearchForm.Item>
|
|
||||||
<SearchForm.Item span={4}>
|
|
||||||
<Button type="primary" icon={<SyncOutlined />} onClick={store.fetchRecords}>刷新</Button>
|
|
||||||
</SearchForm.Item>
|
|
||||||
</SearchForm>
|
|
||||||
<Table
|
|
||||||
rowKey="id"
|
|
||||||
rowSelection={{
|
|
||||||
selectedRowKeys: selectedRows.map(item => item.id),
|
|
||||||
onChange: (_, rows) => {
|
|
||||||
let tmp = selectedRows.filter(x => !dataIds.includes(x.id))
|
|
||||||
this.setState({selectedRows: tmp.concat(rows)})
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
dataSource={data}
|
|
||||||
loading={store.isFetching}
|
|
||||||
onRow={record => {
|
|
||||||
return {
|
|
||||||
onClick: () => this.handleClick(record)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
pagination={false}
|
|
||||||
scroll={{y: 480}}
|
|
||||||
columns={this.columns}/>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default HostSelector
|
|
|
@ -73,9 +73,9 @@ export default [{
|
||||||
label: '构建仓库',
|
label: '构建仓库',
|
||||||
perms: [
|
perms: [
|
||||||
{key: 'view', label: '查看构建'},
|
{key: 'view', label: '查看构建'},
|
||||||
{key: 'detail', label: '构建详情'},
|
{key: 'add', label: '新建版本'},
|
||||||
{key: 'build', label: '构建仓库'},
|
{key: 'build', label: '执行构建'},
|
||||||
{key: 'log', label: '构建日志'},
|
{key: 'del', label: '删除版本'},
|
||||||
]
|
]
|
||||||
},{
|
},{
|
||||||
key: 'request',
|
key: 'request',
|
||||||
|
|
Loading…
Reference in New Issue