forked from p81075629/datagear
看板添加导出功能,调整看板列表页面按钮布局
This commit is contained in:
parent
b6df44fa69
commit
4f9530b0b3
|
@ -1,6 +1,6 @@
|
|||
下一主版本:
|
||||
|
||||
导出看板功能;
|
||||
ok 导出看板功能;
|
||||
数据分析添加项目概念,用于分组管理数据集、图表、看板;
|
||||
表格图表轮播效果;
|
||||
看板展示页面可显示数据集结果数据;
|
||||
|
|
|
@ -111,6 +111,15 @@ public interface TemplateDashboardWidgetResManager
|
|||
*/
|
||||
void copyFrom(String id, File directory) throws IOException;
|
||||
|
||||
/**
|
||||
* 将指定{@linkplain TemplateDashboardWidget#getId()}的所有资源拷贝至目标目录。
|
||||
*
|
||||
* @param id
|
||||
* @param directory
|
||||
* @throws IOException
|
||||
*/
|
||||
void copyTo(String id, File directory) throws IOException;
|
||||
|
||||
/**
|
||||
* 是否包含指定名称的资源。
|
||||
*
|
||||
|
|
|
@ -148,6 +148,13 @@ public class FileTemplateDashboardWidgetResManager extends AbstractTemplateDashb
|
|||
IOUtil.copy(directory, myDirectory, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTo(String id, File directory) throws IOException
|
||||
{
|
||||
File myDirectory = FileUtil.getDirectory(this.rootDirectory, id);
|
||||
IOUtil.copy(myDirectory, directory, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsResource(String id, String name)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.datagear.web.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -17,6 +18,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.datagear.management.service.DataPermissionEntityService;
|
||||
import org.datagear.persistence.PagingQuery;
|
||||
import org.datagear.util.IOUtil;
|
||||
import org.datagear.util.JDBCCompatiblity;
|
||||
import org.datagear.util.StringUtil;
|
||||
import org.datagear.web.OperationMessage;
|
||||
|
@ -619,6 +621,24 @@ public abstract class AbstractController
|
|||
return pathInfo.substring(index + pathPrefix.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件名转换为作为响应下载文件名。
|
||||
* <p>
|
||||
* 此方法会对处理中文乱码问题。
|
||||
* </p>
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param fileName
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
protected String toResponseAttachmentFileName(HttpServletRequest request, HttpServletResponse response,
|
||||
String fileName) throws IOException
|
||||
{
|
||||
return new String(fileName.getBytes(RESPONSE_ENCODING), IOUtil.CHARSET_ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断对象、字符串、数组、集合、Map是否为空。
|
||||
*
|
||||
|
|
|
@ -183,7 +183,8 @@ public class ChartPluginController extends AbstractChartPluginAwareController
|
|||
public void download(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String[] ids) throws Exception
|
||||
{
|
||||
response.addHeader("Content-Disposition", "attachment;filename=chartPlugins.zip");
|
||||
response.addHeader("Content-Disposition",
|
||||
"attachment;filename=" + toResponseAttachmentFileName(request, response, "chartPlugins.zip"));
|
||||
response.setContentType("application/octet-stream");
|
||||
|
||||
ZipOutputStream zout = IOUtil.getZipOutputStream(response.getOutputStream());
|
||||
|
|
|
@ -16,6 +16,7 @@ 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.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -551,6 +552,40 @@ public class DashboardController extends AbstractDataAnalysisController implemen
|
|||
return "/analysis/dashboard/dashboard_form";
|
||||
}
|
||||
|
||||
@RequestMapping("/export")
|
||||
public void export(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id) throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
HtmlTplDashboardWidgetEntity dashboard = this.htmlTplDashboardWidgetEntityService.getById(user, id);
|
||||
|
||||
if (dashboard == null)
|
||||
throw new RecordNotFoundException();
|
||||
|
||||
TemplateDashboardWidgetResManager dashboardWidgetResManager = this.htmlTplDashboardWidgetEntityService
|
||||
.getHtmlTplDashboardWidgetRenderer().getTemplateDashboardWidgetResManager();
|
||||
|
||||
File tmpDirectory = FileUtil.generateUniqueDirectory(this.tempDirectory);
|
||||
dashboardWidgetResManager.copyTo(dashboard.getId(), tmpDirectory);
|
||||
|
||||
response.addHeader("Content-Disposition",
|
||||
"attachment;filename=" + toResponseAttachmentFileName(request, response, dashboard.getName() + ".zip"));
|
||||
response.setContentType("application/octet-stream");
|
||||
|
||||
ZipOutputStream zout = IOUtil.getZipOutputStream(response.getOutputStream());
|
||||
|
||||
try
|
||||
{
|
||||
IOUtil.writeFileToZipOutputStream(zout, tmpDirectory, "");
|
||||
}
|
||||
finally
|
||||
{
|
||||
zout.flush();
|
||||
zout.close();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> delete(HttpServletRequest request, HttpServletResponse response,
|
||||
|
|
|
@ -686,8 +686,9 @@ public class DataController extends AbstractSchemaConnTableController
|
|||
}
|
||||
}.execute();
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + columnName + "");
|
||||
response.setCharacterEncoding(IOUtil.CHARSET_UTF_8);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, columnName));
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
@ -735,7 +736,8 @@ public class DataController extends AbstractSchemaConnTableController
|
|||
@RequestParam("file") String fileName) throws Throwable
|
||||
{
|
||||
response.setCharacterEncoding(RESPONSE_ENCODING);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + "");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, fileName));
|
||||
|
||||
OutputStream out = null;
|
||||
|
||||
|
|
|
@ -1319,7 +1319,7 @@ public class DataExchangeController extends AbstractSchemaConnController
|
|||
{
|
||||
response.setCharacterEncoding(RESPONSE_ENCODING);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + new String(fileName.getBytes(RESPONSE_ENCODING), "iso-8859-1") + "");
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, fileName));
|
||||
|
||||
File directory = getTempDataExchangeDirectory(dataExchangeId, true);
|
||||
File file = FileUtil.getFile(directory, fileName);
|
||||
|
@ -1345,7 +1345,7 @@ public class DataExchangeController extends AbstractSchemaConnController
|
|||
{
|
||||
response.setCharacterEncoding(RESPONSE_ENCODING);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + new String(fileName.getBytes(RESPONSE_ENCODING), "iso-8859-1"));
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, fileName));
|
||||
|
||||
File directory = getTempDataExchangeDirectory(dataExchangeId, true);
|
||||
|
||||
|
|
|
@ -505,10 +505,10 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
File entityFile = FileUtil.getFile(dataSetDirectory, dataSetEntity.getFileName());
|
||||
|
||||
String displayName = dataSetEntity.getDisplayName();
|
||||
displayName = new String(displayName.getBytes("UTF-8"), "ISO-8859-1");
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + displayName + "");
|
||||
response.setCharacterEncoding(IOUtil.CHARSET_UTF_8);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, displayName));
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
IOUtil.write(entityFile, out);
|
||||
|
|
|
@ -245,7 +245,8 @@ public class DriverEntityController extends AbstractController
|
|||
public void export(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(value = "id", required = false) String[] driverEntityIds) throws Exception
|
||||
{
|
||||
response.addHeader("Content-Disposition", "attachment;filename=drivers.zip");
|
||||
response.addHeader("Content-Disposition",
|
||||
"attachment;filename=" + toResponseAttachmentFileName(request, response, "drivers.zip"));
|
||||
response.setContentType("application/octet-stream");
|
||||
|
||||
ZipOutputStream zout = IOUtil.getZipOutputStream(response.getOutputStream());
|
||||
|
@ -393,8 +394,9 @@ public class DriverEntityController extends AbstractController
|
|||
{
|
||||
DriverEntity driverEntity = this.driverEntityManager.get(id);
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + "");
|
||||
response.setCharacterEncoding(IOUtil.CHARSET_UTF_8);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, fileName));
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
if (driverEntity != null)
|
||||
|
|
|
@ -285,8 +285,9 @@ public class SqlpadController extends AbstractSchemaConnController
|
|||
if (!blobFile.exists())
|
||||
throw new FileNotFoundException(value);
|
||||
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=BLOB");
|
||||
response.setCharacterEncoding(IOUtil.CHARSET_UTF_8);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + toResponseAttachmentFileName(request, response, "BLOB"));
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
|
|
@ -753,7 +753,7 @@ dashboard.editDashboard=编辑看板
|
|||
dashboard.viewDashboard=查看看板
|
||||
dashboard.selectDashboard=选择看板
|
||||
dashboard.importDashboard=导入看板
|
||||
dashboard.name=名称
|
||||
dashboard.name=看板名称
|
||||
dashboard.template=模板内容
|
||||
dashboard.templateEncoding=HTML模板编码
|
||||
dashboard.templateName=模板文件名
|
||||
|
@ -762,7 +762,7 @@ dashboard.createTime=创建时间
|
|||
dashboard.show=展示
|
||||
dashboard.import.selectFile=选择文件
|
||||
dashboard.import.desc=文件格式应为:*.html、*.htm、*.zip
|
||||
dashboard.import.template.desc=多个模板以英文逗号(,)分隔
|
||||
dashboard.import.templateName.desc=导入文件中作为看板模板的文件名,应是*.html、*.htm文件,多个模板以英文逗号(,)分隔
|
||||
dashboard.import.validation.importDashboardFileRequired=请选择看板文件
|
||||
dashboard.import.templateFileNotExists=导入看板文件中没有找到[{0}]模板文件
|
||||
dashboard.typeChartIdHere=在此输入图表ID
|
||||
|
|
|
@ -26,14 +26,19 @@ selectOperation 是否选择操作,允许为null
|
|||
<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="importButton" type="button" value="<@spring.message code='import' />" />
|
||||
<div class="addGroup">
|
||||
<input name="addButton" type="button" value="<@spring.message code='add' />" />
|
||||
<select class="addGroupSelect">
|
||||
<option value="importDashboard"><@spring.message code='import' /></option>
|
||||
</select>
|
||||
</div>
|
||||
<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="exportButton" type="button" value="<@spring.message code='export' />" />
|
||||
<input name="deleteButton" type="button" value="<@spring.message code='delete' />" />
|
||||
</#if>
|
||||
</div>
|
||||
|
@ -58,8 +63,25 @@ selectOperation 是否选择操作,允许为null
|
|||
(function(po)
|
||||
{
|
||||
$.initButtons(po.element(".operation"));
|
||||
po.element(".addGroupSelect").selectmenu(
|
||||
{
|
||||
appendTo: po.element(),
|
||||
classes:
|
||||
{
|
||||
"ui-selectmenu-button": "ui-button-icon-only splitbutton-select",
|
||||
"ui-selectmenu-menu": "ui-widget-shadow ui-widget ui-widget-content"
|
||||
},
|
||||
select: function(event, ui)
|
||||
{
|
||||
var action = $(ui.item).attr("value");
|
||||
|
||||
if(action == "importDashboard")
|
||||
po.open(po.url("import"));
|
||||
}
|
||||
});
|
||||
po.element(".addGroup").controlgroup();
|
||||
po.initDataFilter();
|
||||
|
||||
|
||||
po.currentUser = <@writeJson var=currentUser />;
|
||||
|
||||
po.url = function(action)
|
||||
|
@ -84,11 +106,6 @@ selectOperation 是否选择操作,允许为null
|
|||
});
|
||||
});
|
||||
|
||||
po.element("input[name=importButton]").click(function()
|
||||
{
|
||||
po.open(po.url("import"));
|
||||
});
|
||||
|
||||
po.element("input[name=editButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
|
@ -138,6 +155,16 @@ selectOperation 是否选择操作,允许为null
|
|||
window.open(showUrl, showUrl);
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=exportButton]").click(function()
|
||||
{
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("export"), { target: "_blank", data : data });
|
||||
});
|
||||
});
|
||||
|
||||
po.element("input[name=deleteButton]").click(
|
||||
function()
|
||||
|
|
|
@ -13,11 +13,13 @@
|
|||
<input type="hidden" name="dashboardFileName" value="" />
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dashboard.import.selectFile' /></label>
|
||||
<label title="<@spring.message code='dashboard.import.desc' />">
|
||||
<@spring.message code='dashboard.import.selectFile' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="hidden" name="inputForValidate" value="" />
|
||||
<div class="fileinput-button" title="<@spring.message code='dashboard.import.desc' />">
|
||||
<div class="fileinput-button">
|
||||
<@spring.message code='select' /><input type="file" accept=".html, .htm, .zip" class="ignore">
|
||||
</div>
|
||||
<div class="upload-file-info"></div>
|
||||
|
@ -33,10 +35,12 @@
|
|||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dashboard.templateName' /></label>
|
||||
<label title="<@spring.message code='dashboard.import.templateName.desc' />">
|
||||
<@spring.message code='dashboard.templateName' />
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="template" value="" class="ui-widget ui-widget-content" placeholder="<@spring.message code='dashboard.import.template.desc' />" />
|
||||
<input type="text" name="template" value="" class="ui-widget ui-widget-content" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue