浏览代码

Merge branch 'develop'

# Conflicts:
#	src/conf/config.js
gaozhan 5 年之前
父节点
当前提交
32229c9f9a
共有 2 个文件被更改,包括 149 次插入150 次删除
  1. 2 2
      src/conf/config.js
  2. 147 148
      src/pages/tc/jobs/jobs.js

+ 2 - 2
src/conf/config.js

@@ -4,7 +4,7 @@ let us = '/back-apit/api'
 const apiCdn = 'http://cdn01t.weipaitang.com/img/'
 let auth = '/back-autht/api'
 const hostDev = `${window.location.protocol}//${window.location.host}`
-let sTaskJobLog = '/ms-tracet/api' // 定时任务日志跳转
+const sTaskJobLog = 'http://ms-trace.weipaitang.com' // 定时任务日志跳转
 let thanos = '/thanos-admint/api'
 
 if (document.domain === 'back-admin.weipaitang.com') {
@@ -12,7 +12,7 @@ if (document.domain === 'back-admin.weipaitang.com') {
   tc = '/back-api/api'
   auth = '/back-auth/api'
   us = '/back-api/api'
-  sTaskJobLog = '/ms-trace/api' // 定时任务日志跳转
+  // sTaskJobLog = '/ms-trace/api' // 定时任务日志跳转
   thanos = '/thanos-admin/api'
 }
 

+ 147 - 148
src/pages/tc/jobs/jobs.js

@@ -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>
+      )
     }
 }