添加数据集、图表、看板分享功能

This commit is contained in:
datagear 2020-02-04 00:00:45 +08:00
parent d189473706
commit b1d4f82a4e
29 changed files with 1045 additions and 345 deletions

View File

@ -41,6 +41,8 @@ public class Schema extends AbstractStringIdEntity
/*------------------------------------------------------*/
public static final String PROPERTY_TITLE = "title";
/** 标题 */
private String title;

View File

@ -44,9 +44,9 @@ public interface AuthorizationService extends DataPermissionEntityService<String
* 查询指定资源的{@linkplain Authorization}
*
* @param user
* @param appointResource
* @param assignedResource
* @param query
* @return
*/
List<Authorization> queryForAppointResource(User user, String appointResource, Query query);
List<Authorization> queryForAssignedResource(User user, String assignedResource, Query query);
}

View File

@ -44,6 +44,15 @@ public interface DataPermissionEntityService<ID, T extends DataPermissionEntity<
/** 数据权限参数:未设置任何权限时的默认权限值 */
String DATA_PERMISSION_PARAM_UNSET_PERMISSION = "DP_UNSET_PERMISSION";
/** 查询过滤值:我的 */
String DATA_FILTER_VALUE_MINE = "mine";
/** 查询过滤值:其他人的 */
String DATA_FILTER_VALUE_OTHER = "other";
/** 查询过滤值:全部 */
String DATA_FILTER_VALUE_ALL = "all";
/**
* 获取数据权限资源类型
*
@ -167,4 +176,14 @@ public interface DataPermissionEntityService<ID, T extends DataPermissionEntity<
* @return
*/
PagingData<T> pagingQuery(User user, PagingQuery pagingQuery);
/**
* 授权分页查询
*
* @param user 操作用户
* @param pagingQuery
* @param dataFilter
* @return
*/
PagingData<T> pagingQuery(User user, PagingQuery pagingQuery, String dataFilter);
}

View File

@ -19,6 +19,7 @@ import org.datagear.management.service.PermissionDeniedException;
import org.datagear.persistence.PagingData;
import org.datagear.persistence.PagingQuery;
import org.datagear.persistence.Query;
import org.datagear.util.StringUtil;
import org.mybatis.spring.SqlSessionTemplate;
/**
@ -168,10 +169,19 @@ public abstract class AbstractMybatisDataPermissionEntityService<ID, T extends D
@Override
public PagingData<T> pagingQuery(User user, PagingQuery pagingQuery)
{
return pagingQuery(user, pagingQuery, null);
}
@Override
public PagingData<T> pagingQuery(User user, PagingQuery pagingQuery, String dataFilter)
{
Map<String, Object> params = buildParamMap();
addDataPermissionParameters(params, user);
if (!StringUtil.isEmpty(dataFilter))
params.put("_dataFilter", dataFilter);
return pagingQuery(pagingQuery, params);
}

View File

@ -128,11 +128,11 @@ public class AuthorizationServiceImpl extends AbstractMybatisDataPermissionEntit
}
@Override
public List<Authorization> queryForAppointResource(User user, String appointResource, Query query)
public List<Authorization> queryForAssignedResource(User user, String assignedResource, Query query)
{
Map<String, Object> params = buildParamMap();
addDataPermissionParameters(params, user);
params.put("appointResource", appointResource);
params.put("assignedResource", assignedResource);
return query(query, params);
}

View File

@ -14,7 +14,6 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.datagear.analysis.support.html.HtmlRenderContext;
import org.datagear.analysis.support.html.HtmlTplDashboardWidgetFmkRenderer;
import org.datagear.analysis.support.html.HtmlTplDashboardWidgetRenderer;
import org.datagear.management.domain.HtmlChartWidgetEntity;
import org.datagear.management.domain.HtmlTplDashboardWidgetEntity;
import org.datagear.management.domain.User;
import org.datagear.management.service.AuthorizationService;
@ -99,7 +98,7 @@ public class HtmlTplDashboardWidgetEntityServiceImpl
@Override
public String getResourceType()
{
return HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE;
return HtmlTplDashboardWidgetEntity.AUTHORIZATION_RESOURCE_TYPE;
}
@Override
@ -131,7 +130,7 @@ public class HtmlTplDashboardWidgetEntityServiceImpl
if (deleted)
{
this.authorizationService.deleteByResource(HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE, id);
this.authorizationService.deleteByResource(HtmlTplDashboardWidgetEntity.AUTHORIZATION_RESOURCE_TYPE, id);
this.htmlTplDashboardWidgetRenderer.getTemplateDashboardWidgetResManager().delete(id);
}

View File

@ -240,15 +240,19 @@
<sql id="queryCondition">
1 = 1
<if test="queryKeyword != null">
AND
(
${_iq_}resourceName${_iq_} LIKE #{queryKeyword} OR ${_iq_}principalName${_iq_} LIKE #{queryKeyword}
)
</if>
<if test="appointResource != null">
AND ${_iq_}resource${_iq_} = #{appointResource} AND ${_iq_}resourceType${_iq_} NOT LIKE '%_PATTERN'
</if>
<choose><when test="assignedResource != null">
AND ${_iq_}resource${_iq_} = #{assignedResource} AND ${_iq_}resourceType${_iq_} NOT LIKE '%_PATTERN'
<if test="queryKeyword != null">
AND ${_iq_}principalName${_iq_} LIKE #{queryKeyword}
</if>
</when><otherwise>
<if test="queryKeyword != null">
AND
(
${_iq_}resourceName${_iq_} LIKE #{queryKeyword} OR ${_iq_}principalName${_iq_} LIKE #{queryKeyword}
)
</if>
</otherwise></choose>
<include refid="common.queryCondition" />
</sql>
</mapper>

View File

@ -168,6 +168,7 @@
${_iq_}name${_iq_} LIKE #{queryKeyword}
)
</if>
<include refid="commonDataPermission.dataFilterCondition" />
<include refid="common.queryCondition" />
</sql>
</mapper>

View File

@ -156,6 +156,7 @@
${_iq_}name${_iq_} LIKE #{queryKeyword}
)
</if>
<include refid="commonDataPermission.dataFilterCondition" />
<include refid="common.queryCondition" />
</sql>
</mapper>

View File

@ -240,6 +240,7 @@
${_iq_}name${_iq_} LIKE #{queryKeyword}
)
</if>
<include refid="commonDataPermission.dataFilterCondition" />
<include refid="common.queryCondition" />
</sql>
</mapper>

View File

@ -162,4 +162,16 @@
)
</sql>
<sql id="dataFilterCondition">
<if test="_dataFilter != null and DP_CURRENT_USER != null">
<choose><when test="_dataFilter == 'mine'">
AND ${_iq_}createUser.id${_iq_} = #{DP_CURRENT_USER.id}
</when><when test="_dataFilter == 'other'">
AND ${_iq_}createUser.id${_iq_} != #{DP_CURRENT_USER.id}
</when><when test="_dataFilter == 'all'">
</when>
</choose>
</if>
</sql>
</mapper>

View File

@ -6,6 +6,8 @@ package org.datagear.persistence;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* 查询
@ -30,6 +32,9 @@ public class Query implements Serializable
/** 排序方式 */
private Order[] orders;
/** 查询参数 */
private Map<String, Object> params = new HashMap<String, Object>();
public Query()
{
}
@ -101,6 +106,16 @@ public class Query implements Serializable
this.orders = orders;
}
public Map<String, Object> getParams()
{
return params;
}
public void setParam(String name, Object value)
{
this.params.put(name, value);
}
@Override
public String toString()
{

View File

@ -11,6 +11,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.datagear.management.service.DataPermissionEntityService;
import org.datagear.persistence.Order;
import org.datagear.persistence.Paging;
import org.datagear.persistence.PagingQuery;
@ -51,7 +52,11 @@ public abstract class AbstractController
public static final String KEY_SELECTONLY = "selectonly";
protected static final String ERROR_PAGE_URL = "/error";
public static final String DATA_FILTER_PARAM = "dataFilter";
public static final String DATA_FILTER_COOKIE = "DATA_FILTER_SEARCH";
public static final String ERROR_PAGE_URL = "/error";
@Autowired
private MessageSource messageSource;
@ -91,6 +96,31 @@ public abstract class AbstractController
this.classDataConverter = classDataConverter;
}
/**
* 获取数据查询过滤值
*
* @param request
* @return
*/
protected String getDataFilterValue(HttpServletRequest request)
{
String value = request.getParameter(DATA_FILTER_PARAM);
if (isEmpty(value))
value = WebUtils.getCookieValue(request, DATA_FILTER_COOKIE);
if (DataPermissionEntityService.DATA_FILTER_VALUE_MINE.equalsIgnoreCase(value))
value = DataPermissionEntityService.DATA_FILTER_VALUE_MINE;
else if (DataPermissionEntityService.DATA_FILTER_VALUE_OTHER.equalsIgnoreCase(value))
value = DataPermissionEntityService.DATA_FILTER_VALUE_OTHER;
else if (DataPermissionEntityService.DATA_FILTER_VALUE_ALL.equalsIgnoreCase(value))
value = DataPermissionEntityService.DATA_FILTER_VALUE_ALL;
else
value = DataPermissionEntityService.DATA_FILTER_VALUE_MINE;
return value;
}
/**
* 获取当前请求的{@linkplain WebContextPath}
*

View File

@ -16,6 +16,7 @@ import org.datagear.management.service.impl.AuthorizationQueryContext;
import org.datagear.management.service.impl.EnumValueLabel;
import org.datagear.persistence.PagingQuery;
import org.datagear.util.IDUtil;
import org.datagear.util.StringUtil;
import org.datagear.web.OperationMessage;
import org.datagear.web.controller.AuthorizationResourceMetas.PermissionMeta;
import org.datagear.web.controller.AuthorizationResourceMetas.ResourceMeta;
@ -41,7 +42,7 @@ public class AuthorizationController extends AbstractController
/**
* 指定授权资源参数设置后所有CRUD操作都只针对这一个资源
*/
public static final String PARAM_APPOINT_RESOURCE = "appointResource";
public static final String PARAM_ASSIGNED_RESOURCE = "assignedResource";
@Autowired
private AuthorizationService authorizationService;
@ -73,10 +74,10 @@ public class AuthorizationController extends AbstractController
{
User user = WebUtils.getUser(request, response);
setResourceMetaAttribute(model, resourceType);
setAppoiontResourceAttributeIf(request, model);
ResourceMeta resourceMeta = setResourceMetaAttribute(model, resourceType);
setAssignedResourceAttributeIf(request, model, resourceMeta);
model.addAttribute("user", user);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "authorization.addAuthorization");
model.addAttribute(KEY_TITLE_MESSAGE_KEY, resourceMeta.getAuthAddAuthorizationLabel());
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
return "/authorization/authorization_form";
@ -112,10 +113,10 @@ public class AuthorizationController extends AbstractController
Authorization authorization = this.authorizationService.getByIdForEdit(user, id);
setAppoiontResourceAttributeIf(request, model);
setAssignedResourceAttributeIf(request, model, resourceMeta);
model.addAttribute("authorization", authorization);
model.addAttribute("user", user);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "authorization.editAuthorization");
model.addAttribute(KEY_TITLE_MESSAGE_KEY, resourceMeta.getAuthEditAuthorizationLabel());
model.addAttribute(KEY_FORM_ACTION, "saveEdit");
return "/authorization/authorization_form";
@ -154,9 +155,9 @@ public class AuthorizationController extends AbstractController
if (authorization == null)
throw new RecordNotFoundException();
setAppoiontResourceAttributeIf(request, model);
setAssignedResourceAttributeIf(request, model, resourceMeta);
model.addAttribute("authorization", authorization);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "authorization.viewAuthorization");
model.addAttribute(KEY_TITLE_MESSAGE_KEY, resourceMeta.getAuthViewAuthorizationLabel());
model.addAttribute(KEY_READONLY, true);
return "/authorization/authorization_form";
@ -178,9 +179,9 @@ public class AuthorizationController extends AbstractController
public String query(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
@PathVariable("resourceType") String resourceType)
{
setResourceMetaAttribute(model, resourceType);
setAppoiontResourceAttributeIf(request, model);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "authorization.manageAuthorization");
ResourceMeta resourceMeta = setResourceMetaAttribute(model, resourceType);
setAssignedResourceAttributeIf(request, model, resourceMeta);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, resourceMeta.getAuthManageAuthorizationLabel());
return "/authorization/authorization_grid";
}
@ -194,26 +195,30 @@ public class AuthorizationController extends AbstractController
ResourceMeta resourceMeta = setResourceMetaAttribute(model, resourceType);
setAuthorizationQueryContext(request, resourceMeta);
String appointResource = getAppoiontResource(request);
String assignedResource = getAssignedResource(request);
PagingQuery pagingQuery = getPagingQuery(request, null);
List<Authorization> authorizations = null;
if (!isEmpty(appointResource))
authorizations = this.authorizationService.queryForAppointResource(user, appointResource, pagingQuery);
if (!isEmpty(assignedResource))
authorizations = this.authorizationService.queryForAssignedResource(user, assignedResource, pagingQuery);
else
authorizations = this.authorizationService.query(user, pagingQuery);
return authorizations;
}
protected void setAppoiontResourceAttributeIf(HttpServletRequest request, org.springframework.ui.Model model)
protected void setAssignedResourceAttributeIf(HttpServletRequest request, org.springframework.ui.Model model,
ResourceMeta resourceMeta)
{
String ap = getAppoiontResource(request);
String ap = getAssignedResource(request);
if (ap != null)
model.addAttribute("appointResource", ap);
if (resourceMeta.mustAssignResource() && StringUtil.isEmpty(ap))
throw new IllegalInputException();
if (!StringUtil.isEmpty(ap))
model.addAttribute("assignedResource", ap);
}
protected ResourceMeta setResourceMetaAttribute(org.springframework.ui.Model model, String resourceType)
@ -228,9 +233,9 @@ public class AuthorizationController extends AbstractController
return resourceMeta;
}
protected String getAppoiontResource(HttpServletRequest request)
protected String getAssignedResource(HttpServletRequest request)
{
return request.getParameter(PARAM_APPOINT_RESOURCE);
return request.getParameter(PARAM_ASSIGNED_RESOURCE);
}
protected void setAuthorizationQueryContext(HttpServletRequest request, ResourceMeta resourceMeta)
@ -248,7 +253,7 @@ public class AuthorizationController extends AbstractController
PermissionMeta permissionMeta = permissionMetas[i];
permissionLabels[i] = new EnumValueLabel<Integer>(permissionMeta.getPermission(),
getMessage(request, permissionMeta.getPermissionLabelKey()));
getMessage(request, permissionMeta.getPermissionLabel()));
}
context.setPermissionLabels(permissionLabels);

