diff --git a/spug_web/src/pages/exec/task/index.js b/spug_web/src/pages/exec/task/index.js
index 1dd0f90..c9c1a83 100644
--- a/spug_web/src/pages/exec/task/index.js
+++ b/spug_web/src/pages/exec/task/index.js
@@ -6,9 +6,9 @@
import React from 'react';
import { observer } from 'mobx-react';
import { PlusOutlined, ThunderboltOutlined } from '@ant-design/icons';
-import { Form, Button, Card, Tag } from 'antd';
+import { Form, Button, Card, Alert } from 'antd';
import { ACEditor, AuthDiv, Breadcrumb } from 'components';
-import HostSelector from './HostSelector';
+import Selector from 'pages/host/Selector';
import TemplateSelector from './TemplateSelector';
import ExecConsole from './ExecConsole';
import { http, cleanCommand } from 'libs';
@@ -26,7 +26,7 @@ class TaskIndex extends React.Component {
handleSubmit = () => {
this.setState({loading: true});
- const host_ids = store.hosts.map(item => item.id);
+ const host_ids = store.host_ids;
http.post('/api/exec/do/', {host_ids, command: cleanCommand(this.state.body)})
.then(store.switchConsole)
.finally(() => this.setState({loading: false}))
@@ -43,17 +43,15 @@ class TaskIndex extends React.Component {
- {store.hosts.map(item => (
- store.hosts = store.hosts.filter(x => x.id !== item.id)}>
- {item.name}({item.hostname}:{item.port})
- ))}
+
+ {store.host_ids.length > 0 && (
+
+ )}
-
+
this.setState({body})}/>
@@ -63,10 +61,14 @@ class TaskIndex extends React.Component {
- {store.showHost && store.hosts = hosts}/>}
{store.showTemplate &&
this.setState({body: body + v})}/>}
{store.showConsole && }
+ store.showHost = false}
+ onOk={(_, ids) => store.host_ids = ids}/>
);
}
diff --git a/spug_web/src/pages/exec/task/store.js b/spug_web/src/pages/exec/task/store.js
index d97db63..b8b0d8d 100644
--- a/spug_web/src/pages/exec/task/store.js
+++ b/spug_web/src/pages/exec/task/store.js
@@ -4,10 +4,11 @@
* Released under the AGPL-3.0 License.
*/
import { observable } from "mobx";
+import hostStore from 'pages/host/store';
class Store {
@observable outputs = {};
- @observable hosts = [];
+ @observable host_ids = [];
@observable token = null;
@observable isFullscreen = false;
@observable showHost = false;
@@ -27,10 +28,11 @@ class Store {
this.showConsole = false;
this.outputs = {}
} else {
- for (let item of this.hosts) {
- const key = `${item.hostname}:${item.port}`;
+ for (let id of this.host_ids) {
+ const host = hostStore.idMap[id];
+ const key = `${host.hostname}:${host.port}`;
this.outputs[key] = {
- title: `${item.name}(${key})`,
+ title: `${host.name}(${key})`,
system: ['### Establishing communication\n'],
info: [],
error: [],