1
0

feat(web): 完善confirmation快照页面

This commit is contained in:
2025-01-14 15:48:51 +08:00
parent 4242940e6b
commit 36c8959c01
2 changed files with 116 additions and 12 deletions

View File

@@ -77,16 +77,11 @@ public class ConfirmationService extends CheckingService<Confirmation> {
protected Object archive(Confirmation entity) {
DataResource resource = entity.getTarget();
return AmisHelper.wrapper(
AmisHelper.property(
AmisHelper.propertyItem("资源名称", resource.getName(), 3),
AmisHelper.propertyItem("资源描述", resource.getDescription(), 3)
),
AmisHelper.property(resource),
AmisHelper.divider(),
AmisHelper.property(resource.getType()),
AmisHelper.property(entity),
AmisHelper.divider(),
AmisHelper.property(resource.getFormat()),
AmisHelper.divider(),
AmisHelper.property(entity)
AmisHelper.property(resource.getExample())
);
}

View File

@@ -5,8 +5,17 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
import com.eshore.gringotts.web.domain.entity.DataFile;
import com.eshore.gringotts.web.domain.entity.DataResource;
import com.eshore.gringotts.web.domain.entity.format.CsvResourceFormat;
import com.eshore.gringotts.web.domain.entity.format.JsonLineResourceFormat;
import com.eshore.gringotts.web.domain.entity.format.JsonResourceFormat;
import com.eshore.gringotts.web.domain.entity.format.ResourceFormat;
import com.eshore.gringotts.web.domain.entity.type.ApiResourceType;
import com.eshore.gringotts.web.domain.entity.type.DatabaseResourceType;
import com.eshore.gringotts.web.domain.entity.type.FileResourceType;
import com.eshore.gringotts.web.domain.entity.type.FtpResourceType;
import com.eshore.gringotts.web.domain.entity.type.HDFSResourceType;
import com.eshore.gringotts.web.domain.entity.type.ResourceType;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.Maps;
@@ -59,6 +68,19 @@ public class AmisHelper {
return Maps.immutable.ofMap(builder.build());
}
public static ImmutableMap<Object, Object> property(DataResource resource) {
return AmisHelper.wrapper(
AmisHelper.property(
AmisHelper.propertyItem("资源名称", resource.getName(), 3),
AmisHelper.propertyItem("资源描述", resource.getDescription(), 3)
),
AmisHelper.divider(),
AmisHelper.property(resource.getType()),
AmisHelper.divider(),
AmisHelper.property(resource.getFormat())
);
}
public static ImmutableMap<Object, Object> property(ResourceType type) {
type = Hibernate.unproxy(type, ResourceType.class);
MutableList<ImmutableMap<Object, Object>> items = Lists.mutable.empty();
@@ -71,16 +93,32 @@ public class AmisHelper {
items.add(propertyItem("地址", apiResourceType.getUrl(), 3));
break;
case FILE:
items.add(propertyItem("资源类型", "文件"));
FileResourceType fileResourceType = (FileResourceType) type;
items.add(propertyItem("资源类型", "文件", 3));
items.add(propertyItem(fileResourceType.getFile()));
break;
case DATABASE:
DatabaseResourceType databaseResourceType = (DatabaseResourceType) type;
items.add(propertyItem("资源类型", "数据库"));
items.add(propertyItem("数据库", databaseResourceType.getDatabaseType().name(), 3));
items.add(propertyItem("地址", databaseResourceType.getJdbc(), 3));
items.add(propertyItem("用户名", databaseResourceType.getUsername(), 1));
items.add(propertyItem("密码", databaseResourceType.getPassword(), 2));
break;
case HDFS:
HDFSResourceType hdfsResourceType = (HDFSResourceType) type;
items.add(propertyItem("资源类型", "HDFS"));
items.add(propertyItem("core-site", hdfsResourceType.getCoreSite()));
items.add(propertyItem("hdfs-site", hdfsResourceType.getHdfsSite()));
break;
case FTP:
FtpResourceType ftpResourceType = (FtpResourceType) type;
items.add(propertyItem("资源类型", "FTP"));
items.add(propertyItem("地址", ftpResourceType.getUrl(), 3));
items.add(propertyItem("用户名", ftpResourceType.getUsername(), 1));
items.add(propertyItem("密码", ftpResourceType.getPassword(), 2));
items.add(propertyItem("根路径", ftpResourceType.getPath(), 3));
items.add(propertyItem("正则匹配过滤", ftpResourceType.getRegexFilter(), 3));
break;
}
return property("资源类型定义", items.toImmutable());
@@ -97,13 +135,19 @@ public class AmisHelper {
items.add(propertyItem("格式类型", "文本行", 3));
break;
case JSON:
items.add(propertyItem("格式类型", "Json"));
JsonResourceFormat jsonResourceFormat = (JsonResourceFormat) format;
items.add(propertyItem("格式类型", "Json", 3));
items.add(propertyItem("格式详情", editor("json", jsonResourceFormat.getJsonSchema()), 3));
break;
case JSON_LINE:
items.add(propertyItem("格式类型", "Json Line"));
JsonLineResourceFormat jsonLineResourceFormat = (JsonLineResourceFormat) format;
items.add(propertyItem("格式类型", "Json Line", 3));
items.add(propertyItem("格式详情", editor("json", jsonLineResourceFormat.getJsonSchema()), 3));
break;
case CSV:
items.add(propertyItem("格式类型", "CSV文本"));
CsvResourceFormat csvResourceFormat = (CsvResourceFormat) format;
items.add(propertyItem("格式类型", "CSV文本", 3));
items.add(propertyItem("格式详情", editor("json", csvResourceFormat.getCsvSchema()), 3));
break;
}
return property("资源格式定义", items.toImmutable());
@@ -118,6 +162,12 @@ public class AmisHelper {
);
}
public static ImmutableMap<Object, Object> property(DataFile dataFile) {
return property(
propertyItem("资源示例", dataFile)
);
}
public static ImmutableMap<Object, Object> propertyItem(String label, Object content) {
return propertyItem(label, content, null);
}
@@ -131,4 +181,63 @@ public class AmisHelper {
}
return Maps.immutable.ofMap(builder.build());
}
public static ImmutableMap<Object, Object> propertyItem(String label, DataFile dataFile) {
return propertyItem(label, Lists.immutable.of(dataFile));
}
public static ImmutableMap<Object, Object> propertyItem(DataFile dataFile) {
return propertyItem(Lists.immutable.of(dataFile));
}
public static ImmutableMap<Object, Object> propertyItem(ImmutableList<DataFile> dataFiles) {
return propertyItem("文件", dataFiles);
}
public static ImmutableMap<Object, Object> propertyItem(String label, ImmutableList<DataFile> dataFiles) {
return propertyItem(
label,
flex(dataFiles.collect(file -> ajaxAction(file.getFilename(), "${base}/upload/download/" + file.getId()))),
3
);
}
public static ImmutableMap<Object, Object> editor(String language, String value) {
return Maps.immutable.ofMap(MapUtil.builder()
.put("disabled", true)
.put("type", "editor")
.put("language", language)
.put("value", value)
.build());
}
public static ImmutableMap<Object, Object> flex(ImmutableList<ImmutableMap<Object, Object>> items) {
return Maps.immutable.ofMap(MapUtil.builder()
.put("type", "flex")
.put("direction", "column")
.put("alignItems", "start")
.put("items", items)
.build());
}
public static ImmutableMap<Object, Object> ajaxAction(String label, String url) {
return Maps.immutable.ofMap(MapUtil.builder()
.put("type", "action")
.put("actionType", "ajax")
.put("label", label)
.put("level", "link")
.put("api", apiDownload(url))
.build());
}
public static ImmutableMap<Object, Object> apiDownload(String url) {
return Maps.immutable.ofMap(MapUtil.builder()
.put("method", "get")
.put("url", url)
.put("responseType", "blob")
.put("headers", MapUtil.builder()
.put("token", "${token|default:undefined}")
.build())
.build());
}
}