View File

@ -22,8 +22,6 @@ import org.datagear.management.domain.Schema;
*/
public class AuthorizationResourceMetas
{
public static final String LABEL_KEY_PREFIX = "authorization.resourceMeta.";
private static final ConcurrentMap<String, ResourceMeta> RESOURCEMETA_MAP = new ConcurrentHashMap<String, ResourceMeta>();
/**
@ -36,6 +34,31 @@ public class AuthorizationResourceMetas
RESOURCEMETA_MAP.put(resourceMeta.getResourceType(), resourceMeta);
}
/**
* 注册用于支持分享功能的{@linkplain ResourceMeta}
*
* @param resourceType
* @param labelKeyPrefix
*/
public static void registerForShare(String resourceType, String labelKeyPrefix)
{
PermissionMeta read = PermissionMeta.valueOfRead();
ResourceMeta resourceMeta = new ResourceMeta(resourceType, labelKeyPrefix, PermissionMeta.valuesOf(read));
resourceMeta.updateResouceTypeLabel();
resourceMeta.setSupportSelectResource(false);
resourceMeta.setSupportPatternResource(false);
resourceMeta.setEnableSetEnable(false);
resourceMeta.setAuthManageAuthorizationLabel("authorization.default.share.manageAuthorization");
resourceMeta.setAuthAddAuthorizationLabel("authorization.default.share.addAuthorization");
resourceMeta.setAuthEditAuthorizationLabel("authorization.default.share.editAuthorization");
resourceMeta.setAuthViewAuthorizationLabel("authorization.default.share.viewAuthorization");
resourceMeta.setAuthPrincipalTypeLabel("authorization.default.share.principalType");
resourceMeta.setAuthPrincipalLabel("authorization.default.share.principal");
register(resourceMeta);
}
/**
* 获取{@linkplain ResourceMeta}
* <p>
@ -54,11 +77,29 @@ public class AuthorizationResourceMetas
{
// 数据源授权资源元信息
{
ResourceMeta resourceMeta = ResourceMeta.valueOf(Schema.AUTHORIZATION_RESOURCE_TYPE, "/schema/select", "id",
"title", true,
PermissionMeta.valuesOf(Schema.AUTHORIZATION_RESOURCE_TYPE, Schema.PERMISSION_TABLE_DATA_READ,
Schema.PERMISSION_TABLE_DATA_EDIT, Schema.PERMISSION_TABLE_DATA_DELETE,
Authorization.PERMISSION_NONE_START, true));
PermissionMeta read = PermissionMeta.valueOfRead(Schema.PERMISSION_TABLE_DATA_READ);
read.setPermissionLabelDesc(ResourceMeta.buildLabelKey("schema", "permission.read.desc"));
PermissionMeta edit = PermissionMeta.valueOfEdit(Schema.PERMISSION_TABLE_DATA_EDIT);
edit.setPermissionLabelDesc(ResourceMeta.buildLabelKey("schema", "permission.edit.desc"));
PermissionMeta delete = PermissionMeta.valueOfDelete(Schema.PERMISSION_TABLE_DATA_DELETE);
delete.setPermissionLabelDesc(ResourceMeta.buildLabelKey("schema", "permission.delete.desc"));
PermissionMeta none = PermissionMeta.valueOfNone();
none.setPermissionLabelDesc(ResourceMeta.buildLabelKey("schema", "permission.none.desc"));
ResourceMeta resourceMeta = new ResourceMeta(Schema.AUTHORIZATION_RESOURCE_TYPE, "schema",
PermissionMeta.valuesOf(read, edit, delete, none));
resourceMeta.updateResouceTypeLabel();
resourceMeta.setSupportSelectResource(true);
resourceMeta.setSelectResourceURL("/schema/select");
resourceMeta.setSelectResourceIdField(Schema.ID_PROP_NAME);
resourceMeta.setSelectResourceNameField(Schema.PROPERTY_TITLE);
resourceMeta.updateAuthModeSelectResourceLabel();
resourceMeta.setSupportPatternResource(true);
resourceMeta.updateAuthModePatternResourceLabel();
resourceMeta.updateAuthModePatternResourceLabelDesc();
register(resourceMeta);
}
@ -79,42 +120,80 @@ public class AuthorizationResourceMetas
{
private static final long serialVersionUID = 1L;
/** 资源类型 */
private String resourceType;
private String resouceTypeLabelKey;
private String selectResourceURL;
private String selectResourceIdField;
private String selectResourceNameField;
/** 标签I18N关键字前缀 */
private String labelKeyPrefix;
/** 资源权限元信息 */
private PermissionMeta[] permissionMetas;
private boolean supportPattern = false;
/** 资源类型标签I18N关键字 */
private String resouceTypeLabel = "authorization.default.resouceTypeLabel";
private String selectResourceLabelKey;
/** 是否支持选择资源授权 */
private boolean supportSelectResource = false;
private String selectResourceLabelDescKey;
/** supportSelectResource=true时必须选择资源URL */
private String selectResourceURL = "";
private String fillPatternLabelKey;
/** supportSelectResource=true时必须选择资源的ID字段名 */
private String selectResourceIdField = "";
private String fillPatternLabelDescKey;
/** supportSelectResource=true时必须选择资源的名称字段名 */
private String selectResourceNameField = "";
/** 是否支持模式匹配授权 */
private boolean supportPatternResource = false;
/** 可选,授权模式-选择资源选项卡标签名I18N关键字 */
private String authModeSelectResourceLabel = "authorization.default.authModeSelectResourceLabel";
/** 可选,授权模式-选择资源选项卡标签描述I18N关键字 */
private String authModeSelectResourceLabelDesc = "authorization.default.authModeSelectResourceLabelDesc";
/** 可选,授权模式-模式输入选项卡标签I18N关键字 */
private String authModePatternResourceLabel = "authorization.default.authModePatternResourceLabel";
/** 可选,授权模式-模式输入选项卡标签描述I18N关键字 */
private String authModePatternResourceLabelDesc = "authorization.default.authModePatternResourceLabelDesc";
/** 是否开启设置启用/禁用功能 */
private boolean enableSetEnable = true;
private String authManageAuthorizationLabel = "authorization.manageAuthorization";
private String authAddAuthorizationLabel = "authorization.addAuthorization";
private String authEditAuthorizationLabel = "authorization.editAuthorization";
private String authViewAuthorizationLabel = "authorization.viewAuthorization";
private String authResourceLabel = "authorization.resource";
private String authResourceTypeLabel = "authorization.resourceType";
private String authPrincipalLabel = "authorization.principal";
private String authPrincipalTypeLabel = "authorization.principalType";
private String authPermissionLabel = "authorization.permission";
private String authEnabledLabel = "authorization.enabled";
private String authCreateUserLabel = "authorization.createUser";
public ResourceMeta()
{
super();
}
public ResourceMeta(String resourceType, String resouceTypeLabelKey, String selectResourceURL,
String selectResourceIdField, String selectResourceNameField, PermissionMeta... permissionMetas)
public ResourceMeta(String resourceType, String labelKeyPrefix, PermissionMeta... permissionMetas)
{
super();
this.resourceType = resourceType;
this.resouceTypeLabelKey = resouceTypeLabelKey;
this.selectResourceURL = selectResourceURL;
this.selectResourceIdField = selectResourceIdField;
this.selectResourceNameField = selectResourceNameField;
this.labelKeyPrefix = labelKeyPrefix;
this.permissionMetas = permissionMetas;
}
@ -128,14 +207,44 @@ public class AuthorizationResourceMetas
this.resourceType = resourceType;
}
public String getResouceTypeLabelKey()
public String getLabelKeyPrefix()
{
return resouceTypeLabelKey;
return labelKeyPrefix;
}
public void setResouceTypeLabelKey(String resouceTypeLabelKey)
public void setLabelKeyPrefix(String labelKeyPrefix)
{
this.resouceTypeLabelKey = resouceTypeLabelKey;
this.labelKeyPrefix = labelKeyPrefix;
}
public PermissionMeta[] getPermissionMetas()
{
return permissionMetas;
}
public void setPermissionMetas(PermissionMeta[] permissionMetas)
{
this.permissionMetas = permissionMetas;
}
public String getResouceTypeLabel()
{
return resouceTypeLabel;
}
public void setResouceTypeLabel(String resouceTypeLabel)
{
this.resouceTypeLabel = resouceTypeLabel;
}
public boolean isSupportSelectResource()
{
return supportSelectResource;
}
public void setSupportSelectResource(boolean supportSelectResource)
{
this.supportSelectResource = supportSelectResource;
}
public String getSelectResourceURL()
@ -168,88 +277,289 @@ public class AuthorizationResourceMetas
this.selectResourceNameField = selectResourceNameField;
}
public PermissionMeta[] getPermissionMetas()
public String getAuthModeSelectResourceLabel()
{
return permissionMetas;
return authModeSelectResourceLabel;
}
public void setPermissionMetas(PermissionMeta... permissionMetas)
public void setAuthModeSelectResourceLabel(String authModeSelectResourceLabel)
{
this.permissionMetas = permissionMetas;
this.authModeSelectResourceLabel = authModeSelectResourceLabel;
}
public boolean isSupportPattern()
public String getAuthModeSelectResourceLabelDesc()
{
return supportPattern;
return authModeSelectResourceLabelDesc;
}
public void setSupportPattern(boolean supportPattern)
public void setAuthModeSelectResourceLabelDesc(String authModeSelectResourceLabelDesc)
{
this.supportPattern = supportPattern;
this.authModeSelectResourceLabelDesc = authModeSelectResourceLabelDesc;
}
public String getSelectResourceLabelKey()
public boolean isSupportPatternResource()
{
return selectResourceLabelKey;
return supportPatternResource;
}
public void setSelectResourceLabelKey(String selectResourceLabelKey)
public void setSupportPatternResource(boolean supportPatternResource)
{
this.selectResourceLabelKey = selectResourceLabelKey;
this.supportPatternResource = supportPatternResource;
}
public String getSelectResourceLabelDescKey()
public String getAuthModePatternResourceLabel()
{
return selectResourceLabelDescKey;
return authModePatternResourceLabel;
}
public void setSelectResourceLabelDescKey(String selectResourceLabelDescKey)
public void setAuthModePatternResourceLabel(String authModePatternResourceLabel)
{
this.selectResourceLabelDescKey = selectResourceLabelDescKey;
this.authModePatternResourceLabel = authModePatternResourceLabel;
}
public String getFillPatternLabelKey()
public String getAuthModePatternResourceLabelDesc()
{
return fillPatternLabelKey;
return authModePatternResourceLabelDesc;
}
public void setFillPatternLabelKey(String fillPatternLabelKey)
public void setAuthModePatternResourceLabelDesc(String authModePatternResourceLabelDesc)
{
this.fillPatternLabelKey = fillPatternLabelKey;
this.authModePatternResourceLabelDesc = authModePatternResourceLabelDesc;
}
public String getFillPatternLabelDescKey()
public boolean isEnableSetEnable()
{
return fillPatternLabelDescKey;
return enableSetEnable;
}
public void setFillPatternLabelDescKey(String fillPatternLabelDescKey)
public void setEnableSetEnable(boolean enableSetEnable)
{
this.fillPatternLabelDescKey = fillPatternLabelDescKey;
this.enableSetEnable = enableSetEnable;
}
public static ResourceMeta valueOf(String resourceType, String selectResourceURL, String selectResourceIdField,
String selectResourceNameField, boolean supportPattern, PermissionMeta... permissionMetas)
public String getAuthManageAuthorizationLabel()
{
String resouceTypeLabelKey = LABEL_KEY_PREFIX + resourceType + ".resouceTypeLabel";
ResourceMeta meta = new ResourceMeta(resourceType, resouceTypeLabelKey, selectResourceURL,
selectResourceIdField, selectResourceNameField, permissionMetas);
return authManageAuthorizationLabel;
}
if (supportPattern)
{
String selectResourceLabelKey = LABEL_KEY_PREFIX + resourceType + ".selectResourceLabel";
String selectResourceLabelDescKey = selectResourceLabelKey + ".desc";
String fillPatternLabelKey = LABEL_KEY_PREFIX + resourceType + ".fillPatternLabel";
String fillPatternLabelDescKey = fillPatternLabelKey + ".desc";
public void setAuthManageAuthorizationLabel(String authManageAuthorizationLabel)
{
this.authManageAuthorizationLabel = authManageAuthorizationLabel;
}
meta.setSupportPattern(true);
meta.setSelectResourceLabelKey(selectResourceLabelKey);
meta.setSelectResourceLabelDescKey(selectResourceLabelDescKey);
meta.setFillPatternLabelKey(fillPatternLabelKey);
meta.setFillPatternLabelDescKey(fillPatternLabelDescKey);
}
public String getAuthAddAuthorizationLabel()
{
return authAddAuthorizationLabel;
}
return meta;
public void setAuthAddAuthorizationLabel(String authAddAuthorizationLabel)
{
this.authAddAuthorizationLabel = authAddAuthorizationLabel;
}
public String getAuthEditAuthorizationLabel()
{
return authEditAuthorizationLabel;
}
public void setAuthEditAuthorizationLabel(String authEditAuthorizationLabel)
{
this.authEditAuthorizationLabel = authEditAuthorizationLabel;
}
public String getAuthViewAuthorizationLabel()
{
return authViewAuthorizationLabel;
}
public void setAuthViewAuthorizationLabel(String authViewAuthorizationLabel)
{
this.authViewAuthorizationLabel = authViewAuthorizationLabel;
}
public String getAuthResourceLabel()
{
return authResourceLabel;
}
public void setAuthResourceLabel(String authResourceLabel)
{
this.authResourceLabel = authResourceLabel;
}
public String getAuthResourceTypeLabel()
{
return authResourceTypeLabel;
}
public void setAuthResourceTypeLabel(String authResourceTypeLabel)
{
this.authResourceTypeLabel = authResourceTypeLabel;
}
public String getAuthPrincipalLabel()
{
return authPrincipalLabel;
}
public void setAuthPrincipalLabel(String authPrincipalLabel)
{
this.authPrincipalLabel = authPrincipalLabel;
}
public String getAuthPrincipalTypeLabel()
{
return authPrincipalTypeLabel;
}
public void setAuthPrincipalTypeLabel(String authPrincipalTypeLabel)
{
this.authPrincipalTypeLabel = authPrincipalTypeLabel;
}
public String getAuthPermissionLabel()
{
return authPermissionLabel;
}
public void setAuthPermissionLabel(String authPermissionLabel)
{
this.authPermissionLabel = authPermissionLabel;
}
public String getAuthEnabledLabel()
{
return authEnabledLabel;
}
public void setAuthEnabledLabel(String authEnabledLabel)
{
this.authEnabledLabel = authEnabledLabel;
}
public String getAuthCreateUserLabel()
{
return authCreateUserLabel;
}
public void setAuthCreateUserLabel(String authCreateUserLabel)
{
this.authCreateUserLabel = authCreateUserLabel;
}
/**
* 是否只有一个权限
*
* @return
*/
public boolean isSinglePermission()
{
return (this.permissionMetas != null && this.permissionMetas.length == 1);
}
public PermissionMeta getSinglePermissionMeta()
{
return this.permissionMetas[0];
}
/**
* 查询编辑操作是否必须首先设置资源
*
* @return
*/
public boolean mustAssignResource()
{
return (!this.supportSelectResource && !supportPatternResource);
}
public String buildLabelKey(String subKey)
{
return buildLabelKey(this.labelKeyPrefix, subKey);
}
public void updateResouceTypeLabel()
{
this.resouceTypeLabel = buildLabelKey("resouceTypeLabel");
}
public void updateAuthModeSelectResourceLabel()
{
this.authModeSelectResourceLabel = buildLabelKey("authModeSelectResourceLabel");
}
public void updateAuthModeSelectResourceLabelDesc()
{
this.authModeSelectResourceLabelDesc = buildLabelKey("authModeSelectResourceLabelDesc");
}
public void updateAuthModePatternResourceLabel()
{
this.authModePatternResourceLabel = buildLabelKey("authModePatternResourceLabel");
}
public void updateAuthModePatternResourceLabelDesc()
{
this.authModePatternResourceLabelDesc = buildLabelKey("authModePatternResourceLabelDesc");
}
public void updateAuthManageAuthorizationLabel()
{
this.authManageAuthorizationLabel = buildLabelKey("authManageAuthorizationLabel");
}
public void updateAuthAddAuthorizationLabel()
{
this.authAddAuthorizationLabel = buildLabelKey("authAddAuthorizationLabel");
}
public void updateAuthEditAuthorizationLabel()
{
this.authEditAuthorizationLabel = buildLabelKey("authEditAuthorizationLabel");
}
public void updateAuthViewAuthorizationLabel()
{
this.authViewAuthorizationLabel = buildLabelKey("authViewAuthorizationLabel");
}
public void updateAuthResourceLabel()
{
this.authResourceLabel = buildLabelKey("authResourceLabel");
}
public void updateAuthResourceTypeLabel()
{
this.authResourceTypeLabel = buildLabelKey("authResourceTypeLabel");
}
public void updateAuthPrincipalLabel()
{
this.authPrincipalLabel = buildLabelKey("authPrincipalLabel");
}
public void updateAuthPrincipalTypeLabel()
{
this.authPrincipalTypeLabel = buildLabelKey("authPrincipalTypeLabel");
}
public void updateAuthPermissionLabel()
{
this.authPermissionLabel = buildLabelKey("authPermissionLabel");
}
public void updateAuthEnabledLabel()
{
this.authEnabledLabel = buildLabelKey("authEnabledLabel");
}
public void updateAuthCreateUserLabel()
{
this.authCreateUserLabel = buildLabelKey("authCreateUserLabel");
}
public static String buildLabelKey(String labelKeyPrefix, String subKey)
{
return labelKeyPrefix + ".auth." + subKey;
}
}
@ -265,23 +575,25 @@ public class AuthorizationResourceMetas
private static final long serialVersionUID = 1L;
/** 权限值 */
private int permission;
private String permissionLabelKey;
/** 权限标签I18N关键字 */
private String permissionLabel;
private String permissionLabelDescKey;
/** 可选权限标签描述I18N关键字 */
private String permissionLabelDesc = "authorization.default.permission.desc";
public PermissionMeta()
{
super();
}
public PermissionMeta(int permission, String permissionLabelKey, String permissionLabelDescKey)
public PermissionMeta(int permission, String permissionLabel)
{
super();
this.permission = permission;
this.permissionLabelKey = permissionLabelKey;
this.permissionLabelDescKey = permissionLabelDescKey;
this.permissionLabel = permissionLabel;
}
public int getPermission()
@ -294,62 +606,73 @@ public class AuthorizationResourceMetas
this.permission = permission;
}
public String getPermissionLabelKey()
public String getPermissionLabel()
{
return permissionLabelKey;
return permissionLabel;
}
public void setPermissionLabelKey(String permissionLabelKey)
public void setPermissionLabel(String permissionLabel)
{
this.permissionLabelKey = permissionLabelKey;
this.permissionLabel = permissionLabel;
}
public String getPermissionLabelDescKey()
public String getPermissionLabelDesc()
{
return permissionLabelDescKey;
return permissionLabelDesc;
}
public void setPermissionLabelDescKey(String permissionLabelDescKey)
public void setPermissionLabelDesc(String permissionLabelDesc)
{
this.permissionLabelDescKey = permissionLabelDescKey;
this.permissionLabelDesc = permissionLabelDesc;
}
public static PermissionMeta valueOf(int permission, String permissionLabelKey)
public static PermissionMeta valueOf(int permission, String permissionLabel)
{
return new PermissionMeta(permission, permissionLabelKey, permissionLabelKey + ".desc");
return new PermissionMeta(permission, permissionLabel);
}
public static PermissionMeta[] valuesOf()
public static PermissionMeta valueOfRead()
{
PermissionMeta[] permissionMetas = new PermissionMeta[4];
permissionMetas[0] = valueOf(Authorization.PERMISSION_READ_START, "authorization.permission.READ");
permissionMetas[1] = valueOf(Authorization.PERMISSION_EDIT_START, "authorization.permission.EDIT");
permissionMetas[2] = valueOf(Authorization.PERMISSION_DELETE_START, "authorization.permission.DELETE");
permissionMetas[3] = valueOf(Authorization.PERMISSION_NONE_START, "authorization.permission.NONE");
return permissionMetas;
return valueOfRead(Authorization.PERMISSION_READ_START);
}
public static PermissionMeta[] valuesOf(String resourceType, int read, int edit, int delete, int none,
boolean customDesc)
public static PermissionMeta valueOfRead(int permission)
{
PermissionMeta[] permissionMetas = new PermissionMeta[4];
return new PermissionMeta(permission, "authorization.permission.READ");
}
permissionMetas[0] = valueOf(read, "authorization.permission.READ");
permissionMetas[1] = valueOf(edit, "authorization.permission.EDIT");
permissionMetas[2] = valueOf(delete, "authorization.permission.DELETE");
permissionMetas[3] = valueOf(none, "authorization.permission.NONE");
public static PermissionMeta valueOfEdit()
{
return valueOfEdit(Authorization.PERMISSION_EDIT_START);
}
if (customDesc)
{
permissionMetas[0].setPermissionLabelDescKey(LABEL_KEY_PREFIX + resourceType + ".permission.READ.desc");
permissionMetas[1].setPermissionLabelDescKey(LABEL_KEY_PREFIX + resourceType + ".permission.EDIT.desc");
permissionMetas[2]
.setPermissionLabelDescKey(LABEL_KEY_PREFIX + resourceType + ".permission.DELETE.desc");
permissionMetas[3].setPermissionLabelDescKey(LABEL_KEY_PREFIX + resourceType + ".permission.NONE.desc");
}
public static PermissionMeta valueOfEdit(int permission)
{
return new PermissionMeta(permission, "authorization.permission.EDIT");
}
public static PermissionMeta valueOfDelete()
{
return valueOfEdit(Authorization.PERMISSION_DELETE_START);
}
public static PermissionMeta valueOfDelete(int permission)
{
return new PermissionMeta(permission, "authorization.permission.DELETE");
}
public static PermissionMeta valueOfNone()
{
return valueOfEdit(Authorization.PERMISSION_NONE_START);
}
public static PermissionMeta valueOfNone(int permission)
{
return new PermissionMeta(permission, "authorization.permission.NONE");
}
public static PermissionMeta[] valuesOf(PermissionMeta... permissionMetas)
{
return permissionMetas;
}
}

