|
@@ -3,7 +3,7 @@ import { connect } from 'dva'
|
|
|
import { Divider, message, Popconfirm, Icon, Popover, Button, Descriptions, Card } from 'antd'
|
|
|
import { FilterTable } from 'wptpc-design'
|
|
|
import s from './jobs.less'
|
|
|
-import { tc,sTaskJobLog } from '@/conf/config'
|
|
|
+import { tc, sTaskJobLog } from '@/conf/config'
|
|
|
import get from 'lodash/get'
|
|
|
import ViewTable from './components/ViewTable'
|
|
|
import { fetchApi } from '@/apis/'
|
|
@@ -12,184 +12,183 @@ import moment from 'moment'
|
|
|
const apiUrl = `${tc}/tc/web/get-jobs`
|
|
|
|
|
|
@connect(({ loading }) => ({
|
|
|
- // 添加或者编辑接口触发的loading属性,可以用于控制接口请求阶段让对话框的”确定“按钮不可点击
|
|
|
- // actionLoading: loading.effects['tctemplate/_addItem'] || loading.effects['ugc/_editItem']
|
|
|
+ // 添加或者编辑接口触发的loading属性,可以用于控制接口请求阶段让对话框的”确定“按钮不可点击
|
|
|
+ // actionLoading: loading.effects['tctemplate/_addItem'] || loading.effects['ugc/_editItem']
|
|
|
}))
|
|
|
class Index extends React.PureComponent {
|
|
|
state = {
|
|
|
- // 这两个state字段用来进行表单显示、隐藏控制以及表单里面的数据
|
|
|
- showModal: false,
|
|
|
- params: {
|
|
|
- },
|
|
|
- limit: 1,
|
|
|
- tableData: [],
|
|
|
- data: [],
|
|
|
- dataLog:[],
|
|
|
- isGoto: false
|
|
|
+ // 这两个state字段用来进行表单显示、隐藏控制以及表单里面的数据
|
|
|
+ showModal: false,
|
|
|
+ params: {
|
|
|
+ },
|
|
|
+ limit: 1,
|
|
|
+ tableData: [],
|
|
|
+ data: [],
|
|
|
+ dataLog: [],
|
|
|
+ isGoto: false
|
|
|
}
|
|
|
|
|
|
// filtertable的搜索项配置
|
|
|
filterSetting = {
|
|
|
- isClearSearch: true,
|
|
|
- // 这个数组里面的每一个元素就是一个搜索项
|
|
|
- formFields: [
|
|
|
- {
|
|
|
- label: 'ID',
|
|
|
- type: 'input',
|
|
|
- key: 'jobName',
|
|
|
- placeholder: '请输入ID(全匹配单独搜索)'
|
|
|
- },
|
|
|
- {
|
|
|
- label: ' | 状态',
|
|
|
- type: 'select',
|
|
|
- key: 'jobStatus',
|
|
|
- option: [
|
|
|
- {value: -1,label:''},
|
|
|
- {value: 0,label:'PENDING'},
|
|
|
- {value: 1,label:'RUNNING'},
|
|
|
- {value: 2,label:'FINISHED'},
|
|
|
- {value: 3,label:'ERROR'},
|
|
|
- {value: 4,label:'CREATE'},
|
|
|
- ],
|
|
|
- placeholder: '请选择',
|
|
|
- },
|
|
|
- {
|
|
|
- label: '筛选日期:',
|
|
|
- type: 'rangePicker',
|
|
|
- key: 'jobCreateTime',
|
|
|
- format: 'YYYY-MM-DD HH:mm:ss',
|
|
|
- defaultValue: [moment(), moment()]
|
|
|
- },
|
|
|
- ],
|
|
|
- // 在接口请求前,可以修改给接口的入参
|
|
|
- beforeSearchFunc: params => {
|
|
|
- const { limit, tableData = [], isHeadOrTail } = this.state;
|
|
|
- console.log(this.props, 1111)
|
|
|
- params.limit = limit;
|
|
|
- if(this.state.isGoto){
|
|
|
- if (limit === -1) {
|
|
|
- params.lastID = get(tableData, [0, 'id', 'id'], '');
|
|
|
- } else {
|
|
|
- params.lastID = get(tableData, [tableData.length - 1, 'id', 'id'], '');
|
|
|
- }
|
|
|
- this.state.isGoto = false;
|
|
|
- }
|
|
|
- if (isHeadOrTail) {
|
|
|
- params.lastID = "";
|
|
|
- }
|
|
|
- params.ruleName = get(this.props, 'location.query.ruleName');
|
|
|
+ isClearSearch: true,
|
|
|
+ // 这个数组里面的每一个元素就是一个搜索项
|
|
|
+ formFields: [
|
|
|
+ {
|
|
|
+ label: 'ID',
|
|
|
+ type: 'input',
|
|
|
+ key: 'jobName',
|
|
|
+ placeholder: '请输入ID(全匹配单独搜索)'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: ' | 状态',
|
|
|
+ type: 'select',
|
|
|
+ key: 'jobStatus',
|
|
|
+ option: [
|
|
|
+ { value: -1, label: '' },
|
|
|
+ { value: 0, label: 'PENDING' },
|
|
|
+ { value: 1, label: 'RUNNING' },
|
|
|
+ { value: 2, label: 'FINISHED' },
|
|
|
+ { value: 3, label: 'ERROR' },
|
|
|
+ { value: 4, label: 'CREATE' }
|
|
|
+ ],
|
|
|
+ placeholder: '请选择'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '筛选日期:',
|
|
|
+ type: 'rangePicker',
|
|
|
+ key: 'jobCreateTime',
|
|
|
+ format: 'YYYY-MM-DD HH:mm:ss',
|
|
|
+ defaultValue: [moment(), moment()]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ // 在接口请求前,可以修改给接口的入参
|
|
|
+ beforeSearchFunc: params => {
|
|
|
+ const { limit, tableData = [], isHeadOrTail } = this.state
|
|
|
+ console.log(this.props, 1111)
|
|
|
+ params.limit = limit
|
|
|
+ if (this.state.isGoto) {
|
|
|
+ if (limit === -1) {
|
|
|
+ params.lastID = get(tableData, [0, 'id', 'id'], '')
|
|
|
+ } else {
|
|
|
+ params.lastID = get(tableData, [tableData.length - 1, 'id', 'id'], '')
|
|
|
+ }
|
|
|
+ this.state.isGoto = false
|
|
|
}
|
|
|
+ if (isHeadOrTail) {
|
|
|
+ params.lastID = ''
|
|
|
+ }
|
|
|
+ params.ruleName = get(this.props, 'location.query.ruleName')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- goX(limit, isHeadOrTail) {
|
|
|
- this.state.isGoto = true;
|
|
|
- this.setState({ limit, isHeadOrTail }, this.refresh)
|
|
|
+ goX (limit, isHeadOrTail) {
|
|
|
+ this.state.isGoto = true
|
|
|
+ this.setState({ limit, isHeadOrTail }, this.refresh)
|
|
|
}
|
|
|
|
|
|
onModalCancel = () => {
|
|
|
- this.setState({ showModal: false })
|
|
|
+ this.setState({ showModal: false })
|
|
|
}
|
|
|
|
|
|
// filtertable的列表配置
|
|
|
tableSetting = {
|
|
|
- pagination: false,
|
|
|
- columnConfig: [
|
|
|
- {
|
|
|
- title: 'ID',
|
|
|
- dataIndex: 'id.id'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '状态',
|
|
|
- dataIndex: 'statusName'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '创建时间',
|
|
|
- dataIndex: 'createTime'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'actions',
|
|
|
- render: (text, record) => <span>
|
|
|
- <a onClick={() => this.viewItem(record)}>日志</a>
|
|
|
- <Divider type="vertical" />
|
|
|
- <a onClick={() => this.triggerTask(record)}>触发</a>
|
|
|
- <Divider type="vertical" />
|
|
|
- <a onClick={() => this.viewLog(record)}>详情</a>
|
|
|
- </span>
|
|
|
- }
|
|
|
- ],
|
|
|
- rowClassName:(record, index) => {
|
|
|
- let className = index % 2 ? 'shallow_gray': 'deep_gray';
|
|
|
- return className
|
|
|
+ pagination: false,
|
|
|
+ columnConfig: [
|
|
|
+ {
|
|
|
+ title: 'ID',
|
|
|
+ dataIndex: 'id.id'
|
|
|
},
|
|
|
- getTableData: tableData => {
|
|
|
- this.setState({ tableData })
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'statusName'
|
|
|
},
|
|
|
- // 通过这个函数可以获取列表的刷新的函数,编辑、删除后可以用它来刷新列表
|
|
|
- getRefresh: refresh => {
|
|
|
- this.refresh = refresh
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ dataIndex: 'createTime'
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'actions',
|
|
|
+ render: (text, record) => <span>
|
|
|
+ <a onClick={() => this.viewItem(record)}>日志</a>
|
|
|
+ <Divider type="vertical" />
|
|
|
+ <a onClick={() => this.triggerTask(record)}>触发</a>
|
|
|
+ <Divider type="vertical" />
|
|
|
+ <a onClick={() => this.viewLog(record)}>详情</a>
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ rowClassName: (record, index) => {
|
|
|
+ const className = index % 2 ? 'shallow_gray' : 'deep_gray'
|
|
|
+ return className
|
|
|
+ },
|
|
|
+ getTableData: tableData => {
|
|
|
+ this.setState({ tableData })
|
|
|
+ },
|
|
|
+ // 通过这个函数可以获取列表的刷新的函数,编辑、删除后可以用它来刷新列表
|
|
|
+ getRefresh: refresh => {
|
|
|
+ this.refresh = refresh
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
viewItem = (record) => {
|
|
|
- this.setState({ showModal: true, data: record.logs })
|
|
|
+ this.setState({ showModal: true, data: record.logs })
|
|
|
}
|
|
|
|
|
|
viewLog = (record) => {
|
|
|
- var tag = "{\"Job.ID\":\""+record.id.id+"\"}"
|
|
|
- var url = sTaskJobLog+"/search?limit=20&lookback=1h&maxDuration&minDuration&service=scheduler&tags="+tag
|
|
|
- window.open(url)
|
|
|
+ var tag = '{"Job.ID":"' + record.id.id + '"}'
|
|
|
+ var url = sTaskJobLog + '/search?limit=20&lookback=1h&maxDuration&minDuration&service=scheduler&tags=' + tag
|
|
|
+ window.open(url)
|
|
|
}
|
|
|
|
|
|
triggerTask = (record) => {
|
|
|
- const url = `${tc}/tc/web/trigger-task`;
|
|
|
- console.log(record.id.id);
|
|
|
- const taskId = record.id.id;
|
|
|
- fetchApi(url, {
|
|
|
- taskId,
|
|
|
- }).then(resp => {
|
|
|
- if(resp.code==0){
|
|
|
- const msg = '触发任务成功!'
|
|
|
- message.success(msg)
|
|
|
- this.refresh()
|
|
|
- }else{
|
|
|
- message.error('触发失败!')
|
|
|
- this.refresh()
|
|
|
- }
|
|
|
- });
|
|
|
+ const url = `${tc}/tc/web/trigger-task`
|
|
|
+ console.log(record.id.id)
|
|
|
+ const taskId = record.id.id
|
|
|
+ fetchApi(url, {
|
|
|
+ taskId
|
|
|
+ }).then(resp => {
|
|
|
+ if (resp.code == 0) {
|
|
|
+ const msg = '触发任务成功!'
|
|
|
+ message.success(msg)
|
|
|
+ this.refresh()
|
|
|
+ } else {
|
|
|
+ message.error('触发失败!')
|
|
|
+ this.refresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
-
|
|
|
|
|
|
- render() {
|
|
|
- const { showModal, data } = this.state
|
|
|
- const { actionLoading } = this.props
|
|
|
- const myState = get(this.props, 'location.state');
|
|
|
- console.log(myState);
|
|
|
- return (
|
|
|
-
|
|
|
- <div className={s.templatePage}>
|
|
|
- <Descriptions title="规则信息">
|
|
|
- <Descriptions.Item label="规则名">{get(myState,'name.name')}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="具体规则">{get(myState,'value')}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="描述">{get(myState,'description.desc')}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="创建人">{get(myState,'description.createName')}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="创建时间">{get(myState,'createTime')}</Descriptions.Item>
|
|
|
- <Descriptions.Item label="最长执行时长">{get(myState,'options.maximumRunSeconds')}</Descriptions.Item>
|
|
|
- </Descriptions>
|
|
|
- {/* <Card title="卡片标题">卡片内容</Card> */}
|
|
|
- <hr></hr>
|
|
|
- <text color="red">注意: ID为全匹配,进行单独搜索。</text>
|
|
|
- <p></p>
|
|
|
- <FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl} />
|
|
|
- <div style={{ textAlign: 'right' }}>
|
|
|
- <Icon type="step-backward" onClick={() => this.goX(1, true)} />
|
|
|
- <Icon type="left" onClick={() => this.goX(-1, false)}></Icon>
|
|
|
- <Icon type="right" onClick={() => this.goX(1, false)}></Icon>
|
|
|
- <Icon type="step-forward" onClick={() => this.goX(-1, true)} />
|
|
|
- </div>
|
|
|
- {showModal && <ViewTable showModal={showModal} onCancel={this.onModalCancel} data={data} />}
|
|
|
- </div>
|
|
|
- )
|
|
|
+ render () {
|
|
|
+ const { showModal, data } = this.state
|
|
|
+ const { actionLoading } = this.props
|
|
|
+ const myState = get(this.props, 'location.state')
|
|
|
+ console.log(myState)
|
|
|
+ return (
|
|
|
+
|
|
|
+ <div className={s.templatePage}>
|
|
|
+ <Descriptions title="规则信息">
|
|
|
+ <Descriptions.Item label="规则名">{get(myState, 'name.name')}</Descriptions.Item>
|
|
|
+ <Descriptions.Item label="具体规则">{get(myState, 'value')}</Descriptions.Item>
|
|
|
+ <Descriptions.Item label="描述">{get(myState, 'description.desc')}</Descriptions.Item>
|
|
|
+ <Descriptions.Item label="创建人">{get(myState, 'description.createName')}</Descriptions.Item>
|
|
|
+ <Descriptions.Item label="创建时间">{get(myState, 'createTime')}</Descriptions.Item>
|
|
|
+ <Descriptions.Item label="最长执行时长">{get(myState, 'options.maximumRunSeconds')}</Descriptions.Item>
|
|
|
+ </Descriptions>
|
|
|
+ {/* <Card title="卡片标题">卡片内容</Card> */}
|
|
|
+ <hr></hr>
|
|
|
+ <text color="red">注意: ID为全匹配,进行单独搜索。</text>
|
|
|
+ <p></p>
|
|
|
+ <FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl} />
|
|
|
+ <div style={{ textAlign: 'right' }}>
|
|
|
+ <Icon type="step-backward" onClick={() => this.goX(1, true)} />
|
|
|
+ <Icon type="left" onClick={() => this.goX(-1, false)}></Icon>
|
|
|
+ <Icon type="right" onClick={() => this.goX(1, false)}></Icon>
|
|
|
+ <Icon type="step-forward" onClick={() => this.goX(-1, true)} />
|
|
|
+ </div>
|
|
|
+ {showModal && <ViewTable showModal={showModal} onCancel={this.onModalCancel} data={data} />}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|