|
|
|
@ -2,18 +2,11 @@ package com.finebi.plugin.custom.component;
|
|
|
|
|
|
|
|
|
|
import com.finebi.common.context.OperationContext; |
|
|
|
|
import com.finebi.provider.api.component.AbstractCustomComponentProvider; |
|
|
|
|
import com.finebi.provider.api.component.CustomComponentContext; |
|
|
|
|
import com.finebi.provider.api.component.DataModel; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.plugin.transform.ExecuteFunctionRecord; |
|
|
|
|
import com.fr.plugin.transform.FunctionRecorder; |
|
|
|
|
import com.fr.web.struct.AssembleComponent; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@FunctionRecorder |
|
|
|
|
public class DemoComponentProvider extends AbstractCustomComponentProvider { |
|
|
|
|
/** |
|
|
|
@ -40,16 +33,9 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider {
|
|
|
|
|
return "http://webapi.amap.com/theme/v1.3/mapinfo_05.png"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 空自定义图表提示,不写默认取 icon |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String getPreviewIcon() { |
|
|
|
|
return "http://webapi.amap.com/theme/v1.3/mapinfo_05.png"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自定义图表预览 dom,注入依赖文件和挂载节点,可以获取 context |
|
|
|
|
* |
|
|
|
|
* @param context 上下文 |
|
|
|
|
*/ |
|
|
|
|
@ExecuteFunctionRecord |
|
|
|
@ -61,21 +47,9 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider {
|
|
|
|
|
"<div id=\"container\">这是预览</div>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自定义图表编辑 dom,不写默认取预览 |
|
|
|
|
* @param context 上下文 |
|
|
|
|
*/ |
|
|
|
|
@ExecuteFunctionRecord |
|
|
|
|
@Override |
|
|
|
|
public String getEditPageHTML(OperationContext context) { |
|
|
|
|
return "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://fanruan.design/fineui/2.0/fineui.min.css\" />" + |
|
|
|
|
"<script src=\"https://fanruan.design/fineui/2.0/fineui.min.js\"></script>" + |
|
|
|
|
"<div>context: </div>" + context.getSystemInfo().getServletURL() + context.getUserInfo().getDisplayName() + |
|
|
|
|
"<div id=\"container\">这是编辑</div>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自定义图表渲染 js、css 注入 |
|
|
|
|
* |
|
|
|
|
* @param context 上下文 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -92,38 +66,24 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 返回是否需要进行自定义数据处理 |
|
|
|
|
* |
|
|
|
|
* @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 |
|
|
|
|
* @return 是否需要进行自定义数据处理 |
|
|
|
|
* 空自定义图表提示,不写默认取 icon |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public boolean needDataProcess(CustomComponentContext customComponentContext) { |
|
|
|
|
return true; |
|
|
|
|
public String getPreviewIcon() { |
|
|
|
|
return "http://webapi.amap.com/theme/v1.3/mapinfo_05.png"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 对BI计算后即将返回前端的数据进行自定义处理 |
|
|
|
|
* 自定义图表编辑 dom,不写默认取预览 |
|
|
|
|
* |
|
|
|
|
* @param dataModels 数据模型 |
|
|
|
|
* @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 |
|
|
|
|
* @return 处理过的数据模型 |
|
|
|
|
* @param context 上下文 |
|
|
|
|
*/ |
|
|
|
|
@ExecuteFunctionRecord |
|
|
|
|
@Override |
|
|
|
|
public List<DataModel> process(List<DataModel> dataModels, CustomComponentContext customComponentContext) { |
|
|
|
|
|
|
|
|
|
return dataModels.stream().map(dataModel -> new DataModel() { |
|
|
|
|
@Override |
|
|
|
|
public List<String> getFields() { |
|
|
|
|
return dataModel.getFields(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<List<Object>> getColData() { |
|
|
|
|
List<List<Object>> colData = new ArrayList<>(dataModel.getFields().size()); |
|
|
|
|
dataModel.getColData().forEach(d -> colData.add(Collections.singletonList(d.get(0)))); |
|
|
|
|
return colData; |
|
|
|
|
} |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
public String getEditPageHTML(OperationContext context) { |
|
|
|
|
return "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://fanruan.design/fineui/2.0/fineui.min.css\" />" + |
|
|
|
|
"<script src=\"https://fanruan.design/fineui/2.0/fineui.min.js\"></script>" + |
|
|
|
|
"<div>context: </div>" + context.getSystemInfo().getServletURL() + context.getUserInfo().getDisplayName() + |
|
|
|
|
"<div id=\"container\">这是编辑</div>"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|