View File

@ -61,6 +61,11 @@ import org.springframework.web.context.request.WebRequest;
@RequestMapping("/analysis/chart")
public class ChartController extends AbstractChartPluginAwareController
{
static
{
AuthorizationResourceMetas.registerForShare(HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE, "chart");
}
@Autowired
private HtmlChartWidgetEntityService htmlChartWidgetEntityService;
@ -233,8 +238,12 @@ public class ChartController extends AbstractChartPluginAwareController
}
@RequestMapping("/pagingQuery")
public String pagingQuery(HttpServletRequest request, org.springframework.ui.Model model)
public String pagingQuery(HttpServletRequest request, HttpServletResponse response,
org.springframework.ui.Model model)
{
User user = WebUtils.getUser(request, response);
model.addAttribute("currentUser", user);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.manageChart");
return "/analysis/chart/chart_grid";
@ -258,8 +267,10 @@ public class ChartController extends AbstractChartPluginAwareController
User user = WebUtils.getUser(request, response);
PagingQuery pagingQuery = getPagingQuery(request);
String dataFilter = getDataFilterValue(request);
PagingData<HtmlChartWidgetEntity> pagingData = this.htmlChartWidgetEntityService.pagingQuery(user, pagingQuery);
PagingData<HtmlChartWidgetEntity> pagingData = this.htmlChartWidgetEntityService.pagingQuery(user, pagingQuery,
dataFilter);
setChartPluginNames(request, pagingData.getItems());
return pagingData;

View File

@ -61,6 +61,12 @@ import org.springframework.web.multipart.MultipartFile;
@RequestMapping("/analysis/dashboard")
public class DashboardController extends AbstractDataAnalysisController
{
static
{
AuthorizationResourceMetas.registerForShare(HtmlTplDashboardWidgetEntity.AUTHORIZATION_RESOURCE_TYPE,
"dashboard");
}
@Autowired
private HtmlTplDashboardWidgetEntityService htmlTplDashboardWidgetEntityService;
@ -449,8 +455,12 @@ public class DashboardController extends AbstractDataAnalysisController
}
@RequestMapping("/pagingQuery")
public String pagingQuery(HttpServletRequest request, org.springframework.ui.Model model)
public String pagingQuery(HttpServletRequest request, HttpServletResponse response,
org.springframework.ui.Model model)
{
User user = WebUtils.getUser(request, response);
model.addAttribute("currentUser", user);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dashboard.manageDashboard");
return "/analysis/dashboard/dashboard_grid";
@ -473,9 +483,10 @@ public class DashboardController extends AbstractDataAnalysisController
User user = WebUtils.getUser(request, response);
PagingQuery pagingQuery = getPagingQuery(request);
String dataFilter = getDataFilterValue(request);
PagingData<HtmlTplDashboardWidgetEntity> pagingData = this.htmlTplDashboardWidgetEntityService.pagingQuery(user,
pagingQuery);
pagingQuery, dataFilter);
return pagingData;
}

