Compare commits
75 Commits
fbe0413c6a
...
2022.01
Author | SHA1 | Date | |
---|---|---|---|
|
b191751e02 | ||
66e492d2f8 | |||
e944064053 | |||
a1a4fc14ab | |||
122563a0bd | |||
33f322424e | |||
519b81d1fd | |||
b7c80dfdd8 | |||
d89670f669 | |||
d025e2e3f6 | |||
|
57407d83d3 | ||
|
f83549b5af | ||
|
132556da81 | ||
|
c2350eec52 | ||
|
c6d14e6c9c | ||
|
8e4364bd08 | ||
|
af3340ed70 | ||
|
ff19d830a7 | ||
|
29914cfb1b | ||
|
7bca0a57c4 | ||
|
fdba357e9c | ||
|
b5d00f5619 | ||
|
89a0fb13a5 | ||
|
2861ba220e | ||
|
45e0d5e836 | ||
|
312611cdc1 | ||
|
54b8a3bf24 | ||
4c1d4137ea | |||
a454f2306d | |||
|
52a72b042c | ||
|
c0c9864b07 | ||
|
e0f36b043f | ||
|
b52bfd4f57 | ||
|
6ff3c0ec96 | ||
|
eb1157d608 | ||
|
1daa8e257f | ||
|
5db24cc63d | ||
ff018d9db1 | |||
8c49965df8 | |||
|
f880623337 | ||
|
2da4f88683 | ||
|
bd125b6f72 | ||
|
610408d17c | ||
|
52e3117771 | ||
|
1b000c6112 | ||
|
28e75d5a0d | ||
|
76c431b9c2 | ||
|
122c49d516 | ||
|
5c549c5851 | ||
|
3fcf80c1a0 | ||
|
519e5c9032 | ||
9c19595597 | |||
ea1b22ed41 | |||
8d3c098f4e | |||
22209cfaf6 | |||
8b45e431a7 | |||
74c792b96a | |||
d833f321d1 | |||
0d9789d8c6 | |||
93513f9dc7 | |||
|
e465142be0 | ||
|
92173c9847 | ||
|
05292f1e5d | ||
|
e672e28795 | ||
|
4b7b639046 | ||
|
34b067fd28 | ||
|
fb9a046ff8 | ||
|
c4934d799d | ||
469bc6f1c1 | |||
d140d4bd4c | |||
1ce259a152 | |||
00ae86ecf2 | |||
880eb26a99 | |||
bcfa13de60 | |||
|
6f77df0f61 |
54
Jenkinsfile
vendored
Normal file
54
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
environment {
|
||||||
|
PACKAGE_VERSION_PREFIX=sh(script: 'jq .version package.json |sed "s/\\"//g"', returnStdout: true).trim()
|
||||||
|
PACKAGE_VERSION="${PACKAGE_VERSION_PREFIX}"
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('npm install'){
|
||||||
|
steps {
|
||||||
|
sh '''rm -rf node_modules/
|
||||||
|
npm install --legacy-peer-deps
|
||||||
|
cd projects/common
|
||||||
|
npm install --legacy-peer-deps
|
||||||
|
cd ../common-map
|
||||||
|
npm install --legacy-peer-deps
|
||||||
|
cd ../common-map3d
|
||||||
|
npm install --legacy-peer-deps
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('build'){
|
||||||
|
steps {
|
||||||
|
sh '''ng build common
|
||||||
|
ng build common-map
|
||||||
|
ng build common-map3d'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('npm publish'){
|
||||||
|
steps {
|
||||||
|
sh '''cd dist/common
|
||||||
|
npm version ${PACKAGE_VERSION} --allow-same-version
|
||||||
|
npm publish
|
||||||
|
cd ../common-map
|
||||||
|
npm version ${PACKAGE_VERSION} --allow-same-version
|
||||||
|
npm publish
|
||||||
|
cd ../common-map3d
|
||||||
|
npm version ${PACKAGE_VERSION} --allow-same-version
|
||||||
|
npm publish'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
emailext (
|
||||||
|
body: '${DEFAULT_CONTENT}',
|
||||||
|
mimeType: 'text/html',
|
||||||
|
replyTo: '${DEFAULT_REPLYTO}',
|
||||||
|
subject: '${DEFAULT_SUBJECT}',
|
||||||
|
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -169,7 +169,7 @@
|
|||||||
"prefix": "fm",
|
"prefix": "fm",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
"builder": "@angular-devkit/build-angular:ng-packagr",
|
||||||
"options": {
|
"options": {
|
||||||
"tsConfig": "projects/common/tsconfig.lib.json",
|
"tsConfig": "projects/common/tsconfig.lib.json",
|
||||||
"project": "projects/common/ng-package.json"
|
"project": "projects/common/ng-package.json"
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
"prefix": "fm-map",
|
"prefix": "fm-map",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-ng-packagr:build",
|
"builder": "@angular-devkit/build-angular:ng-packagr",
|
||||||
"options": {
|
"options": {
|
||||||
"tsConfig": "projects/common-map/tsconfig.lib.json",
|
"tsConfig": "projects/common-map/tsconfig.lib.json",
|
||||||
"project": "projects/common-map/ng-package.json"
|
"project": "projects/common-map/ng-package.json"
|
||||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 73 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -47,6 +47,12 @@
|
|||||||
content: "h";
|
content: "h";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fm-blight-holes:before {
|
||||||
|
content: "i";
|
||||||
|
}
|
||||||
|
|
||||||
|
hallo
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "FarmMaps";
|
font-family: "FarmMaps";
|
||||||
src: url("./FMIconFont.woff") format("woff"), /* Modern Browsers */
|
src: url("./FMIconFont.woff") format("woff"), /* Modern Browsers */
|
||||||
|
8899
package-lock.json
generated
8899
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
75
package.json
75
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farmmaps-lib-app",
|
"name": "farmmaps-lib-app",
|
||||||
"version": "0.0.1",
|
"version": "1.1.13",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
@@ -11,63 +11,62 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "~10.2.4",
|
"@angular/animations": "~11.2.14",
|
||||||
"@angular/common": "~10.2.4",
|
"@angular/common": "~11.2.14",
|
||||||
"@angular/compiler": "~10.2.4",
|
"@angular/compiler": "~11.2.14",
|
||||||
"@angular/core": "~10.2.4",
|
"@angular/core": "~11.2.14",
|
||||||
"@angular/forms": "~10.2.4",
|
"@angular/forms": "~11.2.14",
|
||||||
"@angular/platform-browser": "~10.2.4",
|
"@angular/platform-browser": "~11.2.14",
|
||||||
"@angular/platform-browser-dynamic": "~10.2.4",
|
"@angular/platform-browser-dynamic": "~11.2.14",
|
||||||
"@angular/router": "~10.2.4",
|
"@angular/router": "~11.2.14",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.575 <0.0.1",
|
"@farmmaps/common": "1.1.12",
|
||||||
"@farmmaps/common-map": ">=0.0.1-prerelease.575 <0.0.1",
|
"@farmmaps/common-map": "1.1.12",
|
||||||
"@farmmaps/common-map3d": ">=0.0.1-prerelease.575 <0.0.1",
|
"@farmmaps/common-map3d": "1.1.12",
|
||||||
"@microsoft/signalr": "^3.1.3",
|
"@microsoft/signalr": "^3.1.16",
|
||||||
"@ng-bootstrap/ng-bootstrap": "^7.0",
|
"@ng-bootstrap/ng-bootstrap": "^9.0",
|
||||||
"@ngrx/effects": "^10.0",
|
"@ngrx/effects": "^11.0",
|
||||||
"@ngrx/router-store": "^10.0",
|
"@ngrx/router-store": "^11.0",
|
||||||
"@ngrx/store": "^10.0",
|
"@ngrx/store": "^11.0",
|
||||||
"angular-oauth2-oidc": "^10.0.3",
|
"angular-oauth2-oidc": "^10.0.3",
|
||||||
"bootstrap": "^4.4.1",
|
"bootstrap": "^4.6.0",
|
||||||
"cesium": "^1.77.0",
|
"cesium": "^1.82.1",
|
||||||
"core-js": "^2.6.11",
|
"core-js": "^2.6.12",
|
||||||
"moment": "^2.27.0",
|
"moment": "^2.29.1",
|
||||||
"ngrx-store-localstorage": "^10.0",
|
"ngrx-store-localstorage": "^11.0.0",
|
||||||
"ngx-avatar": "^4.0.0",
|
"ngx-avatar": "^4.1.0",
|
||||||
"ngx-clipboard": "^14.0.1",
|
"ngx-clipboard": "^14.0.1",
|
||||||
"ngx-image-cropper": "^3.3.5",
|
"ngx-image-cropper": "^3.3.5",
|
||||||
"ngx-openlayers": "1.0.0-next.17",
|
"ngx-openlayers": "1.0.0-next.17",
|
||||||
"ngx-uploadx": "^3.5.1",
|
"ngx-uploadx": "^3.5.1",
|
||||||
"ol": "6.5.0",
|
"ol": "6.5.0",
|
||||||
"ol-cesium": "^2.12.0",
|
"ol-cesium": "^2.13.0",
|
||||||
"resumablejs": "^1.1.0",
|
"resumablejs": "^1.1.0",
|
||||||
"rxjs": "^6.5.4",
|
"rxjs": "^6.6.7",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.2.0",
|
||||||
"zone.js": "~0.10.2"
|
"zone.js": "~0.10.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/custom-webpack": "~10.0.1",
|
"@angular-builders/custom-webpack": "^11.1.1",
|
||||||
"@angular-devkit/build-angular": "^0.1002.1",
|
"@angular-devkit/build-angular": "^0.1102.14",
|
||||||
"@angular-devkit/build-ng-packagr": "~0.1002.1",
|
"@angular/cli": "^11.2.14",
|
||||||
"@angular/cli": "^10.2.1",
|
"@angular/compiler-cli": "~11.2.14",
|
||||||
"@angular/compiler-cli": "~10.2.4",
|
"@angular/language-service": "~11.2.14",
|
||||||
"@angular/language-service": "~10.2.4",
|
|
||||||
"@types/jasmine": "~2.8.8",
|
"@types/jasmine": "~2.8.8",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "^2.0.9",
|
||||||
"@types/node": "^12.11.1",
|
"@types/node": "^12.20.15",
|
||||||
"codelyzer": "^5.1.2",
|
"codelyzer": "^5.1.2",
|
||||||
"jasmine-core": "~3.5.0",
|
"jasmine-core": "~3.5.0",
|
||||||
"jasmine-spec-reporter": "~5.0.0",
|
"jasmine-spec-reporter": "~5.0.0",
|
||||||
"karma": "~5.0.0",
|
"karma": "~6.3.3",
|
||||||
"karma-chrome-launcher": "~3.1.0",
|
"karma-chrome-launcher": "~3.1.0",
|
||||||
"karma-coverage-istanbul-reporter": "~3.0.2",
|
"karma-coverage-istanbul-reporter": "~3.0.2",
|
||||||
"karma-jasmine": "~4.0.0",
|
"karma-jasmine": "~4.0.0",
|
||||||
"karma-jasmine-html-reporter": "^1.5.0",
|
"karma-jasmine-html-reporter": "^1.6.0",
|
||||||
"ng-packagr": "^10.1.0",
|
"ng-packagr": "^11.2.4",
|
||||||
"protractor": "~7.0.0",
|
"protractor": "~7.0.0",
|
||||||
"ts-node": "^8.8.1",
|
"ts-node": "^8.8.1",
|
||||||
"tslint": "~6.1.0",
|
"tslint": "~6.1.0",
|
||||||
"typescript": "~4.0.3"
|
"typescript": "~4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common-map",
|
"name": "@farmmaps/common-map",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"@ngrx/router-store": "^10.0",
|
"@ngrx/router-store": "^10.0",
|
||||||
"@ngrx/store": "^10.0",
|
"@ngrx/store": "^10.0",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.508 <0.0.1",
|
"@farmmaps/common": "~1.0",
|
||||||
"ngx-openlayers": "1.0.0-next.17",
|
"ngx-openlayers": "1.0.0-next.17",
|
||||||
"ol": "6.4.3"
|
"ol": "6.4.3"
|
||||||
}
|
}
|
||||||
|
@@ -6,12 +6,14 @@ import { ILayervalue } from '../models/layer.value';
|
|||||||
import { IQueryState } from '@farmmaps/common';
|
import { IQueryState } from '@farmmaps/common';
|
||||||
import { IItem } from '@farmmaps/common';
|
import { IItem } from '@farmmaps/common';
|
||||||
import { Feature,Style } from 'ol';
|
import { Feature,Style } from 'ol';
|
||||||
|
import { IPeriodState } from '../models/period.state';
|
||||||
|
|
||||||
export const SETSTATE = '[Map] SetState';
|
export const SETSTATE = '[Map] SetState';
|
||||||
export const SETMAPSTATE = '[Map] MapState';
|
export const SETMAPSTATE = '[Map] MapState';
|
||||||
export const SETVIEWEXTENT = '[Map] SetViewExtent';
|
export const SETVIEWEXTENT = '[Map] SetViewExtent';
|
||||||
export const INIT = '[Map] Init';
|
export const INIT = '[Map] Init';
|
||||||
export const SETPARENT = '[Map] SetParent';
|
export const SETPARENT = '[Map] SetParent';
|
||||||
|
export const SETPERIOD = '[Map] SetPeriod';
|
||||||
export const STARTSEARCH = '[Map] StartSearch';
|
export const STARTSEARCH = '[Map] StartSearch';
|
||||||
export const STARTSEARCHSUCCESS = '[Map] StartSearchSuccess';
|
export const STARTSEARCHSUCCESS = '[Map] StartSearchSuccess';
|
||||||
export const SELECTFEATURE = '[Map] SelectFeature';
|
export const SELECTFEATURE = '[Map] SelectFeature';
|
||||||
@@ -86,6 +88,12 @@ export class SetParent implements Action {
|
|||||||
constructor(public parentCode:string) { }
|
constructor(public parentCode:string) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class SetPeriod implements Action {
|
||||||
|
readonly type = SETPERIOD;
|
||||||
|
|
||||||
|
constructor(public period:IPeriodState) { }
|
||||||
|
}
|
||||||
|
|
||||||
export class StartSearch implements Action {
|
export class StartSearch implements Action {
|
||||||
readonly type = STARTSEARCH;
|
readonly type = STARTSEARCH;
|
||||||
|
|
||||||
@@ -257,7 +265,7 @@ export class ZoomToExtent implements Action {
|
|||||||
export class DoQuery implements Action {
|
export class DoQuery implements Action {
|
||||||
readonly type = DOQUERY;
|
readonly type = DOQUERY;
|
||||||
|
|
||||||
constructor(public query:IQueryState) { }
|
constructor(public query:IQueryState,public replace:boolean = false) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SetStyle implements Action {
|
export class SetStyle implements Action {
|
||||||
@@ -348,5 +356,6 @@ export type Actions = SetMapState
|
|||||||
| SetLayerValuesLocation
|
| SetLayerValuesLocation
|
||||||
| ToggleLayerValuesEnabled
|
| ToggleLayerValuesEnabled
|
||||||
| GetLayerValueSuccess
|
| GetLayerValueSuccess
|
||||||
| GetLayerValue;
|
| GetLayerValue
|
||||||
|
| SetPeriod;
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ import * as mapEffects from './effects/map.effects';
|
|||||||
import { IMapState} from './models/map.state';
|
import { IMapState} from './models/map.state';
|
||||||
import { ISelectedFeatures } from './models/selected.features';
|
import { ISelectedFeatures } from './models/selected.features';
|
||||||
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer } from './models/item.layer';
|
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer } from './models/item.layer';
|
||||||
|
import { IClickedFeature } from './models/clicked.feature';
|
||||||
import { IPeriodState } from './models/period.state';
|
import { IPeriodState } from './models/period.state';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
@@ -82,9 +83,17 @@ export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any
|
|||||||
if(ms) {
|
if(ms) {
|
||||||
r2["mapState"] = JSON.parse(ms);
|
r2["mapState"] = JSON.parse(ms);
|
||||||
}
|
}
|
||||||
|
let sp = window.localStorage.getItem(MODULE_NAME+"_searchPeriod");
|
||||||
|
if(sp) {
|
||||||
|
let p = JSON.parse(sp);
|
||||||
|
r2["period"] = { startDate: new Date(Date.parse(p.startDate)),endDate:new Date(Date.parse(p.endDate))};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(action.type == "[Map] MapState" || action.type == "[Map] SetState") {
|
if(action.type == "[Map] MapState" || action.type == "[Map] SetState") {
|
||||||
window.localStorage.setItem(MODULE_NAME + "_mapState",JSON.stringify(r2["mapState"]));
|
window.localStorage.setItem(MODULE_NAME + "_mapState",JSON.stringify(r2["mapState"]));
|
||||||
|
}
|
||||||
|
if(action.type == "[Map] SetPeriod" ) {
|
||||||
|
window.localStorage.setItem(MODULE_NAME + "_searchPeriod",JSON.stringify(r2["period"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r2;
|
return r2;
|
||||||
@@ -155,7 +164,9 @@ export {
|
|||||||
ITemporalItemLayer,
|
ITemporalItemLayer,
|
||||||
TemporalItemLayer,
|
TemporalItemLayer,
|
||||||
ifZoomToShowDirective,
|
ifZoomToShowDirective,
|
||||||
ZoomToShowAlert
|
ZoomToShowAlert,
|
||||||
|
IClickedFeature,
|
||||||
|
GeometryThumbnailComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -265,7 +276,8 @@ export {
|
|||||||
FeatureListFeatureContainerComponent,
|
FeatureListFeatureContainerComponent,
|
||||||
ZoomToExtentComponent,
|
ZoomToExtentComponent,
|
||||||
ifZoomToShowDirective,
|
ifZoomToShowDirective,
|
||||||
ZoomToShowAlert
|
ZoomToShowAlert,
|
||||||
|
GeometryThumbnailComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
FeatureIconService,
|
FeatureIconService,
|
||||||
@@ -288,5 +300,5 @@ export {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
export class AppCommonMapModule {
|
export class AppCommonMapModule {
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ export class GpsLocation implements OnInit,OnChanges{
|
|||||||
|
|
||||||
@Input() enable:boolean;
|
@Input() enable:boolean;
|
||||||
public instance: Overlay;
|
public instance: Overlay;
|
||||||
@Input() position: Position;
|
@Input() position: GeolocationPosition;
|
||||||
@Input() location: number[]=[0,0];
|
@Input() location: number[]=[0,0];
|
||||||
@Input() locationTolerance: number = 0;
|
@Input() locationTolerance: number = 0;
|
||||||
@Input() showHeading: boolean = false;
|
@Input() showHeading: boolean = false;
|
||||||
@@ -61,7 +61,7 @@ export class GpsLocation implements OnInit,OnChanges{
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes.position && this.instance) {
|
if (changes.position && this.instance) {
|
||||||
var p = changes.position.currentValue as Position;
|
var p = changes.position.currentValue as GeolocationPosition;
|
||||||
if(p && this.initialized) {
|
if(p && this.initialized) {
|
||||||
this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude]));
|
this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude]));
|
||||||
this.locationTolerance = p.coords.accuracy;
|
this.locationTolerance = p.coords.accuracy;
|
||||||
|
@@ -112,17 +112,18 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
this.host.instance.setSource(this.instance);
|
this.host.instance.setSource(this.instance);
|
||||||
|
|
||||||
this.host.instance.setStyle((feature) => {
|
this.host.instance.setStyle((feature) => {
|
||||||
var key = feature.get('itemType') + (this.selectedItem?"_I":"");
|
var itemType = feature.get('itemType');
|
||||||
|
var key = itemType + (this.selectedItem?"_I":"");
|
||||||
if (!this.stylesCache[key]) {
|
if (!this.stylesCache[key]) {
|
||||||
if (this.itemTypeService.itemTypes[key]) {
|
if (this.itemTypeService.itemTypes[itemType]) {
|
||||||
let itemType = this.itemTypeService.itemTypes[key];
|
let itemTypeEntry = this.itemTypeService.itemTypes[itemType];
|
||||||
let fillColor = color.asArray(itemType.iconColor);
|
let fillColor = color.asArray(itemTypeEntry.iconColor);
|
||||||
fillColor[3] = 0;
|
fillColor[3] = 0;
|
||||||
this.stylesCache[key] = new style.Style({
|
this.stylesCache[key] = new style.Style({
|
||||||
image: itemType.icon ? new style.Icon({
|
image: itemTypeEntry.icon ? new style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
scale: 0.05,
|
scale: 0.05,
|
||||||
src: this.featureIconService$.getIconImageDataUrl(itemType.icon)
|
src: this.featureIconService$.getIconImageDataUrl(itemTypeEntry.icon)
|
||||||
}):null,
|
}):null,
|
||||||
stroke: new style.Stroke({
|
stroke: new style.Stroke({
|
||||||
color: 'red',
|
color: 'red',
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div *ngIf="itemLayer.legendVisible">
|
<div *ngIf="itemLayer.legendVisible">
|
||||||
<div class="card legend">
|
<div class="card legend">
|
||||||
<fm-map-layer-legend [layer]="firstLayer(itemLayer)" (click)="handleLegendClick($event,itemLayer);"></fm-map-layer-legend>
|
<fm-map-layer-legend [layer]="firstLayer(itemLayer)" (click)="handleLegendClick($event,itemLayer);" [histogramenabled]="true"></fm-map-layer-legend>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||||
<div>{{layerValue.layerName}}</div>
|
<div>{{layerValue.layerName}}</div>
|
||||||
<div>{{layerValue.date|date}}</div>
|
<div>{{layerValue.date|date}}</div>
|
||||||
<div><span class="mr-1">{{layerValue.quantity}}</span> <span class="mr-1 font-weight-bold">{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
<div><span *ngIf="layerValue.quantity"><span class="mr-1">{{layerValue.quantity}}</span> </span><span class="mr-1 font-weight-bold">{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ng-template #no_data>
|
<ng-template #no_data>
|
||||||
|
@@ -14,7 +14,7 @@ export class PanToLocation implements OnInit,OnChanges{
|
|||||||
|
|
||||||
view: View;
|
view: View;
|
||||||
map: MapComponent;
|
map: MapComponent;
|
||||||
@Input() position: Position;
|
@Input() position: GeolocationPosition;
|
||||||
@Input() mapState: IMapState;
|
@Input() mapState: IMapState;
|
||||||
@Input() animate: boolean;
|
@Input() animate: boolean;
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { Component, Host, Input, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core';
|
import { Component, Host, Input, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { ViewComponent, MapComponent } from 'ngx-openlayers';
|
import { ViewComponent, MapComponent } from 'ngx-openlayers';
|
||||||
|
|
||||||
|
|
||||||
@@ -9,12 +10,24 @@ import { ViewComponent, MapComponent } from 'ngx-openlayers';
|
|||||||
export class ZoomToExtentComponent implements OnChanges {
|
export class ZoomToExtentComponent implements OnChanges {
|
||||||
view: ViewComponent;
|
view: ViewComponent;
|
||||||
map: MapComponent;
|
map: MapComponent;
|
||||||
|
paddingTop: number = 0;
|
||||||
|
paddingLeft: number = 0;
|
||||||
|
paddingBottom: number = 0;
|
||||||
|
paddingRight: number = 0;
|
||||||
|
|
||||||
@Input() extent: number[];
|
@Input() extent: number[];
|
||||||
@Input() animate: boolean = false;
|
@Input() animate: boolean = false;
|
||||||
|
|
||||||
constructor(@Host() view: ViewComponent, @Host() map: MapComponent) {
|
constructor(@Host() view: ViewComponent, @Host() map: MapComponent,route: ActivatedRoute ) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.map = map;
|
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) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
@@ -31,7 +44,7 @@ export class ZoomToExtentComponent implements OnChanges {
|
|||||||
bottom = 5 * rem;
|
bottom = 5 * rem;
|
||||||
left = 23 * 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;
|
if (this.animate) options["duration"] = 1000;
|
||||||
this.view.instance.fit(this.extent, options);
|
this.view.instance.fit(this.extent, options);
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ export class FeatureListContainerComponent {
|
|||||||
let criteria=0;
|
let criteria=0;
|
||||||
if (this.featureLists[i]['forItemType']) {
|
if (this.featureLists[i]['forItemType']) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if( this.featureLists[i]['forItemType'].indexOf(queryState.itemType) >= 0) {
|
if( this.featureLists[i]['forItemType'].split(",").filter(part => part == queryState.itemType).length == 1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ export class FeatureListFeatureContainerComponent {
|
|||||||
let criteria=0;
|
let criteria=0;
|
||||||
if (this.featureLists[i]['forItemType']) {
|
if (this.featureLists[i]['forItemType']) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if(this.featureLists[i]['forItemType'].indexOf(this.feature.get("itemType")) >= 0) {
|
if(this.featureLists[i]['forItemType'].split(",").filter(part => part == this.feature.get("itemType")).length == 1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnInit,ViewChild } from '@angular/core';
|
import { Component, Input, AfterViewInit, ViewChild } from '@angular/core';
|
||||||
import { Feature} from 'ol';
|
import { Feature} from 'ol';
|
||||||
import { Geometry } from 'ol/geom';
|
import { Geometry } from 'ol/geom';
|
||||||
import * as extent from 'ol/extent';
|
import * as extent from 'ol/extent';
|
||||||
@@ -10,51 +10,86 @@ import * as style from 'ol/style';
|
|||||||
templateUrl: './feature-thumbnail.component.html',
|
templateUrl: './feature-thumbnail.component.html',
|
||||||
styleUrls: ['./feature-thumbnail.component.scss']
|
styleUrls: ['./feature-thumbnail.component.scss']
|
||||||
})
|
})
|
||||||
export class GeometryThumbnailComponent implements OnInit {
|
export class GeometryThumbnailComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
@ViewChild('canvas') canvas;
|
@ViewChild('canvas') canvas;
|
||||||
@ViewChild('container') container;
|
@ViewChild('container') container;
|
||||||
@Input('feature') feature:Feature;
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
private geometry:Geometry = null;
|
||||||
|
@Input() set feature(value:Feature) {
|
||||||
|
if(value) {
|
||||||
|
this.geometry = value.getGeometry();
|
||||||
|
} else {
|
||||||
|
this.geometry = null;
|
||||||
|
}
|
||||||
|
this.render(this.canvas,
|
||||||
|
this.geometryStyle,
|
||||||
|
this.geometry,
|
||||||
|
this.width,
|
||||||
|
this.height);
|
||||||
|
};
|
||||||
|
|
||||||
|
private defaultStyle:style.Style = new style.Style({
|
||||||
|
stroke: new style.Stroke({ color: 'black',width:1.5 })
|
||||||
|
});
|
||||||
|
private geometryStyle:style.Style = this.defaultStyle;
|
||||||
|
@Input() set fillColor(value:string) {
|
||||||
|
if(style) {
|
||||||
|
this.geometryStyle = new style.Style({
|
||||||
|
stroke: new style.Stroke({ color: 'black',width:1.5 }),
|
||||||
|
fill: new style.Fill({color: value})
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.geometryStyle = this.defaultStyle
|
||||||
|
}
|
||||||
|
this.render(this.canvas,
|
||||||
|
this.geometryStyle,
|
||||||
|
this.geometry,
|
||||||
|
this.width,
|
||||||
|
this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
render(canvas,width,height,geometry:Geometry) {
|
private width:number = 0;
|
||||||
let renderContext = render.toContext(canvas.getContext( '2d'),{ size: [width, height] });
|
private height:number = 0;
|
||||||
|
|
||||||
let strokeStyle = new style.Style({
|
|
||||||
stroke: new style.Stroke({ color: 'black',width:1.5 })
|
|
||||||
});
|
|
||||||
|
|
||||||
let geom = geometry.clone(),
|
render(canvas,style:style.Style,geometry:Geometry,width:number,height:number) {
|
||||||
line = geom.getCoordinates()[0],
|
if(canvas && canvas.nativeElement && geometry && style) {
|
||||||
e = extent.boundingExtent( line );
|
let renderContext = render.toContext(canvas.nativeElement.getContext( '2d'),{ size: [width, height] });
|
||||||
|
|
||||||
let dxy = extent.getCenter(e),
|
let geom = geometry.clone(),
|
||||||
sxy = [
|
line = geom.getCoordinates()[0],
|
||||||
(width - 2 ) / extent.getWidth(e),
|
e = extent.boundingExtent( line );
|
||||||
(height - 2 ) / extent.getHeight(e)
|
|
||||||
];
|
let dxy = extent.getCenter(e),
|
||||||
|
sxy = [
|
||||||
let dx = dxy[0],
|
(width - 2 ) / extent.getWidth(e),
|
||||||
dy = dxy[1],
|
(height - 2 ) / extent.getHeight(e)
|
||||||
sx = sxy[0],
|
];
|
||||||
sy = sxy[1];
|
|
||||||
|
let dx = dxy[0],
|
||||||
geom.translate( -dx, -dy );
|
dy = dxy[1],
|
||||||
geom.scale( Math.min(sx, sy), -Math.min(sx, sy));
|
sx = sxy[0],
|
||||||
geom.translate( width / 2, height / 2 );
|
sy = sxy[1];
|
||||||
|
|
||||||
renderContext.setStyle( strokeStyle );
|
geom.translate( -dx, -dy );
|
||||||
renderContext.drawGeometry( geom );
|
geom.scale( Math.min(sx, sy), -Math.min(sx, sy));
|
||||||
|
geom.translate(width / 2,height / 2 );
|
||||||
|
renderContext.setStyle( style );
|
||||||
|
renderContext.drawGeometry( geom );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.render(this.canvas.nativeElement,
|
this.width = this.container.nativeElement.offsetWidth;
|
||||||
this.container.nativeElement.offsetWidth,
|
this.height = this.container.nativeElement.offsetHeight;
|
||||||
this.container.nativeElement.offsetHeight,
|
this.render(this.canvas,
|
||||||
this.feature.getGeometry());
|
this.geometryStyle,
|
||||||
|
this.geometry,
|
||||||
|
this.width,
|
||||||
|
this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -33,13 +33,13 @@ export class ItemListItemContainerComponent {
|
|||||||
let criteria=0;
|
let criteria=0;
|
||||||
if (this.itemComponentList[i]['forItemType']) {
|
if (this.itemComponentList[i]['forItemType']) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if(this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0) {
|
if(this.itemComponentList[i]['forItemType'].split(",").filter(part => part ==this.item.itemType).length == 1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.itemComponentList[i]['forSourceTask']) {
|
if (this.itemComponentList[i]['forSourceTask']) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if(this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
|
if(this.itemComponentList[i]['forSourceTask'].split(",").filter(part => part ==this.item.sourceTask).length ==1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
<div *ngIf="showHistogram()">
|
<div *ngIf="showHistogram()">
|
||||||
<span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)">
|
<span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)">
|
||||||
</span>
|
</span>
|
||||||
<span class="bar-label">{{getLabel(layer.renderer,i)}}</span>
|
<span *ngIf="getPercentage(layer.renderer,i) as percentage" class="bar-label">{{percentage | number:'1.0-2'}} %</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -78,10 +78,10 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLabel(renderer: IRenderer, index: number): string {
|
public getPercentage(renderer: IRenderer, index: number): number {
|
||||||
let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
|
let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
|
||||||
let percent = renderer.band.histogram.entries[index].freqency * scale;
|
let percent = renderer.band.histogram.entries[index].freqency * scale;
|
||||||
return percent < 0.1 ? "" : percent.toFixed(1) + " %";
|
return percent < 0.1 ? null : percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
showLegend(): boolean {
|
showLegend(): boolean {
|
||||||
@@ -89,12 +89,10 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showHistogram(): boolean {
|
showHistogram(): boolean {
|
||||||
return this.histogramenabled && this.layer.renderer.band.histogram.entries && this.layer.renderer.band.histogram.entries.length > 0 && this.layer.renderer.colorMap.colormapType == "minmax";
|
return this.histogramenabled && this.layer.renderer.band.histogram.entries && this.layer.renderer.band.histogram.entries.length > 0 && this.layer.renderer.band.histogram.entries.length == this.layer.renderer.colorMap.entries.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
bandContainsStatistics(): boolean {
|
bandContainsStatistics(): boolean {
|
||||||
return this.layer.renderer.band.statistics != null;
|
return this.layer.renderer.band.statistics != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@@ -33,4 +33,4 @@
|
|||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<fm-map-select-period-modal [modalState]="openedModalName" (onCloseModal)="handleCloseModal()" (onSelect)="handleSelectPeriod($event)" [startDate]="startDate" [endDate]="endDate"></fm-map-select-period-modal>
|
<fm-map-select-period-modal [modalState]="openedModalName" (onCloseModal)="handleCloseModal()" (onSelect)="handleSelectPeriod($event)" [startDate]="periodLocal.startDate" [endDate]="periodLocal.endDate"></fm-map-select-period-modal>
|
||||||
|
@@ -22,7 +22,10 @@ export class MapSearchComponent {
|
|||||||
@Input() set searchMinified(minified: boolean) {
|
@Input() set searchMinified(minified: boolean) {
|
||||||
this.searchMinifiedLocal = minified;
|
this.searchMinifiedLocal = minified;
|
||||||
}
|
}
|
||||||
@Input() period: IPeriodState
|
@Input() set period(period:IPeriodState) {
|
||||||
|
this.periodLocal = tassign(this.periodLocal,{startDate: period.startDate,endDate:period.endDate});
|
||||||
|
this.startEndCaption = this.timespanService.getCaption(period.startDate, period.endDate, 4)
|
||||||
|
}
|
||||||
@Output() onSearch = new EventEmitter<IQueryState>();
|
@Output() onSearch = new EventEmitter<IQueryState>();
|
||||||
@Output() onClear = new EventEmitter<any>();
|
@Output() onClear = new EventEmitter<any>();
|
||||||
@Output() onSearchCollapse = new EventEmitter<any>();
|
@Output() onSearchCollapse = new EventEmitter<any>();
|
||||||
@@ -30,6 +33,7 @@ export class MapSearchComponent {
|
|||||||
@Output() onToggleMenu = new EventEmitter<any>();
|
@Output() onToggleMenu = new EventEmitter<any>();
|
||||||
@Output() onOpenModal = new EventEmitter<string>();
|
@Output() onOpenModal = new EventEmitter<string>();
|
||||||
@Output() onCloseModal = new EventEmitter<any>();
|
@Output() onCloseModal = new EventEmitter<any>();
|
||||||
|
@Output() onPeriodChange = new EventEmitter<IPeriodState>();
|
||||||
@Input() openedModalName: string;
|
@Input() openedModalName: string;
|
||||||
@Input() set filterOptions(filterOptions: IQueryState) {
|
@Input() set filterOptions(filterOptions: IQueryState) {
|
||||||
if (filterOptions && filterOptions.query && filterOptions.query.length > 0) {
|
if (filterOptions && filterOptions.query && filterOptions.query.length > 0) {
|
||||||
@@ -42,23 +46,18 @@ export class MapSearchComponent {
|
|||||||
this.searchTextLocal = { name: filterOptions.tags };
|
this.searchTextLocal = { name: filterOptions.tags };
|
||||||
} else {
|
} else {
|
||||||
this.searchTextLocal = { name: filterOptions.query };
|
this.searchTextLocal = { name: filterOptions.query };
|
||||||
}
|
}
|
||||||
if (this.dateFilter) {
|
|
||||||
this.filterOptionsLocal.startDate = this.startDate;
|
|
||||||
this.filterOptionsLocal.endDate = this.endDate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public collapsedLocal: boolean = true;
|
public collapsedLocal: boolean = true;
|
||||||
public searchMinifiedLocal: boolean = false;
|
public searchMinifiedLocal: boolean = false;
|
||||||
|
public periodLocal: IPeriodState = { startDate:new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1), endDate:new Date(Date.now())};
|
||||||
public filterOptionsLocal: IQueryState;
|
public filterOptionsLocal: IQueryState;
|
||||||
private extent: number[];
|
private extent: number[];
|
||||||
public searchTextLocal: any;
|
public searchTextLocal: any;
|
||||||
public searchTextLocalOutput: string;
|
public searchTextLocalOutput: string;
|
||||||
public dateFilter: boolean = true;
|
public dateFilter: boolean = true;
|
||||||
public startDate: Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1);
|
public startEndCaption: string = this.timespanService.getCaption(this.periodLocal.startDate, this.periodLocal.endDate, 4);
|
||||||
public endDate: Date = new Date(Date.now());
|
|
||||||
public startEndCaption: string = this.timespanService.getCaption(this.startDate, this.endDate, 4);
|
|
||||||
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchFailed = false;
|
searchFailed = false;
|
||||||
@@ -94,8 +93,8 @@ export class MapSearchComponent {
|
|||||||
this.filterOptionsLocal.parentCode = null;
|
this.filterOptionsLocal.parentCode = null;
|
||||||
this.filterOptionsLocal.query = this.searchTextLocalOutput;
|
this.filterOptionsLocal.query = this.searchTextLocalOutput;
|
||||||
if (this.dateFilter) {
|
if (this.dateFilter) {
|
||||||
this.filterOptionsLocal.startDate = this.startDate;
|
this.filterOptionsLocal.startDate = this.periodLocal.startDate;
|
||||||
this.filterOptionsLocal.endDate = this.endDate;
|
this.filterOptionsLocal.endDate = this.periodLocal.endDate;
|
||||||
}
|
}
|
||||||
this.onSearch.emit(this.filterOptionsLocal);
|
this.onSearch.emit(this.filterOptionsLocal);
|
||||||
}
|
}
|
||||||
@@ -117,26 +116,30 @@ export class MapSearchComponent {
|
|||||||
this.filterOptionsLocal.parentCode = null;
|
this.filterOptionsLocal.parentCode = null;
|
||||||
this.filterOptionsLocal.tags = event.item.name;
|
this.filterOptionsLocal.tags = event.item.name;
|
||||||
if (this.dateFilter) {
|
if (this.dateFilter) {
|
||||||
this.filterOptionsLocal.startDate = this.startDate;
|
this.filterOptionsLocal.startDate = this.periodLocal.startDate;
|
||||||
this.filterOptionsLocal.endDate = this.endDate;
|
this.filterOptionsLocal.endDate = this.periodLocal.endDate;
|
||||||
}
|
}
|
||||||
this.onSearch.emit(this.filterOptionsLocal);
|
this.onSearch.emit(this.filterOptionsLocal);
|
||||||
this.searchTextLocal = { name: this.filterOptionsLocal.tags };
|
this.searchTextLocal = { name: this.filterOptionsLocal.tags };
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSelectPeriod(event: { startDate: Date, endDate: Date }) {
|
handleSelectPeriod(event: { startDate: Date, endDate: Date }) {
|
||||||
this.startDate = event.startDate;
|
this.periodLocal = { startDate: event.startDate, endDate: event.endDate}
|
||||||
this.endDate = event.endDate;
|
this.onPeriodChange.emit(this.periodLocal);
|
||||||
this.handleCloseModal();
|
|
||||||
this.startEndCaption = this.timespanService.getCaption(event.startDate, event.endDate, 4);
|
this.startEndCaption = this.timespanService.getCaption(event.startDate, event.endDate, 4);
|
||||||
this.onSearch.emit(this.filterOptionsLocal);
|
if(this.dateFilter) {
|
||||||
|
this.filterOptionsLocal.startDate =event.startDate;
|
||||||
|
this.filterOptionsLocal.endDate = event.endDate;
|
||||||
|
this.onSearch.emit(this.filterOptionsLocal);
|
||||||
|
}
|
||||||
|
this.handleCloseModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChangeEnableDateFilter(enabled) {
|
handleChangeEnableDateFilter(enabled) {
|
||||||
this.dateFilter = enabled;
|
this.dateFilter = enabled;
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
this.filterOptionsLocal.startDate = this.startDate;
|
this.filterOptionsLocal.startDate = this.periodLocal.startDate;
|
||||||
this.filterOptionsLocal.endDate = this.endDate;
|
this.filterOptionsLocal.endDate = this.periodLocal.endDate;
|
||||||
} else {
|
} else {
|
||||||
this.filterOptionsLocal.startDate = null;
|
this.filterOptionsLocal.startDate = null;
|
||||||
this.filterOptionsLocal.endDate = null;
|
this.filterOptionsLocal.endDate = null;
|
||||||
|
@@ -33,8 +33,8 @@
|
|||||||
<aol-interaction-default></aol-interaction-default>
|
<aol-interaction-default></aol-interaction-default>
|
||||||
<aol-interaction-dragrotateandzoom></aol-interaction-dragrotateandzoom>
|
<aol-interaction-dragrotateandzoom></aol-interaction-dragrotateandzoom>
|
||||||
<fm-map-item-layers [itemLayers]="state.baseLayers"></fm-map-item-layers>
|
<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 *ngIf="!overrideOverlayLayers" [itemLayers]="state.overlayLayers"></fm-map-item-layers>
|
||||||
<fm-map-item-layers [itemLayer]="state.selectedItemLayer"></fm-map-item-layers>
|
<fm-map-item-layers *ngIf="!overrideSelectedItemLayer" [itemLayer]="state.selectedItemLayer"></fm-map-item-layers>
|
||||||
<aol-layer-vector>
|
<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>
|
<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>
|
</aol-layer-vector>
|
||||||
@@ -50,31 +50,33 @@
|
|||||||
<fm-map-file-drop-target [parentCode]="state.parentCode" (onFileDropped)="handleFileDropped($event)"></fm-map-file-drop-target>
|
<fm-map-file-drop-target [parentCode]="state.parentCode" (onFileDropped)="handleFileDropped($event)"></fm-map-file-drop-target>
|
||||||
|
|
||||||
<div *ngIf="noContent">
|
<div *ngIf="noContent">
|
||||||
<fm-map-map-search #mapSearch [openedModalName]="state.openedModalName" (onOpenModal)="handleOpenModal($event)" (onCloseModal)="handleCloseModal()" [ngClass]="{'menuVisible':state.menuVisible}" (onToggleMenu)="handleToggleMenu($event)" (onSearchCollapse)="handleSearchCollapse($event)" (onSearchExpand)="handleSearchExpand($event)" [collapsed]="state.searchCollapsed" [searchMinified]="state.searchMinified" (onSearch)="handleSearch($event)" (onClear)="handleClearSearch($event)" [filterOptions]="state.queryState" [clearEnabled]="state.clearEnabled" [period]="state.period"></fm-map-map-search>
|
<fm-map-map-search #mapSearch [openedModalName]="state.openedModalName" (onOpenModal)="handleOpenModal($event)" (onCloseModal)="handleCloseModal()" [ngClass]="{'menuVisible':state.menuVisible}" (onToggleMenu)="handleToggleMenu($event)" (onSearchCollapse)="handleSearchCollapse($event)" (onSearchExpand)="handleSearchExpand($event)" [collapsed]="state.searchCollapsed" [searchMinified]="state.searchMinified" (onSearch)="handleSearch($event)" (onClear)="handleClearSearch($event)" [filterOptions]="state.queryState" [clearEnabled]="state.clearEnabled" [period]="state.period" (onPeriodChange)="handlePeriodChange($event)"></fm-map-map-search>
|
||||||
</div>
|
</div>
|
||||||
<fm-side-panel [resizeable]="true" [visible]="state.panelVisible && noContent" [collapsed]="state.panelCollapsed" [collapsable]="false">
|
<div class="side-panel-container">
|
||||||
<div class="panel-wrapper" *ngIf="noContent">
|
<fm-side-panel [resizeable]="true" [visible]="state.panelVisible && noContent" [collapsed]="state.panelCollapsed" [collapsable]="false">
|
||||||
<div class="panel-top bg-secondary" *ngIf="!(state.searchMinified)">
|
<div class="panel-wrapper" *ngIf="noContent">
|
||||||
</div>
|
<div class="panel-top bg-secondary" *ngIf="!(state.searchMinified)">
|
||||||
<div class="panel-bottom">
|
|
||||||
|
|
||||||
<div *ngIf="!(state.selectedItem)">
|
|
||||||
<fm-map-feature-list-container [features]="state.features" [selectedFeature]="state.selectedFeature" [queryState]="state.queryState" [clickedFeature]="clickedFeature"></fm-map-feature-list-container>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-bottom">
|
||||||
<div *ngIf="state.selectedItem;let item">
|
|
||||||
<fm-map-selected-item-container [item]="item" [parentItem]="state.parentItem" [itemLayer]="state.selectedItemLayer" [overlayLayers]="state.overlayLayers"></fm-map-selected-item-container>
|
<div *ngIf="!(state.selectedItem)">
|
||||||
|
<fm-map-feature-list-container [features]="state.features" [selectedFeature]="state.selectedFeature" [queryState]="state.queryState" [clickedFeature]="clickedFeature"></fm-map-feature-list-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="state.selectedItem;let item">
|
||||||
|
<fm-map-selected-item-container [item]="item" [parentItem]="state.parentItem" [itemLayer]="state.selectedItemLayer" [overlayLayers]="state.overlayLayers"></fm-map-selected-item-container>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="state.features.length == 0" class="no-results m-2">
|
||||||
|
<div *ngIf="state.queryState.query">Cannot find <span>{{state.queryState?.query}}</span></div>
|
||||||
|
<div *ngIf="state.queryState?.tags">Cannot find tag <span>{{state.queryState?.tags}}</span></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="state.features.length == 0" class="no-results m-2">
|
</div>
|
||||||
<div *ngIf="state.queryState.query">Cannot find <span>{{state.queryState?.query}}</span></div>
|
</fm-side-panel>
|
||||||
<div *ngIf="state.queryState?.tags">Cannot find tag <span>{{state.queryState?.tags}}</span></div>
|
<fm-side-panel [resizeable]="true" [visible]="!noContent">
|
||||||
</div>
|
<router-outlet (activate)="handleSidepaneloutletActivate($event)" (deactivate)="handleSidepaneloutletDeactivate($event)"></router-outlet>
|
||||||
</div>
|
</fm-side-panel>
|
||||||
</div>
|
</div>
|
||||||
</fm-side-panel>
|
|
||||||
<fm-side-panel [resizeable]="true" [visible]="!noContent">
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</fm-side-panel>
|
|
||||||
</aol-map>
|
</aol-map>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
@import "~bootstrap/scss/bootstrap.scss";
|
@import "~bootstrap/scss/bootstrap.scss";
|
||||||
|
|
||||||
aol-map { width:100%;}
|
aol-map { position:absolute;width:100%;height:calc(100vh + 4rem);}
|
||||||
|
|
||||||
.arrow {
|
.arrow {
|
||||||
top: 3rem;
|
top: 3rem;
|
||||||
@@ -49,11 +49,23 @@ aol-map { width:100%;}
|
|||||||
.control-container {
|
.control-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1em;
|
right: 1em;
|
||||||
bottom: 1em;
|
bottom: 8.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fullscreen .control-container {
|
.fullscreen .control-container {
|
||||||
bottom: 1em;
|
bottom: 5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.side-panel-container {
|
||||||
|
position: absolute;
|
||||||
|
top:0em;
|
||||||
|
bottom: 7.1em;
|
||||||
|
width: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fullscreen .side-panel-container {
|
||||||
|
bottom: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch2d3d {
|
switch2d3d {
|
||||||
@@ -125,6 +137,10 @@ timespan.menuVisible {
|
|||||||
.panel-top {
|
.panel-top {
|
||||||
height: 8.1rem;
|
height: 8.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.side-panel-container {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.map {
|
.map {
|
||||||
|
@@ -11,6 +11,8 @@ import { DeviceService } from '@farmmaps/common';
|
|||||||
import * as mapReducers from '../../reducers/map.reducer';
|
import * as mapReducers from '../../reducers/map.reducer';
|
||||||
import * as mapActions from '../../actions/map.actions';
|
import * as mapActions from '../../actions/map.actions';
|
||||||
import { IMapState} from '../../models/map.state';
|
import { IMapState} from '../../models/map.state';
|
||||||
|
import { IClickedFeature} from '../../models/clicked.feature';
|
||||||
|
import { IQuery } from '../../reducers/map.reducer'
|
||||||
import { ISelectedFeatures } from '../../models/selected.features';
|
import { ISelectedFeatures } from '../../models/selected.features';
|
||||||
import { IItemLayer } from '../../models/item.layer';
|
import { IItemLayer } from '../../models/item.layer';
|
||||||
import { IListItem, IQueryState } from '@farmmaps/common';
|
import { IListItem, IQueryState } from '@farmmaps/common';
|
||||||
@@ -73,8 +75,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
public searchCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchCollapsed);
|
public searchCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchCollapsed);
|
||||||
public searchMinified$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchMinified);
|
public searchMinified$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchMinified);
|
||||||
public menuVisible$: Observable<boolean>;
|
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<Position> = this.geolocationService.getCurrentPosition();
|
public position$: Observable<GeolocationPosition> = this.geolocationService.getCurrentPosition();
|
||||||
public compassHeading$: Observable<number> = this.deviceorientationService.getCurrentCompassHeading();
|
public compassHeading$: Observable<number> = this.deviceorientationService.getCurrentCompassHeading();
|
||||||
public baseLayersCollapsed:boolean = true;
|
public baseLayersCollapsed:boolean = true;
|
||||||
public overlayLayersCollapsed: boolean = true;
|
public overlayLayersCollapsed: boolean = true;
|
||||||
@@ -84,6 +86,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
private lastUrl = "";
|
private lastUrl = "";
|
||||||
private initialized: boolean = false;
|
private initialized: boolean = false;
|
||||||
public noContent: boolean = false;
|
public noContent: boolean = false;
|
||||||
|
public overrideSelectedItemLayer: boolean = false;
|
||||||
|
public overrideOverlayLayers: boolean = false;
|
||||||
|
|
||||||
@ViewChild('map') map;
|
@ViewChild('map') map;
|
||||||
@ViewChild('contentDiv') contentDiv: ElementRef;
|
@ViewChild('contentDiv') contentDiv: ElementRef;
|
||||||
@@ -99,28 +103,33 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
private deviceorientationService:DeviceOrientationService,
|
private deviceorientationService:DeviceOrientationService,
|
||||||
public devicesService:DeviceService) {
|
public devicesService:DeviceService) {
|
||||||
this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$)).subscribe(([queryState,mapState]) =>{
|
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-map"]) {
|
||||||
if(queryState) {
|
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);
|
let newQueryState = tassign(mapReducers.initialQueryState);
|
||||||
console.debug(`Do Query`);
|
console.debug(`Do Query`);
|
||||||
let urlparts=[];
|
let urlparts=[];
|
||||||
if (queryState.itemCode && queryState.itemCode != "") {
|
if (query.querystate.itemCode && query.querystate.itemCode != "") {
|
||||||
if(queryState.itemType && queryState.itemType!= "") {
|
if(query.querystate.itemType && query.querystate.itemType!= "") {
|
||||||
let itemType = this.itemTypeService.itemTypes[queryState.itemType];
|
let itemType = this.itemTypeService.itemTypes[query.querystate.itemType];
|
||||||
if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) {
|
if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) {
|
||||||
urlparts.push('/editor');
|
urlparts.push('/editor');
|
||||||
urlparts.push(itemType.editor);
|
urlparts.push(itemType.editor);
|
||||||
urlparts.push('item');
|
urlparts.push('item');
|
||||||
urlparts.push(queryState.itemCode);
|
urlparts.push(query.querystate.itemCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newQueryState= queryState;
|
newQueryState= query.querystate;
|
||||||
}
|
}
|
||||||
if(urlparts.length==0 ) {
|
if(urlparts.length==0 ) {
|
||||||
newQueryState.itemCode = queryState.itemCode;
|
newQueryState.itemCode = query.querystate.itemCode;
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
this.replaceUrl(mapState,newQueryState,false);
|
this.replaceUrl(mapState,newQueryState,query.replace);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(urlparts);
|
this.router.navigate(urlparts);
|
||||||
@@ -167,6 +176,18 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
this.store.dispatch(new mapActions.DoQuery(queryState));
|
this.store.dispatch(new mapActions.DoQuery(queryState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSidepaneloutletActivate(component:any) {
|
||||||
|
if(component && component.hasOwnProperty('clickedFeature')) {
|
||||||
|
(component as IClickedFeature).clickedFeature = this.clickedFeature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSidepaneloutletDeactivate(component:any) {
|
||||||
|
if(component && component.hasOwnProperty('clickedFeature')) {
|
||||||
|
(component as IClickedFeature).clickedFeature = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
console.debug("Init");
|
console.debug("Init");
|
||||||
@@ -426,6 +447,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
this.store.dispatch(new mapActions.SelectOverlayLayer(itemLayer));
|
this.store.dispatch(new mapActions.SelectOverlayLayer(itemLayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePeriodChange(period:IPeriodState) {
|
||||||
|
this.store.dispatch(new mapActions.SetPeriod(period));
|
||||||
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if (this.paramSub) this.paramSub.unsubscribe();
|
if (this.paramSub) this.paramSub.unsubscribe();
|
||||||
if (this.itemTypeSub) this.itemTypeSub.unsubscribe();
|
if (this.itemTypeSub) this.itemTypeSub.unsubscribe();
|
||||||
|
@@ -34,13 +34,13 @@ export class SelectedItemContainerComponent {
|
|||||||
let criteria=0;
|
let criteria=0;
|
||||||
if (this.selectedItemComponents[i]['forItemType'] ) {
|
if (this.selectedItemComponents[i]['forItemType'] ) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if(this.selectedItemComponents[i]['forItemType'].indexOf(this.item.itemType) >= 0) {
|
if(this.selectedItemComponents[i]['forItemType'].split(",").filter(part => part ==this.item.itemType).length == 1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.selectedItemComponents[i]['forSourceTask']) {
|
if (this.selectedItemComponents[i]['forSourceTask']) {
|
||||||
criteria++;
|
criteria++;
|
||||||
if( this.selectedItemComponents[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
|
if( this.selectedItemComponents[i]['forSourceTask'].split(",").filter(part => part ==this.item.sourceTask).length == 1) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Store, Action } from '@ngrx/store';
|
import { Store, Action,createFeatureSelector } from '@ngrx/store';
|
||||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
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 { EMPTY, Observable , of} from 'rxjs';
|
||||||
import { withLatestFrom, switchMap, map, catchError, mergeMap,tap } from 'rxjs/operators';
|
import { withLatestFrom, switchMap, map, catchError, mergeMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import {GeoJSON,WKT} from 'ol/format';
|
import {GeoJSON,WKT} from 'ol/format';
|
||||||
import {Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
@@ -29,25 +31,38 @@ import * as style from 'ol/style';
|
|||||||
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
||||||
import { TemporalItemLayer } from '../models/item.layer'
|
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()
|
@Injectable()
|
||||||
export class MapEffects {
|
export class MapEffects {
|
||||||
private _geojsonFormat: GeoJSON;
|
private _geojsonFormat: GeoJSON;
|
||||||
private _wktFormat: WKT;
|
private _wktFormat: WKT;
|
||||||
|
private overrideSelectedItemLayer: boolean = false;
|
||||||
|
|
||||||
private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature {
|
private updateFeatureGeometry(feature:Feature, updateEvent:commonActions.DeviceUpdateEvent): Feature {
|
||||||
|
let newFeature = feature.clone();
|
||||||
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
||||||
dataProjection: 'EPSG:4326',
|
dataProjection: 'EPSG:4326',
|
||||||
featureProjection: 'EPSG:3857'
|
featureProjection: 'EPSG:3857'
|
||||||
});
|
});
|
||||||
f.setId(updateEvent.itemCode);
|
|
||||||
var centroid = getCenter(f.getGeometry().getExtent());
|
var centroid = getCenter(f.getGeometry().getExtent());
|
||||||
f.setGeometry(new Point(centroid));
|
newFeature.setId(feature.getId());
|
||||||
return f;
|
newFeature.setGeometry(new Point(centroid));
|
||||||
|
return newFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Effect()
|
init$ = createEffect(() => this.actions$.pipe(
|
||||||
init$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.INIT),
|
ofType(mapActions.INIT),
|
||||||
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
||||||
switchMap(([action, rootItems]) => {
|
switchMap(([action, rootItems]) => {
|
||||||
@@ -87,25 +102,23 @@ export class MapEffects {
|
|||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
initBaseLayers$ = createEffect(() => this.actions$.pipe(
|
||||||
initBaseLayers$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.INIT),
|
ofType(mapActions.INIT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetProjection)),
|
||||||
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)));
|
map(([action, projection]) => new mapActions.LoadBaseLayers(projection)))
|
||||||
|
);
|
||||||
|
|
||||||
@Effect()
|
loadBaseLayers$ = createEffect(() => this.actions$.pipe(
|
||||||
loadBaseLayers$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.LOADBASELAYERS),
|
ofType(mapActions.LOADBASELAYERS),
|
||||||
switchMap((action: mapActions.LoadBaseLayers) => {
|
switchMap((action: mapActions.LoadBaseLayers) => {
|
||||||
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe(
|
||||||
map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)),
|
map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
startSearch$ = createEffect(() => this.actions$.pipe(
|
||||||
startSearch$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.STARTSEARCH),
|
ofType(mapActions.STARTSEARCH),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as mapActions.StartSearch;
|
let a = action as mapActions.StartSearch;
|
||||||
@@ -128,11 +141,10 @@ export class MapEffects {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return newAction;
|
return newAction;
|
||||||
}));
|
})));
|
||||||
|
|
||||||
|
|
||||||
@Effect()
|
zoomToExtent$ = createEffect(() => this.actions$.pipe(
|
||||||
zoomToExtent$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||||
let actions =[];
|
let actions =[];
|
||||||
@@ -149,10 +161,9 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return actions;
|
return actions;
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
|
||||||
zoomToExtent2$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SETFEATURES),
|
ofType(mapActions.SETFEATURES),
|
||||||
switchMap((action: mapActions.SetFeatures) => {
|
switchMap((action: mapActions.SetFeatures) => {
|
||||||
let extent = createEmpty();
|
let extent = createEmpty();
|
||||||
@@ -163,17 +174,15 @@ export class MapEffects {
|
|||||||
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
||||||
}
|
}
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
hideMenu$ = createEffect(() => this.actions$.pipe(
|
||||||
hideMenu$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||||
return of(new commonActions.SetMenuVisible(false));
|
return of(new commonActions.SetMenuVisible(false));
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
selectItem$ = createEffect(() => this.actions$.pipe(
|
||||||
selectItem$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEM),
|
ofType(mapActions.SELECTITEM),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||||
switchMap(([action, selectedItem]) => {
|
switchMap(([action, selectedItem]) => {
|
||||||
@@ -194,32 +203,33 @@ export class MapEffects {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
|
||||||
selectItemSuccessSetLayer$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
map((action:mapActions.SelectItemSuccess) =>
|
map((action:mapActions.SelectItemSuccess) =>
|
||||||
new mapActions.SetSelectedItemLayer(action.item)
|
new mapActions.SetSelectedItemLayer(action.item)
|
||||||
)
|
)
|
||||||
);
|
));
|
||||||
|
|
||||||
@Effect()
|
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
|
||||||
selectItemSuccess$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
switchMap((action:mapActions.SelectItemSuccess) => {
|
||||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
if(!this.overrideSelectedItemLayer) {
|
||||||
map((feature: any) => {
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||||
let f = this._geojsonFormat.readFeature(feature);
|
map((feature: any) => {
|
||||||
f.setId(action.item.code);
|
let f = this._geojsonFormat.readFeature(feature);
|
||||||
return new mapActions.AddFeatureSuccess(f );
|
f.setId(action.item.code);
|
||||||
}),
|
return new mapActions.AddFeatureSuccess(f );
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
}),
|
||||||
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
|
} else {
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
selectItemSuccessTemporal$ = createEffect(() => this.actions$.pipe(
|
||||||
selectItemSuccessTemporal$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
switchMap((action:mapActions.SelectItemSuccess) => {
|
||||||
if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||||
@@ -234,16 +244,14 @@ export class MapEffects {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
|
||||||
uploadedItemClick$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(commonActions.UPLOADEDFILECLICK),
|
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$ = createEffect(() => this.actions$.pipe(
|
||||||
featureUpdate$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(commonActions.DEVICEUPDATEEVENT),
|
ofType(commonActions.DEVICEUPDATEEVENT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)),
|
||||||
mergeMap(([action, features]) => {
|
mergeMap(([action, features]) => {
|
||||||
@@ -256,14 +264,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feature) {
|
if (feature) {
|
||||||
return of(new mapActions.UpdateFeatureSuccess(this.toPointFeature(deviceUpdateEventAction)));
|
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature,deviceUpdateEventAction)));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
itemUpdate$ = createEffect(() => this.actions$.pipe(
|
||||||
itemUpdate$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(commonActions.ITEMCHANGEDEVENT),
|
ofType(commonActions.ITEMCHANGEDEVENT),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)),
|
||||||
mergeMap(([action, selectedItem]) => {
|
mergeMap(([action, selectedItem]) => {
|
||||||
@@ -282,7 +289,7 @@ export class MapEffects {
|
|||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}));
|
})));
|
||||||
|
|
||||||
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
|
getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable<Action>|[] {
|
||||||
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
|
if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) {
|
||||||
@@ -299,8 +306,7 @@ export class MapEffects {
|
|||||||
return of(newAction);
|
return of(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Effect()
|
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
||||||
getLayerValue$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.GETLAYERVALUE),
|
ofType(mapActions.GETLAYERVALUE),
|
||||||
mergeMap((action:mapActions.GetLayerValue) => {
|
mergeMap((action:mapActions.GetLayerValue) => {
|
||||||
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
||||||
@@ -311,7 +317,7 @@ export class MapEffects {
|
|||||||
if(v !== null) {
|
if(v !== null) {
|
||||||
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
||||||
l.renderer.colorMap.entries.forEach((e) => {
|
l.renderer.colorMap.entries.forEach((e) => {
|
||||||
if(e.value == v) {
|
if(e.value == v && e.label) {
|
||||||
v=e.label;
|
v=e.label;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -324,19 +330,17 @@ export class MapEffects {
|
|||||||
return a;
|
return a;
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
||||||
updateLayerValuesOnLayerAddedOrRemoved$: Observable<Action> = this.actions$.pipe(
|
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEMSUCCESS,mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED,mapActions.SETLAYERINDEX,mapActions.SETSELECTEDITEMLAYER),
|
||||||
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEM,mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED),
|
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
||||||
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
||||||
);
|
));
|
||||||
|
|
||||||
|
|
||||||
@Effect()
|
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
||||||
getLayerValues$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SETLAYERVALUESLOCATION),
|
ofType(mapActions.SETLAYERVALUESLOCATION),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
||||||
@@ -362,20 +366,18 @@ export class MapEffects {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return actions;
|
return actions;
|
||||||
}));
|
})));
|
||||||
|
|
||||||
|
|
||||||
@Effect()
|
setState$ = createEffect(() => this.actions$.pipe(
|
||||||
setState$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(mapActions.SETSTATE),
|
ofType(mapActions.SETSTATE),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)),
|
||||||
switchMap(([action,inSearch]) => {
|
switchMap(([action,inSearch]) => {
|
||||||
let a = action as mapActions.SetState;
|
let a = action as mapActions.SetState;
|
||||||
return this.getActionFromQueryState(a.queryState,inSearch);
|
return this.getActionFromQueryState(a.queryState,inSearch);
|
||||||
}));
|
})));
|
||||||
|
|
||||||
@Effect()
|
escape$ = createEffect(() => this.actions$.pipe(
|
||||||
escape$:Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(commonActions.ESCAPE),
|
ofType(commonActions.ESCAPE),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as commonActions.Escape;
|
let a = action as commonActions.Escape;
|
||||||
@@ -384,10 +386,24 @@ export class MapEffects {
|
|||||||
} else {
|
} else {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
}));
|
})));
|
||||||
|
|
||||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) {
|
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();
|
this._geojsonFormat = new GeoJSON();
|
||||||
this._wktFormat = new WKT();
|
this._wktFormat = new WKT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
projects/common-map/src/fm-map/models/clicked.feature.ts
Normal file
10
projects/common-map/src/fm-map/models/clicked.feature.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import {Feature} from 'ol';
|
||||||
|
import {Geometry} from 'ol/geom';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This interface will be removed soon
|
||||||
|
*/
|
||||||
|
export interface IClickedFeature {
|
||||||
|
clickedFeature: Observable<Feature<Geometry>>
|
||||||
|
}
|
@@ -3,7 +3,7 @@ import { IItem,Item } from '@farmmaps/common';
|
|||||||
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer';
|
import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer';
|
||||||
import { IMapState} from '../models/map.state';
|
import { IMapState} from '../models/map.state';
|
||||||
import { IQueryState} from '@farmmaps/common';
|
import { IQueryState} from '@farmmaps/common';
|
||||||
import { IPeriodState} from '../models/period.state';
|
import { IPeriodState } from '../models/period.state';
|
||||||
import { IStyles} from '../models/style.cache';
|
import { IStyles} from '../models/style.cache';
|
||||||
import { ILayervalue } from '../models/layer.value';
|
import { ILayervalue } from '../models/layer.value';
|
||||||
import * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
@@ -33,12 +33,17 @@ export const initialQueryState: IQueryState = {
|
|||||||
bbox: []
|
bbox: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface IQuery {
|
||||||
|
querystate: IQueryState,
|
||||||
|
replace: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
period:IPeriodState,
|
period:IPeriodState,
|
||||||
mapState: IMapState,
|
mapState: IMapState,
|
||||||
viewExtent: number[],
|
viewExtent: number[],
|
||||||
queryState: IQueryState,
|
queryState: IQueryState,
|
||||||
query:IQueryState,
|
query:IQuery,
|
||||||
parentCode: string,
|
parentCode: string,
|
||||||
features: Array<Feature>,
|
features: Array<Feature>,
|
||||||
panelVisible: boolean,
|
panelVisible: boolean,
|
||||||
@@ -297,8 +302,18 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
case mapActions.DOQUERY: {
|
case mapActions.DOQUERY: {
|
||||||
let a = action as mapActions.DoQuery;
|
let a = action as mapActions.DoQuery;
|
||||||
return tassign(state, {
|
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.SETPERIOD: {
|
||||||
|
return tassign(state,{ period: action.period});
|
||||||
|
}
|
||||||
|
|
||||||
case mapActions.ADDFEATURESUCCESS: {
|
case mapActions.ADDFEATURESUCCESS: {
|
||||||
let a = action as mapActions.AddFeatureSuccess;
|
let a = action as mapActions.AddFeatureSuccess;
|
||||||
let features = state.features.slice();
|
let features = state.features.slice();
|
||||||
@@ -507,6 +522,30 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
v.push(a.layervalue);
|
v.push(a.layervalue);
|
||||||
return tassign(state,{layerValues:v});
|
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: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@@ -9,14 +9,14 @@ import { Observer, Observable,BehaviorSubject } from 'rxjs';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class GeolocationService {
|
export class GeolocationService {
|
||||||
|
|
||||||
private positionObserver$:BehaviorSubject<Position> = new BehaviorSubject<Position>(null);
|
private positionObserver$:BehaviorSubject<GeolocationPosition> = new BehaviorSubject<GeolocationPosition>(null);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
navigator.geolocation.watchPosition(
|
navigator.geolocation.watchPosition(
|
||||||
(position: Position) => {
|
(position: GeolocationPosition) => {
|
||||||
this.positionObserver$.next(position);
|
this.positionObserver$.next(position);
|
||||||
},
|
},
|
||||||
(error: PositionError) => {
|
(error: GeolocationPositionError) => {
|
||||||
console.debug('Geolocation service: ' + error.message);
|
console.debug('Geolocation service: ' + error.message);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ export class GeolocationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getCurrentPosition(): Observable<Position> {
|
getCurrentPosition(): Observable<GeolocationPosition> {
|
||||||
return this.positionObserver$;
|
return this.positionObserver$;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common-map3d",
|
"name": "@farmmaps/common-map3d",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common",
|
"name": "@farmmaps/common",
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
|
@@ -17,6 +17,7 @@ import { EventService } from './services/event.service';
|
|||||||
import { TypeaheadService } from './services/typeahead.service';
|
import { TypeaheadService } from './services/typeahead.service';
|
||||||
import { UserService } from './services/user.service';
|
import { UserService } from './services/user.service';
|
||||||
import { ImageService } from './services/image.service';
|
import { ImageService } from './services/image.service';
|
||||||
|
import { GeolocatorService } from './services/geolocator.service';
|
||||||
import { WeatherService} from './services/weather.service';
|
import { WeatherService} from './services/weather.service';
|
||||||
import { AppConfig } from './shared/app.config';
|
import { AppConfig } from './shared/app.config';
|
||||||
import { AccessTokenInterceptor } from "./shared/accesstoken.interceptor";
|
import { AccessTokenInterceptor } from "./shared/accesstoken.interceptor";
|
||||||
@@ -44,6 +45,7 @@ export {
|
|||||||
TypeaheadService,
|
TypeaheadService,
|
||||||
UserService,
|
UserService,
|
||||||
ImageService,
|
ImageService,
|
||||||
|
GeolocatorService,
|
||||||
WeatherService,
|
WeatherService,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
AccessTokenInterceptor,
|
AccessTokenInterceptor,
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AppMenuComponent } from './app-menu.component';
|
|
||||||
|
|
||||||
describe('AppMenuComponent', () => {
|
|
||||||
let component: AppMenuComponent;
|
|
||||||
let fixture: ComponentFixture<AppMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ AppMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AppMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { AvatarComponent } from './avatar.component';
|
|
||||||
|
|
||||||
describe('AvatarComponent', () => {
|
|
||||||
let component: AvatarComponent;
|
|
||||||
let fixture: ComponentFixture<AvatarComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ AvatarComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AvatarComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { EditImageModalComponent } from './edit-image-modal.component';
|
|
||||||
|
|
||||||
describe('EditImageModalComponent', () => {
|
|
||||||
let component: EditImageModalComponent;
|
|
||||||
let fixture: ComponentFixture<EditImageModalComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ EditImageModalComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(EditImageModalComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { GradientSelectComponent } from './gradient-select.component';
|
|
||||||
|
|
||||||
describe('GradientSelectComponent', () => {
|
|
||||||
let component: GradientSelectComponent;
|
|
||||||
let fixture: ComponentFixture<GradientSelectComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ GradientSelectComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(GradientSelectComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { GradientComponent } from './gradient.component';
|
|
||||||
|
|
||||||
describe('GradientComponent', () => {
|
|
||||||
let component: GradientComponent;
|
|
||||||
let fixture: ComponentFixture<GradientComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ GradientComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(GradientComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,61 +1,61 @@
|
|||||||
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input,OnDestroy } from '@angular/core';
|
import {AfterViewInit, Directive, Input, OnDestroy, TemplateRef, ViewContainerRef} from '@angular/core';
|
||||||
import { Store} from '@ngrx/store';
|
import {Subscription} from 'rxjs';
|
||||||
import * as appCommonReducer from '../../reducers/app-common.reducer'
|
import {PackageService} from '../../services/package.service';
|
||||||
import { IPackages } from '../../models/package';
|
import * as appCommonReducer from '../../reducers/app-common.reducer';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import {Store} from '@ngrx/store';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[fmHasPackage]',
|
selector: '[fmHasPackage]',
|
||||||
})
|
})
|
||||||
export class HasPackageDirective implements OnDestroy{
|
export class HasPackageDirective implements OnDestroy, AfterViewInit {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set fmHasPackage(packageIdentifier:string) {
|
set fmHasPackage(packageIdentifier: string) {
|
||||||
this.packageIdentifier$ = packageIdentifier;
|
this.packageIdentifier = packageIdentifier;
|
||||||
this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set fmHasPackageThen(thenTemplate:TemplateRef<any>) {
|
set fmHasPackageThen(thenTemplate: TemplateRef<any>) {
|
||||||
this.thenTemplate$ = thenTemplate;
|
this.thenTemplate = thenTemplate;
|
||||||
this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
set fmHasPackageElse(thenTemplate:TemplateRef<any>) {
|
set fmHasPackageElse(thenTemplate: TemplateRef<any>) {
|
||||||
this.elseTemplate$ = thenTemplate;
|
this.elseTemplate = thenTemplate;
|
||||||
this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private packageIdentifier$:string;
|
private packageIdentifier: string;
|
||||||
private thenTemplate$:TemplateRef<any>;
|
private thenTemplate: TemplateRef<any>;
|
||||||
private elseTemplate$:TemplateRef<any>;
|
private elseTemplate: TemplateRef<any>;
|
||||||
private packages$:any = {};
|
private packSub: Subscription;
|
||||||
private packagesObservable$:Observable<IPackages> = this.store$.select(appCommonReducer.SelectGetUserPackages);
|
|
||||||
private packSub:Subscription;
|
|
||||||
|
|
||||||
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private store$: Store<appCommonReducer.State>) {
|
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
||||||
this.thenTemplate$=templateRef$;
|
private store: Store<appCommonReducer.State>, private packageService: PackageService) {
|
||||||
this.packSub = this.store$.select(appCommonReducer.SelectGetUserPackages).subscribe((packages) => {
|
this.thenTemplate = hostTemplateRef;
|
||||||
this.packages$ = packages;
|
this.packSub = this.store.select(appCommonReducer.SelectGetValidUserPackages).subscribe((_) => {
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
this.updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.updateView();
|
||||||
|
}
|
||||||
|
|
||||||
updateView() {
|
updateView() {
|
||||||
this.viewContainerRef$.clear();
|
this.viewContainerRef.clear();
|
||||||
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0, 0, 0, 0);
|
if (this.packageService.hasPackage(this.packageIdentifier)) {
|
||||||
if (this.packages$[this.packageIdentifier$] &&
|
this.viewContainerRef.createEmbeddedView(this.thenTemplate);
|
||||||
(this.packages$[this.packageIdentifier$].dataDate && new Date(this.packages$[this.packageIdentifier$].dataDate).setHours(0, 0, 0, 0) <= today) &&
|
} else if (this.elseTemplate) {
|
||||||
(this.packages$[this.packageIdentifier$].dataEndDate == null || new Date(this.packages$[this.packageIdentifier$].dataEndDate).setHours(0, 0, 0, 0) >= today)) {
|
this.viewContainerRef.createEmbeddedView(this.elseTemplate);
|
||||||
this.viewContainerRef$.createEmbeddedView(this.thenTemplate$);
|
}
|
||||||
} else if (this.elseTemplate$) {
|
|
||||||
this.viewContainerRef$.createEmbeddedView(this.elseTemplate$);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if(this.packSub) this.packSub.unsubscribe();
|
if (this.packSub) {
|
||||||
|
this.packSub.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<div>
|
<div class="mobile-hide">
|
||||||
<div (click)="toggle($event)" class="rounded-circle menu-button hidden" [ngClass]="{'hidden':!user || noContent}">
|
<div (click)="toggle($event)" class="rounded-circle menu-button hidden" [ngClass]="{'hidden':!user || noContent}">
|
||||||
<span i18n-title title="Help"><i class="fas fa-question" aria-hidden="true"></i></span>
|
<span i18n-title title="Help"><i class="fas fa-question" aria-hidden="true"></i></span>
|
||||||
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
|
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
|
||||||
|
@@ -68,6 +68,16 @@ div.menu-button > span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobile-hide {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 768px) {
|
||||||
|
.mobile-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.unread {
|
.unread {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { HelpMenuComponent } from './help-menu.component';
|
|
||||||
|
|
||||||
describe('HelpMenuComponent', () => {
|
|
||||||
let component: HelpMenuComponent;
|
|
||||||
let fixture: ComponentFixture<HelpMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ HelpMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(HelpMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { NotificationMenuComponent } from './notification-menu.component';
|
|
||||||
|
|
||||||
describe('NotificationMenuComponent', () => {
|
|
||||||
let component: NotificationMenuComponent;
|
|
||||||
let fixture: ComponentFixture<NotificationMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ NotificationMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(NotificationMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -7,6 +7,7 @@
|
|||||||
transition: left 0.2s, top 0.2s;
|
transition: left 0.2s, top 0.2s;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
|
||||||
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.side-panel.resizing {
|
.side-panel.resizing {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
<div #thumbnail class="thumbnail" [style.background-color]="itemTypeService.getColor(item.itemType)" >
|
<div #thumbnail class="thumbnail" [style.background-color]="itemTypeService.getColor(item.itemType)" >
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<img *ngIf="item.thumbnail" class="card-img-top" [src]="getThumbnailUrl(item)" />
|
<img *ngIf="hasThumbnail()" class="card-img-top" [src]="getThumbnailUrl(item)" />
|
||||||
<div *ngIf="!item.thumbnail" class="large-icon" [style.font-size]="getFontSize()" [style.line-height]="getLineHeight()"><i [ngClass]="itemTypeService.getIcon(item.itemType)"></i></div>
|
<div *ngIf="!hasThumbnail()" class="large-icon" [style.font-size]="getFontSize()" [style.line-height]="getLineHeight()"><i [ngClass]="itemTypeService.getIcon(item.itemType)"></i></div>
|
||||||
<div *ngIf="canEdit()" class="edit btn btn-secondary rounded-circle" (click)="onEditClick()"><i class="fal fa-camera"></i></div>
|
<div *ngIf="canEdit()" class="edit btn btn-secondary rounded-circle" (click)="onEditClick()"><i class="fal fa-camera"></i></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<fm-edit-image-modal #modal (changed)="onChanged()"></fm-edit-image-modal>
|
<fm-edit-image-modal #modal (changed)="onChanged($event)"></fm-edit-image-modal>
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import { Component,Input ,ViewChild,ElementRef,ChangeDetectorRef} from '@angular/core';
|
import { Component,Input ,ViewChild,ElementRef,ChangeDetectorRef, Output,EventEmitter} from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { IListItem } from '../../models/list.item';
|
import { IListItem } from '../../models/list.item';
|
||||||
|
import { ImageService } from '../../services/image.service';
|
||||||
import { commonReducers,ItemTypeService } from '../../../public-api'
|
import { commonReducers,ItemTypeService } from '../../../public-api'
|
||||||
import { EditImageModalComponent} from '../edit-image-modal/edit-image-modal.component';
|
import { EditImageModalComponent} from '../edit-image-modal/edit-image-modal.component';
|
||||||
import { AppConfig } from "../../shared/app.config";
|
import { AppConfig } from "../../shared/app.config";
|
||||||
@@ -16,14 +17,25 @@ import { AppConfig } from "../../shared/app.config";
|
|||||||
export class ThumbnailComponent {
|
export class ThumbnailComponent {
|
||||||
@Input() public item: IListItem;
|
@Input() public item: IListItem;
|
||||||
@Input() public edit: boolean = false;
|
@Input() public edit: boolean = false;
|
||||||
|
@Input() public save: boolean = true;
|
||||||
|
@Output() changed = new EventEmitter();
|
||||||
@ViewChild('thumbnail') el:ElementRef;
|
@ViewChild('thumbnail') el:ElementRef;
|
||||||
@ViewChild('modal') modal:EditImageModalComponent;
|
@ViewChild('modal') modal:EditImageModalComponent;
|
||||||
|
|
||||||
constructor(public store: Store<commonReducers.State>, public itemTypeService: ItemTypeService,public appConfig: AppConfig,private changeDetector:ChangeDetectorRef) {
|
public image = null;
|
||||||
|
private endpoint = "";
|
||||||
|
public thumnailUrl = "";
|
||||||
|
|
||||||
|
constructor(public store: Store<commonReducers.State>, public itemTypeService: ItemTypeService,public appConfig: AppConfig,private changeDetector:ChangeDetectorRef,public imageService:ImageService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getThumbnailUrl(item:IListItem):string {
|
getThumbnailUrl(item:IListItem):string {
|
||||||
return this.appConfig.getConfig("apiEndPoint")+item.url+'/thumbnail?v=' + Date.parse(item.updated);
|
if(this.image == null && this.item.thumbnail) {
|
||||||
|
this.thumnailUrl = this.appConfig.getConfig("apiEndPoint")+item.url+'/thumbnail?v=' + Date.parse(item.updated);
|
||||||
|
} else if (this.image == null) {
|
||||||
|
this.thumnailUrl = "";
|
||||||
|
}
|
||||||
|
return this.thumnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFontSize():string {
|
getFontSize():string {
|
||||||
@@ -47,15 +59,28 @@ import { AppConfig } from "../../shared/app.config";
|
|||||||
return this.edit && this.item != null;
|
return this.edit && this.item != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditClick() {
|
hasThumbnail():boolean {
|
||||||
var endpoint = `${this.appConfig.getConfig("apiEndPoint")}/api/v1/items/${this.item.code}/thumbnail`;
|
return (this.item && this.item.thumbnail) || this.image != null;
|
||||||
this.modal.open(endpoint,4/3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onChanged() {
|
onEditClick() {
|
||||||
if(this.item) {
|
this.endpoint = `${this.appConfig.getConfig("apiEndPoint")}/api/v1/items/${this.item.code}/thumbnail`;
|
||||||
this.item.updated = new Date(new Date().getTime()).toISOString();
|
this.modal.open(this.endpoint,4/3,false,200,false);
|
||||||
this.changeDetector.detectChanges();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChanged(event:any) {
|
||||||
|
this.image = event.croppedImage;
|
||||||
|
this.imageService.blobToDataUrl(event.croppedImage).then(url => {
|
||||||
|
this.thumnailUrl = url
|
||||||
|
this.changeDetector.detectChanges();
|
||||||
|
if(this.save) this.saveImage();
|
||||||
|
this.changed.emit(event.croppedImage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
saveImage() {
|
||||||
|
if(this.image) {
|
||||||
|
this.imageService.putImage(this.endpoint,this.image).subscribe(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { UserMenuComponent } from './user-menu.component';
|
|
||||||
|
|
||||||
describe('UserMenuComponent', () => {
|
|
||||||
let component: UserMenuComponent;
|
|
||||||
let fixture: ComponentFixture<UserMenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ UserMenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(UserMenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,9 +1,9 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
|
import { OAuthService,UserInfo } from 'angular-oauth2-oidc';
|
||||||
import { Store, Action } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Effect, Actions,ofType } from '@ngrx/effects';
|
import { Actions,ofType,createEffect } from '@ngrx/effects';
|
||||||
import { Observable , defer , of,from,zip } from 'rxjs';
|
import { of,from,zip } from 'rxjs';
|
||||||
import { withLatestFrom,mergeMap,switchMap,map,catchError,first} from 'rxjs/operators';
|
import { withLatestFrom,mergeMap,switchMap,map,catchError,first} from 'rxjs/operators';
|
||||||
import * as appCommonActions from '../actions/app-common.actions';
|
import * as appCommonActions from '../actions/app-common.actions';
|
||||||
import * as appCommonReducers from '../reducers/app-common.reducer';
|
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 { UserService } from '../services/user.service';
|
||||||
import { IItemTypes } from '../models/item.types';
|
import { IItemTypes } from '../models/item.types';
|
||||||
import { IListItem } from '../models/list.item';
|
import { IListItem } from '../models/list.item';
|
||||||
import { IUser } from '../models/user';
|
|
||||||
import {IQueryState} from '../models/query.state';
|
|
||||||
import {StateSerializerService} from '../services/state-serializer.service';
|
import {StateSerializerService} from '../services/state-serializer.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppCommonEffects {
|
export class AppCommonEffects {
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
login$ = createEffect(() => this.actions$.pipe(
|
||||||
login$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.LOGIN),
|
ofType(appCommonActions.LOGIN),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
|
||||||
mergeMap(([action, initialized]) => {
|
mergeMap(([action, initialized]) => {
|
||||||
var a = (action as appCommonActions.Login);
|
var a = (action as appCommonActions.Login);
|
||||||
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
|
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
|
||||||
return [];
|
return [];
|
||||||
}));
|
})),{dispatch:false});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
logout$ = createEffect(() => this.actions$.pipe(
|
||||||
logout$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.LOGOUT),
|
ofType(appCommonActions.LOGOUT),
|
||||||
mergeMap((action) => {
|
mergeMap((action) => {
|
||||||
this.oauthService$.revokeTokenAndLogout();
|
this.oauthService$.revokeTokenAndLogout();
|
||||||
return [];
|
return [];
|
||||||
}));
|
})),{dispatch:false});
|
||||||
|
|
||||||
@Effect()
|
loadItemTypes$ = createEffect(() => this.actions$.pipe(
|
||||||
loadItemTypes$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.LOADITEMTYPES),
|
ofType(appCommonActions.LOADITEMTYPES),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
return this.itemService$.getItemTypes().pipe(
|
return this.itemService$.getItemTypes().pipe(
|
||||||
map((itemTypes: IItemTypes) => new appCommonActions.LoadItemTypesSuccess(itemTypes)),
|
map((itemTypes: IItemTypes) => new appCommonActions.LoadItemTypesSuccess(itemTypes)),
|
||||||
catchError(error => of(new appCommonActions.Fail(error))))
|
catchError(error => of(new appCommonActions.Fail(error))))
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
initUser$ = createEffect(() => this.actions$.pipe(
|
||||||
initUser$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.INITUSER),
|
ofType(appCommonActions.INITUSER),
|
||||||
first(),
|
first(),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
@@ -56,11 +50,10 @@ export class AppCommonEffects {
|
|||||||
switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
|
switchMap(([user,userInfo]) => {return of(new appCommonActions.InitUserSuccess(user,userInfo as UserInfo))} ),
|
||||||
catchError(error => of(new appCommonActions.Fail(error))))
|
catchError(error => of(new appCommonActions.Fail(error))))
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
|
|
||||||
@Effect()
|
initUserPackages$ = createEffect(() => this.actions$.pipe(
|
||||||
initUserPackages$:Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.INITUSERPACKAGES),
|
ofType(appCommonActions.INITUSERPACKAGES),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return this.itemService$.getItemList('vnd.farmmaps.itemtype.package').pipe(
|
return this.itemService$.getItemList('vnd.farmmaps.itemtype.package').pipe(
|
||||||
@@ -68,10 +61,9 @@ export class AppCommonEffects {
|
|||||||
catchError(error => of(new appCommonActions.Fail(error)))
|
catchError(error => of(new appCommonActions.Fail(error)))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
);
|
));
|
||||||
|
|
||||||
@Effect()
|
userPackagesChanged$ = createEffect(() => this.actions$.pipe(
|
||||||
userPackagesChanged$:Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as appCommonActions.ItemChangedEvent;
|
let a = action as appCommonActions.ItemChangedEvent;
|
||||||
@@ -80,10 +72,9 @@ export class AppCommonEffects {
|
|||||||
else
|
else
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
);
|
));
|
||||||
|
|
||||||
@Effect()
|
initUserSettingsRoot$ = createEffect(() => this.actions$.pipe(
|
||||||
initUserSettingsRoot$:Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.INITUSERSETTINGSROOT),
|
ofType(appCommonActions.INITUSERSETTINGSROOT),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
|
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
|
||||||
switchMap(([, user]) => {
|
switchMap(([, user]) => {
|
||||||
@@ -92,10 +83,9 @@ export class AppCommonEffects {
|
|||||||
catchError(error => of(new appCommonActions.Fail(error)))
|
catchError(error => of(new appCommonActions.Fail(error)))
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
);
|
));
|
||||||
|
|
||||||
@Effect()
|
initUserSettingsRootChanged$ = createEffect(() => this.actions$.pipe(
|
||||||
initUserSettingsRootChanged$:Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as appCommonActions.ItemChangedEvent;
|
let a = action as appCommonActions.ItemChangedEvent;
|
||||||
@@ -104,38 +94,34 @@ export class AppCommonEffects {
|
|||||||
else
|
else
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
);
|
));
|
||||||
|
|
||||||
@Effect()
|
initUserSuccess$ = createEffect(() => this.actions$.pipe(
|
||||||
initUserSuccess$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.INITUSERSUCCESS),
|
ofType(appCommonActions.INITUSERSUCCESS),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages(),new appCommonActions.InitUserSettingsRoot()];
|
return [new appCommonActions.InitRoot(),new appCommonActions.InitUserPackages(),new appCommonActions.InitUserSettingsRoot()];
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
initRoot$ = createEffect(() => this.actions$.pipe(
|
||||||
initRoot$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.INITROOT),
|
ofType(appCommonActions.INITROOT),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
return this.folderService$.getMyRoots().pipe(
|
return this.folderService$.getMyRoots().pipe(
|
||||||
map((folders: IListItem[]) => new appCommonActions.InitRootSuccess(folders)),
|
map((folders: IListItem[]) => new appCommonActions.InitRootSuccess(folders)),
|
||||||
catchError(error => of(new appCommonActions.Fail(error))))
|
catchError(error => of(new appCommonActions.Fail(error))))
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
deleteItems$ = createEffect(() => this.actions$.pipe(
|
||||||
deleteItems$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.DELETEITEMS),
|
ofType(appCommonActions.DELETEITEMS),
|
||||||
switchMap((action:appCommonActions.DeleteItems) => {
|
switchMap((action:appCommonActions.DeleteItems) => {
|
||||||
return this.itemService$.deleteItems(action.itemCodes).pipe(
|
return this.itemService$.deleteItems(action.itemCodes).pipe(
|
||||||
map((deletedItemCodes: string[]) => new appCommonActions.DeleteItemsSuccess(deletedItemCodes)),
|
map((deletedItemCodes: string[]) => new appCommonActions.DeleteItemsSuccess(deletedItemCodes)),
|
||||||
catchError(error => of(new appCommonActions.Fail(error))))
|
catchError(error => of(new appCommonActions.Fail(error))))
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
editItem$ = createEffect(() => this.actions$.pipe(
|
||||||
editItem$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.EDITITEM),
|
ofType(appCommonActions.EDITITEM),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
||||||
switchMap(([action, itemtypes]) => {
|
switchMap(([action, itemtypes]) => {
|
||||||
@@ -148,10 +134,9 @@ export class AppCommonEffects {
|
|||||||
this.router$.navigate(['/editor',editor,'item', a.item.code])
|
this.router$.navigate(['/editor',editor,'item', a.item.code])
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
@Effect()
|
viewItem$ = createEffect(() => this.actions$.pipe(
|
||||||
viewItem$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.VIEWITEM),
|
ofType(appCommonActions.VIEWITEM),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
||||||
switchMap(([action, itemtypes]) => {
|
switchMap(([action, itemtypes]) => {
|
||||||
@@ -181,20 +166,18 @@ export class AppCommonEffects {
|
|||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
));
|
)));
|
||||||
|
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
fail$ = createEffect(() => this.actions$.pipe(
|
||||||
fail$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.FAIL),
|
ofType(appCommonActions.FAIL),
|
||||||
map((action) => {
|
map((action) => {
|
||||||
let failAction = action as appCommonActions.Fail;
|
let failAction = action as appCommonActions.Fail;
|
||||||
console.debug(failAction.payload)
|
console.debug(failAction.payload)
|
||||||
return null;
|
return null;
|
||||||
}));
|
})),{dispatch:false});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
online$ = createEffect(() => this.actions$.pipe(
|
||||||
online$: Observable<Action> = this.actions$.pipe(
|
|
||||||
ofType(appCommonActions.ONLINE),
|
ofType(appCommonActions.ONLINE),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
console.debug("Online: Check token");
|
console.debug("Online: Check token");
|
||||||
@@ -206,7 +189,7 @@ export class AppCommonEffects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return of(undefined);
|
return of(undefined);
|
||||||
}));
|
})),{dispatch:false});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,5 +7,5 @@ export interface IPackage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IPackages {
|
export interface IPackages {
|
||||||
[id: string]: IPackage;
|
[id: string]: IPackage[];
|
||||||
}
|
}
|
||||||
|
@@ -15,4 +15,5 @@ export interface IUser {
|
|||||||
cocNumber?: string;
|
cocNumber?: string;
|
||||||
searchable: boolean;
|
searchable: boolean;
|
||||||
newsletter?: boolean;
|
newsletter?: boolean;
|
||||||
|
language?: string;
|
||||||
}
|
}
|
@@ -8,6 +8,7 @@ import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/s
|
|||||||
|
|
||||||
import { MODULE_NAME } from '../module-name';
|
import { MODULE_NAME } from '../module-name';
|
||||||
import { IItem } from '../models/item';
|
import { IItem } from '../models/item';
|
||||||
|
import {getValidPackages, isValidPackage} from '../services/package.service';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
openedModalName: string,
|
openedModalName: string,
|
||||||
@@ -66,7 +67,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
name:a.userinfo["name"],
|
name:a.userinfo["name"],
|
||||||
claims:claims,
|
claims:claims,
|
||||||
searchable: false
|
searchable: false
|
||||||
};
|
};
|
||||||
return tassign(state, { user: user });
|
return tassign(state, { user: user });
|
||||||
}
|
}
|
||||||
case appCommonActions.INITROOTSUCCESS: {
|
case appCommonActions.INITROOTSUCCESS: {
|
||||||
@@ -75,10 +76,10 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
}
|
}
|
||||||
case appCommonActions.OPENMODAL: {
|
case appCommonActions.OPENMODAL: {
|
||||||
return tassign(state, { openedModalName: action.modalName });
|
return tassign(state, { openedModalName: action.modalName });
|
||||||
}
|
}
|
||||||
case appCommonActions.CLOSEMODAL: {
|
case appCommonActions.CLOSEMODAL: {
|
||||||
return tassign(state, { openedModalName: null });
|
return tassign(state, { openedModalName: null });
|
||||||
}
|
}
|
||||||
case appCommonActions.LOADITEMTYPESSUCCESS: {
|
case appCommonActions.LOADITEMTYPESSUCCESS: {
|
||||||
let a = action as appCommonActions.LoadItemTypesSuccess;
|
let a = action as appCommonActions.LoadItemTypesSuccess;
|
||||||
return tassign(state, { itemTypes: a.itemTypes });
|
return tassign(state, { itemTypes: a.itemTypes });
|
||||||
@@ -131,7 +132,10 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
a.items.forEach((item) => {
|
a.items.forEach((item) => {
|
||||||
item.data.dataDate = item.dataDate;
|
item.data.dataDate = item.dataDate;
|
||||||
item.data.dataEndDate = item.dataEndDate;
|
item.data.dataEndDate = item.dataEndDate;
|
||||||
packages[item.data.id]=item.data;
|
if (!packages[item.data.id]) {
|
||||||
|
packages[item.data.id] = [];
|
||||||
|
}
|
||||||
|
packages[item.data.id].push(item.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
return tassign(state,{userPackages:packages});
|
return tassign(state,{userPackages:packages});
|
||||||
@@ -203,6 +207,9 @@ export const selectGetRouteLoading = createSelector(selectAppCommonState, getRou
|
|||||||
export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuVisible);
|
export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuVisible);
|
||||||
export const SelectGetUser = createSelector(selectAppCommonState,getUser);
|
export const SelectGetUser = createSelector(selectAppCommonState,getUser);
|
||||||
export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages);
|
export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages);
|
||||||
|
export const SelectGetValidUserPackages = createSelector(SelectGetUserPackages, (packageMap) => {
|
||||||
|
return getValidPackages(packageMap);
|
||||||
|
});
|
||||||
export const SelectGetUserSettingsRoot = createSelector(selectAppCommonState,getUserSettingsRoot);
|
export const SelectGetUserSettingsRoot = createSelector(selectAppCommonState,getUserSettingsRoot);
|
||||||
export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible);
|
export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible);
|
||||||
export const SelectGetAppMenuVisible = createSelector(selectAppCommonState,getAppMenuVisible);
|
export const SelectGetAppMenuVisible = createSelector(selectAppCommonState,getAppMenuVisible);
|
||||||
@@ -213,3 +220,4 @@ export const SelectgetUnreadNotifications = createSelector(selectAppCommonState,
|
|||||||
export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline);
|
export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline);
|
||||||
export const SelectGetIsPageMode = createSelector(selectAppCommonState,getIsPageMode);
|
export const SelectGetIsPageMode = createSelector(selectAppCommonState,getIsPageMode);
|
||||||
|
|
||||||
|
|
||||||
|
21
projects/common/src/fm/services/geolocator.service.ts
Normal file
21
projects/common/src/fm/services/geolocator.service.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { IUser } from '../models/user';
|
||||||
|
import { HttpClient,HttpHeaders } from "@angular/common/http";
|
||||||
|
import { AppConfig } from "../shared/app.config";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class GeolocatorService {
|
||||||
|
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiEndpoint() {
|
||||||
|
return this.appConfig.getConfig("apiEndPoint");
|
||||||
|
}
|
||||||
|
|
||||||
|
geocode(address:string): Observable<any> {
|
||||||
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/service/geocode?address=${address}`)
|
||||||
|
}
|
||||||
|
}
|
@@ -48,4 +48,18 @@ export class ImageService {
|
|||||||
blobToFile(blob:Blob, filename:string):File {
|
blobToFile(blob:Blob, filename:string):File {
|
||||||
return new File([blob],filename,{type:blob.type});
|
return new File([blob],filename,{type:blob.type});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blobToDataUrl(blob:File):Promise<string> {
|
||||||
|
|
||||||
|
return new Promise<string>((resolve) => {
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.addEventListener('error', () => {
|
||||||
|
resolve("");
|
||||||
|
});
|
||||||
|
reader.addEventListener("load", function () {
|
||||||
|
resolve(reader.result as string);
|
||||||
|
}, false);
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ export class ItemTypeService {
|
|||||||
})
|
})
|
||||||
.catch(error => this.itemTypes = null);
|
.catch(error => this.itemTypes = null);
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve) => {resolve()});
|
return new Promise<void>((resolve) => {resolve()});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
122
projects/common/src/fm/services/package.service.spec.ts
Normal file
122
projects/common/src/fm/services/package.service.spec.ts
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import {getValidPackages, isValidPackage, PackageService} from './package.service';
|
||||||
|
import {MockStore, provideMockStore} from '@ngrx/store/testing';
|
||||||
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||||
|
import {reducer, State} from '../reducers/app-common.reducer';
|
||||||
|
import * as appCommonActions from '../actions/app-common.actions';
|
||||||
|
import {IItem} from '../models/item';
|
||||||
|
import {IPackage} from '../models/package';
|
||||||
|
|
||||||
|
describe('PackageService', () => {
|
||||||
|
const initialState = {userPackages: {}} as State;
|
||||||
|
let serviceUnderTest: PackageService;
|
||||||
|
let items;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
provideMockStore({
|
||||||
|
initialState,
|
||||||
|
selectors: [
|
||||||
|
{
|
||||||
|
selector: appCommonReducer.SelectGetValidUserPackages,
|
||||||
|
value: {
|
||||||
|
'vnd.farmmaps.package.zoning': {
|
||||||
|
id: 'vnd.farmmaps.package.zoning',
|
||||||
|
name: 'zoning package',
|
||||||
|
dataDate: '2022-01-25T00:00:00.000000Z'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = TestBed.inject(MockStore);
|
||||||
|
serviceUnderTest = new PackageService(store, null, null);
|
||||||
|
|
||||||
|
items = [
|
||||||
|
{
|
||||||
|
code: '123132',
|
||||||
|
dataDate: '2021-01-25T00:00:00Z',
|
||||||
|
dataEndDate: '2021-05-25T00:00:00Z',
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.zoning'
|
||||||
|
}
|
||||||
|
} as IItem,
|
||||||
|
{
|
||||||
|
code: '1231325',
|
||||||
|
dataDate: '2021-01-25T00:00:00Z',
|
||||||
|
dataEndDate: null,
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.zoning'
|
||||||
|
}
|
||||||
|
} as IItem,
|
||||||
|
{
|
||||||
|
code: '1231325',
|
||||||
|
dataDate: '2022-01-25T00:00:00Z',
|
||||||
|
dataEndDate: '2022-05-25T00:00:00Z',
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.tipstar'
|
||||||
|
}
|
||||||
|
} as IItem,
|
||||||
|
{
|
||||||
|
code: '1231325',
|
||||||
|
dataDate: '2022-01-25T00:00:00Z',
|
||||||
|
dataEndDate: null,
|
||||||
|
data: {
|
||||||
|
id: 'vnd.farmmaps.package.weather'
|
||||||
|
}
|
||||||
|
} as IItem
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Does not have a tipstar package', () => {
|
||||||
|
const hasPackage = serviceUnderTest.hasPackage('vnd.farmmaps.package.tipstar');
|
||||||
|
expect(hasPackage).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Does have a zoning package', () => {
|
||||||
|
const hasPackage = serviceUnderTest.hasPackage('vnd.farmmaps.package.zoning');
|
||||||
|
expect(hasPackage).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reducer.INITUSERPACKAGESSUCCESS alter state correctly', () => {
|
||||||
|
const action = new appCommonActions.InitUserPackagesSuccess(items);
|
||||||
|
|
||||||
|
expect(Object.keys(initialState.userPackages).length).toBe(0);
|
||||||
|
const state = reducer(initialState, action);
|
||||||
|
expect(Object.keys(state.userPackages).length).toBe(3);
|
||||||
|
expect(state.userPackages['vnd.farmmaps.package.zoning'].length).toBe(2);
|
||||||
|
expect(state.userPackages['vnd.farmmaps.package.tipstar'].length).toBe(1);
|
||||||
|
expect(state.userPackages['vnd.farmmaps.package.weather'].length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('to validatePackage', () => {
|
||||||
|
const action = new appCommonActions.InitUserPackagesSuccess(items);
|
||||||
|
const state = reducer(initialState, action);
|
||||||
|
|
||||||
|
expect(isValidPackage(null)).toBe(false);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.tipstar'][0])).toBe(true);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.zoning'][0])).toBe(false);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.zoning'][1])).toBe(true);
|
||||||
|
expect(isValidPackage(state.userPackages['vnd.farmmaps.package.weather'][0])).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('to getValidPackages', () => {
|
||||||
|
const action = new appCommonActions.InitUserPackagesSuccess(items);
|
||||||
|
const state = reducer(initialState, action);
|
||||||
|
|
||||||
|
const validPackages = getValidPackages(state.userPackages);
|
||||||
|
|
||||||
|
expect(Object.keys(validPackages).length).toBe(3);
|
||||||
|
|
||||||
|
// today is 27-01-2022, so the below package is not valid
|
||||||
|
expect(validPackages['vnd.farmmaps.package.zoning']).not.toEqual({
|
||||||
|
id: 'vnd.farmmaps.package.zoning',
|
||||||
|
dataDate: '2021-01-25T00:00:00Z',
|
||||||
|
dataEndDate: '2021-05-25T00:00:00Z'
|
||||||
|
} as unknown as IPackage);
|
||||||
|
});
|
||||||
|
});
|
@@ -1,37 +1,58 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import { Store} from '@ngrx/store';
|
import {Store} from '@ngrx/store';
|
||||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||||
import { IPackages } from '../models/package';
|
import {IPackage, IPackages} from '../models/package';
|
||||||
|
|
||||||
import { IItem } from '../models/item';
|
import {IItem} from '../models/item';
|
||||||
import { IItemTask } from '../models/itemTask';
|
import {IItemTask} from '../models/itemTask';
|
||||||
import { HttpClient } from "@angular/common/http";
|
import {HttpClient} from '@angular/common/http';
|
||||||
import { AppConfig } from "../shared/app.config";
|
import {AppConfig} from '../shared/app.config';
|
||||||
import { Observable } from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class PackageService {
|
export class PackageService {
|
||||||
private packages$:IPackages = {};
|
private packages: { [key: string]: IPackage } = {};
|
||||||
|
|
||||||
constructor(private store$: Store<appCommonReducer.State>, public httpClient: HttpClient, public appConfig: AppConfig) {
|
constructor(private store$: Store<appCommonReducer.State>, public httpClient: HttpClient, public appConfig: AppConfig) {
|
||||||
store$.select(appCommonReducer.SelectGetUserPackages).subscribe((packages) => {
|
store$.select(appCommonReducer.SelectGetValidUserPackages).subscribe((packages) => {
|
||||||
this.packages$ = packages;
|
this.packages = packages;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiEndpoint() {
|
ApiEndpoint() {
|
||||||
return this.appConfig.getConfig("apiEndPoint");
|
return this.appConfig.getConfig('apiEndPoint');
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPackage(id:string):boolean {
|
|
||||||
if(!this.packages$[id]) return false;
|
|
||||||
return this.packages$[id].enabled == true;
|
|
||||||
}
|
|
||||||
|
|
||||||
postItemPackageTask(item: IItem, task: IItemTask): Observable<IItemTask> {
|
hasPackage(id: string): boolean {
|
||||||
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
|
return id in this.packages;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
postItemPackageTask(item: IItem, task: IItemTask): Observable<IItemTask> {
|
||||||
|
return this.httpClient.post<IItemTask>(`${this.ApiEndpoint()}/api/v1/items/${item.code}/packagetasks`, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getValidPackages(packageMap: IPackages): {[key: string]: IPackage} {
|
||||||
|
const keys = Object.keys(packageMap);
|
||||||
|
return keys.filter(k => {
|
||||||
|
const packages = packageMap[k]
|
||||||
|
.filter((p) => isValidPackage(p));
|
||||||
|
|
||||||
|
return packages.length > 0;
|
||||||
|
}).reduce((map, key) => {
|
||||||
|
const packages = packageMap[key];
|
||||||
|
const newMap = {...map};
|
||||||
|
newMap[key] = packages.find(p => isValidPackage(p));
|
||||||
|
return newMap;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isValidPackage(pack: IPackage): boolean {
|
||||||
|
const now = new Date(Date.now());
|
||||||
|
const utcToday = Date.UTC(now.getUTCFullYear(),now.getUTCMonth(),now.getUTCDate());
|
||||||
|
return pack !== null && new Date(pack.dataDate).getTime() <= utcToday
|
||||||
|
&& (!pack.dataEndDate || new Date(pack.dataEndDate).getTime() >= utcToday);
|
||||||
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import { IAuthconfigFactory } from './authconfigFactory';
|
|||||||
|
|
||||||
export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthService: OAuthService, authconfigFactory:IAuthconfigFactory,authStorage:OAuthStorage,itemtypeService:ItemTypeService): () => Promise<any> {
|
export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthService: OAuthService, authconfigFactory:IAuthconfigFactory,authStorage:OAuthStorage,itemtypeService:ItemTypeService): () => Promise<any> {
|
||||||
return (): Promise<any> => {
|
return (): Promise<any> => {
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise<void>((resolve,reject) => {
|
||||||
appConfig.load().then(() => {
|
appConfig.load().then(() => {
|
||||||
oauthService.configure(authconfigFactory.getAuthConfig(appConfig));
|
oauthService.configure(authconfigFactory.getAuthConfig(appConfig));
|
||||||
oauthService.setStorage(authStorage);
|
oauthService.setStorage(authStorage);
|
||||||
|
40
projects/common/tsconfig.lib.prod.json
Normal file
40
projects/common/tsconfig.lib.prod.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../out-tsc/lib",
|
||||||
|
"target": "es2015",
|
||||||
|
"module": "es2015",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"importHelpers": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"types": [],
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es2018"
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@angular/*": [
|
||||||
|
|
||||||
|
"node_modules/@angular/*"
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"skipTemplateCodegen": true,
|
||||||
|
"strictMetadataEmit": true,
|
||||||
|
"fullTemplateTypeCheck": true,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"enableResourceInlining": true,
|
||||||
|
"enableIvy": false
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"src/test.ts",
|
||||||
|
"**/*.spec.ts"
|
||||||
|
]
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, UrlSegment } from '@angular/router';
|
import { RouterModule, UrlSegment, ExtraOptions } from '@angular/router';
|
||||||
|
|
||||||
import { AuthGuard, FullScreenGuard } from '@farmmaps/common';
|
import { AuthGuard, FullScreenGuard } from '@farmmaps/common';
|
||||||
//import { MapComponent } from '@farmmaps/common-map';
|
//import { MapComponent } from '@farmmaps/common-map';
|
||||||
@@ -78,7 +78,7 @@ const routes = [
|
|||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(routes,
|
imports: [RouterModule.forRoot(routes,
|
||||||
{ initialNavigation: true })], // , enableTracing: true
|
{ initialNavigation: 'enabledBlocking' })], // , enableTracing: true
|
||||||
exports: [RouterModule]
|
exports: [RouterModule]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule { }
|
export class AppRoutingModule { }
|
||||||
|
@@ -13,7 +13,7 @@ import {AppRootComponent} from './app.component';
|
|||||||
|
|
||||||
import {StoreModule, ActionReducer,MetaReducer} from '@ngrx/store';
|
import {StoreModule, ActionReducer,MetaReducer} from '@ngrx/store';
|
||||||
import {EffectsModule, EffectSources} from '@ngrx/effects';
|
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 {AppRoutingModule} from './app-routing.module';
|
||||||
import { LogoComponent } from './logo/logo.component';
|
import { LogoComponent } from './logo/logo.component';
|
||||||
@@ -76,13 +76,14 @@ export const metaReducers: MetaReducer<any>[] = [debug];
|
|||||||
AppCommonModule,
|
AppCommonModule,
|
||||||
AppCommonServiceModule.forRoot(),
|
AppCommonServiceModule.forRoot(),
|
||||||
BrowserModule,
|
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,
|
strictStateImmutability: false,
|
||||||
strictActionImmutability: false,
|
strictActionImmutability: false,
|
||||||
strictStateSerializability: false,
|
strictStateSerializability: false,
|
||||||
strictActionSerializability: false
|
strictActionSerializability: false
|
||||||
}}),
|
}}),
|
||||||
EffectsModule.forRoot([])
|
StoreRouterConnectingModule.forRoot({stateKey:"router"}),
|
||||||
|
EffectsModule.forRoot([]),
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
AuthConfigFactory,
|
AuthConfigFactory,
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TestComponent } from './landingpage.component';
|
|
||||||
|
|
||||||
describe('TestComponent', () => {
|
|
||||||
let component: TestComponent;
|
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ TestComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { MenuComponent } from './menu.component';
|
|
||||||
|
|
||||||
describe('MenuComponent', () => {
|
|
||||||
let component: MenuComponent;
|
|
||||||
let fixture: ComponentFixture<MenuComponent>;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
declarations: [ MenuComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(MenuComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TestComponent } from './test.component';
|
|
||||||
|
|
||||||
describe('TestComponent', () => {
|
|
||||||
let component: TestComponent;
|
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ TestComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"issuer": "https://accounts.test.farmmaps.eu",
|
"issuer": "http://localhost:8094",
|
||||||
"clientId": "farmmapsdev",
|
"clientId": "farmmapsdev",
|
||||||
"audience": "http://localhost:8082",
|
"audience": "http://localhost:8082/",
|
||||||
"requireHttps": true,
|
"requireHttps": false,
|
||||||
"apiEndPoint": "http://localhost:8082",
|
"apiEndPoint": "http://localhost:8082",
|
||||||
"grantType":"code"
|
"grantType":"code"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user