mirror of https://github.com/openspug/spug
style migrate v3
parent
069adbd644
commit
3128fbfc7e
|
@ -5,7 +5,15 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { Modal, Collapse, Tooltip, Icon } from 'antd';
|
import {
|
||||||
|
CaretRightOutlined,
|
||||||
|
CheckCircleTwoTone,
|
||||||
|
LoadingOutlined,
|
||||||
|
WarningTwoTone,
|
||||||
|
FullscreenOutlined,
|
||||||
|
FullscreenExitOutlined
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
import { Modal, Collapse, Tooltip } from 'antd';
|
||||||
import { X_TOKEN } from 'libs';
|
import { X_TOKEN } from 'libs';
|
||||||
import OutView from './OutView';
|
import OutView from './OutView';
|
||||||
import styles from './index.module.css';
|
import styles from './index.module.css';
|
||||||
|
@ -54,14 +62,14 @@ class ExecConsole extends React.Component {
|
||||||
genExtra = (outputs) => {
|
genExtra = (outputs) => {
|
||||||
let latest, icon;
|
let latest, icon;
|
||||||
if (outputs['status'] === -2) {
|
if (outputs['status'] === -2) {
|
||||||
return <Icon type="loading" style={{fontSize: 20, color: '#108ee9'}}/>
|
return <LoadingOutlined style={{fontSize: 20, color: '#108ee9'}}/>;
|
||||||
} else if (outputs['status'] === 0) {
|
} else if (outputs['status'] === 0) {
|
||||||
latest = outputs['info'][outputs['info'].length - 1];
|
latest = outputs['info'][outputs['info'].length - 1];
|
||||||
icon = <Icon type="check-circle" style={{fontSize: 20}} theme="twoTone" twoToneColor="#52c41a"/>
|
icon = <CheckCircleTwoTone style={{fontSize: 20}} twoToneColor="#52c41a"/>
|
||||||
} else {
|
} else {
|
||||||
latest = outputs['error'][outputs['error'].length - 1]
|
latest = outputs['error'][outputs['error'].length - 1]
|
||||||
icon = <Tooltip title={`退出状态码:${outputs['status']}`}>
|
icon = <Tooltip title={`退出状态码:${outputs['status']}`}>
|
||||||
<Icon type="warning" style={{fontSize: 20}} theme="twoTone" twoToneColor="red"/>
|
<WarningTwoTone style={{fontSize: 20}} twoToneColor="red"/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
@ -80,7 +88,7 @@ class ExecConsole extends React.Component {
|
||||||
title={[
|
title={[
|
||||||
<span key="1">执行控制台</span>,
|
<span key="1">执行控制台</span>,
|
||||||
<div key="2" className={styles.fullscreen} onClick={() => store.isFullscreen = !store.isFullscreen}>
|
<div key="2" className={styles.fullscreen} onClick={() => store.isFullscreen = !store.isFullscreen}>
|
||||||
<Icon type={store.isFullscreen ? 'fullscreen-exit' : 'fullscreen'}/>
|
{store.isFullscreen ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}
|
||||||
</div>
|
</div>
|
||||||
]}
|
]}
|
||||||
footer={null}
|
footer={null}
|
||||||
|
@ -91,7 +99,7 @@ class ExecConsole extends React.Component {
|
||||||
accordion
|
accordion
|
||||||
defaultActiveKey={[0]}
|
defaultActiveKey={[0]}
|
||||||
className={styles.collapse}
|
className={styles.collapse}
|
||||||
expandIcon={({isActive}) => <Icon type="caret-right" style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}>
|
expandIcon={({isActive}) => <CaretRightOutlined style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}>
|
||||||
{Object.entries(store.outputs).map(([key, item], index) => (
|
{Object.entries(store.outputs).map(([key, item], index) => (
|
||||||
<Collapse.Panel
|
<Collapse.Panel
|
||||||
key={index}
|
key={index}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
|
import { SyncOutlined } from '@ant-design/icons';
|
||||||
import { Modal, Table, Input, Button, Select } from 'antd';
|
import { Modal, Table, Input, Button, Select } from 'antd';
|
||||||
import { SearchForm } from 'components';
|
import { SearchForm } from 'components';
|
||||||
import store from '../../host/store';
|
import store from '../../host/store';
|
||||||
|
@ -92,7 +93,7 @@ class HostSelector extends React.Component {
|
||||||
{selectedRows.length} 台
|
{selectedRows.length} 台
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
<SearchForm.Item span={4}>
|
<SearchForm.Item span={4}>
|
||||||
<Button type="primary" icon="sync" onClick={store.fetchRecords}>刷新</Button>
|
<Button type="primary" icon={<SyncOutlined />} onClick={store.fetchRecords}>刷新</Button>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
</SearchForm>
|
</SearchForm>
|
||||||
<Table
|
<Table
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
|
import { SyncOutlined } from '@ant-design/icons';
|
||||||
import { Modal, Table, Input, Button, Select } from 'antd';
|
import { Modal, Table, Input, Button, Select } from 'antd';
|
||||||
import { SearchForm } from 'components';
|
import { SearchForm } from 'components';
|
||||||
import store from '../template/store';
|
import store from '../template/store';
|
||||||
|
@ -82,7 +83,7 @@ class TemplateSelector extends React.Component {
|
||||||
<Input allowClear value={store.f_name} onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
|
<Input allowClear value={store.f_name} onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
<SearchForm.Item span={8}>
|
<SearchForm.Item span={8}>
|
||||||
<Button type="primary" icon="sync" onClick={store.fetchRecords}>刷新</Button>
|
<Button type="primary" icon={<SyncOutlined />} onClick={store.fetchRecords}>刷新</Button>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
</SearchForm>
|
</SearchForm>
|
||||||
<Table
|
<Table
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { Form, Button, Tag } from 'antd';
|
import { PlusOutlined, ThunderboltOutlined } from '@ant-design/icons';
|
||||||
import { ACEditor, AuthCard } from 'components';
|
import { Form, Button, Card, Tag } from 'antd';
|
||||||
|
import { ACEditor, AuthDiv, Breadcrumb } from 'components';
|
||||||
import HostSelector from './HostSelector';
|
import HostSelector from './HostSelector';
|
||||||
import TemplateSelector from './TemplateSelector';
|
import TemplateSelector from './TemplateSelector';
|
||||||
import ExecConsole from './ExecConsole';
|
import ExecConsole from './ExecConsole';
|
||||||
|
@ -34,32 +35,40 @@ class TaskIndex extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const {body, token} = this.state;
|
const {body, token} = this.state;
|
||||||
return (
|
return (
|
||||||
<AuthCard auth="exec.task.do">
|
<AuthDiv auth="exec.task.do">
|
||||||
<Form>
|
<Breadcrumb>
|
||||||
<Form.Item label="执行主机">
|
<Breadcrumb.Item>首页</Breadcrumb.Item>
|
||||||
{store.hosts.map(item => (
|
<Breadcrumb.Item>批量执行</Breadcrumb.Item>
|
||||||
<Tag
|
<Breadcrumb.Item>执行任务</Breadcrumb.Item>
|
||||||
closable
|
</Breadcrumb>
|
||||||
color="#108ee9"
|
<Card>
|
||||||
key={item.id}
|
<Form layout="vertical">
|
||||||
onClose={() => store.hosts = store.hosts.filter(x => x.id !== item.id)}>
|
<Form.Item label="执行主机" style={{marginBottom: 12}}>
|
||||||
{item.name}({item.hostname}:{item.port})</Tag>
|
{store.hosts.map(item => (
|
||||||
))}
|
<Tag
|
||||||
</Form.Item>
|
closable
|
||||||
<Button icon="plus" onClick={store.switchHost}>从主机列表中选择</Button>
|
color="#108ee9"
|
||||||
<Form.Item label="执行命令">
|
key={item.id}
|
||||||
<ACEditor mode="sh" value={body} height="300px" onChange={body => this.setState({body})}/>
|
onClose={() => store.hosts = store.hosts.filter(x => x.id !== item.id)}>
|
||||||
</Form.Item>
|
{item.name}({item.hostname}:{item.port})</Tag>
|
||||||
<Form.Item>
|
))}
|
||||||
<Button icon="plus" onClick={store.switchTemplate}>从执行模版中选择</Button>
|
</Form.Item>
|
||||||
</Form.Item>
|
<Button style={{marginBottom: 24}} icon={<PlusOutlined/>} onClick={store.switchHost}>从主机列表中选择</Button>
|
||||||
<Button icon="thunderbolt" type="primary" onClick={this.handleSubmit}>开始执行</Button>
|
<Form.Item label="执行命令">
|
||||||
</Form>
|
<ACEditor mode="sh" value={body} height="300px" onChange={body => this.setState({body})}/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item>
|
||||||
|
<Button icon={<PlusOutlined/>} onClick={store.switchTemplate}>从执行模版中选择</Button>
|
||||||
|
</Form.Item>
|
||||||
|
<Button icon={<ThunderboltOutlined/>} type="primary" onClick={this.handleSubmit}>开始执行</Button>
|
||||||
|
</Form>
|
||||||
|
</Card>
|
||||||
{store.showHost && <HostSelector onCancel={store.switchHost} onOk={hosts => store.hosts = hosts}/>}
|
{store.showHost && <HostSelector onCancel={store.switchHost} onOk={hosts => store.hosts = hosts}/>}
|
||||||
{store.showTemplate && <TemplateSelector onCancel={store.switchTemplate} onOk={v => this.setState({body: body + v})}/>}
|
{store.showTemplate &&
|
||||||
|
<TemplateSelector onCancel={store.switchTemplate} onOk={v => this.setState({body: body + v})}/>}
|
||||||
{store.showConsole && <ExecConsole token={token} onCancel={store.switchConsole}/>}
|
{store.showConsole && <ExecConsole token={token} onCancel={store.switchConsole}/>}
|
||||||
</AuthCard>
|
</AuthDiv>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue