forked from p81075629/datagear
完善看板管理功能
This commit is contained in:
parent
25f188add6
commit
7497a0869d
|
@ -33,10 +33,25 @@ import org.datagear.util.IOUtil;
|
|||
* 此类从上述格式的输入流解析{@linkplain JsDefContent}对象,其中:
|
||||
* </p>
|
||||
* <p>
|
||||
* {@linkplain JsDefContent#getPluginJson()}为上述格式中将<code>chartRender: {...}</code>替换为<code>chartRender: {}</code>的内容。
|
||||
* {@linkplain JsDefContent#getPluginJson()}为上述格式中将
|
||||
* </p>
|
||||
* <p>
|
||||
* {@linkplain JsDefContent#getPluginChartRender()}为上述格式中<code>chartRender</code>属性值部分的内容:<code>{...}</code>
|
||||
* <code>chartRender: {...}</code>
|
||||
* </p>
|
||||
* <p>
|
||||
* 替换为
|
||||
* </p>
|
||||
* <p>
|
||||
* <code>chartRender: {}</code>
|
||||
* </p>
|
||||
* <p>
|
||||
* 的内容。
|
||||
* </p>
|
||||
* <p>
|
||||
* {@linkplain JsDefContent#getPluginChartRender()}为上述格式中<code>chartRender</code>属性值的内容:
|
||||
* </p>
|
||||
* <p>
|
||||
* <code>{...}</code>
|
||||
* </p>
|
||||
*
|
||||
* @author datagear@163.com
|
||||
|
|
|
@ -341,6 +341,13 @@ public class HtmlChartPluginLoader
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从指定目录加载单个{@linkplain HtmlChartPlugin},返回{@code null}表示文件不合法。
|
||||
*
|
||||
* @param directory
|
||||
* @return
|
||||
* @throws HtmlChartPluginLoadException
|
||||
*/
|
||||
protected HtmlChartPlugin<?> loadSingleForDirectory(File directory) throws HtmlChartPluginLoadException
|
||||
{
|
||||
File chartFile = new File(directory, FILE_NAME_PLUGIN);
|
||||
|
@ -370,6 +377,9 @@ public class HtmlChartPluginLoader
|
|||
plugin.setChartRenderer(new StringJsChartRenderer(jsDefContent.getPluginChartRender()));
|
||||
|
||||
plugin.setIcons(toBytesIconsInDirectory(directory, plugin.getIcons()));
|
||||
|
||||
if (StringUtil.isEmpty(plugin.getId()) || StringUtil.isEmpty(plugin.getNameLabel()))
|
||||
plugin = null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -90,6 +90,24 @@ public abstract class AbstractController
|
|||
this.classDataConverter = classDataConverter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置{@code isMultipleSelect}属性。
|
||||
*
|
||||
* @param request
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
protected boolean setIsMultipleSelectAttribute(HttpServletRequest request, org.springframework.ui.Model model)
|
||||
{
|
||||
boolean isMultipleSelect = false;
|
||||
if (request.getParameter("multiple") != null)
|
||||
isMultipleSelect = true;
|
||||
|
||||
model.addAttribute("isMultipleSelect", isMultipleSelect);
|
||||
|
||||
return isMultipleSelect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取{@linkplain PagingQuery}。
|
||||
*
|
||||
|
|
|
@ -214,6 +214,7 @@ public class ChartController extends AbstractChartPluginAwareController
|
|||
{
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.selectChart");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
setIsMultipleSelectAttribute(request, model);
|
||||
|
||||
return "/analysis/chart/chart_grid";
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.datagear.analysis.support.html.HtmlRenderAttributes;
|
|||
import org.datagear.analysis.support.html.HtmlRenderContext;
|
||||
import org.datagear.analysis.support.html.HtmlRenderContext.WebContext;
|
||||
import org.datagear.analysis.support.html.HtmlTplDashboardWidget;
|
||||
import org.datagear.analysis.support.html.HtmlTplDashboardWidgetHtmlRenderer;
|
||||
import org.datagear.analysis.support.html.HtmlTplDashboardWidgetRenderer;
|
||||
import org.datagear.management.domain.HtmlTplDashboardWidgetEntity;
|
||||
import org.datagear.management.domain.User;
|
||||
import org.datagear.management.service.HtmlTplDashboardWidgetEntityService;
|
||||
|
@ -110,40 +110,69 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
dashboard.setTemplate(HtmlTplDashboardWidgetEntity.DEFAULT_TEMPLATE);
|
||||
dashboard.setTemplateEncoding(HtmlTplDashboardWidget.DEFAULT_TEMPLATE_ENCODING);
|
||||
|
||||
String templateContent = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"" + dashboard.getTemplateEncoding()
|
||||
+ "\">\n</head>\n<body>\n\t<div " + HtmlTplDashboardWidgetHtmlRenderer.DEFAULT_ATTR_NAME_CHART_WIDGET
|
||||
+ "=\"" + getMessage(request, "dashboard.typeChartIdHere") + "\"></div>\n</body>\n</html>";
|
||||
HtmlTplDashboardWidgetRenderer<HtmlRenderContext> renderer = getHtmlTplDashboardWidgetEntityService()
|
||||
.getHtmlTplDashboardWidgetRenderer();
|
||||
String dashbaordStyleName = renderer.getDashboardStyleName();
|
||||
String chartStyleName = renderer.getChartStyleName();
|
||||
|
||||
String templateContent = "<!DOCTYPE html>\n"
|
||||
//
|
||||
+ "<html>\n"
|
||||
//
|
||||
+ "<head>\n"
|
||||
//
|
||||
+ "<meta charset=\"" + dashboard.getTemplateEncoding() + "\">\n"
|
||||
//
|
||||
+ "<style type=\"text/css\">\n"
|
||||
//
|
||||
+ "." + dashbaordStyleName + "{\n"
|
||||
//
|
||||
+ " position: absolute;\n"
|
||||
//
|
||||
+ " left: 0px;\n"
|
||||
//
|
||||
+ " right: 0px;\n"
|
||||
//
|
||||
+ " top: 0px;\n"
|
||||
//
|
||||
+ " bottom: 0px;\n"
|
||||
//
|
||||
+ "}\n"
|
||||
//
|
||||
+ "." + chartStyleName + "{\n"
|
||||
//
|
||||
+ " display: inline-block;\n"
|
||||
//
|
||||
+ " min-width: 30%;\n"
|
||||
//
|
||||
+ " min-height: 30%;\n"
|
||||
//
|
||||
+ " margin-left: 2.3%;\n"
|
||||
//
|
||||
+ " margin-bottom: 1em;\n"
|
||||
//
|
||||
+ "}\n"
|
||||
//
|
||||
+ "</style>\n"
|
||||
//
|
||||
+ "</head>\n"
|
||||
//
|
||||
+ "<body class=\"" + dashbaordStyleName + "\">\n"
|
||||
//
|
||||
+ "\n"
|
||||
//
|
||||
+ "</body>\n"
|
||||
//
|
||||
+ "</html>";
|
||||
|
||||
model.addAttribute("dashboard", dashboard);
|
||||
model.addAttribute("templateContent", templateContent);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dashboard.addDashboard");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveAdd");
|
||||
model.addAttribute(KEY_FORM_ACTION, "save");
|
||||
|
||||
return "/analysis/dashboard/dashboard_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveAdd", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveAdd(HttpServletRequest request, HttpServletResponse response,
|
||||
HtmlTplDashboardWidgetEntity dashboard, @RequestParam("templateContent") String templateContent)
|
||||
throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
checkSaveEntity(dashboard);
|
||||
|
||||
dashboard.setId(IDUtil.uuid());
|
||||
dashboard.setCreateUser(user);
|
||||
dashboard.setTemplateEncoding(resolveTemplateEncoding(templateContent));
|
||||
|
||||
boolean add = this.htmlTplDashboardWidgetEntityService.add(user, dashboard);
|
||||
|
||||
if (add)
|
||||
saveTemplateContent(dashboard, templateContent);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
public String edit(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model,
|
||||
@RequestParam("id") String id) throws Exception
|
||||
|
@ -158,32 +187,46 @@ public class DashboardController extends AbstractDataAnalysisController
|
|||
model.addAttribute("dashboard", dashboard);
|
||||
readAndSetTemplateContent(dashboard, model);
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dashboard.editDashboard");
|
||||
model.addAttribute(KEY_FORM_ACTION, "saveEdit");
|
||||
model.addAttribute(KEY_FORM_ACTION, "save");
|
||||
|
||||
return "/analysis/dashboard/dashboard_form";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveEdit", produces = CONTENT_TYPE_JSON)
|
||||
@RequestMapping(value = "/save", produces = CONTENT_TYPE_JSON)
|
||||
@ResponseBody
|
||||
public ResponseEntity<OperationMessage> saveEdit(HttpServletRequest request, HttpServletResponse response,
|
||||
public ResponseEntity<OperationMessage> save(HttpServletRequest request, HttpServletResponse response,
|
||||
HtmlTplDashboardWidgetEntity dashboard, @RequestParam("templateContent") String templateContent)
|
||||
throws Exception
|
||||
{
|
||||
User user = WebUtils.getUser(request, response);
|
||||
|
||||
if (isEmpty(dashboard.getTemplate()))
|
||||
dashboard.setTemplate(HtmlTplDashboardWidgetEntity.DEFAULT_TEMPLATE);
|
||||
|
||||
checkSaveEntity(dashboard);
|
||||
|
||||
dashboard.setTemplateEncoding(resolveTemplateEncoding(templateContent));
|
||||
boolean save = false;
|
||||
|
||||
boolean updated = this.htmlTplDashboardWidgetEntityService.update(user, dashboard);
|
||||
if (isEmpty(dashboard.getId()))
|
||||
{
|
||||
dashboard.setId(IDUtil.uuid());
|
||||
dashboard.setCreateUser(user);
|
||||
dashboard.setTemplateEncoding(resolveTemplateEncoding(templateContent));
|
||||
save = this.htmlTplDashboardWidgetEntityService.add(user, dashboard);
|
||||
}
|
||||
else
|
||||
{
|
||||
dashboard.setTemplateEncoding(resolveTemplateEncoding(templateContent));
|
||||
save = this.htmlTplDashboardWidgetEntityService.update(user, dashboard);
|
||||
}
|
||||
|
||||
if (updated)
|
||||
if (save)
|
||||
saveTemplateContent(dashboard, templateContent);
|
||||
|
||||
return buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("id", dashboard.getId());
|
||||
|
||||
ResponseEntity<OperationMessage> responseEntity = buildOperationMessageSaveSuccessResponseEntity(request);
|
||||
responseEntity.getBody().setData(data);
|
||||
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
@RequestMapping("/import")
|
||||
|
|
|
@ -278,13 +278,9 @@ public class DataSetController extends AbstractSchemaConnController
|
|||
@RequestMapping(value = "/select")
|
||||
public String select(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
|
||||
{
|
||||
boolean isMultipleSelect = false;
|
||||
if (request.getParameter("multiple") != null)
|
||||
isMultipleSelect = true;
|
||||
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "dataSet.selectDataSet");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
model.addAttribute("isMultipleSelect", isMultipleSelect);
|
||||
setIsMultipleSelectAttribute(request, model);
|
||||
|
||||
return "/analysis/dataSet/dataSet_grid";
|
||||
}
|
||||
|
|
|
@ -191,13 +191,9 @@ public class UserController extends AbstractController
|
|||
@RequestMapping(value = "/select")
|
||||
public String select(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
|
||||
{
|
||||
boolean isMultipleSelect = false;
|
||||
if (request.getParameter("multiple") != null)
|
||||
isMultipleSelect = true;
|
||||
|
||||
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "user.selectUser");
|
||||
model.addAttribute(KEY_SELECTONLY, true);
|
||||
model.addAttribute("isMultipleSelect", isMultipleSelect);
|
||||
setIsMultipleSelectAttribute(request, model);
|
||||
|
||||
return "/user/user_grid";
|
||||
}
|
||||
|
|
|
@ -664,6 +664,8 @@ dashboard.import.desc=\u6587\u4EF6\u683C\u5F0F\u5E94\u4E3A\uFF1A*.html\u3001*.ht
|
|||
dashboard.import.validation.importDashboardFileRequired=\u8BF7\u9009\u62E9\u770B\u677F\u6587\u4EF6
|
||||
dashboard.import.templateFileNotExists=\u6A21\u677F\u6587\u4EF6[{0}]\u4E0D\u5B58\u5728
|
||||
dashboard.typeChartIdHere=\u5728\u6B64\u8F93\u5165\u56FE\u8868ID
|
||||
dashboard.saveAndShow=\u4FDD\u5B58\u5E76\u5C55\u793A
|
||||
dashboard.insertChart=\u63D2\u5165\u56FE\u8868
|
||||
|
||||
#Chart plugin
|
||||
chartPlugin.manageChartPlugin=\u7BA1\u7406\u56FE\u8868\u63D2\u4EF6
|
||||
|
|
|
@ -5,6 +5,7 @@ titleMessageKey 标题标签I18N关键字,不允许null
|
|||
selectonly 是否选择操作,允许为null
|
||||
-->
|
||||
<#assign selectonly=(selectonly!false)>
|
||||
<#assign isMultipleSelect=(isMultipleSelect!false)>
|
||||
<html>
|
||||
<head>
|
||||
<#include "../../include/html_head.ftl">
|
||||
|
@ -132,6 +133,19 @@ selectonly 是否选择操作,允许为null
|
|||
<#if selectonly>
|
||||
po.element("input[name=confirmButton]").click(function()
|
||||
{
|
||||
<#if isMultipleSelect>
|
||||
po.executeOnSelects(function(rows)
|
||||
{
|
||||
var close = po.pageParamCall("submit", rows);
|
||||
|
||||
//单选默认关闭
|
||||
if(close == undefined)
|
||||
close = true;
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
});
|
||||
<#else>
|
||||
po.executeOnSelect(function(row)
|
||||
{
|
||||
var close = po.pageParamCall("submit", row);
|
||||
|
@ -143,6 +157,7 @@ selectonly 是否选择操作,允许为null
|
|||
if(close)
|
||||
po.close();
|
||||
});
|
||||
</#if>
|
||||
});
|
||||
</#if>
|
||||
|
||||
|
|
|
@ -32,11 +32,14 @@ readonly 是否只读操作,允许为null
|
|||
<div class="form-item-label">
|
||||
<label><@spring.message code='dashboard.template' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<div class="form-item-value form-item-value-template">
|
||||
<textarea name="templateContent" class="ui-widget ui-widget-content" style="display: none;">${templateContent!''?html}</textarea>
|
||||
<div class="ui-widget ui-widget-content template-editor-wrapper">
|
||||
<div id="${pageId}-template-editor" class="template-editor"></div>
|
||||
</div>
|
||||
<#if !readonly>
|
||||
<button type="button" class="insert-chart-button"><@spring.message code='dashboard.insertChart' /></button>
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -44,6 +47,8 @@ readonly 是否只读操作,允许为null
|
|||
<#if !readonly>
|
||||
<input type="submit" value="<@spring.message code='save' />" class="recommended" />
|
||||
|
||||
<button type="button" name="saveAndShow"><@spring.message code='dashboard.saveAndShow' /></button>
|
||||
|
||||
<input type="reset" value="<@spring.message code='reset' />" />
|
||||
</#if>
|
||||
</div>
|
||||
|
@ -89,14 +94,54 @@ readonly 是否只读操作,允许为null
|
|||
<#if readonly>
|
||||
po.templateEditor.setReadOnly(true);
|
||||
</#if>
|
||||
|
||||
|
||||
<#if !readonly>
|
||||
po.insertChartCode = function(charts)
|
||||
{
|
||||
if(!charts || !charts.length)
|
||||
return;
|
||||
|
||||
var code = "";
|
||||
|
||||
for(var i=0; i<charts.length; i++)
|
||||
code += "<div class=\"dg-chart\" dg-chart-widget=\""+charts[i].id+"\">" + "<!--"+charts[i].name+"-->" + "</div>\n";
|
||||
|
||||
var cursor = po.templateEditor.getCursorPosition();
|
||||
po.templateEditor.moveCursorToPosition(cursor);
|
||||
po.templateEditor.session.insert(cursor, code);
|
||||
};
|
||||
po.element(".insert-chart-button").click(function()
|
||||
{
|
||||
var options =
|
||||
{
|
||||
pageParam :
|
||||
{
|
||||
submit : function(charts)
|
||||
{
|
||||
po.insertChartCode(charts);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.setGridPageHeightOption(options);
|
||||
|
||||
po.open("${contextPath}/analysis/chart/select?multiple", options);
|
||||
});
|
||||
|
||||
po.showAfterSave = false;
|
||||
|
||||
po.element("button[name=saveAndShow]").click(function()
|
||||
{
|
||||
po.showAfterSave = true;
|
||||
po.element("input[type='submit']").click();
|
||||
});
|
||||
|
||||
$.validator.addMethod("dashboardTemplateContent", function(value, element)
|
||||
{
|
||||
var html = po.templateEditor.getValue();
|
||||
return html.length > 0;
|
||||
});
|
||||
|
||||
|
||||
po.form().validate(
|
||||
{
|
||||
ignore : "",
|
||||
|
@ -116,12 +161,22 @@ readonly 是否只读操作,允许为null
|
|||
|
||||
$(form).ajaxSubmit(
|
||||
{
|
||||
success : function()
|
||||
success : function(response)
|
||||
{
|
||||
var close = (po.pageParamCall("afterSave") != false);
|
||||
var dashboard = response.data;
|
||||
po.element("input[name='id']").val(dashboard.id);
|
||||
|
||||
var close = (po.pageParamCall("afterSave") == true);
|
||||
|
||||
if(close)
|
||||
po.close();
|
||||
|
||||
if(po.showAfterSave)
|
||||
window.open(po.url("show/"+dashboard.id+"/index"), dashboard.id);
|
||||
},
|
||||
complete: function()
|
||||
{
|
||||
po.showAfterSave = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -2165,6 +2165,9 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
.page-form-uploadChartPlugin .chart-plugin-infos .chart-plugin-item .version{
|
||||
margin-left: 0.3em;
|
||||
}
|
||||
.page-form-dashboard{
|
||||
position: relative;
|
||||
}
|
||||
.page-form-dashboard .template-editor-wrapper{
|
||||
width:80%;
|
||||
min-height:10em;
|
||||
|
@ -2173,4 +2176,12 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
.page-form-dashboard .template-editor-wrapper .template-editor{
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
.page-form-dashboard .insert-chart-button{
|
||||
vertical-align: top;
|
||||
}
|
||||
.page-form-dashboard .show-button{
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
right: 0.5em;
|
||||
}
|
|
@ -147,6 +147,12 @@ CREATE TABLE T_DATA_EXPORT
|
|||
PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
CREATE TABLE T_ANALYSIS
|
||||
(
|
||||
NAME VARCHAR(50) NOT NULL,
|
||||
VALUE FLOAT(10,2) NOT NULL
|
||||
);
|
||||
|
||||
/*
|
||||
truncate table t_auto_generated_keys;
|
||||
truncate table t_data_export;
|
||||
|
|
Loading…
Reference in New Issue