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. 53
      src/modules/pages/connection/list/list_item/list_item.model.ts
  3. 11
      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) {
return {
host: result[5],
port: result[7],
port: result[7] === 'port' ? '' : result[7],
databaseName: result[9],
urlInfo: result[10],
};
@ -64,7 +64,7 @@ export function resolveUrlInfo (url: string) {
return {
host: host ? host[1] : '',
port: port ? port[1] : '',
port: port && port[1] !== 'port' ? port[1] : '',
databaseName: databaseName ? databaseName[1] : '',
urlInfo: '',
};

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

@ -1,6 +1,7 @@
import { model, Model } from '@core/core';
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();
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;
},
testConnection: (name: string) => api.testConnection(this.model.connections.find(item => item.connectionName === name)),
getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected);
},
setDatebaseTypeSelected(name: string) {
getConnectionStatus: () => api.getConnectionStatus(this.model.connectionSelected),
setDatebaseTypeSelected: (name: string) => {
this.model.datebaseTypeSelected = name;
},
setIsEdit(isEdit: boolean, name: string) {
setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) {
api.getConnectionStatus(name).then(re => {
if (re.data && re.data === 'success') {
@ -66,30 +65,42 @@ export class ListItemModel extends Model<{
this.model.isEdit = false;
}
},
changeName(oldName: string, newName: string) {
const connection = this.model.connections.find(item => item.connectionName === oldName);
changeName: (oldName: string, newName: string): Promise<ResultType> => {
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.connectionName = newName;
this.model.connections = this.model.connections.map(item => {
return {
...item,
connectionName: item.connectionName === oldName ? newName : item.connectionName,
connectionId: item.connectionName === oldName ? newName : item.connectionName,
};
});
return api.updateConnection(connection).then(re => {
this.setIsEdit(false, oldName);
if (!re.errorCode) {
this.store.setIsEdit(false, oldName);
this.model.connections = this.model.connections.map(item => {
return {
...item,
connectionName: item.connectionName === oldName ? newName : item.connectionName,
connectionId: item.connectionName === oldName ? newName : item.connectionName,
};
});
}
return re;
});
},
setIsCopy(isCopy: boolean) {
setIsCopy: (isCopy: boolean) => {
this.model.isCopy = isCopy;
},
isDriverError(errorCode: string) {
return api.isDriverError(errorCode);
},
isDriverError: (errorCode: string) => api.isDriverError(errorCode),
}
removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist())

11
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,
action: () => {
const newName = this.nameEditor.getValue();
this.store.changeName(name, newName).then(() => {
this.nameLabel.setText(newName);
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);
}
});
},
}],

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

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

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

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

Loading…
Cancel
Save