Upgrade @farmmaps/common-map to angular 8.2
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
parent
fc84548d8a
commit
529b1c9bd7
@ -18,7 +18,7 @@ pipeline {
|
||||
stage('build'){
|
||||
steps {
|
||||
sh '''ng build common
|
||||
'''
|
||||
ng build common-map'''
|
||||
}
|
||||
}
|
||||
stage('npm publish'){
|
||||
@ -26,7 +26,9 @@ pipeline {
|
||||
sh '''cd dist/common
|
||||
npm version ${PACKAGE_VERSION}
|
||||
npm publish
|
||||
'''
|
||||
cd ../common-map
|
||||
npm version ${PACKAGE_VERSION}
|
||||
npm publish'''
|
||||
}
|
||||
}
|
||||
|
||||
|
76
projects/common-map/package-lock.json
generated
76
projects/common-map/package-lock.json
generated
@ -4,68 +4,42 @@
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@farmmaps/common": {
|
||||
"version": "0.0.1-prerelease.56",
|
||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.56.tgz",
|
||||
"integrity": "sha512-m9KxWsLkTSz2JI074gIJH1kDR0PCLsFAug8oBjtlU/QxgBySrvqHCRiODpNmNWnFyNTZHqKHJQefn3Q9iAil4g==",
|
||||
"requires": {
|
||||
"angular-oauth2-oidc": "^5.0.2",
|
||||
"ngx-uploadx": "^3.1.3",
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"angular-oauth2-oidc": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/angular-oauth2-oidc/-/angular-oauth2-oidc-5.0.2.tgz",
|
||||
"integrity": "sha512-jtOv4IWEjSFfBHVE4seWGWT/ZfWJ95QJ1JaFhVVGJEF64ibGuPwV3ztwTOUl98QHi/Yg4PXXDAisb31JnIbxBw==",
|
||||
"requires": {
|
||||
"jsrsasign": "^8.0.12",
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
"@openlayers/pepjs": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@openlayers/pepjs/-/pepjs-0.5.3.tgz",
|
||||
"integrity": "sha512-Bgvi5c14BS0FJWyYWWFstNEnXsB30nK8Jt8hkAAdqr7E0gDdBBWVDglF3Ub19wTxvgJ/CVHyTY6VuCtnyRzglg=="
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.1.13",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
|
||||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
||||
},
|
||||
"jsrsasign": {
|
||||
"version": "8.0.12",
|
||||
"resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-8.0.12.tgz",
|
||||
"integrity": "sha1-Iqu5ZW00owuVMENnIINeicLlwxY="
|
||||
},
|
||||
"ngx-openlayers": {
|
||||
"version": "1.0.0-next.9",
|
||||
"resolved": "https://registry.npmjs.org/ngx-openlayers/-/ngx-openlayers-1.0.0-next.9.tgz",
|
||||
"integrity": "sha512-14UFxJX9oeOXtq+HJCJyXn0sBmYmCqj2AnFtetKk1FsDe8EUMFGIRju8UOFegCr2oEu5JsuRjALcfW7lCe+teg==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"ngx-uploadx": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ngx-uploadx/-/ngx-uploadx-3.3.2.tgz",
|
||||
"integrity": "sha512-gRdXXq2cRU9HE6dj65qay9GV8NRC7n8y5LtMzJWqsfu2k3CHMQxo2TqZwA9/l/PqJ76RoO7sTPy1OenFQ+krkQ==",
|
||||
"version": "1.0.0-next.13",
|
||||
"resolved": "https://registry.npmjs.org/ngx-openlayers/-/ngx-openlayers-1.0.0-next.13.tgz",
|
||||
"integrity": "sha512-6y724s5JV6n1oxEhryxP3wcbwzpierj9RLiMLXInfKOG3l5IO1AtPNkeK9+mKctVDUVm5URIfzzZH02Ld+bvSQ==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"ol": {
|
||||
"version": "5.3.3",
|
||||
"resolved": "https://registry.npmjs.org/ol/-/ol-5.3.3.tgz",
|
||||
"integrity": "sha512-7eU4x8YMduNcED1D5wI+AMWDRe7/1HmGfsbV+kFFROI9RNABU/6n4osj6Q3trZbxxKnK2DSRIjIRGwRHT/Z+Ww==",
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ol/-/ol-6.1.1.tgz",
|
||||
"integrity": "sha512-0dL3i3eJqgOpqIjDKEY3grkeQnjAYfV5L/JCxhOu4SxiaizRwFrFgeas6LILRoxKa03jhQFbut2r2bbgcLGQeA==",
|
||||
"requires": {
|
||||
"pbf": "3.1.0",
|
||||
"@openlayers/pepjs": "^0.5.3",
|
||||
"pbf": "3.2.1",
|
||||
"pixelworks": "1.1.0",
|
||||
"rbush": "2.0.2"
|
||||
"rbush": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"pbf": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pbf/-/pbf-3.1.0.tgz",
|
||||
"integrity": "sha512-/hYJmIsTmh7fMkHAWWXJ5b8IKLWdjdlAFb3IHkRBn1XUhIYBChVGfVwmHEAV3UfXTxsP/AKfYTXTS/dCPxJd5w==",
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz",
|
||||
"integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==",
|
||||
"requires": {
|
||||
"ieee754": "^1.1.6",
|
||||
"resolve-protobuf-schema": "^2.0.0"
|
||||
"ieee754": "^1.1.12",
|
||||
"resolve-protobuf-schema": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"pixelworks": {
|
||||
@ -79,16 +53,16 @@
|
||||
"integrity": "sha512-Xdayp8sB/mU+sUV4G7ws8xtYMGdQnxbeIfLjyO9TZZRJdztBGhlmbI5x1qcY4TG5hBkIKGnc28i7nXxaugu88w=="
|
||||
},
|
||||
"quickselect": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/quickselect/-/quickselect-1.1.1.tgz",
|
||||
"integrity": "sha512-qN0Gqdw4c4KGPsBOQafj6yj/PA6c/L63f6CaZ/DCF/xF4Esu3jVmKLUDYxghFx8Kb/O7y9tI7x2RjTSXwdK1iQ=="
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz",
|
||||
"integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="
|
||||
},
|
||||
"rbush": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rbush/-/rbush-2.0.2.tgz",
|
||||
"integrity": "sha512-XBOuALcTm+O/H8G90b6pzu6nX6v2zCKiFG4BJho8a+bY6AER6t8uQUZdi5bomQc0AprCWhEGa7ncAbbRap0bRA==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rbush/-/rbush-3.0.1.tgz",
|
||||
"integrity": "sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==",
|
||||
"requires": {
|
||||
"quickselect": "^1.0.1"
|
||||
"quickselect": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"resolve-protobuf-schema": {
|
||||
|
@ -5,16 +5,16 @@
|
||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||
},
|
||||
"dependencies": {
|
||||
"ngx-openlayers": "1.0.0-next.9",
|
||||
"ol": "^5.3.3"
|
||||
"ngx-openlayers": "1.0.0-next.13",
|
||||
"ol": "^6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/core": "^7.2.0",
|
||||
"@angular/core": "^8.2.0",
|
||||
"ngrx-store-localstorage": "^8.0.0",
|
||||
"@ngrx/effects": "^7.2",
|
||||
"@ngrx/router-store": "^7.2",
|
||||
"@ngrx/store": "^7.2",
|
||||
"@ngrx/effects": "^8.2",
|
||||
"@ngrx/router-store": "^8.2",
|
||||
"@ngrx/store": "^8.2",
|
||||
"tassign": "^1.0.0",
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.56 <0.0.1"
|
||||
"@farmmaps/common": ">=0.0.1-prerelease.82 <0.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import { debounceTime,distinctUntilChanged,tap,switchMap,merge,catchError} from
|
||||
import { TypeaheadService, TimespanService } from '@farmmaps/common';
|
||||
import { IQueryState } from '../../models/query.state';
|
||||
import { IPeriodState } from '../../models/period.state';
|
||||
import { fillProperties } from '@angular/core/src/util/property';
|
||||
import { tassign } from 'tassign';
|
||||
|
||||
@Component({
|
||||
|
@ -1,230 +1,230 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Store, Action } from '@ngrx/store';
|
||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
||||
|
||||
import { Observable , of } from 'rxjs';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap, delay} from 'rxjs/operators';
|
||||
|
||||
import {GeoJSON} from 'ol/format';
|
||||
import {Feature} from 'ol';
|
||||
import { getCenter, Extent, createEmpty, extend} from 'ol/extent';
|
||||
import {Point} from 'ol/geom'
|
||||
|
||||
|
||||
import * as mapActions from '../actions/map.actions';
|
||||
import * as mapReducers from '../reducers/map.reducer';
|
||||
import {commonReducers} from '@farmmaps/common';
|
||||
|
||||
import {commonActions} from '@farmmaps/common';
|
||||
|
||||
import { IListItem, IItem } from '@farmmaps/common';
|
||||
import { FolderService, ItemService } from '@farmmaps/common';
|
||||
import { tassign } from 'tassign';
|
||||
|
||||
@Injectable()
|
||||
export class MapEffects {
|
||||
private _format: GeoJSON;
|
||||
|
||||
private toPointFeature(feature: any): Feature {
|
||||
var f = this._format.readFeature(feature);
|
||||
var centroid = getCenter(f.getGeometry().getExtent());
|
||||
f.setGeometry(new Point(centroid));
|
||||
return f;
|
||||
}
|
||||
|
||||
@Effect()
|
||||
init$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.INIT),
|
||||
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
||||
switchMap(([action, rootItems]) => {
|
||||
for (let rootItem of rootItems) {
|
||||
if (rootItem.itemType == "UPLOADS_FOLDER") return of(new mapActions.SetParent(rootItem.code));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
initBaseLayers$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.INIT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
||||
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)));
|
||||
|
||||
@Effect()
|
||||
loadBaseLayers$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.LOADBASELAYERS),
|
||||
switchMap((action: mapActions.LoadBaseLayers) => {
|
||||
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
||||
map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
initRootItems$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.INITROOTSUCCESS),
|
||||
map((action) => new mapActions.Init()
|
||||
));
|
||||
|
||||
@Effect()
|
||||
startSearch$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCH),
|
||||
switchMap((action: mapActions.StartSearch) => {
|
||||
console.debug("Start search");
|
||||
var startDate = action.queryState.startDate;
|
||||
var endDate = action.queryState.endDate;
|
||||
var newAction;
|
||||
if (action.queryState.itemCode || action.queryState.parentCode || action.queryState.itemType || action.queryState.query || action.queryState.tags) {
|
||||
newAction= this.itemService$.getFeatures(action.queryState.bbox, "EPSG:3857", action.queryState.query, action.queryState.tags, startDate, endDate, action.queryState.itemType, action.queryState.parentCode).pipe(
|
||||
switchMap((features: any) => {
|
||||
for (let f of features.features) {
|
||||
if (f.properties && f.properties["code"]) {
|
||||
f.id = f.properties["code"];
|
||||
}
|
||||
}
|
||||
return of(new mapActions.StartSearchSuccess(this._format.readFeatures(features), action.queryState));
|
||||
}
|
||||
),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
newAction= of(new commonActions.Escape(true,false));
|
||||
}
|
||||
return newAction;
|
||||
}));
|
||||
|
||||
|
||||
@Effect()
|
||||
startSearchSucces$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||
if (action.query.bboxFilter) {
|
||||
return [];
|
||||
} else {
|
||||
var extent = createEmpty();
|
||||
|
||||
if (extent) {
|
||||
for (let f of action.features) {
|
||||
extend(extent, (f as Feature).getGeometry().getExtent());
|
||||
}
|
||||
}
|
||||
//return [];
|
||||
return of(new mapActions.SetExtent(extent));
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
selectItem$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SELECTITEM),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||
switchMap(([action, selectedItem]) => {
|
||||
let a = action as mapActions.SelectItem;
|
||||
let itemCode = selectedItem ? selectedItem.code : "";
|
||||
if (a.itemCode != itemCode) {
|
||||
return this.itemService$.getItem(a.itemCode).pipe(
|
||||
map((item: IItem) => new mapActions.SelectItemSuccess(item)),
|
||||
catchError(error => of(new commonActions.Fail(error))))
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
selectItemSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SELECTITEMSUCCESS),
|
||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||
map((feature: IItem) => new mapActions.AddFeatureSuccess(this._format.readFeature(feature) )),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
uploadedItemClick$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.UPLOADEDFILECLICK),
|
||||
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode})))
|
||||
));
|
||||
|
||||
//@Effect()
|
||||
//itemAdded$: Observable<Action> = this.actions$.pipe(
|
||||
// ofType(commonActions.ITEMADDEDEVENT),
|
||||
// withLatestFrom(this.store$.select(mapReducers.selectGetParentCode)),
|
||||
// mergeMap(([action, parentCode]) => {
|
||||
// let itemAddedAction = action as commonActions.ItemAddedEvent;
|
||||
// if (parentCode && itemAddedAction.attributes["parentCode"] == parentCode) {
|
||||
// return this.itemService$.getFeature(itemAddedAction.itemCode,"EPSG:3857").pipe(
|
||||
// map((feature: Feature) => new mapActions.AddFeatureSuccess(this.toPointFeature(feature))),
|
||||
// catchError(error => of(new commonActions.Fail(error))))
|
||||
// } else
|
||||
// return [
|
||||
// ];
|
||||
// }));
|
||||
|
||||
@Effect()
|
||||
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
||||
mergeMap(([action, features]) => {
|
||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
||||
var feature: Feature = null;
|
||||
for (let f of features) {
|
||||
if (f.get("code") == itemChangedAction.itemCode) {
|
||||
feature = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (feature) {
|
||||
return this.itemService$.getFeature(itemChangedAction.itemCode, "EPSG:3857").pipe(
|
||||
map((feature: any) => new mapActions.UpdateFeatureSuccess(this.toPointFeature(feature))),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
itemUpdate$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||
mergeMap(([action, selectedItem]) => {
|
||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
||||
if (selectedItem && selectedItem.code == itemChangedAction.itemCode) {
|
||||
return this.itemService$.getItem(itemChangedAction.itemCode).pipe(
|
||||
map((item: IItem) => new mapActions.SelectItemSuccess(item)),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
setQueryState$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SETQUERYSTATE),
|
||||
switchMap((action: mapActions.SetQueryState) => {
|
||||
var newAction:Action;
|
||||
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
||||
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
||||
} else {
|
||||
newAction= new mapActions.StartSearch(action.queryState);
|
||||
}
|
||||
return of(newAction);
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
setState$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SETSTATE),
|
||||
switchMap((action: mapActions.SetState) => {
|
||||
var newAction:Action;
|
||||
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
||||
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
||||
} else {
|
||||
newAction= new mapActions.StartSearch(action.queryState);
|
||||
}
|
||||
return of(newAction);
|
||||
}));
|
||||
|
||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService) {
|
||||
this._format = new GeoJSON();
|
||||
}
|
||||
}
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Store, Action } from '@ngrx/store';
|
||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
||||
|
||||
import { Observable , of } from 'rxjs';
|
||||
import { withLatestFrom, switchMap, map, catchError, mergeMap, delay} from 'rxjs/operators';
|
||||
|
||||
import {GeoJSON} from 'ol/format';
|
||||
import {Feature} from 'ol';
|
||||
import { getCenter, Extent, createEmpty, extend} from 'ol/extent';
|
||||
import {Point} from 'ol/geom'
|
||||
|
||||
|
||||
import * as mapActions from '../actions/map.actions';
|
||||
import * as mapReducers from '../reducers/map.reducer';
|
||||
import {commonReducers} from '@farmmaps/common';
|
||||
|
||||
import {commonActions} from '@farmmaps/common';
|
||||
|
||||
import { IListItem, IItem } from '@farmmaps/common';
|
||||
import { FolderService, ItemService } from '@farmmaps/common';
|
||||
import { tassign } from 'tassign';
|
||||
|
||||
@Injectable()
|
||||
export class MapEffects {
|
||||
private _format: GeoJSON;
|
||||
|
||||
private toPointFeature(feature: any): Feature {
|
||||
var f = this._format.readFeature(feature);
|
||||
var centroid = getCenter(f.getGeometry().getExtent());
|
||||
f.setGeometry(new Point(centroid));
|
||||
return f;
|
||||
}
|
||||
|
||||
@Effect()
|
||||
init$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.INIT),
|
||||
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
||||
switchMap(([action, rootItems]) => {
|
||||
for (let rootItem of rootItems) {
|
||||
if (rootItem.itemType == "UPLOADS_FOLDER") return of(new mapActions.SetParent(rootItem.code));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
initBaseLayers$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.INIT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
||||
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)));
|
||||
|
||||
@Effect()
|
||||
loadBaseLayers$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.LOADBASELAYERS),
|
||||
switchMap((action: mapActions.LoadBaseLayers) => {
|
||||
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
||||
map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
initRootItems$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.INITROOTSUCCESS),
|
||||
map((action) => new mapActions.Init()
|
||||
));
|
||||
|
||||
@Effect()
|
||||
startSearch$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCH),
|
||||
switchMap((action: mapActions.StartSearch) => {
|
||||
console.debug("Start search");
|
||||
var startDate = action.queryState.startDate;
|
||||
var endDate = action.queryState.endDate;
|
||||
var newAction:Observable<Action>;
|
||||
if (action.queryState.itemCode || action.queryState.parentCode || action.queryState.itemType || action.queryState.query || action.queryState.tags) {
|
||||
newAction= this.itemService$.getFeatures(action.queryState.bbox, "EPSG:3857", action.queryState.query, action.queryState.tags, startDate, endDate, action.queryState.itemType, action.queryState.parentCode).pipe(
|
||||
switchMap((features: any) => {
|
||||
for (let f of features.features) {
|
||||
if (f.properties && f.properties["code"]) {
|
||||
f.id = f.properties["code"];
|
||||
}
|
||||
}
|
||||
return of(new mapActions.StartSearchSuccess(this._format.readFeatures(features), action.queryState));
|
||||
}
|
||||
),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
newAction= of(new commonActions.Escape(true,false));
|
||||
}
|
||||
return newAction;
|
||||
}));
|
||||
|
||||
|
||||
@Effect()
|
||||
startSearchSucces$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||
if (action.query.bboxFilter) {
|
||||
return [];
|
||||
} else {
|
||||
var extent = createEmpty();
|
||||
|
||||
if (extent) {
|
||||
for (let f of action.features) {
|
||||
extend(extent, (f as Feature).getGeometry().getExtent());
|
||||
}
|
||||
}
|
||||
//return [];
|
||||
return of(new mapActions.SetExtent(extent));
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
selectItem$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SELECTITEM),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||
switchMap(([action, selectedItem]) => {
|
||||
let a = action as mapActions.SelectItem;
|
||||
let itemCode = selectedItem ? selectedItem.code : "";
|
||||
if (a.itemCode != itemCode) {
|
||||
return this.itemService$.getItem(a.itemCode).pipe(
|
||||
map((item: IItem) => new mapActions.SelectItemSuccess(item)),
|
||||
catchError(error => of(new commonActions.Fail(error))))
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
selectItemSuccess$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SELECTITEMSUCCESS),
|
||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||
map((feature: IItem) => new mapActions.AddFeatureSuccess(this._format.readFeature(feature) )),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
}
|
||||
));
|
||||
|
||||
@Effect()
|
||||
uploadedItemClick$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.UPLOADEDFILECLICK),
|
||||
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode})))
|
||||
));
|
||||
|
||||
//@Effect()
|
||||
//itemAdded$: Observable<Action> = this.actions$.pipe(
|
||||
// ofType(commonActions.ITEMADDEDEVENT),
|
||||
// withLatestFrom(this.store$.select(mapReducers.selectGetParentCode)),
|
||||
// mergeMap(([action, parentCode]) => {
|
||||
// let itemAddedAction = action as commonActions.ItemAddedEvent;
|
||||
// if (parentCode && itemAddedAction.attributes["parentCode"] == parentCode) {
|
||||
// return this.itemService$.getFeature(itemAddedAction.itemCode,"EPSG:3857").pipe(
|
||||
// map((feature: Feature) => new mapActions.AddFeatureSuccess(this.toPointFeature(feature))),
|
||||
// catchError(error => of(new commonActions.Fail(error))))
|
||||
// } else
|
||||
// return [
|
||||
// ];
|
||||
// }));
|
||||
|
||||
@Effect()
|
||||
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
||||
mergeMap(([action, features]) => {
|
||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
||||
var feature: Feature = null;
|
||||
for (let f of features) {
|
||||
if (f.get("code") == itemChangedAction.itemCode) {
|
||||
feature = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (feature) {
|
||||
return this.itemService$.getFeature(itemChangedAction.itemCode, "EPSG:3857").pipe(
|
||||
map((feature: any) => new mapActions.UpdateFeatureSuccess(this.toPointFeature(feature))),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
itemUpdate$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||
mergeMap(([action, selectedItem]) => {
|
||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
||||
if (selectedItem && selectedItem.code == itemChangedAction.itemCode) {
|
||||
return this.itemService$.getItem(itemChangedAction.itemCode).pipe(
|
||||
map((item: IItem) => new mapActions.SelectItemSuccess(item)),
|
||||
catchError(error => of(new commonActions.Fail(error))));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
setQueryState$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SETQUERYSTATE),
|
||||
switchMap((action: mapActions.SetQueryState) => {
|
||||
var newAction:Action;
|
||||
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
||||
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
||||
} else {
|
||||
newAction= new mapActions.StartSearch(action.queryState);
|
||||
}
|
||||
return of(newAction);
|
||||
}));
|
||||
|
||||
@Effect()
|
||||
setState$: Observable<Action> = this.actions$.pipe(
|
||||
ofType(mapActions.SETSTATE),
|
||||
switchMap((action: mapActions.SetState) => {
|
||||
var newAction:Action;
|
||||
if (action.queryState.itemCode && action.queryState.itemCode != "") {
|
||||
newAction= new mapActions.SelectItem(action.queryState.itemCode);
|
||||
} else {
|
||||
newAction= new mapActions.StartSearch(action.queryState);
|
||||
}
|
||||
return of(newAction);
|
||||
}));
|
||||
|
||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService) {
|
||||
this._format = new GeoJSON();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user