View File

@ -57,6 +57,11 @@ public class DataSetController extends AbstractSchemaConnController
public static final String DATA_SET_PROPERTY_LABELS_SPLITTER = ",";
static
{
AuthorizationResourceMetas.registerForShare(SqlDataSetEntity.AUTHORIZATION_RESOURCE_TYPE, "dataSet");
}
@Autowired
private SqlDataSetEntityService sqlDataSetEntityService;
@ -268,8 +273,12 @@ public class DataSetController extends AbstractSchemaConnController
}
@RequestMapping("/pagingQuery")
public String pagingQuery(HttpServletRequest request, org.springframework.ui.Model model)
public String pagingQuery(HttpServletRequest request, HttpServletResponse response,
org.springframework.ui.Model model)
{
User user = WebUtils.getUser(request, response);
model.addAttribute("currentUser", user);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dataSet.manageDataSet");
return "/analysis/dataSet/dataSet_grid";
@ -293,8 +302,10 @@ public class DataSetController extends AbstractSchemaConnController
User user = WebUtils.getUser(request, response);
PagingQuery pagingQuery = getPagingQuery(request, WebUtils.COOKIE_PAGINATION_SIZE);
String dataFilter = getDataFilterValue(request);
PagingData<SqlDataSetEntity> pagingData = this.sqlDataSetEntityService.pagingQuery(user, pagingQuery);
PagingData<SqlDataSetEntity> pagingData = this.sqlDataSetEntityService.pagingQuery(user, pagingQuery,
dataFilter);
return pagingData;
}

