Browse Source

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

* commit 'ec2bcc3db94bc55215cd99f5f5a9ba04ecf6cc29':
  feat: DEC-9068 如果连接被占用则提示
qufenxi
alan 5 years ago
parent
commit
ef98ce9e2c
  1. 1
      i18n/zh_cn.properties
  2. 14
      src/modules/crud/api.ts
  3. 6
      src/modules/crud/crud.typings.d.ts
  4. 21
      src/modules/crud/decision.api.ts
  5. 14
      src/modules/crud/design.api.ts
  6. 6
      src/modules/pages/connection/connection.model.ts
  7. 11
      src/modules/pages/connection/connection.ts
  8. 24
      src/modules/pages/connection/list/list_item/list_item.model.ts
  9. 4
      src/modules/pages/database/database.model.ts
  10. 1
      src/modules/pages/database/database.ts
  11. 2
      src/modules/pages/maintain/forms/form.ts
  12. 4
      src/modules/title/title_maintain/title_maintain.model.ts
  13. 7
      src/modules/title/title_maintain/title_maintain.ts

1
i18n/zh_cn.properties

@ -94,6 +94,7 @@ Dec-Dcm_Connection_Form_JNDI_Collapse-Attributes= 收起
Dec-Dcm_Connection_JNDI= JNDI数据连接 Dec-Dcm_Connection_JNDI= JNDI数据连接
Dec-Dcm_Connection_JNDI_Warning= 注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下 Dec-Dcm_Connection_JNDI_Warning= 注意:需要把包含INTIAL_CONTEXT_FACTORY类的.jar文件复制到软件安装目录下的/lib目录下
Dec-Dcm_Connection_Error= 接口访问错误 Dec-Dcm_Connection_Error= 接口访问错误
Dec-Dcm_Connection_Is_Using= 该连接正在被{R1}编辑,请稍后再试
BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Quarter_End= 季度末
BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_Month_Begin= 月初

14
src/modules/crud/api.ts

@ -1,4 +1,4 @@
import { Connection, TestRequest, ConnectionPoolType } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
export interface Api { export interface Api {
/** /**
@ -39,4 +39,16 @@ export interface Api {
* @param name * @param name
*/ */
getConnectionPool(name: string): Promise<{data: ConnectionPoolType}>; getConnectionPool(name: string): Promise<{data: ConnectionPoolType}>;
/**
*
* @param name
*/
getConnectionStatus(name: string): Promise<SocketResult>;
/**
*
* @param name
*/
shutdownConnectionStatus(name: string): Promise<SocketResult>;
} }

6
src/modules/crud/crud.typings.d.ts vendored

@ -204,3 +204,9 @@ export interface ConnectionPoolType {
numActive: number; numActive: number;
numIdle: number; numIdle: number;
} }
export interface SocketResult {
data?: string;
errorCode?: string;
errorMsg?: string;
}

21
src/modules/crud/decision.api.ts

@ -1,6 +1,7 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
import { requestGet, requestDelete, requestPost, requestPut } from './crud.service'; import { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent } from '@constants/env';
export class DecisionApi implements Api { export class DecisionApi implements Api {
isDec = true; isDec = true;
@ -47,4 +48,22 @@ export class DecisionApi implements Api {
getConnectionPool(name: string): Promise<{data: ConnectionPoolType}> { getConnectionPool(name: string): Promise<{data: ConnectionPoolType}> {
return requestGet(`pool/info?connectionName=${name}`); return requestGet(`pool/info?connectionName=${name}`);
} }
getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN);
}
shutdownConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.SHUTDOWN);
}
private sendEditStatusEvent(name: string, type: string): Promise<SocketResult> {
return new Promise(resolve => {
if (Dec) {
const re = Dec.socket.emit(editStatusEvent.SHUTDOWN, name);
resolve(JSON.parse(re));
}
resolve({ data: 'success' });
});
}
} }

14
src/modules/crud/design.api.ts

@ -1,5 +1,5 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
// TODO: 此页面的接口等待设计器提供相应的方法 // TODO: 此页面的接口等待设计器提供相应的方法
export class DesignApi implements Api { export class DesignApi implements Api {
@ -44,4 +44,16 @@ export class DesignApi implements Api {
} }); } });
}); });
} }
getConnectionStatus(name: string): Promise<SocketResult> {
return new Promise(resolve => {
resolve({ data: 'success' });
});
}
shutdownConnectionStatus(name: string): Promise<SocketResult> {
return new Promise(resolve => {
resolve({ data: 'success' });
});
}
} }

