forked from p81075629/datagear
添加看板全局资源管理功能
This commit is contained in:
parent
861180ec7c
commit
12c60654df
|
@ -122,6 +122,8 @@ public class CoreConfig implements InitializingBean
|
|||
|
||||
public static final String NAME_DASHBOARD_SHOW_HtmlTplDashboardWidgetHtmlRenderer = "htmlTplDashboardWidgetRenderer";
|
||||
|
||||
public static final String NAME_DASHBOARD_GLOBAL_RES_ROOT_DIRECTORY = "dashboardGlobalResRootDirectory";
|
||||
|
||||
private DataSourceConfig dataSourceConfig;
|
||||
|
||||
private Environment environment;
|
||||
|
@ -260,6 +262,12 @@ public class CoreConfig implements InitializingBean
|
|||
return createDirectory(environment.getProperty("directory.dashboard"), true);
|
||||
}
|
||||
|
||||
@Bean(NAME_DASHBOARD_GLOBAL_RES_ROOT_DIRECTORY)
|
||||
public File dashboardGlobalResRootDirectory()
|
||||
{
|
||||
return createDirectory(environment.getProperty("directory.dashboardGlobalRes"), true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public File resetPasswordCheckFileDirectory()
|
||||
{
|
||||
|
|
|
@ -253,6 +253,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||
// 管理
|
||||
.antMatchers("/dataSetResDirectory/**").access(AUTH_ADMIN)
|
||||
|
||||
// 看板全局资源
|
||||
// 选择
|
||||
.antMatchers("/dashboardGlobalRes/queryData")
|
||||
.access(disableAnonymous ? AUTH_USER_ADMIN_AND_DATA_ADMIN_ANALYST
|
||||
: AUTH_ANONYMOUS_USER_ADMIN_AND_DATA_ADMIN_ANALYST)
|
||||
// 管理
|
||||
.antMatchers("/dashboardGlobalRes/**").access(AUTH_ADMIN)
|
||||
|
||||
// 数据授权
|
||||
.antMatchers("/authorization/**").access(AUTH_USER_ADMIN)
|
||||
|
||||
|
|
|
@ -0,0 +1,424 @@
|
|||
/*
|
||||
* 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.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.datagear.util.FileUtil;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.datagear.web.config.CoreConfig;
|
||||
import org.datagear.web.util.KeywordMatcher;
|
||||
import org.datagear.web.util.OperationMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
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;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 看板全局资源控制器。
|
||||
*
|
||||
* @author datagear@163.com
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/dashboardGlobalRes")
|
||||
public class DashboardGlobalResController extends AbstractController
|
||||
{
|
||||
@Autowired
|
||||
@Qualifier(CoreConfig.NAME_DASHBOARD_GLOBAL_RES_ROOT_DIRECTORY)
|
||||
private File dashboardGlobalResRootDirectory;
|
||||
|
||||
@Autowired
|
||||
private File tempDirectory;
|
||||
|
||||
public DashboardGlobalResController()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public File getDashboardGlobalResRootDirectory()
|
||||
{
|
||||
return dashboardGlobalResRootDirectory;
|
||||
}
|
||||
|
||||
public void setDashboardGlobalResRootDirectory(File dashboardGlobalResRootDirectory)
|
||||
{
|
||||
this.dashboardGlobalResRootDirectory = dashboardGlobalResRootDirectory;
|
||||
}
|
||||
|
||||
public File getTempDirectory()
|
||||
{
|
||||
return tempDirectory;
|
||||
}
|
||||
|
||||
public void setTempDirectory(File tempDirectory)
|
||||
{
|
||||
this.tempDirectory = tempDirectory;
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dashboardGlobalRes.addDashboardGlobalRes");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
|
||||
return "/dashboardGlobalRes/dashboardGlobalRes_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody DashboardGlobalResAddForm form) throws Exception
|
||||
{
|
||||
if (isEmpty(form.getFilePath()))
|
||||
throw new IllegalInputException();
|
||||
|
||||
File file = FileUtil.getFile(this.tempDirectory, form.getFilePath());
|
||||
String savePath = form.getSavePath();
|
||||
|
||||
if (form.isAutoUnzip() && FileUtil.isExtension(file, "zip"))
|
||||
{
|
||||
File parent = this.dashboardGlobalResRootDirectory;
|
||||
if (!StringUtil.isEmpty(savePath))
|
||||
parent = FileUtil.getDirectory(this.dashboardGlobalResRootDirectory, savePath);
|
||||
|
||||
ZipInputStream in = null;
|
||||
|
||||
try
|
||||
{
|
||||
in = IOUtil.getZipInputStream(file);
|
||||
IOUtil.unzip(in, parent);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(in);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isEmpty(form.getSavePath()))
|
||||
throw new IllegalInputException();
|
||||
|
||||
File resFile = FileUtil.getFile(this.dashboardGlobalResRootDirectory, savePath);
|
||||
IOUtil.copy(file, resFile, false);
|
||||
}
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/upload", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public Map<String, Object> upload(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("file") MultipartFile multipartFile) throws Exception
|
||||
{
|
||||
File tmpDirectory = FileUtil.generateUniqueDirectory(this.tempDirectory);
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
File file = FileUtil.getFile(tmpDirectory, fileName);
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try
|
||||
{
|
||||
in = multipartFile.getInputStream();
|
||||
out = IOUtil.getOutputStream(file);
|
||||
IOUtil.write(in, out);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(in);
|
||||
IOUtil.close(out);
|
||||
}
|
||||
|
||||
String uploadFilePath = FileUtil.getRelativePath(this.tempDirectory, file);
|
||||
|
||||
Map<String, Object> results = new HashMap<>();
|
||||
results.put("filePath", uploadFilePath);
|
||||
results.put("fileName", fileName);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public String view(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("path") String path)
|
||||
{
|
||||
File file = FileUtil.getFile(this.dashboardGlobalResRootDirectory, path);
|
||||
|
||||
if (!file.exists())
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
DashboardGlobalResItem dashboardGlobalResItem = toDashboardGlobalResItem(file);
|
||||
|
||||
model.addAttribute("dashboardGlobalResItem", dashboardGlobalResItem);
|
||||
|
||||
return "/dashboardGlobalRes/dashboardGlobalRes_detail";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/download")
|
||||
public void downloadFile(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam("path") String path)
|
||||
throws Exception
|
||||
{
|
||||
File file = FileUtil.getFile(this.dashboardGlobalResRootDirectory, path);
|
||||
|
||||
if (!file.exists())
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
String responseFileName = toResponseAttachmentFileName(request, response, file.getName());
|
||||
|
||||
if (file.isDirectory())
|
||||
{
|
||||
if (!FileUtil.isExtension(responseFileName, "zip"))
|
||||
responseFileName += ".zip";
|
||||
}
|
||||
|
||||
response.setCharacterEncoding(IOUtil.CHARSET_UTF_8);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + responseFileName);
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
if (file.isDirectory())
|
||||
{
|
||||
ZipOutputStream zout = null;
|
||||
|
||||
try
|
||||
{
|
||||
zout = IOUtil.getZipOutputStream(out);
|
||||
IOUtil.writeFileToZipOutputStream(zout, file, file.getName());
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.flush(zout);
|
||||
IOUtil.close(zout);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IOUtil.write(file, out);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> delete(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody String[] paths)
|
||||
{
|
||||
for (int i = 0; i < paths.length; i++)
|
||||
{
|
||||
File file = FileUtil.getFile(this.dashboardGlobalResRootDirectory, paths[i]);
|
||||
FileUtil.deleteFile(file);
|
||||
}
|
||||
|
||||
return buildOperationMessageDeleteSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/query")
|
||||
public String query(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dashboardGlobalRes.manageDashboardGlobalRes");
|
||||
|
||||
return "/dashboardGlobalRes/dashboardGlobalRes_grid";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryData", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public List<DashboardGlobalResItem> queryData(HttpServletRequest request, HttpServletResponse response,
|
||||
final org.springframework.ui.Model springModel, @RequestBody(required = false) PagingQuery pagingQueryParam)
|
||||
throws Exception
|
||||
{
|
||||
final PagingQuery pagingQuery = inflatePagingQuery(request, pagingQueryParam);
|
||||
|
||||
return findDashboardGlobalResItems(pagingQuery.getKeyword());
|
||||
}
|
||||
|
||||
protected List<DashboardGlobalResItem> findDashboardGlobalResItems(String keyword)
|
||||
{
|
||||
List<File> files = new ArrayList<File>();
|
||||
listAllDescendentFiles(this.dashboardGlobalResRootDirectory, files);
|
||||
|
||||
List<DashboardGlobalResItem> resItems = new ArrayList<>(files.size());
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
DashboardGlobalResItem item = toDashboardGlobalResItem(file);
|
||||
resItems.add(item);
|
||||
}
|
||||
|
||||
if (StringUtil.isEmpty(keyword))
|
||||
return resItems;
|
||||
|
||||
return KeywordMatcher.<DashboardGlobalResItem>match(resItems, keyword,
|
||||
new KeywordMatcher.MatchValue<DashboardGlobalResItem>()
|
||||
{
|
||||
@Override
|
||||
public String[] get(DashboardGlobalResItem t)
|
||||
{
|
||||
return new String[] { t.getPath() };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected DashboardGlobalResItem toDashboardGlobalResItem(File file)
|
||||
{
|
||||
String path = FileUtil.trimPath(FileUtil.getRelativePath(this.dashboardGlobalResRootDirectory, file));
|
||||
|
||||
if (file.isDirectory() && !path.endsWith(FileUtil.PATH_SEPARATOR_SLASH))
|
||||
path += FileUtil.PATH_SEPARATOR_SLASH;
|
||||
|
||||
DashboardGlobalResItem item = new DashboardGlobalResItem(path);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出所有嵌套目录、文件夹。
|
||||
*
|
||||
* @param directory
|
||||
* @param files
|
||||
*/
|
||||
protected void listAllDescendentFiles(File directory, List<File> files)
|
||||
{
|
||||
if (!directory.exists())
|
||||
return;
|
||||
|
||||
File[] children = directory.listFiles();
|
||||
|
||||
Arrays.sort(children, new Comparator<File>()
|
||||
{
|
||||
@Override
|
||||
public int compare(File o1, File o2)
|
||||
{
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
for (File child : children)
|
||||
{
|
||||
files.add(child);
|
||||
|
||||
if (child.isDirectory())
|
||||
listAllDescendentFiles(child, files);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DashboardGlobalResAddForm implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private String fileName;
|
||||
|
||||
/** 是否自动解压zip文件 */
|
||||
private boolean autoUnzip = false;
|
||||
|
||||
/** 存储路径 */
|
||||
private String savePath = "";
|
||||
|
||||
public DashboardGlobalResAddForm()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DashboardGlobalResAddForm(String filePath, String fileName)
|
||||
{
|
||||
super();
|
||||
this.filePath = filePath;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getFileName()
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public boolean isAutoUnzip()
|
||||
{
|
||||
return autoUnzip;
|
||||
}
|
||||
|
||||
public void setAutoUnzip(boolean autoUnzip)
|
||||
{
|
||||
this.autoUnzip = autoUnzip;
|
||||
}
|
||||
|
||||
public String getSavePath()
|
||||
{
|
||||
return savePath;
|
||||
}
|
||||
|
||||
public void setSavePath(String savePath)
|
||||
{
|
||||
this.savePath = savePath;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DashboardGlobalResItem implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 相对路径 */
|
||||
private String path;
|
||||
|
||||
public DashboardGlobalResItem()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public DashboardGlobalResItem(String path)
|
||||
{
|
||||
super();
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,9 @@ directory.chartPlugin=${directory.root}/chartPlugin
|
|||
#看板主目录
|
||||
directory.dashboard=${directory.root}/dashboard
|
||||
|
||||
#看板全局资源主目录
|
||||
directory.dashboardGlobalRes=${directory.root}/dashboardGlobalRes
|
||||
|
||||
#数据集文件主目录
|
||||
directory.dataSet=${directory.root}/dataSet
|
||||
|
||||
|
|
|
@ -247,6 +247,7 @@ main.manageSchemaAuth=数据源授权
|
|||
main.manageChartPlugin=管理图表插件
|
||||
main.uploadChartPlugin=上传图表插件
|
||||
main.manageDataSetResDirectory=管理数据集资源目录
|
||||
main.manageDashboardGlobalRes=管理看板全局资源
|
||||
main.personalSet=个人设置
|
||||
main.changeTheme=切换肤色
|
||||
main.changeTheme.light=浅色
|
||||
|
@ -883,4 +884,14 @@ dataSetResDirectory.directory.desc=目录应是在服务器端已存在的,例
|
|||
dataSetResDirectory.desc=描述
|
||||
dataSetResDirectory.createUser=创建用户
|
||||
dataSetResDirectory.createTime=创建时间
|
||||
dataSetResDirectory.DataSetResDirectoryNotFoundException=目录[{0}]不存在
|
||||
dataSetResDirectory.DataSetResDirectoryNotFoundException=目录[{0}]不存在
|
||||
|
||||
#看板全局资源
|
||||
dashboardGlobalRes.manageDashboardGlobalRes=管理看板全局资源
|
||||
dashboardGlobalRes.addDashboardGlobalRes=添加看板全局资源
|
||||
dashboardGlobalRes.path=路径
|
||||
dashboardGlobalRes.selectFile=选择文件
|
||||
dashboardGlobalRes.savePath=存储路径
|
||||
dashboardGlobalRes.savePath.desc=文件存储路径,例如:global.js、css/style.css
|
||||
dashboardGlobalRes.autoUnzip=自动解压
|
||||
dashboardGlobalRes.autoUnzip.desc=如果文件是*.zip文件,则将其解压,如果未设置存储路径,将解压至资源根路径
|
||||
|
|
|
@ -247,6 +247,7 @@ main.manageSchemaAuth=Data source authorization
|
|||
main.manageChartPlugin=Manage chart plugin
|
||||
main.uploadChartPlugin=Upload chart plugin
|
||||
main.manageDataSetResDirectory=Manage data set directory
|
||||
main.manageDashboardGlobalRes=Manage dashboard global resource
|
||||
main.personalSet=Personal set
|
||||
main.changeTheme=Theme
|
||||
main.changeTheme.light=Light
|
||||
|
@ -884,3 +885,14 @@ dataSetResDirectory.desc=Description
|
|||
dataSetResDirectory.createUser=Creator
|
||||
dataSetResDirectory.createTime=Create time
|
||||
dataSetResDirectory.DataSetResDirectoryNotFoundException=Directory [{0}] inexistence
|
||||
|
||||
|
||||
#\u770B\u677F\u5168\u5C40\u8D44\u6E90
|
||||
dashboardGlobalRes.manageDashboardGlobalRes=Manage dashboard global resource
|
||||
dashboardGlobalRes.addDashboardGlobalRes=Add dashboard global resource
|
||||
dashboardGlobalRes.path=Path
|
||||
dashboardGlobalRes.selectFile=Select file
|
||||
dashboardGlobalRes.savePath=Save path
|
||||
dashboardGlobalRes.savePath.desc=File save path, example: global.js, css/style.css
|
||||
dashboardGlobalRes.autoUnzip=Auto unzip
|
||||
dashboardGlobalRes.autoUnzip.desc=Auto unzip file if it is *.zip
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
$fileLink[0].click();//$fileLink.click()无法触发下载动作
|
||||
*/
|
||||
|
||||
$.postOnForm(url, {"data" : options.data});
|
||||
$.postOnForm(url, {"data" : options.data, "target" : "_blank"});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -985,7 +985,7 @@
|
|||
return columnName.replace("\\.", ".");
|
||||
},
|
||||
|
||||
buildDataTablesColumnSimpleOption : function(title, data, hidden)
|
||||
buildDataTablesColumnSimpleOption : function(title, data, hidden, noTruncate)
|
||||
{
|
||||
var option =
|
||||
{
|
||||
|
@ -1000,6 +1000,14 @@
|
|||
defaultContent: "",
|
||||
};
|
||||
|
||||
if(noTruncate)
|
||||
{
|
||||
option.render = function(data, type, row, meta)
|
||||
{
|
||||
return $.escapeHtml(data);
|
||||
};
|
||||
}
|
||||
|
||||
return option;
|
||||
},
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ selectOperation 是否选择操作,允许为null
|
|||
<#if !isAjaxRequest>
|
||||
<div class="fill-parent">
|
||||
</#if>
|
||||
<div id="${pageId}" class="page-grid page-grid-chartPlugin">
|
||||
<div id="${pageId}" class="page-grid page-grid-hidden-foot page-grid-chartPlugin">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<#include "../../include/page_obj_searchform.html.ftl">
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<#--
|
||||
*
|
||||
* 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">
|
||||
<html>
|
||||
<head>
|
||||
<#include "../include/html_head.ftl">
|
||||
<title><#include "../include/html_title_app_name.ftl">查看看板全局资源</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="${pageId}" class="page-form page-form-dashboardGlobalResDetail">
|
||||
<form id="${pageId}-form" action="#" method="POST">
|
||||
<div class="form-head"></div>
|
||||
<div class="form-content">
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dashboardGlobalRes.path' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" class="ui-widget ui-widget-content" value="${dashboardGlobalResItem.path}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-foot" style="text-align:center;">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<#include "../include/page_js_obj.ftl" >
|
||||
<#include "../include/page_obj_form.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,181 @@
|
|||
<#--
|
||||
*
|
||||
* 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)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../include/html_head.ftl">
|
||||
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /></title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="${pageId}" class="page-form page-form-dashboardGlobalRes">
|
||||
<form id="${pageId}-form" action="${contextPath}/dashboardGlobalRes/${formAction}" method="POST">
|
||||
<div class="form-head"></div>
|
||||
<div class="form-content">
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dashboardGlobalRes.selectFile' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="hidden" name="filePath" value="" />
|
||||
<input type="hidden" name="fileName" value="" />
|
||||
<div class="ui-widget ui-corner-all ui-button fileinput-button">
|
||||
<@spring.message code='select' /><input type="file">
|
||||
</div>
|
||||
<div class="upload-file-info"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item form-item-savePath">
|
||||
<div class="form-item-label">
|
||||
<label title="<@spring.message code='dashboardGlobalRes.savePath.desc' />">
|
||||
<@spring.message code='dashboardGlobalRes.savePath' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="savePath" class="ui-widget ui-widget-content" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label title="<@spring.message code='dashboardGlobalRes.autoUnzip.desc' />">
|
||||
<@spring.message code='dashboardGlobalRes.autoUnzip' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="autoUnzip-radios">
|
||||
<label for="${pageId}-autoUnzip_true" title="">
|
||||
<@spring.message code='yes' />
|
||||
</label>
|
||||
<input type="radio" id="${pageId}-autoUnzip_true" name="autoUnzip" value="true" />
|
||||
<label for="${pageId}-autoUnzip_false" title="">
|
||||
<@spring.message code='no' />
|
||||
</label>
|
||||
<input type="radio" id="${pageId}-autoUnzip_false" name="autoUnzip" value="false" checked="checked" />
|
||||
</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_js_obj.ftl" >
|
||||
<#include "../include/page_obj_form.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element());
|
||||
po.element("input[name='autoUnzip']").checkboxradio({icon:false});
|
||||
po.element(".autoUnzip-radios").controlgroup();
|
||||
|
||||
po.isZipExtention = function(resName)
|
||||
{
|
||||
var reg = /\.(zip)$/gi;
|
||||
return (resName && reg.test(resName));
|
||||
};
|
||||
|
||||
po.element("input[name='autoUnzip']").on("change", function()
|
||||
{
|
||||
var val = $(this).val();
|
||||
var $savePath = po.element("input[name='savePath']");
|
||||
|
||||
if(val == "true")
|
||||
{
|
||||
var savePath = po.element("input[name='savePath']").val();
|
||||
|
||||
if(po.isZipExtention(savePath))
|
||||
$savePath.val(savePath.substring(0, savePath.length - 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
$savePath.val(po.element("input[name='fileName']").val());
|
||||
}
|
||||
});
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/dashboardGlobalRes/" + action;
|
||||
};
|
||||
|
||||
po.fileUploadInfo = function(){ return this.element(".upload-file-info"); };
|
||||
|
||||
po.element(".fileinput-button").fileupload(
|
||||
{
|
||||
url : po.url("upload"),
|
||||
paramName : "file",
|
||||
success : function(uploadResult, textStatus, jqXHR)
|
||||
{
|
||||
$.fileuploadsuccessHandlerForUploadInfo(po.fileUploadInfo(), false);
|
||||
po.element("input[name='filePath']").val(uploadResult.filePath);
|
||||
po.element("input[name='fileName']").val(uploadResult.fileName);
|
||||
po.element("input[name='savePath']").val(uploadResult.fileName);
|
||||
}
|
||||
})
|
||||
.bind('fileuploadadd', function (e, data)
|
||||
{
|
||||
po.element("input[name='filePath']").val("");
|
||||
po.element("input[name='fileName']").val("");
|
||||
po.element("input[name='savePath']").val("");
|
||||
po.form().validate().resetForm();
|
||||
$.fileuploadaddHandlerForUploadInfo(e, data, po.fileUploadInfo());
|
||||
})
|
||||
.bind('fileuploadprogressall', function (e, data)
|
||||
{
|
||||
$.fileuploadprogressallHandlerForUploadInfo(e, data, po.fileUploadInfo());
|
||||
});
|
||||
|
||||
$.validator.addMethod("uploadDashboardGlobalResFileRequired", function(value, element)
|
||||
{
|
||||
var thisForm = $(element).closest("form");
|
||||
var $filePath = $("input[name='filePath']", thisForm).val();
|
||||
|
||||
return ($filePath.length > 0);
|
||||
});
|
||||
|
||||
po.form().validate(
|
||||
{
|
||||
ignore : ".ignore",
|
||||
rules :
|
||||
{
|
||||
filePath : "uploadDashboardGlobalResFileRequired"
|
||||
},
|
||||
messages :
|
||||
{
|
||||
filePath : "<@spring.message code='validation.required' />"
|
||||
},
|
||||
submitHandler : function(form)
|
||||
{
|
||||
var formData = $.formToJson(form);
|
||||
|
||||
$.postJson("${contextPath}/dashboardGlobalRes/${formAction}", formData,
|
||||
function(response)
|
||||
{
|
||||
po.pageParamCallAfterSave(true, response.data);
|
||||
});
|
||||
},
|
||||
errorPlacement : function(error, element)
|
||||
{
|
||||
error.appendTo(element.closest(".form-item-value"));
|
||||
}
|
||||
});
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,122 @@
|
|||
<#--
|
||||
*
|
||||
* 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)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../include/html_head.ftl">
|
||||
<title><#include "../include/html_title_app_name.ftl"><@spring.message code='${titleMessageKey}' /></title>
|
||||
</head>
|
||||
<body class="fill-parent">
|
||||
<#if !isAjaxRequest>
|
||||
<div class="fill-parent">
|
||||
</#if>
|
||||
<div id="${pageId}" class="page-grid page-grid-hidden-foot page-grid-dashboardGlobalRes">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<#include "../include/page_obj_searchform.html.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="downloadButton" type="button" value="<@spring.message code='download' />" />
|
||||
<input name="viewButton" type="button" value="<@spring.message code='view' />" />
|
||||
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<table id="${pageId}-table" width="100%" class="hover stripe">
|
||||
</table>
|
||||
</div>
|
||||
<div class="foot">
|
||||
<div class="pagination-wrapper">
|
||||
<div id="${pageId}-pagination" class="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<#if !isAjaxRequest>
|
||||
</div>
|
||||
</#if>
|
||||
<#include "../include/page_js_obj.ftl">
|
||||
<#include "../include/page_obj_searchform_js.ftl">
|
||||
<#include "../include/page_obj_grid.ftl">
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element(".operation"));
|
||||
|
||||
po.url = function(action)
|
||||
{
|
||||
return "${contextPath}/dashboardGlobalRes/" + action;
|
||||
};
|
||||
|
||||
po.element("input[name=addButton]").click(function()
|
||||
{
|
||||
po.open(po.url("add"));
|
||||
});
|
||||
|
||||
po.element("input[name=downloadButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"path" : row.path};
|
||||
|
||||
po.open(po.url("download"),
|
||||
{
|
||||
target: "_file",
|
||||
data : data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=viewButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"path" : row.path};
|
||||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
data : data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=deleteButton]").click(
|
||||
function()
|
||||
{
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
po.confirmDeleteEntities(po.url("delete"), rows, "path");
|
||||
});
|
||||
});
|
||||
|
||||
var tableColumns = [
|
||||
$.buildDataTablesColumnSimpleOption("<@spring.message code='id' />", "path", true),
|
||||
$.buildDataTablesColumnSimpleOption($.buildDataTablesColumnTitleSearchable("<@spring.message code='dashboardGlobalRes.path' />"), "path", false, true)
|
||||
];
|
||||
|
||||
var tableSettings = po.buildDataTableSettingsAjax(tableColumns, po.url("queryData"));
|
||||
tableSettings.ordering = false;
|
||||
po.initDataTable(tableSettings);
|
||||
po.bindResizeDataTable();
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -895,6 +895,12 @@ ${detectNewVersionScript?no_esc}
|
|||
$.setGridPageHeightOption(options);
|
||||
po.open(contextPath+"/dataSetResDirectory/pagingQuery", options);
|
||||
}
|
||||
else if($item.hasClass("system-set-manageDashboardGlobalRes"))
|
||||
{
|
||||
var options = {};
|
||||
$.setGridPageHeightOption(options);
|
||||
po.open(contextPath+"/dashboardGlobalRes/query", options);
|
||||
}
|
||||
else if($item.hasClass("system-set-rold-manage"))
|
||||
{
|
||||
var options = {};
|
||||
|
@ -1449,6 +1455,7 @@ ${detectNewVersionScript?no_esc}
|
|||
<li class="system-set-authorization-manage"><a href="javascript:void(0);"><@spring.message code='main.manageSchemaAuth' /></a></li>
|
||||
<li class="ui-widget-header"></li>
|
||||
<li class="system-set-dataSetResDirectory-manage"><a href="javascript:void(0);"><@spring.message code='main.manageDataSetResDirectory' /></a></li>
|
||||
<li class="system-set-manageDashboardGlobalRes"><a href="javascript:void(0);"><@spring.message code='main.manageDashboardGlobalRes' /></a></li>
|
||||
<li class="system-set-chartPlugin-manage"><a href="javascript:void(0);"><@spring.message code='main.manageChartPlugin' /></a></li>
|
||||
<!--
|
||||
<li class="system-set-chartPlugin-upload"><a href="javascript:void(0);"><@spring.message code='main.uploadChartPlugin' /></a></li>
|
||||
|
|
Loading…
Reference in New Issue