View File

@ -288,6 +288,9 @@
<property name="resourceServices">
<list>
<ref bean="schemaService" />
<ref bean="sqlDataSetEntityService" />
<ref bean="htmlChartWidgetEntityService" />
<ref bean="htmlTplDashboardWidgetEntityService" />
</list>
</property>
</bean>

View File

@ -71,7 +71,11 @@ loadMore=\u52A0\u8F7D\u66F4\u591A
insert=\u63D2\u5165
copySuccess=\u590D\u5236\u6210\u529F\uFF01
copyToClipboardSuccess=\u5DF2\u590D\u5236\u5230\u526A\u5207\u677F\uFF01
share=\u5206\u4EAB
dataFilter.mine=\u6211\u7684
dataFilter.other=\u5206\u4EAB\u7684
dataFilter.all=\u5168\u90E8
dataTables.noData=\u6CA1\u6709\u6570\u636E
dataTables.zeroRecords=\u6CA1\u6709\u7ED3\u679C
@ -324,6 +328,14 @@ schema.url.host=\u4E3B\u673A\u540D/IP
schema.url.port=\u7AEF\u53E3
schema.url.name=\u6570\u636E\u6E90\u540D\u79F0
schema.loadUrlBuilderScriptError=\u52A0\u8F7D\u6570\u636E\u6E90URL\u6784\u5EFA\u5668\u4EE3\u7801\u51FA\u9519
schema.auth.resouceTypeLabel=\u6570\u636E\u6E90
schema.auth.authModeSelectResourceLabel=\u6307\u5B9A\u6570\u636E\u6E90
schema.auth.authModePatternResourceLabel=\u6570\u636E\u6E90URL\u901A\u914D
schema.auth.authModePatternResourceLabelDesc=\u53EF\u5728[\u6570\u636E\u6E90]\u8F93\u5165\u6846\u4E2D\u586B\u5199\u6570\u636E\u6E90URL\u901A\u914D\u7B26\uFF0C\u9488\u5BF9\u6240\u6709\u5339\u914D\u7684\u6570\u636E\u6E90\u6388\u6743\uFF0C\u4F8B\u5982\uFF1A*\u3001*192.168.1.1*
schema.auth.permission.read.desc=\u4EC5\u53EF\u6D4F\u89C8\u6570\u636E\uFF0C\u6267\u884CSELECT SQL\u8BED\u53E5
schema.auth.permission.edit.desc=\u53EF\u6D4F\u89C8\u3001\u7F16\u8F91\u6570\u636E\uFF0C\u6267\u884CSELECT\u3001UPDATE SQL\u8BED\u53E5
schema.auth.permission.delete.desc=\u53EF\u6D4F\u89C8\u3001\u7F16\u8F91\u3001\u5220\u9664\u6570\u636E\uFF0C\u6267\u884C\u6240\u6709SQL\u8BED\u53E5
schema.auth.permission.none.desc=\u4E0D\u53EF\u8BBF\u95EE
#schemaUrlBuilder
schemaUrlBuilder.schemaUrlBuilder=\u6570\u636E\u6E90URL\u6784\u5EFA\u5668
@ -597,16 +609,18 @@ authorization.principalType.ANONYMOUS=\u5168\u90E8\u533F\u540D\u7528\u6237
authorization.principalType.ALL=\u5168\u90E8\u7528\u6237
authorization.enabled=\u662F\u5426\u542F\u7528
authorization.createUser=\u8BBE\u7F6E\u7528\u6237
#DATA_SOURCE resource meta
authorization.resourceMeta.DATA_SOURCE.resouceTypeLabel=\u6570\u636E\u6E90
authorization.resourceMeta.DATA_SOURCE.selectResourceLabel=\u6307\u5B9A\u6570\u636E\u6E90
authorization.resourceMeta.DATA_SOURCE.selectResourceLabel.desc=
authorization.resourceMeta.DATA_SOURCE.fillPatternLabel=\u6570\u636E\u6E90URL\u901A\u914D
authorization.resourceMeta.DATA_SOURCE.fillPatternLabel.desc=\u53EF\u5728[\u6570\u636E\u6E90]\u8F93\u5165\u6846\u4E2D\u586B\u5199\u6570\u636E\u6E90URL\u901A\u914D\u7B26\uFF0C\u9488\u5BF9\u6240\u6709\u5339\u914D\u7684\u6570\u636E\u6E90\u6388\u6743\uFF0C\u4F8B\u5982\uFF1A*\u3001*192.168.1.1*
authorization.resourceMeta.DATA_SOURCE.permission.READ.desc=\u4EC5\u53EF\u6D4F\u89C8\u6570\u636E\uFF0C\u6267\u884CSELECT SQL\u8BED\u53E5
authorization.resourceMeta.DATA_SOURCE.permission.EDIT.desc=\u53EF\u6D4F\u89C8\u3001\u7F16\u8F91\u6570\u636E\uFF0C\u6267\u884CSELECT\u3001UPDATE SQL\u8BED\u53E5
authorization.resourceMeta.DATA_SOURCE.permission.DELETE.desc=\u53EF\u6D4F\u89C8\u3001\u7F16\u8F91\u3001\u5220\u9664\u6570\u636E\uFF0C\u6267\u884C\u6240\u6709SQL\u8BED\u53E5
authorization.resourceMeta.DATA_SOURCE.permission.NONE.desc=\u4E0D\u53EF\u8BBF\u95EE
authorization.default.resouceTypeLabel=\u8D44\u6E90
authorization.default.authModeSelectResourceLabel=\u6307\u5B9A\u8D44\u6E90
authorization.default.authModeSelectResourceLabelDesc=
authorization.default.authModePatternResourceLabel=\u8D44\u6E90\u901A\u914D
authorization.default.authModePatternResourceLabelDesc=
authorization.default.permission.desc=
authorization.default.share.addAuthorization=\u6DFB\u52A0\u5206\u4EAB
authorization.default.share.editAuthorization=\u7F16\u8F91\u5206\u4EAB
authorization.default.share.viewAuthorization=\u67E5\u770B\u5206\u4EAB
authorization.default.share.manageAuthorization=\u5206\u4EAB
authorization.default.share.principal=\u5206\u4EAB\u76EE\u6807
authorization.default.share.principalType=\u76EE\u6807\u7C7B\u578B
#Data Set
dataSet.manageDataSet=\u7BA1\u7406\u6570\u636E\u96C6
@ -628,6 +642,7 @@ dataSet.DataCategory.DIMENSION=\u7EF4\u5EA6
dataSet.DataCategory.SCALAR=\u91CF\u5EA6
dataSet.propertyLabelsTextSplitByComma=\u591A\u4E2A\u6807\u7B7E\u4EE5\u82F1\u6587\u9017\u53F7\uFF08,\uFF09\u5206\u9694
dataSet.validation.previewSqlForCorrection=\u8BF7\u5148\u6267\u884C\u9884\u89C8\u786E\u4FDDSQL\u8BED\u53E5\u6B63\u786E
dataSet.auth.resouceTypeLabel=\u6570\u636E\u96C6
#Chart
chart.manageChart=\u7BA1\u7406\u56FE\u8868
@ -652,6 +667,7 @@ chart.updateInterval.realtime=\u5B9E\u65F6
chart.updateInterval.interval=\u95F4\u9694
chart.updateIntervalUnit=\u6BEB\u79D2
chart.updateIntervalWithUnit={0}\u6BEB\u79D2
chart.auth.resouceTypeLabel=\u56FE\u8868
#Dashboard
dashboard.manageDashboard=\u7BA1\u7406\u770B\u677F
@ -680,6 +696,7 @@ dashboard.confirmDeleteSelectedResource=\u786E\u8BA4\u5220\u9664\u9009\u4E2D\u76
dashboard.pleaseSaveDashboardFirst=\u8BF7\u5148\u4FDD\u5B58\u770B\u677F
dashboard.copyResourceNameToClipboard=\u62F7\u8D1D\u8D44\u6E90\u540D\u5230\u526A\u5207\u677F
dashboard.addResource=\u6DFB\u52A0\u8D44\u6E90
dashboard.auth.resouceTypeLabel=\u770B\u677F
#Chart plugin
chartPlugin.manageChartPlugin=\u7BA1\u7406\u56FE\u8868\u63D2\u4EF6

View File

