1
0

2 Commits

Author SHA1 Message Date
36c8959c01 feat(web): 完善confirmation快照页面 2025-01-14 15:48:51 +08:00
4242940e6b feat(frontend): 增加测试页面 2025-01-14 15:48:23 +08:00
4 changed files with 265 additions and 12 deletions

View File

@@ -0,0 +1,25 @@
<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title></title>
<link href="/assets/sdk/antd.css" rel="stylesheet"/>
<link href="/assets/sdk/helper.css" rel="stylesheet"/>
<link href="/assets/sdk/iconfont.css" rel="stylesheet"/>
<style>
html, body, #app {
position: relative;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="/assets/sdk/sdk.js"></script>
<script src="./main.js" type="module"></script>
</body>
</html>

View File

@@ -0,0 +1,124 @@
import {useAmis} from "../../components/constants.js";
useAmis((information) => {
return {
"type": "wrapper",
"size": "none",
"body": [
{
"type": "wrapper",
"body": [
{
"items": [
{
"label": "资源名称",
"span": 3,
"content": "文件资源"
},
{
"content": "FIle",
"span": 3,
"label": "资源描述"
}
],
"type": "property"
},
{
"type": "divider"
},
{
"title": "资源类型定义",
"type": "property",
"items": [
{
"span": 3,
"label": "资源类型",
"content": "文件"
},
{
"span": 3,
"content": {
"type": "flex",
"alignItems": "start",
"items": [
{
"label": "arthas-bin.zip",
"api": {
"method": "get",
"url": "${base}/upload/download/3557040775256064",
"headers": {
"token": "${token|default:undefined}"
},
"responseType": "blob"
},
"actionType": "ajax",
"type": "action",
"level": "link"
}
],
"direction": "column"
},
"label": "文件"
},
{
label: '格式详情',
content: {
type: 'editor',
language: 'json',
value: {
"name": "arthas-bin.zip",
"size": 1024,
"type": "application/zip",
"lastModified": 1673920000000,
"lastModifiedDate": "2023-01-14T14:40:00.000Z",
"webkitRelativePath": ""
}
},
}
]
},
{
"type": "divider"
},
{
"items": [
{
"label": "格式类型",
"content": "Json"
}
],
"type": "property",
"title": "资源格式定义"
}
],
"size": "none"
},
{
"type": "divider"
},
{
"items": [
{
"label": "创建人",
"span": 2,
"content": "administrator@eshore.com"
},
{
"content": "2025-01-14 14:41:56",
"label": "创建时间"
},
{
"span": 2,
"content": "administrator@eshore.com",
"label": "修改人"
},
{
"content": "2025-01-14 14:41:56",
"label": "修改时间"
}
],
"type": "property"
}
]
}
})

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());
}
}