Browse Source

fix: 修改bug

pull/17/head
alan 5 years ago
parent
commit
57e70eb0a5
  1. 20
      src/web/src/modules/app.dataset.ts
  2. 2
      src/web/src/modules/app.model.ts
  3. 19
      src/web/src/modules/app.program.ts
  4. 4
      src/web/src/modules/components/database_index/database_index.model.ts
  5. 20
      src/web/src/modules/components/database_index/database_index.ts
  6. 2
      src/web/src/modules/crud/crud.request.ts
  7. 7
      src/web/src/modules/crud/crud.service.ts
  8. 2
      src/web/src/modules/table_list/table_list.model.ts
  9. 12
      src/web/src/modules/table_list/table_list.ts

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

@ -1,5 +1,5 @@
import { shortcut, store } from '@core/core';
import { VerticalXtype, HtapeXtype, LabelXtype, IconComboXtype, CodeEditorXtype, ComponentsStyleTable, ButtonXtype, IconTextValue_Combo } from 'ui';
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';
@ -27,7 +27,7 @@ export class RedisDataset extends BI.Widget {
value: {
datasetData: {
database: '',
orderValue: '0',
orderValue: 0,
query: '',
parameters: [],
},
@ -38,14 +38,16 @@ export class RedisDataset extends BI.Widget {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
ablePreview: (ablePreview: boolean) => {
this.previewButton.setEnable(ablePreview);
ableSave: (ableSave: boolean) => {
this.previewButton.setEnable(ableSave);
},
}
render() {
const { database = '', orderValue = '0', query = '', parameters = [] } = this.options.value.datasetData || {};
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,
@ -81,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',
@ -107,6 +109,7 @@ export class RedisDataset extends BI.Widget {
type: DatabaseIndex.xtype,
rgap: 11,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseIndex = _ref;
},
@ -124,9 +127,10 @@ 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;
@ -165,7 +169,7 @@ export class RedisDataset extends BI.Widget {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Preview'),
disabled: !this.model.ablePreview,
disabled: !BI.get(this.model, 'ableSave'),
handler: () => {
this.openPreview();
},

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

@ -8,14 +8,12 @@ export class RedisModel extends Model {
state() {
return {
parameters: [] as ParameterType[],
ablePreview: false,
};
}
actions = {
setAbleSave(ableSave: boolean) {
this.model.ableSave = ableSave;
this.model.ablePreview = ableSave;
},
setParameters: (parameters: ParameterType[]) => {
this.model.parameters = parameters;

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

@ -1,5 +1,5 @@
import { shortcut, store } from '@core/core';
import { VerticalXtype, HtapeXtype, LabelXtype, IconComboXtype, TextValueComboXtype, CodeEditorXtype, ComponentsStyleTable, ButtonXtype, IconTextValue_Combo } from 'ui';
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';
@ -29,7 +29,7 @@ export class RedisProgram extends BI.Widget {
value: {
datasetData: {
database: '',
orderValue: '0',
orderValue: 0,
script: '',
engineType: 0,
parameters: [],
@ -41,14 +41,15 @@ export class RedisProgram extends BI.Widget {
parameters: () => {
this.parameterEditor.populate(this.renderItems(), [this.model.paramHeader]);
},
ablePreview: (ablePreview: boolean) => {
this.previewButton.setEnable(ablePreview);
ableSave: (ableSave: boolean) => {
this.previewButton.setEnable(ableSave);
},
}
render() {
const { database = '', orderValue = '0', script = '', parameters = [], engineType = 0 } = this.options.value.datasetData || {};
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,
@ -84,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',
@ -110,6 +111,7 @@ export class RedisProgram extends BI.Widget {
type: DatabaseIndex.xtype,
rgap: 11,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseIndex = _ref;
},
@ -152,9 +154,10 @@ export class RedisProgram extends BI.Widget {
},
width: this.textWidth,
}, {
type: CodeEditorXtype,
type: TextAreaEditorXtype,
cls: 'bi-border',
height: 200,
allowBlank: true,
value: script,
ref: (_ref: any) => {
this.queryCondition = _ref;
@ -193,7 +196,7 @@ export class RedisProgram extends BI.Widget {
el: {
type: ButtonXtype,
text: BI.i18nText('Plugin-Redis_Preview'),
disabled: !this.model.ablePreview,
disabled: !BI.get(this.model, 'ableSave'),
handler: () => {
this.openPreview();
},

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

@ -6,12 +6,12 @@ export class DatabaseIndexModel extends Model {
state() {
return {
inputValue: '',
inputValue: '' as string | number,
};
}
actions = {
setInpueValue: (value: string) => {
setInpueValue: (value: string | number) => {
this.model.inputValue = value;
},
}

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

@ -10,23 +10,24 @@ export class DatabaseIndex extends BI.Widget {
databaseIndexTab: any;
textEditor: any;
formulaPane: typeof BI.FormulaOpeartingPanel;
formulaPane: any;
model: DatabaseIndexModel['model']
store: DatabaseIndexModel['store']
props = {
value: '',
inputType: 'int',
}
render() {
const { value } = this.options;
const { value, inputType } = this.options;
this.store.setInpueValue(value);
return {
type: TabXtype,
single: true,
showIndex: 'int',
showIndex: inputType,
ref: (_ref: any) => {
this.databaseIndexTab = _ref;
},
@ -35,13 +36,13 @@ export class DatabaseIndex extends BI.Widget {
return {
type: TextEditorXtype,
warningTitle: '',
value: this.model.inputValue,
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(this.textEditor.getValue());
this.store.setInpueValue(parseInt(this.textEditor.getValue(), 10));
},
}],
ref: (_ref: any) => {
@ -54,7 +55,7 @@ export class DatabaseIndex extends BI.Widget {
type: TextEditorXtype,
allowBlank: true,
value: this.model.inputValue,
ref: (_ref: typeof BI.FormulaOpeartingPanel) => {
ref: (_ref: any) => {
this.formulaPane = _ref;
},
};
@ -69,8 +70,11 @@ export class DatabaseIndex extends BI.Widget {
this.databaseIndexTab.setSelect(value);
if (value === 'formula') {
openFormulaPopover({
formula: '',
}, BI.ComplexFormulaInserter.xtype);
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);
});
}
}

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

@ -4,7 +4,7 @@ export function getConnectionlist(): Promise<{data?: Connection[]}> {
return requestGet('/v10/config/connection/list');
}
export function getTableList(database: string, pattern = ''): Promise<{data?: string[]}> {
export function getTableList(database: string, pattern = ''): Promise<string[]> {
return requestGet('plugin/private/com.fr.solution.plugin.db.redis.v10/redis/keys', {
database,
pattern,

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

@ -50,7 +50,7 @@ function checkStatus(response: AxiosResponse) {
return resData;
}
export async function request(reqOptions: CrudReqOpts = {}): Promise<ResultType> {
export async function request(reqOptions: CrudReqOpts = {}): Promise<any> {
const { url, type, headers, data, params } = reqOptions;
return axios
@ -128,8 +128,3 @@ interface CrudParams {
[key: string]: string | number | { [key: string]: any };
}
interface ResultType {
data?: any;
errorCode?: string;
errorMsg?: string;
}

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

@ -22,7 +22,7 @@ export class TableModelModel extends Model {
initTableList: () => {
if (this.model.selectedConnection) {
getTableList(this.model.selectedConnection, this.model.search).then(re => {
this.model.tables = re ? re.data : [];
this.model.tables = re ? re : [];
});
} else {
this.model.tables = [];

12
src/web/src/modules/table_list/table_list.ts

@ -30,6 +30,9 @@ export class TableList extends BI.Widget {
'selectedConnection || search': () => {
this.store.initTableList();
},
tables: (tables: string[]) => {
this.buttonGroup.populate(this.renderTableList());
},
}
render() {
@ -118,6 +121,15 @@ export class TableList extends BI.Widget {
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,

Loading…
Cancel
Save