Browse Source

Merge pull request #54 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:feature/10.0 to feature/10.0

* commit '4e03ac3f145586f188635c9817624d41bb62c3fa':
  fix: DEC-9890 && DEC-9860 重命名时加入非空和重名的判断
qufenxi
alan 5 years ago
parent
commit
f305521286
  1. 4
      src/modules/app.service.ts
  2. 43
      src/modules/pages/connection/list/list_item/list_item.model.ts
  3. 9
      src/modules/pages/connection/list/list_item/list_item.ts
  4. 9
      src/modules/pages/maintain/forms/form.ts
  5. 4
      src/modules/pages/maintain/maintain.ts

4
src/modules/app.service.ts

@ -50,7 +50,7 @@ export function resolveUrlInfo (url: string) {
if (result) { if (result) {
return { return {
host: result[5], host: result[5],
port: result[7], port: result[7] === 'port' ? '' : result[7],
databaseName: result[9], databaseName: result[9],
urlInfo: result[10], urlInfo: result[10],
}; };
@ -64,7 +64,7 @@ export function resolveUrlInfo (url: string) {
return { return {
host: host ? host[1] : '', host: host ? host[1] : '',
port: port ? port[1] : '', port: port && port[1] !== 'port' ? port[1] : '',
databaseName: databaseName ? databaseName[1] : '', databaseName: databaseName ? databaseName[1] : '',
urlInfo: '', urlInfo: '',
}; };

43
src/modules/pages/connection/list/list_item/list_item.model.ts

@ -1,6 +1,7 @@
import { model, Model } from '@core/core'; import { model, Model } from '@core/core';
import { AppModel } from '../../../../app.model'; import { AppModel } from '../../../../app.model';
import { ApiFactory } from 'src/modules/crud/apiFactory'; import { ApiFactory } from '../../../../crud/apiFactory';
import { ResultType } from '../../../../crud/crud.typings';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
export const ListItemModelXtype = 'dec.dcm.model.connection.list_item'; export const ListItemModelXtype = 'dec.dcm.model.connection.list_item';
@ -39,18 +40,16 @@ export class ListItemModel extends Model<{
} }
}); });
}, },
setPageIndex(pageIndex: string) { setPageIndex: (pageIndex: string) => {
this.model.pageIndex = pageIndex; this.model.pageIndex = pageIndex;
}, },
testConnection: (name: string) => api.testConnection(this.model.connections.find(item => item.connectionName === name)), testConnection: (name: string) => api.testConnection(this.model.connections.find(item => item.connectionName === name)),
getConnectionStatus() { getConnectionStatus: () => api.getConnectionStatus(this.model.connectionSelected),
return api.getConnectionStatus(this.model.connectionSelected); setDatebaseTypeSelected: (name: string) => {
},
setDatebaseTypeSelected(name: string) {
this.model.datebaseTypeSelected = name; this.model.datebaseTypeSelected = name;
}, },
setIsEdit(isEdit: boolean, name: string) { setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) { if (isEdit) {
api.getConnectionStatus(name).then(re => { api.getConnectionStatus(name).then(re => {
if (re.data && re.data === 'success') { if (re.data && re.data === 'success') {
@ -66,10 +65,26 @@ export class ListItemModel extends Model<{
this.model.isEdit = false; this.model.isEdit = false;
} }
}, },
changeName(oldName: string, newName: string) { changeName: (oldName: string, newName: string): Promise<ResultType> => {
const connection = this.model.connections.find(item => item.connectionName === oldName); if (!newName) {
return new Promise(resolve => {
resolve({ errorCode: '1', errorMsg: 'Dec-Dcm_Connection_ConnectionName_Cannt_Null' });
});
}
const hasNamed = this.model.connections.some(item => item.connectionName === newName);
if (hasNamed && oldName !== newName) {
return new Promise(resolve => {
resolve({ errorCode: '1', errorMsg: 'Dec-Dcm_Connection_Is_Existence' });
});
}
const connection = BI.clone(this.model.connections.find(item => item.connectionName === oldName));
connection.connectionId = oldName; connection.connectionId = oldName;
connection.connectionName = newName; connection.connectionName = newName;
return api.updateConnection(connection).then(re => {
if (!re.errorCode) {
this.store.setIsEdit(false, oldName);
this.model.connections = this.model.connections.map(item => { this.model.connections = this.model.connections.map(item => {
return { return {
...item, ...item,
@ -77,19 +92,15 @@ export class ListItemModel extends Model<{
connectionId: item.connectionName === oldName ? newName : item.connectionName, connectionId: item.connectionName === oldName ? newName : item.connectionName,
}; };
}); });
}
return api.updateConnection(connection).then(re => {
this.setIsEdit(false, oldName);
return re; return re;
}); });
}, },
setIsCopy(isCopy: boolean) { setIsCopy: (isCopy: boolean) => {
this.model.isCopy = isCopy; this.model.isCopy = isCopy;
}, },
isDriverError(errorCode: string) { isDriverError: (errorCode: string) => api.isDriverError(errorCode),
return api.isDriverError(errorCode);
},
} }
removeConnection(name: string) { removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist()) api.deleteConnection(name).then(re => api.getConnectionlist())

9
src/modules/pages/connection/list/list_item/list_item.ts

@ -71,8 +71,15 @@ export class ListItem extends BI.BasicButton {
eventName: BI.SignEditor.EVENT_BLUR, eventName: BI.SignEditor.EVENT_BLUR,
action: () => { action: () => {
const newName = this.nameEditor.getValue(); const newName = this.nameEditor.getValue();
this.store.changeName(name, newName).then(() => { this.store.changeName(name, newName).then(re => {
if (re.errorCode) {
BI.Msg.toast(BI.i18nText(re.errorMsg), {
level: 'error',
});
this.nameEditor.focus();
} else {
this.nameLabel.setText(newName); this.nameLabel.setText(newName);
}
}); });
}, },
}], }],

9
src/modules/pages/maintain/forms/form.ts

@ -40,8 +40,13 @@ export class MaintainForm extends BI.Widget {
this.store.setIsCopy(false); this.store.setIsCopy(false);
}, },
testEvent: () => { testEvent: () => {
if (!this.testValue()) { const value = this.form.getSubmitValue();
return; if (!value.connectionName) {
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_ConnectionName_Cannt_Null'), {
level: 'error',
});
return false;
} }
const id = BI.UUID(); const id = BI.UUID();
const testConnection = () => { const testConnection = () => {

4
src/modules/pages/maintain/maintain.ts

@ -17,7 +17,7 @@ export class Maintain extends BI.Widget {
listView: any; listView: any;
render() { render() {
const { text, isEdit } = this.getEditConnection(); const { text } = this.getEditConnection();
return { return {
type: Vtape, type: Vtape,
@ -32,7 +32,7 @@ export class Maintain extends BI.Widget {
type: IconButton, type: IconButton,
hgap: 5, hgap: 5,
cls: 'dcm-back-font', cls: 'dcm-back-font',
invisible: isEdit, invisible: this.model.isCopy,
handler: () => { handler: () => {
this.store.setPageIndex(PAGE_INDEX.DATEBASE); this.store.setPageIndex(PAGE_INDEX.DATEBASE);
}, },

Loading…
Cancel
Save