Compare commits
202 Commits
da562ca96d
...
2022.03
Author | SHA1 | Date | |
---|---|---|---|
|
d8730e77ad | ||
e62c185f35 | |||
f81b16b966 | |||
b9ee39399c | |||
be9b01dbab | |||
feacfd8bb3 | |||
2f0362e730 | |||
|
f4ba89920c | ||
|
f5b312a888 | ||
|
97142bc986 | ||
|
67335a0a4a | ||
|
b752b377da | ||
|
74c77bae5e | ||
|
b22278a75f | ||
|
37854d43fc | ||
|
2161951cbb | ||
66e492d2f8 | |||
e944064053 | |||
a1a4fc14ab | |||
122563a0bd | |||
33f322424e | |||
519b81d1fd | |||
b7c80dfdd8 | |||
|
77d2433d63 | ||
|
9bc78dc302 | ||
ac0fe962a0 | |||
d89670f669 | |||
d025e2e3f6 | |||
|
c22cede59b | ||
|
48574dc0b0 | ||
|
57407d83d3 | ||
|
f83549b5af | ||
|
132556da81 | ||
|
c2350eec52 | ||
aa1ad9f844 | |||
|
c6d14e6c9c | ||
|
8e4364bd08 | ||
|
af3340ed70 | ||
|
cc4726e85c | ||
|
ff19d830a7 | ||
|
29914cfb1b | ||
|
7bca0a57c4 | ||
|
fdba357e9c | ||
|
e28564c88a | ||
|
90c3fa25a4 | ||
|
3b8b812c55 | ||
|
025889b390 | ||
|
eabaa1db19 | ||
|
ba541c4e08 | ||
|
b994bc51cd | ||
|
960275dd38 | ||
|
5b7fef689a | ||
|
1c1315a580 | ||
|
5d21d66589 | ||
|
160eb10aba | ||
|
4ef077f8d7 | ||
|
df84a7c217 | ||
|
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 | ||
fbe0413c6a | |||
115f53e93c | |||
ca40ca0927 | |||
29968a736c | |||
077afcb0d7 | |||
|
6e79afd115 | ||
4f9cdf1588 | |||
fa69dee550 | |||
|
06e353ee94 | ||
8d723477d3 | |||
771e388f0e | |||
|
040b5b8c4d | ||
3504990708 | |||
798ec8d1ca | |||
8f5dd0969c | |||
|
861a8a48fc | ||
86a545d7e6 | |||
|
8a1c4b5e20 | ||
b24e47e39b | |||
c0d8e6d615 | |||
7192f66420 | |||
|
dcc24aa149 | ||
|
0485c163ad | ||
|
1380d7169a | ||
|
a6d3b208b0 | ||
|
cbf805e1ff | ||
|
8907dca091 | ||
|
fe1fddd211 | ||
|
fa146f2c6e | ||
|
c9fac05aa6 | ||
|
75d8909997 | ||
|
36d9c98e47 | ||
|
e2255164fc | ||
|
4c5b77000f | ||
|
997ebb24a7 | ||
00346a963e | |||
a42059627a | |||
|
5b710ce200 | ||
|
f8a0e1e167 | ||
|
eb46b3496a | ||
|
e8bbb74185 | ||
|
3d8ce7ee74 | ||
|
aa308abbb0 | ||
|
9d5cd0fa88 | ||
|
5760c2b8ea | ||
|
1e6c9e9363 | ||
|
8f06a56e52 | ||
|
2f74f43c8e | ||
|
c093ffae50 | ||
|
c7da0866ef | ||
|
b000d5119a | ||
2dd10f04a3 | |||
4d62184e5b | |||
8ad9d56b07 | |||
|
2b1cb1ac8f | ||
|
08163f86bf | ||
|
33adb35923 | ||
|
855bd8fe2d | ||
|
fad257c6e2 | ||
|
e262f7c65d | ||
|
cabdeaa875 | ||
|
2f1c5210ea | ||
|
47f3238edd | ||
|
01488ae2e0 | ||
|
ae02dd0b53 | ||
|
7768387f58 | ||
3c0f220ee3 | |||
38e64a0713 | |||
0bb5406773 | |||
7c125f1771 | |||
3673e0b349 | |||
ece6096064 | |||
|
dd71b49502 | ||
|
a098f72b1a | ||
535f6bd064 | |||
74e7f41583 | |||
b537239c96 | |||
f9ba4fd5e2 | |||
8326255ce9 | |||
3d60d0127b | |||
697708710e | |||
102d96ded9 | |||
|
f802f41bbb | ||
|
d134240b8b | ||
3242058c4f | |||
3f6863845b | |||
|
231fbf9ee8 | ||
|
142a1c9e58 | ||
39993e75da | |||
|
b7b168dffb | ||
|
fb9c11fce6 |
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 --configuration production
|
||||||
|
ng build common-map --configuration production
|
||||||
|
ng build common-map3d --configuration production'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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']])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -8,21 +8,21 @@ pipeline {
|
|||||||
stage('npm install'){
|
stage('npm install'){
|
||||||
steps {
|
steps {
|
||||||
sh '''rm -rf node_modules/
|
sh '''rm -rf node_modules/
|
||||||
npm install
|
npm install --legacy-peer-deps
|
||||||
cd projects/common
|
cd projects/common
|
||||||
npm install
|
npm install --legacy-peer-deps
|
||||||
cd ../common-map
|
cd ../common-map
|
||||||
npm install
|
npm install --legacy-peer-deps
|
||||||
cd ../common-map3d
|
cd ../common-map3d
|
||||||
npm install
|
npm install --legacy-peer-deps
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('build'){
|
stage('build'){
|
||||||
steps {
|
steps {
|
||||||
sh '''ng build common
|
sh '''ng build common --configuration production
|
||||||
ng build common-map
|
ng build common-map --configuration production
|
||||||
ng build common-map3d'''
|
ng build common-map3d --configuration production'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('npm publish'){
|
stage('npm publish'){
|
||||||
|
35
angular.json
35
angular.json
@@ -83,6 +83,31 @@
|
|||||||
"maximumWarning": "6kb"
|
"maximumWarning": "6kb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": false,
|
||||||
|
"sourceMap": true,
|
||||||
|
"namedChunks": true,
|
||||||
|
"extractLicenses": false,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": false,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "7mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -94,8 +119,12 @@
|
|||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"browserTarget": "farmmaps-lib-app:build:production"
|
"browserTarget": "farmmaps-lib-app:build:production"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"browserTarget": "farmmaps-lib-app:build:development"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"defaultConfiguration": "development"
|
||||||
},
|
},
|
||||||
"extract-i18n": {
|
"extract-i18n": {
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
@@ -169,7 +198,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 +238,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"
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
node: {
|
resolve: {
|
||||||
|
fallback: {
|
||||||
// Resolve node module use of fs
|
// Resolve node module use of fs
|
||||||
fs: "empty",
|
fs: "empty",
|
||||||
Buffer: false,
|
Buffer: false,
|
||||||
@@ -7,4 +8,5 @@ module.exports = {
|
|||||||
https: "empty",
|
https: "empty",
|
||||||
zlib: "empty"
|
zlib: "empty"
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
};
|
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 */
|
||||||
|
12911
package-lock.json
generated
12911
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
87
package.json
87
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "farmmaps-lib-app",
|
"name": "farmmaps-lib-app",
|
||||||
"version": "0.0.1",
|
"version": "2.0.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
@@ -11,61 +11,64 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "~10.2.4",
|
"@angular/animations": "~12.2.8",
|
||||||
"@angular/common": "~10.2.4",
|
"@angular/common": "~12.2.8",
|
||||||
"@angular/compiler": "~10.2.4",
|
"@angular/compiler": "~12.2.8",
|
||||||
"@angular/core": "~10.2.4",
|
"@angular/core": "~12.2.8",
|
||||||
"@angular/forms": "~10.2.4",
|
"@angular/forms": "~12.2.8",
|
||||||
"@angular/platform-browser": "~10.2.4",
|
"@angular/platform-browser": "~12.2.8",
|
||||||
"@angular/platform-browser-dynamic": "~10.2.4",
|
"@angular/platform-browser-dynamic": "~12.2.8",
|
||||||
"@angular/router": "~10.2.4",
|
"@angular/router": "~12.2.8",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.517 <0.0.1",
|
"@farmmaps/common": "file:dist/common",
|
||||||
"@farmmaps/common-map": ">=0.0.1-prerelease.517 <0.0.1",
|
"@farmmaps/common-map": "file:dist/common-map",
|
||||||
"@farmmaps/common-map3d": ">=0.0.1-prerelease.517 <0.0.1",
|
"@farmmaps/common-map3d": "file:dist/common-map3d",
|
||||||
"@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": "^12.0",
|
||||||
"@ngrx/router-store": "^10.0",
|
"@ngrx/router-store": "^12.0",
|
||||||
"@ngrx/store": "^10.0",
|
"@ngrx/store": "^12.0",
|
||||||
"angular-oauth2-oidc": "^10.0.3",
|
"angular-oauth2-oidc": "^12.0",
|
||||||
"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",
|
||||||
"ngrx-store-localstorage": "^10.0",
|
"moment": "^2.29.1",
|
||||||
"ngx-bootstrap": "^5.6.1",
|
"ngrx-store-localstorage": "^12.0",
|
||||||
"ngx-openlayers": "1.0.0-next.17",
|
"ngx-avatar": "^4.1.0",
|
||||||
|
"ngx-clipboard": "^14.0.1",
|
||||||
|
"ngx-image-cropper": "^3.3.5",
|
||||||
|
"ngx-openlayers": "1.0.0-next.19",
|
||||||
"ngx-uploadx": "^3.5.1",
|
"ngx-uploadx": "^3.5.1",
|
||||||
"ol": "6.5.0",
|
"ol": "6.8.1",
|
||||||
"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.11.4"
|
||||||
"moment": "^2.27.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/custom-webpack": "~10.0.1",
|
"@angular-builders/custom-webpack": "^12.1.3",
|
||||||
"@angular-devkit/build-angular": "^0.1002.1",
|
"@angular-devkit/build-angular": "^12.2.8",
|
||||||
"@angular-devkit/build-ng-packagr": "~0.1002.1",
|
"@angular/cli": "^12.2.8",
|
||||||
"@angular/cli": "^10.2.1",
|
"@angular/compiler-cli": "~12.2.8",
|
||||||
"@angular/compiler-cli": "~10.2.4",
|
"@angular/language-service": "~12.2.8",
|
||||||
"@angular/language-service": "~10.2.4",
|
"@angular/localize": "^12.2.8",
|
||||||
|
"@types/arcgis-rest-api": "^10.4.5",
|
||||||
"@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": "^12.2.2",
|
||||||
"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.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
"lib": {
|
"lib": {
|
||||||
"entryFile": "src/public-api.ts"
|
"entryFile": "src/public-api.ts"
|
||||||
},
|
},
|
||||||
"whitelistedNonPeerDependencies": [
|
"allowedNonPeerDependencies": [
|
||||||
"."
|
"."
|
||||||
]
|
]
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common-map",
|
"name": "@farmmaps/common-map",
|
||||||
"version": "0.0.1",
|
"version": "2.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
"tslib": "^2.0.0"
|
"tslib": "^2.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/core": "^10.2.4",
|
"@angular/core": "~12.2.8",
|
||||||
"ngrx-store-localstorage": "^10.0",
|
"ngrx-store-localstorage": "^12.0",
|
||||||
"@ngrx/effects": "^10.0",
|
"@ngrx/effects": "^12.0",
|
||||||
"@ngrx/router-store": "^10.0",
|
"@ngrx/router-store":"^12.0",
|
||||||
"@ngrx/store": "^10.0",
|
"@ngrx/store":"^12.0",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.508 <0.0.1",
|
"@farmmaps/common": "~2.0",
|
||||||
"ngx-openlayers": "1.0.0-next.17",
|
"ngx-openlayers": "1.0.0-next.19",
|
||||||
"ol": "6.4.3"
|
"ol": "6.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,15 +2,20 @@ import { Action } from '@ngrx/store';
|
|||||||
|
|
||||||
import { IMapState } from '../models/map.state';
|
import { IMapState } from '../models/map.state';
|
||||||
import { IItemLayer } from '../models/item.layer';
|
import { IItemLayer } from '../models/item.layer';
|
||||||
|
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 } from 'ol';
|
||||||
|
import { Style } from 'ol/style';
|
||||||
|
import { Geometry } from 'ol/geom';
|
||||||
|
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';
|
||||||
@@ -45,6 +50,10 @@ export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher';
|
|||||||
export const CLEAR = '[Map] Clear';
|
export const CLEAR = '[Map] Clear';
|
||||||
export const SETREPLACEURL = '[Map] SetReplaceUrl';
|
export const SETREPLACEURL = '[Map] SetReplaceUrl';
|
||||||
export const SETFEATURES = '[Map] SetFeatures'
|
export const SETFEATURES = '[Map] SetFeatures'
|
||||||
|
export const SETLAYERVALUESLOCATION = '[Map] SetLayerValuesLocation'
|
||||||
|
export const TOGGLELAYERVALUESENABLED = '[Map] ToggleLayerValuesEnabled'
|
||||||
|
export const GETLAYERVALUE = '[Map] GetLayerValue'
|
||||||
|
export const GETLAYERVALUESUCCESS = '[Map] GetLayerValueSuccess'
|
||||||
|
|
||||||
export class Clear implements Action {
|
export class Clear implements Action {
|
||||||
readonly type = CLEAR;
|
readonly type = CLEAR;
|
||||||
@@ -81,6 +90,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;
|
||||||
|
|
||||||
@@ -90,13 +105,13 @@ export class StartSearch implements Action {
|
|||||||
export class StartSearchSuccess implements Action {
|
export class StartSearchSuccess implements Action {
|
||||||
readonly type = STARTSEARCHSUCCESS;
|
readonly type = STARTSEARCHSUCCESS;
|
||||||
|
|
||||||
constructor(public features: Array<Feature>, public query:IQueryState) { }
|
constructor(public features: Array<Feature<Geometry>>, public query:IQueryState) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SelectFeature implements Action {
|
export class SelectFeature implements Action {
|
||||||
readonly type = SELECTFEATURE;
|
readonly type = SELECTFEATURE;
|
||||||
|
|
||||||
constructor(public feature:Feature) { }
|
constructor(public feature:Feature<Geometry>) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SelectItem implements Action {
|
export class SelectItem implements Action {
|
||||||
@@ -138,13 +153,13 @@ export class SelectTemporal implements Action {
|
|||||||
export class AddFeatureSuccess implements Action {
|
export class AddFeatureSuccess implements Action {
|
||||||
readonly type = ADDFEATURESUCCESS;
|
readonly type = ADDFEATURESUCCESS;
|
||||||
|
|
||||||
constructor(public feature: Feature) { }
|
constructor(public feature: Feature<Geometry>) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateFeatureSuccess implements Action {
|
export class UpdateFeatureSuccess implements Action {
|
||||||
readonly type = UPDATEFEATURESUCCESS;
|
readonly type = UPDATEFEATURESUCCESS;
|
||||||
|
|
||||||
constructor(public feature: Feature) { }
|
constructor(public feature: Feature<Geometry>) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ExpandSearch implements Action {
|
export class ExpandSearch implements Action {
|
||||||
@@ -252,13 +267,13 @@ 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 {
|
||||||
readonly type = SETSTYLE;
|
readonly type = SETSTYLE;
|
||||||
|
|
||||||
constructor(public itemType:string,public style: Style | (Feature)) { }
|
constructor(public itemType:string,public style: Style | ((feature:Feature<Geometry>) => Style )) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ShowLayerSwitcher implements Action {
|
export class ShowLayerSwitcher implements Action {
|
||||||
@@ -274,7 +289,31 @@ export class SetReplaceUrl implements Action {
|
|||||||
export class SetFeatures implements Action {
|
export class SetFeatures implements Action {
|
||||||
readonly type = SETFEATURES;
|
readonly type = SETFEATURES;
|
||||||
|
|
||||||
constructor(public features: Array<Feature>) { }
|
constructor(public features: Array<Feature<Geometry>>) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SetLayerValuesLocation implements Action {
|
||||||
|
readonly type = SETLAYERVALUESLOCATION;
|
||||||
|
|
||||||
|
constructor(public x:number, public y:number) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ToggleLayerValuesEnabled implements Action {
|
||||||
|
readonly type = TOGGLELAYERVALUESENABLED;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetLayerValue implements Action {
|
||||||
|
readonly type = GETLAYERVALUE;
|
||||||
|
|
||||||
|
constructor(public itemLayer:IItemLayer,public x:number,public y:number) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetLayerValueSuccess implements Action {
|
||||||
|
readonly type = GETLAYERVALUESUCCESS;
|
||||||
|
|
||||||
|
constructor(public layervalue:ILayervalue) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Actions = SetMapState
|
export type Actions = SetMapState
|
||||||
@@ -315,5 +354,10 @@ export type Actions = SetMapState
|
|||||||
| ShowLayerSwitcher
|
| ShowLayerSwitcher
|
||||||
| SetReplaceUrl
|
| SetReplaceUrl
|
||||||
| SetFeatures
|
| SetFeatures
|
||||||
| SetSelectedItemLayer;
|
| SetSelectedItemLayer
|
||||||
|
| SetLayerValuesLocation
|
||||||
|
| ToggleLayerValuesEnabled
|
||||||
|
| GetLayerValueSuccess
|
||||||
|
| 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
|
||||||
@@ -70,6 +71,8 @@ import {HistogramDetailsComponent} from './components/legend/histogram-details/h
|
|||||||
import {StatisticsDetailsComponent} from './components/legend/statistics-details/statistics-details.component';
|
import {StatisticsDetailsComponent} from './components/legend/statistics-details/statistics-details.component';
|
||||||
import { ifZoomToShowDirective} from './components/if-zoom-to-show/if-zoom-to-show.directive';
|
import { ifZoomToShowDirective} from './components/if-zoom-to-show/if-zoom-to-show.directive';
|
||||||
import { ZoomToShowAlert} from './components/zoom-to-show-alert/zoom-to-show-alert.component';
|
import { ZoomToShowAlert} from './components/zoom-to-show-alert/zoom-to-show-alert.component';
|
||||||
|
import { LayerValuesComponent } from './components/aol/layer-values/layer-values.component';
|
||||||
|
import { GeometryThumbnailComponent } from './components/feature-thumbnail/feature-thumbnail.component';
|
||||||
|
|
||||||
export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any> {
|
export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any> {
|
||||||
const r = function(state, action) {
|
const r = function(state, action) {
|
||||||
@@ -80,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;
|
||||||
@@ -153,7 +164,9 @@ export {
|
|||||||
ITemporalItemLayer,
|
ITemporalItemLayer,
|
||||||
TemporalItemLayer,
|
TemporalItemLayer,
|
||||||
ifZoomToShowDirective,
|
ifZoomToShowDirective,
|
||||||
ZoomToShowAlert
|
ZoomToShowAlert,
|
||||||
|
IClickedFeature,
|
||||||
|
GeometryThumbnailComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -207,7 +220,9 @@ export {
|
|||||||
HistogramDetailsComponent,
|
HistogramDetailsComponent,
|
||||||
StatisticsDetailsComponent,
|
StatisticsDetailsComponent,
|
||||||
ifZoomToShowDirective,
|
ifZoomToShowDirective,
|
||||||
ZoomToShowAlert
|
ZoomToShowAlert,
|
||||||
|
LayerValuesComponent,
|
||||||
|
GeometryThumbnailComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
FeatureListComponent,
|
FeatureListComponent,
|
||||||
@@ -261,7 +276,8 @@ export {
|
|||||||
FeatureListFeatureContainerComponent,
|
FeatureListFeatureContainerComponent,
|
||||||
ZoomToExtentComponent,
|
ZoomToExtentComponent,
|
||||||
ifZoomToShowDirective,
|
ifZoomToShowDirective,
|
||||||
ZoomToShowAlert
|
ZoomToShowAlert,
|
||||||
|
GeometryThumbnailComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
FeatureIconService,
|
FeatureIconService,
|
||||||
|
@@ -4,7 +4,7 @@ import { MapComponent } from 'ngx-openlayers';
|
|||||||
import * as proj from 'ol/proj';
|
import * as proj from 'ol/proj';
|
||||||
import {Point,Geometry} from 'ol/geom';
|
import {Point,Geometry} from 'ol/geom';
|
||||||
import { GeoJSON } from 'ol/format';
|
import { GeoJSON } from 'ol/format';
|
||||||
import { Feature } from 'ol';
|
import { Feature} from 'ol';
|
||||||
|
|
||||||
export interface IDroppedFile {
|
export interface IDroppedFile {
|
||||||
files: any,
|
files: any,
|
||||||
@@ -21,7 +21,7 @@ export class FileDropTargetComponent implements OnInit, OnDestroy {
|
|||||||
element: Element;
|
element: Element;
|
||||||
@Output() onFileDropped = new EventEmitter<IDroppedFile>();
|
@Output() onFileDropped = new EventEmitter<IDroppedFile>();
|
||||||
@Input() parentCode: string;
|
@Input() parentCode: string;
|
||||||
@Input() features: Array<Feature>;
|
@Input() features: Array<Feature<Geometry>>;
|
||||||
|
|
||||||
constructor(private map: MapComponent) {
|
constructor(private map: MapComponent) {
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<stop offset="100%" class="stop2" />
|
<stop offset="100%" class="stop2" />
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
</defs>
|
</defs>
|
||||||
<circle class="tolerance hidden" [class]="{'hidden':!showTolerance}" cx="500" cy="500" stroke="none" [attr.r]="locTolerancePixels" />
|
<circle class="tolerance hidden" [ngClass]="{'hidden':!showTolerance}" cx="500" cy="500" stroke="none" [attr.r]="locTolerancePixels" />
|
||||||
<path class="heading hidden" [class]="{'hidden': !showHeading }" stroke="none" [attr.d]="path" fill="url(#grad1)" [attr.transform]="rotate"></path>
|
<path class="heading hidden" [ngClass]="{'hidden': !showHeading }" stroke="none" [attr.d]="path" fill="url(#grad1)" [attr.transform]="rotate"></path>
|
||||||
<circle class="border" cx="500" cy="500" r="7" stroke="none" />
|
<circle class="border" cx="500" cy="500" r="7" stroke="none" />
|
||||||
<circle class="center" cx="500" cy="500" r="6" stroke="none" />
|
<circle class="center" cx="500" cy="500" r="6" stroke="none" />
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core';
|
import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core';
|
||||||
import { MapComponent } from 'ngx-openlayers';
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
import Overlay from 'ol/Overlay';
|
import Overlay from 'ol/Overlay';
|
||||||
import { fromLonLat, toLonLat } from 'ol/proj';
|
import { fromLonLat, toLonLat } from 'ol/proj';
|
||||||
|
|
||||||
|
|
||||||
@@ -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;
|
||||||
@@ -52,7 +52,7 @@ export class GpsLocation implements OnInit,OnChanges{
|
|||||||
this.rotate = "rotate(" + Math.round(this.heading) + " 500 500)";
|
this.rotate = "rotate(" + Math.round(this.heading) + " 500 500)";
|
||||||
this.locTolerancePixels = this.locationTolerance;
|
this.locTolerancePixels = this.locationTolerance;
|
||||||
this.map.instance.addOverlay(this.instance);
|
this.map.instance.addOverlay(this.instance);
|
||||||
this.map.instance.getView().on('change:resolution', (evt) => {
|
this.map.instance.getView().on('change:resolution', (evt:any) => {
|
||||||
this.resolution = evt.target.get('resolution');
|
this.resolution = evt.target.get('resolution');
|
||||||
this.recalcLocationTolerance();
|
this.recalcLocationTolerance();
|
||||||
});
|
});
|
||||||
@@ -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;
|
||||||
|
@@ -3,19 +3,21 @@ import { LayerGroupComponent, MapComponent } from 'ngx-openlayers';
|
|||||||
import { ItemService,IItem,AppConfig } from '@farmmaps/common';
|
import { ItemService,IItem,AppConfig } from '@farmmaps/common';
|
||||||
import { IItemLayer, ITemporalItemLayer} from '../../../models/item.layer';
|
import { IItemLayer, ITemporalItemLayer} from '../../../models/item.layer';
|
||||||
import { ILayerData} from '../../../models/layer.data';
|
import { ILayerData} from '../../../models/layer.data';
|
||||||
import { IRenderoutputTiles,IRenderoutputImage,IGradientstop,ILayer,IHistogram} from '../../../models/color.map';
|
import { IRenderoutputTiles,IRenderoutputImage,IGradientstop,ILayer,IHistogram,IColor} from '../../../models/color.map';
|
||||||
import {Extent} from 'ol/extent';
|
import {Extent} from 'ol/extent';
|
||||||
import Projection from 'ol/proj/Projection';
|
import Projection from 'ol/proj/Projection';
|
||||||
import * as proj from 'ol/proj';
|
import * as proj from 'ol/proj';
|
||||||
import * as loadingstrategy from 'ol/loadingstrategy';
|
import * as loadingstrategy from 'ol/loadingstrategy';
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
import {Tile,Layer,Image} from 'ol/layer';
|
import {Tile,Layer,Image} from 'ol/layer';
|
||||||
import {XYZ,ImageStatic,OSM,BingMaps,TileWMS,TileArcGISRest,TileJSON} from 'ol/source';
|
import {XYZ,ImageStatic,OSM,BingMaps,TileWMS,TileArcGISRest,TileJSON,Source} from 'ol/source';
|
||||||
import {Vector as VectorSource} from 'ol/source';
|
import {Vector as VectorSource} from 'ol/source';
|
||||||
import { Vector as VectorLayer } from 'ol/layer';
|
import { Vector as VectorLayer } from 'ol/layer';
|
||||||
import VectorTileSource from 'ol/source/VectorTile';
|
import VectorTileSource from 'ol/source/VectorTile';
|
||||||
import VectorTileLayer from 'ol/layer/VectorTile';
|
import VectorTileLayer from 'ol/layer/VectorTile';
|
||||||
import {GeoJSON,MVT} from 'ol/format';
|
import {GeoJSON,MVT} from 'ol/format';
|
||||||
|
import { Geometry } from 'ol/geom';
|
||||||
|
import TileSource from 'ol/source/Tile';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-item-layers',
|
selector: 'fm-map-item-layers',
|
||||||
@@ -34,7 +36,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
private initialized:boolean = false;
|
private initialized:boolean = false;
|
||||||
private mapEventHandlerInstalled = false;
|
private mapEventHandlerInstalled = false;
|
||||||
private selectedFeatures = {};
|
private selectedFeatures = {};
|
||||||
private selectionLayer:Layer = null;
|
private selectionLayer:Layer<Source> = null;
|
||||||
|
|
||||||
constructor(private itemService: ItemService, private map: MapComponent, public appConfig: AppConfig) {
|
constructor(private itemService: ItemService, private map: MapComponent, public appConfig: AppConfig) {
|
||||||
super(map);
|
super(map);
|
||||||
@@ -52,11 +54,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b) + this.componentToHex(a);
|
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b) + this.componentToHex(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
getColorFromGradient(item:IItem,layer: ILayer, feature): style.Style {
|
getColorFromGradient(layer: ILayer, value: number): IColor {
|
||||||
var value = layer.indexKey ? feature.get(layer.indexKey): feature.get(layer.name);
|
var gradient: IGradientstop[] = layer.renderer.colorMap.gradient;
|
||||||
var key = item.code + "_" + value;
|
|
||||||
if(!this.styleCache[key]) {
|
|
||||||
var gradient: IGradientstop[] = layer.renderer.colorMap.gradient;
|
|
||||||
var histogram: IHistogram = layer.renderer.band.histogram;
|
var histogram: IHistogram = layer.renderer.band.histogram;
|
||||||
var index = (value - histogram.min) / histogram.max;
|
var index = (value - histogram.min) / histogram.max;
|
||||||
var min = gradient[0];
|
var min = gradient[0];
|
||||||
@@ -68,34 +67,63 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
var i = index - min.relativestop;
|
var i = index - min.relativestop;
|
||||||
var size = max.relativestop - min.relativestop;
|
var size = max.relativestop - min.relativestop;
|
||||||
var alpha = Math.round( min.color.alpha + ((max.color.alpha - min.color.alpha) * i / size));
|
var alpha = Math.round(min.color.alpha + ((max.color.alpha - min.color.alpha) * i / size));
|
||||||
var red = Math.round(min.color.red + ((max.color.red - min.color.red) * i / size));
|
var red = Math.round(min.color.red + ((max.color.red - min.color.red) * i / size));
|
||||||
var green = Math.round(min.color.green + ((max.color.green - min.color.green) * i / size));
|
var green = Math.round(min.color.green + ((max.color.green - min.color.green) * i / size));
|
||||||
var blue = Math.round(min.color.blue + ((max.color.blue - min.color.blue) * i / size));
|
var blue = Math.round(min.color.blue + ((max.color.blue - min.color.blue) * i / size));
|
||||||
|
|
||||||
this.styleCache[key] = new style.Style(
|
return { alpha: alpha, red: red, green: green, blue: blue };
|
||||||
{
|
}
|
||||||
image: new style.Circle({
|
|
||||||
fill: new style.Fill({
|
getColorForValue(layer: ILayer, value: number): IColor {
|
||||||
color: this.rgbaToHex(red,green,blue,alpha)
|
var color: IColor = { alpha:0,red:0,green:0,blue:0};
|
||||||
|
if(layer.renderer.colorMap.entries.length>0) {
|
||||||
|
color=layer.renderer.colorMap.noValue;
|
||||||
|
}
|
||||||
|
layer.renderer.colorMap.entries.forEach((entry) => {
|
||||||
|
if(entry.value==value) {
|
||||||
|
color =entry.color;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
getColor(item: IItem, layer: ILayer, feature): style.Style {
|
||||||
|
var value = layer.indexKey ? feature.get(layer.indexKey) : feature.get(layer.name);
|
||||||
|
var key = item.code + "_" + value;
|
||||||
|
if (!this.styleCache[key]) {
|
||||||
|
var color: IColor;
|
||||||
|
if(layer.renderer.colorMap.colormapType == "manual") {
|
||||||
|
color = this.getColorForValue(layer, value);
|
||||||
|
} else {
|
||||||
|
color = this.getColorFromGradient(layer, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.styleCache[key] = new style.Style(
|
||||||
|
{
|
||||||
|
image: new style.Circle({
|
||||||
|
fill: new style.Fill({
|
||||||
|
color: this.rgbaToHex(color.red, color.green, color.blue, color.alpha)
|
||||||
|
}),
|
||||||
|
radius: 3
|
||||||
}),
|
}),
|
||||||
radius: 3
|
fill: new style.Fill({
|
||||||
}),
|
color: this.rgbaToHex(color.red, color.green, color.blue, color.alpha)
|
||||||
fill: new style.Fill({
|
}),
|
||||||
color: this.rgbaToHex(red, green, blue, alpha)
|
stroke: new style.Stroke({
|
||||||
}),
|
color: this.rgbaToHex(color.red, color.green, color.blue, 255),
|
||||||
stroke: new style.Stroke({
|
width: 1.25
|
||||||
color: this.rgbaToHex(red, green, blue, 255),
|
}),
|
||||||
width: 1.25
|
});
|
||||||
}),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return this.styleCache[key];
|
return this.styleCache[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer {
|
createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
var layerIndex = -1;
|
||||||
var layer: Layer = null;
|
var layer: Layer<Source> = null;
|
||||||
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index;
|
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index;
|
||||||
let source = new XYZ({ maxZoom: 19, minZoom: 1, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` });
|
let source = new XYZ({ maxZoom: 19, minZoom: 1, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` });
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
@@ -116,9 +144,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer {
|
createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
var layerIndex = -1;
|
||||||
var layer: Layer = null;
|
var layer: Layer<Source> = null;
|
||||||
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index;
|
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index;
|
||||||
var data = item.data;
|
var data = item.data;
|
||||||
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
||||||
@@ -133,7 +161,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
url: `${this._apiEndPoint}/api/v1/items/${item.code}/vectortiles/{z}/{x}/{y}.pbf?v=${Date.parse(item.updated)}`
|
url: `${this._apiEndPoint}/api/v1/items/${item.code}/vectortiles/{z}/{x}/{y}.pbf?v=${Date.parse(item.updated)}`
|
||||||
}),
|
}),
|
||||||
style: (feature) => {
|
style: (feature) => {
|
||||||
return this.getColorFromGradient(item,l, feature);
|
return this.getColor(item,l, feature);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (l && l.rendering && l.rendering.renderoutputType == "Tiles") {
|
} else if (l && l.rendering && l.rendering.renderoutputType == "Tiles") {
|
||||||
@@ -151,7 +179,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
let source = new VectorSource({
|
let source = new VectorSource({
|
||||||
strategy: loadingstrategy.bbox,
|
strategy: loadingstrategy.bbox,
|
||||||
loader: function (extent: Extent, resolution: number, projection: Projection) {
|
loader: function (extent: Extent, resolution: number, projection: Projection) {
|
||||||
var source = this as VectorSource;
|
var source = this as VectorSource<Geometry>;
|
||||||
__this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) {
|
__this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) {
|
||||||
var features = format.readFeatures(data);
|
var features = format.readFeatures(data);
|
||||||
for (let f of features) {
|
for (let f of features) {
|
||||||
@@ -204,16 +232,16 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
createSelectionLayer(itemLayer:IItemLayer):Layer {
|
createSelectionLayer(itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
var layerIndex = -1;
|
||||||
var layer: Layer = null;
|
var layer: Layer<Source> = null;
|
||||||
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : itemLayer.item.data.layers[0].index;
|
layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : itemLayer.item.data.layers[0].index;
|
||||||
var data = itemLayer.item.data;
|
var data = itemLayer.item.data;
|
||||||
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
||||||
if (l && l.rendering && l.rendering.renderoutputType == "VectorTiles") {
|
if (l && l.rendering && l.rendering.renderoutputType == "VectorTiles") {
|
||||||
return new VectorTileLayer({
|
return new VectorTileLayer({
|
||||||
renderMode: 'vector',
|
renderMode: 'vector',
|
||||||
source: itemLayer.layer.getSource(),
|
source: (itemLayer.layer as VectorTileLayer).getSource(),
|
||||||
style: (feature) => {
|
style: (feature) => {
|
||||||
if (feature.getId() in this.selectedFeatures) {
|
if (feature.getId() in this.selectedFeatures) {
|
||||||
|
|
||||||
@@ -234,9 +262,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer {
|
createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
let data = item.data as ILayerData;
|
let data = item.data as ILayerData;
|
||||||
var layer: Layer = null;
|
var layer: Layer<Source> = null;
|
||||||
switch (data.interfaceType) {
|
switch (data.interfaceType) {
|
||||||
case 'OSM': {
|
case 'OSM': {
|
||||||
let source = new OSM();
|
let source = new OSM();
|
||||||
@@ -286,8 +314,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
createLayer(itemLayer: IItemLayer): Layer {
|
createLayer(itemLayer: IItemLayer): Layer<Source> {
|
||||||
var layer: Layer = null;
|
var layer: Layer<Source> = null;
|
||||||
var layerIndex = -1;
|
var layerIndex = -1;
|
||||||
if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.geotiff.processed') {
|
if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.geotiff.processed') {
|
||||||
layer = this.createGeotiffLayer(itemLayer.item,itemLayer);
|
layer = this.createGeotiffLayer(itemLayer.item,itemLayer);
|
||||||
@@ -334,7 +362,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer {
|
addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer<Source> {
|
||||||
if(!itemLayer) return null;
|
if(!itemLayer) return null;
|
||||||
var olLayers = this.instance.getLayers();
|
var olLayers = this.instance.getLayers();
|
||||||
var layer = itemLayer.layer;
|
var layer = itemLayer.layer;
|
||||||
@@ -359,7 +387,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLayers(itemLayers: IItemLayer[]) {
|
updateLayers(itemLayers: IItemLayer[]) {
|
||||||
let newLayers: IItemLayer[] = [];
|
let newLayers: Layer<Source>[] = [];
|
||||||
if (itemLayers) {
|
if (itemLayers) {
|
||||||
itemLayers.forEach((itemLayer, index) => {
|
itemLayers.forEach((itemLayer, index) => {
|
||||||
if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
import { Component, Host, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, forwardRef, Inject, InjectionToken } from '@angular/core';
|
import { Component, Host, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, forwardRef, Inject, InjectionToken } from '@angular/core';
|
||||||
import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ngx-openlayers';
|
import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ngx-openlayers';
|
||||||
import { ItemService,ItemTypeService,IItem, IItemType } from '@farmmaps/common';
|
import { ItemService,ItemTypeService,IItem, IItemType } from '@farmmaps/common';
|
||||||
|
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
import { Point } from 'ol/geom';
|
import { Point,Geometry } from 'ol/geom';
|
||||||
import { MapBrowserEvent } from 'ol';
|
import { MapBrowserEvent } from 'ol';
|
||||||
|
import { Types } from 'ol/MapBrowserEventType';
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
import * as color from 'ol/color';
|
import * as color from 'ol/color';
|
||||||
import * as loadingstrategy from 'ol/loadingstrategy';
|
import * as loadingstrategy from 'ol/loadingstrategy';
|
||||||
import * as condition from 'ol/events/condition';
|
import * as condition from 'ol/events/condition';
|
||||||
import * as extent from 'ol/extent';
|
import * as extent from 'ol/extent';
|
||||||
import {Vector,Cluster} from 'ol/source';
|
import {Vector,Cluster,Source} from 'ol/source';
|
||||||
import {Layer} from 'ol/layer';
|
import {Layer} from 'ol/layer';
|
||||||
import {GeoJSON} from 'ol/format';
|
import {GeoJSON} from 'ol/format';
|
||||||
import {Select} from 'ol/interaction';
|
import {Select} from 'ol/interaction';
|
||||||
@@ -25,17 +26,17 @@ import {FeatureIconService} from '../../../services/feature-icon.service';
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges {
|
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges {
|
||||||
instance: Vector;
|
instance: Vector<Geometry>;
|
||||||
private _format: GeoJSON;
|
private _format: GeoJSON;
|
||||||
private _select: Select;
|
private _select: Select;
|
||||||
private _hoverSelect: Select;
|
private _hoverSelect: Select;
|
||||||
private _iconScale: number = 0.05;
|
private _iconScale: number = 0.05;
|
||||||
@Input() features: Array<Feature>;
|
@Input() features: Array<Feature<Geometry>>;
|
||||||
@Input() selectedFeature: Feature;
|
@Input() selectedFeature: Feature<Geometry>;
|
||||||
@Input() selectedItem: IItem;
|
@Input() selectedItem: IItem;
|
||||||
@Input() styles:IStyles;
|
@Input() styles:IStyles;
|
||||||
@Output() onFeatureSelected: EventEmitter<Feature> = new EventEmitter<Feature>();
|
@Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
||||||
@Output() onFeatureHover: EventEmitter<Feature> = new EventEmitter<Feature>();
|
@Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
||||||
private stylesCache:IStyles = {};
|
private stylesCache:IStyles = {};
|
||||||
|
|
||||||
constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) {
|
constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) {
|
||||||
@@ -43,7 +44,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
this._format = new GeoJSON();
|
this._format = new GeoJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry(feature: Feature) {
|
geometry(feature: Feature<Geometry>) {
|
||||||
let view = this.map.instance.getView();
|
let view = this.map.instance.getView();
|
||||||
let resolution = view.getResolution();
|
let resolution = view.getResolution();
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
@@ -55,9 +56,9 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedStyle(feature:Feature):style.Style {
|
getSelectedStyle(feature:Feature<Geometry>):style.Style {
|
||||||
let key = feature.get('itemType')+"_selected";
|
let key = feature.get('itemType')+"_selected";
|
||||||
let evaluatedStyle =null;
|
let evaluatedStyle: style.Style =undefined;
|
||||||
var styleEntry = this.stylesCache[key];
|
var styleEntry = this.stylesCache[key];
|
||||||
if(styleEntry) {
|
if(styleEntry) {
|
||||||
if(typeof styleEntry === 'function') {
|
if(typeof styleEntry === 'function') {
|
||||||
@@ -66,12 +67,12 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
evaluatedStyle = styleEntry;
|
evaluatedStyle = styleEntry;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
evaluatedStyle = this.stylesCache["selected"];
|
evaluatedStyle = this.stylesCache["selected"] as style.Style;
|
||||||
}
|
}
|
||||||
if(evaluatedStyle ) {
|
if(evaluatedStyle ) {
|
||||||
evaluatedStyle.setGeometry((feature) => this.geometry(feature));
|
evaluatedStyle .setGeometry((feature:Feature<Geometry>) => this.geometry(feature));
|
||||||
}
|
}
|
||||||
return evaluatedStyle
|
return evaluatedStyle as style.Style
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -80,17 +81,17 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
this._select = new Select({
|
this._select = new Select({
|
||||||
style:null,
|
style:null,
|
||||||
hitTolerance: 10,
|
hitTolerance: 10,
|
||||||
layers: [this.layer.instance as Layer]
|
layers: [this.layer.instance as Layer<Source>]
|
||||||
});
|
});
|
||||||
this._hoverSelect = new Select({
|
this._hoverSelect = new Select({
|
||||||
style: (feature) => {
|
style: (feature:Feature<Geometry>) => {
|
||||||
return this.getSelectedStyle(feature);
|
return this.getSelectedStyle(feature);
|
||||||
},
|
},
|
||||||
hitTolerance: 10,
|
hitTolerance: 10,
|
||||||
condition: (e: MapBrowserEvent) => {
|
condition: (e: MapBrowserEvent<UIEvent>) => {
|
||||||
return e.type == 'pointermove';
|
return e.type == 'pointermove';
|
||||||
},
|
},
|
||||||
layers: [this.layer.instance as Layer]
|
layers: [this.layer.instance as Layer<Source>]
|
||||||
});
|
});
|
||||||
this.map.instance.addInteraction(this._select);
|
this.map.instance.addInteraction(this._select);
|
||||||
this.map.instance.addInteraction(this._hoverSelect);
|
this.map.instance.addInteraction(this._hoverSelect);
|
||||||
@@ -112,17 +113,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',
|
||||||
@@ -131,7 +133,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
fill: new style.Fill({
|
fill: new style.Fill({
|
||||||
color: fillColor
|
color: fillColor
|
||||||
}),
|
}),
|
||||||
geometry:(feature) => this.geometry(feature)
|
geometry:(feature:Feature<Geometry>) => this.geometry(feature)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
key = 'file';
|
key = 'file';
|
||||||
|
@@ -13,11 +13,11 @@
|
|||||||
</span>
|
</span>
|
||||||
<a href="#" title="Zoom to extent" class="btn btn-light btn-sm" (click)="handleZoomToExtent($event,itemLayer)"><i class="far fa-search-plus" aria-hidden="true"></i></a>
|
<a href="#" title="Zoom to extent" class="btn btn-light btn-sm" (click)="handleZoomToExtent($event,itemLayer)"><i class="far fa-search-plus" aria-hidden="true"></i></a>
|
||||||
<span *ngIf="firstLayer(itemLayer)"><a href="#" title="Toggle legend" class="btn btn-light btn-sm" (click)="itemLayer.legendVisible=toggleLegend($event,itemLayer.legendVisible)"><i class="far fa-chart-bar" aria-hidden="true"></i></a></span>
|
<span *ngIf="firstLayer(itemLayer)"><a href="#" title="Toggle legend" class="btn btn-light btn-sm" (click)="itemLayer.legendVisible=toggleLegend($event,itemLayer.legendVisible)"><i class="far fa-chart-bar" aria-hidden="true"></i></a></span>
|
||||||
<span class="float-right"><a href="#" title="Remove overlay" class="btn btn-light btn-sm" (click)="handleDelete($event,itemLayer)"><i class="fas fa-layer-minus" aria-hidden="true"></i></a></span>
|
<span *ngIf="!dataLayers" class="float-right"><a href="#" title="Remove overlay" class="btn btn-light btn-sm" (click)="handleDelete($event,itemLayer)"><i class="fas fa-layer-minus" aria-hidden="true"></i></a></span>
|
||||||
</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>
|
||||||
|
@@ -10,6 +10,7 @@ import { IItemLayer } from '../../../models/item.layer';
|
|||||||
export class LayerListComponent {
|
export class LayerListComponent {
|
||||||
@Input() itemLayers: IItemLayer[] = [];
|
@Input() itemLayers: IItemLayer[] = [];
|
||||||
@Input() baseLayers: boolean = false;
|
@Input() baseLayers: boolean = false;
|
||||||
|
@Input() dataLayers: boolean = false;
|
||||||
@Output() onToggleVisibility = new EventEmitter<IItemLayer>();
|
@Output() onToggleVisibility = new EventEmitter<IItemLayer>();
|
||||||
@Output() onSetOpacity = new EventEmitter<{layer: IItemLayer,opacity:number }>();
|
@Output() onSetOpacity = new EventEmitter<{layer: IItemLayer,opacity:number }>();
|
||||||
@Output() onDelete = new EventEmitter<IItemLayer>();
|
@Output() onDelete = new EventEmitter<IItemLayer>();
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
<div #layerValues class="layer-values">
|
||||||
|
<div class="cross" *ngIf="enabled$ | async">
|
||||||
|
<div class="pointer"></div>
|
||||||
|
<div class="values-container border border-dark rounded p-2" *ngIf="(layerValues$ | async ) as layers">
|
||||||
|
<div class="lonlat pb-2 "><span class="font-weight-bold">{{lonlat$}}</span><i class="ml-2 fal fa-copy" (click)="copyToClipboard()"></i> </div>
|
||||||
|
<ul class="value-list p-0 mb-0" *ngIf="layers.length>0 ;else no_data">
|
||||||
|
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||||
|
<div>{{layerValue.layerName}}</div>
|
||||||
|
<div>{{layerValue.date|date}}</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>
|
||||||
|
</ul>
|
||||||
|
<ng-template #no_data>
|
||||||
|
<div i18n class="border-top pt-1 pb-1">No data at location</div>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>>
|
@@ -0,0 +1,37 @@
|
|||||||
|
.layer-values {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cross {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
left: -0.5em;
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.values-container {
|
||||||
|
position: relative;
|
||||||
|
background-color: white;
|
||||||
|
left: calc( 1em - 1px);
|
||||||
|
top: -1.3em;
|
||||||
|
min-width: 15em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value-list {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pointer {
|
||||||
|
position: relative;
|
||||||
|
width: 0px;
|
||||||
|
height: 0px;
|
||||||
|
left: 0.5em;
|
||||||
|
border-top: 0.5em solid transparent;
|
||||||
|
border-bottom: 0.5em solid transparent;
|
||||||
|
border-right: 0.5em solid black;
|
||||||
|
}
|
||||||
|
|
@@ -1,20 +1,20 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { AppMenuComponent } from './app-menu.component';
|
import { LayerValuesComponent } from './layer-values.component';
|
||||||
|
|
||||||
describe('AppMenuComponent', () => {
|
describe('LayerValuesComponent', () => {
|
||||||
let component: AppMenuComponent;
|
let component: LayerValuesComponent;
|
||||||
let fixture: ComponentFixture<AppMenuComponent>;
|
let fixture: ComponentFixture<LayerValuesComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ AppMenuComponent ]
|
declarations: [ LayerValuesComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(AppMenuComponent);
|
fixture = TestBed.createComponent(LayerValuesComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
@@ -0,0 +1,62 @@
|
|||||||
|
import { Component, OnInit,Input,ViewChild,ElementRef,AfterViewInit } from '@angular/core';
|
||||||
|
import {IItemLayer} from '../../../models/item.layer';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import * as mapReducers from '../../../reducers/map.reducer';
|
||||||
|
import * as mapActions from '../../../actions/map.actions';
|
||||||
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
|
import { ILayervalue } from '../../../models/layer.value';
|
||||||
|
import { Observable,interval,Subject } from 'rxjs';
|
||||||
|
import { debounce, throttle } from 'rxjs/operators';
|
||||||
|
import { toLonLat } from 'ol/proj';
|
||||||
|
import { toStringHDMS } from 'ol/coordinate';
|
||||||
|
import { ClipboardService } from 'ngx-clipboard'
|
||||||
|
import {GeoJSON,WKT} from 'ol/format';
|
||||||
|
import { Point } from 'ol/geom';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-map-layer-values',
|
||||||
|
templateUrl: './layer-values.component.html',
|
||||||
|
styleUrls: ['./layer-values.component.scss']
|
||||||
|
})
|
||||||
|
export class LayerValuesComponent implements OnInit,AfterViewInit {
|
||||||
|
|
||||||
|
@ViewChild('layerValues') containerRef:ElementRef;
|
||||||
|
offsetX$:number =0;
|
||||||
|
offsetY$:number =0;
|
||||||
|
lonlat$: string="";
|
||||||
|
wkt$= "";
|
||||||
|
layerValues$:Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||||
|
enabled$:Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||||
|
wktFormat$:WKT;
|
||||||
|
|
||||||
|
constructor( private store: Store<mapReducers.State>,private map: MapComponent,private clipboardService$:ClipboardService) {
|
||||||
|
this.wktFormat$=new WKT();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
moveEndSubject = new Subject<any>();
|
||||||
|
|
||||||
|
ngAfterViewInit():void {
|
||||||
|
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
||||||
|
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
||||||
|
this.map.instance.on('moveend', () => {
|
||||||
|
this.moveEndSubject.next({});
|
||||||
|
});
|
||||||
|
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateValuesLocation() {
|
||||||
|
var xy = this.map.instance.getCoordinateFromPixel([this.offsetX$,this.offsetY$])
|
||||||
|
var lonlat = toLonLat(xy);
|
||||||
|
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
||||||
|
this.lonlat$ = toStringHDMS(lonlat);
|
||||||
|
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0],xy[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
copyToClipboard() {
|
||||||
|
this.clipboardService$.copy(this.wkt$);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,9 +1,8 @@
|
|||||||
import { Component, OnDestroy, OnInit, Input, Optional, OnChanges, SimpleChanges } from '@angular/core';
|
import { Component, OnDestroy, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { Vector } from 'ol/layer';
|
import { LayerVectorComponent, MapComponent } from 'ngx-openlayers';
|
||||||
import { Style } from 'ol/style';
|
import RenderType from 'ol/layer/Vector';
|
||||||
import { StyleFunction } from 'ol/style/Style';
|
import { Vector as VectorSource } from 'ol/source';
|
||||||
import { LayerVectorComponent, LayerGroupComponent, MapComponent } from 'ngx-openlayers';
|
import { Geometry } from 'ol/geom';
|
||||||
import { RenderType } from 'ol/layer/Vector';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-aol-layer-vector-image',
|
selector: 'fm-map-aol-layer-vector-image',
|
||||||
@@ -12,10 +11,10 @@ import { RenderType } from 'ol/layer/Vector';
|
|||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class LayerVectorImageComponent extends LayerVectorComponent implements OnInit, OnDestroy, OnChanges {
|
export class LayerVectorImageComponent extends LayerVectorComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
public source: Vector;
|
//public source: Vector;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
renderMode: RenderType | string = "image";
|
renderMode: RenderType<VectorSource<Geometry>> | string = "image";
|
||||||
|
|
||||||
constructor(map: MapComponent) {
|
constructor(map: MapComponent) {
|
||||||
super(map);
|
super(map);
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject} from '@angular/core';
|
import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject} from '@angular/core';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import { Geometry} from 'ol/geom';
|
||||||
import { FeatureListComponent,AbstractFeatureListComponent } from '../feature-list/feature-list.component';
|
import { FeatureListComponent,AbstractFeatureListComponent } from '../feature-list/feature-list.component';
|
||||||
import { WidgetHostDirective } from '../widget-host/widget-host.directive';
|
import { WidgetHostDirective } from '../widget-host/widget-host.directive';
|
||||||
import {IQueryState,PackageService } from '@farmmaps/common';
|
import {IQueryState,PackageService } from '@farmmaps/common';
|
||||||
@@ -20,10 +21,10 @@ export class FeatureListContainerComponent {
|
|||||||
this.featureLists = [...this.featureLists].reverse();
|
this.featureLists = [...this.featureLists].reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input() features: Array<Feature>
|
@Input() features: Array<Feature<Geometry>>
|
||||||
@Input() queryState: IQueryState;
|
@Input() queryState: IQueryState;
|
||||||
@Input() selectedFeature: Feature;
|
@Input() selectedFeature: Feature<Geometry>;
|
||||||
@Input() clickedFeature:Observable<Feature>;
|
@Input() clickedFeature:Observable<Feature<Geometry>>;
|
||||||
|
|
||||||
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
||||||
componentRef:any;
|
componentRef:any;
|
||||||
@@ -38,7 +39,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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<div class="card border-0">
|
<div class="card border-0">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<fm-back-button></fm-back-button>
|
<fm-back-button></fm-back-button>
|
||||||
<h3><i class="fm fm-farm"></i> <span i18n>Farms</span></h3>
|
<h3><i class="far fa-farm"></i> <span i18n>Farms</span></h3>
|
||||||
<div *ngIf="features;let features">
|
<div *ngIf="features;let features">
|
||||||
<div class="farms">
|
<div class="farms">
|
||||||
<div class="row m-0 pl-3 pr-3" *ngFor="let feature of features"[ngClass]="{'selected':isFeatureSelected(feature)}" (click)="handleFeatureClick(feature)" (mouseenter)="handleFeatureMouseEnter(feature)" (mouseleave)="handleFeatureMouseLeave(feature)">
|
<div class="row m-0 pl-3 pr-3" *ngFor="let feature of features"[ngClass]="{'selected':isFeatureSelected(feature)}" (click)="handleFeatureClick(feature)" (mouseenter)="handleFeatureMouseEnter(feature)" (mouseleave)="handleFeatureMouseLeave(feature)">
|
||||||
|
@@ -9,6 +9,7 @@ import * as mapActions from '../../actions/map.actions';
|
|||||||
import { tassign } from 'tassign';
|
import { tassign } from 'tassign';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import { Geometry} from 'ol/geom';
|
||||||
|
|
||||||
@ForItemType("vnd.farmmaps.itemtype.croppingscheme")
|
@ForItemType("vnd.farmmaps.itemtype.croppingscheme")
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -23,7 +24,7 @@ export class FeatureListCroppingschemeComponent extends AbstractFeatureListCompo
|
|||||||
super(store, itemTypeService, location);
|
super(store, itemTypeService, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAction(feature:Feature):Action {
|
getAction(feature:Feature<Geometry>):Action {
|
||||||
var queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" });
|
var queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" });
|
||||||
return new mapActions.DoQuery(queryState);
|
return new mapActions.DoQuery(queryState);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core';
|
import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import { Geometry } from 'ol/geom';
|
||||||
import { AbstractFeatureListFeatureComponent,FeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component';
|
import { AbstractFeatureListFeatureComponent,FeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component';
|
||||||
import { WidgetHostDirective } from '../widget-host/widget-host.directive';
|
import { WidgetHostDirective } from '../widget-host/widget-host.directive';
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ export class FeatureListFeatureContainerComponent {
|
|||||||
this.featureLists = [...this.featureLists].reverse();
|
this.featureLists = [...this.featureLists].reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input() feature: Feature;
|
@Input() feature: Feature<Geometry>;
|
||||||
|
|
||||||
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
||||||
|
|
||||||
@@ -32,7 +33,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,12 +1,14 @@
|
|||||||
<div *ngIf="feature;let feature" class="d-flex m-0">
|
<div *ngIf="feature;let feature" class="d-flex m-0">
|
||||||
<div class="p-2">
|
<div class="p-2">
|
||||||
<div #container class="thumbnail">
|
<div class="thumbnail">
|
||||||
<canvas #canvas ></canvas>
|
<fm-map-feature-thumbnail [feature]="feature"></fm-map-feature-thumbnail>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow p-2 overflow-hidden">
|
<div class="flex-grow p-2 overflow-hidden">
|
||||||
<h1 class="card-title" title="{{feature.get('name')}}">{{feature.get('name')}}</h1>
|
<h1 class="card-title" title="{{feature.get('name')}}">{{feature.get('name')}}</h1>
|
||||||
<div class="card-text"><span>{{areaInHa(feature)| number:'1.2-2'}} ha</span> <span>{{feature.get('cropTypeName')}}</span> </div>
|
<div class="card-text"><span>{{areaInHa(feature)| number:'1.2-2'}}
|
||||||
<div class="card-text"><span>{{feature.get('datadate')|date}}</span> - <span>{{feature.get('dataenddate')|date}}</span> </div>
|
ha</span> <span>{{feature.get('cropTypeName')}}</span> </div>
|
||||||
|
<div class="card-text"><span>{{feature.get('datadate')|date}}</span> -
|
||||||
|
<span>{{feature.get('dataenddate')|date}}</span> </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@@ -1,14 +1,13 @@
|
|||||||
import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core';
|
import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
import * as extent from 'ol/extent';
|
import { Geometry } from 'ol/geom';
|
||||||
import * as render from 'ol/render';
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import * as mapReducers from '../../reducers/map.reducer';
|
import * as mapReducers from '../../reducers/map.reducer';
|
||||||
import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
||||||
import { AbstractFeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component';
|
import { AbstractFeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component';
|
||||||
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
||||||
import {getArea} from 'ol/sphere';
|
import {getArea} from 'ol/sphere';
|
||||||
import * as style from 'ol/style';
|
|
||||||
|
|
||||||
|
|
||||||
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
@ForItemType("vnd.farmmaps.itemtype.cropfield")
|
||||||
@@ -18,58 +17,18 @@ import * as style from 'ol/style';
|
|||||||
templateUrl: './feature-list-feature-cropfield.component.html',
|
templateUrl: './feature-list-feature-cropfield.component.html',
|
||||||
styleUrls: ['./feature-list-feature-cropfield.component.scss']
|
styleUrls: ['./feature-list-feature-cropfield.component.scss']
|
||||||
})
|
})
|
||||||
export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFeatureComponent implements AfterViewInit {
|
export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFeatureComponent {
|
||||||
|
|
||||||
@ViewChild('canvas') canvas;
|
|
||||||
@ViewChild('container') container;
|
|
||||||
|
|
||||||
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,config:AppConfig) {
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,config:AppConfig) {
|
||||||
super(store, itemTypeService,config);
|
super(store, itemTypeService,config);
|
||||||
}
|
}
|
||||||
|
|
||||||
areaInHa(feature:Feature):number {
|
areaInHa(feature:Feature<Geometry>):number {
|
||||||
if(!feature) return 0;
|
if(!feature) return 0;
|
||||||
// get area from faeture if 0 calculate from polygon
|
// get area from faeture if 0 calculate from polygon
|
||||||
let a = feature.get('area');
|
let a = feature.get('area');
|
||||||
if(a) return a;
|
if(a) return a;
|
||||||
return getArea(feature.getGeometry(),{projectio:"EPSG:3857"}) / 10000;
|
return getArea(feature.getGeometry(),{projection:"EPSG:3857"}) / 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
render(canvas,width,height,feature:Feature) {
|
|
||||||
let renderContext = render.toContext(canvas.getContext( '2d'),{ size: [width, height] });
|
|
||||||
|
|
||||||
let strokeStyle = new style.Style({
|
|
||||||
stroke: new style.Stroke({ color: 'black',width:1.5 })
|
|
||||||
});
|
|
||||||
|
|
||||||
let geom = feature.getGeometry().clone(),
|
|
||||||
line = geom.getCoordinates()[0],
|
|
||||||
e = extent.boundingExtent( line );
|
|
||||||
|
|
||||||
let dxy = extent.getCenter(e),
|
|
||||||
sxy = [
|
|
||||||
(width - 2 ) / extent.getWidth(e),
|
|
||||||
(height - 2 ) / extent.getHeight(e)
|
|
||||||
];
|
|
||||||
|
|
||||||
let dx = dxy[0],
|
|
||||||
dy = dxy[1],
|
|
||||||
sx = sxy[0],
|
|
||||||
sy = sxy[1];
|
|
||||||
|
|
||||||
geom.translate( -dx, -dy );
|
|
||||||
geom.scale( Math.min(sx, sy), -Math.min(sx, sy));
|
|
||||||
geom.translate( width / 2, height / 2 );
|
|
||||||
|
|
||||||
renderContext.setStyle( strokeStyle );
|
|
||||||
renderContext.drawGeometry( geom );
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit() {
|
|
||||||
this.render(this.canvas.nativeElement,
|
|
||||||
this.container.nativeElement.offsetWidth,
|
|
||||||
this.container.nativeElement.offsetHeight,
|
|
||||||
this.feature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { Component, Input, Injectable,Directive} from '@angular/core';
|
import { Component, Input, Injectable,Directive} from '@angular/core';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import { Geometry } from 'ol/geom';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import * as mapReducers from '../../reducers/map.reducer';
|
import * as mapReducers from '../../reducers/map.reducer';
|
||||||
import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
||||||
@@ -9,7 +10,7 @@ import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
@Directive()
|
@Directive()
|
||||||
export abstract class AbstractFeatureListFeatureComponent {
|
export abstract class AbstractFeatureListFeatureComponent {
|
||||||
@Input() feature: Feature
|
@Input() feature: Feature<Geometry>
|
||||||
|
|
||||||
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService,public config:AppConfig) {
|
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService,public config:AppConfig) {
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { Component, Input, Injectable,Directive,SimpleChanges } from '@angular/core';
|
import { Component, Input, Injectable,Directive,SimpleChanges } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
import { Geometry} from 'ol/geom';
|
||||||
import { Store,Action} from '@ngrx/store';
|
import { Store,Action} from '@ngrx/store';
|
||||||
import * as mapReducers from '../../reducers/map.reducer';
|
import * as mapReducers from '../../reducers/map.reducer';
|
||||||
import { commonReducers,ItemTypeService, IItem, Item } from '@farmmaps/common';
|
import { commonReducers,ItemTypeService, IItem, Item } from '@farmmaps/common';
|
||||||
@@ -14,20 +15,20 @@ import { IQueryState } from '@farmmaps/common';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
@Directive()
|
@Directive()
|
||||||
export abstract class AbstractFeatureListComponent {
|
export abstract class AbstractFeatureListComponent {
|
||||||
@Input() features: Array<Feature>;
|
@Input() features: Array<Feature<Geometry>>;
|
||||||
@Input() queryState: IQueryState;
|
@Input() queryState: IQueryState;
|
||||||
@Input() selectedFeature: Feature;
|
@Input() selectedFeature: Feature<Geometry>;
|
||||||
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService, private location: Location) {
|
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService, private location: Location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFeatureClick(feature:Feature) {
|
handleFeatureClick(feature:Feature<Geometry>) {
|
||||||
if(feature) {
|
if(feature) {
|
||||||
let action = this.getAction(feature);
|
let action = this.getAction(feature);
|
||||||
this.store.dispatch(action);
|
this.store.dispatch(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAction(feature:Feature):Action {
|
getAction(feature:Feature<Geometry>):Action {
|
||||||
var newQuery: any = tassign(mapReducers.initialState.queryState);
|
var newQuery: any = tassign(mapReducers.initialState.queryState);
|
||||||
newQuery.parentCode = feature.get('parentCode');
|
newQuery.parentCode = feature.get('parentCode');
|
||||||
newQuery.itemCode = feature.get('code');
|
newQuery.itemCode = feature.get('code');
|
||||||
@@ -48,7 +49,7 @@ export abstract class AbstractFeatureListComponent {
|
|||||||
this.location.back();
|
this.location.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
isFeatureSelected(feature:Feature):boolean {
|
isFeatureSelected(feature:Feature<Geometry>):boolean {
|
||||||
if(!this.selectedFeature) return false;
|
if(!this.selectedFeature) return false;
|
||||||
return feature.getId() == this.selectedFeature.getId();
|
return feature.getId() == this.selectedFeature.getId();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
<div #container class="container">
|
||||||
|
<canvas #canvas ></canvas>
|
||||||
|
</div>
|
||||||
|
|
@@ -0,0 +1,5 @@
|
|||||||
|
.container {
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
@@ -1,20 +1,20 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TestComponent } from './landingpage.component';
|
import { GeometryThumbnailComponent } from './feature-thumbnail.component';
|
||||||
|
|
||||||
describe('TestComponent', () => {
|
describe('GeometryThumbnailComponent', () => {
|
||||||
let component: TestComponent;
|
let component: GeometryThumbnailComponent;
|
||||||
let fixture: ComponentFixture<TestComponent>;
|
let fixture: ComponentFixture<GeometryThumbnailComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ TestComponent ]
|
declarations: [ GeometryThumbnailComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(GeometryThumbnailComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
@@ -0,0 +1,95 @@
|
|||||||
|
import { Component, Input, AfterViewInit, ViewChild } from '@angular/core';
|
||||||
|
import { Feature} from 'ol';
|
||||||
|
import { Geometry,Polygon,MultiPolygon } from 'ol/geom';
|
||||||
|
import * as extent from 'ol/extent';
|
||||||
|
import * as render from 'ol/render';
|
||||||
|
import * as style from 'ol/style';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-map-feature-thumbnail',
|
||||||
|
templateUrl: './feature-thumbnail.component.html',
|
||||||
|
styleUrls: ['./feature-thumbnail.component.scss']
|
||||||
|
})
|
||||||
|
export class GeometryThumbnailComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
@ViewChild('canvas') canvas;
|
||||||
|
@ViewChild('container') container;
|
||||||
|
|
||||||
|
private geometry:Geometry = null;
|
||||||
|
@Input() set feature(value:Feature<Geometry>) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private width:number = 0;
|
||||||
|
private height:number = 0;
|
||||||
|
|
||||||
|
render(canvas,style:style.Style,geometry:Geometry,width:number,height:number) {
|
||||||
|
if(canvas && canvas.nativeElement && geometry && style) {
|
||||||
|
let renderContext = render.toContext(canvas.nativeElement.getContext( '2d'),{ size: [width, height] });
|
||||||
|
|
||||||
|
let geom = geometry.clone() as Polygon,
|
||||||
|
line = geom.getCoordinates()[0],
|
||||||
|
e = extent.boundingExtent( line );
|
||||||
|
|
||||||
|
let dxy = extent.getCenter(e),
|
||||||
|
sxy = [
|
||||||
|
(width - 2 ) / extent.getWidth(e),
|
||||||
|
(height - 2 ) / extent.getHeight(e)
|
||||||
|
];
|
||||||
|
|
||||||
|
let dx = dxy[0],
|
||||||
|
dy = dxy[1],
|
||||||
|
sx = sxy[0],
|
||||||
|
sy = sxy[1];
|
||||||
|
|
||||||
|
geom.translate( -dx, -dy );
|
||||||
|
geom.scale( Math.min(sx, sy), -Math.min(sx, sy));
|
||||||
|
geom.translate(width / 2,height / 2 );
|
||||||
|
renderContext.setStyle( style );
|
||||||
|
renderContext.drawGeometry( geom );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.width = this.container.nativeElement.offsetWidth;
|
||||||
|
this.height = this.container.nativeElement.offsetHeight;
|
||||||
|
this.render(this.canvas,
|
||||||
|
this.geometryStyle,
|
||||||
|
this.geometry,
|
||||||
|
this.width,
|
||||||
|
this.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,37 +1,58 @@
|
|||||||
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input, OnChanges } from '@angular/core';
|
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input, OnChanges } from '@angular/core';
|
||||||
import { layer } from 'ol';
|
import { Layer } from 'ol/layer';
|
||||||
|
import { Source } from 'ol/source';
|
||||||
import { MapComponent } from 'ngx-openlayers';
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[fm-map-ifZoomToShow]',
|
selector: '[fmMapIfZoomToShow]',
|
||||||
})
|
})
|
||||||
export class ifZoomToShowDirective implements OnInit,OnChanges {
|
export class ifZoomToShowDirective implements OnInit {
|
||||||
@Input('fm-map-ifZoomToShow') layer$:layer;
|
@Input()
|
||||||
|
set fmMapIfZoomToShow(layer:Layer<Source>) {
|
||||||
|
this.layer$=layer;
|
||||||
|
this.checkZoom();
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private map$: MapComponent) { }
|
@Input()
|
||||||
|
set fmMapIfZoomToShowThen(templateRef: TemplateRef<any>) {
|
||||||
|
this.thenTemplate$ = templateRef;
|
||||||
|
this.checkZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
set fmMapIfZoomToShowElse(templateRef: TemplateRef<any>) {
|
||||||
|
this.elseTemplate$ = templateRef;
|
||||||
|
this.checkZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
private layer$:Layer<Source>;
|
||||||
|
private thenTemplate$:TemplateRef<any>;
|
||||||
|
private elseTemplate$:TemplateRef<any>;
|
||||||
private showView = false;
|
private showView = false;
|
||||||
|
|
||||||
|
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private map$: MapComponent) {
|
||||||
|
this.thenTemplate$ = templateRef$;
|
||||||
|
this.checkZoom();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.map$.instance.on('moveend', (e) => {
|
this.map$.instance.on('moveend', (e) => {
|
||||||
this.checkZoom();
|
this.checkZoom();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
|
||||||
this.checkZoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
checkZoom() {
|
checkZoom() {
|
||||||
if(this.layer$ && this.map$.instance) {
|
if(this.layer$ && this.map$.instance) {
|
||||||
let minZoom = this.layer$.getMinZoom();
|
let minZoom = this.layer$.getMinZoom();
|
||||||
let currentZoom = this.map$.instance.getView().getZoom();
|
let currentZoom = this.map$.instance.getView().getZoom();
|
||||||
let view = currentZoom < minZoom;
|
let view = currentZoom < minZoom;
|
||||||
if(view!= this.showView) {
|
if(view!= this.showView) {
|
||||||
|
this.viewContainerRef$.clear();
|
||||||
this.showView=view;
|
this.showView=view;
|
||||||
if ( !this.showView) {
|
if (this.showView && this.thenTemplate$ ) {
|
||||||
this.viewContainerRef$.clear();
|
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
||||||
} else {
|
} else if(this.elseTemplate$ ) {
|
||||||
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
this.viewContainerRef$.createEmbeddedView(this.elseTemplate$);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,13 @@
|
|||||||
<fm-map-layer-list [itemLayers]="overlayLayers|async" [selectedLayer]="selectedOverlayLayer|async" (onDelete)="handleOnDelete($event)" (onToggleVisibility)="handleOnToggleVisibility($event)" (onSetOpacity)="handleOnSetOpacity($event)" (onZoomToExtent)="handleZoomToExtent($event)" (onSelectLayer)="handleSelectOverlayLayer($event)"></fm-map-layer-list>
|
<fm-map-layer-list [itemLayers]="overlayLayers|async" [selectedLayer]="selectedOverlayLayer|async" (onDelete)="handleOnDelete($event)" (onToggleVisibility)="handleOnToggleVisibility($event)" (onSetOpacity)="handleOnSetOpacity($event)" (onZoomToExtent)="handleZoomToExtent($event)" (onSelectLayer)="handleSelectOverlayLayer($event)"></fm-map-layer-list>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item py-0" *ngIf="selectedItemLayer$ | async as selectedItemLayer">
|
||||||
|
<span><i class="fal fa-layer-group" aria-hidden="true"></i> <span i18n>Data</span></span>
|
||||||
|
<div class="mb-4">
|
||||||
|
<fm-map-layer-list [dataLayers]="true" [itemLayers]="[selectedItemLayer]" [selectedLayer]="selectedItemLayer" (onToggleVisibility)="handleOnToggleVisibility($event)" (onSetOpacity)="handleOnSetOpacity($event)" (onZoomToExtent)="handleZoomToExtent($event)" (onSelectLayer)="handleSelectOverlayLayer($event)"></fm-map-layer-list>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -16,6 +16,7 @@ export class LayerSwitcher implements OnInit,OnChanges{
|
|||||||
public showLayerSwitcher:Observable<boolean>;
|
public showLayerSwitcher:Observable<boolean>;
|
||||||
public overlayLayers: Observable<Array<IItemLayer>>;
|
public overlayLayers: Observable<Array<IItemLayer>>;
|
||||||
public selectedOverlayLayer: Observable<IItemLayer>;
|
public selectedOverlayLayer: Observable<IItemLayer>;
|
||||||
|
public selectedItemLayer$: Observable<IItemLayer>;
|
||||||
public baseLayers: Observable<Array<IItemLayer>>;
|
public baseLayers: Observable<Array<IItemLayer>>;
|
||||||
public selectedBaseLayer: Observable<IItemLayer>;
|
public selectedBaseLayer: Observable<IItemLayer>;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ export class LayerSwitcher implements OnInit,OnChanges{
|
|||||||
this.selectedOverlayLayer = this.store.select(mapReducers.selectGetSelectedOverlayLayer);
|
this.selectedOverlayLayer = this.store.select(mapReducers.selectGetSelectedOverlayLayer);
|
||||||
this.baseLayers = this.store.select(mapReducers.selectGetBaseLayers);
|
this.baseLayers = this.store.select(mapReducers.selectGetBaseLayers);
|
||||||
this.selectedBaseLayer = this.store.select(mapReducers.selectGetSelectedBaseLayer);
|
this.selectedBaseLayer = this.store.select(mapReducers.selectGetSelectedBaseLayer);
|
||||||
|
this.selectedItemLayer$ = this.store.select(mapReducers.selectGetSelectedItemLayer)
|
||||||
this.showLayerSwitcher = this.store.select(mapReducers.selectGetShowLayerSwitcher);
|
this.showLayerSwitcher = this.store.select(mapReducers.selectGetShowLayerSwitcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@@ -1,5 +1,5 @@
|
|||||||
<ng-template #rt let-r="result" let-t="term">
|
<ng-template #rt let-r="result" let-t="term">
|
||||||
<i class="fal fa-search" aria-hidden="true" style="width:2rem"></i>
|
<i [class]="getIcon(r.type)" aria-hidden="true" style="width:2rem"></i>
|
||||||
<ngb-highlight [result]="formatter(r)" [term]="t"></ngb-highlight>
|
<ngb-highlight [result]="formatter(r)" [term]="t"></ngb-highlight>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
@@ -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>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, Input, Output, OnInit, EventEmitter, SimpleChanges, OnChanges, ViewChild } from '@angular/core';
|
import { Component, Input, Output, OnInit, EventEmitter, SimpleChanges, OnChanges, ViewChild } from '@angular/core';
|
||||||
import { Observable , of } from 'rxjs';
|
import { Observable , of,merge,forkJoin } from 'rxjs';
|
||||||
import { debounceTime,distinctUntilChanged,tap,switchMap,merge,catchError} from 'rxjs/operators';
|
import { debounceTime,distinctUntilChanged,tap,switchMap,catchError,map} from 'rxjs/operators';
|
||||||
import { TypeaheadService, TimespanService } from '@farmmaps/common';
|
import { TypeaheadService, TimespanService } from '@farmmaps/common';
|
||||||
import { IQueryState } from '@farmmaps/common';
|
import { IQueryState } from '@farmmaps/common';
|
||||||
import { IPeriodState } from '../../models/period.state';
|
import { IPeriodState } from '../../models/period.state';
|
||||||
@@ -22,14 +22,19 @@ 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) {
|
||||||
@Output() onSearch = new EventEmitter<IQueryState>();
|
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() onCitySearch = new EventEmitter<string>()
|
||||||
@Output() onClear = new EventEmitter<any>();
|
@Output() onClear = new EventEmitter<any>();
|
||||||
@Output() onSearchCollapse = new EventEmitter<any>();
|
@Output() onSearchCollapse = new EventEmitter<any>();
|
||||||
@Output() onSearchExpand = new EventEmitter<any>();
|
@Output() onSearchExpand = new EventEmitter<any>();
|
||||||
@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 +47,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;
|
||||||
@@ -70,20 +70,27 @@ export class MapSearchComponent {
|
|||||||
this.filterOptionsLocal = { query: "", tags: "", startDate: null, endDate: null, bboxFilter: false, itemType: null, itemCode:null,level:0,parentCode:null,bbox:[] };
|
this.filterOptionsLocal = { query: "", tags: "", startDate: null, endDate: null, bboxFilter: false, itemType: null, itemCode:null,level:0,parentCode:null,bbox:[] };
|
||||||
}
|
}
|
||||||
|
|
||||||
search = (text$: Observable<string>) =>
|
search = (text$: Observable<string>) =>
|
||||||
text$.pipe(
|
text$.pipe(
|
||||||
debounceTime(300),
|
debounceTime(300),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
tap(() => this.searching = true),
|
tap(() => {this.searching = true;this.searchFailed=false;}),
|
||||||
switchMap(term => term.length < 1 ? of([]) :
|
switchMap(term => term.length < 1 ? of([]) :
|
||||||
this.typeaheadService.getSearchTypeaheadItems(term).pipe(
|
forkJoin(
|
||||||
tap(() => this.searchFailed = false),
|
this.typeaheadService.getTagTypeaheadItems(term).pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.searchFailed = true;
|
this.searchFailed = true;
|
||||||
return of([]);
|
return of([]);
|
||||||
})) ),
|
}),map( (sa:string[]) => sa.map((s,i) => ({"name":s,"type":"tag"})))),
|
||||||
|
this.typeaheadService.getCityTypeaheadItems(term).pipe(
|
||||||
|
catchError(() => {
|
||||||
|
this.searchFailed = true;
|
||||||
|
return of([]);
|
||||||
|
}),map( (sa:string[]) => sa.map((s,i) => ({"name":s,"type":"city"})))),
|
||||||
|
).pipe(map(([a1,a2]) => [...a1, ...a2] ),map(a => a.sort((a, b) => (a.name.toUpperCase() > b.name.toUpperCase()) ? 1 : -1)))
|
||||||
|
),
|
||||||
tap(() => this.searching = false),
|
tap(() => this.searching = false),
|
||||||
merge(this.hideSearchingWhenUnsubscribed));
|
);
|
||||||
|
|
||||||
formatter = (x: { name: string }) => x.name;
|
formatter = (x: { name: string }) => x.name;
|
||||||
|
|
||||||
@@ -94,8 +101,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);
|
||||||
}
|
}
|
||||||
@@ -110,33 +117,42 @@ export class MapSearchComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSelect(event) {
|
handleSelect(event) {
|
||||||
event.preventDefault();
|
if(event.item.type == "tag") {
|
||||||
this.filterOptionsLocal.query = null;
|
event.preventDefault();
|
||||||
this.filterOptionsLocal.itemType = null;
|
this.filterOptionsLocal.query = null;
|
||||||
this.filterOptionsLocal.itemCode = null;
|
this.filterOptionsLocal.itemType = null;
|
||||||
this.filterOptionsLocal.parentCode = null;
|
this.filterOptionsLocal.itemCode = null;
|
||||||
this.filterOptionsLocal.tags = event.item.name;
|
this.filterOptionsLocal.parentCode = null;
|
||||||
if (this.dateFilter) {
|
this.filterOptionsLocal.tags = event.item.name;
|
||||||
this.filterOptionsLocal.startDate = this.startDate;
|
if (this.dateFilter) {
|
||||||
this.filterOptionsLocal.endDate = this.endDate;
|
this.filterOptionsLocal.startDate = this.periodLocal.startDate;
|
||||||
|
this.filterOptionsLocal.endDate = this.periodLocal.endDate;
|
||||||
|
}
|
||||||
|
this.onSearch.emit(this.filterOptionsLocal);
|
||||||
|
this.searchTextLocal = { name: this.filterOptionsLocal.tags };
|
||||||
|
} else if (event.item.type == "city") {
|
||||||
|
this.clearEnabled = true;
|
||||||
|
this.onCitySearch.emit(event.item.name);
|
||||||
}
|
}
|
||||||
this.onSearch.emit(this.filterOptionsLocal);
|
|
||||||
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;
|
||||||
@@ -174,5 +190,15 @@ export class MapSearchComponent {
|
|||||||
handleClearClick(event) {
|
handleClearClick(event) {
|
||||||
this.onClear.emit({});
|
this.onClear.emit({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getIcon(type):string {
|
||||||
|
if(type == "tag")
|
||||||
|
return "fal fa-tag";
|
||||||
|
else if(type == "city")
|
||||||
|
return "fal fa-map-marker-alt";
|
||||||
|
else if(type == "search")
|
||||||
|
return "fal fa-search";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
selectedFeature:selectedFeature$|async,
|
selectedFeature:selectedFeature$|async,
|
||||||
fullscreen:fullscreen$|async
|
fullscreen:fullscreen$|async
|
||||||
} as state">
|
} as state">
|
||||||
<aol-map #map (moveEnd)="handleOnMoveEnd($event)" (click)="handleOnMouseDown($event)" [ngClass]="{'panel-visible':state.panelVisible,'fullscreen':state.fullscreen}" class="map">
|
<aol-map #map (moveEnd)="handleOnMoveEnd($event)" (click)="handleOnMouseDown($event)" (dblClick)="handleShowLayerValues($event)" [ngClass]="{'panel-visible':state.panelVisible,'fullscreen':state.fullscreen}" class="map">
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -33,13 +33,14 @@
|
|||||||
<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>
|
||||||
<router-outlet name="map-layers"></router-outlet>
|
<router-outlet name="map-layers"></router-outlet>
|
||||||
<fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="devicesService.IsMobile()" [showTolerance]="devicesService.IsMobile()" [heading]="state.compassHeading"></fm-map-gps-location>
|
<fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="devicesService.IsMobile()" [showTolerance]="devicesService.IsMobile()" [heading]="state.compassHeading"></fm-map-gps-location>
|
||||||
|
<fm-map-layer-values></fm-map-layer-values>
|
||||||
<div class="control-container" >
|
<div class="control-container" >
|
||||||
<router-outlet name="map-controls"></router-outlet>
|
<router-outlet name="map-controls"></router-outlet>
|
||||||
<fm-map-layer-switcher></fm-map-layer-switcher>
|
<fm-map-layer-switcher></fm-map-layer-switcher>
|
||||||
@@ -49,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)" (onCitySearch)="handleCitySearch($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>
|
||||||
|
|
||||||
|
@@ -56,6 +56,18 @@ aol-map { position:absolute;width:100%;height:calc(100vh + 4rem);}
|
|||||||
bottom: 5em;
|
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 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1em;
|
right: 1em;
|
||||||
@@ -109,7 +121,7 @@ timespan {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
timespan.menuVisible {
|
timespan.menuVisible {
|
||||||
@@ -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';
|
||||||
@@ -19,6 +21,7 @@ import {IStyles} from '../../models/style.cache';
|
|||||||
import { IDroppedFile } from '../aol/file-drop-target/file-drop-target.component';
|
import { IDroppedFile } from '../aol/file-drop-target/file-drop-target.component';
|
||||||
import { StateSerializerService } from '@farmmaps/common';
|
import { StateSerializerService } from '@farmmaps/common';
|
||||||
import { GeolocationService} from '../../services/geolocation.service';
|
import { GeolocationService} from '../../services/geolocation.service';
|
||||||
|
import { GeolocatorService } from '@farmmaps/common';
|
||||||
import {DeviceOrientationService} from '../../services/device-orientation.service';
|
import {DeviceOrientationService} from '../../services/device-orientation.service';
|
||||||
|
|
||||||
// AppCommon
|
// AppCommon
|
||||||
@@ -28,6 +31,7 @@ import {commonReducers} from '@farmmaps/common';
|
|||||||
import {commonActions} from '@farmmaps/common';
|
import {commonActions} from '@farmmaps/common';
|
||||||
|
|
||||||
import {Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
|
import {Geometry,Point,Circle} from 'ol/geom';
|
||||||
import {Extent,createEmpty,extend } from 'ol/extent';
|
import {Extent,createEmpty,extend } from 'ol/extent';
|
||||||
import {transform} from 'ol/proj';
|
import {transform} from 'ol/proj';
|
||||||
import { tassign } from 'tassign';
|
import { tassign } from 'tassign';
|
||||||
@@ -45,7 +49,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
public openedModalName$: Observable<string> = this.store.select(commonReducers.selectOpenedModalName);
|
public openedModalName$: Observable<string> = this.store.select(commonReducers.selectOpenedModalName);
|
||||||
public itemTypes$: Observable<{ [id: string]: IItemType }>;
|
public itemTypes$: Observable<{ [id: string]: IItemType }>;
|
||||||
public mapState$: Observable<IMapState> = this.store.select(mapReducers.selectGetMapState);
|
public mapState$: Observable<IMapState> = this.store.select(mapReducers.selectGetMapState);
|
||||||
public features$: Observable<Array<Feature>> = this.store.select(mapReducers.selectGetFeatures);
|
public features$: Observable<Array<Feature<Geometry>>> = this.store.select(mapReducers.selectGetFeatures);
|
||||||
public overlayLayers$: Observable<Array<IItemLayer>> = this.store.select(mapReducers.selectGetOverlayLayers);
|
public overlayLayers$: Observable<Array<IItemLayer>> = this.store.select(mapReducers.selectGetOverlayLayers);
|
||||||
public selectedOverlayLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedOverlayLayer);
|
public selectedOverlayLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedOverlayLayer);
|
||||||
public selectedItemLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedItemLayer);
|
public selectedItemLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedItemLayer);
|
||||||
@@ -62,8 +66,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
public parentCode$: Observable<string> =this.store.select(mapReducers.selectGetParentCode);
|
public parentCode$: Observable<string> =this.store.select(mapReducers.selectGetParentCode);
|
||||||
public panelVisible$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelVisible);
|
public panelVisible$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelVisible);
|
||||||
public panelCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelCollapsed);
|
public panelCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelCollapsed);
|
||||||
public selectedFeature$: Observable<Feature> = this.store.select(mapReducers.selectGetSelectedFeature);
|
public selectedFeature$: Observable<Feature<Geometry>> = this.store.select(mapReducers.selectGetSelectedFeature);
|
||||||
public clickedFeature: Subject<Feature> = new Subject<Feature>();
|
public clickedFeature: Subject<Feature<Geometry>> = new Subject<Feature<Geometry>>();
|
||||||
public selectedItem$: Observable<IItem> = this.store.select(mapReducers.selectGetSelectedItem);
|
public selectedItem$: Observable<IItem> = this.store.select(mapReducers.selectGetSelectedItem);
|
||||||
public parentItem$: Observable<IItem> =this.store.select(mapReducers.selectGetParentItem);
|
public parentItem$: Observable<IItem> =this.store.select(mapReducers.selectGetParentItem);
|
||||||
public queryState$: Observable<IQueryState> = this.store.select(mapReducers.selectGetQueryState);
|
public queryState$: Observable<IQueryState> = this.store.select(mapReducers.selectGetQueryState);
|
||||||
@@ -73,8 +77,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 +88,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;
|
||||||
@@ -96,31 +102,37 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
public itemTypeService: ItemTypeService,
|
public itemTypeService: ItemTypeService,
|
||||||
private location: Location,
|
private location: Location,
|
||||||
private geolocationService: GeolocationService,
|
private geolocationService: GeolocationService,
|
||||||
|
private geolocaterService: GeolocatorService,
|
||||||
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);
|
||||||
@@ -155,11 +167,11 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
this.uploadService.addFiles(droppedFile.files, droppedFile.event, { parentCode:droppedFile.parentCode, geometry:droppedFile.geometry });
|
this.uploadService.addFiles(droppedFile.files, droppedFile.event, { parentCode:droppedFile.parentCode, geometry:droppedFile.geometry });
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFeatureClick(feature: Feature) {
|
handleFeatureClick(feature: Feature<Geometry>) {
|
||||||
this.clickedFeature.next(feature);
|
this.clickedFeature.next(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFeatureHover(feature: Feature) {
|
handleFeatureHover(feature: Feature<Geometry>) {
|
||||||
this.store.dispatch(new mapActions.SelectFeature(feature));
|
this.store.dispatch(new mapActions.SelectFeature(feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +179,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");
|
||||||
@@ -383,6 +407,13 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleShowLayerValues(event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
this.zone.run(() =>{
|
||||||
|
this.store.dispatch(new mapActions.ToggleLayerValuesEnabled());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleOnDownload(event) {
|
handleOnDownload(event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -419,6 +450,23 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCitySearch(location:string) {
|
||||||
|
this.geolocaterService.geocode(location).subscribe(locations => {
|
||||||
|
if( locations.length > 0) {
|
||||||
|
let point = new Point([locations[0].coordinates.lon,locations[0].coordinates.lat]);
|
||||||
|
point.transform('EPSG:4326', 'EPSG:3857');
|
||||||
|
let circle = new Circle(point.getCoordinates(),5000);//
|
||||||
|
let extent = createEmpty();
|
||||||
|
extend(extent, circle.getExtent());
|
||||||
|
this.store.dispatch(new mapActions.SetExtent(extent))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<fm-back-button></fm-back-button>
|
<fm-back-button></fm-back-button>
|
||||||
<div class="card menu-card">
|
<div class="card menu-card">
|
||||||
<h2 *ngIf="parentItem">{{parentItem.name}}</h2>
|
<h2 *ngIf="parentOfItemType('vnd.farmmaps.itemtype.cropfield')">{{parentItem.name}}</h2>
|
||||||
<h1>{{item.name}}</h1>
|
<h1>{{item.name}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<fm-back-button></fm-back-button>
|
<fm-back-button></fm-back-button>
|
||||||
<div class="card menu-card">
|
<div class="card menu-card">
|
||||||
<h2 *ngIf="parentItem">{{parentItem.name}}</h2>
|
<h2 *ngIf="parentOfItemType('vnd.farmmaps.itemtype.cropfield')">{{parentItem.name}}</h2>
|
||||||
<h1>{{item.name}}</h1>
|
<h1>{{item.name}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<fm-back-button></fm-back-button>
|
<fm-back-button></fm-back-button>
|
||||||
<div class="card menu-card">
|
<div class="card menu-card">
|
||||||
<h2 *ngIf="parentItem">{{parentItem.name}}</h2>
|
<h2 *ngIf="parentOfItemType('vnd.farmmaps.itemtype.cropfield')">{{parentItem.name}}</h2>
|
||||||
<h1>{{item.name}}</h1>
|
<h1>{{item.name}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
<div class="legend-container" *ngIf="item?.data.layers;let layers">
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
<div *ngIf="item;let item">
|
<div *ngIf="item;let item">
|
||||||
<div class="card border-0">
|
<div class="card border-0">
|
||||||
<img *ngIf="item.thumbnail" class="card-img-top" [src]="getThumbnailUrl(item)" />
|
<fm-thumbnail [item]="item" [edit]="item.isEditable"></fm-thumbnail>
|
||||||
<div *ngIf="!item.thumbnail" class="big-icon" [style.background-color]="itemTypeService.getColor(item.itemType)">
|
|
||||||
<i [ngClass]="itemTypeService.getIcon(item.itemType)"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
@@ -62,6 +62,10 @@ export abstract class AbstractSelectedItemComponent {
|
|||||||
this.location.back();
|
this.location.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parentOfItemType(itemType:string):boolean {
|
||||||
|
if(this.parentItem && this.parentItem.itemType == itemType) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@@ -1,11 +1,16 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { layer } from 'ol';
|
import { Layer } from 'ol/layer';
|
||||||
|
import { Source } from 'ol/source';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-zoom-to-show-alert',
|
selector: 'fm-map-zoom-to-show-alert',
|
||||||
template: '<div *fm-map-ifZoomToShow="layer" class="alert alert-info"><i class="fas fa-search-plus" aria-hidden="true" i18n-title title="Add as layer"></i> <span i18n>Zoom in to show layer</span></div>'
|
template: '<div *fmMapIfZoomToShow="layer$" class="alert alert-info"><i class="fas fa-search-plus" aria-hidden="true" i18n-title title="Add as layer"></i> <span i18n>Zoom in to show layer</span></div>'
|
||||||
})
|
})
|
||||||
export class ZoomToShowAlert {
|
export class ZoomToShowAlert {
|
||||||
@Input() layer: layer;
|
public layer$: Layer<Source>;
|
||||||
|
@Input()
|
||||||
|
set layer(layer:Layer<Source>) {
|
||||||
|
this.layer$ = layer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,17 @@
|
|||||||
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 } from 'rxjs';
|
import { EMPTY, Observable , of} from 'rxjs';
|
||||||
import { withLatestFrom, switchMap, map, catchError, mergeMap } 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';
|
||||||
import { getCenter,createEmpty,extend } from 'ol/extent';
|
import { getCenter,createEmpty,extend } from 'ol/extent';
|
||||||
import {Point} from 'ol/geom'
|
import {Point,Geometry} from 'ol/geom'
|
||||||
|
|
||||||
|
|
||||||
import * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
@@ -27,26 +29,40 @@ import {FeatureIconService} from '../services/feature-icon.service';
|
|||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
|
|
||||||
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
import { ItemTypeService,IQueryState } from '@farmmaps/common';
|
||||||
|
import { TemporalItemLayer } from '../models/item.layer'
|
||||||
|
|
||||||
|
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
|
||||||
|
|
||||||
|
export const {
|
||||||
|
selectCurrentRoute, // select the current route
|
||||||
|
selectQueryParams, // select the current route query params
|
||||||
|
selectQueryParam, // factory function to select a query param
|
||||||
|
selectRouteParams, // select the current route params
|
||||||
|
selectRouteParam, // factory function to select a route param
|
||||||
|
selectRouteData, // select the current route data
|
||||||
|
selectUrl, // select the current url
|
||||||
|
} = fromRouter.getSelectors(getRouterState);
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@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<Geometry>, updateEvent:commonActions.DeviceUpdateEvent): Feature<Geometry> {
|
||||||
|
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]) => {
|
||||||
@@ -86,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;
|
||||||
@@ -112,7 +126,7 @@ export class MapEffects {
|
|||||||
var endDate = a.queryState.endDate;
|
var endDate = a.queryState.endDate;
|
||||||
var newAction:Observable<Action>;
|
var newAction:Observable<Action>;
|
||||||
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) {
|
||||||
newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode).pipe(
|
newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode, null, a.queryState.level).pipe(
|
||||||
switchMap((features: any) => {
|
switchMap((features: any) => {
|
||||||
for (let f of features.features) {
|
for (let f of features.features) {
|
||||||
if (f.properties && f.properties["code"]) {
|
if (f.properties && f.properties["code"]) {
|
||||||
@@ -127,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 =[];
|
||||||
@@ -140,7 +153,7 @@ export class MapEffects {
|
|||||||
if (!action.query.bboxFilter) {
|
if (!action.query.bboxFilter) {
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (let f of action.features) {
|
for (let f of action.features) {
|
||||||
extend(extent, (f as Feature).getGeometry().getExtent());
|
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
||||||
}
|
}
|
||||||
if(action.features && action.features.length >0) {
|
if(action.features && action.features.length >0) {
|
||||||
actions.push(new mapActions.SetExtent(extent));
|
actions.push(new mapActions.SetExtent(extent));
|
||||||
@@ -148,30 +161,28 @@ 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),
|
||||||
map((action: mapActions.SetFeatures) => {
|
switchMap((action: mapActions.SetFeatures) => {
|
||||||
let extent = createEmpty();
|
let extent = createEmpty();
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (let f of action.features) {
|
for (let f of action.features) {
|
||||||
extend(extent, (f as Feature).getGeometry().getExtent());
|
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
||||||
}
|
}
|
||||||
}
|
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
||||||
return new mapActions.SetExtent(extent);
|
}
|
||||||
}));
|
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]) => {
|
||||||
@@ -192,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") {
|
||||||
@@ -232,21 +244,19 @@ 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]) => {
|
||||||
let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent;
|
let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent;
|
||||||
var feature: Feature = null;
|
var feature: Feature<Geometry> = null;
|
||||||
for (let f of features) {
|
for (let f of features) {
|
||||||
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
||||||
feature = f;
|
feature = f;
|
||||||
@@ -254,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]) => {
|
||||||
@@ -280,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)) {
|
||||||
@@ -297,17 +306,78 @@ export class MapEffects {
|
|||||||
return of(newAction);
|
return of(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Effect()
|
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
||||||
setState$: Observable<Action> = this.actions$.pipe(
|
ofType(mapActions.GETLAYERVALUE),
|
||||||
|
mergeMap((action:mapActions.GetLayerValue) => {
|
||||||
|
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
||||||
|
var scale = l.scale?l.scale:1;
|
||||||
|
return this.itemService$.getLayerValue(action.itemLayer.item.code,action.itemLayer.layerIndex,action.x,action.y).pipe(
|
||||||
|
mergeMap((v: number) => {
|
||||||
|
let a=[];
|
||||||
|
if(v !== null) {
|
||||||
|
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
||||||
|
l.renderer.colorMap.entries.forEach((e) => {
|
||||||
|
if(e.value == v && e.label) {
|
||||||
|
v=e.label;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v,layerName:l.name,quantity:"",unit:l.unit}));
|
||||||
|
} else {
|
||||||
|
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
)));
|
||||||
|
|
||||||
|
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEMSUCCESS,mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED,mapActions.SETLAYERINDEX,mapActions.SETSELECTEDITEMLAYER),
|
||||||
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
||||||
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
||||||
|
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(mapActions.SETLAYERVALUESLOCATION),
|
||||||
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
||||||
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
||||||
|
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
||||||
|
mergeMap(([[[action, selected], enabled],overlayLayers]) => {
|
||||||
|
let layers = [];
|
||||||
|
if(selected) {
|
||||||
|
if(selected && (selected as TemporalItemLayer).selectedItemLayer ) {
|
||||||
|
selected=(selected as TemporalItemLayer).selectedItemLayer;
|
||||||
|
}
|
||||||
|
layers.push(selected);
|
||||||
|
}
|
||||||
|
overlayLayers.forEach((ol) => {
|
||||||
|
if(ol!=selected) layers.push(ol);
|
||||||
|
});
|
||||||
|
let a = action as mapActions.SetLayerValuesLocation;
|
||||||
|
let actions = [];
|
||||||
|
if(enabled) {
|
||||||
|
layers.forEach((ol) => {
|
||||||
|
if("vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(ol.item.itemType)>=0) {
|
||||||
|
actions.push(new mapActions.GetLayerValue(ol,a.x,a.y));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return actions;
|
||||||
|
})));
|
||||||
|
|
||||||
|
|
||||||
|
setState$ = createEffect(() => 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;
|
||||||
@@ -316,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>>
|
||||||
|
}
|
@@ -54,7 +54,7 @@ export interface IGradientstop {
|
|||||||
|
|
||||||
export interface IColorMap {
|
export interface IColorMap {
|
||||||
gradient: IGradientstop[],
|
gradient: IGradientstop[],
|
||||||
noValue: IColorEntry,
|
noValue: IColor,
|
||||||
entries: IColorEntry[],
|
entries: IColorEntry[],
|
||||||
colormapType: string
|
colormapType: string
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { IItem,IListItem } from '@farmmaps/common';
|
import { IItem,IListItem } from '@farmmaps/common';
|
||||||
import {Layer} from 'ol/layer';
|
import {Layer} from 'ol/layer';
|
||||||
|
import { Source } from 'ol/source';
|
||||||
|
|
||||||
export interface IItemLayer {
|
export interface IItemLayer {
|
||||||
item: IItem,
|
item: IItem,
|
||||||
layer: Layer,
|
layer: Layer<Source>,
|
||||||
visible: boolean,
|
visible: boolean,
|
||||||
legendVisible:boolean,
|
legendVisible:boolean,
|
||||||
projection: string,
|
projection: string,
|
||||||
@@ -13,7 +14,7 @@ export interface IItemLayer {
|
|||||||
|
|
||||||
export class ItemLayer implements IItemLayer {
|
export class ItemLayer implements IItemLayer {
|
||||||
public item: IItem;
|
public item: IItem;
|
||||||
public layer: Layer = null;
|
public layer: Layer<Source> = null;
|
||||||
public visible: boolean = true;
|
public visible: boolean = true;
|
||||||
public legendVisible: boolean = false;
|
public legendVisible: boolean = false;
|
||||||
public projection: string;
|
public projection: string;
|
||||||
|
7
projects/common-map/src/fm-map/models/layer.value.ts
Normal file
7
projects/common-map/src/fm-map/models/layer.value.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface ILayervalue {
|
||||||
|
date:string;
|
||||||
|
layerName:string;
|
||||||
|
unit:string;
|
||||||
|
quantity:string;
|
||||||
|
value:number;
|
||||||
|
}
|
@@ -1,5 +1,7 @@
|
|||||||
import {Style,Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
|
import { Style } from 'ol/style';
|
||||||
|
import {Geometry } from 'ol/geom';
|
||||||
|
|
||||||
export interface IStyles{
|
export interface IStyles{
|
||||||
[id: string]: Style | (Feature);
|
[id: string]: Style | ((featue:Feature<Geometry>) => Style);
|
||||||
};
|
};
|
@@ -3,13 +3,15 @@ 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 * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
import {commonActions} from '@farmmaps/common';
|
import {commonActions} from '@farmmaps/common';
|
||||||
import { createSelector, createFeatureSelector } from '@ngrx/store';
|
import { createSelector, createFeatureSelector } from '@ngrx/store';
|
||||||
|
|
||||||
import {Feature} from 'ol';
|
import {Feature} from 'ol';
|
||||||
|
import {Geometry} from 'ol/geom';
|
||||||
|
|
||||||
|
|
||||||
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';
|
||||||
@@ -32,17 +34,22 @@ 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<Geometry>>,
|
||||||
panelVisible: boolean,
|
panelVisible: boolean,
|
||||||
panelCollapsed: boolean,
|
panelCollapsed: boolean,
|
||||||
selectedFeature: Feature,
|
selectedFeature: Feature<Geometry>,
|
||||||
selectedItem:IItem,
|
selectedItem:IItem,
|
||||||
parentItem:IItem,
|
parentItem:IItem,
|
||||||
clearEnabled: boolean,
|
clearEnabled: boolean,
|
||||||
@@ -59,7 +66,11 @@ export interface State {
|
|||||||
showLayerSwitcher:boolean,
|
showLayerSwitcher:boolean,
|
||||||
inSearch:boolean,
|
inSearch:boolean,
|
||||||
inZoom:boolean,
|
inZoom:boolean,
|
||||||
replaceUrl:boolean
|
replaceUrl:boolean,
|
||||||
|
layerValuesX:number,
|
||||||
|
layerValuesY:number,
|
||||||
|
layerValuesEnabled:boolean;
|
||||||
|
layerValues: Array<ILayervalue>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
@@ -98,7 +109,11 @@ export const initialState: State = {
|
|||||||
showLayerSwitcher: false,
|
showLayerSwitcher: false,
|
||||||
inSearch:false,
|
inSearch:false,
|
||||||
inZoom:false,
|
inZoom:false,
|
||||||
replaceUrl:true
|
replaceUrl:true,
|
||||||
|
layerValuesX:0,
|
||||||
|
layerValuesY:0,
|
||||||
|
layerValuesEnabled:false,
|
||||||
|
layerValues:[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
||||||
@@ -288,8 +303,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();
|
||||||
@@ -322,7 +347,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
case mapActions.COLLAPSESEARCH: {
|
case mapActions.COLLAPSESEARCH: {
|
||||||
return tassign(state, { searchCollapsed: state.panelVisible ? false: true});
|
return tassign(state, { searchCollapsed: state.panelVisible ? false: true});
|
||||||
}
|
}
|
||||||
case commonActions.CLOSEALL: {
|
case commonActions.CLOSEALL: {
|
||||||
return tassign(state, { searchCollapsed: state.panelVisible ? false: true,showLayerSwitcher:false});
|
return tassign(state, { searchCollapsed: state.panelVisible ? false: true,showLayerSwitcher:false});
|
||||||
}
|
}
|
||||||
case mapActions.SETEXTENT: {
|
case mapActions.SETEXTENT: {
|
||||||
@@ -360,17 +385,25 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
}
|
}
|
||||||
case mapActions.SETVISIBILITY: {
|
case mapActions.SETVISIBILITY: {
|
||||||
let a = action as mapActions.SetVisibility;
|
let a = action as mapActions.SetVisibility;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
if(state.selectedItemLayer == a.itemLayer) {
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{visible:a.visibility})});
|
||||||
newLayers[i].visible = a.visibility;
|
} else {
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
|
newLayers[i].visible = a.visibility;
|
||||||
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case mapActions.SETOPACITY: {
|
case mapActions.SETOPACITY: {
|
||||||
let a = action as mapActions.SetOpacity;
|
let a = action as mapActions.SetOpacity;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
if(state.selectedItemLayer == a.itemLayer) {
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{opacity:a.opacity})});
|
||||||
newLayers[i].opacity = a.opacity;
|
} else {
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
let newLayers = state.overlayLayers.slice(0);
|
||||||
|
let i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
|
newLayers[i].opacity = a.opacity;
|
||||||
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case mapActions.SETLAYERINDEX: {
|
case mapActions.SETLAYERINDEX: {
|
||||||
let a = action as mapActions.SetLayerIndex;
|
let a = action as mapActions.SetLayerIndex;
|
||||||
@@ -462,6 +495,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
selectedFeature: null,
|
selectedFeature: null,
|
||||||
queryState: newQueryState,
|
queryState: newQueryState,
|
||||||
clearEnabled: false,
|
clearEnabled: false,
|
||||||
|
layerValuesEnabled: false,
|
||||||
searchCollapsed: true,
|
searchCollapsed: true,
|
||||||
searchMinified: false,
|
searchMinified: false,
|
||||||
features: [],
|
features: [],
|
||||||
@@ -484,6 +518,43 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
let a= action as mapActions.SetReplaceUrl;
|
let a= action as mapActions.SetReplaceUrl;
|
||||||
return tassign(state,{replaceUrl:a.replaceUrl});
|
return tassign(state,{replaceUrl:a.replaceUrl});
|
||||||
}
|
}
|
||||||
|
case mapActions.TOGGLELAYERVALUESENABLED: {
|
||||||
|
return tassign(state,{layerValuesEnabled:!state.layerValuesEnabled});
|
||||||
|
}
|
||||||
|
case mapActions.SETLAYERVALUESLOCATION: {
|
||||||
|
let a= action as mapActions.SetLayerValuesLocation;
|
||||||
|
return tassign(state,{layerValuesX: a.x, layerValuesY:a.y,layerValues:[]});
|
||||||
|
}
|
||||||
|
case mapActions.GETLAYERVALUESUCCESS:{
|
||||||
|
let a= action as mapActions.GetLayerValueSuccess;
|
||||||
|
let v = state.layerValues.slice(0);
|
||||||
|
v.push(a.layervalue);
|
||||||
|
return tassign(state,{layerValues:v});
|
||||||
|
}
|
||||||
|
case commonActions.ITEMDELETEDEVENT:{
|
||||||
|
let a= action as commonActions.ItemDeletedEvent;
|
||||||
|
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
|
||||||
|
return tassign(state,{
|
||||||
|
selectedItem: null,
|
||||||
|
selectedItemLayer: null,
|
||||||
|
features:[]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(state.features.length>0) {
|
||||||
|
var index = -1;
|
||||||
|
for (var i = 0; i < state.features.length; i++) {
|
||||||
|
if (state.features[i].getId() == a.itemCode ) {
|
||||||
|
index=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(index>=0) {
|
||||||
|
let newFeatures = state.features.slice(0);
|
||||||
|
newFeatures.splice(index,1);
|
||||||
|
return tassign(state,{features:newFeatures});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -515,6 +586,11 @@ export const getStyles = (state:State) => state.styles;
|
|||||||
export const getShowLayerSwitcher = (state:State) => state.showLayerSwitcher;
|
export const getShowLayerSwitcher = (state:State) => state.showLayerSwitcher;
|
||||||
export const getInSearch = (state:State) => state.inSearch;
|
export const getInSearch = (state:State) => state.inSearch;
|
||||||
export const getState = (state:State) => {return {mapState:state.mapState,queryState:state.queryState,replaceUrl:state.replaceUrl};}
|
export const getState = (state:State) => {return {mapState:state.mapState,queryState:state.queryState,replaceUrl:state.replaceUrl};}
|
||||||
|
export const getLayerValuesEnabled = (state:State) => state.layerValuesEnabled;
|
||||||
|
export const getLayerValues = (state:State) => state.layerValues;
|
||||||
|
export const getLayerValuesX = (state:State) => state.layerValuesX;
|
||||||
|
export const getLayerValuesY = (state:State) => state.layerValuesY;
|
||||||
|
|
||||||
|
|
||||||
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
|
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
|
||||||
export const selectGetMapState= createSelector(selectMapState, getMapState);
|
export const selectGetMapState= createSelector(selectMapState, getMapState);
|
||||||
@@ -542,5 +618,9 @@ export const selectGetStyles = createSelector(selectMapState, getStyles);
|
|||||||
export const selectGetShowLayerSwitcher = createSelector(selectMapState,getShowLayerSwitcher);
|
export const selectGetShowLayerSwitcher = createSelector(selectMapState,getShowLayerSwitcher);
|
||||||
export const selectGetInSearch = createSelector(selectMapState,getInSearch);
|
export const selectGetInSearch = createSelector(selectMapState,getInSearch);
|
||||||
export const selectGetState = createSelector(selectMapState,getState);
|
export const selectGetState = createSelector(selectMapState,getState);
|
||||||
|
export const selectGetLayerValuesEnabled = createSelector(selectMapState,getLayerValuesEnabled);
|
||||||
|
export const selectGetLayerValues = createSelector(selectMapState,getLayerValues);
|
||||||
|
export const selectGetLayerValuesX = createSelector(selectMapState,getLayerValuesX);
|
||||||
|
export const selectGetLayerValuesY = createSelector(selectMapState,getLayerValuesY);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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,8 +1,8 @@
|
|||||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||||
|
|
||||||
import 'core-js/es7/reflect';
|
import 'core-js/es7/reflect';
|
||||||
import 'zone.js/dist/zone';
|
import 'zone.js';
|
||||||
import 'zone.js/dist/zone-testing';
|
import 'zone.js/testing';
|
||||||
import { getTestBed } from '@angular/core/testing';
|
import { getTestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
BrowserDynamicTestingModule,
|
BrowserDynamicTestingModule,
|
||||||
|
@@ -22,8 +22,7 @@
|
|||||||
"strictMetadataEmit": true,
|
"strictMetadataEmit": true,
|
||||||
"fullTemplateTypeCheck": true,
|
"fullTemplateTypeCheck": true,
|
||||||
"strictInjectionParameters": true,
|
"strictInjectionParameters": true,
|
||||||
"enableResourceInlining": true,
|
"enableResourceInlining": true
|
||||||
"enableIvy": false
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"src/test.ts",
|
"src/test.ts",
|
||||||
|
40
projects/common-map/tsconfig.lib.prod.json
Normal file
40
projects/common-map/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,
|
||||||
|
"compilationMode": "partial"
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"src/test.ts",
|
||||||
|
"**/*.spec.ts"
|
||||||
|
]
|
||||||
|
}
|
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common-map3d",
|
"name": "@farmmaps/common-map3d",
|
||||||
"version": "0.0.1",
|
"version": "2.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": "^10.1.3",
|
"@angular/common": "~12.2.8",
|
||||||
"@angular/core": "^10.1.3",
|
"@angular/core": "~12.2.8",
|
||||||
"ngx-openlayers": "1.0.0-next.16",
|
"ngx-openlayers": "1.0.0-next.19",
|
||||||
"cesium": "^1.73.0",
|
"cesium": "^1.82.1",
|
||||||
"ol-cesium": "^2.11.3"
|
"ol-cesium": "^2.13.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.0.0"
|
"tslib": "^2.0.0"
|
||||||
|
@@ -1 +1 @@
|
|||||||
<div *fm-haspackage="'vnd.farmmaps.package.3d'" (click)="handleClick($event)" class="btn btn-outline-primary twotreed"><i class="fas fa-spinner fa-spin loading" [class]="{'loading':loading}"></i>{{label}}</div>
|
<div *fmHasPackage="'vnd.farmmaps.itemtype.package.3d'" (click)="handleClick($event)" class="btn btn-outline-primary twotreed"><i class="fas fa-spinner fa-spin loading" [ngClass]="{'loading':loading}"></i>{{label}}</div>
|
||||||
|
@@ -32,6 +32,7 @@ export class Switch2D3DComponent {
|
|||||||
this.loading=false;
|
this.loading=false;
|
||||||
return this.synchronizers;
|
return this.synchronizers;
|
||||||
}, stopOpenLayersEventsPropagation:true});
|
}, stopOpenLayersEventsPropagation:true});
|
||||||
|
this.ol3d.warmUp(3000,5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronize() {
|
synchronize() {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||||
|
|
||||||
import 'zone.js/dist/zone';
|
import 'zone.js';
|
||||||
import 'zone.js/dist/zone-testing';
|
import 'zone.js/testing';
|
||||||
import { getTestBed } from '@angular/core/testing';
|
import { getTestBed } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
BrowserDynamicTestingModule,
|
BrowserDynamicTestingModule,
|
||||||
|
@@ -22,8 +22,7 @@
|
|||||||
"strictMetadataEmit": true,
|
"strictMetadataEmit": true,
|
||||||
"fullTemplateTypeCheck": true,
|
"fullTemplateTypeCheck": true,
|
||||||
"strictInjectionParameters": true,
|
"strictInjectionParameters": true,
|
||||||
"enableResourceInlining": true,
|
"enableResourceInlining": true
|
||||||
"enableIvy": false
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"src/test.ts",
|
"src/test.ts",
|
||||||
|
@@ -1,10 +1,40 @@
|
|||||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
||||||
{
|
{
|
||||||
"extends": "./tsconfig.lib.json",
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"declarationMap": false
|
"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": {
|
"angularCompilerOptions": {
|
||||||
"enableIvy": false
|
"skipTemplateCodegen": true,
|
||||||
}
|
"strictMetadataEmit": true,
|
||||||
|
"fullTemplateTypeCheck": true,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"enableResourceInlining": true,
|
||||||
|
"compilationMode": "partial"
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"src/test.ts",
|
||||||
|
"**/*.spec.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
"my-data": "my-data"
|
"my-data": "my-data"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"whitelistedNonPeerDependencies": [
|
"allowedNonPeerDependencies": [
|
||||||
"."
|
"."
|
||||||
]
|
]
|
||||||
}
|
}
|
24
projects/common/package-lock.json
generated
24
projects/common/package-lock.json
generated
@@ -1,5 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common",
|
"name": "@farmmaps/common",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"lockfileVersion": 1
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"is-retina": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-retina/-/is-retina-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-10AbKGvqKuN/Ykd1iN5QTQuGR+M="
|
||||||
|
},
|
||||||
|
"ngx-avatar": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ngx-avatar/-/ngx-avatar-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-Uk40UXl26RvDy1ori9NDsGFB+f84AaxMnsIwZA6JPJK0pLcbo3F4vZTmzLZeOusOw1Qtgk5IzF630jo06keXwQ==",
|
||||||
|
"requires": {
|
||||||
|
"is-retina": "^1.0.3",
|
||||||
|
"ts-md5": "^1.2.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ts-md5": {
|
||||||
|
"version": "1.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-md5/-/ts-md5-1.2.7.tgz",
|
||||||
|
"integrity": "sha512-emODogvKGWi1KO1l9c6YxLMBn6CEH3VrH5mVPIyOtxBG52BvV4jP3GWz6bOZCz61nLgBc3ffQYE4+EHfCD+V7w=="
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common",
|
"name": "@farmmaps/common",
|
||||||
"version": "0.0.1",
|
"version": "2.0.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
"registry": "https://repository.akkerweb.nl/repository/npm-hosted/"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@ng-bootstrap/ng-bootstrap": "^7.0",
|
"@ng-bootstrap/ng-bootstrap": "^7.0",
|
||||||
"@angular/common": "~10.2.4",
|
"@angular/common": "~12.2.8",
|
||||||
"@angular/core": "~10.2.4",
|
"@angular/core": "~12.2.8",
|
||||||
"@angular/forms": "~10.2.4",
|
"@angular/forms": "~12.2.8",
|
||||||
"@ngrx/effects": "^10.0",
|
"@ngrx/effects": "^12.0",
|
||||||
"@ngrx/router-store": "^10.0",
|
"@ngrx/router-store": "^12.0",
|
||||||
"@ngrx/store": "^10.0",
|
"@ngrx/store": "^12.0",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
"bootstrap": "^4.4.1",
|
"bootstrap": "^4.4.1",
|
||||||
"@microsoft/signalr": "^3.1.3",
|
"@microsoft/signalr": "^3.1.3",
|
||||||
"ngx-uploadx": "^3.3.4",
|
"ngx-uploadx": "^3.3.4",
|
||||||
"angular-oauth2-oidc": "^10.0.3",
|
"angular-oauth2-oidc": "^12.0",
|
||||||
"moment": "^2.27.0"
|
"moment": "^2.27.0",
|
||||||
|
"ngx-avatar": "^4.0.0",
|
||||||
|
"ngx-image-cropper": "^3.3.5",
|
||||||
|
"ngx-clipboard": "^14.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,8 @@ export const TASKPROGRESSEVENT = '[AppCommon] TaskProgressEvent';
|
|||||||
|
|
||||||
export const DEVICEUPDATEEVENT = '[AppCommon] DeviceUpdateEvent';
|
export const DEVICEUPDATEEVENT = '[AppCommon] DeviceUpdateEvent';
|
||||||
|
|
||||||
|
export const NOTIFICATIONEVENT = '[AppCommon] NotificationEvent';
|
||||||
|
|
||||||
export const DELETEITEMS = '[AppCommon] DeleteItems';
|
export const DELETEITEMS = '[AppCommon] DeleteItems';
|
||||||
export const DELETEITEMSSUCCESS = '[AppCommon] DeleteItemsSuccess';
|
export const DELETEITEMSSUCCESS = '[AppCommon] DeleteItemsSuccess';
|
||||||
|
|
||||||
@@ -62,6 +64,10 @@ export const TOGGLEACCOUNTMENU = '[AppCommon] ToggleAccountMenu';
|
|||||||
|
|
||||||
export const TOGGLEAPPMENU = '[AppCommon] ToggleAppMenu';
|
export const TOGGLEAPPMENU = '[AppCommon] ToggleAppMenu';
|
||||||
|
|
||||||
|
export const TOGGLENOTIFICATIONMENU = '[AppCommon] ToggleNotificationMenu';
|
||||||
|
|
||||||
|
export const TOGGLEHELPMENU = '[AppCommon] ToggleHelpMenu';
|
||||||
|
|
||||||
export const SETMENUVISIBLE = '[AppCommon] SetMenuVisible';
|
export const SETMENUVISIBLE = '[AppCommon] SetMenuVisible';
|
||||||
|
|
||||||
export const ONLINE = '[AppCommon] Online';
|
export const ONLINE = '[AppCommon] Online';
|
||||||
@@ -70,6 +76,8 @@ export const OFFLINE = '[AppCommon] Offline';
|
|||||||
|
|
||||||
export const SETPAGEMODE = '[AppCommon] SetPageMode';
|
export const SETPAGEMODE = '[AppCommon] SetPageMode';
|
||||||
|
|
||||||
|
export const SETUNREADNOTIFICATIONS = '[AppCommon] SetUnreadNotifications';
|
||||||
|
|
||||||
export class InitUser implements Action {
|
export class InitUser implements Action {
|
||||||
readonly type = INITUSER;
|
readonly type = INITUSER;
|
||||||
|
|
||||||
@@ -232,6 +240,12 @@ export class DeviceUpdateEvent implements Action {
|
|||||||
constructor(public itemCode: string, public attributes: any) { }
|
constructor(public itemCode: string, public attributes: any) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class NotificationEvent implements Action {
|
||||||
|
readonly type = NOTIFICATIONEVENT;
|
||||||
|
|
||||||
|
constructor(public attributes: any) { }
|
||||||
|
}
|
||||||
|
|
||||||
export class DeleteItems implements Action {
|
export class DeleteItems implements Action {
|
||||||
readonly type = DELETEITEMS;
|
readonly type = DELETEITEMS;
|
||||||
|
|
||||||
@@ -291,6 +305,18 @@ export class ToggleAppMenu implements Action {
|
|||||||
constructor() { }
|
constructor() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ToggleNotificationMenu implements Action {
|
||||||
|
readonly type = TOGGLENOTIFICATIONMENU;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ToggleHelpMenu implements Action {
|
||||||
|
readonly type = TOGGLEHELPMENU;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
}
|
||||||
|
|
||||||
export class SetMenuVisible implements Action {
|
export class SetMenuVisible implements Action {
|
||||||
readonly type = SETMENUVISIBLE;
|
readonly type = SETMENUVISIBLE;
|
||||||
|
|
||||||
@@ -314,6 +340,13 @@ export class SetPageMode implements Action {
|
|||||||
|
|
||||||
constructor(public pageMode:boolean) {}
|
constructor(public pageMode:boolean) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class SetUnreadNotifications implements Action {
|
||||||
|
readonly type = SETUNREADNOTIFICATIONS;
|
||||||
|
|
||||||
|
constructor(public unread:number) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export type Actions = OpenModal
|
export type Actions = OpenModal
|
||||||
@@ -355,6 +388,10 @@ export type Actions = OpenModal
|
|||||||
| Online
|
| Online
|
||||||
| Offline
|
| Offline
|
||||||
| SetPageMode
|
| SetPageMode
|
||||||
| ToggleAppMenu;
|
| ToggleAppMenu
|
||||||
|
| ToggleNotificationMenu
|
||||||
|
| ToggleHelpMenu
|
||||||
|
| NotificationEvent
|
||||||
|
| SetUnreadNotifications;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,12 +16,15 @@ import { ItemService } from './services/item.service';
|
|||||||
import { EventService } from './services/event.service';
|
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 { 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";
|
||||||
import { appConfigFactory } from "./shared/app.config.factory";
|
import { appConfigFactory } from "./shared/app.config.factory";
|
||||||
import { AuthGuard } from './services/auth-guard.service';
|
import { AuthGuard } from './services/auth-guard.service';
|
||||||
import { NavBarGuard } from './services/nav-bar-guard.service';
|
import { NavBarGuard } from './services/nav-bar-guard.service';
|
||||||
|
import { PackageGuard } from './services/package-guard.service';
|
||||||
import { FullScreenGuard } from './services/full-screen-guard.service';
|
import { FullScreenGuard } from './services/full-screen-guard.service';
|
||||||
import { AuthCallbackGuard } from './components/auth-callback/auth-callback.guard';
|
import { AuthCallbackGuard } from './components/auth-callback/auth-callback.guard';
|
||||||
import { ResumableFileUploadService } from './components/resumable-file-upload/resumable-file-upload.service';
|
import { ResumableFileUploadService } from './components/resumable-file-upload/resumable-file-upload.service';
|
||||||
@@ -41,11 +44,14 @@ export {
|
|||||||
EventService,
|
EventService,
|
||||||
TypeaheadService,
|
TypeaheadService,
|
||||||
UserService,
|
UserService,
|
||||||
|
ImageService,
|
||||||
|
GeolocatorService,
|
||||||
WeatherService,
|
WeatherService,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
AccessTokenInterceptor,
|
AccessTokenInterceptor,
|
||||||
AuthGuard,
|
AuthGuard,
|
||||||
NavBarGuard,
|
NavBarGuard,
|
||||||
|
PackageGuard,
|
||||||
FullScreenGuard,
|
FullScreenGuard,
|
||||||
AuthCallbackGuard,
|
AuthCallbackGuard,
|
||||||
ResumableFileUploadService,
|
ResumableFileUploadService,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// angular modules
|
// angular modules
|
||||||
import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector, Optional, SkipSelf } from '@angular/core';
|
import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector, Optional, SkipSelf,InjectionToken } from '@angular/core';
|
||||||
import { CommonModule, DatePipe } from '@angular/common';
|
import { CommonModule, DatePipe } from '@angular/common';
|
||||||
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
@@ -10,6 +10,7 @@ import { StoreModule, Store } from '@ngrx/store';
|
|||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { UploadxModule } from 'ngx-uploadx';
|
import { UploadxModule } from 'ngx-uploadx';
|
||||||
|
import { ClipboardModule } from 'ngx-clipboard';
|
||||||
|
|
||||||
|
|
||||||
// routing module
|
// routing module
|
||||||
@@ -33,6 +34,7 @@ import { MenuBackgroundComponent } from './components/menu-background/menu-backg
|
|||||||
import { HasPackageDirective} from './components/has-package/has-package.directive';
|
import { HasPackageDirective} from './components/has-package/has-package.directive';
|
||||||
import { HasClaimDirective} from './components/has-claim/has-claim.directive';
|
import { HasClaimDirective} from './components/has-claim/has-claim.directive';
|
||||||
import { UserMenuComponent} from './components/user-menu/user-menu.component';
|
import { UserMenuComponent} from './components/user-menu/user-menu.component';
|
||||||
|
import { ThumbnailComponent } from './components/thumbnail/thumbnail.component';
|
||||||
import { Alert } from './enumerations/alert.enum';
|
import { Alert } from './enumerations/alert.enum';
|
||||||
import { IEventMessage } from './models/event.message';
|
import { IEventMessage } from './models/event.message';
|
||||||
import { IItem, Item } from './models/item';
|
import { IItem, Item } from './models/item';
|
||||||
@@ -56,7 +58,15 @@ import { SecureOAuthStorage} from './shared/secureOAuthStorage';
|
|||||||
import { GradientComponent } from './components/gradient/gradient.component';
|
import { GradientComponent } from './components/gradient/gradient.component';
|
||||||
import { GradientSelectComponent } from './components/gradient-select/gradient-select.component';
|
import { GradientSelectComponent } from './components/gradient-select/gradient-select.component';
|
||||||
import { AppMenuComponent } from './components/app-menu/app-menu.component';
|
import { AppMenuComponent } from './components/app-menu/app-menu.component';
|
||||||
|
import { NotificationMenuComponent} from './components/notification-menu/notification-menu.component';
|
||||||
|
import { HelpMenuComponent} from './components/help-menu/help-menu.component';
|
||||||
import { BackButtonComponent } from './components/back-button/back-button.component';
|
import { BackButtonComponent } from './components/back-button/back-button.component';
|
||||||
|
import { EditImageModalComponent } from './components/edit-image-modal/edit-image-modal.component';
|
||||||
|
import { AvatarComponent } from './components/avatar/avatar.component';
|
||||||
|
import { AvatarModule } from 'ngx-avatar';
|
||||||
|
import { ImageCropperModule } from 'ngx-image-cropper';
|
||||||
|
|
||||||
|
export const FM_COMMON_STARTPAGE = new InjectionToken<string>('fm-common-startpage');
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SafePipe,
|
SafePipe,
|
||||||
@@ -70,6 +80,7 @@ export {
|
|||||||
TimespanComponent,
|
TimespanComponent,
|
||||||
TagInputComponent,
|
TagInputComponent,
|
||||||
UserMenuComponent,
|
UserMenuComponent,
|
||||||
|
ThumbnailComponent,
|
||||||
HasPackageDirective,
|
HasPackageDirective,
|
||||||
HasClaimDirective,
|
HasClaimDirective,
|
||||||
Alert,
|
Alert,
|
||||||
@@ -98,7 +109,11 @@ export {
|
|||||||
IDataLayer,
|
IDataLayer,
|
||||||
IColor,
|
IColor,
|
||||||
IGradientstop,
|
IGradientstop,
|
||||||
BackButtonComponent
|
BackButtonComponent,
|
||||||
|
AvatarComponent,
|
||||||
|
EditImageModalComponent,
|
||||||
|
GradientComponent,
|
||||||
|
GradientSelectComponent
|
||||||
};
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -111,7 +126,10 @@ export {
|
|||||||
OAuthModule.forRoot(),
|
OAuthModule.forRoot(),
|
||||||
NgbModule,
|
NgbModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
UploadxModule
|
UploadxModule,
|
||||||
|
ClipboardModule,
|
||||||
|
AvatarModule,
|
||||||
|
ImageCropperModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
@@ -131,11 +149,17 @@ export {
|
|||||||
GradientComponent,
|
GradientComponent,
|
||||||
GradientSelectComponent,
|
GradientSelectComponent,
|
||||||
AppMenuComponent,
|
AppMenuComponent,
|
||||||
BackButtonComponent
|
NotificationMenuComponent,
|
||||||
|
HelpMenuComponent,
|
||||||
|
BackButtonComponent,
|
||||||
|
ThumbnailComponent,
|
||||||
|
EditImageModalComponent,
|
||||||
|
AvatarComponent
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
NgbModule,
|
NgbModule,
|
||||||
UploadxModule,
|
UploadxModule,
|
||||||
|
ClipboardModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
AppComponent,
|
AppComponent,
|
||||||
ResumableFileUploadComponent,
|
ResumableFileUploadComponent,
|
||||||
@@ -154,7 +178,10 @@ export {
|
|||||||
UserMenuComponent,
|
UserMenuComponent,
|
||||||
GradientComponent,
|
GradientComponent,
|
||||||
GradientSelectComponent,
|
GradientSelectComponent,
|
||||||
BackButtonComponent
|
BackButtonComponent,
|
||||||
|
ThumbnailComponent,
|
||||||
|
AvatarComponent,
|
||||||
|
EditImageModalComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppCommonModule {
|
export class AppCommonModule {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<div (click)="toggle($event)" class="rounded-circle menu-button hidden" [ngClass]="{'hidden':!user}">
|
<div (click)="toggle($event)" class="rounded-circle menu-button hidden" [ngClass]="{'hidden':!user || noContent}">
|
||||||
<span i18n-title title="Apps"><i class="fas fa-th" aria-hidden="true"></i></span>
|
<span i18n-title title="Apps"><i class="fas fa-th" aria-hidden="true"></i></span>
|
||||||
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
|
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
|
||||||
<router-outlet name="app-menu"></router-outlet>
|
<router-outlet name="app-menu" (activate)="activateRoute()" (deactivate)="deActivateRoute()"></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
import { IUser } from '../../models/user';
|
import { IUser } from '../../models/user';
|
||||||
import {Store} from '@ngrx/store';
|
import {Store} from '@ngrx/store';
|
||||||
import * as appReducers from '../../reducers/app-common.reducer';
|
import * as appReducers from '../../reducers/app-common.reducer';
|
||||||
@@ -15,6 +14,7 @@ export class AppMenuComponent implements OnInit {
|
|||||||
|
|
||||||
@Input() user:IUser;
|
@Input() user:IUser;
|
||||||
@Input() showMenu:boolean;
|
@Input() showMenu:boolean;
|
||||||
|
public noContent: boolean = true;
|
||||||
|
|
||||||
constructor(private store: Store<appReducers.State>) { }
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
@@ -26,4 +26,12 @@ export class AppMenuComponent implements OnInit {
|
|||||||
this.store.dispatch(new appActions.ToggleAppMenu());
|
this.store.dispatch(new appActions.ToggleAppMenu());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activateRoute() {
|
||||||
|
this.noContent=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
deActivateRoute() {
|
||||||
|
this.noContent=true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<button type="button" class="btn btn-outline-secondary apponly" (click)="handleToggleMenu($event)"><i class="fal fa-bars" aria-hidden="true"></i></button>
|
<button type="button" class="btn btn-outline-secondary apponly" (click)="handleToggleMenu($event)"><i class="fal fa-bars" aria-hidden="true"></i></button>
|
||||||
<router-outlet name="menu" class="ml-4"></router-outlet>
|
<router-outlet name="menu" class="ml-4"></router-outlet>
|
||||||
<div class="collapse navbar-collapse pageonly">
|
<div class="collapse navbar-collapse pageonly">
|
||||||
<a class="btn btn-primary ml-auto" role="button" [routerLink]="['/map']">
|
<a class="btn btn-primary ml-auto" role="button" [routerLink]="[ startPage == null?'/map':startPage]">
|
||||||
<span *ngIf="(user|async)==null" i18n>Sign in</span>
|
<span *ngIf="(user|async)==null" i18n>Sign in</span>
|
||||||
<span *ngIf="(user|async)!=null" i18n>To app</span>
|
<span *ngIf="(user|async)!=null" i18n>To app</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
<fm-resumable-file-upload></fm-resumable-file-upload>
|
<fm-resumable-file-upload></fm-resumable-file-upload>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="user-menu apponly">
|
<div class="user-menu apponly">
|
||||||
|
<fm-help-menu [user]="user|async" [showMenu]="helpMenuVisible|async"></fm-help-menu>
|
||||||
|
<fm-notification-menu [user]="user|async" [unread]="unreadNotifications|async" [showMenu]="notificationMenuVisible|async"></fm-notification-menu>
|
||||||
<fm-app-menu [user]="user|async" [showMenu]="appMenuVisible|async"></fm-app-menu>
|
<fm-app-menu [user]="user|async" [showMenu]="appMenuVisible|async"></fm-app-menu>
|
||||||
<fm-user-menu [user]="user|async" [showMenu]="accountMenuVisible|async"></fm-user-menu>
|
<fm-user-menu [user]="user|async" [showMenu]="accountMenuVisible|async"></fm-user-menu>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -125,7 +125,7 @@ body { background: #f1f1f1; line-height: 18px; user-select:none;font-family: Lat
|
|||||||
max-height:0em;
|
max-height:0em;
|
||||||
}
|
}
|
||||||
|
|
||||||
fm-app-menu,fm-user-menu {
|
fm-help-menu,fm-app-menu,fm-user-menu,fm-notification-menu {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core';
|
import { Component, OnInit, OnDestroy, Inject, Optional,ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core';
|
||||||
import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
|
import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router';
|
||||||
import { Meta, Title, MetaDefinition } from '@angular/platform-browser'; import { DOCUMENT } from "@angular/common";
|
import { Meta, Title, MetaDefinition } from '@angular/platform-browser'; import { DOCUMENT } from "@angular/common";
|
||||||
import { Subscription, Observable } from 'rxjs';
|
import { Subscription, Observable } from 'rxjs';
|
||||||
@@ -6,6 +6,7 @@ import { distinctUntilChanged } from 'rxjs/operators';
|
|||||||
import { Store, Action } from '@ngrx/store';
|
import { Store, Action } from '@ngrx/store';
|
||||||
import { IUser } from '../../models/user';
|
import { IUser } from '../../models/user';
|
||||||
import { OAuthService, OAuthErrorEvent } from 'angular-oauth2-oidc';
|
import { OAuthService, OAuthErrorEvent } from 'angular-oauth2-oidc';
|
||||||
|
import { FM_COMMON_STARTPAGE} from '../../common.module';
|
||||||
|
|
||||||
//AppCommon
|
//AppCommon
|
||||||
import { IEventMessage } from '../../models/event.message';
|
import { IEventMessage } from '../../models/event.message';
|
||||||
@@ -43,11 +44,15 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
public menuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetMenuVisible);
|
public menuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetMenuVisible);
|
||||||
public accountMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetAccountMenuVisible);
|
public accountMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetAccountMenuVisible);
|
||||||
public appMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetAppMenuVisible);
|
public appMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetAppMenuVisible);
|
||||||
|
public notificationMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetNotificationMenuVisible);
|
||||||
|
public helpMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetHelpMenuVisible);
|
||||||
|
public unreadNotifications: Observable<number> = this.store$.select(appReducers.SelectgetUnreadNotifications);
|
||||||
public user: Observable<IUser> = this.store$.select(appReducers.SelectGetUser);
|
public user: Observable<IUser> = this.store$.select(appReducers.SelectGetUser);
|
||||||
public isPageMode: Observable<boolean> = this.store$.select(appReducers.SelectGetIsPageMode);
|
public isPageMode: Observable<boolean> = this.store$.select(appReducers.SelectGetIsPageMode);
|
||||||
@Input() showUploadProgress: boolean = true;
|
@Input() showUploadProgress: boolean = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@Optional() @Inject(FM_COMMON_STARTPAGE) public startPage: string,
|
||||||
public router: Router,
|
public router: Router,
|
||||||
private activatedRoute$: ActivatedRoute,
|
private activatedRoute$: ActivatedRoute,
|
||||||
private title$: Title,
|
private title$: Title,
|
||||||
@@ -98,6 +103,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
action = new commonActions.DeviceUpdateEvent(event.itemCode, event.attributes);
|
action = new commonActions.DeviceUpdateEvent(event.itemCode, event.attributes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "notification": {
|
||||||
|
action = new commonActions.NotificationEvent(event.attributes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "DeleteUser": {
|
||||||
|
action = new commonActions.Logout();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,14 @@
|
|||||||
|
.avatar-container {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-text {
|
||||||
|
position: absolute;
|
||||||
|
top: 25px;
|
||||||
|
left: 10px;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
color: white;
|
||||||
|
padding-left: 20px;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
@@ -0,0 +1,10 @@
|
|||||||
|
<span class="avatar-container" [title]="name">
|
||||||
|
<ngx-avatar
|
||||||
|
class="farmmaps-avatar"
|
||||||
|
[src]="src"
|
||||||
|
[name]="name"
|
||||||
|
[size]="size"
|
||||||
|
[round]='true'
|
||||||
|
>
|
||||||
|
</ngx-avatar>
|
||||||
|
</span>
|
48
projects/common/src/fm/components/avatar/avatar.component.ts
Normal file
48
projects/common/src/fm/components/avatar/avatar.component.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges } from '@angular/core';
|
||||||
|
import { IUser } from '../../models/user';
|
||||||
|
import { AppConfig } from '../../shared/app.config';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-avatar',
|
||||||
|
templateUrl: './avatar.component.html',
|
||||||
|
styleUrls: ['./avatar.component.css']
|
||||||
|
})
|
||||||
|
export class AvatarComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() user: IUser;
|
||||||
|
@Input() bgColor: string;
|
||||||
|
@Input() fgColor: string;
|
||||||
|
@Input() size: number = 75;
|
||||||
|
@Input() round: boolean = true;
|
||||||
|
|
||||||
|
@Output() click = new EventEmitter();
|
||||||
|
|
||||||
|
src : string = null;
|
||||||
|
name : string = null;
|
||||||
|
|
||||||
|
constructor(private appConfig: AppConfig) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes['user']) {
|
||||||
|
const user: IUser = changes['user'].currentValue;
|
||||||
|
this.refresh(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClick(event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
this.click.emit();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh(user: IUser) {
|
||||||
|
if (!user) return null;
|
||||||
|
const apiEndpoint = this.appConfig.getConfig("apiEndPoint");
|
||||||
|
this.src = `${apiEndpoint}/api/v1/users/${user.code}/avatar`;
|
||||||
|
this.name = user.firstName && user.lastName ?
|
||||||
|
user.firstName + ' ' + user.lastName : user.name;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,25 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { BackButtonComponent } from './back-button.component';
|
|
||||||
|
|
||||||
describe('BackButtonComponent', () => {
|
|
||||||
let component: BackButtonComponent;
|
|
||||||
let fixture: ComponentFixture<BackButtonComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ BackButtonComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(BackButtonComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
@@ -0,0 +1,36 @@
|
|||||||
|
<ng-template #upload_modal let-modal>
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" i18n>Edit image</h4>
|
||||||
|
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="cropper">
|
||||||
|
<div *ngIf="!isImageLoaded" class="no-image" (click)="fileInput.click()">
|
||||||
|
<i class="fal fa-image"></i>
|
||||||
|
<div i18n>No image selected</div>
|
||||||
|
</div>
|
||||||
|
<image-cropper #imageCropper
|
||||||
|
[imageChangedEvent]="imageChangedEvent"
|
||||||
|
[maintainAspectRatio]="true"
|
||||||
|
[format]="imageType"
|
||||||
|
[aspectRatio]="aspectRatio"
|
||||||
|
[autoCrop]="true"
|
||||||
|
[resizeToWidth]="maxWidth"
|
||||||
|
[roundCropper]="roundImage"
|
||||||
|
(imageCropped)="imageCropped($event)"
|
||||||
|
(imageLoaded)="imageLoaded($event)"
|
||||||
|
(cropperReady)="cropperReady()"
|
||||||
|
(loadImageFailed)="loadImageFailed()"
|
||||||
|
[imageURL]="imageUrl"
|
||||||
|
></image-cropper>
|
||||||
|
</div>
|
||||||
|
<input #fileInput type="file" (change)="fileChangeEvent($event)" style="display:none" accept="image/*"/>
|
||||||
|
<span class="btn btn-primary" (click)="fileInput.click()" i18n>Select image</span>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="submit" class="btn btn-primary" i18n [disabled]="!isImageLoaded" (click)="save()">Apply</button>
|
||||||
|
<button type="button" autofocus class="btn btn-secondary" (click)="modal.close('Save click')" i18n="@@buttonCancel">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
@@ -0,0 +1,13 @@
|
|||||||
|
.cropper {
|
||||||
|
position: relative;
|
||||||
|
height: calc(60vh);
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-image {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-image i {
|
||||||
|
font-size: calc(50vh);
|
||||||
|
color: gray;
|
||||||
|
}
|
@@ -0,0 +1,73 @@
|
|||||||
|
import { Component, OnInit,ViewChild,ElementRef,EventEmitter, Output } from '@angular/core';
|
||||||
|
import { HttpClient, HttpParams,HttpHeaders } from "@angular/common/http";
|
||||||
|
import {NgbModal} from "@ng-bootstrap/ng-bootstrap"
|
||||||
|
import { ImageCroppedEvent,LoadedImage } from 'ngx-image-cropper';
|
||||||
|
import {ImageService } from '../../services/image.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-edit-image-modal',
|
||||||
|
templateUrl: './edit-image-modal.component.html',
|
||||||
|
styleUrls: ['./edit-image-modal.component.scss']
|
||||||
|
})
|
||||||
|
export class EditImageModalComponent implements OnInit {
|
||||||
|
|
||||||
|
@Output() changed = new EventEmitter();
|
||||||
|
@ViewChild('upload_modal') modal:ElementRef;
|
||||||
|
|
||||||
|
constructor(private modalService: NgbModal,public imageService:ImageService) { }
|
||||||
|
|
||||||
|
isImageLoaded:boolean = false;
|
||||||
|
aspectRatio:number = 4/3;
|
||||||
|
imageChangedEvent: any = '';
|
||||||
|
croppedImage: string = '';
|
||||||
|
endpointUrl:string = null;
|
||||||
|
imageUrl:string = null;
|
||||||
|
maxWidth:number = 200;
|
||||||
|
roundImage:boolean = false;
|
||||||
|
imageType:string = "jpeg";
|
||||||
|
saveImage:boolean = true;
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
open(endpoint:string,aspectRatio:number,roundImage?:boolean,maxWidth?:number,saveImage?:boolean, imageType?:string) {
|
||||||
|
this.endpointUrl = endpoint;
|
||||||
|
this.imageUrl = endpoint;
|
||||||
|
this.aspectRatio= aspectRatio;
|
||||||
|
this.roundImage = roundImage === undefined?this.roundImage:roundImage;
|
||||||
|
this.maxWidth = maxWidth === undefined?this.maxWidth:maxWidth;
|
||||||
|
this.imageType = imageType === undefined?this.imageType:imageType.substr(6);
|
||||||
|
this.saveImage = saveImage === undefined?this.saveImage:saveImage;
|
||||||
|
this.modalService.open(this.modal,{ size: 'lg' });
|
||||||
|
}
|
||||||
|
|
||||||
|
fileChangeEvent(event: any): void {
|
||||||
|
this.imageChangedEvent = event;
|
||||||
|
}
|
||||||
|
imageCropped(event: ImageCroppedEvent) {
|
||||||
|
this.croppedImage = event.base64;
|
||||||
|
}
|
||||||
|
imageLoaded(image: LoadedImage) {
|
||||||
|
this.isImageLoaded=true;
|
||||||
|
}
|
||||||
|
cropperReady() {
|
||||||
|
// cropper ready
|
||||||
|
}
|
||||||
|
loadImageFailed() {
|
||||||
|
// show message
|
||||||
|
}
|
||||||
|
|
||||||
|
save() {
|
||||||
|
if(this.croppedImage) {
|
||||||
|
var blob = this.imageService.dataUrltoBlob(this.croppedImage);
|
||||||
|
if(this.saveImage) {
|
||||||
|
this.imageService.putImage(this.endpointUrl,blob).subscribe(() => {
|
||||||
|
this.changed.emit({});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.changed.emit({ "croppedImage": this.imageService.blobToFile(blob,"croppedimage.jpg")} );
|
||||||
|
}
|
||||||
|
this.modalService.dismissAll("Save");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -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,36 +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: '[fm-haspackage]',
|
selector: '[fmHasPackage]',
|
||||||
})
|
})
|
||||||
export class HasPackageDirective implements OnInit,OnDestroy{
|
export class HasPackageDirective implements OnDestroy, AfterViewInit {
|
||||||
@Input('fm-haspackage') package:string;
|
|
||||||
|
|
||||||
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private store$: Store<appCommonReducer.State>) { }
|
@Input()
|
||||||
private packages$:Observable<IPackages> = this.store$.select(appCommonReducer.SelectGetUserPackages);
|
set fmHasPackage(packageIdentifier: string) {
|
||||||
private hasView = false;
|
this.packageIdentifier = packageIdentifier;
|
||||||
private packSub:Subscription;
|
this.updateView();
|
||||||
ngOnInit() {
|
}
|
||||||
this.packages$.subscribe((packages) => {
|
|
||||||
const today = new Date(new Date(Date.now()).toUTCString()).setHours(0,0,0,0);
|
@Input()
|
||||||
if (packages[this.package] &&
|
set fmHasPackageThen(thenTemplate: TemplateRef<any>) {
|
||||||
packages[this.package].enabled &&
|
this.thenTemplate = thenTemplate;
|
||||||
(packages[this.package].dataDate && new Date(packages[this.package].dataDate).setHours(0, 0, 0, 0) <= today) &&
|
this.updateView();
|
||||||
(packages[this.package].dataEndDate == null || new Date(packages[this.package].dataEndDate).setHours(0, 0, 0, 0) >= today)) {
|
}
|
||||||
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
|
||||||
this.hasView=true;
|
@Input()
|
||||||
} else if (this.hasView) {
|
set fmHasPackageElse(thenTemplate: TemplateRef<any>) {
|
||||||
this.viewContainerRef$.clear();
|
this.elseTemplate = thenTemplate;
|
||||||
this.hasView = false;
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private packageIdentifier: string;
|
||||||
|
private thenTemplate: TemplateRef<any>;
|
||||||
|
private elseTemplate: TemplateRef<any>;
|
||||||
|
private packSub: Subscription;
|
||||||
|
|
||||||
|
constructor(private hostTemplateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef,
|
||||||
|
private store: Store<appCommonReducer.State>, private packageService: PackageService) {
|
||||||
|
this.thenTemplate = hostTemplateRef;
|
||||||
|
this.packSub = this.store.select(appCommonReducer.SelectGetValidUserPackages).subscribe((_) => {
|
||||||
|
this.updateView();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngAfterViewInit() {
|
||||||
if(this.packSub) this.packSub.unsubscribe();
|
this.updateView();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
updateView() {
|
||||||
|
this.viewContainerRef.clear();
|
||||||
|
if (this.packageService.hasPackage(this.packageIdentifier)) {
|
||||||
|
this.viewContainerRef.createEmbeddedView(this.thenTemplate);
|
||||||
|
} else if (this.elseTemplate) {
|
||||||
|
this.viewContainerRef.createEmbeddedView(this.elseTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
if (this.packSub) {
|
||||||
|
this.packSub.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
<div class="mobile-hide">
|
||||||
|
<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>
|
||||||
|
<div class="menu hidden" [ngClass]="{'hidden':!showMenu}">
|
||||||
|
<router-outlet name="help-menu" (activate)="activateRoute()" (deactivate)="deActivateRoute()"></router-outlet>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@@ -0,0 +1,90 @@
|
|||||||
|
.menu-button {
|
||||||
|
background-color: gray;
|
||||||
|
display: inline-block;
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
line-height: 2.5em;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1rem;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.menu-button > span {
|
||||||
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
max-height: calc( 100vh - 4rem);
|
||||||
|
//transition: max-height 0.2s;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 0 20px rgba(0,0,0,.3);
|
||||||
|
position: fixed;
|
||||||
|
top: 3.4rem;
|
||||||
|
right:0.5rem;
|
||||||
|
left:0.5rem;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host-context(.fullscreen) .menu {
|
||||||
|
top:4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding:0.5rem;
|
||||||
|
min-width: 10rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-body {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
max-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu.hidden {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-button.hidden {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media screen and (min-width: 44rem) {
|
||||||
|
.menu {
|
||||||
|
position: absolute;
|
||||||
|
top: 3rem;
|
||||||
|
right:0;
|
||||||
|
left: unset;
|
||||||
|
max-width: 30em;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host-context(.fullscreen) .menu {
|
||||||
|
top: 3rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-hide {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 768px) {
|
||||||
|
.mobile-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.unread {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top:-0.5em;
|
||||||
|
right: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unread.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
import { Input } from '@angular/core';
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
import { IUser } from '../../models/user';
|
||||||
|
import {Store} from '@ngrx/store';
|
||||||
|
import * as appReducers from '../../reducers/app-common.reducer';
|
||||||
|
import * as appActions from '../../actions/app-common.actions';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-help-menu',
|
||||||
|
templateUrl: './help-menu.component.html',
|
||||||
|
styleUrls: ['./help-menu.component.scss']
|
||||||
|
})
|
||||||
|
export class HelpMenuComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() user:IUser;
|
||||||
|
@Input() showMenu:boolean;
|
||||||
|
public noContent: boolean = true;
|
||||||
|
|
||||||
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle(event:MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
this.store.dispatch(new appActions.ToggleHelpMenu());
|
||||||
|
}
|
||||||
|
|
||||||
|
activateRoute() {
|
||||||
|
this.noContent=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
deActivateRoute() {
|
||||||
|
this.noContent=true;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user