6
src/modules/pages/connection/connection.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';
const api = new ApiFactory().create();
export const ConnectionModelXtype = 'dec.dcm.model.connection'; export const ConnectionModelXtype = 'dec.dcm.model.connection';
@model(ConnectionModelXtype) @model(ConnectionModelXtype)
export class ConnectionModel extends Model<{ export class ConnectionModel extends Model<{
@ -24,5 +25,8 @@ export class ConnectionModel extends Model<{
setConnectionSelected(name: string) { setConnectionSelected(name: string) {
this.model.connectionSelected = name; this.model.connectionSelected = name;
}, },
getConnectionStatus() {
return api.getConnectionStatus(this.model.connectionSelected);
},
} }
} }

11
src/modules/pages/connection/connection.ts

@ -6,7 +6,7 @@ import { ConnectionListXtype } from './list/list';
import { ConnectionJdbcXtype } from './connection_jdbc/connection_jdbc'; import { ConnectionJdbcXtype } from './connection_jdbc/connection_jdbc';
import { ConnectionJndiXtype } from './connection_jndi/connection_jndi'; import { ConnectionJndiXtype } from './connection_jndi/connection_jndi';
import { ConnectionPluginXtype } from './connection_plugin/connection_plugin'; import { ConnectionPluginXtype } from './connection_plugin/connection_plugin';
import { connectionType, editStatusEvent } from '@constants/env'; import { connectionType } from '@constants/env';
import { getAllDatabaseTypes } from '../../app.service'; import { getAllDatabaseTypes } from '../../app.service';
export const ConnectionXtype = 'dec.dcm.connection'; export const ConnectionXtype = 'dec.dcm.connection';
@ -102,9 +102,16 @@ export class Connection extends BI.Widget {
this.connectionEditWidget = _ref; this.connectionEditWidget = _ref;
}, },
handler: () => { handler: () => {
this.store.getConnectionStatus().then(re => {
if (re.data && re.data === 'success') {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected(''); this.store.setDatebaseTypeSelected('');
Dec ? Dec.socket.emit(editStatusEvent.OPEN, this.model.connectionSelected) : null; } else {
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error',
});
}
});
}, },
}, },
], ],

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

@ -21,6 +21,23 @@ export class ListItemModel extends Model<{
this.model.connectionSelected = name; this.model.connectionSelected = name;
}, },
deleteConnection: (name: string) => { deleteConnection: (name: string) => {
api.getConnectionStatus(name).then(re => {
if (re.data && re.data === 'success') {
this.removeConnection(name);
} else {
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error',
});
}
});
},
setPageIndex(pageIndex: string) {
this.model.pageIndex = pageIndex;
},
testConnection: () => api.testConnection(this.model.connectionSelectedOne),
}
removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist()) api.deleteConnection(name).then(re => api.getConnectionlist())
.then(connections => { .then(connections => {
this.model.connections = connections.data; this.model.connections = connections.data;
@ -31,12 +48,7 @@ export class ListItemModel extends Model<{
if (name === this.model.connectionSelected) { if (name === this.model.connectionSelected) {
this.model.connectionSelected = ''; this.model.connectionSelected = '';
} }
api.shutdownConnectionStatus(name);
}); });
},
setPageIndex(pageIndex: string) {
this.model.pageIndex = pageIndex;
},
testConnection: () => api.testConnection(this.model.connectionSelectedOne),
} }
} }

4
src/modules/pages/database/database.model.ts

@ -29,6 +29,7 @@ export class DatebaseModel extends Model<{
}, },
setDatebaseTypes: (datebaseTypes: DatabaseType[]) => { setDatebaseTypes: (datebaseTypes: DatabaseType[]) => {
this.model.datebaseTypes = datebaseTypes; this.model.datebaseTypes = datebaseTypes;
this.model.datebaseTypeSelected = '';
}, },
setInternal:(isInternal: boolean) => { setInternal:(isInternal: boolean) => {
this.model.isInternal = isInternal; this.model.isInternal = isInternal;
@ -36,5 +37,8 @@ export class DatebaseModel extends Model<{
setPlugin: (isPlugin: boolean) => { setPlugin: (isPlugin: boolean) => {
this.model.isPlugin = isPlugin; this.model.isPlugin = isPlugin;
}, },
setDatebaseTypeSelected(datebaseType: string) {
this.model.datebaseTypeSelected = datebaseType;
},
} }
} }

