Browse Source

feat: 调整布局,对接后端

refactor
alan 5 years ago
parent
commit
cb1e3db73f
  1. 25
      src/main/resources/com/fr/plugin/db/redis/locale/redis_zh_CN.properties
  2. 19
      src/web/assets/scripts/dec.js
  3. 5
      src/web/index.html
  4. 21
      src/web/private/i18n.ts
  5. 19
      src/web/src/index.ts
  6. 7
      src/web/src/less/font.less
  7. 7
      src/web/src/less/lib/font.less
  8. 33
      src/web/src/modules/app.constant.ts
  9. 46
      src/web/src/modules/app.dataset.model.ts
  10. 161
      src/web/src/modules/app.dataset.ts
  11. 7
      src/web/src/modules/app.less
  12. 175
      src/web/src/modules/app.program.ts
  13. 18
      src/web/src/modules/components/database_index/database_index.model.ts
  14. 70
      src/web/src/modules/components/database_index/database_index.ts
  15. 2
      src/web/src/modules/components/parameter/parameter.ts
  16. 4
      src/web/src/modules/constants/env.ts
  17. 22
      src/web/src/modules/crud/crud.request.ts
  18. 135
      src/web/src/modules/crud/crud.service.ts
  19. 36
      src/web/src/modules/table_list/list_item.ts
  20. 38
      src/web/src/modules/table_list/table_list.model.ts
  21. 95
      src/web/src/modules/table_list/table_list.ts
  22. 2
      src/web/src/ui/fineui.ts
  23. 2
      src/web/types/globals.d.ts
  24. 6
      src/web/webpack/webpack.dev.js
  25. 1698
      src/web/yarn.lock

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

@ -41,21 +41,12 @@ Plugin-Redis_Script_Engine_Type_V8=V8\u9AD8\u901F\u5F15\u64CE
Plugin-Redis_Proxy_Private_Key_Path_Mark=\u8bf7\u8f93\u5165\u670d\u52a1\u5668\u6587\u4ef6\u8def\u5f84
Plugin-Redis_Connection_Form_OriginalCharsetName= \u7f16\u7801
Plugin-Redis_Check_Integer=\u8bf7\u8f93\u5165\u4e0d\u5c0f\u4e8e\u0030\u7684\u6574\u6570
Plugin-Redis_Parameter_Insert=\u63D2\u5165
Plugin-Redis_Parameter_Delete=\u5220\u9664
Plugin-Redis_Parameter_Move_Up=\u4E0A\u79FB
Plugin-Redis_Parameter_Move_Down=\u4E0B\u79FB
Plugin-Redis_Parameter_Refresh=\u5237\u65B0
Plugin-Redis_Dataset_Parameter_Name=\u53C2\u6570
Plugin-Redis_Dataset_Parameter_Value=\u503C
Plugin-Redis_Parameter_Please_Set_Parameter_Name=\u8BF7\u5148\u8BBE\u7F6E\u53C2\u6570\u540D
Plugin-Redis_Parameter_Type_String=\u5B57\u7B26\u4E32
Plugin-Redis_Parameter_Type_Int=\u6574\u578B
Plugin-Redis_Parameter_Type_Number=\u53CC\u7CBE\u5EA6\u578B
Plugin-Redis_Parameter_Type_Date=\u65E5\u671F
Plugin-Redis_Parameter_Type_Boolean=\u5E03\u5C14\u578B
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_Preview=\u9884\u89c8
Plugin-Redis_Refresh=\u5237\u65B0
Plugin-Redis_Data_Connection=\u6570\u636e\u8fde\u63a5
Plugin-Redis_Set_Parameter=\u53c2\u6570\u8bbe\u7f6e
Plugin-Redis_Set_Parameter_Name=\u53c2\u6570\u540d
Plugin-Redis_Set_Parameter_Type=\u53c2\u6570\u7c7b\u578b
Plugin-Redis_Set_Parameter_Value=\u9ed8\u8ba4\u503c

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',
}

5
src/web/index.html

@ -22,13 +22,10 @@
href="./node_modules/fineui-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>

21
src/web/private/i18n.ts

@ -42,22 +42,11 @@ 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': '表',
'Plugin-Redis_Data_Connection': '数据连接',
'Plugin-Redis_Set_Parameter': '参数设置',
'Plugin-Redis_Set_Parameter_Name': '参数名',
'Plugin-Redis_Set_Parameter_Type': '参数类型',
'Plugin-Redis_Set_Parameter_Value': '默认值',
};

19
src/web/src/index.ts

@ -1,6 +1,7 @@
import { RedisShow } from './modules/app.show';
import { RedisEdit } from './modules/app.edit';
import { RedisDataset } from './modules/app.dataset';
import { RedisProgram } from './modules/app.program';
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';
@ -11,6 +12,22 @@ BI.DOM.ready(() => {
databaseType: 'Redis',
iconUrl: 'com/fr/plugin/db/redis/images/redis.png',
}]);
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,
});
});
BI.constant(ConstantRedisShow, RedisShow.xtype);
BI.constant(ConstantRedisEdit, RedisEdit.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',
}];

46
src/web/src/modules/app.dataset.model.ts

@ -0,0 +1,46 @@
import { model, Model } from './core/core';
import { redisParamHeader } from './app.constant';
@model()
export class RedisDatasetModel extends Model {
static xtype = 'dec.model.dcm.connection.plugin.redis.dataset'
context = ['dataSetName', 'ableSave']
state() {
return {
parameters: [{ name: '123', type: 'String' }] as {
name: string;
type: string;
value: string;
}[],
};
}
actions = {
setAbleSave(ableSave: boolean) {
this.model.ableSave = ableSave;
},
setParameters: (parameters: {
name: string;
type: string;
value: string;
}[]) => {
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);
}
},
}
computed = {
paramHeader: () => redisParamHeader.map(item => BI.extend({
textAlign: 'left',
height: 30,
hgap: 10,
}, item)),
}
}

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

