Merge branch 'develop' of https://git.akkerweb.nl/FarmMaps/FarmMapsLib into develop
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Peter Bastiani 2021-08-04 12:05:09 +02:00
commit ff018d9db1
12 changed files with 232 additions and 175 deletions

54
package-lock.json generated
View File

@ -1657,9 +1657,9 @@
"dev": true
},
"postcss": {
"version": "7.0.35",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.35.tgz",
"integrity": "sha512-3QT8bBJeX/S5zKTTjTCIjRF3If4avAT6kqxcASlTWEtAFCb9NH0OUxNDfgZSWdP5fJnBYCMEWkIFfWeugjzYMg==",
"version": "7.0.36",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.36.tgz",
"integrity": "sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
@ -4079,25 +4079,25 @@
"dev": true
},
"@farmmaps/common": {
"version": "1.0.1",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-1.0.1.tgz",
"integrity": "sha512-ZVj+/0dVSNT1TtU+ExBFyak/Hfl8hKl5RnBWux6+v7GyHJYyaYDotbSPhszoNm6Mrz7Lt0pifCja1vUKL8w5sQ==",
"version": "1.1.1-prerelease.2031",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-1.1.1-prerelease.2031.tgz",
"integrity": "sha512-lSmTd2D1/PqzaXBjjY4X6UTYA5joZndXyZpUkFNm/Z0TTFmzFKmiIyGRA9AHX4StdQXC7QsCNfalYN31tnwtuQ==",
"requires": {
"tslib": "^2.0.0"
}
},
"@farmmaps/common-map": {
"version": "1.0.1",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-1.0.1.tgz",
"integrity": "sha512-yWBM/F0RLvb6hG0QEREBamYOeaPUjIYUw2tazlQoXzVtGeNm/8S0p+3l6Uw6U3z35Zk7/Ptaeb7nXsK6dOGgWg==",
"version": "1.1.1-prerelease.2031",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-1.1.1-prerelease.2031.tgz",
"integrity": "sha512-BQ2bvNohPth0+oxoSoh+WWLJ/mP2CGW4Qf4xqgC3tgfW+UZfD0dBPl7IT2piuvOuUQzlSVloinCJ4ciZGyZRXg==",
"requires": {
"tslib": "^2.0.0"
}
},
"@farmmaps/common-map3d": {
"version": "1.0.1",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map3d/-/common-map3d-1.0.1.tgz",
"integrity": "sha512-7aD/d1s35l8QwUPn4Z4LwxoRE4qhW+1KBAxcXEorIoc4pFTR04Mx+WoYJgTYXaOjAayPjTUM7K+bpR6d0uCqMA==",
"version": "1.1.1-prerelease.2031",
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map3d/-/common-map3d-1.1.1-prerelease.2031.tgz",
"integrity": "sha512-2M5wv5sFwlVwPGlN1b1AGM3Dh/DJFS7+L3b6e6ir2+ASoyy7xhZ67IWS2du8B7y7/xVsgxCJcJp1EJezbSCMAA==",
"requires": {
"tslib": "^2.0.0"
}
@ -9897,9 +9897,9 @@
}
},
"lodash": {
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"lodash.memoize": {
@ -11633,9 +11633,9 @@
"dev": true
},
"postcss": {
"version": "7.0.32",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.32.tgz",
"integrity": "sha512-03eXong5NLnNCD05xscnGKGDZ98CyzoqPSMjOe6SuoQY7Z2hIj0Ld1g/O/UQRuOle2aRtiIRDg9tDcTGAkLfKw==",
"version": "7.0.36",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.36.tgz",
"integrity": "sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw==",
"dev": true,
"requires": {
"chalk": "^2.4.2",
@ -14717,9 +14717,9 @@
}
},
"url-parse": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz",
"integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==",
"requires": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
@ -15303,9 +15303,9 @@
"dev": true
},
"ws": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz",
"integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==",
"requires": {
"async-limiter": "~1.0.0"
}
@ -15342,9 +15342,9 @@
}
},
"y18n": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true
},
"yallist": {

View File

@ -19,9 +19,9 @@
"@angular/platform-browser": "~11.2.14",
"@angular/platform-browser-dynamic": "~11.2.14",
"@angular/router": "~11.2.14",
"@farmmaps/common": "~1.0",
"@farmmaps/common-map": "~1.0",
"@farmmaps/common-map3d": "~1.0",
"@farmmaps/common": "1.1.1-prerelease.2031",
"@farmmaps/common-map": "1.1.1-prerelease.2031",
"@farmmaps/common-map3d": "1.1.1-prerelease.2031",
"@microsoft/signalr": "^3.1.16",
"@ng-bootstrap/ng-bootstrap": "^9.0",
"@ngrx/effects": "^11.0",

View File

@ -257,7 +257,7 @@ export class ZoomToExtent implements Action {
export class DoQuery implements Action {
readonly type = DOQUERY;
constructor(public query:IQueryState) { }
constructor(public query:IQueryState,public replace:boolean = false) { }
}
export class SetStyle implements Action {

View File

@ -1,4 +1,5 @@
import { Component, Host, Input, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ViewComponent, MapComponent } from 'ngx-openlayers';
@ -9,12 +10,24 @@ import { ViewComponent, MapComponent } from 'ngx-openlayers';
export class ZoomToExtentComponent implements OnChanges {
view: ViewComponent;
map: MapComponent;
paddingTop: number = 0;
paddingLeft: number = 0;
paddingBottom: number = 0;
paddingRight: number = 0;
@Input() extent: number[];
@Input() animate: boolean = false;
constructor(@Host() view: ViewComponent, @Host() map: MapComponent) {
constructor(@Host() view: ViewComponent, @Host() map: MapComponent,route: ActivatedRoute ) {
this.view = view;
this.map = map;
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-zoom-to-extent"]) {
let params = route.snapshot.data["fm-map-zoom-to-extent"];
this.paddingTop = params["padding-top"] ? params["padding-top"] : 0;
this.paddingBottom = params["padding-bottom"] ? params["padding-bottom"] : 0;
this.paddingLeft = params["padding-left"] ? params["padding-left"] : 0;
this.paddingRight = params["padding-right"] ? params["padding-right"] : 0;
}
}
ngOnChanges(changes: SimpleChanges) {
@ -31,7 +44,7 @@ export class ZoomToExtentComponent implements OnChanges {
bottom = 5 * rem;
left = 23 * rem;
}
options.padding = [top, right, bottom, left];
options.padding = [top + (this.paddingTop*rem), right+ (this.paddingRight*rem), bottom + (this.paddingBottom*rem), left+ (this.paddingLeft*rem)];
if (this.animate) options["duration"] = 1000;
this.view.instance.fit(this.extent, options);
}

View File

@ -33,8 +33,8 @@
<aol-interaction-default></aol-interaction-default>
<aol-interaction-dragrotateandzoom></aol-interaction-dragrotateandzoom>
<fm-map-item-layers [itemLayers]="state.baseLayers"></fm-map-item-layers>
<fm-map-item-layers [itemLayers]="state.overlayLayers"></fm-map-item-layers>
<fm-map-item-layers [itemLayer]="state.selectedItemLayer"></fm-map-item-layers>
<fm-map-item-layers *ngIf="!overrideOverlayLayers" [itemLayers]="state.overlayLayers"></fm-map-item-layers>
<fm-map-item-layers *ngIf="!overrideSelectedItemLayer" [itemLayer]="state.selectedItemLayer"></fm-map-item-layers>
<aol-layer-vector>
<fm-map-item-source-vector [styles]="state.styles" [features]="state.features" (onFeatureSelected)="handleFeatureClick($event)" (onFeatureHover)="handleFeatureHover($event)" [selectedFeature]="state.selectedFeature" [selectedItem]="state.selectedItem"></fm-map-item-source-vector>
</aol-layer-vector>

View File

@ -61,6 +61,7 @@ aol-map { position:absolute;width:100%;height:calc(100vh + 4rem);}
top:0em;
bottom: 7.1em;
width: 100%;
pointer-events: none;
}
.fullscreen .side-panel-container {

View File

@ -11,6 +11,7 @@ import { DeviceService } from '@farmmaps/common';
import * as mapReducers from '../../reducers/map.reducer';
import * as mapActions from '../../actions/map.actions';
import { IMapState} from '../../models/map.state';
import { IQuery } from '../../reducers/map.reducer'
import { ISelectedFeatures } from '../../models/selected.features';
import { IItemLayer } from '../../models/item.layer';
import { IListItem, IQueryState } from '@farmmaps/common';
@ -73,7 +74,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
public searchCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchCollapsed);
public searchMinified$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchMinified);
public menuVisible$: Observable<boolean>;
public query$: Observable<IQueryState> = this.store.select(mapReducers.selectGetQuery);
public query$: Observable<IQuery> = this.store.select(mapReducers.selectGetQuery);
public position$: Observable<GeolocationPosition> = this.geolocationService.getCurrentPosition();
public compassHeading$: Observable<number> = this.deviceorientationService.getCurrentCompassHeading();
public baseLayersCollapsed:boolean = true;
@ -84,6 +85,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
private lastUrl = "";
private initialized: boolean = false;
public noContent: boolean = false;
public overrideSelectedItemLayer: boolean = false;
public overrideOverlayLayers: boolean = false;
@ViewChild('map') map;
@ViewChild('contentDiv') contentDiv: ElementRef;
@ -99,28 +102,33 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
private zone: NgZone,
private deviceorientationService:DeviceOrientationService,
public devicesService:DeviceService) {
this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$)).subscribe(([queryState,mapState]) =>{
if(queryState) {
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-map"]) {
let params = route.snapshot.data["fm-map-map"];
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
this.overrideOverlayLayers = params["overrideOverlayLayers"] ? params["overrideOverlayLayers"] : false;
}
this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$)).subscribe(([query,mapState]) =>{
if(query && query.querystate) {
let newQueryState = tassign(mapReducers.initialQueryState);
console.debug(`Do Query`);
let urlparts=[];
if (queryState.itemCode && queryState.itemCode != "") {
if(queryState.itemType && queryState.itemType!= "") {
let itemType = this.itemTypeService.itemTypes[queryState.itemType];
if (query.querystate.itemCode && query.querystate.itemCode != "") {
if(query.querystate.itemType && query.querystate.itemType!= "") {
let itemType = this.itemTypeService.itemTypes[query.querystate.itemType];
if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) {
urlparts.push('/editor');
urlparts.push(itemType.editor);
urlparts.push('item');
urlparts.push(queryState.itemCode);
urlparts.push(query.querystate.itemCode);
}
}
} else {
newQueryState= queryState;
newQueryState= query.querystate;
}
if(urlparts.length==0 ) {
newQueryState.itemCode = queryState.itemCode;
newQueryState.itemCode = query.querystate.itemCode;
this.zone.run(() => {
this.replaceUrl(mapState,newQueryState,false);
this.replaceUrl(mapState,newQueryState,query.replace);
})
} else {
this.router.navigate(urlparts);

View File

@ -1,10 +1,12 @@
import { Injectable } from '@angular/core';
import { Store, Action } from '@ngrx/store';
import { Effect, Actions,ofType } from '@ngrx/effects';
import { Store, Action,createFeatureSelector } from '@ngrx/store';
import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store';
import * as fromRouter from '@ngrx/router-store';
import { createEffect, Actions,ofType } from '@ngrx/effects';
import { EMPTY, Observable , of,merge} from 'rxjs';
import { withLatestFrom, switchMap, map, catchError, mergeMap,tap } from 'rxjs/operators';
import { EMPTY, Observable , of} from 'rxjs';
import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators';
import {GeoJSON,WKT} from 'ol/format';
import {Feature} from 'ol';
@ -29,11 +31,24 @@ import * as style from 'ol/style';
import { ItemTypeService,IQueryState } from '@farmmaps/common';
import { TemporalItemLayer } from '../models/item.layer'
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
export const {
selectCurrentRoute, // select the current route
selectQueryParams, // select the current route query params
selectQueryParam, // factory function to select a query param
selectRouteParams, // select the current route params
selectRouteParam, // factory function to select a route param
selectRouteData, // select the current route data
selectUrl, // select the current url
} = fromRouter.getSelectors(getRouterState);
@Injectable()
export class MapEffects {
private _geojsonFormat: GeoJSON;
private _wktFormat: WKT;
private overrideSelectedItemLayer: boolean = false;
private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature {
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
@ -46,8 +61,7 @@ export class MapEffects {
return f;
}
@Effect()
init$: Observable<Action> = this.actions$.pipe(
init$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.INIT),
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
switchMap(([action, rootItems]) => {
@ -87,25 +101,23 @@ export class MapEffects {
return actions;
}
));
)));
@Effect()
initBaseLayers$: Observable<Action> = this.actions$.pipe(
initBaseLayers$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.INIT),
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)));
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)))
);
@Effect()
loadBaseLayers$: Observable<Action> = this.actions$.pipe(
loadBaseLayers$ = createEffect(() => 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()
startSearch$: Observable<Action> = this.actions$.pipe(
startSearch$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.STARTSEARCH),
switchMap((action) => {
let a = action as mapActions.StartSearch;
@ -128,11 +140,10 @@ export class MapEffects {
return [];
}
return newAction;
}));
})));
@Effect()
zoomToExtent$: Observable<Action> = this.actions$.pipe(
zoomToExtent$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.STARTSEARCHSUCCESS),
mergeMap((action: mapActions.StartSearchSuccess) => {
let actions =[];
@ -149,10 +160,9 @@ export class MapEffects {
}
}
return actions;
}));
})));
@Effect()
zoomToExtent2$: Observable<Action> = this.actions$.pipe(
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SETFEATURES),
switchMap((action: mapActions.SetFeatures) => {
let extent = createEmpty();
@ -163,17 +173,15 @@ export class MapEffects {
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
}
return EMPTY;
}));
})));
@Effect()
hideMenu$: Observable<Action> = this.actions$.pipe(
hideMenu$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.STARTSEARCHSUCCESS),
mergeMap((action: mapActions.StartSearchSuccess) => {
return of(new commonActions.SetMenuVisible(false));
}));
})));
@Effect()
selectItem$: Observable<Action> = this.actions$.pipe(
selectItem$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SELECTITEM),
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
switchMap(([action, selectedItem]) => {
@ -194,20 +202,19 @@ export class MapEffects {
return [];
}
}
));
)));
@Effect()
selectItemSuccessSetLayer$: Observable<Action> = this.actions$.pipe(
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SELECTITEMSUCCESS),
map((action:mapActions.SelectItemSuccess) =>
new mapActions.SetSelectedItemLayer(action.item)
)
);
));
@Effect()
selectItemSuccess$: Observable<Action> = this.actions$.pipe(
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SELECTITEMSUCCESS),
switchMap((action:mapActions.SelectItemSuccess) => {
if(!this.overrideSelectedItemLayer) {
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
map((feature: any) => {
let f = this._geojsonFormat.readFeature(feature);
@ -215,11 +222,13 @@ export class MapEffects {
return new mapActions.AddFeatureSuccess(f );
}),
catchError(error => of(new commonActions.Fail(error))));
} else {
return EMPTY;
}
));
}
)));
@Effect()
selectItemSuccessTemporal$: Observable<Action> = this.actions$.pipe(
selectItemSuccessTemporal$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SELECTITEMSUCCESS),
switchMap((action:mapActions.SelectItemSuccess) => {
if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
@ -234,16 +243,14 @@ export class MapEffects {
return [];
}
}
));
)));
@Effect()
uploadedItemClick$: Observable<Action> = this.actions$.pipe(
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
ofType(commonActions.UPLOADEDFILECLICK),
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode})))
));
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query.querystate, {itemCode:action.itemCode})))
)));
@Effect()
featureUpdate$: Observable<Action> = this.actions$.pipe(
featureUpdate$ = createEffect(() => this.actions$.pipe(
ofType(commonActions.DEVICEUPDATEEVENT),
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
mergeMap(([action, features]) => {
@ -260,10 +267,9 @@ export class MapEffects {
} else {
return [];
}
}));
})));
@Effect()
itemUpdate$: Observable<Action> = this.actions$.pipe(
itemUpdate$ = createEffect(() => this.actions$.pipe(
ofType(commonActions.ITEMCHANGEDEVENT),
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
mergeMap(([action, selectedItem]) => {
@ -282,7 +288,7 @@ export class MapEffects {
} else {
return [];
}
}));
})));
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
@ -299,8 +305,7 @@ export class MapEffects {
return of(newAction);
}
@Effect()
getLayerValue$: Observable<Action> = this.actions$.pipe(
getLayerValue$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.GETLAYERVALUE),
mergeMap((action:mapActions.GetLayerValue) => {
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
@ -324,19 +329,17 @@ export class MapEffects {
return a;
}))
}
));
)));
@Effect()
updateLayerValuesOnLayerAddedOrRemoved$: Observable<Action> = this.actions$.pipe(
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEM,mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED),
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEMSUCCESS,mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED,mapActions.SETLAYERINDEX,mapActions.SETSELECTEDITEMLAYER),
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
);
));
@Effect()
getLayerValues$: Observable<Action> = this.actions$.pipe(
getLayerValues$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SETLAYERVALUESLOCATION),
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
@ -362,20 +365,18 @@ export class MapEffects {
});
}
return actions;
}));
})));
@Effect()
setState$: Observable<Action> = this.actions$.pipe(
setState$ = createEffect(() => this.actions$.pipe(
ofType(mapActions.SETSTATE),
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
switchMap(([action,inSearch]) => {
let a = action as mapActions.SetState;
return this.getActionFromQueryState(a.queryState,inSearch);
}));
})));
@Effect()
escape$:Observable<Action> = this.actions$.pipe(
escape$ = createEffect(() => this.actions$.pipe(
ofType(commonActions.ESCAPE),
switchMap((action) => {
let a = action as commonActions.Escape;
@ -384,7 +385,21 @@ export class MapEffects {
} else {
return EMPTY;
}
}));
})));
setOverride$ = createEffect(() => this.actions$.pipe(
ofType(ROUTER_NAVIGATED),
switchMap(() => this.store$.select(selectRouteData as any)),
switchMap((data: any) => {
if(data && data["fm-map-map"]) {
let params = data["fm-map-map"];
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
} else {
this.overrideSelectedItemLayer = false;
}
return [];
})
));
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) {
this._geojsonFormat = new GeoJSON();

View File

@ -33,12 +33,17 @@ export const initialQueryState: IQueryState = {
bbox: []
};
export interface IQuery {
querystate: IQueryState,
replace: boolean
}
export interface State {
period:IPeriodState,
mapState: IMapState,
viewExtent: number[],
queryState: IQueryState,
query:IQueryState,
query:IQuery,
parentCode: string,
features: Array<Feature>,
panelVisible: boolean,
@ -297,8 +302,14 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
case mapActions.DOQUERY: {
let a = action as mapActions.DoQuery;
return tassign(state, {
query: tassign(a.query, { bbox: a.query.bboxFilter ? state.viewExtent : [] })});
query: tassign(state.query,
{
querystate: tassign(a.query, { bbox: a.query.bboxFilter ? state.viewExtent : [] }),
replace:a.replace
})
})
}
case mapActions.ADDFEATURESUCCESS: {
let a = action as mapActions.AddFeatureSuccess;
let features = state.features.slice();
@ -507,6 +518,30 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
v.push(a.layervalue);
return tassign(state,{layerValues:v});
}
case commonActions.ITEMDELETEDEVENT:{
let a= action as commonActions.ItemDeletedEvent;
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
return tassign(state,{
selectedItem: null,
selectedItemLayer: null,
features:[]
});
}
if(state.features.length>0) {
var index = -1;
for (var i = 0; i < state.features.length; i++) {
if (state.features[i].getId() == a.itemCode ) {
index=i;
}
}
if(index>=0) {
let newFeatures = state.features.slice(0);
newFeatures.splice(index,1);
return tassign(state,{features:newFeatures});
}
}
return state;
}
default: {
return state;
}

View File

@ -7,6 +7,7 @@
transition: left 0.2s, top 0.2s;
background-color: white;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
pointer-events: all;
}
.side-panel.resizing {

View File

@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
import { Store, Action } from '@ngrx/store';
import { Effect, Actions,ofType } from '@ngrx/effects';
import { Observable , defer , of,from,zip } from 'rxjs';
import { Store } from '@ngrx/store';
import { Actions,ofType,createEffect } from '@ngrx/effects';
import { of,from,zip } from 'rxjs';
import { withLatestFrom,mergeMap,switchMap,map,catchError,first} from 'rxjs/operators';
import * as appCommonActions from '../actions/app-common.actions';
import * as appCommonReducers from '../reducers/app-common.reducer';
@ -12,43 +12,37 @@ import { FolderService } from '../services/folder.service';
import { UserService } from '../services/user.service';
import { IItemTypes } from '../models/item.types';
import { IListItem } from '../models/list.item';
import { IUser } from '../models/user';
import {IQueryState} from '../models/query.state';
import {StateSerializerService} from '../services/state-serializer.service';
@Injectable()
export class AppCommonEffects {
@Effect({ dispatch: false })
login$: Observable<Action> = this.actions$.pipe(
login$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.LOGIN),
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
mergeMap(([action, initialized]) => {
var a = (action as appCommonActions.Login);
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
return [];
}));
})),{dispatch:false});
@Effect({ dispatch: false })
logout$: Observable<Action> = this.actions$.pipe(
logout$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.LOGOUT),
mergeMap((action) => {
this.oauthService$.revokeTokenAndLogout();
return [];
}));
})),{dispatch:false});
@Effect()
loadItemTypes$: Observable<Action> = this.actions$.pipe(
loadItemTypes$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.LOADITEMTYPES),
switchMap((action) => {
return this.itemService$.getItemTypes().pipe(
map((itemTypes: IItemTypes) => new appCommonActions.LoadItemTypesSuccess(itemTypes)),
catchError(error => of(new appCommonActions.Fail(error))))
}
));
)));
@Effect()
initUser$: Observable<Action> = this.actions$.pipe(
initUser$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.INITUSER),
first(),
switchMap((action) => {
@ -56,11 +50,10 @@ export class AppCommonEffects {
switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
catchError(error => of(new appCommonActions.Fail(error))))
}
));
)));
@Effect()
initUserPackages$:Observable<Action> = this.actions$.pipe(
initUserPackages$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.INITUSERPACKAGES),
switchMap(() => {
return this.itemService$.getItemList('vnd.farmmaps.itemtype.package').pipe(
@ -68,10 +61,9 @@ export class AppCommonEffects {
catchError(error => of(new appCommonActions.Fail(error)))
)
})
);
));
@Effect()
userPackagesChanged$:Observable<Action> = this.actions$.pipe(
userPackagesChanged$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
@ -80,10 +72,9 @@ export class AppCommonEffects {
else
return [];
})
);
));
@Effect()
initUserSettingsRoot$:Observable<Action> = this.actions$.pipe(
initUserSettingsRoot$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.INITUSERSETTINGSROOT),
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
switchMap(([, user]) => {
@ -92,10 +83,9 @@ export class AppCommonEffects {
catchError(error => of(new appCommonActions.Fail(error)))
)
})
);
));
@Effect()
initUserSettingsRootChanged$:Observable<Action> = this.actions$.pipe(
initUserSettingsRootChanged$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.ITEMCHANGEDEVENT),
switchMap((action) => {
let a = action as appCommonActions.ItemChangedEvent;
@ -104,38 +94,34 @@ export class AppCommonEffects {
else
return [];
})
);
));
@Effect()
initUserSuccess$: Observable<Action> = this.actions$.pipe(
initUserSuccess$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.INITUSERSUCCESS),
switchMap(() => {
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages(),new appCommonActions.InitUserSettingsRoot()];
}
));
)));
@Effect()
initRoot$: Observable<Action> = this.actions$.pipe(
initRoot$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.INITROOT),
switchMap(() => {
return this.folderService$.getMyRoots().pipe(
map((folders: IListItem[]) => new appCommonActions.InitRootSuccess(folders)),
catchError(error => of(new appCommonActions.Fail(error))))
}
));
)));
@Effect()
deleteItems$: Observable<Action> = this.actions$.pipe(
deleteItems$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.DELETEITEMS),
switchMap((action:appCommonActions.DeleteItems) => {
return this.itemService$.deleteItems(action.itemCodes).pipe(
map((deletedItemCodes: string[]) => new appCommonActions.DeleteItemsSuccess(deletedItemCodes)),
catchError(error => of(new appCommonActions.Fail(error))))
}
));
)));
@Effect()
editItem$: Observable<Action> = this.actions$.pipe(
editItem$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.EDITITEM),
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
switchMap(([action, itemtypes]) => {
@ -148,10 +134,9 @@ export class AppCommonEffects {
this.router$.navigate(['/editor',editor,'item', a.item.code])
return [];
}
));
)));
@Effect()
viewItem$: Observable<Action> = this.actions$.pipe(
viewItem$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.VIEWITEM),
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
switchMap(([action, itemtypes]) => {
@ -181,20 +166,18 @@ export class AppCommonEffects {
}
return [];
}
));
)));
@Effect({ dispatch: false })
fail$: Observable<Action> = this.actions$.pipe(
fail$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.FAIL),
map((action) => {
let failAction = action as appCommonActions.Fail;
console.debug(failAction.payload)
return null;
}));
})),{dispatch:false});
@Effect({ dispatch: false })
online$: Observable<Action> = this.actions$.pipe(
online$ = createEffect(() => this.actions$.pipe(
ofType(appCommonActions.ONLINE),
switchMap((action) => {
console.debug("Online: Check token");
@ -206,7 +189,7 @@ export class AppCommonEffects {
}
}
return of(undefined);
}));
})),{dispatch:false});

View File

@ -13,7 +13,7 @@ import {AppRootComponent} from './app.component';
import {StoreModule, ActionReducer,MetaReducer} from '@ngrx/store';
import {EffectsModule, EffectSources} from '@ngrx/effects';
import { StoreRouterConnectingModule} from '@ngrx/router-store';
import { StoreRouterConnectingModule,routerReducer} from '@ngrx/router-store';
import {AppRoutingModule} from './app-routing.module';
import { LogoComponent } from './logo/logo.component';
@ -76,13 +76,14 @@ export const metaReducers: MetaReducer<any>[] = [debug];
AppCommonModule,
AppCommonServiceModule.forRoot(),
BrowserModule,
StoreModule.forRoot({},{metaReducers,runtimeChecks: { // TODO fix this should all be true
StoreModule.forRoot({router:routerReducer},{metaReducers,runtimeChecks: { // TODO fix this should all be true
strictStateImmutability: false,
strictActionImmutability: false,
strictStateSerializability: false,
strictActionSerializability: false
}}),
EffectsModule.forRoot([])
StoreRouterConnectingModule.forRoot({stateKey:"router"}),
EffectsModule.forRoot([]),
],
providers: [
AuthConfigFactory,