forked from p81075629/datagear
页面端看板渲染方式由“dashboardRenderer.render(dashboard)”改为“dashboardFactory.init(dashboard);dashboard.render();”
This commit is contained in:
parent
e348a9b894
commit
51cee8e0fb
|
@ -52,7 +52,7 @@ import freemarker.template.TemplateScalarModel;
|
|||
* ...
|
||||
* <@theme />
|
||||
* ...
|
||||
* <@dashboard var="..." renderer="...">
|
||||
* <@dashboard var="..." factory="...">
|
||||
* ...
|
||||
* <@chart widget="..." var="..." elementId="..." />
|
||||
* ...
|
||||
|
@ -68,7 +68,7 @@ import freemarker.template.TemplateScalarModel;
|
|||
* <@theme />:引入内置CSS主题样式。
|
||||
* </p>
|
||||
* <p>
|
||||
* <@dashboard>:定义看板,“var”自定义看板JS变量名,可不填;“renderer”自定义看板渲染器JS变量,可不填,默认为{@linkplain HtmlTplDashboardWidgetRenderer#getDefaultDashboardRendererVar()}。
|
||||
* <@dashboard>:定义看板,“var”自定义看板JS变量名,可不填;“factory”自定义看板工厂JS变量,可不填,默认为{@linkplain HtmlTplDashboardWidgetRenderer#getDefaultDashboardFactoryVar()}。
|
||||
* </p>
|
||||
* <p>
|
||||
* <@chart
|
||||
|
@ -406,7 +406,7 @@ public class HtmlTplDashboardWidgetFmkRenderer<T extends HtmlRenderContext> exte
|
|||
throws TemplateException, IOException
|
||||
{
|
||||
String dashboardVar = getStringParamValue(params, "var");
|
||||
String rendererVar = getStringParamValue(params, "renderer");
|
||||
String factoryVar = getStringParamValue(params, "factory");
|
||||
|
||||
if (StringUtil.isEmpty(dashboardVar))
|
||||
dashboardVar = getDefaultDashboardVar();
|
||||
|
@ -439,7 +439,8 @@ public class HtmlTplDashboardWidgetFmkRenderer<T extends HtmlRenderContext> exte
|
|||
HtmlChartPluginRenderOption.removeOption(renderContext);
|
||||
|
||||
writeHtmlDashboardJSInit(out, dashboard);
|
||||
writeHtmlDashboardJSRender(out, dashboard, rendererVar);
|
||||
writeHtmlDashboardJSFactoryInit(out, dashboard, factoryVar);
|
||||
writeHtmlDashboardJSRender(out, dashboard);
|
||||
|
||||
writeScriptEndTag(out);
|
||||
writeNewLine(out);
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.datagear.util.StringUtil;
|
|||
* <code>
|
||||
* <pre>
|
||||
* ...
|
||||
* <html dg-dashboard-renderer="..." dg-dashboard-var="..." dg-dashboard-import-exclude="...">
|
||||
* <html dg-dashboard-factory="..." dg-dashboard-var="..." dg-dashboard-import-exclude="...">
|
||||
* ...
|
||||
* <head>
|
||||
* ...
|
||||
|
@ -44,7 +44,7 @@ import org.datagear.util.StringUtil;
|
|||
* </pre>
|
||||
* </code>
|
||||
* <p>
|
||||
* <code>html dg-dashboard-renderer</code>:选填,定义看板渲染器JS对象的变量名,默认为{@linkplain HtmlTplDashboardWidgetRenderer#getDefaultDashboardRendererVar()}
|
||||
* <code>html dg-dashboard-factory</code>:选填,定义看板工厂JS对象的变量名,默认为{@linkplain HtmlTplDashboardWidgetRenderer#getDefaultDashboardFactoryVar()}
|
||||
* </p>
|
||||
* <p>
|
||||
* <code>html dg-dashboard-var</code>:选填,定义看板JS对象的变量名,默认为{@linkplain #getDefaultDashboardVar()}
|
||||
|
@ -71,7 +71,7 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
|
||||
public static final String DEFAULT_ATTR_NAME_DASHBOARD_VAR = "dg-dashboard-var";
|
||||
|
||||
public static final String DEFAULT_ATTR_NAME_DASHBOARD_RENDERER = "dg-dashboard-renderer";
|
||||
public static final String DEFAULT_ATTR_NAME_DASHBOARD_FACTORY = "dg-dashboard-factory";
|
||||
|
||||
public static final String DEFAULT_ATTR_NAME_DASHBOARD_IMPORT_EXCLUDE = "dg-dashboard-import-exclude";
|
||||
|
||||
|
@ -83,8 +83,8 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
/** 属性名:看板JS变量名 */
|
||||
private String attrNameDashboardVar = DEFAULT_ATTR_NAME_DASHBOARD_VAR;
|
||||
|
||||
/** 属性名:看板渲染器JS变量名 */
|
||||
private String attrNameDashboardRenderer = DEFAULT_ATTR_NAME_DASHBOARD_RENDERER;
|
||||
/** 属性名:看板工厂JS变量名 */
|
||||
private String attrNameDashboardFactory = DEFAULT_ATTR_NAME_DASHBOARD_FACTORY;
|
||||
|
||||
/** 属性名:不导入内置库的 */
|
||||
private String attrNameDashboardImportExclude = DEFAULT_ATTR_NAME_DASHBOARD_IMPORT_EXCLUDE;
|
||||
|
@ -128,12 +128,12 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
|
||||
public String getAttrNameDashboardRenderer()
|
||||
{
|
||||
return attrNameDashboardRenderer;
|
||||
return attrNameDashboardFactory;
|
||||
}
|
||||
|
||||
public void setAttrNameDashboardRenderer(String attrNameDashboardRenderer)
|
||||
{
|
||||
this.attrNameDashboardRenderer = attrNameDashboardRenderer;
|
||||
this.attrNameDashboardFactory = attrNameDashboardRenderer;
|
||||
}
|
||||
|
||||
public String getAttrNameDashboardImportExclude()
|
||||
|
@ -445,13 +445,13 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
writeNewLine(out);
|
||||
|
||||
writeHtmlChartScripts(renderContext, dashboard, dashboardInfo);
|
||||
|
||||
writeHtmlDashboardJSInit(out, dashboard);
|
||||
writeHtmlDashboardJSFactoryInit(out, dashboard, dashboardInfo.getDashboardFactoryVar());
|
||||
|
||||
out.write("})();");
|
||||
writeNewLine(out);
|
||||
|
||||
writeHtmlDashboardJSRender(out, dashboard, dashboardInfo.getRendererVar());
|
||||
writeHtmlDashboardJSRender(out, dashboard);
|
||||
|
||||
writeScriptEndTag(out);
|
||||
writeNewLine(out);
|
||||
|
@ -581,9 +581,9 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
{
|
||||
dashboardInfo.setDashboardVar(attrValueStr);
|
||||
}
|
||||
else if (this.attrNameDashboardRenderer.equalsIgnoreCase(attrNameStr))
|
||||
else if (this.attrNameDashboardFactory.equalsIgnoreCase(attrNameStr))
|
||||
{
|
||||
dashboardInfo.setRendererVar(attrValueStr);
|
||||
dashboardInfo.setDashboardFactoryVar(attrValueStr);
|
||||
}
|
||||
else if (this.attrNameDashboardImportExclude.equalsIgnoreCase(attrNameStr))
|
||||
{
|
||||
|
@ -813,8 +813,8 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
{
|
||||
/** 看板变量名称 */
|
||||
private String dashboardVar;
|
||||
/** 看板渲染器名称 */
|
||||
private String rendererVar;
|
||||
/** 看板工厂名称 */
|
||||
private String dashboardFactoryVar;
|
||||
/** 内置导入排除项 */
|
||||
private String importExclude;
|
||||
/** 图表信息 */
|
||||
|
@ -841,14 +841,14 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
this.dashboardVar = dashboardVar;
|
||||
}
|
||||
|
||||
public String getRendererVar()
|
||||
public String getDashboardFactoryVar()
|
||||
{
|
||||
return rendererVar;
|
||||
return dashboardFactoryVar;
|
||||
}
|
||||
|
||||
public void setRendererVar(String rendererVar)
|
||||
public void setDashboardFactoryVar(String dashboardFactoryVar)
|
||||
{
|
||||
this.rendererVar = rendererVar;
|
||||
this.dashboardFactoryVar = dashboardFactoryVar;
|
||||
}
|
||||
|
||||
public String getImportExclude()
|
||||
|
@ -874,8 +874,8 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getClass().getSimpleName() + " [dashboardVar=" + dashboardVar + ", rendererVar=" + rendererVar
|
||||
+ ", importExclude=" + importExclude + ", chartInfos=" + chartInfos + "]";
|
||||
return getClass().getSimpleName() + " [dashboardVar=" + dashboardVar + ", rendererVar="
|
||||
+ dashboardFactoryVar + ", importExclude=" + importExclude + ", chartInfos=" + chartInfos + "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,23 +36,21 @@ import org.datagear.util.StringUtil;
|
|||
/**
|
||||
* 抽象{@linkplain HtmlTplDashboardWidget}渲染器。
|
||||
* <p>
|
||||
* 此类的{@linkplain #writeHtmlDashboardJSRender(Writer, HtmlDashboard, String)}方法的JS看板渲染逻辑为:
|
||||
* 此类的{@linkplain #writeHtmlDashboardJSFactoryInit(Writer, HtmlDashboard, String)}方法的JS看板渲染逻辑为:
|
||||
* </p>
|
||||
* <code>
|
||||
* <pre>
|
||||
* window.onload = function(){
|
||||
* dashboardRenderer.render(dashboard);
|
||||
* };
|
||||
* dashboardFactory.init(dashboard);
|
||||
* </pre>
|
||||
* </code>
|
||||
* <p>
|
||||
* 因此,看板页面应该定义如下JS看板渲染器对象:
|
||||
* 因此,看板页面应该定义如下JS看板工厂对象:
|
||||
* </p>
|
||||
* <code>
|
||||
* <pre>
|
||||
* var dashboardRenderer =
|
||||
* var dashboardFactory =
|
||||
* {
|
||||
* render : function(dashboard)
|
||||
* init : function(dashboard)
|
||||
* {
|
||||
* ...
|
||||
* }
|
||||
|
@ -60,7 +58,7 @@ import org.datagear.util.StringUtil;
|
|||
* </pre>
|
||||
* </code>
|
||||
* <p>
|
||||
* 子类在调用此方法时可以传入自定义JS看板渲染器对象的变量名,默认为{@linkplain #getDefaultDashboardRendererVar()}。
|
||||
* 子类在调用此方法时可以传入自定义JS看板工厂对象的变量名,默认为{@linkplain #getDefaultDashboardFactoryVar()}。
|
||||
* </p>
|
||||
* <p>
|
||||
* 此类的{@linkplain #getHtmlDashboardImports()}的{@linkplain HtmlDashboardImport#getContent()}可以包含{@linkplain #getContextPathPlaceholder()}占位符,
|
||||
|
@ -81,7 +79,7 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
|
||||
public static final String DEFAULT_DASHBOARD_VAR_PLACE_HOLDER = "$DASHBOARD";
|
||||
|
||||
public static final String DEFAULT_DASHBOARD_RENDERER_VAR = "dashboardRenderer";
|
||||
public static final String DEFAULT_DASHBOARD_FACTORY_VAR = "dashboardFactory";
|
||||
|
||||
public static final String DEFAULT_THEME_IMPORT_NAME = "dg-theme";
|
||||
|
||||
|
@ -133,11 +131,14 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
/** 看板变量占位符 */
|
||||
private String dashboardVarPlaceholder = DEFAULT_DASHBOARD_VAR_PLACE_HOLDER;
|
||||
|
||||
/** 默认JS看板渲染器变量名 */
|
||||
private String defaultDashboardRendererVar = DEFAULT_DASHBOARD_RENDERER_VAR;
|
||||
/** 默认JS看板工厂变量名 */
|
||||
private String defaultDashboardFactoryVar = DEFAULT_DASHBOARD_FACTORY_VAR;
|
||||
|
||||
/** JS看板渲染器的渲染函数名 */
|
||||
private String dashboardRendererRenderFunctionName = "render";
|
||||
/** JS看板工厂初始化函数名 */
|
||||
private String dashboardFactoryInitFuncName = "init";
|
||||
|
||||
/** 看板对象渲染函数名 */
|
||||
private String dashboardRenderFuncName = "render";
|
||||
|
||||
/** 主题导入名 */
|
||||
private String themeImportName = DEFAULT_THEME_IMPORT_NAME;
|
||||
|
@ -302,24 +303,34 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
this.dashboardVarPlaceholder = dashboardVarPlaceholder;
|
||||
}
|
||||
|
||||
public String getDefaultDashboardRendererVar()
|
||||
public String getDefaultDashboardFactoryVar()
|
||||
{
|
||||
return defaultDashboardRendererVar;
|
||||
return defaultDashboardFactoryVar;
|
||||
}
|
||||
|
||||
public void setDefaultDashboardRendererVar(String defaultDashboardRendererVar)
|
||||
public void setDefaultDashboardFactoryVar(String defaultDashboardFactoryVar)
|
||||
{
|
||||
this.defaultDashboardRendererVar = defaultDashboardRendererVar;
|
||||
this.defaultDashboardFactoryVar = defaultDashboardFactoryVar;
|
||||
}
|
||||
|
||||
public String getDashboardRendererRenderFunctionName()
|
||||
public String getDashboardFactoryInitFuncName()
|
||||
{
|
||||
return dashboardRendererRenderFunctionName;
|
||||
return dashboardFactoryInitFuncName;
|
||||
}
|
||||
|
||||
public void setDashboardRendererRenderFunctionName(String dashboardRendererRenderFunctionName)
|
||||
public void setDashboardFactoryInitFuncName(String dashboardFactoryInitFuncName)
|
||||
{
|
||||
this.dashboardRendererRenderFunctionName = dashboardRendererRenderFunctionName;
|
||||
this.dashboardFactoryInitFuncName = dashboardFactoryInitFuncName;
|
||||
}
|
||||
|
||||
public String getDashboardRenderFuncName()
|
||||
{
|
||||
return dashboardRenderFuncName;
|
||||
}
|
||||
|
||||
public void setDashboardRenderFuncName(String dashboardRenderFuncName)
|
||||
{
|
||||
this.dashboardRenderFuncName = dashboardRenderFuncName;
|
||||
}
|
||||
|
||||
public String getThemeImportName()
|
||||
|
@ -657,7 +668,7 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
{
|
||||
chartWidget = this.chartWidgetSource.getChartWidget(id);
|
||||
}
|
||||
catch(Throwable t)
|
||||
catch (Throwable t)
|
||||
{
|
||||
chartWidget = createHtmlChartWidgetForGetException(id, t);
|
||||
}
|
||||
|
@ -799,24 +810,22 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
}
|
||||
|
||||
/**
|
||||
* 写{@linkplain HtmlDashboard} JS渲染代码:
|
||||
* 写{@linkplain HtmlDashboard} JS工厂初始化代码:
|
||||
* <p>
|
||||
* <code>
|
||||
* <pre>
|
||||
* window.onload = function(){
|
||||
* dashboardRenderer.render();
|
||||
* };
|
||||
* dashboardFactory.init(dashboard);
|
||||
* </pre>
|
||||
* </code>
|
||||
* </p>
|
||||
*
|
||||
* @param out
|
||||
* @param dashboard
|
||||
* @param dashboardRendererVar
|
||||
* 如果为{@code null},则使用{@linkplain #getDefaultDashboardRendererVar()}
|
||||
* @param dashboardFactoryVar
|
||||
* 如果为{@code null},则使用{@linkplain #getDefaultDashboardFactoryVar()}
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void writeHtmlDashboardJSRender(Writer out, HtmlDashboard dashboard, String dashboardRendererVar)
|
||||
protected void writeHtmlDashboardJSFactoryInit(Writer out, HtmlDashboard dashboard, String dashboardFactoryVar)
|
||||
throws IOException
|
||||
{
|
||||
String varName = dashboard.getVarName();
|
||||
|
@ -824,16 +833,44 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
if (StringUtil.isEmpty(varName))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if (StringUtil.isEmpty(dashboardRendererVar))
|
||||
dashboardRendererVar = this.defaultDashboardRendererVar;
|
||||
if (StringUtil.isEmpty(dashboardFactoryVar))
|
||||
dashboardFactoryVar = this.defaultDashboardFactoryVar;
|
||||
|
||||
out.write("window.onload = function(){");
|
||||
out.write(dashboardFactoryVar + "." + this.dashboardFactoryInitFuncName + "(" + varName + ");");
|
||||
writeNewLine(out);
|
||||
}
|
||||
|
||||
out.write(" " + dashboardRendererVar + "." + this.dashboardRendererRenderFunctionName + "(" + varName + ");");
|
||||
/**
|
||||
* 写{@linkplain HtmlDashboard} JS渲染代码:
|
||||
* <p>
|
||||
* <code>
|
||||
* <pre>
|
||||
* if(typeof $ != "undefined")
|
||||
* $(document).ready(function(){ dashboard.render(); });
|
||||
* else
|
||||
* window.onload = function(){ dashboard.render(); };
|
||||
* </pre>
|
||||
* </code>
|
||||
* </p>
|
||||
*
|
||||
* @param out
|
||||
* @param dashboard
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void writeHtmlDashboardJSRender(Writer out, HtmlDashboard dashboard) throws IOException
|
||||
{
|
||||
String varName = dashboard.getVarName();
|
||||
|
||||
if (StringUtil.isEmpty(varName))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
out.write("if(typeof $ != \"undefined\")");
|
||||
writeNewLine(out);
|
||||
|
||||
out.write("};");
|
||||
out.write(" $(document).ready(function(){ " + varName + "." + this.dashboardRenderFuncName + "(); });");
|
||||
writeNewLine(out);
|
||||
out.write("else");
|
||||
writeNewLine(out);
|
||||
out.write(" window.onload = function(){ " + varName + "." + this.dashboardRenderFuncName + "(); };");
|
||||
writeNewLine(out);
|
||||
}
|
||||
|
||||
|
@ -883,8 +920,8 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
* @param renderContext
|
||||
* @return
|
||||
*/
|
||||
protected HtmlChart writeHtmlChart(HtmlChartWidget<HtmlRenderContext> chartWidget,
|
||||
HtmlRenderContext renderContext) throws RenderException
|
||||
protected HtmlChart writeHtmlChart(HtmlChartWidget<HtmlRenderContext> chartWidget, HtmlRenderContext renderContext)
|
||||
throws RenderException
|
||||
{
|
||||
return chartWidget.render(renderContext);
|
||||
}
|
||||
|
@ -1077,10 +1114,14 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
* 解析HTML标签属性。
|
||||
*
|
||||
* @param in
|
||||
* @param last 上一个已读取的字符
|
||||
* @param out 写入已读取字符的缓存
|
||||
* @param attrName 属性名写入缓存
|
||||
* @param attrValue 属性值写入缓存,引号不会写入
|
||||
* @param last
|
||||
* 上一个已读取的字符
|
||||
* @param out
|
||||
* 写入已读取字符的缓存
|
||||
* @param attrName
|
||||
* 属性名写入缓存
|
||||
* @param attrValue
|
||||
* 属性值写入缓存,引号不会写入
|
||||
* @return '>'、'/'、空格、下一个属性名的第一个字符、-1
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -1176,7 +1217,8 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
* 读取字符到“{@code -->}”。
|
||||
*
|
||||
* @param in
|
||||
* @param out 为{@code null}则不写入
|
||||
* @param out
|
||||
* 为{@code null}则不写入
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void skipHtmlComment(Reader in, Writer out) throws IOException
|
||||
|
|
|
@ -88,7 +88,7 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
|
||||
// 看板属性,双引号
|
||||
{
|
||||
String template = "<html dg-dashboard-var=\"myDashboard\" dg-dashboard-renderer=\"myRenderer\" "
|
||||
String template = "<html dg-dashboard-var=\"myDashboard\" dg-dashboard-factory=\"myDashboardFactory\" "
|
||||
+ " dg-dashboard-import-exclude=\"jquery\"><head></head><body></body></html>";
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
|
@ -102,19 +102,19 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
String html = getHtmlWithPrint(out);
|
||||
|
||||
Assert.assertEquals("myDashboard", dashboardInfo.getDashboardVar());
|
||||
Assert.assertEquals("myRenderer", dashboardInfo.getRendererVar());
|
||||
Assert.assertEquals("myDashboardFactory", dashboardInfo.getDashboardFactoryVar());
|
||||
Assert.assertEquals("jquery", dashboardInfo.getImportExclude());
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_JQUERY));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_UTIL));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_THEME));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_STYLE));
|
||||
Assert.assertTrue(html.contains("var myDashboard"));
|
||||
Assert.assertTrue(html.contains("myRenderer.render(myDashboard);"));
|
||||
Assert.assertTrue(html.contains("myDashboardFactory.init(myDashboard);"));
|
||||
}
|
||||
|
||||
// 看板属性,无引号
|
||||
{
|
||||
String template = "<html dg-dashboard-var=myDashboard dg-dashboard-renderer=myRenderer "
|
||||
String template = "<html dg-dashboard-var=myDashboard dg-dashboard-factory=myDashboardFactory "
|
||||
+ " dg-dashboard-import-exclude=jquery><head></head><body></body></html>";
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
|
@ -128,19 +128,19 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
String html = getHtmlWithPrint(out);
|
||||
|
||||
Assert.assertEquals("myDashboard", dashboardInfo.getDashboardVar());
|
||||
Assert.assertEquals("myRenderer", dashboardInfo.getRendererVar());
|
||||
Assert.assertEquals("myDashboardFactory", dashboardInfo.getDashboardFactoryVar());
|
||||
Assert.assertEquals("jquery", dashboardInfo.getImportExclude());
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_JQUERY));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_UTIL));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_THEME));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_STYLE));
|
||||
Assert.assertTrue(html.contains("var myDashboard"));
|
||||
Assert.assertTrue(html.contains("myRenderer.render(myDashboard);"));
|
||||
Assert.assertTrue(html.contains("myDashboardFactory.init(myDashboard);"));
|
||||
}
|
||||
|
||||
// 看板属性,单引号
|
||||
{
|
||||
String template = "<html dg-dashboard-var='myDashboard' dg-dashboard-renderer='myRenderer' "
|
||||
String template = "<html dg-dashboard-var='myDashboard' dg-dashboard-factory='myDashboardFactory' "
|
||||
+ " dg-dashboard-import-exclude='jquery'><head></head><body></body></html>";
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
|
@ -154,19 +154,19 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
String html = getHtmlWithPrint(out);
|
||||
|
||||
Assert.assertEquals("myDashboard", dashboardInfo.getDashboardVar());
|
||||
Assert.assertEquals("myRenderer", dashboardInfo.getRendererVar());
|
||||
Assert.assertEquals("myDashboardFactory", dashboardInfo.getDashboardFactoryVar());
|
||||
Assert.assertEquals("jquery", dashboardInfo.getImportExclude());
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_JQUERY));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_UTIL));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_THEME));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_STYLE));
|
||||
Assert.assertTrue(html.contains("var myDashboard"));
|
||||
Assert.assertTrue(html.contains("myRenderer.render(myDashboard);"));
|
||||
Assert.assertTrue(html.contains("myDashboardFactory.init(myDashboard);"));
|
||||
}
|
||||
|
||||
// 看板属性,多个导入排除值
|
||||
{
|
||||
String template = "<html dg-dashboard-var='myDashboard' dg-dashboard-renderer='myRenderer' "
|
||||
String template = "<html dg-dashboard-var='myDashboard' dg-dashboard-factory='myDashboardFactory' "
|
||||
+ " dg-dashboard-import-exclude='jquery,theme, style'><head></head><body></body></html>";
|
||||
|
||||
StringWriter out = new StringWriter();
|
||||
|
@ -180,14 +180,14 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
String html = getHtmlWithPrint(out);
|
||||
|
||||
Assert.assertEquals("myDashboard", dashboardInfo.getDashboardVar());
|
||||
Assert.assertEquals("myRenderer", dashboardInfo.getRendererVar());
|
||||
Assert.assertEquals("myDashboardFactory", dashboardInfo.getDashboardFactoryVar());
|
||||
Assert.assertEquals("jquery,theme, style", dashboardInfo.getImportExclude());
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_JQUERY));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_UTIL));
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_THEME));
|
||||
Assert.assertFalse(html.contains(IMPORT_CONTENT_STYLE));
|
||||
Assert.assertTrue(html.contains("var myDashboard"));
|
||||
Assert.assertTrue(html.contains("myRenderer.render(myDashboard);"));
|
||||
Assert.assertTrue(html.contains("myDashboardFactory.init(myDashboard);"));
|
||||
}
|
||||
|
||||
// 看板属性,默认
|
||||
|
@ -205,14 +205,14 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
String html = getHtmlWithPrint(out);
|
||||
|
||||
Assert.assertNull(dashboardInfo.getDashboardVar());
|
||||
Assert.assertNull(dashboardInfo.getRendererVar());
|
||||
Assert.assertNull(dashboardInfo.getDashboardFactoryVar());
|
||||
Assert.assertNull(dashboardInfo.getImportExclude());
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_JQUERY));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_UTIL));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_THEME));
|
||||
Assert.assertTrue(html.contains(IMPORT_CONTENT_STYLE));
|
||||
Assert.assertTrue(html.contains("var dashboard"));
|
||||
Assert.assertTrue(html.contains("dashboardRenderer.render(dashboard);"));
|
||||
Assert.assertTrue(html.contains("dashboardFactory.init(dashboard);"));
|
||||
}
|
||||
|
||||
// 图表属性
|
||||
|
@ -285,8 +285,7 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
HtmlRenderAttributes.setHtmlTitleHandler(renderContext, htmlTitleHandler);
|
||||
|
||||
HtmlDashboard dashboard = this.renderer.createHtmlDashboard(renderContext, dashboardWidget);
|
||||
this.renderer.renderHtmlDashboard(renderContext, dashboard,
|
||||
IOUtil.getReader(template));
|
||||
this.renderer.renderHtmlDashboard(renderContext, dashboard, IOUtil.getReader(template));
|
||||
|
||||
String html = getHtmlWithPrint(out);
|
||||
|
||||
|
@ -301,8 +300,7 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
HtmlRenderAttributes.setHtmlTitleHandler(renderContext, htmlTitleHandler);
|
||||
|
||||
HtmlDashboard dashboard = this.renderer.createHtmlDashboard(renderContext, dashboardWidget);
|
||||
this.renderer.renderHtmlDashboard(renderContext, dashboard,
|
||||
IOUtil.getReader(template));
|
||||
this.renderer.renderHtmlDashboard(renderContext, dashboard, IOUtil.getReader(template));
|
||||
|
||||
String html = getHtmlWithPrint(out);
|
||||
|
||||
|
|
|
@ -310,13 +310,21 @@
|
|||
<property name="name" value="echarts-map-world" />
|
||||
<property name="content" value="<script type='text/javascript' res-name='echarts-map-world' src='$CONTEXTPATH/static/script/echarts-map/world.js'></script>" />
|
||||
</bean>
|
||||
<bean class="org.datagear.analysis.support.html.HtmlDashboardImport">
|
||||
<property name="name" value="chartFactory" />
|
||||
<property name="content" value="<script type='text/javascript' res-name='chartFactory' src='$CONTEXTPATH/static/script/datagear-chartFactory.js'></script>" />
|
||||
</bean>
|
||||
<bean class="org.datagear.analysis.support.html.HtmlDashboardImport">
|
||||
<property name="name" value="dashboardFactory" />
|
||||
<property name="content" value="<script type='text/javascript' res-name='dashboardFactory' src='$CONTEXTPATH/static/script/datagear-dashboardFactory.js'></script>" />
|
||||
</bean>
|
||||
<bean class="org.datagear.analysis.support.html.HtmlDashboardImport">
|
||||
<property name="name" value="chart-util" />
|
||||
<property name="content" value="<script type='text/javascript' res-name='chart-util' src='$CONTEXTPATH/static/script/datagear-chart-util.js'></script>" />
|
||||
<property name="content" value="<script type='text/javascript' deprecated='use chartFactory' res-name='chart-util' src='$CONTEXTPATH/static/script/datagear-chart-util.js'></script>" />
|
||||
</bean>
|
||||
<bean class="org.datagear.analysis.support.html.HtmlDashboardImport">
|
||||
<property name="name" value="dashboard-renderer" />
|
||||
<property name="content" value="<script type='text/javascript' res-name='dashboard-renderer' src='$CONTEXTPATH/static/script/datagear-dashboard-renderer.js'></script>" />
|
||||
<property name="content" value="<script type='text/javascript' deprecated='use dashboardFactory' res-name='dashboard-renderer' src='$CONTEXTPATH/static/script/datagear-dashboard-renderer.js'></script>" />
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
*/
|
||||
chartBase.chartDataSetFirst = function()
|
||||
{
|
||||
return this.indexChartDataSet(0);
|
||||
return this.chartDataSetAt(0);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -327,7 +327,7 @@
|
|||
*/
|
||||
chartBase.resultFirst = function(results)
|
||||
{
|
||||
return this.indexResult(results, 0);
|
||||
return this.resultAt(results, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue