|
|
|
@ -1,14 +1,21 @@
|
|
|
|
|
package com.finebi.plugin.custom.component; |
|
|
|
|
|
|
|
|
|
import com.finebi.common.api.service.plugin.common.context.OperationContext; |
|
|
|
|
import com.finebi.common.api.service.plugin.component.AbstractCustomComponentProvider; |
|
|
|
|
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{ |
|
|
|
|
public class DemoComponentProvider extends AbstractCustomComponentProvider { |
|
|
|
|
/** |
|
|
|
|
* 自定义图表名称 |
|
|
|
|
*/ |
|
|
|
@ -63,7 +70,7 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider{
|
|
|
|
|
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() + context.getUserInfo() + |
|
|
|
|
"<div>context: </div>" + context.getSystemInfo().getServletURL() + context.getUserInfo().getDisplayName() + |
|
|
|
|
"<div id=\"container\">这是编辑</div>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -83,4 +90,40 @@ public class DemoComponentProvider extends AbstractCustomComponentProvider{
|
|
|
|
|
public String config() { |
|
|
|
|
return IOUtils.readResourceAsString("com/finebi/plugin/custom/component/config.json"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 返回是否需要进行自定义数据处理 |
|
|
|
|
* |
|
|
|
|
* @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 |
|
|
|
|
* @return 是否需要进行自定义数据处理 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public boolean needDataProcess(CustomComponentContext customComponentContext) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 对BI计算后即将返回前端的数据进行自定义处理 |
|
|
|
|
* |
|
|
|
|
* @param dataModels 数据模型 |
|
|
|
|
* @param customComponentContext 自定义图表相关的上下文信息,目前包含前端传的查询配置 |
|
|
|
|
* @return 处理过的数据模型 |
|
|
|
|
*/ |
|
|
|
|
@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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|