forked from p85126437/datagear
[analysis]DashboardWidgetResManager重构为TemplateDashboardWidgetResManager
This commit is contained in:
parent
a6a4b987d8
commit
1961bc25ea
|
@ -1,4 +1,4 @@
|
|||
package org.datagear.analysis.support;
|
||||
package org.datagear.analysis;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -7,11 +7,8 @@ import java.io.OutputStream;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.datagear.analysis.Dashboard;
|
||||
import org.datagear.analysis.DashboardWidget;
|
||||
|
||||
/**
|
||||
* {@linkplain DashboardWidget}资源管理器。
|
||||
* {@linkplain TemplateDashboardWidget}资源管理器。
|
||||
* <p>
|
||||
* 此类通过{@linkplain DashboardWidget#getId()}来管理{@linkplain DashboardWidget}资源。
|
||||
* </p>
|
||||
|
@ -19,7 +16,7 @@ import org.datagear.analysis.DashboardWidget;
|
|||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface DashboardWidgetResManager
|
||||
public interface TemplateDashboardWidgetResManager
|
||||
{
|
||||
/**
|
||||
* 获取默认资源编码。
|
||||
|
@ -28,48 +25,65 @@ public interface DashboardWidgetResManager
|
|||
*/
|
||||
String getDefaultEncoding();
|
||||
|
||||
/**
|
||||
* 获取{@linkplain TemplateDashboardWidget#getTemplate()}的输入流。
|
||||
*
|
||||
* @param widget
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
Reader getTemplateReader(TemplateDashboardWidget<?> widget) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取{@linkplain TemplateDashboardWidget#getTemplate()}的输出流。
|
||||
*
|
||||
* @param widget
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
Writer getTemplateWriter(TemplateDashboardWidget<?> widget) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取指定名称资源的输入流。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param id {@linkplain TemplateDashboardWidget#getId()}
|
||||
* @param name 资源名称
|
||||
* @param encoding 资源编码,为{@code null}或空则使用默认编码
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
Reader getReader(String id, String name, String encoding) throws IOException;
|
||||
Reader getResourceReader(String id, String name, String encoding) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取指定名称资源的输出流。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param id {@linkplain TemplateDashboardWidget#getId()}
|
||||
* @param name 资源名称
|
||||
* @param encoding 资源编码,为{@code null}或空则使用默认编码
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
Writer getWriter(String id, String name, String encoding) throws IOException;
|
||||
Writer getResourceWriter(String id, String name, String encoding) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取指定名称资源的输入流。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param name 资源名称
|
||||
* @param id {@linkplain TemplateDashboardWidget#getId()}
|
||||
* @param name 资源名称
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
InputStream getInputStream(String id, String name) throws IOException;
|
||||
InputStream getResourceInputStream(String id, String name) throws IOException;
|
||||
|
||||
/**
|
||||
* 获取指定名称资源的输出流。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param id {@linkplain TemplateDashboardWidget#getId()}
|
||||
* @param name 资源名称
|
||||
* @param encoding 资源编码,为{@code null}则使用默认编码
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
OutputStream getOutputStream(String id, String name) throws IOException;
|
||||
OutputStream getResourceOutputStream(String id, String name) throws IOException;
|
||||
|
||||
/**
|
||||
* 将指定目录下的所有文件作为资源拷入。
|
||||
|
@ -90,7 +104,7 @@ public interface DashboardWidgetResManager
|
|||
* @param name 资源名称
|
||||
* @return
|
||||
*/
|
||||
boolean contains(String id, String name);
|
||||
boolean containsResource(String id, String name);
|
||||
|
||||
/**
|
||||
* 获取指定资源上次修改时间。
|
||||
|
@ -99,7 +113,7 @@ public interface DashboardWidgetResManager
|
|||
* @param name
|
||||
* @return
|
||||
*/
|
||||
long lastModified(String id, String name);
|
||||
long lastModifiedResource(String id, String name);
|
||||
|
||||
/**
|
||||
* 删除指定ID的所有资源。
|
|
@ -1,51 +0,0 @@
|
|||
package org.datagear.analysis.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 抽象{@linkplain DashboardWidgetResManager}。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDashboardWidgetResManager implements DashboardWidgetResManager
|
||||
{
|
||||
public AbstractDashboardWidgetResManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultEncoding()
|
||||
{
|
||||
return Charset.defaultCharset().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getReader(String id, String name, String encoding) throws IOException
|
||||
{
|
||||
if (StringUtil.isEmpty(encoding))
|
||||
encoding = getDefaultEncoding();
|
||||
|
||||
InputStream in = getInputStream(id, name);
|
||||
return IOUtil.getReader(in, encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writer getWriter(String id, String name, String encoding) throws IOException
|
||||
{
|
||||
if (StringUtil.isEmpty(encoding))
|
||||
encoding = getDefaultEncoding();
|
||||
|
||||
OutputStream out = getOutputStream(id, name);
|
||||
return IOUtil.getWriter(out, encoding);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package org.datagear.analysis.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.datagear.analysis.TemplateDashboardWidget;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 抽象{@linkplain TemplateDashboardWidgetResManager}。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractTemplateDashboardWidgetResManager implements TemplateDashboardWidgetResManager
|
||||
{
|
||||
public AbstractTemplateDashboardWidgetResManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultEncoding()
|
||||
{
|
||||
return Charset.defaultCharset().name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getResourceReader(String id, String name, String encoding) throws IOException
|
||||
{
|
||||
encoding = getResourceEncodingWithDefault(encoding);
|
||||
|
||||
InputStream in = getResourceInputStream(id, name);
|
||||
return IOUtil.getReader(in, encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writer getResourceWriter(String id, String name, String encoding) throws IOException
|
||||
{
|
||||
encoding = getResourceEncodingWithDefault(encoding);
|
||||
|
||||
OutputStream out = getResourceOutputStream(id, name);
|
||||
return IOUtil.getWriter(out, encoding);
|
||||
}
|
||||
|
||||
protected String getTemplateEncodingWithDefault(TemplateDashboardWidget<?> widget)
|
||||
{
|
||||
String encoding = widget.getTemplateEncoding();
|
||||
|
||||
if (StringUtil.isEmpty(encoding))
|
||||
encoding = getDefaultEncoding();
|
||||
|
||||
return encoding;
|
||||
}
|
||||
|
||||
protected String getResourceEncodingWithDefault(String encoding)
|
||||
{
|
||||
if (StringUtil.isEmpty(encoding))
|
||||
encoding = getDefaultEncoding();
|
||||
|
||||
return encoding;
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package org.datagear.analysis.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.datagear.analysis.TemplateDashboardWidget;
|
||||
import org.datagear.util.IOUtil;
|
||||
|
||||
/**
|
||||
* 直接{@linkplain DashboardWidgetResManager}。
|
||||
* <p>
|
||||
* 此类仅实现了
|
||||
* </p>
|
||||
* <p>
|
||||
* {@linkplain DashboardWidgetResManager#getDefaultEncoding()}<br>
|
||||
* {@linkplain DashboardWidgetResManager#getReader(String, String, String)}
|
||||
* </p>
|
||||
* <p>
|
||||
* 两个接口,并且{@linkplain DashboardWidgetResManager#getReader(String, String, String)}将资源名(第二个参数<code>name</code>)作为资源输入流返回。
|
||||
* </p>
|
||||
* <p>
|
||||
* 此类可以作为{@linkplain TemplateDashboardWidget#getTemplate()}即是模板内容且不包含任何其他资源依赖的{@linkplain TemplateDashboardWidget}的伪资源管理器。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class DirectDashboardWidgetResManager extends AbstractDashboardWidgetResManager
|
||||
{
|
||||
public DirectDashboardWidgetResManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getReader(String id, String name, String encoding) throws IOException
|
||||
{
|
||||
return IOUtil.getReader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream(String id, String name) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream(String id, String name) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(String id, File directory) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String id, String name)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long lastModified(String id, String name)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package org.datagear.analysis.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.datagear.analysis.Dashboard;
|
||||
import org.datagear.util.FileUtil;
|
||||
import org.datagear.util.IOUtil;
|
||||
|
||||
/**
|
||||
* 基于文件的{@linkplain DashboardWidgetResManager}。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class FileDashboardWidgetResManager extends AbstractDashboardWidgetResManager
|
||||
{
|
||||
private File rootDirectory;
|
||||
|
||||
public FileDashboardWidgetResManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public FileDashboardWidgetResManager(File rootDirectory)
|
||||
{
|
||||
super();
|
||||
this.rootDirectory = rootDirectory;
|
||||
}
|
||||
|
||||
public FileDashboardWidgetResManager(String rootDirectory)
|
||||
{
|
||||
super();
|
||||
this.rootDirectory = FileUtil.getDirectory(FileUtil.trimPath(rootDirectory));
|
||||
}
|
||||
|
||||
public File getRootDirectory()
|
||||
{
|
||||
return rootDirectory;
|
||||
}
|
||||
|
||||
public void setRootDirectory(File rootDirectory)
|
||||
{
|
||||
this.rootDirectory = rootDirectory;
|
||||
|
||||
if (!this.rootDirectory.exists())
|
||||
this.rootDirectory.mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定资源相对{@linkplain #getRootDirectory()}的路径。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param name 资源名称
|
||||
* @return
|
||||
*/
|
||||
public String getRelativePath(String id, String name)
|
||||
{
|
||||
return doGetRelativePath(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream(String id, String name) throws IOException
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return IOUtil.getInputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream(String id, String name) throws IOException
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return IOUtil.getOutputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(String id, File directory) throws IOException
|
||||
{
|
||||
File myDirectory = FileUtil.getDirectory(this.rootDirectory, id);
|
||||
IOUtil.copy(directory, myDirectory, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String id, String name)
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long lastModified(String id, String name)
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return file.lastModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id)
|
||||
{
|
||||
File directory = FileUtil.getDirectory(this.rootDirectory, id);
|
||||
FileUtil.deleteFile(directory);
|
||||
}
|
||||
|
||||
protected File getFile(String id, String name)
|
||||
{
|
||||
String path = doGetRelativePath(id, name);
|
||||
return FileUtil.getFile(this.rootDirectory, path);
|
||||
}
|
||||
|
||||
protected String doGetRelativePath(String id, String name)
|
||||
{
|
||||
String path = FileUtil.concatPath(id, name);
|
||||
return path;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
package org.datagear.analysis.support;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.datagear.analysis.Dashboard;
|
||||
import org.datagear.analysis.TemplateDashboardWidget;
|
||||
import org.datagear.util.FileUtil;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 基于文件的{@linkplain DashboardWidgetResManager}。
|
||||
* <p>
|
||||
* 此类将{@linkplain TemplateDashboardWidget#getTemplate()}作为资源文件名处理。
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class FileTemplateDashboardWidgetResManager extends AbstractTemplateDashboardWidgetResManager
|
||||
{
|
||||
private File rootDirectory;
|
||||
|
||||
private boolean templateAsContent = false;
|
||||
|
||||
public FileTemplateDashboardWidgetResManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public FileTemplateDashboardWidgetResManager(File rootDirectory)
|
||||
{
|
||||
super();
|
||||
this.rootDirectory = rootDirectory;
|
||||
}
|
||||
|
||||
public FileTemplateDashboardWidgetResManager(String rootDirectory)
|
||||
{
|
||||
super();
|
||||
this.rootDirectory = FileUtil.getDirectory(FileUtil.trimPath(rootDirectory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否将{@linkplain TemplateDashboardWidget#getTemplate()}作为模板内容而非模板资源名处理。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isTemplateAsContent()
|
||||
{
|
||||
return templateAsContent;
|
||||
}
|
||||
|
||||
public void setTemplateAsContent(boolean templateAsContent)
|
||||
{
|
||||
this.templateAsContent = templateAsContent;
|
||||
}
|
||||
|
||||
public File getRootDirectory()
|
||||
{
|
||||
return rootDirectory;
|
||||
}
|
||||
|
||||
public void setRootDirectory(File rootDirectory)
|
||||
{
|
||||
this.rootDirectory = rootDirectory;
|
||||
|
||||
if (!this.rootDirectory.exists())
|
||||
this.rootDirectory.mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定资源相对{@linkplain #getRootDirectory()}的路径。
|
||||
*
|
||||
* @param id {@linkplain Dashboard#getId()}
|
||||
* @param name 资源名称
|
||||
* @return
|
||||
*/
|
||||
public String getRelativePath(String id, String name)
|
||||
{
|
||||
return doGetRelativePath(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getTemplateReader(TemplateDashboardWidget<?> widget) throws IOException
|
||||
{
|
||||
if (this.templateAsContent)
|
||||
{
|
||||
String content = widget.getTemplate();
|
||||
if (StringUtil.isEmpty(content))
|
||||
content = "";
|
||||
|
||||
return IOUtil.getReader(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = getResourceNameForTemplate(widget);
|
||||
return getResourceReader(widget.getId(), name, getTemplateEncodingWithDefault(widget));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writer getTemplateWriter(TemplateDashboardWidget<?> widget) throws IOException
|
||||
{
|
||||
if (this.templateAsContent)
|
||||
throw new UnsupportedOperationException();
|
||||
else
|
||||
{
|
||||
String name = getResourceNameForTemplate(widget);
|
||||
return getResourceWriter(widget.getId(), name, getTemplateEncodingWithDefault(widget));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceInputStream(String id, String name) throws IOException
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return IOUtil.getInputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getResourceOutputStream(String id, String name) throws IOException
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return IOUtil.getOutputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(String id, File directory) throws IOException
|
||||
{
|
||||
File myDirectory = FileUtil.getDirectory(this.rootDirectory, id);
|
||||
IOUtil.copy(directory, myDirectory, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsResource(String id, String name)
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long lastModifiedResource(String id, String name)
|
||||
{
|
||||
File file = getFile(id, name);
|
||||
return file.lastModified();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id)
|
||||
{
|
||||
File directory = FileUtil.getDirectory(this.rootDirectory, id);
|
||||
FileUtil.deleteFile(directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain TemplateDashboardWidget#getTemplate()}的资源名。
|
||||
*
|
||||
* @param widget
|
||||
* @return
|
||||
*/
|
||||
protected String getResourceNameForTemplate(TemplateDashboardWidget<?> widget)
|
||||
{
|
||||
return widget.getTemplate();
|
||||
}
|
||||
|
||||
protected File getFile(String id, String name)
|
||||
{
|
||||
String path = doGetRelativePath(id, name);
|
||||
return FileUtil.getFile(this.rootDirectory, path);
|
||||
}
|
||||
|
||||
protected String doGetRelativePath(String id, String name)
|
||||
{
|
||||
String path = FileUtil.concatPath(id, name);
|
||||
return path;
|
||||
}
|
||||
}
|
|
@ -16,9 +16,9 @@ import java.util.Map;
|
|||
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.RenderContext;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.ChartWidgetSource;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.FileDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.FileTemplateDashboardWidgetResManager;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
|
@ -37,8 +37,8 @@ import freemarker.template.TemplateScalarModel;
|
|||
/**
|
||||
* 使用Freemarker作为模板的{@linkplain HtmlTplDashboardWidget}渲染器。
|
||||
* <p>
|
||||
* 此类可渲染由{@linkplain FileDashboardWidgetResManager}管理模板的{@linkplain HtmlTplDashboardWidget},
|
||||
* 其中{@linkplain HtmlTplDashboardWidget#getTemplate()}即是可以通过{@linkplain FileDashboardWidgetResManager#getRelativePath(String, String)}找到的模板文件。
|
||||
* 此类可渲染由{@linkplain FileTemplateDashboardWidgetResManager}管理模板的{@linkplain HtmlTplDashboardWidget},
|
||||
* 其中{@linkplain HtmlTplDashboardWidget#getTemplate()}即是可以通过{@linkplain FileTemplateDashboardWidgetResManager#getRelativePath(String, String)}找到的模板文件。
|
||||
* </p>
|
||||
* <p>
|
||||
* 此类需要手动调用{@linkplain #init()}方法进行初始化。
|
||||
|
@ -104,25 +104,27 @@ public class HtmlTplDashboardWidgetFmkRenderer<T extends HtmlRenderContext> exte
|
|||
super();
|
||||
}
|
||||
|
||||
public HtmlTplDashboardWidgetFmkRenderer(FileDashboardWidgetResManager dashboardWidgetResManager,
|
||||
public HtmlTplDashboardWidgetFmkRenderer(FileTemplateDashboardWidgetResManager templateDashboardWidgetResManager,
|
||||
ChartWidgetSource chartWidgetSource)
|
||||
{
|
||||
super(dashboardWidgetResManager, chartWidgetSource);
|
||||
super(templateDashboardWidgetResManager, chartWidgetSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileDashboardWidgetResManager getDashboardWidgetResManager()
|
||||
public FileTemplateDashboardWidgetResManager getTemplateDashboardWidgetResManager()
|
||||
{
|
||||
return (FileDashboardWidgetResManager) super.getDashboardWidgetResManager();
|
||||
return (FileTemplateDashboardWidgetResManager) super.getTemplateDashboardWidgetResManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDashboardWidgetResManager(DashboardWidgetResManager dashboardWidgetResManager)
|
||||
public void setTemplateDashboardWidgetResManager(
|
||||
TemplateDashboardWidgetResManager templateDashboardWidgetResManager)
|
||||
{
|
||||
if (dashboardWidgetResManager != null && !(dashboardWidgetResManager instanceof FileDashboardWidgetResManager))
|
||||
if (templateDashboardWidgetResManager != null
|
||||
&& !(templateDashboardWidgetResManager instanceof FileTemplateDashboardWidgetResManager))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setDashboardWidgetResManager(dashboardWidgetResManager);
|
||||
super.setTemplateDashboardWidgetResManager(templateDashboardWidgetResManager);
|
||||
}
|
||||
|
||||
public String getDefaultTemplateEncoding()
|
||||
|
@ -153,7 +155,7 @@ public class HtmlTplDashboardWidgetFmkRenderer<T extends HtmlRenderContext> exte
|
|||
public void init() throws IOException
|
||||
{
|
||||
Configuration cfg = new Configuration(Configuration.VERSION_2_3_28);
|
||||
cfg.setDirectoryForTemplateLoading(getDashboardWidgetResManager().getRootDirectory());
|
||||
cfg.setDirectoryForTemplateLoading(getTemplateDashboardWidgetResManager().getRootDirectory());
|
||||
cfg.setDefaultEncoding(this.defaultTemplateEncoding);
|
||||
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
||||
cfg.setLogTemplateExceptions(false);
|
||||
|
@ -193,7 +195,7 @@ public class HtmlTplDashboardWidgetFmkRenderer<T extends HtmlRenderContext> exte
|
|||
*/
|
||||
protected Template getTemplate(HtmlTplDashboardWidget<?> dashboardWidget) throws Exception
|
||||
{
|
||||
String path = getDashboardWidgetResManager().getRelativePath(dashboardWidget.getId(),
|
||||
String path = getTemplateDashboardWidgetResManager().getRelativePath(dashboardWidget.getId(),
|
||||
dashboardWidget.getTemplate());
|
||||
|
||||
return getConfiguration().getTemplate(path);
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.datagear.analysis.Chart;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.ChartWidgetSource;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.util.StringUtil;
|
||||
|
||||
/**
|
||||
|
@ -101,10 +101,10 @@ public class HtmlTplDashboardWidgetHtmlRenderer<T extends HtmlRenderContext> ext
|
|||
super();
|
||||
}
|
||||
|
||||
public HtmlTplDashboardWidgetHtmlRenderer(DashboardWidgetResManager dashboardWidgetResManager,
|
||||
public HtmlTplDashboardWidgetHtmlRenderer(TemplateDashboardWidgetResManager templateDashboardWidgetResManager,
|
||||
ChartWidgetSource chartWidgetSource)
|
||||
{
|
||||
super(dashboardWidgetResManager, chartWidgetSource);
|
||||
super(templateDashboardWidgetResManager, chartWidgetSource);
|
||||
}
|
||||
|
||||
public String getDashboardSetTagName()
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.datagear.analysis.support.html;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -23,10 +22,10 @@ import org.datagear.analysis.DashboardThemeSource;
|
|||
import org.datagear.analysis.RenderContext;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.Theme;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
import org.datagear.analysis.support.ChartWidgetSource;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.SimpleDashboardThemeSource;
|
||||
import org.datagear.util.Global;
|
||||
import org.datagear.util.IDUtil;
|
||||
|
@ -95,7 +94,7 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
|
||||
public static final String PROPERTY_VALUE_FOR_RENDER_EXCEPTION = "targetHtmlChartRenderExceptionMessage";
|
||||
|
||||
private DashboardWidgetResManager dashboardWidgetResManager;
|
||||
private TemplateDashboardWidgetResManager templateDashboardWidgetResManager;
|
||||
|
||||
private ChartWidgetSource chartWidgetSource;
|
||||
|
||||
|
@ -153,22 +152,23 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
super();
|
||||
}
|
||||
|
||||
public HtmlTplDashboardWidgetRenderer(DashboardWidgetResManager dashboardWidgetResManager,
|
||||
public HtmlTplDashboardWidgetRenderer(TemplateDashboardWidgetResManager templateDashboardWidgetResManager,
|
||||
ChartWidgetSource chartWidgetSource)
|
||||
{
|
||||
super();
|
||||
this.dashboardWidgetResManager = dashboardWidgetResManager;
|
||||
this.templateDashboardWidgetResManager = templateDashboardWidgetResManager;
|
||||
this.chartWidgetSource = chartWidgetSource;
|
||||
}
|
||||
|
||||
public DashboardWidgetResManager getDashboardWidgetResManager()
|
||||
public TemplateDashboardWidgetResManager getTemplateDashboardWidgetResManager()
|
||||
{
|
||||
return dashboardWidgetResManager;
|
||||
return templateDashboardWidgetResManager;
|
||||
}
|
||||
|
||||
public void setDashboardWidgetResManager(DashboardWidgetResManager dashboardWidgetResManager)
|
||||
public void setTemplateDashboardWidgetResManager(
|
||||
TemplateDashboardWidgetResManager templateDashboardWidgetResManager)
|
||||
{
|
||||
this.dashboardWidgetResManager = dashboardWidgetResManager;
|
||||
this.templateDashboardWidgetResManager = templateDashboardWidgetResManager;
|
||||
}
|
||||
|
||||
public ChartWidgetSource getChartWidgetSource()
|
||||
|
@ -564,9 +564,6 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
|
||||
/**
|
||||
* 获取{@linkplain HtmlTplDashboardWidget}的模板输入流。
|
||||
* <p>
|
||||
* 如果文件不存在,它将返回一个空字符串的{@linkplain StringReader}。
|
||||
* </p>
|
||||
*
|
||||
* @param dashboardWidget
|
||||
* @return
|
||||
|
@ -574,17 +571,11 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
*/
|
||||
protected Reader getTemplateReaderNotNull(HtmlTplDashboardWidget<?> dashboardWidget) throws IOException
|
||||
{
|
||||
String template = dashboardWidget.getTemplate();
|
||||
String templateEncoding = dashboardWidget.getTemplateEncoding();
|
||||
|
||||
return getDashboardWidgetResManager().getReader(dashboardWidget.getId(), template, templateEncoding);
|
||||
return getTemplateDashboardWidgetResManager().getTemplateReader(dashboardWidget);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain HtmlTplDashboardWidget}的模板输入流。
|
||||
* <p>
|
||||
* 如果文件不存在,它将返回一个空字符串的{@linkplain StringReader}。
|
||||
* </p>
|
||||
*
|
||||
* @param dashboardWidget
|
||||
* @return
|
||||
|
@ -592,10 +583,7 @@ public abstract class HtmlTplDashboardWidgetRenderer<T extends HtmlRenderContext
|
|||
*/
|
||||
protected Writer getTemplateWriter(HtmlTplDashboardWidget<?> dashboardWidget) throws IOException
|
||||
{
|
||||
String template = dashboardWidget.getTemplate();
|
||||
String templateEncoding = dashboardWidget.getTemplateEncoding();
|
||||
|
||||
return getDashboardWidgetResManager().getWriter(dashboardWidget.getId(), template, templateEncoding);
|
||||
return getTemplateDashboardWidgetResManager().getTemplateWriter(dashboardWidget);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.io.StringWriter;
|
|||
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.FileDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.FileTemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.SimpleChartWidgetSource;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext.WebContext;
|
||||
import org.junit.Assert;
|
||||
|
@ -36,7 +36,7 @@ public class HtmlTplDashboardWidgetFmkRendererTest
|
|||
HtmlChartWidget<HtmlRenderContext> htmlChartWidget = new HtmlChartWidget<HtmlRenderContext>("chart-widget-01",
|
||||
"chart-widget-01", chartPlugin, (ChartDataSet[]) null);
|
||||
|
||||
FileDashboardWidgetResManager resManager = new FileDashboardWidgetResManager(
|
||||
FileTemplateDashboardWidgetResManager resManager = new FileTemplateDashboardWidgetResManager(
|
||||
"src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/freemarker");
|
||||
|
||||
SimpleChartWidgetSource chartWidgetSource = new SimpleChartWidgetSource(htmlChartWidget);
|
||||
|
|
|
@ -13,8 +13,8 @@ import java.util.List;
|
|||
|
||||
import org.datagear.analysis.ChartDataSet;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.FileDashboardWidgetResManager;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.FileTemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.SimpleChartWidgetSource;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext.WebContext;
|
||||
import org.datagear.analysis.support.html.HtmlTplDashboardWidgetHtmlRenderer.ChartInfo;
|
||||
|
@ -50,7 +50,7 @@ public class HtmlTplDashboardWidgetHtmlRendererTest
|
|||
HtmlChartWidget<HtmlRenderContext> htmlChartWidget = new HtmlChartWidget<HtmlRenderContext>("chart-widget-01",
|
||||
"chart-widget-01", chartPlugin, (ChartDataSet[]) null);
|
||||
|
||||
DashboardWidgetResManager resManager = new FileDashboardWidgetResManager(
|
||||
TemplateDashboardWidgetResManager resManager = new FileTemplateDashboardWidgetResManager(
|
||||
"src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html");
|
||||
|
||||
SimpleChartWidgetSource chartWidgetSource = new SimpleChartWidgetSource(htmlChartWidget);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class HtmlTplDashboardWidgetEntityServiceImpl
|
|||
if (deleted)
|
||||
{
|
||||
this.authorizationService.deleteByResource(HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE, id);
|
||||
this.htmlTplDashboardWidgetRenderer.getDashboardWidgetResManager().delete(id);
|
||||
this.htmlTplDashboardWidgetRenderer.getTemplateDashboardWidgetResManager().delete(id);
|
||||
}
|
||||
|
||||
return deleted;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package org.datagear.web.controller;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -20,6 +22,7 @@ import org.datagear.analysis.ChartDataSet;
|
|||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlDashboard;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
|
@ -33,6 +36,7 @@ import org.datagear.management.service.HtmlChartWidgetEntityService;
|
|||
import org.datagear.persistence.PagingData;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.datagear.util.IDUtil;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.web.OperationMessage;
|
||||
import org.datagear.web.util.WebUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -43,6 +47,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
|
||||
/**
|
||||
* 图表控制器。
|
||||
|
@ -61,8 +66,8 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
private ChartPluginManager chartPluginManager;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("chartPreviewHtmlTplDashboardWidgetHtmlRenderer")
|
||||
private HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartPreviewHtmlTplDashboardWidgetHtmlRenderer;
|
||||
@Qualifier("chartShowHtmlTplDashboardWidgetHtmlRenderer")
|
||||
private HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartShowHtmlTplDashboardWidgetHtmlRenderer;
|
||||
|
||||
public ChartController()
|
||||
{
|
||||
|
@ -71,12 +76,12 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
|
||||
public ChartController(HtmlChartWidgetEntityService htmlChartWidgetEntityService,
|
||||
ChartPluginManager chartPluginManager,
|
||||
HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartPreviewHtmlTplDashboardWidgetHtmlRenderer)
|
||||
HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartShowHtmlTplDashboardWidgetHtmlRenderer)
|
||||
{
|
||||
super();
|
||||
this.htmlChartWidgetEntityService = htmlChartWidgetEntityService;
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
this.chartPreviewHtmlTplDashboardWidgetHtmlRenderer = chartPreviewHtmlTplDashboardWidgetHtmlRenderer;
|
||||
this.chartShowHtmlTplDashboardWidgetHtmlRenderer = chartShowHtmlTplDashboardWidgetHtmlRenderer;
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntityService getHtmlChartWidgetEntityService()
|
||||
|
@ -99,15 +104,15 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
this.chartPluginManager = chartPluginManager;
|
||||
}
|
||||
|
||||
public HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> getChartPreviewHtmlTplDashboardWidgetHtmlRenderer()
|
||||
public HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> getChartShowHtmlTplDashboardWidgetHtmlRenderer()
|
||||
{
|
||||
return chartPreviewHtmlTplDashboardWidgetHtmlRenderer;
|
||||
return chartShowHtmlTplDashboardWidgetHtmlRenderer;
|
||||
}
|
||||
|
||||
public void setChartPreviewHtmlTplDashboardWidgetHtmlRenderer(
|
||||
HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartPreviewHtmlTplDashboardWidgetHtmlRenderer)
|
||||
public void setChartShowHtmlTplDashboardWidgetHtmlRenderer(
|
||||
HtmlTplDashboardWidgetHtmlRenderer<HtmlRenderContext> chartShowHtmlTplDashboardWidgetHtmlRenderer)
|
||||
{
|
||||
this.chartPreviewHtmlTplDashboardWidgetHtmlRenderer = chartPreviewHtmlTplDashboardWidgetHtmlRenderer;
|
||||
this.chartShowHtmlTplDashboardWidgetHtmlRenderer = chartShowHtmlTplDashboardWidgetHtmlRenderer;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
|
@ -259,7 +264,7 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
}
|
||||
|
||||
/**
|
||||
* 预览图表。
|
||||
* 展示图表。
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
|
@ -267,8 +272,8 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
* @param id
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/preview/{id}")
|
||||
public void preview(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestMapping({ "/show/{id}/", "/show/{id}/index" })
|
||||
public void show(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@PathVariable("id") String id) throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
@ -278,12 +283,12 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
if (chart == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
String htmlTitle = getMessage(request, "chart.preview.htmlTitle", chart.getName());
|
||||
String htmlTitle = getMessage(request, "chart.show.htmlTitle", chart.getName());
|
||||
HtmlTplDashboardWidget<HtmlRenderContext> dashboardWidget = new HtmlTplDashboardWidget<HtmlRenderContext>(id,
|
||||
this.chartPreviewHtmlTplDashboardWidgetHtmlRenderer.simpleTemplateContent("UTF-8", htmlTitle,
|
||||
" width:80%;\n height:80%;\n margin-left:10%;\n margin-top:5%;\n",
|
||||
this.chartShowHtmlTplDashboardWidgetHtmlRenderer.simpleTemplateContent("UTF-8", htmlTitle,
|
||||
" position:absolute;\n left:1em;\n right:1em;\n top:1em;\n bottom:1em;\n margin:0 0;\n",
|
||||
new String[] { id }),
|
||||
this.chartPreviewHtmlTplDashboardWidgetHtmlRenderer);
|
||||
this.chartShowHtmlTplDashboardWidgetHtmlRenderer);
|
||||
|
||||
String responseEncoding = dashboardWidget.getTemplateEncoding();
|
||||
response.setCharacterEncoding(responseEncoding);
|
||||
|
@ -299,7 +304,37 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
}
|
||||
|
||||
/**
|
||||
* 预览数据。
|
||||
* 加载展示图表的资源。
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param webRequest
|
||||
* @param model
|
||||
* @param id
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/show/{id}/**/*")
|
||||
public void showResource(HttpServletRequest request, HttpServletResponse response, WebRequest webRequest,
|
||||
org.springframework.ui.Model model, @PathVariable("id") String id) throws Exception
|
||||
{
|
||||
String pathInfo = request.getPathInfo();
|
||||
String resPath = pathInfo.substring(pathInfo.indexOf(id) + id.length() + 1);
|
||||
|
||||
TemplateDashboardWidgetResManager resManager = this.chartShowHtmlTplDashboardWidgetHtmlRenderer
|
||||
.getTemplateDashboardWidgetResManager();
|
||||
|
||||
long lastModified = resManager.lastModifiedResource(id, resPath);
|
||||
if (webRequest.checkNotModified(lastModified))
|
||||
return;
|
||||
|
||||
InputStream in = resManager.getResourceInputStream(id, resPath);
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
IOUtil.write(in, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示数据。
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
|
@ -307,9 +342,9 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
* @param id
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/previewData", produces = CONTENT_TYPE_JSON)
|
||||
@RequestMapping(value = "/showData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public Map<String, DataSetResult[]> previewData(HttpServletRequest request, HttpServletResponse response,
|
||||
public Map<String, DataSetResult[]> showData(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model) throws Exception
|
||||
{
|
||||
WebContext webContext = createWebContext(request);
|
||||
|
@ -319,7 +354,7 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
protected WebContext createWebContext(HttpServletRequest request)
|
||||
{
|
||||
String contextPath = request.getContextPath();
|
||||
return new WebContext(contextPath, contextPath + "/analysis/chart/previewData");
|
||||
return new WebContext(contextPath, contextPath + "/analysis/chart/showData");
|
||||
}
|
||||
|
||||
protected void setChartPluginNames(HttpServletRequest request, List<HtmlChartWidgetEntity> entities)
|
||||
|
|
|
@ -18,7 +18,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.support.DashboardWidgetResManager;
|
||||
import org.datagear.analysis.TemplateDashboardWidgetResManager;
|
||||
import org.datagear.analysis.support.html.HtmlDashboard;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext.WebContext;
|
||||
|
@ -285,8 +285,8 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
|
||||
this.htmlTplDashboardWidgetEntityService.add(user, dashboard);
|
||||
|
||||
DashboardWidgetResManager dashboardWidgetResManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getDashboardWidgetResManager();
|
||||
TemplateDashboardWidgetResManager dashboardWidgetResManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getTemplateDashboardWidgetResManager();
|
||||
|
||||
dashboardWidgetResManager.copyFrom(dashboard.getId(), uploadDirectory);
|
||||
|
||||
|
@ -381,8 +381,8 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
if (dashboardWidget == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
DashboardWidgetResManager dashboardWidgetResManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getDashboardWidgetResManager();
|
||||
TemplateDashboardWidgetResManager dashboardWidgetResManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getTemplateDashboardWidgetResManager();
|
||||
|
||||
String responseEncoding = dashboardWidget.getTemplateEncoding();
|
||||
|
||||
|
@ -418,14 +418,14 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
String pathInfo = request.getPathInfo();
|
||||
String resPath = pathInfo.substring(pathInfo.indexOf(id) + id.length() + 1);
|
||||
|
||||
DashboardWidgetResManager resManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getDashboardWidgetResManager();
|
||||
TemplateDashboardWidgetResManager resManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getTemplateDashboardWidgetResManager();
|
||||
|
||||
long lastModified = resManager.lastModified(id, resPath);
|
||||
long lastModified = resManager.lastModifiedResource(id, resPath);
|
||||
if (webRequest.checkNotModified(lastModified))
|
||||
return;
|
||||
|
||||
InputStream in = resManager.getInputStream(id, resPath);
|
||||
InputStream in = resManager.getResourceInputStream(id, resPath);
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
IOUtil.write(in, out);
|
||||
|
|
|
@ -313,7 +313,7 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dashboardWidgetResManager" class="org.datagear.analysis.support.FileDashboardWidgetResManager">
|
||||
<bean id="templateDashboardWidgetResManager" class="org.datagear.analysis.support.FileTemplateDashboardWidgetResManager">
|
||||
<property name="rootDirectory" ref="dashboardRootDirectory" />
|
||||
</bean>
|
||||
|
||||
|
@ -338,7 +338,7 @@
|
|||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="dashboardWidgetResManager" ref="dashboardWidgetResManager" />
|
||||
<property name="templateDashboardWidgetResManager" ref="templateDashboardWidgetResManager" />
|
||||
<property name="chartWidgetSource" ref="htmlChartWidgetEntityService" />
|
||||
</bean>
|
||||
|
||||
|
@ -360,9 +360,12 @@
|
|||
<property name="authorizationService" ref="authorizationService" />
|
||||
</bean>
|
||||
|
||||
<bean id="chartPreviewHtmlTplDashboardWidgetHtmlRenderer" parent="htmlTplDashboardWidgetRendererParent">
|
||||
<property name="dashboardWidgetResManager">
|
||||
<bean class="org.datagear.analysis.support.DirectDashboardWidgetResManager" />
|
||||
<bean id="chartShowHtmlTplDashboardWidgetHtmlRenderer" parent="htmlTplDashboardWidgetRendererParent">
|
||||
<property name="templateDashboardWidgetResManager">
|
||||
<bean id="templateDashboardWidgetResManager" class="org.datagear.analysis.support.FileTemplateDashboardWidgetResManager">
|
||||
<property name="rootDirectory" ref="dashboardRootDirectory" />
|
||||
<property name="templateAsContent" value="true" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -644,8 +644,9 @@ chart.createTime=\u521B\u5EFA\u65F6\u95F4
|
|||
chart.addDataSign=\u6DFB\u52A0\u6570\u636E\u6807\u8BB0
|
||||
chart.selectDataSign=\u9009\u62E9\u6570\u636E\u6807\u8BB0
|
||||
chart.validation.chartDataSetSign=\u6570\u636E\u96C6[{needSignDataSetName}]\u5FC5\u987B\u8BBE\u7F6E\u6570\u636E\u6807\u8BB0\uFF1A{needDataSignLabel}
|
||||
chart.preview.htmlTitle=\u9884\u89C8\u56FE\u8868 - {0}
|
||||
chart.saveAndPreview=\u4FDD\u5B58\u5E76\u9884\u89C8
|
||||
chart.show.htmlTitle=\u56FE\u8868 - {0}
|
||||
chart.saveAndShow=\u4FDD\u5B58\u5E76\u5C55\u793A
|
||||
chart.show=\u5C55\u793A
|
||||
|
||||
#Dashboard
|
||||
dashboard.manageDashboard=\u7BA1\u7406\u770B\u677F
|
||||
|
|
|
@ -67,7 +67,7 @@ readonly 是否只读操作,允许为null
|
|||
<#if !readonly>
|
||||
<input type="submit" value="<@spring.message code='save' />" class="recommended" />
|
||||
|
||||
<button type="button" name="saveAndPreview"><@spring.message code='chart.saveAndPreview' /></button>
|
||||
<button type="button" name="saveAndShow"><@spring.message code='chart.saveAndShow' /></button>
|
||||
|
||||
<input type="reset" value="<@spring.message code='reset' />" />
|
||||
</#if>
|
||||
|
@ -396,7 +396,7 @@ readonly 是否只读操作,允许为null
|
|||
|
||||
po.previewAfterSave = false;
|
||||
|
||||
po.element("button[name=saveAndPreview]").click(function()
|
||||
po.element("button[name=saveAndShow]").click(function()
|
||||
{
|
||||
po.previewAfterSave = true;
|
||||
po.element("input[type='submit']").click();
|
||||
|
@ -498,7 +498,7 @@ readonly 是否只读操作,允许为null
|
|||
po.close();
|
||||
|
||||
if(po.previewAfterSave)
|
||||
window.open(po.url("preview/"+chart.id), chart.id);
|
||||
window.open(po.url("show/"+chart.id+"/index"), chart.id);
|
||||
},
|
||||
complete: function()
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ selectonly 是否选择操作,允许为null
|
|||
<input name="addButton" type="button" value="<@spring.message code='add' />" />
|
||||
<input name="editButton" type="button" value="<@spring.message code='edit' />" />
|
||||
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
|
||||
<input name="previewButton" type="button" value="<@spring.message code='preview' />" />
|
||||
<input name="showButton" type="button" value="<@spring.message code='chart.show' />" />
|
||||
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</#if>
|
||||
</div>
|
||||
|
@ -109,11 +109,11 @@ selectonly 是否选择操作,允许为null
|
|||
});
|
||||
});
|
||||
|
||||
po.element("input[name=previewButton]").click(function()
|
||||
po.element("input[name=showButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
window.open(po.url("preview/"+row.id), row.id);
|
||||
window.open(po.url("show/"+row.id+"/index"), row.id);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue