mirror of https://github.com/openspug/spug
A web update
parent
c5440c3687
commit
8638039198
|
@ -27,18 +27,16 @@ class Index extends React.Component {
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.socket) this.socket.close();
|
if (this.socket) this.socket.close();
|
||||||
store.request = {};
|
store.request = { targets: []};
|
||||||
store.outputs = {};
|
store.outputs = {};
|
||||||
store.targets = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDeploy = () => {
|
handleDeploy = () => {
|
||||||
this.setState({loading: true});
|
this.setState({loading: true});
|
||||||
http.post(`/api/deploy/request/${this.id}/`)
|
http.post(`/api/deploy/request/${this.id}/`)
|
||||||
.then(({token, outputs, targets}) => {
|
.then(({token, outputs}) => {
|
||||||
store.request.status = '2';
|
store.request.status = '2';
|
||||||
store.outputs = outputs;
|
store.outputs = outputs;
|
||||||
store.targets = targets;
|
|
||||||
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`);
|
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`);
|
||||||
this.socket.onopen = () => {
|
this.socket.onopen = () => {
|
||||||
this.socket.send('ok');
|
this.socket.send('ok');
|
||||||
|
@ -71,8 +69,8 @@ class Index extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
getStatusAlias = () => {
|
getStatusAlias = () => {
|
||||||
if (store.targets.length !== 0) {
|
if (Object.keys(store.outputs).length !== 0) {
|
||||||
for (let item of [{id: 'local'}, ...store.targets]) {
|
for (let item of [{id: 'local'}, ...store.request.targets]) {
|
||||||
if (lds.get(store.outputs, `${item.id}.status`) === 'error') {
|
if (lds.get(store.outputs, `${item.id}.status`) === 'error') {
|
||||||
return <Tag color="red">发布异常</Tag>
|
return <Tag color="red">发布异常</Tag>
|
||||||
} else if (lds.get(store.outputs, `${item.id}.step`, -1) < 5) {
|
} else if (lds.get(store.outputs, `${item.id}.step`, -1) < 5) {
|
||||||
|
@ -99,6 +97,7 @@ class Index extends React.Component {
|
||||||
onBack={() => history.goBack()}/>
|
onBack={() => history.goBack()}/>
|
||||||
<Collapse defaultActiveKey={1} className={styles.collapse}>
|
<Collapse defaultActiveKey={1} className={styles.collapse}>
|
||||||
<Collapse.Panel showArrow={false} key={1} header={
|
<Collapse.Panel showArrow={false} key={1} header={
|
||||||
|
store.request.type === '1' ?
|
||||||
<Steps>
|
<Steps>
|
||||||
<Steps.Step {...this.getStatus('local', 0)} title="建立连接"/>
|
<Steps.Step {...this.getStatus('local', 0)} title="建立连接"/>
|
||||||
<Steps.Step {...this.getStatus('local', 1)} title="发布准备"/>
|
<Steps.Step {...this.getStatus('local', 1)} title="发布准备"/>
|
||||||
|
@ -106,6 +105,9 @@ class Index extends React.Component {
|
||||||
<Steps.Step {...this.getStatus('local', 3)} title="执行检出"/>
|
<Steps.Step {...this.getStatus('local', 3)} title="执行检出"/>
|
||||||
<Steps.Step {...this.getStatus('local', 4)} title="检出后任务"/>
|
<Steps.Step {...this.getStatus('local', 4)} title="检出后任务"/>
|
||||||
<Steps.Step {...this.getStatus('local', 5)} title="执行打包"/>
|
<Steps.Step {...this.getStatus('local', 5)} title="执行打包"/>
|
||||||
|
</Steps> : <Steps style={{width: 400}}>
|
||||||
|
<Steps.Step {...this.getStatus('local', 0)} title="建立连接"/>
|
||||||
|
<Steps.Step {...this.getStatus('local', 1)} title="发布准备"/>
|
||||||
</Steps>}>
|
</Steps>}>
|
||||||
<pre className={styles.console}>{lds.get(store.outputs, 'local.data')}</pre>
|
<pre className={styles.console}>{lds.get(store.outputs, 'local.data')}</pre>
|
||||||
</Collapse.Panel>
|
</Collapse.Panel>
|
||||||
|
@ -115,7 +117,7 @@ class Index extends React.Component {
|
||||||
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}) => <Icon type="caret-right" style={{fontSize: 16}} rotate={isActive ? 90 : 0}/>}>
|
||||||
{store.targets.map((item, index) => (
|
{store.request.targets.map((item, index) => (
|
||||||
<Collapse.Panel key={index} header={
|
<Collapse.Panel key={index} header={
|
||||||
<div style={{display: 'flex', justifyContent: 'space-between'}}>
|
<div style={{display: 'flex', justifyContent: 'space-between'}}>
|
||||||
<b>{item.title}</b>
|
<b>{item.title}</b>
|
||||||
|
|
|
@ -2,8 +2,9 @@ import { observable } from "mobx";
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
@observable outputs = {};
|
@observable outputs = {};
|
||||||
@observable targets = [];
|
@observable request = {
|
||||||
@observable request = {};
|
targets: [],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Store()
|
export default new Store()
|
|
@ -8,6 +8,13 @@ import { LinkButton } from "components";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
class ComTable extends React.Component {
|
class ComTable extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
loading: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
store.fetchRecords()
|
store.fetchRecords()
|
||||||
}
|
}
|
||||||
|
@ -76,10 +83,16 @@ class ComTable extends React.Component {
|
||||||
return <React.Fragment>
|
return <React.Fragment>
|
||||||
<Link to={`/deploy/do/${info.id}`}>发布</Link>
|
<Link to={`/deploy/do/${info.id}`}>发布</Link>
|
||||||
<Divider type="vertical"/>
|
<Divider type="vertical"/>
|
||||||
<LinkButton onClick={() => store.showForm(info)}>回滚</LinkButton>
|
<LinkButton
|
||||||
|
disabled={info.type === '2'}
|
||||||
|
loading={this.state.loading}
|
||||||
|
onClick={() => this.handleRollback(info)}>回滚</LinkButton>
|
||||||
</React.Fragment>;
|
</React.Fragment>;
|
||||||
case '3':
|
case '3':
|
||||||
return <LinkButton onClick={() => store.showForm(info)}>回滚</LinkButton>;
|
return <LinkButton
|
||||||
|
disabled={info.type === '2'}
|
||||||
|
loading={this.state.loading}
|
||||||
|
onClick={() => this.handleRollback(info)}>回滚</LinkButton>;
|
||||||
case '-1':
|
case '-1':
|
||||||
return <React.Fragment>
|
return <React.Fragment>
|
||||||
<LinkButton onClick={() => store.showForm(info)}>编辑</LinkButton>
|
<LinkButton onClick={() => store.showForm(info)}>编辑</LinkButton>
|
||||||
|
@ -106,12 +119,31 @@ class ComTable extends React.Component {
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
handleDelete = (text) => {
|
handleRollback = (info) => {
|
||||||
|
this.setState({loading: true});
|
||||||
|
http.put('/api/deploy/request/', {id: info.id, action: 'check'})
|
||||||
|
.then(res => {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '回滚确认',
|
||||||
|
content: `确定要回滚至 ${res['date']} 创建的名称为【${res['name']}】的发布申请版本?`,
|
||||||
|
onOk: () => {
|
||||||
|
return http.put('/api/deploy/request/', {id: info.id, action: 'do'})
|
||||||
|
.then(() => {
|
||||||
|
message.success('回滚申请创建成功');
|
||||||
|
store.fetchRecords()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.finally(() => this.setState({loading: false}))
|
||||||
|
};
|
||||||
|
|
||||||
|
handleDelete = (info) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '删除确认',
|
title: '删除确认',
|
||||||
content: `确定要删除【${text['name']}】?`,
|
content: `确定要删除【${info['name']}】?`,
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
return http.delete('/api/exec/template/', {params: {id: text.id}})
|
return http.delete('/api/exec/template/', {params: {id: info.id}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
store.fetchRecords()
|
store.fetchRecords()
|
||||||
|
|
Loading…
Reference in New Issue