You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by te...@apache.org on 2020/12/23 14:03:09 UTC

[shardingsphere-elasticjob-ui] branch master updated: Fix time criteria doesn't work in History Trace (#83)

This is an automated email from the ASF dual-hosted git repository.

technoboy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new f2358d7  Fix time criteria doesn't work in History Trace (#83)
f2358d7 is described below

commit f2358d7894cc5264dd8e57649877cc6ee3f1da85
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Wed Dec 23 22:03:02 2020 +0800

    Fix time criteria doesn't work in History Trace (#83)
---
 .../dto/request/FindJobExecutionEventsRequest.java | 20 +++++---------
 .../service/impl/EventTraceHistoryServiceImpl.java |  9 +++---
 .../elasticjob/lite/ui/util/BeanUtils.java         | 32 ----------------------
 .../src/lang/en-US.js                              |  5 ++--
 .../src/lang/zh-CN.js                              |  5 ++--
 .../views/history-trace/module/historyTrace.vue    | 25 +++++++++--------
 6 files changed, 31 insertions(+), 65 deletions(-)

diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/dto/request/FindJobExecutionEventsRequest.java b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/dto/request/FindJobExecutionEventsRequest.java
index 90a7719..2ccf87e 100644
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/dto/request/FindJobExecutionEventsRequest.java
+++ b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/dto/request/FindJobExecutionEventsRequest.java
@@ -17,8 +17,6 @@
 
 package org.apache.shardingsphere.elasticjob.lite.ui.dto.request;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -41,13 +39,9 @@ public class FindJobExecutionEventsRequest extends BasePageRequest {
     
     private Boolean isSuccess;
     
-    @JsonProperty("startTime")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date start;
+    private Date startTimeFrom;
     
-    @JsonProperty("endTime")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date end;
+    private Date startTimeTo;
     
     /**
      * Create new FindJobExecutionEventsRequest with pageSize and pageNumber.
@@ -64,13 +58,13 @@ public class FindJobExecutionEventsRequest extends BasePageRequest {
      * @param pageSize page size
      * @param sortBy the field name sort by
      * @param orderType order type, asc or desc
-     * @param startTime start time
-     * @param endTime end time
+     * @param startTimeFrom start time from
+     * @param startTimeTo start time to
      */
     public FindJobExecutionEventsRequest(final Integer pageSize, final Integer pageNumber, final String sortBy,
-                                         final String orderType, final Date startTime, final Date endTime) {
+                                         final String orderType, final Date startTimeFrom, final Date startTimeTo) {
         super(pageSize, pageNumber, sortBy, orderType);
-        this.start = startTime;
-        this.end = endTime;
+        this.startTimeFrom = startTimeFrom;
+        this.startTimeTo = startTimeTo;
     }
 }
diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/service/impl/EventTraceHistoryServiceImpl.java b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/service/impl/EventTraceHistoryServiceImpl.java
index fb4796a..3ba4af2 100644
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/service/impl/EventTraceHistoryServiceImpl.java
+++ b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/service/impl/EventTraceHistoryServiceImpl.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.elasticjob.lite.ui.dto.request.BasePageRequest;
 import org.apache.shardingsphere.elasticjob.lite.ui.dto.request.FindJobExecutionEventsRequest;
 import org.apache.shardingsphere.elasticjob.lite.ui.dto.request.FindJobStatusTraceEventsRequest;
 import org.apache.shardingsphere.elasticjob.lite.ui.service.EventTraceHistoryService;
-import org.apache.shardingsphere.elasticjob.lite.ui.util.BeanUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Example;
 import org.springframework.data.domain.Page;
@@ -65,9 +65,8 @@ public final class EventTraceHistoryServiceImpl implements EventTraceHistoryServ
     @Override
     public Page<JobExecutionEvent> findJobExecutionEvents(final FindJobExecutionEventsRequest findJobExecutionEventsRequest) {
         Example<JobExecutionLog> jobExecutionLogExample = getExample(findJobExecutionEventsRequest, JobExecutionLog.class);
-        Specification<JobExecutionLog> specification = getSpecWithExampleAndDate(jobExecutionLogExample, findJobExecutionEventsRequest.getStart(),
-            findJobExecutionEventsRequest.getEnd(), "startTime");
-
+        Specification<JobExecutionLog> specification = getSpecWithExampleAndDate(jobExecutionLogExample, findJobExecutionEventsRequest.getStartTimeFrom(),
+            findJobExecutionEventsRequest.getStartTimeTo(), "startTime");
         Page<JobExecutionLog> page = jobExecutionLogRepository.findAll(specification, getPageable(findJobExecutionEventsRequest, JobExecutionLog.class));
         return new PageImpl<>(page.getContent().stream().map(JobExecutionLog::toJobExecutionEvent).collect(Collectors.toList()), null, page.getTotalElements());
     }
