forked from p85126437/datagear
添加数据源防护基本管理功能
This commit is contained in:
parent
773dc8173e
commit
227470e09d
|
@ -12,13 +12,15 @@ import java.util.Comparator;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/**
|
||||
* 数据源管控。
|
||||
* 数据源防护。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SchemaGuard extends AbstractStringIdEntity
|
||||
public class SchemaGuard extends AbstractStringIdEntity implements CloneableEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -26,16 +28,16 @@ public class SchemaGuard extends AbstractStringIdEntity
|
|||
private String pattern;
|
||||
|
||||
/** 是否允许:true 允许;false 禁止 */
|
||||
private boolean permitted;
|
||||
private boolean permitted = true;
|
||||
|
||||
/** 优先级 */
|
||||
private int priority;
|
||||
private int priority = 0;
|
||||
|
||||
/** 是否启用 */
|
||||
private boolean enabled = true;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
private Date createTime = new Date();
|
||||
|
||||
public SchemaGuard()
|
||||
{
|
||||
|
@ -47,14 +49,10 @@ public class SchemaGuard extends AbstractStringIdEntity
|
|||
super(id);
|
||||
}
|
||||
|
||||
public SchemaGuard(String id, String pattern, boolean permitted, int priority)
|
||||
public SchemaGuard(String id, String pattern)
|
||||
{
|
||||
super(id);
|
||||
this.pattern = pattern;
|
||||
this.permitted = permitted;
|
||||
this.priority = priority;
|
||||
this.enabled = true;
|
||||
this.createTime = new Date();
|
||||
}
|
||||
|
||||
public String getPattern()
|
||||
|
@ -107,12 +105,21 @@ public class SchemaGuard extends AbstractStringIdEntity
|
|||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemaGuard clone()
|
||||
{
|
||||
SchemaGuard entity = new SchemaGuard();
|
||||
BeanUtils.copyProperties(this, entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将{@linkplain SchemaGuard}列表按照优先级排序,{@linkplain SchemaGuard#getPriority()}越大越靠前、{@linkplain SchemaGuard#getCreateTime()}越新越靠前。
|
||||
*
|
||||
* @param schemaGuards
|
||||
*/
|
||||
public void sortByPriority(List<? extends SchemaGuard> schemaGuards)
|
||||
public static void sortByPriority(List<? extends SchemaGuard> schemaGuards)
|
||||
{
|
||||
if (schemaGuards == null)
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*/
|
||||
|
||||
package org.datagear.management.service;
|
||||
|
||||
import org.datagear.management.domain.SchemaGuard;
|
||||
|
||||
/**
|
||||
* {@linkplain SchemaGuard}业务服务接口。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public interface SchemaGuardService extends EntityService<String, SchemaGuard>
|
||||
{
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*/
|
||||
|
||||
package org.datagear.management.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.datagear.management.domain.SchemaGuard;
|
||||
import org.datagear.management.service.SchemaGuardService;
|
||||
import org.datagear.management.util.dialect.MbSqlDialect;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* {@linkplain SchemaGuardService}实现类。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
public class SchemaGuardServiceImpl extends AbstractMybatisEntityService<String, SchemaGuard>
|
||||
implements SchemaGuardService
|
||||
{
|
||||
protected static final String SQL_NAMESPACE = SchemaGuard.class.getName();
|
||||
|
||||
public SchemaGuardServiceImpl()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SchemaGuardServiceImpl(SqlSessionFactory sqlSessionFactory, MbSqlDialect dialect)
|
||||
{
|
||||
super(sqlSessionFactory, dialect);
|
||||
}
|
||||
|
||||
public SchemaGuardServiceImpl(SqlSessionTemplate sqlSessionTemplate, MbSqlDialect dialect)
|
||||
{
|
||||
super(sqlSessionTemplate, dialect);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SchemaGuard> query(String statement, Map<String, Object> params)
|
||||
{
|
||||
List<SchemaGuard> list = super.query(statement, params);
|
||||
|
||||
SchemaGuard.sortByPriority(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<SchemaGuard> query(String statement, Map<String, Object> params, RowBounds rowBounds)
|
||||
{
|
||||
List<SchemaGuard> list = super.query(statement, params, rowBounds);
|
||||
|
||||
SchemaGuard.sortByPriority(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSqlNamespace()
|
||||
{
|
||||
return SQL_NAMESPACE;
|
||||
}
|
||||
}
|
|
@ -157,7 +157,7 @@ public class SchemaServiceImpl extends AbstractMybatisDataPermissionEntityServic
|
|||
*/
|
||||
protected void checkSaveUrlPermission(User user, String url) throws SaveSchemaUrlPermissionDeniedException
|
||||
{
|
||||
// TODO 新增数据源管控功能,管理员可设置URL白/黑名单,只允许新建名单允许的数据源
|
||||
// TODO 新增数据源防护功能,管理员可设置URL白/黑名单,只允许新建名单允许的数据源
|
||||
// throw new SaveSchemaUrlPermissionDeniedException();
|
||||
}
|
||||
|
||||
|
|
|
@ -836,7 +836,7 @@ DROP FUNCTION DATAGEAR_REPLACE;
|
|||
ALTER TABLE DATAGEAR_AUTHORIZATION DROP COLUMN AUTH_CREATE_USER_ID;
|
||||
|
||||
--2021-08-30
|
||||
--数据源管控
|
||||
--数据源防护
|
||||
|
||||
CREATE TABLE DATAGEAR_SCHEMA_GUARD
|
||||
(
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
A.AUTH_PRINCIPAL_TYPE AS ${_iq_}principalType${_iq_},
|
||||
A.AUTH_PERMISSION AS ${_iq_}permission${_iq_},
|
||||
A.AUTH_ENABLED AS ${_iq_}enabled${_iq_},
|
||||
A.AUTH_CREATE_TIME AS ${_iq_}ceateTime${_iq_},
|
||||
A.AUTH_CREATE_TIME AS ${_iq_}createTime${_iq_},
|
||||
(
|
||||
CASE A.AUTH_PRINCIPAL_TYPE
|
||||
WHEN 'ALL' THEN '${queryContext.principalAllLabel}'
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
<?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.SchemaGuard">
|
||||
|
||||
<insert id="insert">
|
||||
INSERT INTO DATAGEAR_SCHEMA_GUARD
|
||||
(
|
||||
SG_ID, SG_PATTERN, SG_PERMITTED, SG_PRIORITY, SG_ENABLED,
|
||||
SG_CREATE_TIME
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
#{entity.id}, #{entity.pattern}, #{entity.permitted, jdbcType=VARCHAR}, #{entity.priority}, #{entity.enabled, jdbcType=VARCHAR},
|
||||
#{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE DATAGEAR_SCHEMA_GUARD SET
|
||||
SG_PATTERN = #{entity.pattern},
|
||||
SG_PERMITTED = #{entity.permitted, jdbcType=VARCHAR},
|
||||
SG_PRIORITY = #{entity.priority},
|
||||
SG_ENABLED = #{entity.enabled, jdbcType=VARCHAR}
|
||||
WHERE
|
||||
SG_ID = #{entity.id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM DATAGEAR_SCHEMA_GUARD
|
||||
WHERE
|
||||
SG_ID = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getById" resultType="org.datagear.management.domain.SchemaGuard">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
T.${_iq_}id${_iq_} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="query" resultType="org.datagear.management.domain.SchemaGuard">
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQueryCount" resultType="int">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
</select>
|
||||
|
||||
<select id="pagingQuery" resultType="org.datagear.management.domain.SchemaGuard">
|
||||
<include refid="common.pagingQueryHead" />
|
||||
SELECT
|
||||
T.*
|
||||
FROM
|
||||
(<include refid="queryView" />) T
|
||||
WHERE
|
||||
<include refid="queryCondition" />
|
||||
<include refid="common.queryOrder" />
|
||||
<include refid="common.pagingQueryFoot" />
|
||||
</select>
|
||||
|
||||
<sql id="queryView">
|
||||
SELECT
|
||||
A.SG_ID AS ${_iq_}id${_iq_},
|
||||
A.SG_PATTERN AS ${_iq_}pattern${_iq_},
|
||||
A.SG_PERMITTED AS ${_iq_}permitted${_iq_},
|
||||
A.SG_PRIORITY AS ${_iq_}priority${_iq_},
|
||||
A.SG_ENABLED AS ${_iq_}enabled${_iq_},
|
||||
A.SG_CREATE_TIME AS ${_iq_}createTime${_iq_}
|
||||
FROM
|
||||
DATAGEAR_SCHEMA_GUARD A
|
||||
</sql>
|
||||
|
||||
<sql id="queryCondition">
|
||||
1 = 1
|
||||
<if test="queryKeyword != null">
|
||||
AND
|
||||
(
|
||||
${_iq_}pattern${_iq_} LIKE #{queryKeyword}
|
||||
)
|
||||
</if>
|
||||
</sql>
|
||||
</mapper>
|
|
@ -60,6 +60,7 @@ import org.datagear.management.service.DataSetResDirectoryService;
|
|||
import org.datagear.management.service.HtmlChartWidgetEntityService;
|
||||
import org.datagear.management.service.HtmlTplDashboardWidgetEntityService;
|
||||
import org.datagear.management.service.RoleService;
|
||||
import org.datagear.management.service.SchemaGuardService;
|
||||
import org.datagear.management.service.SchemaService;
|
||||
import org.datagear.management.service.SqlHistoryService;
|
||||
import org.datagear.management.service.UserService;
|
||||
|
@ -76,6 +77,7 @@ import org.datagear.management.service.impl.DataSetResDirectoryServiceImpl;
|
|||
import org.datagear.management.service.impl.HtmlChartWidgetEntityServiceImpl;
|
||||
import org.datagear.management.service.impl.HtmlTplDashboardWidgetEntityServiceImpl;
|
||||
import org.datagear.management.service.impl.RoleServiceImpl;
|
||||
import org.datagear.management.service.impl.SchemaGuardServiceImpl;
|
||||
import org.datagear.management.service.impl.SchemaServiceImpl;
|
||||
import org.datagear.management.service.impl.SqlHistoryServiceImpl;
|
||||
import org.datagear.management.service.impl.UserPasswordEncoder;
|
||||
|
@ -496,6 +498,14 @@ public class CoreConfig implements ApplicationListener<ContextRefreshedEvent>
|
|||
return bean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SchemaGuardService schemaGuardService()
|
||||
{
|
||||
SchemaGuardServiceImpl bean = new SchemaGuardServiceImpl(this.sqlSessionFactory(), this.mbSqlDialect());
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserService userService()
|
||||
{
|
||||
|
|
|
@ -289,6 +289,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
// 管理
|
||||
.antMatchers("/role/**").access(AUTH_ADMIN)
|
||||
|
||||
// 数据源防护
|
||||
.antMatchers("/schemaGuard/**").access(AUTH_ADMIN)
|
||||
|
||||
//
|
||||
.antMatchers("/login/**", "/register/**", "/resetPassword/**").access(AUTH_ANONYMOUS)
|
||||
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*/
|
||||
|
||||
package org.datagear.web.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.management.domain.SchemaGuard;
|
||||
import org.datagear.management.service.SchemaGuardService;
|
||||
import org.datagear.util.IDUtil;
|
||||
import org.datagear.web.util.OperationMessage;
|
||||
import org.datagear.web.vo.DataFilterPagingQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* {@linkplain SchemaGuard}控制器。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/schemaGuard")
|
||||
public class SchemaGuardController extends AbstractController
|
||||
{
|
||||
@Autowired
|
||||
private SchemaGuardService schemaGuardService;
|
||||
|
||||
public SchemaGuardController()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public SchemaGuardService getSchemaGuardService()
|
||||
{
|
||||
return schemaGuardService;
|
||||
}
|
||||
|
||||
public void setSchemaGuardService(SchemaGuardService schemaGuardService)
|
||||
{
|
||||
this.schemaGuardService = schemaGuardService;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
SchemaGuard schemaGuard = new SchemaGuard();
|
||||
|
||||
model.addAttribute("schemaGuard", schemaGuard);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "schemaGuard.addSchemaGuard");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
|
||||
return "/schemaGuard/schemaGuard_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody SchemaGuard schemaGuard)
|
||||
{
|
||||
checkSaveEntity(schemaGuard);
|
||||
|
||||
schemaGuard.setId(IDUtil.randomIdOnTime20());
|
||||
|
||||
this.schemaGuardService.add(schemaGuard);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request, schemaGuard);
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id)
|
||||
{
|
||||
SchemaGuard schemaGuard = this.schemaGuardService.getById(id);
|
||||
|
||||
if (schemaGuard == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
model.addAttribute("schemaGuard", schemaGuard);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "schemaGuard.editSchemaGuard");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveEdit");
|
||||
|
||||
return "/schemaGuard/schemaGuard_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveEdit", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> save(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody SchemaGuard schemaGuard)
|
||||
{
|
||||
checkSaveEntity(schemaGuard);
|
||||
|
||||
this.schemaGuardService.update(schemaGuard);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request, schemaGuard);
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id)
|
||||
{
|
||||
SchemaGuard schemaGuard = this.schemaGuardService.getById(id);
|
||||
|
||||
if (schemaGuard == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
model.addAttribute("schemaGuard", schemaGuard);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "schemaGuard.viewSchemaGuard");
|
||||
model.addAttribute(KEY_READONLY, true);
|
||||
|
||||
return "/schemaGuard/schemaGuard_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> delete(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody String[] ids)
|
||||
{
|
||||
this.schemaGuardService.deleteByIds(ids);
|
||||
|
||||
return buildOperationMessageDeleteSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/query")
|
||||
public String pagingQuery(HttpServletRequest request, HttpServletResponse response,
|
||||
org.springframework.ui.Model model)
|
||||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "schemaGuard.manageSchemaGuard");
|
||||
|
||||
return "/schemaGuard/schemaGuard_grid";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public List<SchemaGuard> pagingQueryData(HttpServletRequest request, HttpServletResponse response,
|
||||
final org.springframework.ui.Model springModel,
|
||||
@RequestBody(required = false) DataFilterPagingQuery pagingQueryParam) throws Exception
|
||||
{
|
||||
final DataFilterPagingQuery pagingQuery = inflateDataFilterPagingQuery(request, pagingQueryParam);
|
||||
|
||||
List<SchemaGuard> schemaGuards = this.schemaGuardService.query(pagingQuery);
|
||||
|
||||
return schemaGuards;
|
||||
}
|
||||
|
||||
protected void checkSaveEntity(SchemaGuard schemaGuard)
|
||||
{
|
||||
if (isBlank(schemaGuard.getPattern()))
|
||||
throw new IllegalInputException();
|
||||
}
|
||||
}
|
|
@ -253,7 +253,7 @@ main.manageDriverEntity=数据源驱动程序
|
|||
main.manageUser=用户
|
||||
main.addUser=添加用户
|
||||
main.manageRole=角色
|
||||
main.manageSchemaGuard=数据源管控
|
||||
main.manageSchemaGuard=数据源防护
|
||||
main.manageChartPlugin=图表插件
|
||||
main.uploadChartPlugin=上传图表插件
|
||||
main.manageDataSetResDirectory=数据集资源目录
|
||||
|
@ -931,4 +931,20 @@ dashboardGlobalRes.savePath.desc=文件存储路径,例如:global.js、css/s
|
|||
dashboardGlobalRes.autoUnzip=自动解压
|
||||
dashboardGlobalRes.autoUnzip.desc=如果文件是*.zip文件,则将其解压,如果未设置存储路径,将解压至资源根路径
|
||||
dashboardGlobalRes.resourceContent=资源内容
|
||||
dashboardGlobalRes.editResourceUnsupport=仅支持编辑文本类文件,比如:*.js、*.css、*.txt
|
||||
dashboardGlobalRes.editResourceUnsupport=仅支持编辑文本类文件,比如:*.js、*.css、*.txt
|
||||
|
||||
#数据源防护
|
||||
schemaGuard.manageSchemaGuard=管理数据源防护
|
||||
schemaGuard.addSchemaGuard=添加数据源防护
|
||||
schemaGuard.editSchemaGuard=编辑数据源防护
|
||||
schemaGuard.viewSchemaGuard=查看数据源防护
|
||||
schemaGuard.selectSchemaGuard=选择数据源防护
|
||||
schemaGuard.auth.resouceTypeLabel=数据源防护
|
||||
schemaGuard.pattern=URL模式
|
||||
schemaGuard.pattern.desc=数据源URL匹配模式,例如:* 所有URL;*192.168.1.1* 所有192.168.1.1的URL;192.168.1.1* 所有192.168.1.1开头的URL
|
||||
schemaGuard.permitted=准许
|
||||
schemaGuard.permitted.desc=是否准许创建匹配上述URL模式的数据源
|
||||
schemaGuard.priority=优先级
|
||||
schemaGuard.priority.desc=是否准许创建给定URL的数据源由与之匹配的最高优先级(或者最新创建的)的数据源防护决定
|
||||
schemaGuard.enabled=是否启用
|
||||
schemaGuard.createTime=创建时间
|
||||
|
|
|
@ -931,4 +931,19 @@ dashboardGlobalRes.savePath.desc=File save path, example: global.js, css/style.c
|
|||
dashboardGlobalRes.autoUnzip=Auto unzip
|
||||
dashboardGlobalRes.autoUnzip.desc=Auto unzip file if it is *.zip
|
||||
dashboardGlobalRes.resourceContent=Resource content
|
||||
dashboardGlobalRes.editResourceUnsupport=Only text file can edit, example: *.js, *.css, *.txt
|
||||
dashboardGlobalRes.editResourceUnsupport=Only text file can edit, example: *.js, *.css, *.txt
|
||||
|
||||
#数据源防护
|
||||
schemaGuard.manageSchemaGuard=Manage data source guard
|
||||
schemaGuard.addSchemaGuard=Add data source guard
|
||||
schemaGuard.editSchemaGuard=Edit data source guard
|
||||
schemaGuard.viewSchemaGuard=View data source guard
|
||||
schemaGuard.selectSchemaGuard=Select data source guard
|
||||
schemaGuard.pattern=URL Pattern
|
||||
schemaGuard.pattern.desc=Data source URL pattern, example: * All URL; *192.168.1.1* All URL contains 192.168.1.1; 192.168.1.1* All URL starts with 192.168.1.1
|
||||
schemaGuard.permitted=Permit
|
||||
schemaGuard.permitted.desc=Whether creating data source with URL matching the above URL is permitted
|
||||
schemaGuard.priority=Priority
|
||||
schemaGuard.priority.desc=The creating data source permit is determined by the highest priority (or most recently created) data source guard that matches it
|
||||
schemaGuard.enabled=Enable
|
||||
schemaGuard.createTime=Create time
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
<#--
|
||||
*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
-->
|
||||
<#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>
|
||||
<#include "../include/page_js_obj.ftl" >
|
||||
<div id="${pageId}" class="page-form page-form-schemaGuard">
|
||||
<form id="${pageId}-form" action="${contextPath}/schemaGuard/${formAction}" method="POST">
|
||||
<div class="form-head"></div>
|
||||
<div class="form-content">
|
||||
<input type="hidden" name="id" value="${(schemaGuard.id)!''}" />
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label title="<@spring.message code='schemaGuard.pattern.desc' />">
|
||||
<@spring.message code='schemaGuard.pattern' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="pattern" value="${(schemaGuard.pattern)!''}" class="ui-widget ui-widget-content" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label title="<@spring.message code='schemaGuard.permitted.desc' />">
|
||||
<@spring.message code='schemaGuard.permitted' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="schemaGuardPermitted-radios">
|
||||
<label for="${pageId}-schemaGuardPermittedYes"><@spring.message code='yes' /></label>
|
||||
<input type="radio" id="${pageId}-schemaGuardPermittedYes" name="permitted" value="true" <#if (schemaGuard.permitted)!false>checked="checked"</#if> />
|
||||
<label for="${pageId}-schemaGuardPermittedNo"><@spring.message code='no' /></label>
|
||||
<input type="radio" id="${pageId}-schemaGuardPermittedNo" name="permitted" value="false" <#if !((schemaGuard.permitted)!false)>checked="checked"</#if> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label title="<@spring.message code='schemaGuard.priority.desc' />">
|
||||
<@spring.message code='schemaGuard.priority' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="priority" class="ui-widget ui-widget-content" value="${(schemaGuard.priority)!''}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='schemaGuard.enabled' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="schemaGuardEnabled-radios">
|
||||
<label for="${pageId}-schemaGuardEnabledYes"><@spring.message code='yes' /></label>
|
||||
<input type="radio" id="${pageId}-schemaGuardEnabledYes" name="enabled" value="true" <#if (schemaGuard.enabled)!false>checked="checked"</#if> />
|
||||
<label for="${pageId}-schemaGuardEnabledNo"><@spring.message code='no' /></label>
|
||||
<input type="radio" id="${pageId}-schemaGuardEnabledNo" name="enabled" value="false" <#if !((schemaGuard.enabled)!false)>checked="checked"</#if> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-foot" style="text-align:center;">
|
||||
<#if !readonly>
|
||||
<input type="submit" value="<@spring.message code='save' />" class="recommended" />
|
||||
</#if>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<#include "../include/page_obj_form.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element());
|
||||
po.element("input[name='permitted']").checkboxradio({icon:false});
|
||||
po.element(".schemaGuardPermitted-radios").controlgroup();
|
||||
|
||||
po.element("input[name='enabled']").checkboxradio({icon:false});
|
||||
po.element(".schemaGuardEnabled-radios").controlgroup();
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/schemaGuard/" + action;
|
||||
};
|
||||
|
||||
<#if !readonly>
|
||||
po.form().validate(
|
||||
{
|
||||
rules :
|
||||
{
|
||||
pattern : "required",
|
||||
priority : "integer"
|
||||
},
|
||||
messages :
|
||||
{
|
||||
pattern : "<@spring.message code='validation.required' />",
|
||||
priority : "<@spring.message code='validation.integer' />"
|
||||
},
|
||||
submitHandler : function(form)
|
||||
{
|
||||
var data = $.formToJson(form);
|
||||
|
||||
$.ajaxJson($(form).attr("action"),
|
||||
{
|
||||
data: data,
|
||||
success : function(response)
|
||||
{
|
||||
po.pageParamCallAfterSave(true, response.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
errorPlacement : function(error, element)
|
||||
{
|
||||
error.appendTo(element.closest(".form-item-value"));
|
||||
}
|
||||
});
|
||||
</#if>
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,169 @@
|
|||
<#--
|
||||
*
|
||||
* Copyright 2018 datagear.tech
|
||||
*
|
||||
* Licensed under the LGPLv3 license:
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
-->
|
||||
<#include "../include/import_global.ftl">
|
||||
<#include "../include/html_doctype.ftl">
|
||||
<#--
|
||||
titleMessageKey 标题标签I18N关键字,不允许null
|
||||
selectOperation 是否选择操作,允许为null
|
||||
-->
|
||||
<#assign selectOperation=(selectOperation!false)>
|
||||
<#assign selectPageCss=(selectOperation?string('page-grid-select',''))>
|
||||
<#assign isMultipleSelect=(isMultipleSelect!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>
|
||||
<#include "../include/page_js_obj.ftl">
|
||||
<div id="${pageId}" class="page-grid ${selectPageCss} page-grid-hidden-foot page-grid-schemaGuard">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<#include "../include/page_obj_searchform.ftl">
|
||||
</div>
|
||||
<div class="operation">
|
||||
<#if selectOperation>
|
||||
<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_obj_grid.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element(".operation"));
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/schemaGuard/" + action;
|
||||
};
|
||||
|
||||
po.element("input[name=addButton]").click(function()
|
||||
{
|
||||
po.open(po.url("add"),
|
||||
{
|
||||
<#if selectOperation>
|
||||
pageParam:
|
||||
{
|
||||
afterSave: function(data)
|
||||
{
|
||||
po.pageParamCallSelect(true, data);
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=editButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"), { data : data });
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=viewButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
data : data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=deleteButton]").click(
|
||||
function()
|
||||
{
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
po.confirmDeleteEntities(po.url("delete"), rows);
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=confirmButton]").click(function()
|
||||
{
|
||||
<#if isMultipleSelect>
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
po.pageParamCallSelect(true, rows);
|
||||
});
|
||||
<#else>
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
po.pageParamCallSelect(true, row);
|
||||
});
|
||||
</#if>
|
||||
});
|
||||
|
||||
var columnPermitted = $.buildDataTablesColumnSimpleOption("<@spring.message code='schemaGuard.permitted' />", "permitted");
|
||||
columnPermitted.render = function(data, type, row, meta)
|
||||
{
|
||||
if(data == true)
|
||||
data = "<@spring.message code='yes' />";
|
||||
else
|
||||
data = "<@spring.message code='no' />";
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
var columnEnabled = $.buildDataTablesColumnSimpleOption("<@spring.message code='schemaGuard.enabled' />", "enabled");
|
||||
columnEnabled.render = function(data, type, row, meta)
|
||||
{
|
||||
if(data == true)
|
||||
data = "<@spring.message code='yes' />";
|
||||
else
|
||||
data = "<@spring.message code='no' />";
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "id", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='schemaGuard.pattern' />"), "pattern"),
|
||||
columnPermitted,
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='schemaGuard.priority' />", "priority"),
|
||||
columnEnabled,
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='schemaGuard.createTime' />", "createTime")
|
||||
];
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("queryData"));
|
||||
tableSettings.ordering = false;
|
||||
po.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue