You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.7 KiB
86 lines
2.7 KiB
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.fr.general.IOUtils; |
|
import com.fr.plugin.transform.ExecuteFunctionRecord; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.web.struct.AssembleComponent; |
|
|
|
@FunctionRecorder |
|
public class DemoComponentProvider extends AbstractCustomComponentProvider{ |
|
/** |
|
* 自定义图表名称 |
|
*/ |
|
@Override |
|
public String getName() { |
|
return "自定义图表demo"; |
|
} |
|
|
|
/** |
|
* 自定义图表类型 |
|
*/ |
|
@Override |
|
public String getType() { |
|
return "demo"; |
|
} |
|
|
|
/** |
|
* 自定义图表 icon |
|
*/ |
|
@Override |
|
public String getIcon() { |
|
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 |
|
@Override |
|
public String getPreviewPageHTML(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 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() + context.getUserInfo() + |
|
"<div id=\"container\">这是编辑</div>"; |
|
} |
|
|
|
/** |
|
* 自定义图表渲染 js、css 注入 |
|
* @param context 上下文 |
|
*/ |
|
@Override |
|
public AssembleComponent previewClient(OperationContext context) { |
|
return CustomComponent.KEY; |
|
} |
|
|
|
/** |
|
* 自定义图表配置文件 |
|
*/ |
|
@Override |
|
public String config() { |
|
return IOUtils.readResourceAsString("com/finebi/plugin/custom/component/config.json"); |
|
} |
|
}
|
|
|