forked from p85126437/datagear
添加图表管理基本功能
This commit is contained in:
parent
9b66dd0fe7
commit
a2f9c273c3
|
@ -44,14 +44,14 @@ public abstract class AbstractChartPluginManager implements ChartPluginManager
|
|||
|
||||
if (oldIndex < 0)
|
||||
{
|
||||
((List<ChartPlugin<?>>) chartPlugin).add(chartPlugin);
|
||||
((List<ChartPlugin<?>>) chartPlugins).add(chartPlugin);
|
||||
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartPlugin<?> old = chartPlugins.get(oldIndex);
|
||||
((List<ChartPlugin<?>>) chartPlugin).set(oldIndex, chartPlugin);
|
||||
((List<ChartPlugin<?>>) chartPlugins).set(oldIndex, chartPlugin);
|
||||
|
||||
return old;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,9 @@ public abstract class AbstractDataSetFactory extends AbstractIdentifiable implem
|
|||
super();
|
||||
}
|
||||
|
||||
public AbstractDataSetFactory(String id, DataSetParams params)
|
||||
public AbstractDataSetFactory(String id)
|
||||
{
|
||||
super(id);
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public boolean hasParam()
|
||||
|
|
|
@ -34,12 +34,10 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
super();
|
||||
}
|
||||
|
||||
public ChartWidget(String id, ChartPlugin<T> chartPlugin, ChartPropertyValues chartPropertyValues,
|
||||
DataSetFactory... dataSetFactories)
|
||||
public ChartWidget(String id, ChartPlugin<T> chartPlugin, DataSetFactory... dataSetFactories)
|
||||
{
|
||||
super(id);
|
||||
this.chartPlugin = chartPlugin;
|
||||
this.chartPropertyValues = chartPropertyValues;
|
||||
this.dataSetFactories = dataSetFactories;
|
||||
}
|
||||
|
||||
|
@ -68,7 +66,7 @@ public class ChartWidget<T extends RenderContext> extends AbstractIdentifiable
|
|||
return dataSetFactories;
|
||||
}
|
||||
|
||||
public void setDataSetFactories(DataSetFactory... dataSetFactories)
|
||||
public void setDataSetFactories(DataSetFactory[] dataSetFactories)
|
||||
{
|
||||
this.dataSetFactories = dataSetFactories;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.datagear.analysis.DataSetFactory;
|
|||
import org.datagear.analysis.DataSetMeta;
|
||||
import org.datagear.analysis.DataSetParam;
|
||||
import org.datagear.analysis.DataSetParamValues;
|
||||
import org.datagear.analysis.DataSetParams;
|
||||
import org.datagear.analysis.DataType;
|
||||
import org.datagear.analysis.support.ParameterSqlResolver.ParameterSql;
|
||||
import org.datagear.util.JdbcUtil;
|
||||
|
@ -61,9 +60,9 @@ public class SqlDataSetFactory extends AbstractDataSetFactory
|
|||
super();
|
||||
}
|
||||
|
||||
public SqlDataSetFactory(String id, DataSetParams dataSetParams, ConnectionFactory connectionFactory, String sql)
|
||||
public SqlDataSetFactory(String id, ConnectionFactory connectionFactory, String sql)
|
||||
{
|
||||
super(id, dataSetParams);
|
||||
super(id);
|
||||
this.connectionFactory = connectionFactory;
|
||||
this.sql = sql;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class HtmlChart extends AbstractChart
|
|||
@Override
|
||||
public void setRenderContext(RenderContext renderContext)
|
||||
{
|
||||
if (!(renderContext instanceof HtmlRenderContext))
|
||||
if (renderContext != null && !(renderContext instanceof HtmlRenderContext))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setRenderContext(renderContext);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
package org.datagear.analysis.support.html;
|
||||
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPropertyValues;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.RenderException;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
|
@ -26,10 +25,9 @@ public class HtmlChartWidget<T extends HtmlRenderContext> extends ChartWidget<T>
|
|||
super();
|
||||
}
|
||||
|
||||
public HtmlChartWidget(String id, HtmlChartPlugin<T> chartPlugin, ChartPropertyValues chartPropertyValues,
|
||||
DataSetFactory... dataSetFactories)
|
||||
public HtmlChartWidget(String id, HtmlChartPlugin<T> chartPlugin, DataSetFactory... dataSetFactories)
|
||||
{
|
||||
super(id, chartPlugin, chartPropertyValues, dataSetFactories);
|
||||
super(id, chartPlugin, dataSetFactories);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +39,7 @@ public class HtmlChartWidget<T extends HtmlRenderContext> extends ChartWidget<T>
|
|||
@Override
|
||||
public void setChartPlugin(ChartPlugin<T> chartPlugin)
|
||||
{
|
||||
if (!(chartPlugin instanceof HtmlChartPlugin<?>))
|
||||
if (chartPlugin != null && !(chartPlugin instanceof HtmlChartPlugin<?>))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setChartPlugin(chartPlugin);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class HtmlDashboard extends AbstractDashboard
|
|||
@Override
|
||||
public void setRenderContext(RenderContext renderContext)
|
||||
{
|
||||
if (!(renderContext instanceof HtmlRenderContext))
|
||||
if (renderContext != null && !(renderContext instanceof HtmlRenderContext))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setRenderContext(renderContext);
|
||||
|
|
|
@ -67,7 +67,8 @@ public class SqlDataSetFactoryTest extends DBTestSupport
|
|||
dataSetParams.add(new DataSetParam("id", DataType.INTEGER, true));
|
||||
dataSetParams.add(new DataSetParam("name", DataType.STRING, true));
|
||||
|
||||
SqlDataSetFactory sqlDataSetFactory = new SqlDataSetFactory("1", dataSetParams, connectionFactory, sql);
|
||||
SqlDataSetFactory sqlDataSetFactory = new SqlDataSetFactory("1", connectionFactory, sql);
|
||||
sqlDataSetFactory.setParams(dataSetParams);
|
||||
sqlDataSetFactory.setColumnLabels(columnLabels);
|
||||
|
||||
DataSetParamValues dataSetParamValues = new DataSetParamValues();
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.datagear.analysis.support.html;
|
|||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.datagear.analysis.ChartPropertyValues;
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.SimpleChartWidgetSource;
|
||||
|
@ -34,7 +33,7 @@ public class HtmlFreemarkerDashboardWidgetTest
|
|||
HtmlChartPlugin<HtmlRenderContext> chartPlugin = HtmlChartPluginTest.createHtmlChartPlugin();
|
||||
|
||||
HtmlChartWidget<HtmlRenderContext> htmlChartWidget = new HtmlChartWidget<HtmlRenderContext>("chart-widget-01",
|
||||
chartPlugin, new ChartPropertyValues(), (DataSetFactory[]) null);
|
||||
chartPlugin, (DataSetFactory[]) null);
|
||||
|
||||
TemplateDashboardWidgetResManager resManager = new TemplateDashboardWidgetResManager(
|
||||
"src/test/resources/org/datagear/analysis/support/html/htmlFreemarkerDashboardWidgets");
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.management.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.datagear.analysis.DataSetFactory;
|
||||
import org.datagear.analysis.support.ChartWidget;
|
||||
import org.datagear.analysis.support.SqlDataSetFactory;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlChartWidget;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
|
||||
/**
|
||||
* HTML {@linkplain ChartWidget}实体。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class HtmlChartWidgetEntity extends HtmlChartWidget<HtmlRenderContext>
|
||||
implements CreateUserEntity<String>, DataPermissionEntity<String>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 授权资源类型 */
|
||||
public static final String AUTHORIZATION_RESOURCE_TYPE = "Chart";
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 创建用户 */
|
||||
private User createUser;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
|
||||
/** 权限 */
|
||||
private int dataPermission = PERMISSION_NOT_LOADED;
|
||||
|
||||
public HtmlChartWidgetEntity()
|
||||
{
|
||||
super();
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntity(String id, HtmlChartPlugin<HtmlRenderContext> chartPlugin,
|
||||
SqlDataSetFactory[] dataSetFactories, String name, User createUser)
|
||||
{
|
||||
super(id, chartPlugin, dataSetFactories);
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public HtmlChartPlugin<HtmlRenderContext> getHtmlChartPlugin()
|
||||
{
|
||||
return getChartPlugin();
|
||||
}
|
||||
|
||||
public void setHtmlChartPlugin(HtmlChartPlugin<HtmlRenderContext> htmlChartPlugin)
|
||||
{
|
||||
setChartPlugin(htmlChartPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlDataSetFactoryEntity[] getDataSetFactories()
|
||||
{
|
||||
return (SqlDataSetFactoryEntity[]) super.getDataSetFactories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataSetFactories(DataSetFactory[] dataSetFactories)
|
||||
{
|
||||
if (dataSetFactories != null && !(dataSetFactories instanceof SqlDataSetFactoryEntity[]))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setDataSetFactories(dataSetFactories);
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntity[] getSqlDataSetFactoryEntities()
|
||||
{
|
||||
return getDataSetFactories();
|
||||
}
|
||||
|
||||
public void setSqlDataSetFactoryEntities(SqlDataSetFactoryEntity[] sqlDataSetFactoryEntities)
|
||||
{
|
||||
setDataSetFactories(sqlDataSetFactoryEntities);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getCreateUser()
|
||||
{
|
||||
return createUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreateUser(User createUser)
|
||||
{
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDataPermission()
|
||||
{
|
||||
return dataPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataPermission(int dataPermission)
|
||||
{
|
||||
this.dataPermission = dataPermission;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ package org.datagear.management.domain;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.datagear.analysis.DataSetParams;
|
||||
import org.datagear.analysis.support.SqlDataSetFactory;
|
||||
import org.datagear.util.resource.ConnectionFactory;
|
||||
|
||||
|
@ -25,7 +24,7 @@ public class SqlDataSetFactoryEntity extends SqlDataSetFactory
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 授权资源类型 */
|
||||
public static final String AUTHORIZATION_RESOURCE_TYPE = "SqlDataSetFactoryEntity";
|
||||
public static final String AUTHORIZATION_RESOURCE_TYPE = "DataSet";
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
@ -45,10 +44,10 @@ public class SqlDataSetFactoryEntity extends SqlDataSetFactory
|
|||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntity(String id, DataSetParams dataSetParams, SchemaConnectionFactory connectionFactory,
|
||||
String sql, String name, User createUser)
|
||||
public SqlDataSetFactoryEntity(String id, SchemaConnectionFactory connectionFactory, String sql, String name,
|
||||
User createUser)
|
||||
{
|
||||
super(id, dataSetParams, connectionFactory, sql);
|
||||
super(id, connectionFactory, sql);
|
||||
this.name = name;
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
@ -62,7 +61,7 @@ public class SqlDataSetFactoryEntity extends SqlDataSetFactory
|
|||
@Override
|
||||
public void setConnectionFactory(ConnectionFactory connectionFactory)
|
||||
{
|
||||
if (!(connectionFactory instanceof SchemaConnectionFactory))
|
||||
if (connectionFactory != null && !(connectionFactory instanceof SchemaConnectionFactory))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
super.setConnectionFactory(connectionFactory);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.management.service;
|
||||
|
||||
import org.datagear.management.domain.HtmlChartWidgetEntity;
|
||||
|
||||
/**
|
||||
* {@linkplain HtmlChartWidgetEntity}业务服务接口。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface HtmlChartWidgetEntityService extends DataPermissionEntityService<String, HtmlChartWidgetEntity>
|
||||
{
|
||||
|
||||
}
|
|
@ -7,6 +7,9 @@
|
|||
*/
|
||||
package org.datagear.management.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.datagear.management.domain.HtmlChartWidgetEntity;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
|
||||
/**
|
||||
|
@ -17,5 +20,11 @@ import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
|||
*/
|
||||
public interface SqlDataSetFactoryEntityService extends DataPermissionEntityService<String, SqlDataSetFactoryEntity>
|
||||
{
|
||||
|
||||
/**
|
||||
* 查找{@linkplain HtmlChartWidgetEntity#getId()}关联的所有{@linkplain SqlDataSetFactoryEntity}。
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<SqlDataSetFactoryEntity> findByHtmlChartWidgetEntityId(String id);
|
||||
}
|
||||
|
|
|
@ -257,6 +257,23 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询。
|
||||
*
|
||||
* @param statement
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
protected List<T> query(String statement, Map<String, Object> params)
|
||||
{
|
||||
addIdentifierQuoteParameter(params);
|
||||
|
||||
List<T> list = selectListMybatis(statement, params);
|
||||
postProcessSelects(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询。
|
||||
*
|
||||
|
@ -329,6 +346,9 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
|
||||
/**
|
||||
* 后置处理查询结果列表。
|
||||
* <p>
|
||||
* 次方法对每一个元素调用{@linkplain #postProcessSelect(Object)}。
|
||||
* </p>
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,280 @@
|
|||
/*
|
||||
* Copyright (c) 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.datagear.management.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.management.domain.HtmlChartWidgetEntity;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.AuthorizationService;
|
||||
import org.datagear.management.service.HtmlChartWidgetEntityService;
|
||||
import org.datagear.management.service.PermissionDeniedException;
|
||||
import org.datagear.management.service.SqlDataSetFactoryEntityService;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* {@linkplain HtmlChartWidgetEntityService}实现类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class HtmlChartWidgetEntityServiceImpl
|
||||
extends AbstractMybatisDataPermissionEntityService<String, HtmlChartWidgetEntity>
|
||||
implements HtmlChartWidgetEntityService
|
||||
{
|
||||
protected static final String SQL_NAMESPACE = HtmlChartWidgetEntity.class.getName();
|
||||
|
||||
private ChartPluginManager chartPluginManager;
|
||||
|
||||
private SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService;
|
||||
|
||||
private AuthorizationService authorizationService;
|
||||
|
||||
public HtmlChartWidgetEntityServiceImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntityServiceImpl(SqlSessionFactory sqlSessionFactory, ChartPluginManager chartPluginManager,
|
||||
SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService, AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionFactory);
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntityServiceImpl(SqlSessionTemplate sqlSessionTemplate,
|
||||
ChartPluginManager chartPluginManager, SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService,
|
||||
AuthorizationService authorizationService)
|
||||
{
|
||||
super(sqlSessionTemplate);
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public ChartPluginManager getChartPluginManager()
|
||||
{
|
||||
return chartPluginManager;
|
||||
}
|
||||
|
||||
public void setChartPluginManager(ChartPluginManager chartPluginManager)
|
||||
{
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
}
|
||||
|
||||
public SqlDataSetFactoryEntityService getSqlDataSetFactoryEntityService()
|
||||
{
|
||||
return sqlDataSetFactoryEntityService;
|
||||
}
|
||||
|
||||
public void setSqlDataSetFactoryEntityService(SqlDataSetFactoryEntityService sqlDataSetFactoryEntityService)
|
||||
{
|
||||
this.sqlDataSetFactoryEntityService = sqlDataSetFactoryEntityService;
|
||||
}
|
||||
|
||||
public AuthorizationService getAuthorizationService()
|
||||
{
|
||||
return authorizationService;
|
||||
}
|
||||
|
||||
public void setAuthorizationService(AuthorizationService authorizationService)
|
||||
{
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceType()
|
||||
{
|
||||
return HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HtmlChartWidgetEntity getByStringId(User user, String id) throws PermissionDeniedException
|
||||
{
|
||||
return super.getById(user, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean add(HtmlChartWidgetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
boolean success = super.add(entity, params);
|
||||
|
||||
if (success)
|
||||
saveWidgetDataSetFactoryRelations(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean update(HtmlChartWidgetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
boolean success = super.update(entity, params);
|
||||
|
||||
if (success)
|
||||
saveWidgetDataSetFactoryRelations(entity);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean deleteById(String id, Map<String, Object> params)
|
||||
{
|
||||
boolean deleted = super.deleteById(id, params);
|
||||
|
||||
if (deleted)
|
||||
this.authorizationService.deleteByResource(HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE, id);
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
protected void saveWidgetDataSetFactoryRelations(HtmlChartWidgetEntity entity)
|
||||
{
|
||||
deleteMybatis("deleteDataSetRelationById", entity.getId());
|
||||
|
||||
List<WidgetDataSetFactoryRelation> relations = WidgetDataSetFactoryRelation.valuesOf(entity);
|
||||
|
||||
if (!relations.isEmpty())
|
||||
{
|
||||
for (WidgetDataSetFactoryRelation relation : relations)
|
||||
insertMybatis("insertDataSetRelation", relation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessSelects(List<HtmlChartWidgetEntity> list)
|
||||
{
|
||||
// XXX 查询操作仅用于展示,不必完全加载
|
||||
// super.postProcessSelects(list);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
protected void postProcessSelect(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
HtmlChartPlugin<HtmlRenderContext> htmlChartPlugin = obj.getHtmlChartPlugin();
|
||||
|
||||
if (htmlChartPlugin != null)
|
||||
{
|
||||
htmlChartPlugin = (HtmlChartPlugin<HtmlRenderContext>) (ChartPlugin) this.chartPluginManager
|
||||
.get(htmlChartPlugin.getId());
|
||||
|
||||
obj.setHtmlChartPlugin(htmlChartPlugin);
|
||||
}
|
||||
|
||||
List<SqlDataSetFactoryEntity> sqlDataSetFactories = this.sqlDataSetFactoryEntityService
|
||||
.findByHtmlChartWidgetEntityId(obj.getId());
|
||||
|
||||
if (sqlDataSetFactories != null)
|
||||
{
|
||||
SqlDataSetFactoryEntity[] sqlDataSetFactoryAry = new SqlDataSetFactoryEntity[sqlDataSetFactories.size()];
|
||||
sqlDataSetFactories.toArray(sqlDataSetFactoryAry);
|
||||
|
||||
obj.setSqlDataSetFactoryEntities(sqlDataSetFactoryAry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addDataPermissionParameters(Map<String, Object> params, User user)
|
||||
{
|
||||
addDataPermissionParameters(params, user, getResourceType(), false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSqlNamespace()
|
||||
{
|
||||
return SQL_NAMESPACE;
|
||||
}
|
||||
|
||||
public static class WidgetDataSetFactoryRelation
|
||||
{
|
||||
private String widgetId;
|
||||
|
||||
private String dataSetFactoryId;
|
||||
|
||||
private int order;
|
||||
|
||||
public WidgetDataSetFactoryRelation()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public WidgetDataSetFactoryRelation(String widgetId, String dataSetFactoryId, int order)
|
||||
{
|
||||
super();
|
||||
this.widgetId = widgetId;
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getWidgetId()
|
||||
{
|
||||
return widgetId;
|
||||
}
|
||||
|
||||
public void setWidgetId(String widgetId)
|
||||
{
|
||||
this.widgetId = widgetId;
|
||||
}
|
||||
|
||||
public String getDataSetFactoryId()
|
||||
{
|
||||
return dataSetFactoryId;
|
||||
}
|
||||
|
||||
public void setDataSetFactoryId(String dataSetFactoryId)
|
||||
{
|
||||
this.dataSetFactoryId = dataSetFactoryId;
|
||||
}
|
||||
|
||||
public int getOrder()
|
||||
{
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(int order)
|
||||
{
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public static List<WidgetDataSetFactoryRelation> valuesOf(HtmlChartWidgetEntity obj)
|
||||
{
|
||||
List<WidgetDataSetFactoryRelation> list = new ArrayList<WidgetDataSetFactoryRelation>();
|
||||
|
||||
if (obj == null)
|
||||
return list;
|
||||
|
||||
SqlDataSetFactoryEntity[] dataSetFactoryEntities = obj.getSqlDataSetFactoryEntities();
|
||||
|
||||
if (dataSetFactoryEntities == null)
|
||||
return list;
|
||||
|
||||
for (int i = 0; i < dataSetFactoryEntities.length; i++)
|
||||
{
|
||||
WidgetDataSetFactoryRelation relation = new WidgetDataSetFactoryRelation(obj.getId(),
|
||||
dataSetFactoryEntities[i].getId(), i + 1);
|
||||
|
||||
list.add(relation);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -92,6 +92,15 @@ public class SqlDataSetFactoryEntityServiceImpl
|
|||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SqlDataSetFactoryEntity> findByHtmlChartWidgetEntityId(String id)
|
||||
{
|
||||
Map<String, Object> params = buildParamMapWithIdentifierQuoteParameter();
|
||||
params.put("htmlChartWidgetEntityId", id);
|
||||
|
||||
return super.query("findByHtmlChartWidgetEntityId", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourceType()
|
||||
{
|
||||
|
|
|
@ -163,6 +163,7 @@ ALTER TABLE DATAGEAR_SQL_HISTORY ADD FOREIGN KEY (SQLHIS_SCHEMA_ID) REFERENCES D
|
|||
--version[1.5.0], DO NOT EDIT THIS LINE!
|
||||
-----------------------------------------
|
||||
|
||||
--数据集
|
||||
CREATE TABLE DATAGEAR_SQL_DATA_SET_FACTORY
|
||||
(
|
||||
DSF_ID VARCHAR(50) NOT NULL,
|
||||
|
@ -176,6 +177,7 @@ CREATE TABLE DATAGEAR_SQL_DATA_SET_FACTORY
|
|||
|
||||
ALTER TABLE DATAGEAR_SQL_DATA_SET_FACTORY ADD FOREIGN KEY (DSF_SCHEMA_ID) REFERENCES DATAGEAR_SCHEMA (SCHEMA_ID);
|
||||
|
||||
--数据集参数
|
||||
CREATE TABLE DATAGEAR_SQL_DATA_SET_FACTORY_PAR
|
||||
(
|
||||
DSFP_DSF_ID VARCHAR(50) NOT NULL,
|
||||
|
@ -188,3 +190,28 @@ CREATE TABLE DATAGEAR_SQL_DATA_SET_FACTORY_PAR
|
|||
ALTER TABLE DATAGEAR_SQL_DATA_SET_FACTORY_PAR ADD FOREIGN KEY (DSFP_DSF_ID) REFERENCES DATAGEAR_SQL_DATA_SET_FACTORY (DSF_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_SQL_DATA_SET_FACTORY_PAR ADD CONSTRAINT UK_DSFP_DSF_ID_NAME UNIQUE (DSFP_DSF_ID, DSFP_NAME);
|
||||
|
||||
--图表
|
||||
CREATE TABLE DATAGEAR_HTML_CHART_WIDGET
|
||||
(
|
||||
HCW_ID VARCHAR(50) NOT NULL,
|
||||
HCW_NAME VARCHAR(100) NOT NULL,
|
||||
HCW_PLUGIN_ID VARCHAR(100) NOT NULL,
|
||||
HCW_CREATE_USER_ID VARCHAR(50),
|
||||
HCW_CREATE_TIME TIMESTAMP,
|
||||
PRIMARY KEY (HCW_ID)
|
||||
);
|
||||
|
||||
--图表-数据集关系表
|
||||
CREATE TABLE DATAGEAR_HCW_DSF
|
||||
(
|
||||
HCW_ID VARCHAR(50) NOT NULL,
|
||||
DSF_ID VARCHAR(50) NOT NULL,
|
||||
DSF_ORDER INTEGER
|
||||
);
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD FOREIGN KEY (HCW_ID) REFERENCES DATAGEAR_HTML_CHART_WIDGET (HCW_ID) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD FOREIGN KEY (DSF_ID) REFERENCES DATAGEAR_SQL_DATA_SET_FACTORY (DSF_ID);
|
||||
|
||||
ALTER TABLE DATAGEAR_HCW_DSF ADD CONSTRAINT UK_HCW_DSF_ID UNIQUE (HCW_ID, DSF_ID);
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="org.datagear.management.domain.HtmlChartWidgetEntity">
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO DATAGEAR_HTML_CHART_WIDGET
|
||||
(
|
||||
HCW_ID, HCW_NAME, HCW_PLUGIN_ID, HCW_CREATE_USER_ID,
|
||||
HCW_CREATE_TIME
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{entity.id}, #{entity.name}, #{entity.htmlChartPlugin.id}, #{entity.createUser.id},
|
||||
#{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_HTML_CHART_WIDGET SET
|
||||
HCW_NAME = #{entity.name},
|
||||
HCW_PLUGIN_ID = #{entity.htmlChartPlugin.id}
|
||||
WHERE
|
||||
HCW_ID = #{entity.id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM DATAGEAR_HTML_CHART_WIDGET
|
||||
WHERE
|
||||
HCW_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getById" resultType="org.datagear.management.domain.HtmlChartWidgetEntity">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryViewDataPermission" />) T
|
||||
WHERE
|
||||
T.${_iq_}id${_iq_} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getDataIdPermissions" resultType="org.datagear.management.domain.DataIdPermission">
|
||||
SELECT
|
||||
T.DATA_ID as ${_iq_}dataId${_iq_},
|
||||
T.DATA_PERMISSION as ${_iq_}dataPermission${_iq_}
|
||||
FROM
|
||||
(
|
||||
<include refid="commonDataPermission.dataIdPermissionQueryViewHead" />
|
||||
<include refid="queryViewDataPermissionId" />
|
||||
<include refid="commonDataPermission.dataIdPermissionQueryViewFoot" />
|
||||
) T
|
||||
WHERE
|
||||
<foreach item="item" collection="ids" separator=" OR ">T.DATA_ID = #{item}</foreach>
|
||||
</select>
|
||||
|
||||
<select id="query" resultType="org.datagear.management.domain.HtmlChartWidgetEntity">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryViewDataPermission" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQueryCount" resultType="int">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
(<include refid="queryViewDataPermission" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQuery" resultType="org.datagear.management.domain.HtmlChartWidgetEntity">
|
||||
<include refid="common.pagingQueryHead" />
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryViewDataPermission" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
<include refid="common.pagingQueryFoot" />
|
||||
</select>
|
||||
|
||||
<delete id="deleteDataSetRelationById">
|
||||
DELETE FROM DATAGEAR_HCW_DSF
|
||||
WHERE
|
||||
HCW_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<insert id="insertDataSetRelation">
|
||||
INSERT INTO DATAGEAR_HCW_DSF
|
||||
(
|
||||
HCW_ID, DSF_ID, DSF_ORDER
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{widgetId}, #{dataSetFactoryId}, #{order}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<sql id="queryViewDataPermission">
|
||||
<choose><when test="DP_CURRENT_USER == null">
|
||||
<include refid="queryView" />
|
||||
</when><otherwise>
|
||||
SELECT
|
||||
T0.*,
|
||||
T1.DATA_PERMISSION as ${_iq_}dataPermission${_iq_}
|
||||
FROM
|
||||
(<include refid="queryView" />) T0
|
||||
INNER JOIN
|
||||
(
|
||||
<include refid="commonDataPermission.dataIdPermissionQueryViewHead" />
|
||||
<include refid="queryViewDataPermissionId" />
|
||||
<include refid="commonDataPermission.dataIdPermissionQueryViewFoot" />
|
||||
) T1
|
||||
ON
|
||||
T0.${_iq_}id${_iq_} = T1.DATA_ID
|
||||
WHERE
|
||||
T1.DATA_PERMISSION >= ${DP_MIN_READ_PERMISSION}
|
||||
</otherwise></choose>
|
||||
</sql>
|
||||
|
||||
<sql id="queryViewDataPermissionId">
|
||||
SELECT
|
||||
A.HCW_ID AS DP_AUTH_DATA_ID,
|
||||
A.HCW_CREATE_USER_ID AS DP_AUTH_DATA_CREATOR_ID
|
||||
FROM
|
||||
DATAGEAR_HTML_CHART_WIDGET A
|
||||
</sql>
|
||||
|
||||
<sql id="queryView">
|
||||
SELECT
|
||||
A.HCW_ID AS ${_iq_}id${_iq_},
|
||||
A.HCW_NAME AS ${_iq_}name${_iq_},
|
||||
A.HCW_PLUGIN_ID AS ${_iq_}htmlChartPlugin.id${_iq_},
|
||||
<include refid="common.fieldsForCreateUser" />,
|
||||
A.HCW_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_HTML_CHART_WIDGET A
|
||||
LEFT JOIN
|
||||
DATAGEAR_USER USR
|
||||
ON
|
||||
A.HCW_CREATE_USER_ID = USR.USER_ID
|
||||
</sql>
|
||||
|
||||
<sql id="queryCondition">
|
||||
1 = 1
|
||||
<if test="queryKeyword != null">
|
||||
AND
|
||||
(
|
||||
${_iq_}name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.name${_iq_} LIKE #{queryKeyword}
|
||||
OR ${_iq_}createUser.realName${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
<include refid="common.queryCondition" />
|
||||
</sql>
|
||||
</mapper>
|
|
@ -85,6 +85,21 @@
|
|||
<include refid="common.pagingQueryFoot" />
|
||||
</select>
|
||||
|
||||
<select id="findByHtmlChartWidgetEntityId" resultType="org.datagear.management.domain.SqlDataSetFactoryEntity">
|
||||
SELECT
|
||||
T0.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T0
|
||||
INNER JOIN
|
||||
DATAGEAR_HCW_DSF T1
|
||||
ON
|
||||
T0.${_iq_}id${_iq_} = T1.DSF_ID
|
||||
WHERE
|
||||
T1.HCW_ID = #{htmlChartWidgetEntityId}
|
||||
ORDER BY
|
||||
T1.DSF_ORDER ASC
|
||||
</select>
|
||||
|
||||
<sql id="queryViewDataPermission">
|
||||
<choose><when test="DP_CURRENT_USER == null">
|
||||
<include refid="queryView" />
|
||||
|
@ -122,8 +137,7 @@
|
|||
B.SCHEMA_ID AS ${_iq_}schemaConnectionFactory.schema.id${_iq_},
|
||||
B.SCHEMA_TITLE AS ${_iq_}schemaConnectionFactory.schema.title${_iq_},
|
||||
A.DSF_SQL AS ${_iq_}sql${_iq_},
|
||||
<include refid="common.fieldsForCreateUser"></include>
|
||||
A.DSF_CREATE_USER_ID AS ${_iq_}createUser.id${_iq_},
|
||||
<include refid="common.fieldsForCreateUser" />,
|
||||
A.DSF_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_SQL_DATA_SET_FACTORY A
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
|
||||
<!-- 带有createUser属性的查询字段,用于表的别名必须为:USR -->
|
||||
<sql id="fieldsForCreateUser">
|
||||
USR.USER_ID AS ${_iq_}createUser.id${_iq_},
|
||||
USR.USER_NAME AS ${_iq_}createUser.name${_iq_},
|
||||
USR.USER_REAL_NAME AS ${_iq_}createUser.realName${_iq_},
|
||||
(CASE WHEN USR.USER_IS_ADMIN IS NULL THEN '0' ELSE USR.USER_IS_ADMIN END) AS ${_iq_}createUser.admin${_iq_},
|
||||
(CASE WHEN USR.USER_ID IS NULL THEN '1' ELSE '0' END) AS ${_iq_}createUser.anonymous${_iq_},
|
||||
USR.USER_CREATE_TIME AS ${_iq_}createUser.createTime${_iq_},
|
||||
USR.USER_CREATE_TIME AS ${_iq_}createUser.createTime${_iq_}
|
||||
</sql>
|
||||
</mapper>
|
|
@ -87,6 +87,18 @@ public abstract class AbstractController
|
|||
this.classDataConverter = classDataConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain PagingQuery}。
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected PagingQuery getPagingQuery(HttpServletRequest request) throws Exception
|
||||
{
|
||||
return getPagingQuery(request, WebUtils.COOKIE_PAGINATION_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain PagingQuery}。
|
||||
*
|
||||
|
|
|
@ -0,0 +1,399 @@
|
|||
/*
|
||||
* Copyright 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package org.datagear.web.controller;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.analysis.ChartPlugin;
|
||||
import org.datagear.analysis.ChartPluginManager;
|
||||
import org.datagear.analysis.Icon;
|
||||
import org.datagear.analysis.RenderStyle;
|
||||
import org.datagear.analysis.support.html.HtmlChartPlugin;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.management.domain.HtmlChartWidgetEntity;
|
||||
import org.datagear.management.domain.SqlDataSetFactoryEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
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.util.i18n.Label;
|
||||
import org.datagear.web.OperationMessage;
|
||||
import org.datagear.web.util.WebUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 数据集控制器。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/analysis/chart")
|
||||
public class ChartController extends AbstractController
|
||||
{
|
||||
@Autowired
|
||||
private HtmlChartWidgetEntityService htmlChartWidgetEntityService;
|
||||
|
||||
@Autowired
|
||||
private ChartPluginManager chartPluginManager;
|
||||
|
||||
public ChartController()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ChartController(HtmlChartWidgetEntityService htmlChartWidgetEntityService,
|
||||
ChartPluginManager chartPluginManager)
|
||||
{
|
||||
super();
|
||||
this.htmlChartWidgetEntityService = htmlChartWidgetEntityService;
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
}
|
||||
|
||||
public HtmlChartWidgetEntityService getHtmlChartWidgetEntityService()
|
||||
{
|
||||
return htmlChartWidgetEntityService;
|
||||
}
|
||||
|
||||
public void setHtmlChartWidgetEntityService(HtmlChartWidgetEntityService htmlChartWidgetEntityService)
|
||||
{
|
||||
this.htmlChartWidgetEntityService = htmlChartWidgetEntityService;
|
||||
}
|
||||
|
||||
public ChartPluginManager getChartPluginManager()
|
||||
{
|
||||
return chartPluginManager;
|
||||
}
|
||||
|
||||
public void setChartPluginManager(ChartPluginManager chartPluginManager)
|
||||
{
|
||||
this.chartPluginManager = chartPluginManager;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
HtmlChartWidgetEntity chart = new HtmlChartWidgetEntity();
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = getAllHtmlChartPluginInfos(request);
|
||||
|
||||
if (pluginInfos.size() > 0)
|
||||
chart.setChartPlugin(pluginInfos.get(0).getChartPlugin());
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.addChart");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
|
||||
return "/analysis/chart/chart_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
HtmlChartWidgetEntity chart)
|
||||
{
|
||||
checkSaveEntity(chart);
|
||||
|
||||
chart.setId(IDUtil.uuid());
|
||||
chart.setCreateUser(WebUtils.getUser(request, response));
|
||||
chart.setSqlDataSetFactoryEntities(getSqlDataSetFactoryEntityParams(request));
|
||||
|
||||
this.htmlChartWidgetEntityService.add(chart);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id)
|
||||
{
|
||||
HtmlChartWidgetEntity chart = this.htmlChartWidgetEntityService.getById(id);
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = getAllHtmlChartPluginInfos(request);
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.editChart");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveEdit");
|
||||
|
||||
return "/analysis/chart/chart_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveEdit", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveEdit(HttpServletRequest request, HttpServletResponse response,
|
||||
HtmlChartWidgetEntity chart)
|
||||
{
|
||||
checkSaveEntity(chart);
|
||||
|
||||
chart.setSqlDataSetFactoryEntities(getSqlDataSetFactoryEntityParams(request));
|
||||
|
||||
this.htmlChartWidgetEntityService.update(chart);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id)
|
||||
{
|
||||
HtmlChartWidgetEntity chart = this.htmlChartWidgetEntityService.getById(id);
|
||||
|
||||
if (chart == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
List<HtmlChartPluginInfo> pluginInfos = getAllHtmlChartPluginInfos(request);
|
||||
|
||||
model.addAttribute("chart", chart);
|
||||
model.addAttribute("pluginInfos", pluginInfos);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.viewChart");
|
||||
model.addAttribute(KEY_READONLY, true);
|
||||
|
||||
return "/analysis/chart/chart_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> delete(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("id") String[] ids)
|
||||
{
|
||||
this.htmlChartWidgetEntityService.deleteByIds(ids);
|
||||
|
||||
return buildOperationMessageDeleteSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/pagingQuery")
|
||||
public String pagingQuery(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.manageChart");
|
||||
|
||||
return "/analysis/chart/chart_grid";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/select")
|
||||
public String select(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
|
||||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.selectChart");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
|
||||
return "/analysis/chart/chart_grid";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pagingQueryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public PagingData<HtmlChartWidgetEntity> pagingQueryData(HttpServletRequest request, HttpServletResponse response,
|
||||
final org.springframework.ui.Model springModel) throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
PagingQuery pagingQuery = getPagingQuery(request);
|
||||
|
||||
PagingData<HtmlChartWidgetEntity> pagingData = this.htmlChartWidgetEntityService.pagingQuery(user, pagingQuery);
|
||||
|
||||
return pagingData;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pluginicon/{pluginId}", produces = CONTENT_TYPE_JSON)
|
||||
public void getPluginIcon(HttpServletRequest request, HttpServletResponse response,
|
||||
@PathVariable("pluginId") String pluginId) throws Exception
|
||||
{
|
||||
ChartPlugin<?> chartPlugin = this.chartPluginManager.get(pluginId);
|
||||
|
||||
if (chartPlugin == null)
|
||||
throw new FileNotFoundException();
|
||||
|
||||
RenderStyle renderStyle = getRenderStyle(request);
|
||||
Icon icon = chartPlugin.getIcon(renderStyle);
|
||||
|
||||
if (icon == null)
|
||||
throw new FileNotFoundException();
|
||||
|
||||
response.setContentType("image/png");
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
InputStream iconIn = null;
|
||||
|
||||
try
|
||||
{
|
||||
iconIn = icon.getInputStream();
|
||||
IOUtil.write(iconIn, out);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(iconIn);
|
||||
}
|
||||
}
|
||||
|
||||
protected SqlDataSetFactoryEntity[] getSqlDataSetFactoryEntityParams(HttpServletRequest request)
|
||||
{
|
||||
String[] dataSetIds = request.getParameterValues("dataSetId");
|
||||
|
||||
if (dataSetIds == null || dataSetIds.length == 0)
|
||||
return null;
|
||||
|
||||
SqlDataSetFactoryEntity[] params = new SqlDataSetFactoryEntity[dataSetIds.length];
|
||||
|
||||
for (int i = 0; i < dataSetIds.length; i++)
|
||||
{
|
||||
SqlDataSetFactoryEntity param = new SqlDataSetFactoryEntity();
|
||||
param.setId(dataSetIds[i]);
|
||||
|
||||
params[i] = param;
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
protected void checkSaveEntity(HtmlChartWidgetEntity chart)
|
||||
{
|
||||
if (isBlank(chart.getName()))
|
||||
throw new IllegalInputException();
|
||||
|
||||
if (isEmpty(chart.getChartPlugin()))
|
||||
throw new IllegalInputException();
|
||||
}
|
||||
|
||||
protected List<HtmlChartPluginInfo> getAllHtmlChartPluginInfos(HttpServletRequest request)
|
||||
{
|
||||
List<HtmlChartPluginInfo> pluginInfos = new ArrayList<HtmlChartPluginInfo>();
|
||||
|
||||
List<ChartPlugin<HtmlRenderContext>> plugins = this.chartPluginManager.getAll(HtmlRenderContext.class);
|
||||
|
||||
if (plugins != null)
|
||||
{
|
||||
Locale locale = WebUtils.getLocale(request);
|
||||
RenderStyle renderStyle = getRenderStyle(request);
|
||||
|
||||
for (ChartPlugin<HtmlRenderContext> plugin : plugins)
|
||||
{
|
||||
if (plugin instanceof HtmlChartPlugin<?>)
|
||||
{
|
||||
HtmlChartPluginInfo pluginInfo = new HtmlChartPluginInfo();
|
||||
pluginInfo.setChartPlugin((HtmlChartPlugin<HtmlRenderContext>) plugin);
|
||||
|
||||
Label nameLabel = plugin.getNameLabel();
|
||||
if (nameLabel != null)
|
||||
pluginInfo.setName(nameLabel.getValue(locale));
|
||||
|
||||
Label descLabel = plugin.getDescLabel();
|
||||
if (descLabel != null)
|
||||
pluginInfo.setDesc(descLabel.getValue(locale));
|
||||
|
||||
Label manualLabel = plugin.getManualLabel();
|
||||
if (manualLabel != null)
|
||||
pluginInfo.setManual(manualLabel.getValue(locale));
|
||||
|
||||
Icon icon = plugin.getIcon(renderStyle);
|
||||
pluginInfo.setHasIcon(icon != null);
|
||||
|
||||
pluginInfos.add(pluginInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pluginInfos;
|
||||
}
|
||||
|
||||
protected RenderStyle getRenderStyle(HttpServletRequest request)
|
||||
{
|
||||
return RenderStyle.LIGHT;
|
||||
}
|
||||
|
||||
public static class HtmlChartPluginInfo implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private HtmlChartPlugin<HtmlRenderContext> chartPlugin;
|
||||
private String name;
|
||||
private String desc;
|
||||
private String manual;
|
||||
private boolean hasIcon;
|
||||
|
||||
public HtmlChartPluginInfo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public HtmlChartPluginInfo(HtmlChartPlugin<HtmlRenderContext> chartPlugin, String name)
|
||||
{
|
||||
super();
|
||||
this.chartPlugin = chartPlugin;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public HtmlChartPlugin<HtmlRenderContext> getChartPlugin()
|
||||
{
|
||||
return chartPlugin;
|
||||
}
|
||||
|
||||
public void setChartPlugin(HtmlChartPlugin<HtmlRenderContext> chartPlugin)
|
||||
{
|
||||
this.chartPlugin = chartPlugin;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.chartPlugin.getId();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDesc()
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc)
|
||||
{
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getManual()
|
||||
{
|
||||
return manual;
|
||||
}
|
||||
|
||||
public void setManual(String manual)
|
||||
{
|
||||
this.manual = manual;
|
||||
}
|
||||
|
||||
public boolean isHasIcon()
|
||||
{
|
||||
return hasIcon;
|
||||
}
|
||||
|
||||
public void setHasIcon(boolean hasIcon)
|
||||
{
|
||||
this.hasIcon = hasIcon;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2189,18 +2189,6 @@ public class DataController extends AbstractSchemaModelConnController
|
|||
return WebUtils.getBooleanValue(request, PARAM_IS_LOAD_PAGE_DATA, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain PagingQuery}。
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected PagingQuery getPagingQuery(HttpServletRequest request) throws Throwable
|
||||
{
|
||||
return super.getPagingQuery(request, WebUtils.COOKIE_PAGINATION_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置表格页面属性。
|
||||
*
|
||||
|
|
|
@ -145,8 +145,13 @@ public class DataSetController extends AbstractController
|
|||
@RequestMapping(value = "/select")
|
||||
public String select(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
|
||||
{
|
||||
boolean isMultipleSelect = false;
|
||||
if (request.getParameter("multiple") != null)
|
||||
isMultipleSelect = true;
|
||||
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dataSet.selectDataSet");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
model.addAttribute("isMultipleSelect", isMultipleSelect);
|
||||
|
||||
return "/analysis/dataSet/dataSet_grid";
|
||||
}
|
||||
|
|
|
@ -80,6 +80,11 @@
|
|||
</bean>
|
||||
<bean id="tempSqlpadRootDirectory" factory-bean="tempSqlpadRootDirectoryFactory" factory-method="getDirectory" />
|
||||
|
||||
<bean id="chartPluginRootDirectoryFactory" class="org.datagear.web.util.DirectoryFactory" init-method="init">
|
||||
<property name="directoryName" value="${directory.chartPlugin}" />
|
||||
</bean>
|
||||
<bean id="chartPluginRootDirectory" factory-bean="chartPluginRootDirectoryFactory" factory-method="getDirectory" />
|
||||
|
||||
<bean id="dataSource"
|
||||
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName">
|
||||
|
@ -311,6 +316,20 @@
|
|||
<property name="authorizationService" ref="authorizationService" />
|
||||
</bean>
|
||||
|
||||
<bean id="chartPluginManager" class="org.datagear.analysis.support.ConcurrentChartPluginManager" />
|
||||
|
||||
<bean class="org.datagear.analysis.support.html.LoadHtmlChartPluginBean" init-method="load">
|
||||
<property name="directory" ref="chartPluginRootDirectory" />
|
||||
<property name="chartPluginManager" ref="chartPluginManager" />
|
||||
</bean>
|
||||
|
||||
<bean id="htmlChartWidgetEntityService" class="org.datagear.management.service.impl.HtmlChartWidgetEntityServiceImpl">
|
||||
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
|
||||
<property name="chartPluginManager" ref="chartPluginManager" />
|
||||
<property name="sqlDataSetFactoryEntityService" ref="sqlDataSetFactoryEntityService" />
|
||||
<property name="authorizationService" ref="authorizationService" />
|
||||
</bean>
|
||||
|
||||
<bean id="sqlHistoryService" class="org.datagear.management.service.impl.SqlHistoryServiceImpl">
|
||||
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
|
||||
</bean>
|
||||
|
|
|
@ -23,5 +23,8 @@ directory.temp.dataExchange=${directory.temp}/dataExchange
|
|||
#SQL工作台临时文件目录
|
||||
directory.temp.sqlpad=${directory.temp}/sqlpad
|
||||
|
||||
#图表插件主目录
|
||||
directory.chartPlugin=${directory.root}/chartPlugins
|
||||
|
||||
#数据编辑界面自定义URL构建器脚本文件
|
||||
schemaUrlBuilderScriptFile=${directory.root}/db_url_builder.js
|
|
@ -612,4 +612,16 @@ dataSet.name=\u540D\u79F0
|
|||
dataSet.dataSource=\u6570\u636E\u6E90
|
||||
dataSet.sql=SQL\u8BED\u53E5
|
||||
dataSet.createUser=\u521B\u5EFA\u7528\u6237
|
||||
dataSet.createTime=\u521B\u5EFA\u65F6\u95F4
|
||||
dataSet.createTime=\u521B\u5EFA\u65F6\u95F4
|
||||
|
||||
#Chart
|
||||
chart.manageChart=\u7BA1\u7406\u56FE\u8868
|
||||
chart.addChart=\u6DFB\u52A0\u56FE\u8868
|
||||
chart.editChart=\u7F16\u8F91\u56FE\u8868
|
||||
chart.viewChart=\u67E5\u770B\u56FE\u8868
|
||||
chart.selectChart=\u9009\u62E9\u56FE\u8868
|
||||
chart.name=\u540D\u79F0
|
||||
chart.htmlChartPlugin=\u56FE\u8868\u7C7B\u578B
|
||||
chart.sqlDataSetFactoryEntities=\u6570\u636E\u96C6
|
||||
chart.createUser=\u521B\u5EFA\u7528\u6237
|
||||
chart.createTime=\u521B\u5EFA\u65F6\u95F4
|
|
@ -0,0 +1,194 @@
|
|||
<#include "../../include/import_global.ftl">
|
||||
<#include "../../include/html_doctype.ftl">
|
||||
<#--
|
||||
titleMessageKey 标题标签I18N关键字,不允许null
|
||||
formAction 表单提交action,允许为null
|
||||
readonly 是否只读操作,允许为null
|
||||
-->
|
||||
<#assign formAction=(formAction!'#')>
|
||||
<#assign readonly=(readonly!false)>
|
||||
<#assign isAdd=(formAction == 'saveAdd')>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../../include/html_head.ftl">
|
||||
<title><#include "../../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /></title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="${pageId}" class="page-form page-form-chart">
|
||||
<form id="${pageId}-form" action="${contextPath}/analysis/chart/${formAction}" method="POST">
|
||||
<div class="form-head"></div>
|
||||
<div class="form-content">
|
||||
<input type="hidden" name="id" value="${(chart.id)!''?html}" />
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='chart.name' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="name" value="${(chart.name)!''?html}" class="ui-widget ui-widget-content" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='chart.htmlChartPlugin' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<ul class="chart-plugin-list ui-widget ui-helper-clearfix">
|
||||
<#list pluginInfos as pi>
|
||||
<li class="ui-state-default ui-corner-all" chart-plugin-id="${pi.id?html}" title="${pi.name?html}">
|
||||
<#if pi.hasIcon>
|
||||
<a class="plugin-icon" style="background-image: url(${contextPath}/analysis/chart/pluginicon/${pi.id?html})"> </a>
|
||||
<#else>
|
||||
<a class="plugin-name">${pi.name?html}</a>
|
||||
</#if>
|
||||
</li>
|
||||
</#list>
|
||||
</ul>
|
||||
<input type="hidden" name="htmlChartPlugin.id" class="ui-widget ui-widget-content" value="${(chart.htmlChartPlugin.id)!''?html}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='chart.sqlDataSetFactoryEntities' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="data-set-wrapper ui-widget ui-widget-content ui-corner-all">
|
||||
<#if (chart.sqlDataSetFactoryEntities)??>
|
||||
<#list chart.sqlDataSetFactoryEntities as ds>
|
||||
<div class='data-set-item ui-widget ui-widget-content ui-corner-all ui-state-default'>
|
||||
<input type='hidden' name='dataSetId' value="${ds.id?html}" />
|
||||
<span class='data-set-name'>${ds.name?html}</span>
|
||||
<#if !readonly>
|
||||
<div class='delete-icon'><span class=' ui-icon ui-icon-close'> </span></div>
|
||||
</#if>
|
||||
</div>
|
||||
</#list>
|
||||
</#if>
|
||||
</div>
|
||||
<#if !readonly>
|
||||
<button type="button" class="add-data-set-button"><@spring.message code='add' /></button>
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-foot" style="text-align:center;">
|
||||
<#if !readonly>
|
||||
<input type="submit" value="<@spring.message code='save' />" class="recommended" />
|
||||
|
||||
<input type="reset" value="<@spring.message code='reset' />" />
|
||||
</#if>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<#include "../../include/page_js_obj.ftl" >
|
||||
<#include "../../include/page_obj_form.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element());
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/analysis/chart/" + action;
|
||||
};
|
||||
|
||||
var currentPluginId = po.element("input[name='htmlChartPlugin.id']").val();
|
||||
|
||||
po.element(".chart-plugin-list li")
|
||||
.hover(function(){ $(this).addClass("ui-state-hover"); },
|
||||
function(){ $(this).removeClass("ui-state-hover"); })
|
||||
.click(function()
|
||||
{
|
||||
<#if !readonly>
|
||||
var $this = $(this);
|
||||
|
||||
po.element("input[name='htmlChartPlugin.id']").val($this.attr("chart-plugin-id"));
|
||||
|
||||
po.element(".chart-plugin-list li").removeClass("ui-state-active");
|
||||
$this.addClass("ui-state-active");
|
||||
</#if>
|
||||
})
|
||||
.each(function()
|
||||
{
|
||||
var $this = $(this);
|
||||
|
||||
var myPluginId = $this.attr("chart-plugin-id");
|
||||
if(myPluginId == currentPluginId)
|
||||
$this.addClass("ui-state-active");
|
||||
});
|
||||
|
||||
|
||||
<#if !readonly>
|
||||
po.element(".add-data-set-button").click(function()
|
||||
{
|
||||
var options =
|
||||
{
|
||||
pageParam :
|
||||
{
|
||||
submit : function(dataSets)
|
||||
{
|
||||
po.addDataSet(dataSets);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.setGridPageHeightOption(options);
|
||||
|
||||
po.open("${contextPath}/analysis/dataSet/select?multiple", options);
|
||||
});
|
||||
|
||||
po.addDataSet = function(dataSets)
|
||||
{
|
||||
if(!dataSets)
|
||||
return;
|
||||
|
||||
var $wrapper = po.element(".data-set-wrapper");
|
||||
|
||||
for(var i=0; i<dataSets.length; i++)
|
||||
{
|
||||
var dataSet = dataSets[i];
|
||||
|
||||
var $item = $("<div class='data-set-item ui-widget ui-widget-content ui-corner-all ui-state-default' />").appendTo($wrapper);
|
||||
$("<input type='hidden' name='dataSetId'>").attr("value", dataSet.id).appendTo($item);
|
||||
$("<span class='data-set-name' />").text(dataSet.name).appendTo($item);
|
||||
$("<div class='delete-icon'><span class=' ui-icon ui-icon-close'> </span></div>").appendTo($item);
|
||||
}
|
||||
}
|
||||
|
||||
po.element(".data-set-wrapper").on("click", ".delete-icon", function(){ $(this).parent().remove(); });
|
||||
|
||||
po.element(".data-set-wrapper").sortable();
|
||||
|
||||
po.form().validate(
|
||||
{
|
||||
rules :
|
||||
{
|
||||
"name" : "required"
|
||||
},
|
||||
messages :
|
||||
{
|
||||
"name" : "<@spring.message code='validation.required' />"
|
||||
},
|
||||
submitHandler : function(form)
|
||||
{
|
||||
$(form).ajaxSubmit(
|
||||
{
|
||||
success : function()
|
||||
{
|
||||
var close = (po.pageParamCall("afterSave") != false);
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
errorPlacement : function(error, element)
|
||||
{
|
||||
error.appendTo(element.closest(".form-item-value"));
|
||||
}
|
||||
});
|
||||
</#if>
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,165 @@
|
|||
<#include "../../include/import_global.ftl">
|
||||
<#include "../../include/html_doctype.ftl">
|
||||
<#--
|
||||
titleMessageKey 标题标签I18N关键字,不允许null
|
||||
selectonly 是否选择操作,允许为null
|
||||
-->
|
||||
<#assign selectonly=(selectonly!false)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../../include/html_head.ftl">
|
||||
<title><#include "../../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /></title>
|
||||
</head>
|
||||
<body class="fill-parent">
|
||||
<#if !isAjaxRequest>
|
||||
<div class="fill-parent">
|
||||
</#if>
|
||||
<div id="${pageId}" class="page-grid page-grid-chart">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<#include "../../include/page_obj_searchform.html.ftl">
|
||||
</div>
|
||||
<div class="operation">
|
||||
<#if selectonly>
|
||||
<input name="confirmButton" type="button" class="recommended" value="<@spring.message code='confirm' />" />
|
||||
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
|
||||
<#else>
|
||||
<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="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<table id="${pageId}-table" width="100%" class="hover stripe">
|
||||
</table>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<div class="pagination-wrapper">
|
||||
<div id="${pageId}-pagination" class="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<#if !isAjaxRequest>
|
||||
</div>
|
||||
</#if>
|
||||
<#include "../../include/page_js_obj.ftl">
|
||||
<#include "../../include/page_obj_searchform_js.ftl">
|
||||
<#include "../../include/page_obj_pagination.ftl">
|
||||
<#include "../../include/page_obj_grid.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element(".operation"));
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/analysis/chart/" + action;
|
||||
};
|
||||
|
||||
<#if !selectonly>
|
||||
po.element("input[name=addButton]").click(function()
|
||||
{
|
||||
po.open(po.url("add"),
|
||||
{
|
||||
pageParam :
|
||||
{
|
||||
afterSave : function()
|
||||
{
|
||||
po.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=editButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"),
|
||||
{
|
||||
data : data,
|
||||
pageParam :
|
||||
{
|
||||
afterSave : function()
|
||||
{
|
||||
po.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</#if>
|
||||
|
||||
po.element("input[name=viewButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
data : data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
<#if !selectonly>
|
||||
po.element("input[name=deleteButton]").click(
|
||||
function()
|
||||
{
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
po.confirm("<@spring.message code='confirmDelete' />",
|
||||
{
|
||||
"confirm" : function()
|
||||
{
|
||||
var data = $.getPropertyParamString(rows, "id");
|
||||
|
||||
$.post(po.url("delete"), data, function()
|
||||
{
|
||||
po.refresh();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</#if>
|
||||
|
||||
<#if selectonly>
|
||||
po.element("input[name=confirmButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var close = po.pageParamCall("submit", row);
|
||||
|
||||
//单选默认关闭
|
||||
if(close == undefined)
|
||||
close = true;
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
});
|
||||
});
|
||||
</#if>
|
||||
|
||||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chart.name' />"), "name"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.htmlChartPlugin' />", "htmlChartPlugin.id"),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='chart.createUser' />"), "createUser.realName"),
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='chart.createTime' />", "createUser.createTime")
|
||||
];
|
||||
|
||||
po.initPagination();
|
||||
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("pagingQueryData"));
|
||||
po.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -5,6 +5,7 @@ titleMessageKey 标题标签I18N关键字,不允许null
|
|||
selectonly 是否选择操作,允许为null
|
||||
-->
|
||||
<#assign selectonly=(selectonly!false)>
|
||||
<#assign isMultipleSelect=(isMultipleSelect!false)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../../include/html_head.ftl">
|
||||
|
@ -132,6 +133,19 @@ selectonly 是否选择操作,允许为null
|
|||
<#if selectonly>
|
||||
po.element("input[name=confirmButton]").click(function()
|
||||
{
|
||||
<#if isMultipleSelect>
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
var close = po.pageParamCall("submit", rows);
|
||||
|
||||
//单选默认关闭
|
||||
if(close == undefined)
|
||||
close = true;
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
});
|
||||
<#else>
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var close = po.pageParamCall("submit", row);
|
||||
|
@ -143,6 +157,7 @@ selectonly 是否选择操作,允许为null
|
|||
if(close)
|
||||
po.close();
|
||||
});
|
||||
</#if>
|
||||
});
|
||||
</#if>
|
||||
|
||||
|
|
|
@ -982,10 +982,12 @@
|
|||
else if($node.hasClass("item-chart"))
|
||||
{
|
||||
tabId += "chart";
|
||||
tabUrl += "chart/pagingQuery";
|
||||
}
|
||||
else if($node.hasClass("item-dashboard"))
|
||||
{
|
||||
tabId += "dashboard";
|
||||
tabUrl += "dashboard/pagingQuery";
|
||||
}
|
||||
|
||||
po.activeWorkTab(po.toMainTabId(tabId), tabName, "", tabUrl);
|
||||
|
|
|
@ -1921,4 +1921,54 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
.page-dataexchange-log .dataexchange-log-content{
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
.page-form-chart .chart-plugin-list{
|
||||
margin: 0 0;
|
||||
padding: 0 0;
|
||||
}
|
||||
.page-form-chart .chart-plugin-list > li{
|
||||
margin: 5px;
|
||||
position: relative;
|
||||
padding: 2px 2px;
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
list-style: none;
|
||||
}
|
||||
.page-form-chart .chart-plugin-list > li:first-child{
|
||||
margin-left: 0px;
|
||||
}
|
||||
.page-form-chart .chart-plugin-list > li a{
|
||||
display: inline-block;
|
||||
margin: 5px 5px;
|
||||
height: 20px;
|
||||
}
|
||||
.page-form-chart .chart-plugin-list > li a.plugin-icon{
|
||||
width: 20px;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.page-form-chart .chart-plugin-list > li a.plugin-name{
|
||||
margin: 5px 0.8em;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper{
|
||||
display: inline-block;
|
||||
width: 50%;
|
||||
height: 10em;
|
||||
padding: 0.3em 0.2em;
|
||||
overflow: auto;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item{
|
||||
padding: 0.3em 0.3em;
|
||||
margin-top: 0.3em;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item:first-child{
|
||||
margin-top: 0;
|
||||
}
|
||||
.page-form-chart .data-set-wrapper .data-set-item .delete-icon{
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
.page-form-chart .add-data-set-button{
|
||||
vertical-align: top;
|
||||
}
|
Loading…
Reference in New Issue