mirror of https://github.com/openspug/spug
A 添加监控中心任务类型过滤
parent
4b132bc025
commit
f2050274ce
|
@ -131,6 +131,9 @@ class ComTable extends React.Component {
|
||||||
if (store.f_name) {
|
if (store.f_name) {
|
||||||
data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase()))
|
data = data.filter(item => item['name'].toLowerCase().includes(store.f_name.toLowerCase()))
|
||||||
}
|
}
|
||||||
|
if (store.f_type) {
|
||||||
|
data = data.filter(item => item['type_alias'] === store.f_type)
|
||||||
|
}
|
||||||
if (store.f_status !== undefined) {
|
if (store.f_status !== undefined) {
|
||||||
if (store.f_status === -3) {
|
if (store.f_status === -3) {
|
||||||
data = data.filter(item => !item['is_active'])
|
data = data.filter(item => !item['is_active'])
|
||||||
|
|
|
@ -4,19 +4,25 @@
|
||||||
* Released under the MIT License.
|
* Released under the MIT License.
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
import { Input, Select, Button } from 'antd';
|
import { Input, Select, Button } from 'antd';
|
||||||
import { SearchForm, AuthDiv, AuthCard } from 'components';
|
import { SearchForm, AuthDiv, AuthCard } from 'components';
|
||||||
import ComTable from './Table';
|
import ComTable from './Table';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
||||||
export default function () {
|
export default observer(function () {
|
||||||
return (
|
return (
|
||||||
<AuthCard auth="monitor.monitor.view">
|
<AuthCard auth="monitor.monitor.view">
|
||||||
<SearchForm>
|
<SearchForm>
|
||||||
<SearchForm.Item span={8} title="任务名称">
|
<SearchForm.Item span={6} title="任务名称">
|
||||||
<Input allowClear onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
|
<Input allowClear onChange={e => store.f_name = e.target.value} placeholder="请输入"/>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
<SearchForm.Item span={8} title="任务状态">
|
<SearchForm.Item span={6} title="任务类型">
|
||||||
|
<Select allowClear onChange={v => store.f_type = v} placeholder="请选择">
|
||||||
|
{store.types.map(item => <Select.Option key={item} value={item}>{item}</Select.Option>)}
|
||||||
|
</Select>
|
||||||
|
</SearchForm.Item>
|
||||||
|
<SearchForm.Item span={6} title="任务状态">
|
||||||
<Select allowClear onChange={v => store.f_status = v} placeholder="请选择">
|
<Select allowClear onChange={v => store.f_status = v} placeholder="请选择">
|
||||||
<Select.Option value={-3}>未激活</Select.Option>
|
<Select.Option value={-3}>未激活</Select.Option>
|
||||||
<Select.Option value={-2}>已激活</Select.Option>
|
<Select.Option value={-2}>已激活</Select.Option>
|
||||||
|
@ -25,7 +31,7 @@ export default function () {
|
||||||
<Select.Option value={1}>异常</Select.Option>
|
<Select.Option value={1}>异常</Select.Option>
|
||||||
</Select>
|
</Select>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
<SearchForm.Item span={8}>
|
<SearchForm.Item span={6}>
|
||||||
<Button type="primary" icon="sync" onClick={store.fetchRecords}>刷新</Button>
|
<Button type="primary" icon="sync" onClick={store.fetchRecords}>刷新</Button>
|
||||||
</SearchForm.Item>
|
</SearchForm.Item>
|
||||||
</SearchForm>
|
</SearchForm>
|
||||||
|
@ -35,4 +41,4 @@ export default function () {
|
||||||
<ComTable/>
|
<ComTable/>
|
||||||
</AuthCard>
|
</AuthCard>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
|
@ -10,21 +10,26 @@ import moment from "moment";
|
||||||
class Store {
|
class Store {
|
||||||
@observable records = [];
|
@observable records = [];
|
||||||
@observable record = {};
|
@observable record = {};
|
||||||
|
@observable types = [];
|
||||||
@observable isFetching = false;
|
@observable isFetching = false;
|
||||||
@observable formVisible = false;
|
@observable formVisible = false;
|
||||||
|
|
||||||
@observable f_name;
|
@observable f_name;
|
||||||
|
@observable f_type;
|
||||||
@observable f_status;
|
@observable f_status;
|
||||||
|
|
||||||
fetchRecords = () => {
|
fetchRecords = () => {
|
||||||
this.isFetching = true;
|
this.isFetching = true;
|
||||||
http.get('/api/monitor/')
|
http.get('/api/monitor/')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
const tmp = new Set();
|
||||||
res.map(item => {
|
res.map(item => {
|
||||||
|
tmp.add(item['type_alias']);
|
||||||
const value = item['latest_run_time'];
|
const value = item['latest_run_time'];
|
||||||
item['latest_run_time'] = value ? moment(value).fromNow() : null;
|
item['latest_run_time'] = value ? moment(value).fromNow() : null;
|
||||||
return null
|
return null
|
||||||
});
|
});
|
||||||
|
this.types = Array.from(tmp);
|
||||||
this.records = res
|
this.records = res
|
||||||
})
|
})
|
||||||
.finally(() => this.isFetching = false)
|
.finally(() => this.isFetching = false)
|
||||||
|
|
Loading…
Reference in New Issue