1
src/modules/pages/database/database.ts

@ -63,6 +63,7 @@ export class Datebase extends BI.Widget {
mounted() { mounted() {
this.store.setFilter(DATEBASE_FILTER_TYPE.COMMONLY); this.store.setFilter(DATEBASE_FILTER_TYPE.COMMONLY);
this.store.setDatebaseTypeSelected('');
} }
render() { render() {

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

@ -203,7 +203,7 @@ export class MaintainForm extends BI.Widget {
if (connections.length === 0) { if (connections.length === 0) {
return name; return name;
} }
let index = 1; let index = 0;
connections.forEach(item => { connections.forEach(item => {
const num = parseFloat(item.connectionName.replace(name, '')); const num = parseFloat(item.connectionName.replace(name, ''));
if (num > index) { if (num > index) {

4
src/modules/title/title_maintain/title_maintain.model.ts

@ -1,6 +1,7 @@
import { model, Model } from '@core/core'; import { model, Model } from '@core/core';
import { AppModel } from 'src/modules/app.model'; import { AppModel } from 'src/modules/app.model';
import { ApiFactory } from 'src/modules/crud/apiFactory';
const api = new ApiFactory().create();
export const TitleMaintainModelXtype = 'dec.dcm.model.title_maintain'; export const TitleMaintainModelXtype = 'dec.dcm.model.title_maintain';
@model(TitleMaintainModelXtype) @model(TitleMaintainModelXtype)
export class TitleMaintainModel extends Model<{ export class TitleMaintainModel extends Model<{
@ -23,5 +24,6 @@ export class TitleMaintainModel extends Model<{
setTestEvent: () => { setTestEvent: () => {
this.model.testEvent = BI.UUID(); this.model.testEvent = BI.UUID();
}, },
shutdownConnectionStatus: () => api.shutdownConnectionStatus(this.model.connectionSelected),
} }
} }

7
src/modules/title/title_maintain/title_maintain.ts

@ -2,7 +2,6 @@ import { shortcut, store } from '@core/core';
import { Right, Button, VerticalAdapt } from 'ui'; import { Right, Button, VerticalAdapt } from 'ui';
import { TitleMaintainModel, TitleMaintainModelXtype } from './title_maintain.model'; import { TitleMaintainModel, TitleMaintainModelXtype } from './title_maintain.model';
import { PAGE_INDEX } from '@constants/constant'; import { PAGE_INDEX } from '@constants/constant';
import { editStatusEvent } from '@constants/env';
export const TitleMaintain = 'dec.dcm.title.maintain'; export const TitleMaintain = 'dec.dcm.title.maintain';
@shortcut(TitleMaintain) @shortcut(TitleMaintain)
@ -24,7 +23,7 @@ export class TitleMaintainWidget extends BI.Widget {
level: 'ignore', level: 'ignore',
handler: () => { handler: () => {
this.store.setPageIndex(PAGE_INDEX.CONNECTION); this.store.setPageIndex(PAGE_INDEX.CONNECTION);
Dec ? Dec.socket.emit(editStatusEvent.SHUTDOWN, this.model.connectionSelected) : null; this.store.shutdownConnectionStatus();
}, },
}, },
{ {
@ -40,7 +39,7 @@ export class TitleMaintainWidget extends BI.Widget {
text: BI.i18nText('BI-Basic_Save'), text: BI.i18nText('BI-Basic_Save'),
handler: () => { handler: () => {
this.store.setSaveEvent(); this.store.setSaveEvent();
Dec ? Dec.socket.emit(editStatusEvent.SHUTDOWN, this.model.connectionSelected) : null; this.store.shutdownConnectionStatus();
}, },
}, },
], ],
@ -50,7 +49,7 @@ export class TitleMaintainWidget extends BI.Widget {
mounted () { mounted () {
window.onunload = () => { window.onunload = () => {
Dec ? Dec.socket.emit(editStatusEvent.SHUTDOWN, this.model.connectionSelected) : null; this.store.shutdownConnectionStatus();
}; };
} }
} }

Loading…
Cancel
Save