Skip to content

Commit

Permalink
[Fix-320][UI] Fix Error data management list Updater field shows ID i…
Browse files Browse the repository at this point in the history
…nstead of name (#325)
  • Loading branch information
xxzuo authored Dec 27, 2023
1 parent 4c54a28 commit dbb6c59
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import io.datavines.core.aop.RefreshToken;
import io.datavines.core.constant.DataVinesConstants;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate;
import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate;
import io.datavines.server.api.dto.vo.ErrorDataStorageVO;
import io.datavines.server.api.dto.vo.Item;
import io.datavines.server.repository.service.ErrorDataStorageService;
import io.datavines.spi.PluginLoader;
Expand Down Expand Up @@ -77,6 +79,12 @@ public Object listByUserId(@PathVariable Long workspaceId) {
return errorDataStorageService.listByWorkspaceId(workspaceId);
}

@ApiOperation(value = "get error data storage page", response = ErrorDataStorageVO.class, responseContainer = "page")
@PostMapping(value = "page")
public Object page(@Valid @RequestBody ErrorDataStoragePageParam errorDataStoragePageParam) {
return errorDataStorageService.getErrorDataStoragePage(errorDataStoragePageParam);
}

@ApiOperation(value = "get storage config json")
@GetMapping(value = "/config/{type}")
public Object getConfigJson(@PathVariable String type){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 io.datavines.server.api.dto.bo.storage;

import lombok.Data;
import javax.validation.constraints.NotNull;

@Data
@NotNull(message = "ErrorDataStoragePageParam cannot be null")
public class ErrorDataStoragePageParam {

private Long workspaceId;

private String searchVal;

private String type;

private String startTime;

private String endTime;

private Integer pageNumber;

private Integer pageSize;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 io.datavines.server.api.dto.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
public class ErrorDataStorageVO implements Serializable {

private static final long serialVersionUID = 1L;

private Long id;

private String name;

private String type;

private String param;

private Long workspaceId;

private String creator;

private String updater;

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime startTime;

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private LocalDateTime updateTime;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.datavines.server.repository.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.datavines.server.api.dto.vo.ErrorDataStorageVO;
import io.datavines.server.repository.entity.ErrorDataStorage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface ErrorDataStorageMapper extends BaseMapper<ErrorDataStorage> {

IPage<ErrorDataStorageVO> getErrorDataStoragePage(Page<ErrorDataStorageVO> page,
@Param("workspaceId") Long workspaceId,
@Param("searchVal") String searchVal,
@Param("type") String type,
@Param("startTime") String startTime,
@Param("endTime") String endTime);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

package io.datavines.server.repository.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import io.datavines.common.param.TestConnectionRequestParam;
import io.datavines.core.exception.DataVinesServerException;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate;
import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate;
import io.datavines.server.api.dto.vo.ErrorDataStorageVO;
import io.datavines.server.repository.entity.ErrorDataStorage;

import java.util.List;
Expand All @@ -40,5 +43,7 @@ public interface ErrorDataStorageService extends IService<ErrorDataStorage> {

List<ErrorDataStorage> listByWorkspaceId(long workspaceId);

IPage<ErrorDataStorageVO> getErrorDataStoragePage(ErrorDataStoragePageParam errorDataStoragePageParam);

String getConfigJson(String type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package io.datavines.server.repository.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.datavines.common.param.ConnectorResponse;
import io.datavines.common.param.TestConnectionRequestParam;
Expand All @@ -26,7 +28,9 @@
import io.datavines.core.exception.DataVinesServerException;
import io.datavines.core.utils.LanguageUtils;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate;
import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam;
import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate;
import io.datavines.server.api.dto.vo.ErrorDataStorageVO;
import io.datavines.server.repository.entity.ErrorDataStorage;
import io.datavines.server.repository.mapper.ErrorDataStorageMapper;
import io.datavines.server.repository.service.ErrorDataStorageService;
Expand Down Expand Up @@ -110,6 +114,22 @@ public List<ErrorDataStorage> listByWorkspaceId(long workspaceId) {
return list;
}

@Override
public IPage<ErrorDataStorageVO> getErrorDataStoragePage(ErrorDataStoragePageParam errorDataStoragePageParam) {
Page<ErrorDataStorageVO> page = new Page<>(errorDataStoragePageParam.getPageNumber(), errorDataStoragePageParam.getPageSize());
IPage<ErrorDataStorageVO> errorDataStoragePage = baseMapper.getErrorDataStoragePage(page,
errorDataStoragePageParam.getWorkspaceId(),
errorDataStoragePageParam.getSearchVal(),
errorDataStoragePageParam.getType(),
errorDataStoragePageParam.getStartTime(),
errorDataStoragePageParam.getEndTime());
List<ErrorDataStorageVO> errorDataStoragePageRecordList = errorDataStoragePage.getRecords();
for (ErrorDataStorageVO errorDataStorageVO : errorDataStoragePageRecordList) {
errorDataStorageVO.setParam(PasswordFilterUtils.convertPasswordToNULL(PWD_PATTERN_1, errorDataStorageVO.getParam()));
}
return errorDataStoragePage;
}

@Override
public int deleteById(long id) {
return baseMapper.deleteById(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
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.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.datavines.server.repository.mapper.ErrorDataStorageMapper">
<sql id="basic_sql">
select * from dv_error_data_storage
<where>
<if test="type != null">
and type = #{type}
</if>
<if test="workspaceId != null">
and workspace_id = #{workspaceId}
</if>
<if test="startTime != null and startTime != ''">
and update_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime != ''">
and update_time &lt;= #{endTime}
</if>
</where>
</sql>

<select id="getErrorDataStoragePage" resultType="io.datavines.server.api.dto.vo.ErrorDataStorageVO">
select p.id, p.name, p.type, p.param, p.workspace_id, u.username as updater, p.update_time
from (<include refid="basic_sql"/>) p
left join `dv_user` u on u.id = p.update_by
<where>
<if test="searchVal != null">
LOWER(p.`name`) LIKE CONCAT(CONCAT('%', LOWER(#{searchVal})), '%')
</if>
</where>
</select>



</mapper>
20 changes: 13 additions & 7 deletions datavines-ui/src/view/Main/ErrorDataManage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, {useEffect, useState} from 'react';
import {
Table, Button, message,
} from 'antd';
Expand Down Expand Up @@ -35,10 +35,13 @@ const Index = () => {
const getData = async () => {
try {
setLoading(true);
const res = (await $http.get(`/errorDataStorage/list/${workspaceId}`)) || [];
const res = (await $http.post(`/errorDataStorage/page`, {
workspaceId: workspaceId,
...pageParams
})) || [];
setTableData({
list: res || [],
total: (res || []).length,
list: res?.records || [],
total: res?.total || 0,
});
} catch (error) {
} finally {
Expand All @@ -48,13 +51,16 @@ const Index = () => {
useMount(() => {
getData();
});
useEffect(() => {
getData();
}, [pageParams]);
const onEdit = (record: TWarnTableItem) => {
show(record);
};
const onDelete = async (id: any) => {
try {
setLoading(true);
const res = await $http.delete(`sla/sender/${id}`);
const res = await $http.delete(`errorDataStorage/${id}`);
if (res) {
getData();
message.success(intl.formatMessage({ id: 'common_success' }));
Expand All @@ -81,8 +87,8 @@ const Index = () => {
},
{
title: intl.formatMessage({ id: 'common_updater' }),
dataIndex: 'updateBy',
key: 'updateBy',
dataIndex: 'updater',
key: 'updater',
render: (text: string) => <div>{text || '--'}</div>,
},
{
Expand Down

0 comments on commit dbb6c59

Please sign in to comment.