Browse Source

Merge branch 'master' of Jimmy.Chai/demo-tabledata-redis into master

master
richie 4 years ago committed by Gogs
parent
commit
923290e4d2
  1. BIN
      lib/finekit-10.0.jar
  2. 9
      src/main/java/com/fr/plugin/db/redis/RedisConnectionComponent.java
  3. 13
      src/main/java/com/fr/plugin/db/redis/RedisScriptUniversalTableDataImpl.java
  4. 13
      src/main/java/com/fr/plugin/db/redis/RedisUniversalTableDataImpl.java
  5. 5
      src/main/java/com/fr/plugin/db/redis/action/SearchKeysAction.java
  6. 15
      src/main/java/com/fr/plugin/db/redis/bean/ParameterBean.java
  7. 11
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java
  8. 5
      src/main/resources/com/fr/plugin/db/redis/locale/redis_en_US.properties
  9. 7
      src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties
  10. BIN
      src/main/resources/com/fr/plugin/db/redis/web/demo-tabledate-redis-web.zip
  11. 2030
      src/main/resources/com/fr/plugin/db/redis/web/redis.css
  12. 24
      src/main/resources/com/fr/plugin/db/redis/web/redis.js
  13. 1
      src/web/.npmrc
  14. 19
      src/web/assets/scripts/dec.js
  15. 12
      src/web/index.html
  16. 6
      src/web/package.json
  17. 210
      src/web/private/i18n.ts
  18. 4
      src/web/src/index.edit.ts
  19. 38
      src/web/src/index.ts
  20. 7
      src/web/src/less/font.less
  21. 7
      src/web/src/less/lib/font.less
  22. 33
      src/web/src/modules/app.constant.ts
  23. 204
      src/web/src/modules/app.dataset.ts
  24. 12
      src/web/src/modules/app.edit.ts
  25. 7
      src/web/src/modules/app.less
  26. 47
      src/web/src/modules/app.model.ts
  27. 224
      src/web/src/modules/app.program.ts
  28. 10
      src/web/src/modules/app.show.ts
  29. 22
      src/web/src/modules/components/database_index/database_index.model.ts
  30. 44
      src/web/src/modules/components/database_index/database_index.service.ts
  31. 86
      src/web/src/modules/components/database_index/database_index.ts
  32. 40
      src/web/src/modules/components/parameter/parameter.model.ts
  33. 172
      src/web/src/modules/components/parameter/parameter.ts
  34. 9
      src/web/src/modules/components/parameter/parameter.typings.d.ts
  35. 20
      src/web/src/modules/components/parameter/parameter_input/input/input.service.ts
  36. 6
      src/web/src/modules/components/parameter/parameter_input/input/input.ts
  37. 41
      src/web/src/modules/components/parameter/parameter_input/input/input_boolean.ts
  38. 42
      src/web/src/modules/components/parameter/parameter_input/input/input_date.ts
  39. 45
      src/web/src/modules/components/parameter/parameter_input/input/input_formula.ts
  40. 42
      src/web/src/modules/components/parameter/parameter_input/input/input_int.ts
  41. 42
      src/web/src/modules/components/parameter/parameter_input/input/input_number.ts
  42. 41
      src/web/src/modules/components/parameter/parameter_input/input/input_string.ts
  43. 5
      src/web/src/modules/components/parameter/parameter_input/parameter_input.less
  44. 40
      src/web/src/modules/components/parameter/parameter_input/parameter_input.model.ts
  45. 165
      src/web/src/modules/components/parameter/parameter_input/parameter_input.ts
  46. 20
      src/web/src/modules/components/preview/preview.model.ts
  47. 31
      src/web/src/modules/components/preview/preview.ts
  48. 4
      src/web/src/modules/constants/env.ts
  49. 59
      src/web/src/modules/crud/crud.request.ts
  50. 130
      src/web/src/modules/crud/crud.service.ts
  51. 549
      src/web/src/modules/crud/formulaData.ts
  52. 36
      src/web/src/modules/table_list/list_item.ts
  53. 40
      src/web/src/modules/table_list/table_list.model.ts
  54. 133
      src/web/src/modules/table_list/table_list.ts
  55. 4
      src/web/src/ui/fineui.ts
  56. 2
      src/web/types/globals.d.ts
  57. 6
      src/web/webpack/webpack.dev.js
  58. 6
      src/web/webpack/webpack.prod.js
  59. 1687
      src/web/yarn.lock

BIN
lib/finekit-10.0.jar

Binary file not shown.

9
src/main/java/com/fr/plugin/db/redis/RedisConnectionComponent.java

@ -2,12 +2,19 @@ package com.fr.plugin.db.redis;
import com.fr.web.struct.Component;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ParserType;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
public class RedisConnectionComponent extends Component {
public static final RedisConnectionComponent KEY = new RedisConnectionComponent();
@Override
public ScriptPath script(RequestClient req) {
return ScriptPath.build("com/fr/plugin/db/redis/web/redis.js");
return ScriptPath.build("com/fr/plugin/db/redis/web/redis.js", ParserType.DYNAMIC);
}
@Override
public StylePath style(RequestClient req) {
return StylePath.build("com/fr/plugin/db/redis/web/redis.css", ParserType.DYNAMIC);
}
}

13
src/main/java/com/fr/plugin/db/redis/RedisScriptUniversalTableDataImpl.java

@ -2,7 +2,6 @@ package com.fr.plugin.db.redis;
import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.TableDataKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.impl.Connection;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
@ -40,7 +39,11 @@ public class RedisScriptUniversalTableDataImpl extends AbstractUniversalServerTa
JSONObject data = new JSONObject();
Connection database = redisScriptTableData.getDatabase();
data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY);
data.put(RedisConstants.ORDER, redisScriptTableData.getOrderValue().toString());
if (redisScriptTableData.getOrderValue() instanceof FormulaOrderValue) {
data.put(RedisConstants.ORDER, redisScriptTableData.getOrderValue().toString());
} else {
data.put(RedisConstants.ORDER, redisScriptTableData.getOrderValue().getValue());
}
data.put(RedisConstants.SCRIPT, redisScriptTableData.getScript());
data.put(RedisConstants.ENGINE, redisScriptTableData.getEngineType().getType());
data.put(RedisConstants.PARAMETERS, ParameterBean.createParameterBeans(redisScriptTableData.getParameters(Calculator.createCalculator())));
@ -52,7 +55,7 @@ public class RedisScriptUniversalTableDataImpl extends AbstractUniversalServerTa
RedisScriptTableData newTableData = new RedisScriptTableData();
String databaseName = data.getString(RedisConstants.DATABASE);
String script = data.getString(RedisConstants.SCRIPT);
if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) {
if (StringKit.isNotEmpty(databaseName) && ConnectionKit.getConnection(databaseName) != null) {
newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName));
}
newTableData.setEngineType(EngineType.parse(data.getInt(RedisConstants.ENGINE)));
@ -63,9 +66,7 @@ public class RedisScriptUniversalTableDataImpl extends AbstractUniversalServerTa
} else {
newTableData.setOrderValue(new FormulaOrderValue(FormulaKit.newFormula(order)));
}
newTableData.setParameters(RedisUtils.analyzeParameter(oldTableData.getParameters(Calculator.createCalculator()), newTableData.getOrderValue(), script));
newTableData.setParameters(RedisUtils.analyzeParameter(data.getJSONArray(RedisConstants.PARAMETERS), newTableData.getOrderValue(), script));
return newTableData;
}

13
src/main/java/com/fr/plugin/db/redis/RedisUniversalTableDataImpl.java

@ -2,7 +2,6 @@ package com.fr.plugin.db.redis;
import com.fanruan.api.cal.FormulaKit;
import com.fanruan.api.data.ConnectionKit;
import com.fanruan.api.data.TableDataKit;
import com.fanruan.api.util.StringKit;
import com.fr.data.impl.Connection;
import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
@ -39,7 +38,11 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat
JSONObject data = new JSONObject();
Connection database = redisTableData.getDatabase();
data.put(RedisConstants.DATABASE, database instanceof NameReference ? ((NameReference) database).getName() : StringKit.EMPTY);
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString());
if (redisTableData.getOrderValue() instanceof FormulaOrderValue) {
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().toString());
} else {
data.put(RedisConstants.ORDER, redisTableData.getOrderValue().getValue());
}
data.put(RedisConstants.SCRIPT, redisTableData.getScript());
data.put(RedisConstants.QUERY, redisTableData.getQuery());
data.put(RedisConstants.PARAMETERS, ParameterBean.createParameterBeans(redisTableData.getParameters(Calculator.createCalculator())));
@ -48,11 +51,11 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat
@Override
public RedisTableData deserialize(RedisTableData oldTableData, JSONObject data) {
RedisTableData newTableData = oldTableData;
RedisTableData newTableData = new RedisTableData();
String databaseName = data.getString(RedisConstants.DATABASE);
String script = data.getString(RedisConstants.SCRIPT);
String query = data.getString(RedisConstants.QUERY);
if (!StringKit.isEmpty(databaseName) && TableDataKit.findTableData(databaseName) != null) {
if (StringKit.isNotEmpty(databaseName) && ConnectionKit.getConnection(databaseName) != null) {
newTableData.setDatabase(ConnectionKit.createNameConnection(databaseName));
}
newTableData.setScript(script);
@ -64,7 +67,7 @@ public class RedisUniversalTableDataImpl extends AbstractUniversalServerTableDat
} else {
newTableData.setOrderValue(new FormulaOrderValue(FormulaKit.newFormula(order)));
}
newTableData.setParameters(RedisUtils.analyzeParameter(oldTableData.getParameters(Calculator.createCalculator()), newTableData.getOrderValue(), script, query));
newTableData.setParameters(RedisUtils.analyzeParameter(data.getJSONArray(RedisConstants.PARAMETERS), newTableData.getOrderValue(), script, query));
return newTableData;
}

5
src/main/java/com/fr/plugin/db/redis/action/SearchKeysAction.java