@ -1,29 +1,62 @@
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, CodeEditorXtype, 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 { RedisDatasetModel } from './app.dataset.model';
import './app.less';
import { redisField } from './app.constant';
@shortcut()
@store(RedisDatasetModel)
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;
store: RedisDatasetModel['store']
model: RedisDatasetModel['model']
props = {
value: {
database: '',
orderValue: '0',
query: '',
parameters: [],
},
}
watch = {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
}
render() {
const { database, orderValue, query, parameters } = this.options.value;
this.store.setParameters(parameters);
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,
@ -58,39 +91,24 @@ 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,
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,
@ -102,15 +120,98 @@ export class RedisDataset extends BI.Widget {
type: CodeEditorXtype,
cls: 'bi-border',
height: 200,
value: query,
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.getValue(), 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'),
},
width: 80,
}],
}, {
type: ComponentsStyleTable,
cls: 'param-table',
height: 200,
columnSize: [250, 250, ''],
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,
}]);
}
public getValue() {
return {
database: this.tableList.getSelectedDatabase(),
orderValue: this.databaseIndex.getValue(),
query: this.queryCondition.getValue(),
parameters: this.model.parameters,
};
}
}

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;
}
}

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

@ -1,29 +1,64 @@
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, CodeEditorXtype, 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 { RedisDatasetModel } from './app.dataset.model';
import './app.less';
import { redisField } from './app.constant';
@shortcut()
@store(RedisDatasetModel)
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;
store: RedisDatasetModel['store']
model: RedisDatasetModel['model']
props = {
value: {
database: '',
orderValue: '0',
script: '',
engineType: 0,
parameters: [],
},
}
watch = {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
}
render() {
const { database, orderValue, script, parameters, engineType } = this.options.value;
this.store.setParameters(parameters);
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,
@ -58,39 +93,24 @@ 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,
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,21 +120,26 @@ 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,
@ -122,15 +147,99 @@ export class RedisProgram extends BI.Widget {
type: CodeEditorXtype,
cls: 'bi-border',
height: 200,
value: script,
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.getValue(), 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'),
},
width: 80,
}],
}, {
type: Parameter.xtype,
type: ComponentsStyleTable,
cls: 'param-table',
height: 200,
columnSize: [250, 250, ''],
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,
}]);
}
public getValue() {
return {
database: this.tableList.getSelectedDatabase(),
orderValue: this.databaseIndex.getValue(),
script: this.queryCondition.getValue(),
engineType: this.engineTypeSelect.getValue()[0],
parameters: this.model.parameters,
};
}
}

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

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

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

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

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

@ -92,7 +92,7 @@ export class Parameter extends BI.Widget {
},
}, showRefresh ? {
type: IconButtonXtype,
cls: 'refresh-font',
cls: 'redis-refresh-font',
width: 25,
title: BI.i18nText('Plugin-Redis_Parameter_Refresh'),
handler: () => {

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=`;

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

@ -0,0 +1,22 @@
import { requestGet } from './crud.service';
export function getConnectionlist(): Promise<{data?: Connection[]}> {
return requestGet('/v10/config/connection/list');
}
export function getTableList(database: string, pattern = ''): Promise<{data?: string[]}> {
return requestGet('com.fr.solution.plugin.db.redis.v10/redis/keys', {
database,
pattern,
});
}
export interface Connection {
connectionId: string;
connectionType: string;
connectionName: string;
creator?: string;
privilegeDetailBeanList?: {
privilegeType: number;
privilegeValue: number;
}[]
}

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

@ -0,0 +1,135 @@
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<ResultType> {
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 };
}
interface ResultType {
data?: any;
errorCode?: string;
errorMsg?: string;
}

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,
}],
};
}
}
}
}

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

@ -0,0 +1,38 @@
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: '',
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).then(re => {
this.model.tables = re ? re.data : [];
});
} else {
this.model.tables = [];
}
},
setSearch(value: string) {
this.model.search = value;
},
setSelectedConnection(name: string) {
this.model.selectedConnection = name;
},
}
}

95
src/web/src/modules/table_list/table_list.ts

@ -1,29 +1,76 @@
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, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype } from 'ui';
import { ListItem } from './list_item';
import { TableModelModel } from './table_list.model';
import { fineServletURL } from '@constants/env';
@shortcut()
@store(TableModelModel)
export class TableList extends BI.Widget {
static xtype = 'dec.dcm.connection.plugin.redis.table_list'
store: TableModelModel['store']
model: TableModelModel['model']
buttonGroup: any;
connectionTextValue: any;
searchText: any;
props = {
database: '',
}
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': () => {
this.store.initTableList();
},
}
render() {
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,
}],
@ -36,11 +83,17 @@ export class TableList extends BI.Widget {
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());
},
},
width: 50,
}],
@ -50,35 +103,21 @@ 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 {
type: ListItem.xtype,
text: item,
@ -86,4 +125,12 @@ export class TableList extends BI.Widget {
};
});
}
mounted() {
this.store.initData();
}
public getSelectedDatabase() {
return this.model.selectedConnection;
}
}

2
src/web/src/ui/fineui.ts

@ -54,6 +54,8 @@ 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 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({

1698
src/web/yarn.lock

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