@@ -140,7 +139,7 @@ public final class EventTraceHistoryServiceImpl implements EventTraceHistoryServ
     }
     
     private <T> Example<T> getExample(final Object source, final Class<T> clazz) {
-        T instance = BeanUtils.newInstance(clazz);
+        T instance = BeanUtils.instantiateClass(clazz);
         BeanUtils.copyProperties(source, instance);
         return Example.of(instance);
     }
diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/util/BeanUtils.java b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/util/BeanUtils.java
deleted file mode 100644
index 356a955..0000000
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/lite/ui/util/BeanUtils.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.ui.util;
-
-public class BeanUtils extends org.springframework.beans.BeanUtils {
-    
-    /**
-     * return a new instance by specified java type.
-     *
-     * @param clazz java type class
-     * @param <T>   java type
-     * @return new instance
-     */
-    public static <T> T newInstance(final Class<T> clazz) {
-        return instantiateClass(clazz);
-    }
-}
diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/en-US.js b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/en-US.js
index 993968b..53e313d 100644
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/en-US.js
+++ b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/en-US.js
@@ -261,8 +261,9 @@ export default {
     searchForm: {
       jobName: 'Job name',
       serverIp: 'Server ip',
-      startTime: 'Start time',
-      CompleteTime: 'Complete time',
+      startTimeRange: 'Start time range',
+      startTimeFrom: 'Start time from',
+      startTimeTo: 'Start time to',
       executeResult: 'Select execute result',
       executeSuccess: 'Success',
       executeFailed: 'Failure'
diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/zh-CN.js b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/zh-CN.js
index 01f178f..09e8ecb 100644
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/zh-CN.js
+++ b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/lang/zh-CN.js
@@ -261,8 +261,9 @@ export default {
     searchForm: {
       jobName: '请输入作业名称',
       serverIp: '请输入服务器IP',
-      startTime: '请输入开始时间',
-      CompleteTime: '请输入完成时间',
+      startTimeRange: '开始时间范围',
+      startTimeFrom: '请输入开始时间起始',
+      startTimeTo: '请输入开始时间截止',
       executeResult: '请选择执行结果',
       executeSuccess: '成功',
       executeFailed: '失败'
diff --git a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/views/history-trace/module/historyTrace.vue b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/views/history-trace/module/historyTrace.vue
index 6813c43..0b03c0b 100644
--- a/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/views/history-trace/module/historyTrace.vue
+++ b/shardingsphere-elasticjob-lite-ui/shardingsphere-elasticjob-lite-ui-frontend/src/views/history-trace/module/historyTrace.vue
@@ -31,15 +31,11 @@
         clearable>
       </el-autocomplete>
       <el-date-picker
-        :placeholder="$t('historyTrace.searchForm.startTime')"
-        v-model="searchForm.start"
-        type="datetime"
-        clearable>
-      </el-date-picker>
-      <el-date-picker
-        :placeholder="$t('historyTrace.searchForm.CompleteTime')"
-        v-model="searchForm.end"
-        type="datetime"
+        :placeholder="$t('historyTrace.searchForm.startTimeRange')"
+        :start-placeholder="$t('historyTrace.searchForm.startTimeFrom')"
+        :end-placeholder="$t('historyTrace.searchForm.startTimeTo')"
+        v-model="startTimeRange"
+        type="datetimerange"
         clearable>
       </el-date-picker>
       <el-select
@@ -148,10 +144,11 @@ export default {
       searchForm: {
         jobName: '',
         ip: '',
-        start: '',
-        end: '',
+        startTimeFrom: null,
+        startTimeTo: null,
         isSuccess: ''
       },
+      startTimeRange: [],
       tableData: [],
       cloneTableData: [],
       currentPage: 1,
@@ -190,6 +187,8 @@ export default {
       })
     },
     getJobTrace() {
+      this.currentPage = 1
+      this.total = 0
       API.loadExecution(this.getSearchForm()).then(res => {
         const data = res.model.rows
         this.total = res.model.total
@@ -200,6 +199,10 @@ export default {
       const requestBody = Object.assign({}, this.searchForm)
       requestBody.jobName = this.getNullIfEmpty(requestBody.jobName)
       requestBody.ip = this.getNullIfEmpty(requestBody.ip)
+      if (this.startTimeRange) {
+        requestBody.startTimeFrom = this.startTimeRange[0]
+        requestBody.startTimeTo = this.startTimeRange[1]
+      }
       return requestBody
     },
     getNullIfEmpty(value) {