data source
This commit is contained in:
parent
bd8d1d611a
commit
a304fc48e9
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "data",
|
"name": "data",
|
||||||
"version": "0.0.27",
|
"version": "0.0.28",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@poweredsoft/data",
|
"name": "@poweredsoft/data",
|
||||||
"version": "0.0.28",
|
"version": "0.0.29",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"rxjs": "^6.5.3"
|
"rxjs": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
protected _loading$: Observable<boolean>;
|
protected _loading$: Observable<boolean>;
|
||||||
protected _validationError$: Observable<IDataSourceValidationError>;
|
protected _validationError$: Observable<IDataSourceValidationError>;
|
||||||
protected _notifyMessage$: Observable<IDataSourceNotifyMessage>;
|
protected _notifyMessage$: Observable<IDataSourceNotifyMessage>;
|
||||||
public manageNotificationMessage: boolean;
|
|
||||||
|
|
||||||
protected _criteria: IQueryCriteria = {
|
protected _criteria: IQueryCriteria = {
|
||||||
page: null,
|
page: null,
|
||||||
@ -68,8 +67,6 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
if (!this.options.defaultCriteria)
|
if (!this.options.defaultCriteria)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.manageNotificationMessage = (null == this.options.manageNotificationMessage || !this.options.manageNotificationMessage) ? false : true;
|
|
||||||
|
|
||||||
const copy: IQueryCriteria = JSON.parse(JSON.stringify(this.options.defaultCriteria));
|
const copy: IQueryCriteria = JSON.parse(JSON.stringify(this.options.defaultCriteria));
|
||||||
this._criteria.page = copy.page || this._criteria.page;
|
this._criteria.page = copy.page || this._criteria.page;
|
||||||
this._criteria.pageSize = copy.pageSize || this._criteria.pageSize;
|
this._criteria.pageSize = copy.pageSize || this._criteria.pageSize;
|
||||||
@ -111,13 +108,12 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
|
|
||||||
return this.options.transport.commands[name].adapter.handle(command).pipe(
|
return this.options.transport.commands[name].adapter.handle(command).pipe(
|
||||||
map(t => {
|
map(t => {
|
||||||
let message = `{command} was executed successfully..`;
|
|
||||||
if (this.manageNotificationMessage)
|
|
||||||
message = message.replace('{command}', name);
|
|
||||||
|
|
||||||
this._notifyMessageSubject.next({
|
this._notifyMessageSubject.next({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: message
|
message: 'COMMAND_EXECUTED_SUCCESFULLY',
|
||||||
|
messageParams: {
|
||||||
|
command: name
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return t;
|
return t;
|
||||||
}),
|
}),
|
||||||
@ -151,14 +147,14 @@ export class DataSource<TModel> implements IDataSource<TModel>
|
|||||||
o.next(result);
|
o.next(result);
|
||||||
this._dataSubject.next(this.data);
|
this._dataSubject.next(this.data);
|
||||||
this._notifyMessageSubject.next({
|
this._notifyMessageSubject.next({
|
||||||
message: 'New data has been read succesfully..',
|
message: 'NEW_DATA_READ_SUCCESFULLY',
|
||||||
type: 'info'
|
type: 'info'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
o.error(err);
|
o.error(err);
|
||||||
this._notifyMessageSubject.next({
|
this._notifyMessageSubject.next({
|
||||||
message: 'Something unexpected as occured during the query',
|
message: 'UNEXPECTED_ERROR_OCCURED',
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export interface IDataSource<TModel>
|
|||||||
resolveCommandModelByName<T extends any>(event: IResolveCommandModelEvent<TModel>) : Observable<T>;
|
resolveCommandModelByName<T extends any>(event: IResolveCommandModelEvent<TModel>) : Observable<T>;
|
||||||
executeCommandByName<TCommand, TResult>(name: string, command: TCommand) : Observable<TResult>;
|
executeCommandByName<TCommand, TResult>(name: string, command: TCommand) : Observable<TResult>;
|
||||||
query<TQuery extends IQueryCriteria>(query: TQuery);
|
query<TQuery extends IQueryCriteria>(query: TQuery);
|
||||||
|
excuteQuery<TQuery extends IQueryCriteria>(query: TQuery): Observable<IQueryExecutionGroupResult<TModel> & IQueryExecutionGroupResult<TModel>>;
|
||||||
refresh();
|
refresh();
|
||||||
resolveIdField<TKeyType extends any>(model: TModel) : TKeyType;
|
resolveIdField<TKeyType extends any>(model: TModel) : TKeyType;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export interface IDataSourceNotifyMessage {
|
export interface IDataSourceNotifyMessage {
|
||||||
type: 'warning' | 'info' | 'success' | 'error';
|
type: 'warning' | 'info' | 'success' | 'error';
|
||||||
message: string;
|
message: string;
|
||||||
|
messageParams?: any;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ export interface IDataSourceOptions<TModel> {
|
|||||||
idField?: string;
|
idField?: string;
|
||||||
resolveIdField?: (model: TModel) => any;
|
resolveIdField?: (model: TModel) => any;
|
||||||
defaultCriteria: IQueryCriteria;
|
defaultCriteria: IQueryCriteria;
|
||||||
manageNotificationMessage?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDataSourceTransportOptions<TModel> {
|
export interface IDataSourceTransportOptions<TModel> {
|
||||||
|
Loading…
Reference in New Issue
Block a user