From 0d7c7f6deb6cb02c057068535dc4d22bd186c48a Mon Sep 17 00:00:00 2001 From: "Jimmy.Chai" Date: Tue, 30 Jun 2020 17:47:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=B9=B3=E5=8F=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=94=AE=E5=80=BC=E6=8C=89=E7=BC=96=E5=8F=B7=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/private/i18n.ts | 5 +++ src/web/src/index.edit.ts | 4 +-- src/web/src/modules/crud/crud.request.ts | 3 +- .../modules/table_list/table_list.model.ts | 6 ++-- src/web/src/modules/table_list/table_list.ts | 32 +++++++++++++++++-- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/web/private/i18n.ts b/src/web/private/i18n.ts index b619fe3..c47cf86 100644 --- a/src/web/private/i18n.ts +++ b/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': '公式', diff --git a/src/web/src/index.edit.ts b/src/web/src/index.edit.ts index 0f8a090..a57adf0 100644 --- a/src/web/src/index.edit.ts +++ b/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', }); diff --git a/src/web/src/modules/crud/crud.request.ts b/src/web/src/modules/crud/crud.request.ts index cfa4471..6860d2a 100644 --- a/src/web/src/modules/crud/crud.request.ts +++ b/src/web/src/modules/crud/crud.request.ts @@ -4,10 +4,11 @@ export function getConnectionlist(): Promise<{data?: Connection[]}> { return requestGet('/v10/config/connection/list'); } -export function getTableList(database: string, pattern = ''): Promise { +export function getTableList(database: string, pattern = '', orderValue: string | number): Promise { return requestGet('plugin/private/com.fr.solution.plugin.db.redis.v10/redis/keys', { database, pattern, + orderValue, }); } diff --git a/src/web/src/modules/table_list/table_list.model.ts b/src/web/src/modules/table_list/table_list.model.ts index d69a462..963d360 100644 --- a/src/web/src/modules/table_list/table_list.model.ts +++ b/src/web/src/modules/table_list/table_list.model.ts @@ -9,6 +9,7 @@ export class TableModelModel extends Model { connections: [] as string[], tables: [] as string[], search: '', + orderValue: '', selectedConnection: '', }; } @@ -21,15 +22,16 @@ export class TableModelModel extends Model { }, initTableList: () => { if (this.model.selectedConnection) { - getTableList(this.model.selectedConnection, this.model.search).then(re => { + getTableList(this.model.selectedConnection, this.model.search, this.model.orderValue).then(re => { this.model.tables = re ? re : []; }); } else { this.model.tables = []; } }, - setSearch(value: string) { + setSearch(value: string, orderValue: string | number) { this.model.search = value; + this.model.orderValue = orderValue; }, setSelectedConnection(name: string) { this.model.selectedConnection = name; diff --git a/src/web/src/modules/table_list/table_list.ts b/src/web/src/modules/table_list/table_list.ts index af4b383..5d8bcc0 100644 --- a/src/web/src/modules/table_list/table_list.ts +++ b/src/web/src/modules/table_list/table_list.ts @@ -1,8 +1,9 @@ import { shortcut, store } from '@core/core'; -import { VtapeXtype, HtapeXtype, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype } from 'ui'; +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) @@ -12,12 +13,18 @@ export class TableList extends BI.Widget { store: TableModelModel['store'] model: TableModelModel['model'] + databaseIndex: DatabaseIndex; buttonGroup: any; connectionTextValue: any; searchText: any; props = { database: '', + value: { + datasetData: { + orderValue: 0, + }, + }, } watch = { @@ -27,7 +34,7 @@ export class TableList extends BI.Widget { this.connectionTextValue.setValue(name); this.store.setSelectedConnection(name); }, - 'selectedConnection || search': () => { + 'selectedConnection || search || orderValue': () => { this.store.initTableList(); }, tables: (tables: string[]) => { @@ -36,6 +43,9 @@ export class TableList extends BI.Widget { } render() { + const { orderValue = 0 } = this.options.value.datasetData || {}; + const inputType = typeof orderValue === 'string' ? 'formula' : 'int'; + return { type: VtapeXtype, hgap: 10, @@ -83,6 +93,22 @@ 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'), @@ -95,7 +121,7 @@ export class TableList extends BI.Widget { minWidth: 50, text: BI.i18nText('Plugin-Redis_Keys_Pattern_Search'), handler: () => { - this.store.setSearch(this.searchText.getValue()); + this.store.setSearch(this.searchText.getValue(), this.databaseIndex.getValue()); }, }, width: 50,