ngx data :)
This commit is contained in:
parent
3efc179756
commit
c89cc92d33
127
package-lock.json
generated
127
package-lock.json
generated
@ -12,6 +12,17 @@
|
||||
"requires": {
|
||||
"@angular-devkit/core": "8.3.3",
|
||||
"rxjs": "6.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular-devkit/build-angular": {
|
||||
@ -76,6 +87,17 @@
|
||||
"webpack-subresource-integrity": "1.1.0-rc.6",
|
||||
"worker-farm": "1.7.0",
|
||||
"worker-plugin": "3.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular-devkit/build-ng-packagr": {
|
||||
@ -86,6 +108,17 @@
|
||||
"requires": {
|
||||
"@angular-devkit/architect": "0.803.3",
|
||||
"rxjs": "6.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular-devkit/build-optimizer": {
|
||||
@ -111,6 +144,17 @@
|
||||
"@angular-devkit/core": "8.3.3",
|
||||
"rxjs": "6.4.0",
|
||||
"webpack-merge": "4.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular-devkit/core": {
|
||||
@ -124,6 +168,17 @@
|
||||
"magic-string": "0.25.3",
|
||||
"rxjs": "6.4.0",
|
||||
"source-map": "0.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular-devkit/schematics": {
|
||||
@ -134,6 +189,17 @@
|
||||
"requires": {
|
||||
"@angular-devkit/core": "8.3.3",
|
||||
"rxjs": "6.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@angular/animations": {
|
||||
@ -330,7 +396,8 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -371,7 +438,8 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
@ -381,7 +449,8 @@
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -511,6 +580,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -636,7 +706,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -769,6 +840,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -788,6 +860,7 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -831,7 +904,8 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
@ -1829,12 +1903,26 @@
|
||||
"rxjs": "6.4.0",
|
||||
"tree-kill": "1.2.1",
|
||||
"webpack-sources": "1.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@poweredsoft/data": {
|
||||
"version": "0.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@poweredsoft/data/-/data-0.0.11.tgz",
|
||||
"integrity": "sha512-5KpsJg6l2sQ0Qx4RZ16lH9DtfeuJHWIqpGNe5wvkp8Csno7a/p+Rgaw1mePiDMpCKJudVLXKdLAfewGv5daSsA=="
|
||||
"version": "0.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@poweredsoft/data/-/data-0.0.14.tgz",
|
||||
"integrity": "sha512-FKCFKUp4kdGO3BAiOT4hP3QOXDwH2hAtMrE41JecN9tsYckXXXYarUhVMOcU8Z8mz8KgK9lTcIZFwniBkbuFHQ==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@schematics/angular": {
|
||||
"version": "8.3.3",
|
||||
@ -1860,6 +1948,17 @@
|
||||
"rxjs": "6.4.0",
|
||||
"semver": "6.3.0",
|
||||
"semver-intersect": "1.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@sindresorhus/is": {
|
||||
@ -7206,8 +7305,7 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
@ -7311,8 +7409,7 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -10194,9 +10291,9 @@
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
|
||||
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz",
|
||||
"integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
"@angular/platform-browser": "~8.2.4",
|
||||
"@angular/platform-browser-dynamic": "~8.2.4",
|
||||
"@angular/router": "~8.2.4",
|
||||
"@poweredsoft/data": "0.0.11",
|
||||
"rxjs": "~6.4.0",
|
||||
"@poweredsoft/data": "0.0.14",
|
||||
"rxjs": "~6.5.3",
|
||||
"tslib": "^1.10.0",
|
||||
"zone.js": "~0.9.1"
|
||||
},
|
||||
|
@ -1,8 +1,10 @@
|
||||
{
|
||||
"name": "@poweredsoft/ngx-data",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.6",
|
||||
"peerDependencies": {
|
||||
"@angular/common": "^8.2.4",
|
||||
"@angular/core": "^8.2.4"
|
||||
"@angular/core": "^8.2.4",
|
||||
"@poweredsoft/data": "^0.0.14",
|
||||
"rxjs": "^6.5.3"
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NgxDataComponent } from './ngx-data.component';
|
||||
|
||||
describe('NgxDataComponent', () => {
|
||||
let component: NgxDataComponent;
|
||||
let fixture: ComponentFixture<NgxDataComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ NgxDataComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NgxDataComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -1,19 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'lib-ngx-data',
|
||||
template: `
|
||||
<p>
|
||||
ngx-data works!
|
||||
</p>
|
||||
`,
|
||||
styles: []
|
||||
})
|
||||
export class NgxDataComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NgxDataComponent } from './ngx-data.component';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [NgxDataComponent],
|
||||
declarations: [],
|
||||
imports: [
|
||||
],
|
||||
exports: [NgxDataComponent]
|
||||
exports: [],
|
||||
})
|
||||
export class NgxDataModule { }
|
||||
|
@ -1,12 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NgxDataService } from './ngx-data.service';
|
||||
|
||||
describe('NgxDataService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: NgxDataService = TestBed.get(NgxDataService);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@ -1,9 +1,65 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { IDataSourceTransportOptions, IDataSourceCommandAdapterOptions } from '@poweredsoft/data';
|
||||
import { IQueryExecutionResult, IQueryExecutionGroupResult, IQueryCriteria } from '@poweredsoft/data';
|
||||
import { IDataSourceQueryAdapterOptions } from '@poweredsoft/data';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NgxDataService {
|
||||
export class GenericRestDataSourceService
|
||||
{
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
createStandardRestTransportOptions<TModel, TKey>(route: string, keyResolver: (model: TModel) => TKey) : IDataSourceTransportOptions<TModel> {
|
||||
|
||||
const query: IDataSourceQueryAdapterOptions<TModel> = {
|
||||
adapter: {
|
||||
handle: (criteria: IQueryCriteria) => {
|
||||
const queryRoute = `${route}/read`;
|
||||
return this.http.post<IQueryExecutionResult<TModel> & IQueryExecutionGroupResult<TModel>>(queryRoute, criteria);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const createCommand: IDataSourceCommandAdapterOptions<TModel> = {
|
||||
adapter: {
|
||||
handle: (command: TModel) => {
|
||||
return this.http.post<TModel>(route, command);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const updateCommand: IDataSourceCommandAdapterOptions<TModel> = {
|
||||
adapter: {
|
||||
handle: (command: TModel) => {
|
||||
const key = keyResolver(command);
|
||||
const updateRoute = `${route}/${encodeURIComponent(key as any)}`;
|
||||
return this.http.put<TModel>(updateRoute, command);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const deleteCommand: IDataSourceCommandAdapterOptions<TModel> = {
|
||||
adapter: {
|
||||
handle: (command: TModel) => {
|
||||
const key = keyResolver(command);
|
||||
const updateRoute = `${route}/${encodeURIComponent(key as any)}`;
|
||||
return this.http.delete<TModel>(updateRoute);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
query: query,
|
||||
commands: {
|
||||
'create': createCommand,
|
||||
'update': updateCommand,
|
||||
'delete': deleteCommand
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -3,5 +3,4 @@
|
||||
*/
|
||||
|
||||
export * from './lib/ngx-data.service';
|
||||
export * from './lib/ngx-data.component';
|
||||
export * from './lib/ngx-data.module';
|
||||
|
@ -1,21 +0,0 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/zone';
|
||||
import 'zone.js/dist/zone-testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
Loading…
Reference in New Issue
Block a user