fix: 调整 workspace 图表模板,之渲染 indexName dashboardName

This commit is contained in:
zhangshuai
2024-10-25 14:24:14 +08:00
parent 0e48531e21
commit b19582293b
2 changed files with 3 additions and 6 deletions

View File

@@ -107,7 +107,6 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEnt
try {
// index name
String indexName = String.format("workspace-%s-*", workspace.getName());
String indexId = T.StrUtil.uuid();
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
String token = tokenInfo.getTokenValue();
@@ -129,7 +128,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEnt
// delete index-patten
if (indexExists) {
indexId = savedObjects.stream().map(x -> {
String indexId = savedObjects.stream().map(x -> {
return ((JSONObject) x).getString("id");
}).findFirst().get();
kibanaClient.deleteIndexPattern(token, indexId, true);
@@ -142,7 +141,6 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEnt
// dashboard Name
String dashboardName = String.format("dashboard-%s", workspace.getName());
Map<Object, Object> params = T.MapUtil.builder()
.put("indexId", indexId)
.put("indexName", indexName)
.put("dashboardName", dashboardName)
.build();
@@ -167,7 +165,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEnt
// get indexId
JSONObject indexObj = kibanaClient.findIndexPattern(token, "index-pattern", indexName);
savedObjects = indexObj.getJSONArray("saved_objects");
indexId = savedObjects.stream().map(x -> {
String indexId = savedObjects.stream().map(x -> {
return ((JSONObject) x).getString("id");
}).findFirst().get();

File diff suppressed because one or more lines are too long