@ -40,10 +40,11 @@ public class SearchKeysAction extends BaseHttpHandler {
String[] keys = new String[0];
String pattern = request.getParameter("pattern");
String connectionName = request.getParameter("database");
if (StringKit.isNotEmpty(pattern) && StringKit.isNotEmpty(connectionName)) {
String orderValue = request.getParameter("orderValue");
if (StringKit.isNotEmpty(pattern) && StringKit.isNotEmpty(connectionName) && StringKit.isNotEmpty(orderValue)) {
Connection connection = ConnectionKit.getConnection(connectionName);
if (connection instanceof RedisDatabaseConnection) {
keys = connection.summary(pattern);
keys = connection.summary(pattern, orderValue);
}
}
FlushKit.printAsJSON(response, JSONFactory.createJSON(Arrays.asList(keys)));

15
src/main/java/com/fr/plugin/db/redis/bean/ParameterBean.java

@ -1,6 +1,7 @@
package com.fr.plugin.db.redis.bean;
import com.fr.base.ParameterTypeHandler;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.util.StringKit;
import com.fr.stable.ParameterProvider;
import java.util.ArrayList;
@ -11,12 +12,12 @@ import java.util.List;
* @version 10.0.4
* Created by Elijah on 2019/10/30
*/
public class ParameterBean{
public class ParameterBean {
public static final String TYPE = "type";
public static final String NAME = "name";
public static final String VALUE = "value";
private String type = ParameterTypeHandler.String.name();
private String type = ParameterKit.Type.TYPE_STRING;
private String name;
private String value;
@ -59,12 +60,16 @@ public class ParameterBean{
}
public static ParameterBean createBean(ParameterProvider parameterProvider) {
return new ParameterBean(parameterProvider.getClass().getSimpleName(),parameterProvider.getName(), parameterProvider.valueToString());
if (parameterProvider.getValue() != null) {
return new ParameterBean(parameterProvider.getValue().getClass().getSimpleName(), parameterProvider.getName(), parameterProvider.valueToString());
} else {
return new ParameterBean(String.class.getSimpleName(), parameterProvider.getName(), StringKit.EMPTY);
}
}
public static List<ParameterBean> createParameterBeans(ParameterProvider[] parameterProviders) {
List<ParameterBean> parameterBeans = new ArrayList<ParameterBean>();
for (ParameterProvider parameterProvider: parameterProviders) {
for (ParameterProvider parameterProvider : parameterProviders) {
parameterBeans.add(ParameterBean.createBean(parameterProvider));
}
return parameterBeans;

11
src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

@ -6,6 +6,7 @@ import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.util.RenderKit;
import com.fanruan.api.util.StringKit;
import com.fr.json.JSONArray;
import com.fr.plugin.db.redis.core.order.OrderValue;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.stable.ParameterProvider;
@ -72,14 +73,18 @@ public class RedisUtils {
}
}
public static ParameterProvider[] analyzeParameter(ParameterProvider[] oldParameters, OrderValue orderValue, String ...parameterTexts) {
public static ParameterProvider[] analyzeParameter(JSONArray existParameters, OrderValue orderValue, String... parameterTexts) {
ParameterProvider[] oldParameters = new ParameterProvider[existParameters.size()];
for (int i = 0; i < existParameters.size(); i++) {
oldParameters[i] = ParameterKit.json2Parameter(existParameters.getJSONObject(i));
}
ParameterProvider[] newParameters = ParameterKit.analyzeAndUnionSameParameters(parameterTexts, oldParameters);
ParameterProvider[] newOrderParameters = orderValue.analyze4Parameters();
Map<String, ParameterProvider> parameterProviderMap = new HashMap<String, ParameterProvider>();
for (ParameterProvider parameterProvider: oldParameters) {
for (ParameterProvider parameterProvider : oldParameters) {
parameterProviderMap.put(parameterProvider.getName(), parameterProvider);
}
for (ParameterProvider parameterProvider: newOrderParameters) {
for (ParameterProvider parameterProvider : newOrderParameters) {
if (parameterProviderMap.containsKey(parameterProvider.getName())) {
parameterProvider.setValue(parameterProviderMap.get(parameterProvider.getName()).getValue());
}

5
src/main/resources/com/fr/plugin/db/redis/locale/redis_en_US.properties

@ -39,3 +39,8 @@ Plugin-Redis_Cluster_Config_Description=Input multiple hosts with commas separat
Plugin-Redis_Script_Engine_Type=Script Engine Type
Plugin-Redis_Script_Engine_Type_Default=Default
Plugin-Redis_Script_Engine_Type_V8=V8
Plugin-Redis_Index=Index
Plugin-Redis_Set_Parameter=Parameter
Plugin-Redis_Set_Parameter_Name=Parameter Name
Plugin-Redis_Set_Parameter_Type=Parameter Type
Plugin-Redis_Set_Parameter_Value=Parameter Value

7
src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties

@ -59,4 +59,9 @@ Plugin-Redis_Parameter_Type_Formula=\u516C\u5F0F
Plugin-Redis_Parameter_Delete_Confirm=\u4F60\u786E\u5B9A\u51B3\u5B9A\u5220\u9664\u9009\u4E2D\u7684\u9879\uFF1F
Plugin-Redis_Parameter_Delete_Alert=\u5F53\u524D\u5217\u8868\u4E3A\u7A7A\u6216\u8005\u4F60\u6CA1\u6709\u9009\u4E2D\u4EFB\u4F55\u9879
Plugin-Redis_View=\u89C6\u56FE
Plugin-Redis_Table=\u8868
Plugin-Redis_Table=\u8868
Plugin-Redis_Index=\u7f16\u53f7
Plugin-Redis_Set_Parameter=\u53c2\u6570
Plugin-Redis_Set_Parameter_Name=\u53c2\u6570\u540d
Plugin-Redis_Set_Parameter_Type=\u53c2\u6570\u7c7b\u578b
Plugin-Redis_Set_Parameter_Value=\u53c2\u6570\u503c

BIN
src/main/resources/com/fr/plugin/db/redis/web/demo-tabledate-redis-web.zip

Binary file not shown.

2030
src/main/resources/com/fr/plugin/db/redis/web/redis.css

File diff suppressed because it is too large Load Diff

24
src/main/resources/com/fr/plugin/db/redis/web/redis.js

File diff suppressed because one or more lines are too long

1
src/web/.npmrc

@ -0,0 +1 @@
@fui:registry=https://npm.fineres.com/

19
src/web/assets/scripts/dec.js

@ -0,0 +1,19 @@
window.DecCst = {
Schedule: {
Parameter: {
Type: {
BOOLEAN: "Boolean",
DATA_SET: "TableColumn",
DATE: "Date",
DOUBLE: "Double",
FORMULA: "Formula",
INTEGER: "Integer",
STRING: "String",
}
}
}
};
window.Dec = {
fineServletURL: '/webroot/decision',
}

12
src/web/index.html

@ -14,23 +14,19 @@
<link
rel="stylesheet"
type="text/css"
href="./node_modules/fineui/dist/fineui.css"
href="./node_modules/fineui/dist/2.0/fineui.min.css"
/>
<link
rel="stylesheet"
type="text/css"
href="./node_modules/fineui-materials/docs/materials.min.css"
href="./node_modules/@fui/materials/docs/materials.min.css"
/>
</head>
<script>
var DecCst = null;
var Dec = null;
</script>
<body id="body">
<div id="wrapper"></div>
<script src="./assets/scripts/dec.js"></script>
<script src="./node_modules/fineui/dist/fineui.js"></script>
<script src="./node_modules/fineui-materials/docs/materials.min.js"></script>
<script src="./node_modules/fineui/i18n/i18n.cn.js"></script>
<script src="./node_modules/@fui/materials/docs/materials.min.js"></script>
</body>
</html>

6
src/web/package.json

@ -7,9 +7,11 @@
"author": "alan",
"license": "MIT",
"dependencies": {
"@fui/materials": "^10.0.0",
"@types/jss": "9.5.8",
"autoprefixer": "^9.6.1",
"es6-promise": "4.2.6",
"fineui": "^2.0.20200628140334",
"fork-ts-checker-webpack-plugin": "^1.5.1",
"jss": "9.8.7",
"jss-plugin-global": "10.0.0-alpha.7",
@ -58,10 +60,6 @@
"webpack-dev-server": "3.7.2",
"webpack-merge": "4.2.1"
},
"optionalDependencies": {
"fineui": "git+ssh://git@cloud.finedevelop.com:7999/visual/fineui.git",
"fineui-materials": "git+ssh://git@cloud.finedevelop.com:7999/fui/fineui-materials.git#release/10.0"
},
"scripts": {
"dev": "cross-env NODE_ENV=mock webpack-dev-server -p --progress --config=webpack/webpack.dev.js --mode development --open",
"build": "webpack -p --progress --config=webpack/webpack.prod.js --mode production",

210
src/web/private/i18n.ts

@ -9,7 +9,12 @@ export const i18n = {
'Plugin-Redis_Help': '帮助文档',
'Plugin-Redis_Keys_Pattern': '键值的正则表达式',
'Plugin-Redis_Keys_Pattern_Search': '搜索',
'Plugin-Redis_Set_Parameter': '参数',
'Plugin-Redis_Set_Parameter_Name': '参数名',
'Plugin-Redis_Set_Parameter_Type': '参数类型',
'Plugin-Redis_Set_Parameter_Value': '参数值',
'Plugin-Redis_DB_Index': '数据库编号',
'Plugin-Redis_Index': '编号',
'Plugin-Redis_Preview': '预览',
'Plugin-Redis_Refresh': '刷新',
'Plugin-Redis_Formula': '公式',
@ -42,22 +47,195 @@ export const i18n = {
'Plugin-Redis_Proxy_Private_Key_Path_Mark': '请输入服务器文件路径',
'Plugin-Redis_Connection_Form_OriginalCharsetName': '编码',
'Plugin-Redis_Check_Integer': '请输入不小于0的整数',
'Plugin-Redis_Parameter_Insert': '插入',
'Plugin-Redis_Parameter_Delete': '删除',
'Plugin-Redis_Parameter_Move_Up': '上移',
'Plugin-Redis_Parameter_Move_Down': '下移',
'Plugin-Redis_Parameter_Refresh': '刷新',
'Plugin-Redis_Dataset_Parameter_Name': '参数',
'Plugin-Redis_Dataset_Parameter_Value': '值',
'Plugin-Redis_Parameter_Please_Set_Parameter_Name': '请先设置参数名',
'Plugin-Redis_Parameter_Type_String': '字符串',
'Plugin-Redis_Parameter_Type_Int': '整型',
'Plugin-Redis_Parameter_Type_Number': '双精度型',
'Plugin-Redis_Parameter_Type_Date': '日期',
'Plugin-Redis_Parameter_Type_Boolean': '布尔型',
'Plugin-Redis_Parameter_Type_Formula': '公式',
'Plugin-Redis_Parameter_Delete_Confirm': '你确定决定删除选中的项?',
'Plugin-Redis_Parameter_Delete_Alert': '当前列表为空或者你没有选中任何项',
'Plugin-Redis_View': '视图',
'Plugin-Redis_Table': '表',
'BI-Multi_Date_Quarter_End': '季度末',
'BI-Multi_Date_Month_Begin': '月初',
'BI-Multi_Date_YMD': '年月日',
'BI-Custom_Color': '自定义颜色',
'BI-Numerical_Interval_Input_Data': '请输入数值',
'BI-Please_Input_Natural_Number': '请输入非负整数',
'BI-No_More_Data': '无更多数据',
'BI-Basic_Altogether': '共',
'BI-Basic_Sunday': '星期日',
'BI-Widget_Background_Colour': '组件背景',
'BI-Color_Picker_Error_Text': '请输入0~255的正整数',
'BI-Multi_Date_Month': '月',
'BI-No_Selected_Item': '没有可选项',
'BI-Multi_Date_Year_Begin': '年初',
'BI-Quarter_1': '第1季度',
'BI-Quarter_2': '第2季度',
'BI-Quarter_3': '第3季度',
'BI-Quarter_4': '第4季度',
'BI-Multi_Date_Year_Next': '年后',
'BI-Multi_Date_Month_Prev': '个月前',
'BI-Month_Trigger_Error_Text': '请输入1~12的正整数',
'BI-Less_And_Equal': '小于等于',
'BI-Year_Trigger_Invalid_Text': '请输入有效时间',
'BI-Multi_Date_Week_Next': '周后',
'BI-Font_Size': '字号',
'BI-Basic_Total': '共',
'BI-Already_Selected': '已选择',
'BI-Formula_Insert': '插入',
'BI-Select_All': '全选',
'BI-Basic_Tuesday': '星期二',
'BI-Multi_Date_Month_End': '月末',
'BI-Load_More': '点击加载更多数据',
'BI-Basic_September': '九月',
'BI-Current_Is_Last_Page': '当前已是最后一页',
'BI-Basic_Auto': '自动',
'BI-Basic_Count': '个',
'BI-Basic_Value': '值',
'BI-Basic_Unrestricted': '无限制',
'BI-Quarter_Trigger_Error_Text': '请输入1~4的正整数',
'BI-Basic_More': '更多',
'BI-Basic_Wednesday': '星期三',
'BI-Basic_Bold': '加粗',
'BI-Basic_Simple_Saturday': '六',
'BI-Multi_Date_Month_Next': '个月后',
'BI-Basic_March': '三月',
'BI-Current_Is_First_Page': '当前已是第一页',
'BI-Basic_Thursday': '星期四',
'BI-Basic_Prompt': '提示',
'BI-Multi_Date_Today': '今天',
'BI-Multi_Date_Quarter_Prev': '个季度前',
'BI-Row_Header': '行表头',
'BI-Date_Trigger_Error_Text': '日期格式示例:2015-3-11',
'BI-Basic_Cancel': '取消',
'BI-Basic_January': '一月',
'BI-Basic_June': '六月',
'BI-Basic_July': '七月',
'BI-Basic_April': '四月',
'BI-Multi_Date_Quarter_Begin': '季度初',
'BI-Multi_Date_Week': '周',
'BI-Click_Blank_To_Select': '点击\\空格键\\选中完全匹配项',
'BI-Basic_August': '八月',
'BI-Word_Align_Left': '文字居左',
'BI-Basic_November': '十一月',
'BI-Font_Colour': '字体颜色',
'BI-Multi_Date_Day_Prev': '天前',
'BI-Select_Part': '部分选择',
'BI-Multi_Date_Day_Next': '天后',
'BI-Less_Than': '小于',
'BI-Basic_February': '二月',
'BI-Multi_Date_Year': '年',
'BI-Number_Index': '序号',
'BI-Multi_Date_Week_Prev': '周前',
'BI-Next_Page': '下一页',
'BI-Right_Page': '向右翻页',
'BI-Numerical_Interval_Signal_Value': '前后值相等,请将操作符改为“≤”',
'BI-Basic_December': '十二月',
'BI-Basic_Saturday': '星期六',
'BI-Basic_Simple_Wednesday': '三',
'BI-Multi_Date_Quarter_Next': '个季度后',
'BI-Basic_October': '十月',
'BI-Basic_Simple_Friday': '五',
'BI-Basic_Save': '保存',
'BI-Numerical_Interval_Number_Value': '请保证前面的数值小于/等于后面的数值',
'BI-Previous_Page': '上一页',
'BI-No_Select': '搜索结果为空',
'BI-Basic_Clears': '清空',
'BI-Created_By_Me': '我创建的',
'BI-Basic_Simple_Tuesday': '二',
'BI-Word_Align_Right': '文字居右',
'BI-Summary_Values': '汇总',
'BI-Basic_Clear': '清除',
'BI-Upload_File_Size_Error': '文件大小不支持',
'BI-Up_Page': '向上翻页',
'BI-Basic_Simple_Sunday': '日',
'BI-Multi_Date_Relative_Current_Time': '相对当前时间',
'BI-Selected_Data': '已选数据:',
'BI-Multi_Date_Quarter': '季度',
'BI-Check_Selected': '查看已选',
'BI-Basic_Search': '搜索',
'BI-Basic_May': '五月',
'BI-Continue_Select': '继续选择',
'BI-Please_Input_Positive_Integer': '请输入正整数',
'BI-Upload_File_Type_Error': '文件类型不支持',
'BI-Upload_File_Error': '文件上传失败',
'BI-Basic_Friday': '星期五',
'BI-Down_Page': '向下翻页',
'BI-Basic_Monday': '星期一',
'BI-Left_Page': '向左翻页',
'BI-Transparent_Color': '透明',
'BI-Basic_Simple_Monday': '一',
'BI-Multi_Date_Year_End': '年末',
'BI-Time_Interval_Error_Text': '请保证开始时间早于/等于结束时间',
'BI-Basic_Time': '时间',
'BI-Basic_OK': '确定',
'BI-Basic_Sure': '确定',
'BI-Basic_Simple_Thursday': '四',
'BI-Multi_Date_Year_Prev': '年前',
'BI-Tiao_Data': '条数据',
'BI-Basic_Italic': '斜体',
'BI-Basic_Dynamic_Title': '动态时间',
'BI-Basic_Year': '年',
'BI-Basic_Single_Quarter': '季',
'BI-Basic_Month': '月',
'BI-Basic_Week': '周',
'BI-Basic_Day': '天',
'BI-Basic_Work_Day': '工作日',
'BI-Basic_Front': '前',
'BI-Basic_Behind': '后',
'BI-Basic_Empty': '空',
'BI-Basic_Month_End': '月末',
'BI-Basic_Month_Begin': '月初',
'BI-Basic_Year_End': '年末',
'BI-Basic_Year_Begin': '年初',
'BI-Basic_Quarter_End': '季末',
'BI-Basic_Quarter_Begin': '季初',
'BI-Basic_Week_End': '周末',
'BI-Basic_Week_Begin': '周初',
'BI-Basic_Current_Day': '当天',
'BI-Basic_Begin_Start': '初',
'BI-Basic_End_Stop': '末',
'BI-Basic_Current_Year': '今年',
'BI-Basic_Year_Fen': '年份',
'BI-Basic_Current_Month': '本月',
'BI-Basic_Current_Quarter': '本季度',
'BI-Basic_Year_Month': '年月',
'BI-Basic_Year_Quarter': '年季度',
'BI-Basic_Input_Can_Not_Null': '输入框不能为空',
'BI-Basic_Date_Time_Error_Text': '日期格式示例:2015-3-11 00:00:00',
'BI-Basic_Input_From_To_Number': '请输入{R1}的数值',
'BI-Basic_Or': '或',
'BI-Basic_And': '且',
'BI-Conf_Add_Formula': '添加公式',
'BI-Conf_Add_Condition': '添加条件',
'BI-Conf_Formula_And': '且公式条件',
'BI-Conf_Formula_Or': '或公式条件',
'BI-Conf_Condition_And': '且条件',
'BI-Conf_Condition_Or': '或条件',
'BI-Microsoft_YaHei': '微软雅黑',
'BI-Apple_Light': '苹方-light',
'BI-Font_Family': '字体',
'BI-Basic_Please_Input_Content': '请输入内容',
'BI-Word_Align_Center': '文字居中',
'BI-Basic_Please_Enter_Number_Between': '请输入{R1}-{R2}的值',
'BI-More_Than': '大于',
'BI-More_And_Equal': '大于等于',
'BI-Please_Enter_SQL': '请输入SQL',
'BI-Basic_Click_To_Add_Text': '+点击新增\\{R1}\\',
'BI-Basic_Please_Select': '请选择',
'BI-Basic_Font_Color': '文字颜色',
'BI-Basic_Background_Color': '背景色',
'BI-Basic_Underline': '下划线',
'BI-Basic_Param_Month': '{R1}月',
'BI-Basic_Param_Day': '{R1}日',
'BI-Basic_Param_Quarter': '{R1}季度',
'BI-Basic_Param_Week_Count': '第{R1}周',
'BI-Basic_Param_Hour': '{R1}时',
'BI-Basic_Param_Minute': '{R1}分',
'BI-Basic_Param_Second': '{R1}秒',
'BI-Basic_Param_Year': '{R1}年',
'BI-Basic_Date_Day': '日',
'BI-Basic_Hour_Sin': '时',
'BI-Basic_Seconds': '秒',
'BI-Basic_Minute': '分',
'BI-Basic_Wan': '万',
'BI-Basic_Million': '百万',
'BI-Basic_Billion': '亿',
'BI-Basic_Quarter': '季度',
'BI-Basic_No_Select': '不选',
'BI-Basic_Now': '此刻',
};

4
src/web/src/index.edit.ts

@ -1,6 +1,6 @@
import { RedisEdit } from './modules/app.edit';
import { TableList } from './modules/table_list/table_list';
BI.createWidget({
type: RedisEdit.xtype,
type: TableList.xtype,
element: '#wrapper',
});

38
src/web/src/index.ts

@ -1,16 +1,32 @@
import { RedisShow } from './modules/app.show';
import { RedisEdit } from './modules/app.edit';
const ConstantRedisType = 'dec.constant.database.conf.connect.types';
const ConstantRedisShow = 'dec.constant.database.conf.connect.form.Redis.show';
const ConstantRedisEdit = 'dec.constant.database.conf.connect.form.Redis.edit';
import { RedisDataset } from './modules/app.dataset';
import { RedisProgram } from './modules/app.program';
BI.DOM.ready(() => {
BI.config(ConstantRedisType, datas => [...datas, {
text: 'Redis',
databaseType: 'Redis',
iconUrl: 'com/fr/plugin/db/redis/images/redis.png',
}]);
BI.constant(ConstantRedisShow, RedisShow.xtype);
BI.constant(ConstantRedisEdit, RedisEdit.xtype);
BI.config('dec.connection.provider.datebase', provider => {
provider.registerDatabaseType({
text: 'Redis',
databaseType: 'Redis',
iconUrl: 'com/fr/plugin/db/redis/images/redis.png',
edit: RedisEdit.xtype,
show: RedisShow.xtype,
});
});
BI.config('dec.provider.data.set', provider => {
provider.registerDataSetType({
value: 'Redis',
text: 'Redis数据集',
cardType: RedisDataset.xtype,
});
});
BI.config('dec.provider.data.set', provider => {
provider.registerDataSetType({
value: 'RedisScript',
text: 'Redis程序数据集',
cardType: RedisProgram.xtype,
});
});
});

7
src/web/src/less/font.less

@ -1,12 +1,13 @@
@import "../../node_modules/fineui/src/less/resource/font.less";
@import "./lib/font.less";
.font(refresh-font, @font-refresh);
.font(redis-refresh-font, @font-redis-refresh);
.font(input-string-font, @font-input-string);
.font(input-formula-font, @font-input-formula);
.font(input-date-font, @font-input-date);
.font(input-boolean-font, @font-input-boolean);
.font(input-int-font, @font-input-int);
.font(input-number-font, @font-input-number);
.font(site-font, @font-site);
.font(column-font, @font-column);
.font(redis-site-font, @font-redis-site);
.font(redis-column-font, @font-redis-column);
.font(redis-preview-font, @font-redis-preview);

7
src/web/src/less/lib/font.less

@ -2,12 +2,13 @@
@fontReportUrl: '$fontReportUrl/';
@fontName: "report";
@font-refresh: "e6ef";
@font-redis-refresh: "e6ef";
@font-input-string: "e6e9";
@font-input-formula: "e6c6";
@font-input-date: "e733";
@font-input-boolean: "e656";
@font-input-int: "e7c2";
@font-input-number: "e60b";
@font-site: "e7c5";
@font-column: "e76f";
@font-redis-site: "e7c5";
@font-redis-column: "e76f";
@font-redis-preview: "e6f2";

33
src/web/src/modules/app.constant.ts

@ -0,0 +1,33 @@
export const redisParamHeader = [{
text: BI.i18nText('Plugin-Redis_Set_Parameter_Name'),
}, {
text: BI.i18nText('Plugin-Redis_Set_Parameter_Type'),
}, {
text: BI.i18nText('Plugin-Redis_Set_Parameter_Value'),
}];
export const redisField = [{
text: BI.i18nText('Dec-Basic_String'),
value: DecCst.Schedule.Parameter.Type.STRING,
iconCls: 'string-field-font',
}, {
text: BI.i18nText('Dec-Basic_Integer'),
value: DecCst.Schedule.Parameter.Type.INTEGER,
iconCls: 'number-field-font',
}, {
text: BI.i18nText('Dec-Basic_Double'),
value: DecCst.Schedule.Parameter.Type.DOUBLE,
iconCls: 'number-field-font',
}, {
text: BI.i18nText('Dec-Basic_Date'),
value: DecCst.Schedule.Parameter.Type.DATE,
iconCls: 'date-field-font',
}, {
text: BI.i18nText('Dec-Basic_Boolean'),
value: DecCst.Schedule.Parameter.Type.BOOLEAN,
iconCls: 'string-field-font',
}, {
text: BI.i18nText('Dec-Basic_Formula'),
value: DecCst.Schedule.Parameter.Type.FORMULA,
iconCls: 'string-field-font',
}];

204
src/web/src/modules/app.dataset.ts

@ -1,29 +1,71 @@
import { shortcut } from '@core/core';
import { VerticalXtype, TextEditorXtype, HtapeXtype, LabelXtype, IconComboXtype, TabXtype, CodeEditorXtype } from 'ui';
import { Parameter } from './components/parameter/parameter';
import { shortcut, store } from '@core/core';
import { VerticalXtype, HtapeXtype, LabelXtype, IconComboXtype, ComponentsStyleTable, ButtonXtype, IconTextValue_Combo, TextAreaEditorXtype } from 'ui';
import { TableList } from './table_list/table_list';
import '../less/index.less';
import { DatabaseIndex } from './components/database_index/database_index';
import { RedisModel, ParameterType } from './app.model';
import { Preview } from './components/preview/preview';
import './app.less';
import { redisField } from './app.constant';
@shortcut()
@store(RedisModel)
export class RedisDataset extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.dataset'
private textWidth = 100;
databaseNoTab: any;
databaseIndex: DatabaseIndex;
iconCombo: any;
queryCondition: any;
tableList: TableList;
parameterEditor: any;
previewButton: any;
store: RedisModel['store']
model: RedisModel['model']
props = {
value: {
datasetData: {
database: '',
orderValue: 0,
query: '',
parameters: [],
},
},
}
watch = {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
ableSave: (ableSave: boolean) => {
this.previewButton.setEnable(ableSave);
},
}
render() {
const { database = '', orderValue = 0, query = '', parameters = [] } = this.options.value.datasetData || {};
this.store.setParameters(parameters);
this.store.setAbleSave(!!query);
const inputType = typeof orderValue === 'string' ? 'formula' : 'int';
return {
type: HtapeXtype,
tgap: 15,
items: [{
el: {
type: TableList.xtype,
cls: 'bi-border-right',
database,
ref: (_ref: any) => {
this.tableList = _ref;
},
},
width: 300,
}, {
type: VerticalXtype,
hgap: 5,
vgap: 10,
lgap: 5,
bgap: 10,
items: [{
type: HtapeXtype,
height: 22,
@ -41,7 +83,7 @@ export class RedisDataset extends BI.Widget {
type: IconComboXtype,
height: 22,
width: 28,
value: 'int',
value: inputType,
items: [{
text: BI.i18nText('Plugin-Redis_Parameter_Type_Int'),
value: 'int',
@ -58,39 +100,25 @@ export class RedisDataset extends BI.Widget {
eventName: 'EVENT_CHANGE',
action: () => {
const typeValue = this.iconCombo.getValue()[0];
this.databaseNoTab.setSelect(typeValue);
this.databaseIndex.setSelect(typeValue);
},
}],
},
width: 28,
}, {
type: TabXtype,
single: true,
showIndex: 'int',
type: DatabaseIndex.xtype,
rgap: 11,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseNoTab = _ref;
},
cardCreator: (index: 'int'|'formula') => {
if (index === 'int') {
return {
type: TextEditorXtype,
warningTitle: '',
value: 0,
validationChecker: (v: string) => this.checkInteger(v),
errorText: BI.i18nText('Plugin-Redis_Check_Integer'),
};
}
return {
type: TextEditorXtype,
allowBlank: true,
};
this.databaseIndex = _ref;
},
}],
}],
}, {
type: HtapeXtype,
height: 200,
rgap: 5,
items: [{
el: {
type: LabelXtype,
@ -99,18 +127,130 @@ export class RedisDataset extends BI.Widget {
},
width: this.textWidth,
}, {
type: CodeEditorXtype,
type: TextAreaEditorXtype,
cls: 'bi-border',
height: 200,
allowBlank: true,
value: query,
ref: (_ref: any) => {
this.queryCondition = _ref;
},
listeners: [{
eventName: 'EVENT_CHANGE',
action: () => {
const value = this.queryCondition.getValue();
this.store.setAbleSave(!!value);
},
}],
}],
}, {
type: HtapeXtype,
height: 24,
rgap: 5,
items: [{
type: LabelXtype,
height: 24,
text: BI.i18nText('Plugin-Redis_Set_Parameter'),
textAlign: 'left',
}, {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Refresh'),
level: 'ignore',
handler: () => {
Dec.Utils.getDataSetParameters(this.getParamSearchValue(), res => {
const newParameters = BI.Services.getService('dec.service.data.set').getParameters(res.data, this.model.parameters);
this.store.setParameters(newParameters);
});
},
},
width: 80,
}, {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Preview'),
disabled: !BI.get(this.model, 'ableSave'),
handler: () => {
this.openPreview();
},
ref: (_ref: any) => {
this.previewButton = _ref;
},
},
width: 80,
}],
}, {
type: Parameter.xtype,
type: ComponentsStyleTable,
cls: 'param-table',
height: 200,
columnSize: [300, 300, ''],
items: this.renderItems(),
header: [this.model.paramHeader],
ref: (_ref: any) => {
this.parameterEditor = _ref;
},
}],
}],
};
}
private checkInteger(value: string) {
return /^[\d]+$/.test(value);
private renderItems() {
const self = this;
return this.model.parameters.map((item, index) => [{
type: LabelXtype,
text: item.name,
textAlign: 'left',
height: 30,
lgap: 10,
}, {
type: IconTextValue_Combo,
cls: 'field-type-change',
height: 30,
items: redisField,
value: item.type,
listeners: [{
eventName: BI.IconTextValueCombo.EVENT_CHANGE,
action () {
self.store.setParamType(index, this.getValue()[0]);
},
}],
}, this.createParameterValueItem(item, (value: string) => {
self.store.setParamValue(index, value);
})]);
}
private createParameterValueItem(param: ParameterType, cb: Function) {
return BI.Services.getService('dec.service.data.set').createParameterValueItem(param, cb);
}
public getValue() {
return {
database: this.tableList.getSelectedDatabase(),
orderValue: this.databaseIndex.getValue(),
query: this.queryCondition.getValue(),
parameters: this.model.parameters,
};
}
private getParamSearchValue() {
return {
datasetType: 'Redis',
datasetName: BI.get(this.model, 'dataSetName'),
datasetData: this.getValue(),
};
}
private openPreview() {
const id = BI.UUID();
BI.Popovers.create(id, {
type: 'bi.popover',
width: 800,
height: 500,
body: {
type: Preview.xtype,
previewedDataSet: this.getParamSearchValue(),
},
}).open(id);
}
}

12
src/web/src/modules/app.edit.ts

@ -8,7 +8,7 @@ import { ProxyEdit } from './components/proxy/proxy_edit';
export class RedisEdit extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.edit';
props = {
formData: {
value: {
basicConfig : {
...BASIC_CONFIG,
},
@ -33,10 +33,10 @@ export class RedisEdit extends BI.Widget {
oldPassword = '';
render() {
const formData = BI.get(this.options, 'formData');
const basicConfig = BI.get(formData, 'basicConfig', BASIC_CONFIG);
const poolConfig = BI.get(formData, 'poolConfig', POOL_CONFIG);
const proxyConfig = BI.get(formData, 'proxyConfig', PROXY_CONFIG);
const value = BI.get(this.options, 'value');
const basicConfig = BI.get(value, 'basicConfig', BASIC_CONFIG);
const poolConfig = BI.get(value, 'poolConfig', POOL_CONFIG);
const proxyConfig = BI.get(value, 'proxyConfig', PROXY_CONFIG);
const { host, port, password, originalCharsetName } = basicConfig;
this.poolConfigData = poolConfig;
this.proxyConfigData = proxyConfig;
@ -166,7 +166,7 @@ export class RedisEdit extends BI.Widget {
};
}
public getSubmitValue() {
public getValue() {
const originalCharsetName = this.originalCharsetName.getValue()[0] || '';
return {

7
src/web/src/modules/app.less

@ -0,0 +1,7 @@
@import '../less/index.less';
.param-table {
.dec-dynamic-date-combo .even-row {
background-color: @background-color-default;
}
}

47
src/web/src/modules/app.model.ts

@ -0,0 +1,47 @@
import { model, Model } from './core/core';
import { redisParamHeader } from './app.constant';
@model()
export class RedisModel extends Model {
static xtype = 'dec.model.dcm.connection.plugin.redis'
context = ['dataSetName', 'ableSave']
state() {
return {
parameters: [] as ParameterType[],
};
}
actions = {
setAbleSave(ableSave: boolean) {
this.model.ableSave = ableSave;
},
setParameters: (parameters: ParameterType[]) => {
this.model.parameters = parameters;
},
setParamType: (index: number, type: string) => {
if (this.model.parameters[index].type !== type) {
this.model.parameters[index].type = type;
this.model.parameters[index].value = BI.Services.getService('dec.service.data.set').getDefaultValueByType(type);
this.model.parameters.splice(0, 0);
}
},
setParamValue: (index: number, val: string) => {
this.model.parameters[index].value = val;
},
}
computed = {
paramHeader: () => redisParamHeader.map(item => BI.extend({
textAlign: 'left',
height: 30,
hgap: 10,
}, item)),
}
}
export interface ParameterType {
name: string;
type: string;
value: string;
}

224
src/web/src/modules/app.program.ts

@ -1,29 +1,73 @@
import { shortcut } from '@core/core';
import { VerticalXtype, TextEditorXtype, HtapeXtype, LabelXtype, IconComboXtype, TabXtype, CodeEditorXtype, TextValueComboXtype } from 'ui';
import { Parameter } from './components/parameter/parameter';
import { shortcut, store } from '@core/core';
import { VerticalXtype, HtapeXtype, LabelXtype, IconComboXtype, TextValueComboXtype, TextAreaEditorXtype, ComponentsStyleTable, ButtonXtype, IconTextValue_Combo } from 'ui';
import { TableList } from './table_list/table_list';
import '../less/index.less';
import { DatabaseIndex } from './components/database_index/database_index';
import { RedisModel, ParameterType } from './app.model';
import './app.less';
import { redisField } from './app.constant';
import { Preview } from './components/preview/preview';
@shortcut()
@store(RedisModel)
export class RedisProgram extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.program'
private textWidth = 100;
databaseNoTab: any;
databaseIndex: DatabaseIndex;
iconCombo: any;
queryCondition: any;
tableList: TableList;
parameterEditor: any;
engineTypeSelect: any;
previewButton: any;
store: RedisModel['store']
model: RedisModel['model']
props = {
value: {
datasetData: {
database: '',
orderValue: 0,
script: '',
engineType: 0,
parameters: [],
},
},
}
watch = {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
ableSave: (ableSave: boolean) => {
this.previewButton.setEnable(ableSave);
},
}
render() {
const { database = '', orderValue = 0, script = '', parameters = [], engineType = 0 } = this.options.value.datasetData || {};
this.store.setParameters(parameters);
const inputType = typeof orderValue === 'string' ? 'formula' : 'int';
return {
type: HtapeXtype,
tgap: 15,
items: [{
el: {
type: TableList.xtype,
cls: 'bi-border-right',
database,
ref: (_ref: any) => {
this.tableList = _ref;
},
},
width: 300,
}, {
type: VerticalXtype,
hgap: 5,
vgap: 10,
lgap: 5,
bgap: 10,
items: [{
type: HtapeXtype,
height: 22,
@ -41,7 +85,7 @@ export class RedisProgram extends BI.Widget {
type: IconComboXtype,
height: 22,
width: 28,
value: 'int',
value: inputType,
items: [{
text: BI.i18nText('Plugin-Redis_Parameter_Type_Int'),
value: 'int',
@ -58,39 +102,25 @@ export class RedisProgram extends BI.Widget {
eventName: 'EVENT_CHANGE',
action: () => {
const typeValue = this.iconCombo.getValue()[0];
this.databaseNoTab.setSelect(typeValue);
this.databaseIndex.setSelect(typeValue);
},
}],
},
width: 28,
}, {
type: TabXtype,
single: true,
showIndex: 'int',
type: DatabaseIndex.xtype,
rgap: 11,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseNoTab = _ref;
},
cardCreator: (index: 'int'|'formula') => {
if (index === 'int') {
return {
type: TextEditorXtype,
warningTitle: '',
value: 0,
validationChecker: (v: string) => this.checkInteger(v),
errorText: BI.i18nText('Plugin-Redis_Check_Integer'),
};
}
return {
type: TextEditorXtype,
allowBlank: true,
};
this.databaseIndex = _ref;
},
}],
}],
}, {
type: HtapeXtype,
height: 22,
rgap: 5,
items: [{
el: {
type: LabelXtype,
@ -100,37 +130,161 @@ export class RedisProgram extends BI.Widget {
width: this.textWidth,
}, {
type: TextValueComboXtype,
value: engineType,
ref: (_ref: any) => {
this.engineTypeSelect = _ref;
},
items: [{
text: BI.i18nText('Plugin-Redis_Script_Engine_Type_Default'),
value: '',
value: 0,
}, {
text: BI.i18nText('Plugin-Redis_Script_Engine_Type_V8'),
value: 'v8',
value: 1,
}],
}],
}, {
type: HtapeXtype,
height: 200,
rgap: 5,
items: [{
el: {
type: LabelXtype,
text: BI.i18nText('Plugin-Redis_Query_Condition'),
text: BI.i18nText('Plugin-Redis_Script_Query_Text'),
textAlign: 'left',
},
width: this.textWidth,
}, {
type: CodeEditorXtype,
type: TextAreaEditorXtype,
cls: 'bi-border',
height: 200,
allowBlank: true,
value: script,
ref: (_ref: any) => {
this.queryCondition = _ref;
},
listeners: [{
eventName: 'EVENT_CHANGE',
action: () => {
const value = this.queryCondition.getValue();
this.store.setAbleSave(!!value);
},
}],
}],
}, {
type: Parameter.xtype,
type: HtapeXtype,
height: 24,
rgap: 5,
items: [{
type: LabelXtype,
height: 24,
text: BI.i18nText('Plugin-Redis_Set_Parameter'),
textAlign: 'left',
}, {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Refresh'),
level: 'ignore',
handler: () => {
Dec.Utils.getDataSetParameters(this.getParamSearchValue(), res => {
const newParameters = BI.Services.getService('dec.service.data.set').getParameters(res.data, this.model.parameters);
this.store.setParameters(newParameters);
});
},
},
width: 80,
}, {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Preview'),
disabled: !BI.get(this.model, 'ableSave'),
handler: () => {
this.openPreview();
},
ref: (_ref: any) => {
this.previewButton = _ref;
},
},
width: 80,
}],
}, {
type: ComponentsStyleTable,
cls: 'param-table',
height: 200,
columnSize: [300, 300, ''],
items: this.renderItems(),
header: [this.model.paramHeader],
ref: (_ref: any) => {
this.parameterEditor = _ref;
},
}],
}],
};
}
private checkInteger(value: string) {
return /^[\d]+$/.test(value);
private renderItems() {
const self = this;
return this.model.parameters.map((item, index) => [{
type: LabelXtype,
text: item.name,
textAlign: 'left',
height: 30,
lgap: 10,
}, {
type: IconTextValue_Combo,
cls: 'field-type-change',
height: 30,
items: redisField,
value: item.type,
listeners: [{
eventName: BI.IconTextValueCombo.EVENT_CHANGE,
action () {
self.store.setParamType(index, this.getValue()[0]);
},
}],
}, {
type: LabelXtype,
text: item.name,
textAlign: 'left',
height: 30,
lgap: 10,
}, this.createParameterValueItem(item, (value: string) => {
self.store.setParamValue(index, value);
})]);
}
private createParameterValueItem(param: ParameterType, cb: Function) {
return BI.Services.getService('dec.service.data.set').createParameterValueItem(param, cb);
}
public getValue() {
return {
database: this.tableList.getSelectedDatabase(),
orderValue: this.databaseIndex.getValue(),
script: this.queryCondition.getValue(),
engineType: this.engineTypeSelect.getValue()[0],
parameters: this.model.parameters,
};
}
private getParamSearchValue() {
return {
datasetType: 'RedisScript',
datasetName: BI.get(this.model, 'dataSetName'),
datasetData: this.getValue(),
};
}
private openPreview() {
const id = BI.UUID();
BI.Popovers.create(id, {
type: 'bi.popover',
width: 800,
height: 500,
body: {
type: Preview.xtype,
previewedDataSet: this.getParamSearchValue(),
},
}).open(id);
}
}

10
src/web/src/modules/app.show.ts

@ -9,7 +9,7 @@ import { POOL_CONFIG, PROXY_CONFIG, BASIC_CONFIG } from '@constants/constant';
export class RedisShow extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.show'
props = {
formData: {
value: {
basicConfig : {
...BASIC_CONFIG,
},
@ -22,10 +22,10 @@ export class RedisShow extends BI.Widget {
},
}
render() {
const formData = BI.get(this.options, 'formData');
const basicConfig = BI.get(formData, 'basicConfig', BASIC_CONFIG);
const poolConfig = BI.get(formData, 'poolConfig', POOL_CONFIG);
const proxyConfig = BI.get(formData, 'proxyConfig', PROXY_CONFIG);
const value = BI.get(this.options, 'value');
const basicConfig = BI.get(value, 'basicConfig', BASIC_CONFIG);
const poolConfig = BI.get(value, 'poolConfig', POOL_CONFIG);
const proxyConfig = BI.get(value, 'proxyConfig', PROXY_CONFIG);
const { host, port, newCharsetName } = basicConfig;
return {

22
src/web/src/modules/components/database_index/database_index.model.ts

@ -0,0 +1,22 @@
import { model, Model } from '../../core/core';
@model()
export class DatabaseIndexModel extends Model {
static xtype = 'plugin.model.report.redis.components.database_index'
state() {
return {
inputValue: '' as string | number,
inputType: 'int',
};
}
actions = {
setInpueValue: (value: string | number) => {
this.model.inputValue = value;
},
setInputType: (value: string) => {
this.model.inputType = value;
},
}
}

44
src/web/src/modules/components/database_index/database_index.service.ts

@ -0,0 +1,44 @@
import { BarPopoverXtype } from 'ui';
import { fetchFormulaConfig } from '../../crud/crud.request';
/**
*
*/
export function openFormulaPopover<T extends {formula: string}>(value: T, inserterType: string = BI.RegularFormulaInserter.xtype): Promise<T> {
return new Promise((resolve, reject) => {
const id = BI.UUID();
let formulaPane: typeof BI.FormulaOpeartingPanel;
BI.Popovers.create(id, {
type: BarPopoverXtype,
width: 900,
height: 600,
header: BI.i18nText('Plugin-JSON_Function_Definition'),
body: {
type: BI.FormulaOpeartingPanel.xtype,
configLoader: fetchFormulaConfig,
ref: (_ref: typeof BI.FormulaOpeartingPanel) => {
formulaPane = _ref;
},
inserterType,
value,
},
listeners: [{
eventName: BI.Popover.EVENT_CANCEL,
action: () => {
reject();
BI.Popovers.remove(id);
},
}, {
eventName: BI.Popover.EVENT_CONFIRM,
action: () => {
resolve(formulaPane.getValue() as T);
BI.Popovers.remove(id);
},
}],
}).open(id);
});
}

86
src/web/src/modules/components/database_index/database_index.ts

@ -0,0 +1,86 @@
import { shortcut, store } from '@core/core';
import { TabXtype, TextEditorXtype } from 'ui';
import { DatabaseIndexModel } from './database_index.model';
import { openFormulaPopover } from './database_index.service';
@shortcut()
@store(DatabaseIndexModel)
export class DatabaseIndex extends BI.Widget {
static xtype = 'plugin.report.redis.components.database_index'
databaseIndexTab: any;
textEditor: any;
formulaPane: any;
model: DatabaseIndexModel['model']
store: DatabaseIndexModel['store']
props = {
value: '',
inputType: 'int',
}
render() {
const { value, inputType } = this.options;
this.store.setInpueValue(value);
this.store.setInputType(inputType);
return {
type: TabXtype,
single: true,
showIndex: this.model.inputType,
ref: (_ref: any) => {
this.databaseIndexTab = _ref;
},
cardCreator: (index: 'int'|'formula') => {
if (index === 'int') {
return {
type: TextEditorXtype,
warningTitle: '',
value: parseInt(this.model.inputValue as string, 10) || 0,
validationChecker: (v: string) => this.checkInteger(v),
errorText: BI.i18nText('Plugin-Redis_Check_Integer'),
listeners: [{
eventName: 'EVENT_CHANGE',
action: () => {
this.store.setInpueValue(parseInt(this.textEditor.getValue(), 10));
},
}],
ref: (_ref: any) => {
this.textEditor = _ref;
},
};
}
return {
type: TextEditorXtype,
allowBlank: true,
value: this.model.inputValue,
ref: (_ref: any) => {
this.formulaPane = _ref;
},
};
},
};
}
private checkInteger(value: string) {
return /^[\d]+$/.test(value);
}
public setSelect(value: string) {
this.databaseIndexTab.setSelect(value);
this.store.setInputType(value);
if (value === 'formula') {
openFormulaPopover({
formula: this.model.inputValue === 0 ? '' : this.model.inputValue as string,
}, BI.ComplexFormulaInserter.xtype).then(value => {
this.store.setInpueValue(value.formula);
this.formulaPane.setValue(value.formula);
});
}
}
public getValue() {
return this.model.inputType === 'int' ? parseInt(`${this.model.inputValue}`, 10) : this.model.inputValue;
}
}

40
src/web/src/modules/components/parameter/parameter.model.ts

@ -1,40 +0,0 @@
import { model, Model } from '../../core/core';
import { ParametersType } from './parameter.typings';
@model()
export class ParameterModel extends Model {
static xtype = 'plugin.model.report.json.components.parameter';
childContext = <const>['selectedId', 'parameters'];
state() {
return {
parameters: [] as ParametersType[],
selectedId: '',
};
}
actions = {
setParameters: (parameters: ParametersType[]) => {
this.model.parameters = parameters;
},
removeSelectedParameter: () => {
this.setParameters(this.model.parameters.filter(item => item.id !== this.model.selectedId));
},
move: (type: 'up'|'down') => {
if (this.model.selectedId) {
const index = this.model.parameters.findIndex(item => item.id === this.model.selectedId);
if (type === 'up' && index > 0) {
const oldItem = this.model.parameters.splice(index, 1)[0];
this.model.parameters.splice(index - 1, 0, oldItem);
}
if (type === 'down' && index < this.model.parameters.length - 1) {
const oldItem = this.model.parameters.splice(index, 1)[0];
this.model.parameters.splice(index + 1, 0, oldItem);
}
}
},
}
}

172
src/web/src/modules/components/parameter/parameter.ts

@ -1,172 +0,0 @@
import { shortcut, store } from '../../core/core';
import { VtapeXtype, LabelXtype, HtapeXtype, LeftRightVerticalAdaptLayoutXtype, IconButtonXtype, ButtonGroupXtype, VerticalXtype } from 'ui';
import { ParameterInput } from './parameter_input/parameter_input';
import { ParameterModel } from './parameter.model';
import { ParametersType } from './parameter.typings';
@shortcut()
@store(ParameterModel)
export class Parameter extends BI.Widget {
static xtype = 'plugin.report.redis.components.parameter';
props = {
title: '',
showRefresh: true,
height: 200,
value: [] as ParametersType[],
}
parameterInputs: any;
model: ParameterModel['model']
store: ParameterModel['store']
watch = {
parameters: () => {
this.parameterInputs.populate(this.renderParameterInputs());
},
selectedId: (id: string) => {
this.parameterInputs.setValue(id);
},
}
render() {
const { title, showRefresh } = this.options;
this.setDefalue();
return {
type: VtapeXtype,
items: [{
el: {
type: LeftRightVerticalAdaptLayoutXtype,
items: {
left: [{
type: LabelXtype,
lgap: 2,
text: title,
textAlign: 'left',
}],
right: [{
type: IconButtonXtype,
cls: 'text-add-tip-font',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Insert'),
handler: () => {
this.store.setParameters([{
name: '',
value: '',
id: BI.UUID(),
type: 'string',
}, ...this.model.parameters]);
},
}, {
type: IconButtonXtype,
cls: 'close-font bi-error',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Delete'),
handler: () => {
if (this.model.selectedId) {
BI.Msg.confirm(BI.i18nText('BI-Basic_Prompt'), BI.i18nText('Plugin-Redis_Parameter_Delete_Confirm'), (re: boolean) => {
if (re) {
this.store.removeSelectedParameter();
}
});
} else {
BI.Msg.alert(BI.i18nText('BI-Basic_Prompt'), BI.i18nText('Plugin-Redis_Parameter_Delete_Alert'));
}
},
}, {
type: IconButtonXtype,
cls: 'add-up-font',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Move_Up'),
handler: () => {
this.store.move('up');
},
}, {
type: IconButtonXtype,
cls: 'minus-down-font',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Move_Down'),
handler: () => {
this.store.move('down');
},
}, showRefresh ? {
type: IconButtonXtype,
cls: 'refresh-font',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Refresh'),
handler: () => {
this.setDefalue();
},
} : null],
},
},
height: 25,
}, {
el: {
type: HtapeXtype,
cls: 'bi-border',
items: [{
el: {
type: LabelXtype,
text: BI.i18nText('Plugin-Redis_Dataset_Parameter_Name'),
},
width: 0.5,
}, {
el: {
type: LabelXtype,
cls: 'bi-border-left',
text: BI.i18nText('Plugin-Redis_Dataset_Parameter_Value'),
},
width: 0.5,
}],
},
height: 25,
}, {
type: ButtonGroupXtype,
cls: 'bi-border',
layouts: [{
type: VerticalXtype,
}],
items: this.renderParameterInputs(),
ref: (_ref: any) => {
this.parameterInputs = _ref;
},
}],
};
}
public getValue() {
return this.model.parameters.map(item => {
return {
name: item.name,
value: item.value,
type: item.type,
};
});
}
private setDefalue() {
const { value = [] } = this.options;
this.store.setParameters(value.map(item => {
return {
...item,
id: BI.UUID(),
};
}));
}
private renderParameterInputs() {
return this.model.parameters.map(item => {
return {
type: ParameterInput.xtype,
inputName: item.name,
inputValue: item.value,
id: item.id,
value: item.id,
selected: item.id === this.model.selectedId,
};
});
}
}

9
src/web/src/modules/components/parameter/parameter.typings.d.ts vendored

@ -1,9 +0,0 @@
export interface ParametersType {
name: string;
value: string;
id?: string;
type: inputTypes;
}
export type inputTypes = 'string' | 'int' | 'number' | 'date' | 'boolean' | 'formula'

20
src/web/src/modules/components/parameter/parameter_input/input/input.service.ts

@ -1,20 +0,0 @@
import { inputTypes } from '../../parameter.typings';
const inputs: {
[key: string]: any;
} = {};
export function input(key: inputTypes): ClassDecorator {
return (target: object) => {
inputs[key] = target;
};
}
export function getInput(type: inputTypes): string {
const inputWidget = inputs[type];
if (BI.isNull(inputWidget)) {
throw new TypeError();
}
return inputWidget.xtype;
}

6
src/web/src/modules/components/parameter/parameter_input/input/input.ts

@ -1,6 +0,0 @@
import './input_boolean';
import './input_date';
import './input_int';
import './input_number';
import './input_string';
import './input_formula';

41
src/web/src/modules/components/parameter/parameter_input/input/input_boolean.ts

@ -1,41 +0,0 @@
import { shortcut } from '../../../../core/core';
import { MultiSelectItemXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('boolean')
export class InputBoolean extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.boolean'
props = {
value: '',
}
input: any;
render() {
const { value } = this.options;
return {
type: MultiSelectItemXtype,
width: 80,
selected: !!value,
text: 'true',
ref: (_ref: any) => {
this.input = _ref;
},
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

42
src/web/src/modules/components/parameter/parameter_input/input/input_date.ts

@ -1,42 +0,0 @@
import { shortcut } from '../../../../core/core';
import { DynamicDateComboXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('date')
export class InputDate extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.date'
props = {
value: '',
}
input: any;
render() {
const { value } = this.options;
return {
type: DynamicDateComboXtype,
height: 22,
allowBlank: true,
value,
ref: (_ref: any) => {
this.input = _ref;
},
validationChecker: (v: string) => BI.isNumeric(v),
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

45
src/web/src/modules/components/parameter/parameter_input/input/input_formula.ts

@ -1,45 +0,0 @@
import { shortcut } from '../../../../core/core';
import { EditorXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('formula')
export class InputFormula extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.formula'
props = {
value: '',
}
input: any;
mounted() {
}
render() {
const { value } = this.options;
return {
type: EditorXtype,
height: 22,
allowBlank: true,
value,
ref: (_ref: any) => {
this.input = _ref;
},
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

42
src/web/src/modules/components/parameter/parameter_input/input/input_int.ts

@ -1,42 +0,0 @@
import { shortcut } from '../../../../core/core';
import { NumberEditorXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('int')
export class InputInt extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.int'
props = {
value: '',
}
input: any;
render() {
const { value } = this.options;
return {
type: NumberEditorXtype,
height: 22,
allowBlank: true,
value,
ref: (_ref: any) => {
this.input = _ref;
},
validationChecker: (v: string) => BI.isInteger(v),
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

42
src/web/src/modules/components/parameter/parameter_input/input/input_number.ts

@ -1,42 +0,0 @@
import { shortcut } from '../../../../core/core';
import { EditorXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('number')
export class InputNumber extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.number'
props = {
value: '',
}
input: any;
render() {
const { value } = this.options;
return {
type: EditorXtype,
height: 22,
allowBlank: true,
value,
ref: (_ref: any) => {
this.input = _ref;
},
validationChecker: (v: string) => BI.isNumeric(v),
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

41
src/web/src/modules/components/parameter/parameter_input/input/input_string.ts

@ -1,41 +0,0 @@
import { shortcut } from '../../../../core/core';
import { EditorXtype } from 'ui';
import { input } from './input.service';
@shortcut()
@input('string')
export class InputString extends BI.Widget {
static xtype = 'plugin.report.json.components.parameter_input.string'
props = {
value: '',
}
input: any;
render() {
const { value } = this.options;
return {
type: EditorXtype,
height: 22,
allowBlank: true,
value,
ref: (_ref: any) => {
this.input = _ref;
},
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
const value = this.input.getValue();
this.fireEvent('EVENT_CHANGE', value);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.fireEvent('EVENT_FOCUS');
},
}],
};
}
}

5
src/web/src/modules/components/parameter/parameter_input/parameter_input.less

@ -1,5 +0,0 @@
@import '../../../../less/index.less';
.plugin-report-json-parameter-input.active{
background-color: @color-bi-light-blue-60;
}

40
src/web/src/modules/components/parameter/parameter_input/parameter_input.model.ts

@ -1,40 +0,0 @@
import { model, Model } from '../../../core/core';
import { ParameterModel } from '../parameter.model';
import { inputTypes } from '../parameter.typings';
@model()
export class ParameterInputModel extends Model<{
types: {
selectedId: ParameterModel['TYPE']['selectedId'];
parameters: ParameterModel['TYPE']['parameters'];
},
context: ParameterInputModel['context'];
}> {
static xtype = 'plugin.model.report.json.components.parameter_input';
context = <const>['selectedId', 'parameters'];
actions = {
setSelectedId: (id: string) => {
this.model.selectedId = id;
},
setParameterName: (id: string, name: string) => {
const thisParameter = this.getParameter(id);
if (thisParameter) {
thisParameter.name = name;
}
},
setParameterValue: (id: string, value: string, type: inputTypes) => {
const thisParameter = this.getParameter(id);
if (thisParameter) {
thisParameter.value = value;
thisParameter.type = type;
}
},
}
private getParameter(id: string) {
return this.model.parameters.find(item => item.id === id);
}
}

165
src/web/src/modules/components/parameter/parameter_input/parameter_input.ts

@ -1,165 +0,0 @@
import { shortcut, store } from '../../../core/core';
import { HtapeXtype, EditorXtype, TextButtonXtype, TabXtype, IconComboXtype } from 'ui';
import { ParameterInputModel } from './parameter_input.model';
import { inputTypes } from '../parameter.typings';
import { getInput } from './input/input.service';
import './input/input';
import './parameter_input.less';
@shortcut()
@store(ParameterInputModel)
export class ParameterInput extends BI.BasicButton {
static xtype = 'plugin.report.json.components.parameter_input'
props = {
inputName: '',
inputValue: '',
height: 22,
id: '',
baseCls: 'plugin-report-json-parameter-input',
}
store: ParameterInputModel['store']
model: ParameterInputModel['model']
tab: any;
parameterName: any;
parameterValue: any;
iconCombo: any;
render() {
let { inputName, inputValue } = this.options;
const { id } = this.options;
return {
type: HtapeXtype,
cls: 'bi-border',
items: [{
el: {
type: EditorXtype,
height: 22,
allowBlank: true,
value: inputName,
ref: (_ref: any) => {
this.parameterName = _ref;
},
listeners: [{
eventName: BI.TextEditor.EVENT_CHANGE,
action: () => {
inputName = this.parameterName.getValue();
this.tab.setSelect(inputName ? 'string' : 'tip');
inputValue = inputName ? inputValue : '';
this.store.setParameterName(id, inputName);
},
}, {
eventName: BI.TextEditor.EVENT_FOCUS,
action: () => {
this.store.setSelectedId(id);
},
}],
},
width: 0.5,
}, {
el: {
type: HtapeXtype,
items: [{
type: TabXtype,
single: true,
showIndex: inputName ? 'string' : 'tip',
ref: (_ref: any) => {
this.tab = _ref;
},
cardCreator: (index: inputTypes | 'tip') => this.renderInputs(index),
}],
},
width: 0.5,
}],
};
}
private renderInputs(type: inputTypes | 'tip') {
const { inputValue, id } = this.options;
if (type === 'tip') {
return {
type: TextButtonXtype,
cls: 'bi-error bi-border-left',
text: BI.i18nText('Plugin-Redis_Parameter_Please_Set_Parameter_Name'),
handler: () => {
this.parameterName.focus();
},
};
}
const xtype = getInput(type);
return {
type: HtapeXtype,
items: [{
el: {
type: IconComboXtype,
cls: 'bi-border-left bi-border-right',
height: 22,
width: 25,
value: type,
items: this.renderDownList(),
ref: (_ref: any) => {
this.iconCombo = _ref;
},
listeners: [{
eventName: 'EVENT_CHANGE',
action: () => {
this.tab.setSelect('tip');
const typeValue = this.iconCombo.getValue()[0];
if (typeValue) {
this.tab.setSelect(typeValue);
}
},
}],
},
width: 25,
}, {
type: xtype,
value: inputValue,
listeners: [{
eventName: 'EVENT_CHANGE',
action: (value: string) => {
const type = this.iconCombo.getValue()[0];
this.store.setParameterValue(id, value, type);
},
}, {
eventName: 'EVENT_FOCUS',
action: () => {
this.store.setSelectedId(id);
},
}],
}],
};
}
private renderDownList() {
return [{
text: BI.i18nText('Plugin-Redis_Parameter_Type_String'),
value: 'string',
iconCls: 'input-string-font',
}, {
text: BI.i18nText('Plugin-Redis_Parameter_Type_Int'),
value: 'int',
iconCls: 'input-int-font',
}, {
text: BI.i18nText('Plugin-Redis_Parameter_Type_Number'),
value: 'number',
iconCls: 'input-number-font',
}, {
text: BI.i18nText('Plugin-Redis_Parameter_Type_Date'),
value: 'date',
iconCls: 'input-date-font',
}, {
text: BI.i18nText('Plugin-Redis_Parameter_Type_Boolean'),
value: 'boolean',
iconCls: 'input-boolean-font',
}, {
text: BI.i18nText('Plugin-Redis_Parameter_Type_Formula'),
value: 'formula',
iconCls: 'input-formula-font',
}];
}
}

20
src/web/src/modules/components/preview/preview.model.ts

@ -0,0 +1,20 @@
import { model, Model } from '@core/core';
@model()
export class PreviewModel extends Model {
static xtype = 'plugin.model.report.redis.components.preview';
childContext = <const>['previewAble', 'previewedDataSet'];
state() {
return {
previewAble: true,
previewedDataSet: {},
};
}
actions = {
setPreviewedDataSet: (value: any) => {
this.model.previewedDataSet = value;
},
}
}

31
src/web/src/modules/components/preview/preview.ts

@ -0,0 +1,31 @@
import { shortcut, store } from '@core/core';
import { PreviewModel } from './preview.model';
@shortcut()
@store(PreviewModel)
export class Preview extends BI.Widget {
static xtype = 'plugin.report.redis.components.preview'
store: PreviewModel['store']
model: PreviewModel['model']
previewPane: any
props = {
previewedDataSet: {},
}
render() {
this.store.setPreviewedDataSet(this.options.previewedDataSet);
return {
type: 'dec.data.set.preview',
ref: (_ref: any) => {
this.previewPane = _ref;
},
};
}
created() {
this.previewPane.previewData();
}
}

4
src/web/src/modules/constants/env.ts

@ -0,0 +1,4 @@
export const fineServletURL = Dec.fineServletURL;
export const ReqPrefix = `${fineServletURL}/v10/config/connection`;
export const ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`;
export const PluginImgPrefix = `${fineServletURL}/resources?path=`;

59
src/web/src/modules/crud/crud.request.ts

@ -0,0 +1,59 @@
import { requestGet } from './crud.service';
import { formulaData } from './formulaData';
export function getConnectionlist(): Promise<{data?: Connection[]}> {
return requestGet('/v10/config/connection/list');
}
export function getTableList(database: string, pattern = '', orderValue: string | number): Promise<string[]> {
return requestGet('plugin/private/com.fr.solution.plugin.db.redis.v10/redis/keys', {
database,
pattern,
orderValue,
});
}
/**
*
*/
export function fetchFormulaConfig(): Promise<{
vars: {
text: string;
value: string;
type: string;
def: string;
}[];
JSONs: {
def: string;
name: string;
type: string;
}[];
}> {
// TODO 后台接口待完成
return new Promise(resolve => {
resolve(formulaData);
});
}
/**
*
* @param formulaStr
*/
export function validateForumula(formulaStr: string): Promise<{
validation: boolean;
}> {
// TODO 后台接口待完成
return new Promise(resolve => {
resolve({ validation: true });
});
}
export interface Connection {
connectionId: string;
connectionType: string;
connectionName: string;
creator?: string;
privilegeDetailBeanList?: {
privilegeType: number;
privilegeValue: number;
}[]
}

130
src/web/src/modules/crud/crud.service.ts

@ -0,0 +1,130 @@
import 'es6-promise/auto';
import axios, { AxiosResponse, AxiosError } from 'axios';
import { fineServletURL } from '../constants/env';
const defaultHeaders = {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
};
export function paramsSerializer(params: { [key: string]: any }) {
return Object.keys(params || {})
.map(paramKey => {
const paramValue = params[paramKey];
let value = '';
if (BI.isObject(paramValue)) {
value = encodeURIComponent(JSON.stringify(paramValue));
} else {
value = paramValue;
}
return BI.isNull(value) ? '' : `${paramKey}=${value}`;
})
.filter(v => v !== '')
.join('&');
}
function getCookieByName(name: string):string {
let value = null;
const regExpName = new RegExp(name);
document.cookie.split(';').forEach((item: string) => {
if (item.match(regExpName)) {
value = item.split(`${name}=`)[1];
return false;
}
});
return value;
}
function checkStatus(response: AxiosResponse) {
const status = response.status;
const resData = status === 200
? typeof response.data === 'string'
? BI.jsonDecode(response.data)
: response.data
: {};
return resData;
}
export async function request(reqOptions: CrudReqOpts = {}): Promise<any> {
const { url, type, headers, data, params } = reqOptions;
return axios
.request({
url,
baseURL: fineServletURL,
method: type,
headers: {
...defaultHeaders,
...headers,
Authorization: `Bearer ${getCookieByName('fine_auth_token')}`,
'Content-Type': 'application/json;charset=UTF-8',
},
params,
paramsSerializer,
data,
})
.then(checkStatus)
.catch((error: AxiosError) => {
console.log(error);
});
}
export function requestGet(url: string, params: CrudParams = {}) {
const timeStamp = new Date().getTime();
return request({
url,
type: 'GET',
params: {
...params,
_: timeStamp,
},
});
}
export function requestPost(url: string, data = {}, params: CrudParams = {}) {
return request({
url,
type: 'POST',
data,
params,
});
}
export function requestDelete(url: string, data = {}) {
return request({
url,
type: 'DELETE',
data,
});
}
export function requestPut(url: string, data = {}, params: CrudParams = {}) {
return request({
url,
type: 'PUT',
data,
params,
});
}
interface CrudReqOpts {
url?: string;
type?: 'GET' | 'POST' | 'DELETE' | 'PUT';
data?: any;
headers?: {
[key: string]: string;
};
noProgress?: boolean;
params?: CrudParams;
}
interface CrudParams {
[key: string]: string | number | { [key: string]: any };
}

549
src/web/src/modules/crud/formulaData.ts

@ -0,0 +1,549 @@
// 后期统一放置公式数据
export const formulaData = {
vars: [
{
text: '$$page_number',
value: '$$page_number',
type: 'VARS',
def: '当前的页数。',
},
{
text: '$$totalPage_number',
value: '$$totalPage_number',
type: 'VARS',
def: '总页数。',
},
],
JSONs: [
{
def: 'ABS(number): 返回指定数字的绝对值。绝对值是指没有正负符号的数值。Number:需要求出绝对值的任意实数。示例:ABS(-1.5)等于1.5。ABS(0)等于0。ABS(2.5)等于2.5。',
name: 'ABS',
type: 'MATH',
},
{
def: 'ABS(number): 返回指定数字的绝对值。绝对值是指没有正负符号的数值。Number:需要求出绝对值的任意实数。示例:ABS(-1.5)等于1.5。ABS(0)等于0。ABS(2.5)等于2.5。',
name: 'ABS',
type: 'COMMON',
},
{
def: 'acc_sum(x_agg(array),range)根据横纵轴或行列维度添加的字段对指标进行跨行累计的计算。第一个参数为用户计算的指标,该指标必须为聚合函数或聚合指标;第二个参数range为用户设置计算的范围,0为对所有行进行累计,1为对组内所有行进行累计示例:acc_sum(sum_agg(array),0)用户横轴轴拖拽销售日期(年分组),则该指标计算结果为,根据销售日期(年)对销量进行分组汇总,然后根据对所有行从上到下进行累加,获得每年的累计销量',
name: 'ACC_SUM',
type: 'TABLE_CAL',
},
{
def: 'ACOS(number): 返回指定数值的反余弦值。反余弦值为一个角度,返回角度以弧度形式表示。Number:需要返回角度的余弦值。备注: 函数的参数必须在-1和1之间,包括-1和1。 返回的角度值在0和Pi之间。 如果要把返回的角度用度数来表示,用180/PI()乘返回值即可。示例:ACOS(1)等于0(弧度)。ACOS(0.5)等于1.047197551(Pi/3弧度)。ACOS(0.5)*180/PI()等于60(度)。',
name: 'ACOS',
type: 'MATH',
},
{
def: 'AND(logical1,logical2,…): 当所有参数的值为真时,返回TRUE;当任意参数的值为假时,返回FALSE。Logical1,logical2,…:指1到30个需要检验TRUE或FALSE的条件值。备注: 参数必须是逻辑值,或是含有逻辑值的数组或引用。 如果数组或引用中含有文本或空的单元格,则忽略其值。 如果在指定的单元格区域中没有逻辑值,AND函数将返回错误信息*NAME?。示例:AND(1+7=8,5+7=12)等于TRUE。AND(1+7=8,5+7=11)等于FALSE。如果单元格A1到A4的值分别为TRUE、TRUE、FALSE和TRUE,则:AND(A1:A4)等于FALSE。如果单元格A5的值在0~50之间,则: AND(0<A5,A5<50)等于TRUE。',
name: 'AND',
type: 'LOGIC',
},
{
def: 'ASIN(number): 返回指定数值的反正弦值。反正弦值为一个角度,返回角度以弧度形式表示。Number:需要返回角度的正弦值。备注: 指定数值必须在-1到1之间(含1与-1)。 返回角度在-pi/2到pi/2之间(含-pi/2与pi/2)。 用角度形式返回数值时,返回数值乘以180/PI()。示例:ASIN(0.5)等于0.523598776(pi/6弧度)。ASIN(1)等于1.570796327(pi/2弧度)。ASIN(0.5)*180/PI()等于30(度)。',
name: 'ASIN',
type: 'MATH',
},
{
def: 'ATAN(number): 计算指定数值的反正切值。指定数值是返回角度的正切值,返回角度以弧度形式表示。Number:返回角度的正切。备注: 返回角度在-pi/2到pi/2之间。 如果返回角度等于-pi/2或pi/2,ATAN将返回错误信息*NUM!。 用角度形式返回数值时,返回数值乘以180/PI()。示例:ATAN(-1)等于-0.785398163(-pi/4弧度)。ATAN(0)等于0(弧度)。ATAN(2)*180/PI()等于63.43494882(度)。',
name: 'ATAN',
type: 'MATH',
},
{
def: 'ATAN2(x_num,y_num): 返回x、y坐标的反正切值。返回角度为x轴与过(x_num,y_num)与坐标原点(0,0)的一条直线形成的角度。该角度以弧度显示。X_num:指定点的x坐标。Y_num:指定点的y坐标。备注: 正值表示从x轴开始以逆时针方式所得的角度;负值表示从x轴开始以顺时针方式所得的角度。a > 0,b > 0 or a > 0, b < 0时,公式直接成立;a < 0,b > 0, ATAN2(a,b)=PI()-ABS(ATAN(b/a))a < 0,b < 0, ATAN2(a,b)=ABS(ATAN(b/a))-PI() 当x_num与y_num都为0时,ATAN2返回错误信息*DIV/0!。 用角度制显示返回数值时,把返回数值乘以180/PI()。 返回值以弧度表示(返回值大于-pi且小于等于pi)。示例:ATAN2(-2,2)等于2.356194490192345(弧度制的3*pi/4)。ATAN2(2,2)等于0.785398163(弧度制的pi/4)。ATAN2(-2,2)*180/PI()等于135(角度制)。',
name: 'ATAN2',
type: 'MATH',
},
{
def: 'AVG_AGG(array): 根据当前分析维度,动态返回指标字段的汇总平均值,生成结果为一动态数据列,行数与当前分析维度行数一致。\n array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。 \n 示例:用户横轴为维度字段\'日\'时,纵轴的计算字段AVG_AGG(销量)返回的值为每日的平均销量;当用户横轴为维度字段\'月\'时,AVG_AGG(销量)返回的值为每月的平均销量。',
name: 'AVG_AGG',
type: 'AGG',
},
{
def: 'CEILING(number): 将参数number沿绝对值增大的方向,舍入为最接近的整数Number:指待舍入的数值。CEILING(-2.5)等于-3。CEILING(0.5)等于1。',
name: 'CEILING',
type: 'MATH',
},
{
def: 'CHAR(number): 根据指定数字返回对应的字符。CHAR函数可将计算机其他类型的数字代码转换为字符。Number:用于指定字符的数字,介于1~65535之间(包括1和65535)。示例:CHAR(88)等于“X”。CHAR(45)等于“-”。',
name: 'CHAR',
type: 'TEXT',
},
{
def: 'CODE(text): 计算文本串中第一个字符的数字代码。返回的代码对应于计算机使用的字符集。Text:需要计算第一个字符代码的文本或单元格引用。示例:CODE("S")等于83。CODE("Spreadsheet")等于83。',
name: 'CODE',
type: 'TEXT',
},
{
def: 'CONCATENATE(text1,text2,...): 将数个字符串合并成一个字符串。Text1,text2,...:需要合并成单个文本的文本项,可以是字符,数字或是单元格引用。示例:CONCATENATE("Average ","Price")等于“Average Price”。CONCATENATE("1","2")等于12。',
name: 'CONCATENATE',
type: 'TEXT',
},
{
def: 'COS(number): 返回一个角度的余弦值。Number:以弧度表示的需要求余弦值的角度。备注: 要把一个角度转换成弧度值,将角度乘于PI()/180。 COS(n*2*PI()+number)=COS(number)(其中n为整数,number从-pi到pi)。示例:COS(0.5)等于0.877582562。COS(30*PI()/180)等于0.866025404。',
name: 'COS',
type: 'MATH',
},
{
def: 'COUNTD_AGG(array): 根据当前分析维度,动态返回某字段的去重计数,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段COUNTD_AGG(销量)返回的值为每日的销量的去重个数;当用户横轴为维度字段\'月\'时,COUNTD_AGG(销量)返回的值为每月的销量的去重个数。"',
name: 'COUNTD_AGG',
type: 'AGG',
},
{
def: 'COUNT_AGG(array): 根据当前分析维度,动态返回某字段的计数,生成结果为一动态数据列,行数与当前分析维度行数一致。\n array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n 示例:用户横轴为维度字段\'日\'时,纵轴的计算字段COUNT_AGG(销量)返回的值为每日的销量的个数;当用户横轴为维度字段\'月\'时,COUNT_AGG(销量)返回的值为每月的销量的个数。',
name: 'COUNT_AGG',
type: 'AGG',
},
{
def: 'DATE(year,month,day): 返回一个表示某一特定日期的系列数。Year:代表年,可为一到四位数。Month:代表月份。若1 month 12,则函数把参数值作为月。若month>12,则函数从年的一月份开始往上累加。例如: DATE(2000,25,2)等于2002年1月2日的系列数。Day:代表日。若日期小于等于某指定月的天数,则函数将此参数值作为日。若日期大于某指定月的天数,则函数从指定月份的第一天开始往上累加。若日期大于两个或多个月的总天数,则函数把减去两个月或多个月的余数加到第三或第四个月上,依此类推。例如:DATE(2000,3,35)等于2000年4月4日的系列数。备注: 若需要处理公式中日期的一部分,如年或月等,则可用此公式。 若年,月和日是函数而不是函数中的常量,则此公式最能体现其作用。示例:DATE(1978, 9, 19) 等于1978-09-19.DATE(1211, 12, 1) 等于1211-12-01. ',
name: 'DATE',
type: 'DATETIME',
},
{
def: 'DATEDELTA(date, deltadays):返回一个日期date后deltadays的日期。deltaDays可以为正值,负值,零。示例:DATEDELTA("2008-08-08", -10)等于2008-07-29。DATEDELTA("2008-08-08", 10)等于2008-08-18。',
name: 'DATEDELTA',
type: 'DATETIME',
},
{
def: 'DATEDIF(start_date,end_date,unit):返回两个指定日期间的天数、月数或年数。Start_date:代表所指定时间段的初始日期。End_date:代表所指定时间段的终止日期。Unit:函数返回信息的类型。若unit=“Y”,则DATEDIF返回指定时间段的年差数。若unit=“M”,则DATEDIF返回指定时间段的月差数。若unit=“D”,则DATEDIF返回指定时间段的日差数。若unit=“MD”,则DATEDIF忽略年和月,返回指定时间段的日差数。若unit=“YM”,则DATEDIF忽略年和日,返回指定时间段的月差数。若unit=“YD”,则DATEDIF忽略年,返回指定时间段的日差数。示例:DATEDIF("2001/2/28","2004/3/20","Y")等于3,即在2001年2月28日与2004年3月20日之间有3个整年。DATEDIF("2001/2/28","2004/3/20","M")等于37,即在2001年2月28日与2004年3月20日之间有36个整月。DATEDIF("2001/2/28","2004/3/20","D")等于1116,即在2001年2月28日与2004年3月20日之间有1116个整天。DATEDIF("2001/2/28","2004/3/20","MD")等于8,即忽略月和年后,2001年2月28日与2004年3月20日的差为8天。DATEDIF("2001/1/28","2004/3/20","YM")等于2,即忽略日和年后,2001年1月28日与2004年3月20日的差为2个月。DATEDIF("2001/2/28","2004/3/20","YD")等于21,即忽略年后,2001年2月28日与2004年3月20日的差为21天。',
name: 'DATEDIF',
type: 'DATETIME',
},
{
def: 'DATESUBDATE(date1, date2, op):返回两个日期之间的时间差。op表示返回的时间单位:"s",以秒为单位。"m",以分钟为单位。"h",以小时为单位。"d",以天为单位。"w",以周为单位。示例:DATESUBDATE("2008-08-08", "2008-06-06","h")等于1512。',
name: 'DATESUBDATE',
type: 'DATETIME',
},
{
def: 'DATETONUMBER(date):返回自 1970 年 1 月 1 日 00:00:00 GMT 经过的毫秒数。示例:DATETONUMBER("2008-08-08")等于1218124800000。',
name: 'DATETONUMBER',
type: 'DATETIME',
},
{
def: 'DAY:(serial_number)返回日期中的日。DAY是介于1和31之间的一个数。Serial_number:含有所求的年的日期.备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。示例:DAY("2000/1/1")等于1。DAY("2006/05/05")等于5。DAY("1997/04/20")等于20。DAY("2000-1-1", "yyyy-MM-dd")等于1。DAY("2006-05-05", "yyyy-MM-dd")等于5。DAY("1997-04-20", "yyyy-MM-dd")等于20。DAY(35796)等于1。',
name: 'DAY',
type: 'DATETIME',
},
{
def: 'DAYS360(start_date,end_date,method):按照一年 360 天的算法(每个月以 30 天计,一年共计 12 个月),返回两日期间相差的天数,这在会计计算中将会用到。如果财务系统是基于一年 12 个月,每月 30 天,可用此函数帮助计算支付款项。Start_date 和 end_date :是用于计算期间天数的起止日期。Method : 它指定了在计算中是采用欧洲方法还是美国方法。Method 定义 :FALSE或忽略 美国方法 (NASD)。如果起始日期是一个月的 31 号,则等于同月的 30 号。如果终止日期是一个月的31号,并且起始日期早于 30 号,则终止日期等于下一个月的 1 号,否则,终止日期等于本月的 30 号。TRUE 欧洲方法。无论是起始日期还是终止日期为一个月的 31 号,都将等于本月的 30 号。备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。示例:DAYS360("1998/1/30", "1998/2/1") 等于 1',
name: 'DAYS360',
type: 'DATETIME',
},
{
def: 'DAYSOFMONTH(date):返回从1900年1月后某年某月包含的天数。示例:DAYSOFMONTH("1900-02-01")等于28。DAYSOFMONTH("2008/04/04")等于30。',
name: 'DAYSOFMONTH',
type: 'DATETIME',
},
{
def: 'DAYSOFQUARTER(date): 返回从1900年1月后某年某季度的天数。示例:DAYSOFQUARTER("2009-02-01")等于90。DAYSOFQUARTER("2009/05/05")等于91。',
name: 'DAYSOFQUARTER',
type: 'DATETIME',
},
{
def: 'DAYSOFYEAR(year):返回某年包含的天数。示例:DAYSOFYEAR(2008)等于365,等价于DAYSOFYEAR("2008-01-01")。',
name: 'DAYSOFYEAR',
type: 'DATETIME',
},
{
def: 'DAYVALUE(date):返回1900年至 date日期所经历的天数。示例:DAYVALUE("2008/08/08")等于39669。',
name: 'DAYVALUE',
type: 'DATETIME',
},
{
def: 'DEGREES(angle): 将弧度转化为度。angle:待转换的弧度角。示例:DEGREES(PI()/2)等于90。DEGREES(3.1415926)等于179.9999969。',
name: 'DEGREES',
type: 'MATH',
},
{
def: 'ENDWITH(str1,str2):判断字符串str1是否以str2结束。备注: str1和str2都是大小写敏感的。示例:ENDWITH("FineReport","Report")等于true。ENDWITH("FineReport","Fine")等于false。ENDWITH("FineReport","report")等于false。',
name: 'ENDWITH',
type: 'TEXT',
},
{
def: 'EXACT(text1,text2): 检测两组文本是否相同。如果完全相同,EXACT函数返回TRUE;否则,返回FALSE。EXACT函数可以区分大小写,但忽略格式的不同。同时也可以利用EXACT函数来检测输入文档的文字。Text1:需要比较的第一组文本。Text2:需要比较的第二组文本。示例:EXACT("Spreadsheet","Spreadsheet")等于TRUE。EXACT("Spreadsheet","S preadsheet")等于FALSE。EXACT("Spreadsheet","spreadsheet")等于FALSE。',
name: 'EXACT',
type: 'TEXT',
},
{
def: 'EXP(number): 返回e的n次幂。常数e为自然对数的底数,等于2.71828182845904。Number:为任意实数,作为常数e的指数。备注: 如果要返回其他常数作为底数的幂,可以使用指数运算符(^)。例如: 在4^2中,4是底数,而2是指数。 EXP函数与LN函数互为反函数。示例:EXP(0)等于1。EXP(3)等于20.08553692。EXP(LN(2))等于2。',
name: 'EXP',
type: 'MATH',
},
{
def: 'FACT(number):返回数的阶乘,一个数的阶乘等于 1*2*3*...*该数。number:要计算其阶乘的非负数。如果输入的 number 不是整数,则截尾取整。示例:FACT(1) 等于 1FACT(1.9) 等于 FACT(1) 等于 1FACT(0) 等于 1FACT(5) 等于 1*2*3*4*5 等于 120',
name: 'FACT',
type: 'MATH',
},
{
def: 'FIND(find_text,within_text,start_num):从指定的索引(start_num)处开始,返回第一次出现的指定子字符串(find_text)在此字符串(within_text)中的索引。Find_text:需要查找的文本或包含文本的单元格引用。Within_text:包含需要查找文本的文本或单元格引用。Start_num:指定进行查找字符的索引位置。within_text里的索引从1开始。如果省略start_num,则假设值为1。备注: 如果find_text不在within_text中,FIND函数返回值为0。 如果start_num不大于0,FIND函数返回错误信息*VALUE!。 如果start_num大于within_text的长度,FIND函数返回值为0。 如果find_text是空白文本,FIND函数将在搜索串中匹配第一个字符(即编号为start_num或1的字符)。示例:FIND("I","Information")等于1。FIND("i","Information")等于9。FIND("o","Information",2)等于4。FIND("o","Information",12)等于0。FIND("o","Information",-1)等于*VALUE!。',
name: 'FIND',
type: 'TEXT',
},
{
def: 'FLOOR(number): 将参数number沿绝对值减小的方向去尾舍入。Number:待舍入的数值。示例:FLOOR(-2.5)等于-2。FLOOR(2.5)等于2。',
name: 'FLOOR',
type: 'MATH',
},
{
def: 'FORMAT(object,format) : 返回object的format格式。object 需要被格式化对象,可以是String,数字,Object(常用的有Date, Time)。format 格式化的样式。示例FORMAT(1234.5, "#,##0.00") => 1234.50FORMAT(1234.5, "#,##0") => 1234FORMAT(1234.5, "¥#,##0.00") => ¥1234.50FORMAT(1.5, "0%") => 150%FORMAT(1.5, "0.000%") => 150.000%FORMAT(6789, "##0.0E0") => 6.789E3FORMAT(6789, "0.00E00") => 6.79E03FORMAT(date(2007,1,1), "EEEEE, MMMMM dd, yyyy") => 星期一,一月 01,2007FORMAT(date(2007,1,13), "MM/dd/yyyy") => 01/13/2007FORMAT(date(2007,1,13), "M-d-yy") => 1-13-07FORMAT(time(16,23,56), "h:mm:ss a") => 4:23:56 下午',
name: 'FORMAT',
type: 'TEXT',
},
{
def: 'HOUR(serial_number):返回某一指定时间的小时数。函数指定HOUR为0(0:00)到23(23:00)之间的一个整数。Serial_number:包含所求小时的时间。示例:HOUR("11:32:40")等于11。HOUR("11:32:40", "HH:mm:ss")等于11。',
name: 'HOUR',
type: 'DATETIME',
},
{
def: 'IF(boolean,number1/string1,number2/string2):判断函数,boolean为true时返回第二个参数,为false时返回第三个。boolean: 用于判断的布尔值,true或者false。number1/string1: 第一个参数,如果boolean为ture,返回这个值。number2/string2: 第二个参数,如果boolean为false,返回这个值。示例:IF(true,2,8)等于2IF(false,"first","second")等于secondIF(true,"first",7)等于first',
name: 'IF',
type: 'LOGIC',
},
{
def: 'IF(boolean,number1/string1,number2/string2):判断函数,boolean为true时返回第二个参数,为false时返回第三个。boolean: 用于判断的布尔值,true或者false。number1/string1: 第一个参数,如果boolean为ture,返回这个值。number2/string2: 第二个参数,如果boolean为false,返回这个值。示例:IF(true,2,8)等于2IF(false,"first","second")等于secondIF(true,"first",7)等于first',
name: 'IF',
type: 'COMMON',
},
{
def: 'INDEXOF(str1,index):返回字符串str1在index位置上的字符。备注: index是从0开始计数的。示例:INDEXOF("FineReport",0)等于\'F\'。INDEXOF("FineReport",2)等于\'n\'。INDEXOF("FineReport",9)等于\'t\'。INDEXOF(array, index):返回数组在index位置上的元素。备注: index是从1开始计数的。示例:String[] array = {"a", "b", "c"}INDEXOF(array, 1)等于"a".',
name: 'INDEXOF',
type: 'TEXT',
},
{
def: 'INT(number): 返回数字下舍入(数值减小的方向)后最接近的整数值。Number:需要下舍入为整数的实数。示例:INT(4.8)等于4。INT(-4.8)等于-5。INT(4.3)等于4。INT(-4.3)等于-5。公式INT(A1)将返回A1单元格中的一个正实数的整数数部分。',
name: 'INT',
type: 'MATH',
},
{
def: 'INT(number): 返回数字下舍入(数值减小的方向)后最接近的整数值。Number:需要下舍入为整数的实数。示例:INT(4.8)等于4。INT(-4.8)等于-5。INT(4.3)等于4。INT(-4.3)等于-5。公式INT(A1)将返回A1单元格中的一个正实数的整数数部分。',
name: 'INT',
type: 'COMMON',
},
{
def: 'ISNULL(object):判断对象中所有的值是否全部都是NULL或者为空字符串。',
name: 'ISNULL',
type: 'OTHER',
},
{
def: 'LEFT(text,num_chars): 根据指定的字符数返回文本串中的第一个或前几个字符。Text:包含需要选取字符的文本串或单元格引用。Num_chars:指定返回的字符串长度。备注: Num_chars的值必须等于或大于0。 如果num_chars大于整个文本的长度,LEFT函数将返回所有的文本。 如果省略num_chars,则默认值为1。示例:LEFT("Fine software",8)等于“Fine sof”。LEFT("Fine software")等于“F”。如果单元格A3中含有“China”,则LEFT(A3,2)等于“Ch”。',
name: 'LEFT',
type: 'TEXT',
},
{
def: 'LEN(args): 返回文本串中的字符数或者数组的长度。需要注意的是:参数args为文本串时,空格也计为字符。参数args为数组时,直接返回数组长度。示例:LEN("Evermore software")等于17。LEN(" ")等于1。LEN([\'a\',\'b\'])等于2。',
name: 'LEN',
type: 'TEXT',
},
{
def: 'LN(number):返回一个数的自然对数。自然对数以常数项 e(2.71828182845904)为底。number:是用于计算其自然对数的正实数。示例:LN(86) 等于 4.45437LN(2.7182818) 等于 1LN(EXP(3)) 等于 3EXP(LN(4)) 等于 4',
name: 'LN',
type: 'MATH',
},
{
def: 'LOG(number,base): 按指定的任意底数,返回数值的对数。Number:需要求对数的正实数。Base:对数的底数。如果省略底数,默认值为10。示例:LOG(16,2)等于4。LOG(10)等于1。LOG(24,3)等于2.892789261。',
name: 'LOG',
type: 'MATH',
},
{
def: 'LOG10(number):返回以 10 为底的对数。number: 用于常用对数计算的正实数。示例:LOG10(86) 等于 1.934498451LOG10(10) 等于 1LOG10(1E5) 等于 5',
name: 'LOG10',
type: 'MATH',
},
{
def: 'LOWER(text): 将所有的大写字母转化为小写字母。Text:需要转化为小写字母的文本串。LOWER函数不转化文本串中非字母的字符。示例:LOWER("A.M.10:30")等于“a.m.10:30”。LOWER("China")等于“china”。',
name: 'LOWER',
type: 'TEXT',
},
{
def: 'LUNAR(year,day,month): 返回当前日期对应的农历时间。year,month,day:分别对应年月日。示例:如果需要查询2011年7月21日对应的农历时间,则只需输入LUNAR(2011,7,21)结果将显示为:辛卯年六月廿一同样,如输入LUNAR(2001,7,21),则显示:辛巳年六月初一 。本公式支持的时间段为1900-2100年。',
name: 'LUNAR',
type: 'DATETIME',
},
{
def: 'MAX(number1,number2,…): 返回参数列表中的最大值。Number1,number2,…:1到30个需要找出最大值的参数。备注: 参数可以是数字、空白单元格、逻辑值或数字的文本表达式。 如果数组或引用参数中包含可解析文本值,逻辑值,零值或空白单元格,这些值都将参与计算,而不可解析的文本值忽略不计。 如果参数中没有任何数字,MAX将返回0。示例:MAX(0.1,0,1.2)等于1.2。',
name: 'MAX',
type: 'MATH',
},
{
def: 'MAX_AGG(array): 根据当前分析维度,动态返回指标字段的最大值,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段MAX_AGG(销量)返回的值为每日的最大值销量;当用户横轴为维度字段\'月\'时,MAX_AGG(销量)返回的值为每月的最大值销量。',
name: 'MAX_AGG',
type: 'AGG',
},
{
def: 'MEDIAN_AGG(array): 根据当前分析维度,动态返回指标字段的中位数,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段MEDIAN_AGG(销量)返回的值为每日的中位数销量;当用户横轴为维度字段\'月\'时,MEDIAN_AGG(销量)返回的值为每月的中位数销量。',
name: 'MEDIAN_AGG',
type: 'AGG',
},
{
def: 'MID(text,start_num,num_chars): 返回文本串中从指定位置开始的一定数目的字符,该数目由用户指定。Text:包含要提取字符的文本串。Start_num:文本中需要提取字符的起始位置。文本中第一个字符的start_num为1,依此类推。Num_chars:返回字符的长度。备注: 如果start_num大于文本长度,MID函数返回“”(空文本)。 如果start_num小于文本长度,并且start_num加上num_chars大于文本长度,MID函数将从start_num指定的起始字符直至文本末的所有字符。 如果start_num小于1,MID函数返回错误信息*VALUE!。 如果num_chars是负数,MID函数返回错误信息*VALUE!。示例:MID("Finemore software",10,8)返回“software”。MID("Finemore software",30,5)返回“”(空文本)。MID("Finemore software",0,8)返回*VALUE!。MID("Finemore software",5,-1)返回*VALUE!。',
name: 'MID',
type: 'TEXT',
},
{
def: 'MIN(number1,number2,…): 返回参数列表中的最小值。Number1,number2,…:1到30个需要找出最小值的参数。备注: 若参数中没有数字,函数MIN将返回0。 参数应为数字、空白单元格、逻辑值或是表示数值的文本串。如果参数是错误值时,MIN将返回错误信息。 如果数组或引用参数中包含可解析文本值,逻辑值,零值或空白单元格,这些值都将参与计算,而不可解析的文本值忽略不计。示例:如果B1:B4包含3,6,9,12,则:MIN(B1:B4)等于3。MIN(B1:B4,0)等于0。',
name: 'MIN',
type: 'MATH',
},
{
def: 'MINUTE(serial_number):返回某一指定时间的分钟数,其值是介于0与59之间的一个整数。serial_number:包含所求分钟数的时间。示例:MINUTE("15:36:25")等于36。MINUTE("15:36:25", "HH:mm:ss")等于36。',
name: 'MINUTE',
type: 'DATETIME',
},
{
def: 'MIN_AGG(array): 根据当前分析维度,动态返回指标字段的最小值,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段MIN_AGG(销量)返回的值为每日的最小值销量;当用户横轴为维度字段\'月\'时,MIN_AGG(销量)返回的值为每月的最小值销量。',
name: 'MIN_AGG',
type: 'AGG',
},
{
def: 'MOD(number,divisor):返回两数相除的余数。结果的正负号与除数相同。number:为被除数。divisor:为除数。示例:MOD(3, 2) 等于 1MOD(-3, 2) 等于 1MOD(3, -2) 等于 -1MOD(-3, -2) 等于 -1',
name: 'MOD',
type: 'MATH',
},
{
def: 'MONTH:(serial_number)返回日期中的月。月是介于1和12之间的一个数。Serial_number:含有所求的月的日期.备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。示例:MONTH("2000/1/1")等于1。MONTH("2006/05/05")等于5。MONTH("1997/04/20")等于4。MONTH("2000-1-1", "yyyy-MM-dd")等于1。MONTH("2006-05-05", "yyyy-MM-dd")等于5。MONTH("1997-04-20", "yyyy-MM-dd")等于4。MONTH(35796)等于1。',
name: 'MONTH',
type: 'DATETIME',
},
{
def: 'MONTHDELTA(date,delta):返回指定日期date后delta个月的日期。示例:MONTHDELTA("2008-08-08", 4)等于2008-12-08。',
name: 'MONTHDELTA',
type: 'DATETIME',
},
{
def: 'NOW():获取当前时间。示例:如果系统时间是2012年5月12日 15点18分38秒则NOW()等于2012-05-12 15:18:36。',
name: 'NOW',
type: 'DATETIME',
},
{
def: 'NUMTO(number,bool)或NUMTO(number):返回number的中文表示。其中bool用于选择中文表示的方式,当没有bool时采用默认方式显示。示例:NUMTO(2345,true)等于二三四五。示例:NUMTO(2345,false)等于二千三百四十五。示例:NUMTO(2345)等于二千三百四十五。',
name: 'NUMTO',
type: 'TEXT',
},
{
def: 'NVL(value1,value2,value3,...):在所有参数中返回第一个不是null的值value1:可以为任意数,也可以为null。value2:可以为任意数,也可以为null。当字符串长度为0时, 返回也为null示例:NVL(12,20)等于12。NVL(null,12)等于12。NVL(null,null)等于null。NVL(20,null)等于20。NVL(null,null,10)等于10。',
name: 'NVL',
type: 'OTHER',
},
{
def: 'OR(logical1,logical2,…): 当所有参数的值为假时,返回FALSE;当任意参数的值为真时,返回TRUE。Logical1,logical2,…:指1到30个需要检验TRUE或FALSE的条件值。备注: 参数必须是逻辑值,或是含有逻辑值的数组或引用。 如果数组或引用中含有文本或空的单元格,则忽略其值。 如果在指定的单元格区域中没有逻辑值,AND函数将返回错误信息*NAME?。示例:OR(1+7=9,5+7=11)等于FALSE。OR(1+7=8,5+7=11)等于TRUE。',
name: 'OR',
type: 'LOGIC',
},
{
def: 'period_anls(x_agg(array),datepart)根据横纵轴或行列维度添加的日期字段进行上期末的计算。第一个参数为用于计算的指标,该指标必须为聚合函数或聚合指标;第二个参数用于配置计算的上期末为上年期末或者上月期末。横纵轴拖拽的字段不满足函数的计算要求时,该指标会标红。示例:period_anls(sum_agg(amount),"Y") 用户横纵轴拖拽销售日期(年月日分组),则该指标计算结果为,根据年月日对销量进行分组汇总,然后计算出该日数据上年年末的销量;如果参数2为“M”,则计算结果为该日销量上月月末的销量。',
name: 'PERIOD_ANLS',
type: 'TABLE_CAL',
},
{
def: 'PI(number): 是一个数学常量函数,当number为空时,函数返回精确到15位的数值3.141592653589793;当参数不为空时,number表示PI的倍数。示例:SIN(PI()/2)等于1。计算圆的面积的公式: S=PI()*(r^2),其中S为圆的面积,R为圆的半径。PI(3)等于9.42477796076938。',
name: 'PI',
type: 'MATH',
},
{
def: 'POWER(number,power): 返回指定数字的乘幂。Number:底数,可以为任意实数。Power:指数。参数number按照该指数次幂乘方。备注: 可以使用符号“^”代替POWER,如: POWER(5,2)等于5^2。示例:POWER(6,2)等于36。POWER(14,5)等于537824。POWER(4,2/3)等于2.519842100。POWER(3,-2.3)等于0.079913677。',
name: 'POWER',
type: 'MATH',
},
{
def: 'previous_period(x_agg(array))根据横纵轴或行列维度添加的日期字段进行环期值的计算。参数为用于计算的指标,该指标必须为聚合函数或聚合指标。横纵轴拖拽的字段不满足函数的计算要求时,该指标会标红。示例:previous_period(sum_agg(amount)) 用户横纵轴拖拽销售日期(年月日分组),则该指标计算结果为,根据年月日对销量进行分组汇总,然后计算出该日数据上一日的销量。',
name: 'PREVIOUS_PERIOD',
type: 'TABLE_CAL',
},
{
def: 'PROMOTION(value1,value2):返回value2在value1上提升的比例。示例:PROMOTION(12, 14)等于0.166666666,即提升了16.6666666%.PROMOTION(-12, 14)等于2.166666666,即提升了216.6666666%.',
name: 'PROMOTION',
type: 'MATH',
},
{
def: 'PROPER(text): 将文本中的第一个字母和所有非字母字符后的第一个字母转化成大写,其他字母变为小写。Text:需要转化为文本的公式、由双引号引用的文本串或是单元格引用。示例:PROPER("Finemore Integrated Office")等于“Finemore Integrated Office”。PROPER("100 percent")等于“100 Percent”。PROPER("SpreaDSheEt")等于“Spreadsheet”。',
name: 'PROPER',
type: 'TEXT',
},
{
def: 'RADIANS(angle): 将角度转换成弧度。Angle:需要转换为弧度的角度。示例:RADIANS(90)等于1.570796327。',
name: 'RADIANS',
type: 'MATH',
},
{
def: 'RAND(): 返回均匀分布的随机数。每计算一次工作表,函数都会返回一个新的随机数值。备注: 要生成一个位于a和b之间的随机数,可以使用以下的公式: C=RAND()*(b-a)+a。 如果要使一个随机产生的数值不随单元格的重计算而改变,可以在编辑框中输入=RAND()并保持编辑状态,然后按F9,将公式永久性地改为随机数。示例:假如需要生成一个大于等于0,小于60的随机数,使用公式: =RAND()*60。假如需要生成一个大于等于0,小于19的随机数,使用公式: =RAND()*19。假如需要生成一个大于等于0,小于50的随机数,使用公式: =RAND()*50。',
name: 'RAND',
type: 'MATH',
},
{
def: 'RANDBETWEEN(value1,value2):返回value1和value2之间的一个随机整数。示例:RANDBETWEEN(12.333, 13.233)只会返回13。RANDBETWEEN(11.2, 13.3)有可能返回12或者13。',
name: 'RANDBETWEEN',
type: 'MATH',
},
{
def: 'rank_anls(x_agg(array),range,order)根据横纵轴或行列维度添加的字段对指标进行跨行排名的计算。第一个参数为用户计算的指标,该指标必须为聚合函数或聚合指标;第二个参数range为用户设置计算的范围,0为对所有行进行排名,1为对组内所有行进行排名;第三个参数order为排名的计算规则,"asc"为升序排名,"desc"为降序排名。示例:rank_anls(sum_agg(amount),0,"asc")用户横轴轴拖拽省份,则该指标计算结果为,根据省份对销量进行分组汇总,然后计算每个省份的销量在所有省份中的升序排名情况。',
name: 'RANK_ANLS',
type: 'TABLE_CAL',
},
{
def: 'REGEXP(str, pattern):字符串str是否与正则表达式pattern相匹配。示例:REGEXP("aaaaac","a*c")等于true。REGEXP("abc","a*c")等于false。REGEXP(str, pattern, intNumber):字符串str是否与具有给定模式 intNumber的正则表达式pattern相匹配。示例:CASE_INSENSITIVE = 0 启用不区分大小写的匹配。 默认情况下,不区分大小写的匹配假定仅匹配 US-ASCII 字符集中的字符。可以通过指 定 UNICODE_CASE 标志连同此标志来启用 Unicode 感知的、不区分大小写的匹配。 MULTILINE = 1 启用多行模式。DOTALL = 2 启用 dotall 模式。在 dotall 模式中,表达式 . 可以匹配任何字符,包括行结束符。默认情况下,此表达式不匹配行 结束符。UNICODE_CASE = 3 启用 Unicode 感知的大小写折叠。指定此标志后,由 CASE_INSENSITIVE 标志启用时,不区分大小写的匹配将以 符合 Unicode Standard 的方式完成。CANON_EQ = 4 启用规范等价。 指定此标志后,当且仅当其完整规范分解匹配时,两个字符才可视为匹配。UNIX_LINES = 5 启用 Unix 行模式。 在此模式中,.、^ 和 $ 的行为中仅识别 \'\n\' 行结束符。LITERAL = 6 启用模式的字面值解析。 指定此标志后,指定模式的输入字符串就会作为字面值字符序列来对待。输入序列中的 元字符或转义序列不具有任何特殊意义。 标志 CASE_INSENSITIVE 和 UNICODE_CASE 在与此标志一起使用时将 对匹配产生影响。其他标志都变得多余了。COMMENTS = 7 模式中允许空白和注释。 此模式将忽略空白和在结束行之前以 # 开头的嵌入式注释。 REGEXP("Aaaaabbbbc","a*b*c", 3)等于true。REGEXP("Aaaaabbbbc","a*b*c", 1)等于false。',
name: 'REGEXP',
type: 'TEXT',
},
{
def: 'REPEAT(text,number_times): 根据指定的次数重复显示文本。REPEAT函数可用来显示同一字符串,并对单元格进行填充。Text:需要重复显示的文本或包含文本的单元格引用。Number_times:指定文本重复的次数,且为正数。如果number_times为0,REPEAT函数将返回“”(空文本)。如果number_times不是整数,将被取整。REPEAT函数的最终结果通常不大于32767个字符。备注: 该函数可被用于在工作表中创建简单的直方图。示例:REPEAT("$",4)等于“$$$$”。如果单元格B10的内容为“你好”,REPEAT(B10,3)等于“你好你好你好”。',
name: 'REPEAT',
type: 'TEXT',
},
{
def: 'REPLACE(text, texttoreplace, replacetext):根据指定字符串,用其他文本来代替原始文本中的内容。text:需要被替换部分字符的文本或单元格引用。texttoreplace:指定的字符串。replacetext:需要替换部分旧文本的文本。示例:REPLACE("abcd", "a", "re")等于"rebcd"。REPLACE("a**d", "**d", "rose")等于"arose"。REPLACE(old_text,start_num,num_chars,new_text): 根据指定的字符数,用其他文本串来替换某个文本串中的部分内容。Old_text:需要被替换部分字符的文本或单元格引用。Start_num:需要用new_text来替换old_text中字符的起始位置。Num_chars:需要用new_text来替换old_text中字符的个数。New_text:需要替换部分旧文本的文本。示例:REPLACE("0123456789",5,4,"*")等于“0123*89”。REPLACE("1980",3,2,"99")等于“1999”。',
name: 'REPLACE',
type: 'TEXT',
},
{
def: 'RIGHT(text,num_chars): 根据指定的字符数从右开始返回文本串中的最后一个或几个字符。Text:包含需要提取字符的文本串或单元格引用。Num_chars:指定RIGHT函数从文本串中提取的字符数。Num_chars不能小于0。如果num_chars大于文本串长度,RIGHT函数将返回整个文本。如果不指定num_chars,则默认值为1。示例:RIGHT("It is interesting",6)等于“esting”。RIGHT("Share Holder")等于“r”。RIGHT("Huge sale",4)等于“sale”。',
name: 'RIGHT',
type: 'TEXT',
},
{
def: 'ROUND(number,num_digits):返回某个数字按指定位数舍入后的数字。number:需要进行舍入的数字。num_digits:指定的位数,按此位数进行舍入。如果 num_digits 大于 0,则舍入到指定的小数位。如果 num_digits 等于 0,则舍入到最接近的整数。如果 num_digits 小于 0,则在小数点左侧进行舍入。示例:ROUND(2.15, 1) 等于 2.2ROUND(2.149, 1) 等于 2.1ROUND(-1.475, 2) 等于 -1.48ROUND(21.5, -1) 等于 20因浮点数存在精度计算丢失问题, 导致计算结果里可能带上9999, 0000这些, 因此加入第三个参数来控制是否需要去除9999. true表示需要过滤9999, 0000这些数据.',
name: 'ROUND',
type: 'MATH',
},
{
def: 'ROUND(number,num_digits):返回某个数字按指定位数舍入后的数字。number:需要进行舍入的数字。num_digits:指定的位数,按此位数进行舍入。如果 num_digits 大于 0,则舍入到指定的小数位。如果 num_digits 等于 0,则舍入到最接近的整数。如果 num_digits 小于 0,则在小数点左侧进行舍入。示例:ROUND(2.15, 1) 等于 2.2ROUND(2.149, 1) 等于 2.1ROUND(-1.475, 2) 等于 -1.48ROUND(21.5, -1) 等于 20因浮点数存在精度计算丢失问题, 导致计算结果里可能带上9999, 0000这些, 因此加入第三个参数来控制是否需要去除9999. true表示需要过滤9999, 0000这些数据.',
name: 'ROUND',
type: 'COMMON',
},
{
def: 'same_period(x_agg(array),datepart)根据横纵轴或行列维度添加的日期字段进行同期值的计算。第一个参数为用于计算的指标,该指标必须为聚合函数或聚合指标;第二个参数用于配置计算同期时计算某日的年同期或者某日的月同期。横纵轴拖拽的字段不满足函数的计算要求时,该指标会标红。示例:same_period(sum_agg(amount),"Y") 用户横纵轴拖拽销售日期(年月日分组),则该指标计算结果为,根据年月日对销量进行分组汇总,然后计算出该日数据上年同日的销量;如果参数2为“M”,则计算结果为该日销量上月同日的销量。',
name: 'SAME_PERIOD',
type: 'TABLE_CAL',
},
{
def: 'SECOND(serial_number):返回某一指定时间的秒数,其值是介于0与59之间的一个整数。Serial_number:包含所求秒数的时间。示例:SECOND("15:36:25")等于25。SECOND("15:36:25", "HH:mm:ss")等于25。',
name: 'SECOND',
type: 'DATETIME',
},
{
def: 'SIGN(number):返回数字的符号。当数字为正数时返回 1,为零时返回 0,为负数时返回 -1。Number:为任意实数。示例:SIGN(10) 等于 1SIGN(4-4) 等于 0SIGN(-0.00001) 等于 -1',
name: 'SIGN',
type: 'MATH',
},
{
def: 'SIN(number): 计算给定角度的正弦值。Number:待求正弦值的以弧度表示的角度。备注: 如果参数的单位是度,将其乘以PI()/180即可转换成弧度。示例:SIN(10)等于-0.5440211108893698。SIN(45*PI()/180)等于0.707106781。',
name: 'SIN',
type: 'MATH',
},
{
def: 'SPLIT(String1,String2):返回由String2分割String1组成的字符串数组。String1:以双引号表示的字符串。String2:以双引号表示的分隔符。例如逗号","示例:SPLIT("hello,world,yes",",") = ["hello","world","yes"]。SPLIT("this is very good"," ") = ["this","is","very","good"]。备注:如果只有一个参数,则返回一个错误。如果有多个参数,则只有前两个起作用。',
name: 'SPLIT',
type: 'TEXT',
},
{
def: 'SQRT(number): 返回一个正数的平方根。Number:要求其平方根的任一正数。备注:Number必须是一个正数,否则函数返回错误信息*NUM!。示例:SQRT(64)等于8。SQRT(-64)返回*NUM!。',
name: 'SQRT',
type: 'MATH',
},
{
def: 'STARTWITH(str1,str2):判断字符串str1是否以str2开始。备注: str1和str2都是大小写敏感的。示例:STARTWITH("FineReport","Fine")等于true。STARTWITH("FineReport","Report")等于false。STARTWITH("FineReport","fine")等于false。',
name: 'STARTWITH',
type: 'TEXT',
},
{
def: 'STDEV_AGG(array): 根据当前分析维度,动态返回指标字段的标准差,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段STDEV_AGG(销量)返回的值为每日的销量标准差;当用户横轴为维度字段\'月\'时,STDEV_AGG(销量)返回的值为每月的销量标准差。',
name: 'STDEV_AGG',
type: 'AGG',
},
{
def: 'SUBSTITUTE(text,old_text,new_text,instance_num): 用new_text替换文本串中的old_text。Text:需要被替换字符的文本,或含有文本的单元格引用。Old_text:需要被替换的部分文本。New_text:用于替换old_text的文本。Instance_num:指定用new_text来替换第几次出现的old_text。如果指定了instance_num,则只有指定位置上的old_text被替换,否则文字串中出现的所有old_text都被new_text替换。备注: 如果需要替换文本串中的指定文本,则使用SUBSTITUTE函数;如果需要替换文本串中指定位置上的任意文本,则使用REPLACE函数。示例:SUBSTITUTE("data base","base","model")等于“data model”。SUBSTITUTE("July 28, 2000","2","1",1)等于“July 18, 2000”。SUBSTITUTE("July 28, 2000","2","1")等于“July 18, 1000”。SUBSTITUTE("July 28, 2000","2","1",2)等于“July 28, 1000”。 ',
name: 'SUBSTITUTE',
type: 'TEXT',
},
{
def: 'SUM_AGG(array):根据当前分析维度,动态返回指标字段的汇总求和值,生成结果为一动态数据列,行数与当前分析维度行数一致。\n array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n 示例:用户横轴为维度字段\'日\'时,纵轴的计算字段SUM_AGG(销量)返回的值为每日的汇总销量;当用户横轴为维度字段\'月\'时,SUM_AGG(销量)返回的值为每月的汇总销量。',
name: 'SUM_AGG',
type: 'AGG',
},
{
def: 'switch(表达式, 值1, 结果1, 值2, 结果2, ...)如果表达式的结果是值1,整个函数返回结果1如果表达式的结果是值2,整个函数返回结果2如果表达式的结果是值3,整个函数返回结果3等等',
name: 'SWITCH',
type: 'LOGIC',
},
{
def: 'TAN(number): 返回指定角度的正切值。Number:待求正切值的角度,以弧度表示。如果参数是以度为单位的,乘以Pi()/180后转换为弧度。示例:TAN(0.8)等于1.029638557。TAN(45*Pi()/180)等于1。',
name: 'TAN',
type: 'MATH',
},
{
def: 'TIME(hour,minute,second): 返回代表指定时间的小数。介于0:00:00(12:00:00 A.M.)与23:59:59(11:59:59 P.M.)之间的时间可返回0到0.99999999之间的对应数值。Hour:介于0到23之间的数。Minute:介于0到59之间的数。Second:介于0到59之间的数。示例:TIME(14,40,0)等于2:40 PM。TIME(19,43,24)等于7:43 PM。',
name: 'TIME',
type: 'DATETIME',
},
{
def: 'TODATE()函数可以将各种日期形式的参数转换为日期类型。它有三种参数的形式:1 参数是一个日期型的参数,那么直接将这个参数返回。示例:TODATE(DATE(2007,12,12))返回2007年12月12日组成的日期。2 参数是以从1970年1月1日0时0分0秒开始的毫秒数,返回对应的时间。示例:TODATE(1023542354746)返回2002年6月8日。3 参数是日期格式的文本,那么返回这个文本对应的日期。示例:TODATE("2007/10/15")返回2007年10月5日组成的日期。TODATE("2007-6-8")返回2007年6月8日组成的日期。4 有两个参数,第一个参数是一个日期格式的文本,第二个参数是用来解析日期的格式。示例:TODATE("1/15/07","mm/dd/yy")返回07年1月15日组成的日期。特别的,"yyyyMMdd"是用来解析形如“20081230”之类的日期格式的。比如TODATE("20110830","yyyyMMdd")返回11年08月30日组成的日期5 有三个参数,第一个参数是一个日期格式的文本,第二个参数是用来解析日期的格式,第三个参数为解析日期的语言,如:zh(中文),en(英文)。示例:TODATE("星期三 1/15/07","EEE mm/dd/yy", "zh")返回07年1月15日组成的日期,使用“zh(中文)”才能够正常解析“星期三”这个字符串。',
name: 'TODATE',
type: 'DATETIME',
},
{
def: 'TODAY():获取当前日期。示例:如果系统日期是2005年9月10日则TODAY()等于2005-9-10。',
name: 'TODAY',
type: 'DATETIME',
},
{
def: 'TODOUBLE(text): 将文本转换成Double对象。Text:需要转换的文本。示例:TODOUBLE("123.21")等于 new Double(123.21)。',
name: 'TODOUBLE',
type: 'TEXT',
},
{
def: 'TOINTEGER(text): 将文本转换成Integer对象。Text:需要转换的文本。示例:TOINTEGER("123")等于 new Integer(123)。',
name: 'TOINTEGER',
type: 'TEXT',
},
{
def: 'total(x_agg(array),range,agg)根据横纵轴或行列维度添加的字段对指标进行跨行汇总的计算。第一个参数为用户计算的指标,该指标必须为聚合函数或聚合指标;第二个参数range为用户设置计算的范围,0为对所有行进行汇总,1为对组内所有行进行汇总;第三个参数agg为汇总的计算规则,"sum"为求和;"avg"为求平均,"max"为求最大值,"min"为求最小值示例:total(sum_agg(array),0,"avg")用户横纵轴拖拽省份,则该指标计算结果为,根据省份对销量进行分组汇总,然后计算平均每个省份的销量',
name: 'TOTAL',
type: 'TABLE_CAL',
},
{
def: 'TRIM(text): 清除文本中所有空格,单词间的单个空格除外,也可用于带有不规则空格的文本。Text:需要清除空格的文本。示例:TRIM(" Monthly Report")等于Monthly Report。',
name: 'TRIM',
type: 'TEXT',
},
{
def: 'TRUNC(number,num_digits):将数字的小数部分截去,返回整数。number:需要截尾取整的数字。num_digits:用于指定取整精度的数字。示例:TRUNC(8.9) 等于 8TRUNC(-8.9) 等于 -8TRUNC(PI()) 等于 3',
name: 'TRUNC',
type: 'MATH',
},
{
def: 'UPPER(text): 将文本中所有的字符转化为大写。Text:需要转化为大写字符的文本,或是包含文本的单元格引用。示例:UPPER("notes")等于“NOTES”。如果单元格E5的值为“Examples”,则UPPER(E5)等于“EXAMPLES”。',
name: 'UPPER',
type: 'TEXT',
},
{
def: 'VAR_AGG(array): 根据当前分析维度,动态返回指标字段的方差,生成结果为一动态数据列,行数与当前分析维度行数一致。\n "array必须为非聚合函数公式返回的结果,可以是某指标字段、维度或指标字段与普通公式的计算结果。\n "示例:用户横轴为维度字段\'日\'时,纵轴的计算字段VAR_AGG(销量)返回的值为每日的销量方差;当用户横轴为维度字段\'月\'时,VAR_AGG(销量)返回的值为每月的销量方差。',
name: 'VAR_AGG',
type: 'AGG',
},
{
def: 'WEEK(serial_num):返回一个代表一年中的第几周的数字。Serial_num:表示输入的日期。备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。示例:WEEK("2010/1/1")等于52。WEEK("2010/1/6")等于1。WEEK(35796)等于1。',
name: 'WEEK',
type: 'DATETIME',
},
{
def: 'weekdate(year,month,weekOfMonth,dayOfWeek): 返回指定年月的指定周的周几的具体日期。示例:weekdate(2009,10,2,1)返回的是2009年的10月的第二个周的第一天即星期天的日期,返回的是2009-10-04最后一个参数dayOfWeek为-1时,表示这个周的最后一天示例:weekdate(2009,12,1,-1)返回的是2009年的12月的第一个周的最后一天即星期六的日期,返回的是2009-12-05',
name: 'WEEKDATE',
type: 'DATETIME',
},
{
def: 'WEEKDAY(Serial_number):获取日期并返回星期数。返回值为介于0到6之间的某一整数,分别代表星期中的某一天(从星期日到星期六)。Serial_number:输入的日期备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。举例:WEEKDAY("2005/9/10")等于6(星期六)。WEEKDAY("2005/9/11")等于0(星期日)。WEEKDAY(35796)等于4(星期四)。',
name: 'WEEKDAY',
type: 'DATETIME',
},
{
def: 'YEAR:(serial_number)返回日期中的年。Year是介于1900和9999之间的一个数。Serial_number:含有所求的年的日期.备注:FineReport将日期保存为系列数,一个系列数代表一个与之匹配的日期,以方便用户对日期进行数值式计算。在1900年日期系统中,FineReport电子表格将1900年1月1日保存为系列数2,将1900年1月2日保存为系列数3,将1900年1月3日保存为系列数4……依此类推。如在1900年日期系统,1998年1月1日存为系列数35796。示例:YEAR("2000/1/1")等于2000。YEAR("2006/05/05")等于2006。YEAR("1997/04/20")等于1997。YEAR("2000-1-1", "yyyy-MM-dd")等于2000。YEAR("2006-05-05", "yyyy-MM-dd")等于2006。YEAR("1997-04-20", "yyyy-MM-dd")等于1997。YEAR(35796)等于1998。',
name: 'YEAR',
type: 'DATETIME',
},
{
def: 'YEARDELTA(date, delta):返回指定日期后delta年的日期。示例:YEARDELTA("2008-10-10",10)等于2018-10-10。',
name: 'YEARDELTA',
type: 'DATETIME',
},
],
};

36
src/web/src/modules/table_list/list_item.ts

@ -6,24 +6,34 @@ export class ListItem extends BI.BasicButton {
props = {
text: '',
height: 20,
showIcon: false,
baseCls: 'bi-list-item-active',
}
render() {
const { text } = this.options;
return {
type: HtapeXtype,
items: [{
el: {
type: IconLabelXtype,
cls: 'column-font',
},
width: 25,
}, {
const { text, showIcon } = this.options;
if(showIcon){
return {
type: HtapeXtype,
items: [{
el: {
type: IconLabelXtype,
cls: 'redis-column-font',
},
width: 25,
}, {
type: LabelXtype,
textAlign: 'left',
text,
}],
};
}else{
return {
type: LabelXtype,
textAlign: 'left',
lgap: 5,
text,
}],
};
}
}
}
}

40
src/web/src/modules/table_list/table_list.model.ts

@ -0,0 +1,40 @@
import { model, Model } from '@core/core';
import { getConnectionlist, getTableList } from '../crud/crud.request';
@model()
export class TableModelModel extends Model {
static xtype = 'dec.model.dcm.connection.plugin.redis.table_list';
state() {
return {
connections: [] as string[],
tables: [] as string[],
search: '',
orderValue: '',
selectedConnection: '',
};
}
actions = {
initData: () => {
getConnectionlist().then(re => {
this.model.connections = re.data.filter(item => item.connectionType === 'Redis').map(item => item.connectionName);
});
},
initTableList: () => {
if (this.model.selectedConnection) {
getTableList(this.model.selectedConnection, this.model.search, this.model.orderValue).then(re => {
this.model.tables = re ? re : [];
});
} else {
this.model.tables = [];
}
},
setSearch(value: string, orderValue: string | number) {
this.model.search = value;
this.model.orderValue = orderValue;
},
setSelectedConnection(name: string) {
this.model.selectedConnection = name;
},
}
}

133
src/web/src/modules/table_list/table_list.ts

@ -1,29 +1,89 @@
import { shortcut } from '@core/core';
import { VtapeXtype, HtapeXtype, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype, MultiSelectItemXtype, LeftXtype } from 'ui';
import { shortcut, store } from '@core/core';
import { VtapeXtype, HtapeXtype, LabelXtype, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype } from 'ui';
import { ListItem } from './list_item';
import { TableModelModel } from './table_list.model';
import { fineServletURL } from '@constants/env';
import { DatabaseIndex } from '../components/database_index/database_index';
@shortcut()
@store(TableModelModel)
export class TableList extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.table_list'
store: TableModelModel['store']
model: TableModelModel['model']
databaseIndex: DatabaseIndex;
buttonGroup: any;
connectionTextValue: any;
searchText: any;
props = {
database: '',
value: {
datasetData: {
orderValue: 0,
},
},
}
watch = {
connections: () => {
this.connectionTextValue.populate(this.renderConnectionList());
const name = this.model.connections.length > 0 ? this.model.connections[0] : '';
this.connectionTextValue.setValue(name);
this.store.setSelectedConnection(name);
},
'selectedConnection || search || orderValue': () => {
this.store.initTableList();
},
tables: (tables: string[]) => {
this.buttonGroup.populate(this.renderTableList());
},
}
render() {
const { orderValue = 0 } = this.options.value.datasetData || {};
const inputType = typeof orderValue === 'string' ? 'formula' : 'int';
return {
type: VtapeXtype,
hgap: 10,
bgap: 5,
items: [{
el: {
type: HtapeXtype,
items: [{
type: TextValueComboXtype,
ref: (_ref: any) => {
this.connectionTextValue = _ref;
},
items: [],
listeners: [{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: () => {
const name = this.connectionTextValue.getValue()[0];
this.store.setSelectedConnection(name);
},
}],
}, {
el: {
type: IconButtonXtype,
cls: 'site-font',
cls: 'redis-site-font',
title: BI.i18nText('Plugin-Redis_Data_Connection'),
handler: () => {
window.location.href = `${fineServletURL}#management/connection`;
},
},
width: 25,
}, {
el: {
type: IconButtonXtype,
cls: 'refresh-font',
cls: 'redis-refresh-font',
title: BI.i18nText('Plugin-Redis_Refresh'),
handler: () => {
this.store.initData();
},
},
width: 25,
}],
@ -33,14 +93,36 @@ export class TableList extends BI.Widget {
el: {
type: HtapeXtype,
items: [{
el: {
type: LabelXtype,
text: BI.i18nText('Plugin-Redis_Index'),
textAlign: 'left',
},
width: 24,
}, {
type: DatabaseIndex.xtype,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseIndex = _ref;
},
width: 24,
height: 22,
}, {
type: TextEditorXtype,
height: 24,
watermark: BI.i18nText('Plugin-Redis_Keys_Pattern'),
ref: (_ref: any) => {
this.searchText = _ref;
},
}, {
el: {
type: ButtonXtype,
minWidth: 50,
text: BI.i18nText('Plugin-Redis_Keys_Pattern_Search'),
handler: () => {
this.store.setSearch(this.searchText.getValue(), this.databaseIndex.getValue());
},
},
width: 50,
}],
@ -50,35 +132,30 @@ export class TableList extends BI.Widget {
type: VtapeXtype,
items: [{
type: ButtonGroupXtype,
chooseType: BI.Selection.None,
layouts: [{
type: VerticalXtype,
}],
items: this.renderList(),
}, {
el: {
type: LeftXtype,
height: 25,
hgap: 40,
items: [{
type: MultiSelectItemXtype,
width: 80,
selected: true,
text: BI.i18nText('Plugin-Redis_Table'),
}, {
type: MultiSelectItemXtype,
width: 80,
selected: true,
text: BI.i18nText('Plugin-Redis_View'),
}],
items: [],
ref: (_ref: any) => {
this.buttonGroup = _ref;
},
height: 25,
}],
}],
};
}
private renderList() {
return ['demo1', 'demo2'].map(item => {
private renderConnectionList() {
return this.model.connections.map(item => {
return {
text: item,
value: item,
};
});
}
private renderTableList() {
return this.model.tables.map(item => {
return {
type: ListItem.xtype,
text: item,
@ -86,4 +163,12 @@ export class TableList extends BI.Widget {
};
});
}
mounted() {
this.store.initData();
}
public getSelectedDatabase() {
return this.model.selectedConnection;
}
}

4
src/web/src/ui/fineui.ts

@ -54,6 +54,10 @@ export const FileXtype = 'bi.file';
export const IconComboXtype = 'bi.icon_combo';
export const NumberEditorXtype = 'bi.number_editor';
export const CodeEditorXtype = 'bi.code_editor';
export const ComponentsStyleTable = 'bi.components.style_table';
export const IconTextValue_Combo = 'bi.icon_text_value_combo';
export const BarPopoverXtype = 'bi.bar_popover';
// 布局
export const VerticalAdaptXtype = 'bi.vertical_adapt';
export const VtapeXtype = 'bi.vtape';

2
src/web/types/globals.d.ts vendored

@ -2,7 +2,7 @@ interface Obj {
[key: string]: any;
}
declare let BI: Obj & import('fineui')._BI;
declare let BI: Obj & import('fineui').BI & import('fineui-materials').BI;
declare const Fix: Obj;
declare const DecCst: Obj;
declare const Dec: Obj;

6
src/web/webpack/webpack.dev.js

@ -54,6 +54,12 @@ module.exports = merge(common, {
contentBase: path.join(__dirname, '..'),
port: 10004,
liveReload: true,
proxy: {
'/webroot/decision': {
target: 'http://localhost:8075',
secure: false,
},
},
},
plugins: [
new MiniCssExtractPlugin({

6
src/web/webpack/webpack.prod.js

@ -38,9 +38,9 @@ module.exports = merge.smart(common, {
options: {
plugins: [vars({
variables: {
fontUrl: '/webroot/decision/resources?path=/com/fr/web/ui/font',
imageUrl: '/webroot/decision/resources?path=/com/fr/web/resources/dist/images/1x',
image2xUrl: '/webroot/decision/resources?path=/com/fr/web/resources/dist/images/2x',
fontUrl: '${fineServletURL}/resources?path=/com/fr/web/ui/font',
imageUrl: '${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/1x',
image2xUrl: '${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x',
}
})]
},

1687
src/web/yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save