@ -1146,6 +1146,25 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
overflow-x: hidden;
font-size: 0.8em;
}
.search-form .data-filter-select-wrapper{
position: absolute;
display: inline-block;
padding-left: 0.5em;
}
.search-form .data-filter-select-wrapper .ui-selectmenu-button.ui-button{
width: 5em;
padding-left: 0.2em;
padding-right: 0.2em;
background: none;
border: none;
}
.search-form .data-filter-select-wrapper .ui-selectmenu-button.ui-button .ui-icon{
float: left;
margin-top: 0.2em;
}
.search-form .data-filter-select-wrapper .ui-selectmenu-button.ui-button .ui-selectmenu-text{
margin-right: 0px;
}
/*表格页*/
.page-grid{

View File

@ -6,6 +6,7 @@ selectonly 是否选择操作允许为null
-->
<#assign selectonly=(selectonly!false)>
<#assign isMultipleSelect=(isMultipleSelect!false)>
<#assign HtmlChartWidgetEntity=statics['org.datagear.management.domain.HtmlChartWidgetEntity']>
<html>
<head>
<#include "../../include/html_head.ftl">
@ -15,10 +16,11 @@ selectonly 是否选择操作允许为null
<#if !isAjaxRequest>
<div class="fill-parent">
</#if>
<#include "../../include/page_js_obj.ftl">
<div id="${pageId}" class="page-grid page-grid-chart">
<div class="head">
<div class="search">
<#include "../../include/page_obj_searchform.html.ftl">
<#include "../../include/page_obj_searchform_data_filter.ftl">
</div>
<div class="operation">
<#if selectonly>
@ -29,6 +31,9 @@ selectonly 是否选择操作允许为null
<input name="editButton" type="button" value="<@spring.message code='edit' />" />
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
<input name="showButton" type="button" value="<@spring.message code='chart.show' />" />
<#if !(currentUser.anonymous)>
<input name="shareButton" type="button" value="<@spring.message code='share' />" />
</#if>
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
</#if>
</div>
@ -46,14 +51,16 @@ selectonly 是否选择操作允许为null
<#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">
<#include "../../include/page_obj_data_permission.ftl" >
<script type="text/javascript">
(function(po)
{
$.initButtons(po.element(".operation"));
po.initDataFilter();
po.currentUser = <@writeJson var=currentUser />;
po.url = function(action)
{
@ -94,6 +101,23 @@ selectonly 是否选择操作允许为null
});
});
});
po.element("input[name=shareButton]").click(function()
{
po.executeOnSelect(function(row)
{
if(!po.canAuthorize(row, po.currentUser))
{
$.tipInfo("<@spring.message code='error.PermissionDeniedException' />");
return;
}
var options = {};
$.setGridPageHeightOption(options);
po.open(contextPath+"/authorization/${HtmlChartWidgetEntity.AUTHORIZATION_RESOURCE_TYPE}/query?"
+"${statics['org.datagear.web.controller.AuthorizationController'].PARAM_ASSIGNED_RESOURCE}="+encodeURIComponent(row.id), options);
});
});
</#if>
po.element("input[name=viewButton]").click(function()

View File

@ -5,6 +5,7 @@ titleMessageKey 标题标签I18N关键字不允许null
selectonly 是否选择操作允许为null
-->
<#assign selectonly=(selectonly!false)>
<#assign HtmlTplDashboardWidgetEntity=statics['org.datagear.management.domain.HtmlTplDashboardWidgetEntity']>
<html>
<head>
<#include "../../include/html_head.ftl">
@ -14,10 +15,11 @@ selectonly 是否选择操作允许为null
<#if !isAjaxRequest>
<div class="fill-parent">
</#if>
<#include "../../include/page_js_obj.ftl">
<div id="${pageId}" class="page-grid page-grid-dashboard">
<div class="head">
<div class="search">
<#include "../../include/page_obj_searchform.html.ftl">
<#include "../../include/page_obj_searchform_data_filter.ftl">
</div>
<div class="operation">
<#if selectonly>
@ -29,6 +31,9 @@ selectonly 是否选择操作允许为null
<input name="editButton" type="button" value="<@spring.message code='edit' />" />
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
<input name="showButton" type="button" value="<@spring.message code='dashboard.show' />" />
<#if !(currentUser.anonymous)>
<input name="shareButton" type="button" value="<@spring.message code='share' />" />
</#if>
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
</#if>
</div>
@ -46,14 +51,16 @@ selectonly 是否选择操作允许为null
<#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">
<#include "../../include/page_obj_data_permission.ftl" >
<script type="text/javascript">
(function(po)
{
$.initButtons(po.element(".operation"));
po.initDataFilter();
po.currentUser = <@writeJson var=currentUser />;
po.url = function(action)
{
@ -108,6 +115,23 @@ selectonly 是否选择操作允许为null
});
});
});
po.element("input[name=shareButton]").click(function()
{
po.executeOnSelect(function(row)
{
if(!po.canAuthorize(row, po.currentUser))
{
$.tipInfo("<@spring.message code='error.PermissionDeniedException' />");
return;
}
var options = {};
$.setGridPageHeightOption(options);
po.open(contextPath+"/authorization/${HtmlTplDashboardWidgetEntity.AUTHORIZATION_RESOURCE_TYPE}/query?"
+"${statics['org.datagear.web.controller.AuthorizationController'].PARAM_ASSIGNED_RESOURCE}="+encodeURIComponent(row.id), options);
});
});
</#if>
po.element("input[name=viewButton]").click(function()

View File

@ -6,6 +6,7 @@ selectonly 是否选择操作允许为null
-->
<#assign selectonly=(selectonly!false)>
<#assign isMultipleSelect=(isMultipleSelect!false)>
<#assign SqlDataSetEntity=statics['org.datagear.management.domain.SqlDataSetEntity']>
<html>
<head>
<#include "../../include/html_head.ftl">
@ -15,10 +16,11 @@ selectonly 是否选择操作允许为null
<#if !isAjaxRequest>
<div class="fill-parent">
</#if>
<#include "../../include/page_js_obj.ftl">
<div id="${pageId}" class="page-grid page-grid-dataSet">
<div class="head">
<div class="search">
<#include "../../include/page_obj_searchform.html.ftl">
<#include "../../include/page_obj_searchform_data_filter.ftl">
</div>
<div class="operation">
<#if selectonly>
@ -28,6 +30,9 @@ 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' />" />
<#if !(currentUser.anonymous)>
<input name="shareButton" type="button" value="<@spring.message code='share' />" />
</#if>
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
</#if>
</div>
@ -45,14 +50,16 @@ selectonly 是否选择操作允许为null
<#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">
<#include "../../include/page_obj_data_permission.ftl" >
<script type="text/javascript">
(function(po)
{
$.initButtons(po.element(".operation"));
po.initDataFilter();
po.currentUser = <@writeJson var=currentUser />;
po.url = function(action)
{
@ -93,6 +100,23 @@ selectonly 是否选择操作允许为null
});
});
});
po.element("input[name=shareButton]").click(function()
{
po.executeOnSelect(function(row)
{
if(!po.canAuthorize(row, po.currentUser))
{
$.tipInfo("<@spring.message code='error.PermissionDeniedException' />");
return;
}
var options = {};
$.setGridPageHeightOption(options);
po.open(contextPath+"/authorization/${SqlDataSetEntity.AUTHORIZATION_RESOURCE_TYPE}/query?"
+"${statics['org.datagear.web.controller.AuthorizationController'].PARAM_ASSIGNED_RESOURCE}="+encodeURIComponent(row.id), options);
});
});
</#if>
po.element("input[name=viewButton]").click(function()

View File

@ -17,10 +17,16 @@ readonly 是否只读操作允许为null
<#assign permission=((authorization.permission)!resourceMeta.permissionMetas[0].permission)>
<#assign enabled=(((authorization.enabled)!true)?string('true', 'false'))>
<#assign isResourceTypePattern=(resourceType == resourceTypePattern)>
<#if assignedResource??>
<#assign resource=assignedResource>
<#else>
<#assign resource=((authorization.resource)!'')>
</#if>
<html>
<head>
<#include "../include/html_head.ftl">
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> - <@spring.message code='${resourceMeta.resouceTypeLabelKey}' /></title>
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> - <@spring.message code='${resourceMeta.resouceTypeLabel}' /></title>
</head>
<body>
<div id="${pageId}" class="page-form page-form-authorization">
@ -28,55 +34,69 @@ readonly 是否只读操作允许为null
<div class="form-head"></div>
<div class="form-content">
<input type="hidden" name="id" value="${(authorization.id)!''?html}" />
<input type="hidden" name="resource" value="${(authorization.resource)!''?html}" />
<input type="hidden" name="resource" value="${resource?html}" />
<input type="hidden" name="principal" value="${(authorization.principal)!''?html}" />
<#if resourceMeta.supportPattern>
<div class="form-item form-item-resourceType">
<div class="form-item-label">
<label><@spring.message code='authorization.resourceType' /></label>
</div>
<div class="form-item-value">
<div class="resourceType-radios">
<label for="${pageId}-resourceType_0" title="<@spring.message code='${resourceMeta.selectResourceLabelDescKey}' />">
<@spring.message code='${resourceMeta.selectResourceLabelKey}' />
</label>
<input type="radio" id="${pageId}-resourceType_0" name="resourceType" value="${resourceMeta.resourceType}" />
<label for="${pageId}-resourceType_1" title="<@spring.message code='${resourceMeta.fillPatternLabelDescKey}' />">
<@spring.message code='${resourceMeta.fillPatternLabelKey}' />
</label>
<input type="radio" id="${pageId}-resourceType_1" name="resourceType" value="${resourceTypePattern}" />
</div>
</div>
</div>
<div class="form-item form-item-resource-name-pattern">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.resouceTypeLabelKey}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="resourceNameForPattern" value="${(!isResourceTypePattern)?string('', (authorization.resourceName)!'')}" class="ui-widget ui-widget-content" />
<#if !readonly>
<#--占位按钮,避免切换时界面尺寸变化-->
<button type="button" style="visibility: hidden; padding-left: 0; padding-right: 0; width: 1px; margin-left: -3px; margin-right: 0;">&nbsp;</button>
</#if>
</div>
</div>
<#if assignedResource??>
<input type="hidden" name="resourceType" value="${resourceType}" />
<#else>
<input type="hidden" name="resourceType" value="${resourceType}" />
<#if (resourceMeta.supportSelectResource && resourceMeta.supportPatternResource)>
<div class="form-item form-item-resourceType">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.authResourceTypeLabel}' /></label>
</div>
<div class="form-item-value">
<div class="resourceType-radios">
<label for="${pageId}-resourceType_0" title="<@spring.message code='${resourceMeta.authModeSelectResourceLabelDesc}' />">
<@spring.message code='${resourceMeta.authModeSelectResourceLabel}' />
</label>
<input type="radio" id="${pageId}-resourceType_0" name="resourceType" value="${resourceMeta.resourceType}" />
<label for="${pageId}-resourceType_1" title="<@spring.message code='${resourceMeta.authModePatternResourceLabelDesc}' />">
<@spring.message code='${resourceMeta.authModePatternResourceLabel}' />
</label>
<input type="radio" id="${pageId}-resourceType_1" name="resourceType" value="${resourceTypePattern}" />
</div>
</div>
</div>
<#elseif resourceMeta.supportPatternResource>
<input type="hidden" name="resourceType" value="${resourceTypePattern}" />
<#else>
<input type="hidden" name="resourceType" value="${resourceType}" />
</#if>
<#if resourceMeta.supportSelectResource>
<div class="form-item form-item-resource-name-entity">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.resouceTypeLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="resourceNameForEntity" value="${isResourceTypePattern?string('', (authorization.resourceName)!'')}" class="ui-widget ui-widget-content" readonly="readonly" />
<#if !readonly>
<button type="button" class="resource-select-button"><@spring.message code='select' /></button>
</#if>
</div>
</div>
</#if>
<#if resourceMeta.supportPatternResource>
<div class="form-item form-item-resource-name-pattern">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.resouceTypeLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="resourceNameForPattern" value="${(!isResourceTypePattern)?string('', (authorization.resourceName)!'')}" class="ui-widget ui-widget-content" />
<#if !readonly>
<#--占位按钮,避免切换时界面尺寸变化-->
<button type="button" style="visibility: hidden; padding-left: 0; padding-right: 0; width: 1px; margin-left: -3px; margin-right: 0;">&nbsp;</button>
</#if>
</div>
</div>
</#if>
</#if>
<div class="form-item form-item-resource-name-entity">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.resouceTypeLabelKey}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="resourceNameForEntity" value="${isResourceTypePattern?string('', (authorization.resourceName)!'')}" class="ui-widget ui-widget-content" readonly="readonly" />
<#if !readonly>
<button type="button" class="resource-select-button"><@spring.message code='select' /></button>
</#if>
</div>
</div>
<div class="form-item">
<div class="form-item-label">
<label><@spring.message code='authorization.principalType' /></label>
<label><@spring.message code='${resourceMeta.authPrincipalTypeLabel}' /></label>
</div>
<div class="form-item-value">
<div class="principalType-radios">
@ -91,9 +111,10 @@ readonly 是否只读操作允许为null
</div>
</div>
</div>
<div class="form-item form-item-principal form-item-principal-user">
<div class="form-item-label">
<label><@spring.message code='authorization.principal' /></label>
<label><@spring.message code='${resourceMeta.authPrincipalLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="principalNameUser" value="${(Authorization.PRINCIPAL_TYPE_USER!=principalType)?string('', (authorization.principalName)!'')}" class="ui-widget ui-widget-content" readonly="readonly" />
@ -104,7 +125,7 @@ readonly 是否只读操作允许为null
</div>
<div class="form-item form-item-principal form-item-principal-role">
<div class="form-item-label">
<label><@spring.message code='authorization.principal' /></label>
<label><@spring.message code='${resourceMeta.authPrincipalLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="principalNameRole" value="${(Authorization.PRINCIPAL_TYPE_ROLE!=principalType)?string('', (authorization.principalName)!'')}" class="ui-widget ui-widget-content" readonly="readonly" />
@ -115,7 +136,7 @@ readonly 是否只读操作允许为null
</div>
<div class="form-item form-item-principal form-item-principal-anonymous">
<div class="form-item-label">
<label><@spring.message code='authorization.principal' /></label>
<label><@spring.message code='${resourceMeta.authPrincipalLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="principalNameAnonymous" value="<@spring.message code='authorization.principalType.ANONYMOUS' />" class="ui-widget ui-widget-content" readonly="readonly" />
@ -127,7 +148,7 @@ readonly 是否只读操作允许为null
</div>
<div class="form-item form-item-principal form-item-principal-all">
<div class="form-item-label">
<label><@spring.message code='authorization.principal' /></label>
<label><@spring.message code='${resourceMeta.authPrincipalLabel}' /></label>
</div>
<div class="form-item-value">
<input type="text" name="principalNameAll" value="<@spring.message code='authorization.principalType.ALL' />" class="ui-widget ui-widget-content" readonly="readonly" />
@ -137,34 +158,45 @@ readonly 是否只读操作允许为null
</#if>
</div>
</div>
<#if !(resourceMeta.singlePermission)>
<div class="form-item">
<div class="form-item-label">
<label><@spring.message code='authorization.permission' /></label>
<label><@spring.message code='${resourceMeta.authPermissionLabel}' /></label>
</div>
<div class="form-item-value">
<div class="permission-radios">
<#list resourceMeta.permissionMetas as pm>
<label for="${pageId}-permission_${pm?counter}" title="<@spring.message code='${pm.permissionLabelDescKey}' />">
<@spring.message code='${pm.permissionLabelKey}' />
<label for="${pageId}-permission_${pm?counter}" title="<@spring.message code='${pm.permissionLabelDesc}' />">
<@spring.message code='${pm.permissionLabel}' />
</label>
<input type="radio" id="${pageId}-permission_${pm?counter}" name="permission" value="${pm.permission}" />
</#list>
</div>
</div>
</div>
<div class="form-item">
<div class="form-item-label">
<label><@spring.message code='authorization.enabled' /></label>
<#else>
<input type="hidden" name="permission" value="${resourceMeta.singlePermissionMeta.permission}" />
</#if>
<#if resourceMeta.enableSetEnable>
<div class="form-item">
<div class="form-item-label">
<label><@spring.message code='${resourceMeta.authEnabledLabel}' /></label>
</div>
<div class="form-item-value">
<div class="enabled-radios">
<label for="${pageId}-enabled_0"><@spring.message code='yes' /></label>
<input type="radio" id="${pageId}-enabled_0" name="enabled" value="true" />
<label for="${pageId}-enabled_1"><@spring.message code='no' /></label>
<input type="radio" id="${pageId}-enabled_1" name="enabled" value="false" />
</div>
</div>
</div>
<div class="form-item-value">
<div class="enabled-radios">
<label for="${pageId}-enabled_0"><@spring.message code='yes' /></label>
<input type="radio" id="${pageId}-enabled_0" name="enabled" value="true" />
<label for="${pageId}-enabled_1"><@spring.message code='no' /></label>
<input type="radio" id="${pageId}-enabled_1" name="enabled" value="false" />
</div>
</div>
</div>
<#else>
<input type="hidden" name="enabled" value="true" />
</#if>
</div>
<div class="form-foot" style="text-align:center;">
<#if !readonly>
@ -183,49 +215,8 @@ readonly 是否只读操作允许为null
$.initButtons(po.element());
<#if !readonly>
po.form().validate(
{
rules :
{
resource : "required",
resourceType : "required",
principal : "required",
principalType : "required",
permission : "required"
},
messages :
{
resource : "<@spring.message code='validation.required' />",
resourceType : "<@spring.message code='validation.required' />",
principal : "<@spring.message code='validation.required' />",
principalType : "<@spring.message code='validation.required' />",
permission : "<@spring.message code='validation.required' />"
},
submitHandler : function(form)
{
<#if resourceMeta.supportPattern>
var resourceType = po.element("input[name='resourceType']:checked").val();
if(resourceType == '${resourceTypePattern}')
po.element("input[name='resource']").val(po.element("input[name='resourceNameForPattern']").val());
</#if>
$(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 resourceMeta.supportSelectResource>
po.element(".resource-select-button").click(function()
{
var options =
@ -244,6 +235,7 @@ readonly 是否只读操作允许为null
po.open("${contextPath}${resourceMeta.selectResourceURL}", options);
});
</#if>
po.element(".principal-user-select-button").click(function()
{
@ -289,61 +281,113 @@ readonly 是否只读操作允许为null
po.element("input[name='resourceType']:checked").change();
po.element("input[name='principalType']:checked").change();
});
</#if>
<#if resourceMeta.supportPattern>
po.element("input[name='resourceType']").on("change", function()
po.form().validate(
{
var val = $(this).val();
var $formItemForPattern = po.element(".form-item-resource-name-pattern");
var $formItemForEntity = po.element(".form-item-resource-name-entity");
var $resourceNameForPattern = po.element("input[name='resourceNameForPattern']");
var $resourceNameForEntity = po.element("input[name='resourceNameForEntity']");
if("${appointResource!''?js_string}" != "")
rules :
{
$formItemForPattern.hide();
$formItemForEntity.hide();
return;
}
if(val == '${resourceMeta.resourceType}')
resource : "required",
resourceType : "required",
principal : "required",
principalType : "required",
permission : "required"
},
messages :
{
$formItemForPattern.hide();
$formItemForEntity.show();
<#if !readonly>
$resourceNameForPattern.rules("remove");
$resourceNameForEntity.rules("add",
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
resource : "<@spring.message code='validation.required' />",
resourceType : "<@spring.message code='validation.required' />",
principal : "<@spring.message code='validation.required' />",
principalType : "<@spring.message code='validation.required' />",
permission : "<@spring.message code='validation.required' />"
},
submitHandler : function(form)
{
<#if assignedResource??>
<#else>
var resourceType = po.element("input[name='resourceType']:checked").val();
if(resourceType == '${resourceTypePattern}')
po.element("input[name='resource']").val(po.element("input[name='resourceNameForPattern']").val());
</#if>
}
else
{
$formItemForPattern.show();
$formItemForEntity.hide();
<#if !readonly>
$resourceNameForPattern.rules("add",
$(form).ajaxSubmit(
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
success : function()
{
var close = (po.pageParamCall("afterSave") != false);
if(close)
po.close();
}
});
$resourceNameForEntity.rules("remove");
</#if>
},
errorPlacement : function(error, element)
{
error.appendTo(element.closest(".form-item-value"));
}
});
</#if>
<#if assignedResource??>
<#else>
<#if !readonly>
po.element("input[name='resourceNameForEntity']").rules("add",
<#if (resourceMeta.supportSelectResource && resourceMeta.supportPatternResource)>
po.element("input[name='resourceType']").on("change", function()
{
var val = $(this).val();
var $formItemForPattern = po.element(".form-item-resource-name-pattern");
var $formItemForEntity = po.element(".form-item-resource-name-entity");
var $resourceNameForPattern = po.element("input[name='resourceNameForPattern']");
var $resourceNameForEntity = po.element("input[name='resourceNameForEntity']");
if(val == '${resourceMeta.resourceType}')
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
$formItemForPattern.hide();
$formItemForEntity.show();
<#if !readonly>
$resourceNameForPattern.rules("remove");
$resourceNameForEntity.rules("add",
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
</#if>
}
else
{
$formItemForPattern.show();
$formItemForEntity.hide();
<#if !readonly>
$resourceNameForPattern.rules("add",
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
$resourceNameForEntity.rules("remove");
</#if>
}
});
</#if>
<#if resourceMeta.supportSelectResource>
<#if !readonly>
po.element("input[name='resourceNameForEntity']").rules("add",
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
</#if>
</#if>
<#if resourceMeta.supportPatternResource>
<#if !readonly>
po.element("input[name='resourceNameForPattern']").rules("add",
{
"required" : true,
messages : {"required" : "<@spring.message code='validation.required' />"}
});
</#if>
</#if>
</#if>
@ -375,38 +419,47 @@ readonly 是否只读操作允许为null
</#if>
});
<#if resourceMeta.supportPattern>
<#if assignedResource??>
<#else>
<#if (resourceMeta.supportSelectResource && resourceMeta.supportPatternResource)>
po.element("input[name='resourceType'][value='${resourceType}']").attr("checked", "checked").change();
po.element("input[name='resourceType']").checkboxradio({icon:false});
po.element(".resourceType-radios").controlgroup();
</#if>
</#if>
po.element("input[name='principalType'][value='${principalType}']").attr("checked", "checked").change();
po.element("input[name='principalType']").checkboxradio({icon:false});
po.element(".principalType-radios").controlgroup();
<#if !(resourceMeta.singlePermission)>
po.element("input[name='permission'][value='${permission}']").attr("checked", "checked");
po.element("input[name='permission']").checkboxradio({icon:false});
po.element(".permission-radios").controlgroup();
</#if>
<#if resourceMeta.enableSetEnable>
po.element("input[name='enabled'][value='${enabled}']").attr("checked", "checked");
po.element("input[name='enabled']").checkboxradio({icon:false});
po.element(".enabled-radios").controlgroup();
</#if>
<#if appointResource??>
<#if resourceMeta.supportPattern>
po.element("input[name='resourceType'][value='${resourceMeta.resourceType}']").attr("checked", "checked").change();
po.element(".form-item-resourceType").hide();
</#if>
po.element("input[name='resource']").val("${appointResource}");
<#if assignedResource??>
<#else>
<#if (resourceMeta.supportSelectResource && resourceMeta.supportPatternResource)>
po.element("input[name='resourceType'][value='${resourceType}']").attr("checked", "checked").change();
</#if>
</#if>
<#--编辑时禁设资源类型,因为管理员也可能编辑普通用户设置的授权,而它们不允许是通配符-->
<#if formAction == 'saveEdit'>
<#if resourceMeta.supportPattern>
<#if assignedResource??>
<#else>
<#if (resourceMeta.supportSelectResource && resourceMeta.supportPatternResource)>
po.element("input[name='resourceType'][value!='${resourceType}']").attr("disabled", "disabled");
po.element("input[name='resourceType']").checkboxradio("refresh");
</#if>
</#if>
</#if>
})
(${pageId});

View File

@ -5,10 +5,11 @@ String titleMessageKey 标题标签I18N关键字不允许null
ResourceMeta resourceMeta 资源元信息不允许null
-->
<#assign AuthorizationController=statics['org.datagear.web.controller.AuthorizationController']>
<#assign isAssignedResource=(assignedResource??)>
<html>
<head>
<#include "../include/html_head.ftl">
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> - <@spring.message code='${resourceMeta.resouceTypeLabelKey}' /></title>
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /> - <@spring.message code='${resourceMeta.resouceTypeLabel}' /></title>
</head>
<body class="fill-parent">
<#if !isAjaxRequest>
@ -57,8 +58,8 @@ ResourceMeta resourceMeta 资源元信息不允许null
{
var data =
{
<#if appointResource??>
"${AuthorizationController.PARAM_APPOINT_RESOURCE}" : "${appointResource}"
<#if assignedResource??>
"${AuthorizationController.PARAM_ASSIGNED_RESOURCE}" : "${assignedResource}"
</#if>
};
@ -81,8 +82,8 @@ ResourceMeta resourceMeta 资源元信息不允许null
{
var data =
{
<#if appointResource??>
"${AuthorizationController.PARAM_APPOINT_RESOURCE}" : "${appointResource?js_string}",
<#if assignedResource??>
"${AuthorizationController.PARAM_ASSIGNED_RESOURCE}" : "${assignedResource?js_string}",
</#if>
"id" : row.id
};
@ -107,8 +108,8 @@ ResourceMeta resourceMeta 资源元信息不允许null
{
var data =
{
<#if appointResource??>
"${AuthorizationController.PARAM_APPOINT_RESOURCE}" : "${appointResource?js_string}",
<#if assignedResource??>
"${AuthorizationController.PARAM_ASSIGNED_RESOURCE}" : "${assignedResource?js_string}",
</#if>
"id" : row.id
};
@ -140,7 +141,7 @@ ResourceMeta resourceMeta 资源元信息不允许null
});
});
var columnEnabled = $.buildDataTablesColumnSimpleOption("<@spring.message code='authorization.enabled' />", "enabled");
var columnEnabled = $.buildDataTablesColumnSimpleOption("<@spring.message code='${resourceMeta.authEnabledLabel}' />", "enabled", ${(resourceMeta.enableSetEnable)?string('false', 'true')});
columnEnabled.render = function(data, type, row, meta)
{
if(data == true)
@ -153,16 +154,16 @@ ResourceMeta resourceMeta 资源元信息不允许null
var tableColumns = [
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='authorization.resource' />"), "resourceName"),
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='authorization.principal' />"), "principalName"),
$.buildDataTablesColumnSimpleOption("<@spring.message code='authorization.permission' />", "permissionLabel"),
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='${resourceMeta.authResourceLabel}' />"), "resourceName", ${isAssignedResource?string('true', 'false')}),
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='${resourceMeta.authPrincipalLabel}' />"), "principalName"),
$.buildDataTablesColumnSimpleOption("<@spring.message code='${resourceMeta.authPermissionLabel}' />", "permissionLabel", ${(resourceMeta.singlePermission)?string('true', 'false')}),
columnEnabled,
$.buildDataTablesColumnSimpleOption("<@spring.message code='authorization.createUser' />", "createUser.nameLabel")
$.buildDataTablesColumnSimpleOption("<@spring.message code='${resourceMeta.authCreateUserLabel}' />", "createUser.nameLabel")
];
var url = po.url("queryData");
<#if appointResource??>
url = po.url("queryData?${AuthorizationController.PARAM_APPOINT_RESOURCE}="+encodeURIComponent("${appointResource?js_string}"));
<#if assignedResource??>
url = po.url("queryData?${AuthorizationController.PARAM_ASSIGNED_RESOURCE}="+encodeURIComponent("${assignedResource?js_string}"));
</#if>
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, url);
po.initDataTable(tableSettings);

View File

@ -0,0 +1,74 @@
<#--
设置共享筛选条件片段。
依赖:
page_js_obj.jsp
-->
<#assign _ssf_AbstractController=statics['org.datagear.web.controller.AbstractController']>
<#assign _ssf_DataPermissionEntityService=statics['org.datagear.management.service.DataPermissionEntityService']>
<form id="${pageId}-searchForm" class="search-form" action="#">
<div class="ui-widget ui-widget-content keyword-widget simple">
<div class="keyword-input-parent">
<input name="keyword" type="text" class="ui-widget ui-widget-content keyword-input" />
</div>
</div>
<input name="submit" type="submit" value="<@spring.message code='query' />" />
<div class="data-filter-select-wrapper">
<select id="${pageId}-dataFilter" name="${_ssf_AbstractController.DATA_FILTER_PARAM}" class="data-filter-select">
<option value="${_ssf_DataPermissionEntityService.DATA_FILTER_VALUE_MINE}"><@spring.message code='dataFilter.mine' /></option>
<option value="${_ssf_DataPermissionEntityService.DATA_FILTER_VALUE_OTHER}"><@spring.message code='dataFilter.other' /></option>
<option value="${_ssf_DataPermissionEntityService.DATA_FILTER_VALUE_ALL}"><@spring.message code='dataFilter.all' /></option>
</select>
</div>
</form>
<#include "page_obj_searchform_js.ftl">
<script type="text/javascript">
(function(po)
{
po.getSearchParam = function()
{
var $form = po.searchForm();
var param =
{
"keyword" : $.trim(po.element("input[name='keyword']", $form).val()),
"${_ssf_AbstractController.DATA_FILTER_PARAM}": po.element("#${pageId}-dataFilter", $form).val()
};
return param;
};
po.initDataFilter = function()
{
var $ele = po.element("#${pageId}-dataFilter");
var val = $.cookie("${_ssf_AbstractController.DATA_FILTER_COOKIE}");
if(!val)
val = $("option:first-child", $ele).attr("value");
$ele.val(val);
$ele.selectmenu(
{
change: function(event, ui)
{
var val = ui.item.value;
$ele.val(val);
if(po.onSetDataFilter)
po.onSetDataFilter(val);
else
po.searchForm().submit();
$.cookie("${_ssf_AbstractController.DATA_FILTER_COOKIE}", val, {expires : 365*5, path : "${contextPath}/"});
}
});
};
po.getDataFilter = function()
{
return po.element("#${pageId}-dataFilter").val();
};
})
(${pageId});
</script>

View File

@ -32,6 +32,12 @@ po.search = undefined;
return param;
};
po.getSearchParamString = function()
{
var param = po.getSearchParam();
return $.param(param);
};
po.element("input:submit", po.searchForm()).button();
})
(${pageId});

View File

@ -946,7 +946,7 @@
var options = {};
$.setGridPageHeightOption(options);
po.open(contextPath+"/authorization/${statics['org.datagear.management.domain.Schema'].AUTHORIZATION_RESOURCE_TYPE}/query?${statics['org.datagear.web.controller.AuthorizationController'].PARAM_APPOINT_RESOURCE}="+encodeURIComponent(schemaId), options);
po.open(contextPath+"/authorization/${statics['org.datagear.management.domain.Schema'].AUTHORIZATION_RESOURCE_TYPE}/query?${statics['org.datagear.web.controller.AuthorizationController'].PARAM_ASSIGNED_RESOURCE}="+encodeURIComponent(schemaId), options);
}
else if($item.hasClass("schema-operation-reload"))
{