Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
9e3f6010c3 | |||
e6a637b866 | |||
|
ccf77805a0 | ||
2b2e1bfafa | |||
3fd4ac2f94 | |||
9849eaf1e7 | |||
b516cc07e2 | |||
c9c9a2ddbf | |||
1d0f3b958d | |||
45537cb2e9 | |||
652ddc0cdc | |||
fd3b331cc0 | |||
9facbe76c8 | |||
20dff38cf7 | |||
e374bb8a73 | |||
294b9c6dd3 | |||
d92bf54c8d | |||
914e272fc2 | |||
|
b182b7fda6 | ||
|
22040b43b3 | ||
|
50170cf599 | ||
|
2deff46a7e | ||
|
e939a787ba | ||
|
4ae9562ce1 | ||
|
288e507e6c | ||
d9848a8ba3 | |||
a9d42484cc | |||
a276593c7f | |||
ff50650c28 | |||
d7efeb8d59 | |||
fd71d1f38e | |||
bc8c9f8bf9 | |||
0865ca1a93 | |||
1bc3983f55 | |||
945d88839f | |||
7c06343909 | |||
b8f8f27794 | |||
2a31771ac6 | |||
3f17341b2e | |||
6165f523cc | |||
19dce51a28 | |||
b29cd8e4c9 | |||
|
f2e265391c | ||
|
3c7adf012f | ||
7c8c16362c | |||
6555e68145 | |||
945c641503 | |||
60bc4c1a10 | |||
7b42ca252b | |||
9ef6c4d308 | |||
|
ed7f7923ca | ||
|
98142fab56 | ||
|
c460d31522 | ||
|
4c5b89852b | ||
|
fa90eaf1af | ||
aeded938bd | |||
c61a4fe7f4 | |||
8c3c40cfe6 | |||
e6e10c835e | |||
07a87175b4 | |||
e9ace73ddd |
22
.eslintrc.js
Normal file
22
.eslintrc.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -49,3 +49,6 @@ Thumbs.db
|
|||||||
projects/common/node_modules/
|
projects/common/node_modules/
|
||||||
projects/common-map/node_modules/
|
projects/common-map/node_modules/
|
||||||
.angular/*
|
.angular/*
|
||||||
|
projects/common-map3d/node_modules/
|
||||||
|
projects/common-map/node_modules/
|
||||||
|
projects/common/node_modules/
|
||||||
|
54
Jenkinsfile
vendored
54
Jenkinsfile
vendored
@@ -1,54 +1,24 @@
|
|||||||
|
@Library('farmmaps-shared-library') _
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any;
|
||||||
environment {
|
options {
|
||||||
PACKAGE_VERSION_PREFIX=sh(script: 'jq .version package.json |sed "s/\\"//g"', returnStdout: true).trim()
|
copyArtifactPermission projectNames: env.allProjectsArtifactPermission;
|
||||||
PACKAGE_VERSION="${PACKAGE_VERSION_PREFIX}"
|
disableConcurrentBuilds abortPrevious: true;
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('npm install'){
|
stage('FarmmapsLibBuildAll') {
|
||||||
steps {
|
steps {
|
||||||
sh '''rm -rf node_modules/
|
stepFarmmapsLibBuildAll();
|
||||||
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 {
|
post {
|
||||||
|
success {
|
||||||
|
postSuccess();
|
||||||
|
}
|
||||||
always {
|
always {
|
||||||
emailext (
|
postAlways();
|
||||||
body: '${DEFAULT_CONTENT}',
|
|
||||||
mimeType: 'text/html',
|
|
||||||
replyTo: '${DEFAULT_REPLYTO}',
|
|
||||||
subject: '${DEFAULT_SUBJECT}',
|
|
||||||
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,54 +1,24 @@
|
|||||||
|
@Library('farmmaps-shared-library') _
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any;
|
||||||
environment {
|
options {
|
||||||
PACKAGE_VERSION_PREFIX=sh(script: 'jq .version package.json |sed "s/\\"//g"', returnStdout: true).trim()
|
copyArtifactPermission projectNames: env.allProjectsArtifactPermission;
|
||||||
PACKAGE_VERSION="${PACKAGE_VERSION_PREFIX + '-prerelease.' + env.BUILD_NUMBER}"
|
disableConcurrentBuilds abortPrevious: true;
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('npm install'){
|
stage('FarmmapsLibBuildAll') {
|
||||||
steps {
|
steps {
|
||||||
sh '''rm -rf node_modules/
|
stepFarmmapsLibBuildAll();
|
||||||
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}
|
|
||||||
npm publish
|
|
||||||
cd ../common-map
|
|
||||||
npm version ${PACKAGE_VERSION}
|
|
||||||
npm publish
|
|
||||||
cd ../common-map3d
|
|
||||||
npm version ${PACKAGE_VERSION}
|
|
||||||
npm publish'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
success {
|
||||||
|
postSuccess();
|
||||||
|
}
|
||||||
always {
|
always {
|
||||||
emailext (
|
postAlways();
|
||||||
body: '${DEFAULT_CONTENT}',
|
|
||||||
mimeType: 'text/html',
|
|
||||||
replyTo: '${DEFAULT_REPLYTO}',
|
|
||||||
subject: '${DEFAULT_SUBJECT}',
|
|
||||||
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']])
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -55,5 +55,11 @@ ng serve
|
|||||||
|
|
||||||
Point your browser to http://localhost:4200
|
Point your browser to http://localhost:4200
|
||||||
|
|
||||||
|
*ESLint*
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run lint src
|
||||||
|
npm run lint projects/common/src
|
||||||
|
npm run lint projects/common-map/src
|
||||||
|
npm run lint projects/common-map3d/src
|
||||||
|
```
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 143 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -51,7 +51,17 @@
|
|||||||
content: "i";
|
content: "i";
|
||||||
}
|
}
|
||||||
|
|
||||||
hallo
|
.fm-carbon:before {
|
||||||
|
content: "j";
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-bo-akkerbouw:before {
|
||||||
|
content: "k";
|
||||||
|
}
|
||||||
|
|
||||||
|
.fm-grass:before {
|
||||||
|
content: "l";
|
||||||
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "FarmMaps";
|
font-family: "FarmMaps";
|
||||||
|
3643
package-lock.json
generated
3643
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "farmmaps-lib-app",
|
"name": "farmmaps-lib-app",
|
||||||
"version": "3.0.1",
|
"version": "3.5.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "eslint -c .eslintrc.js --ext .ts",
|
||||||
"e2e": "ng e2e"
|
"e2e": "ng e2e"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"@angular/common": "^14.1.3",
|
"@angular/common": "^14.1.3",
|
||||||
"@angular/compiler": "^14.1.3",
|
"@angular/compiler": "^14.1.3",
|
||||||
"@angular/core": "^14.1.3",
|
"@angular/core": "^14.1.3",
|
||||||
|
"@angular-eslint/eslint-plugin": "^15.2.1",
|
||||||
"@angular/forms": "^14.1.3",
|
"@angular/forms": "^14.1.3",
|
||||||
"@angular/platform-browser": "^14.1.3",
|
"@angular/platform-browser": "^14.1.3",
|
||||||
"@angular/platform-browser-dynamic": "^14.1.3",
|
"@angular/platform-browser-dynamic": "^14.1.3",
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
"ol": "6.14.1",
|
"ol": "6.14.1",
|
||||||
"olcs": "^2.13.1",
|
"olcs": "^2.13.1",
|
||||||
"resumablejs": "^1.1.0",
|
"resumablejs": "^1.1.0",
|
||||||
"rxjs": "^6.6.7",
|
"rxjs": "^7.8.1",
|
||||||
"stream": "^0.0.2",
|
"stream": "^0.0.2",
|
||||||
"stream-http": "^3.2.0",
|
"stream-http": "^3.2.0",
|
||||||
"tassign": "^1.0.0",
|
"tassign": "^1.0.0",
|
||||||
@@ -66,7 +67,13 @@
|
|||||||
"@types/jasmine": "~2.8.8",
|
"@types/jasmine": "~2.8.8",
|
||||||
"@types/jasminewd2": "^2.0.9",
|
"@types/jasminewd2": "^2.0.9",
|
||||||
"@types/node": "^12.20.15",
|
"@types/node": "^12.20.15",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||||
|
"@typescript-eslint/eslint-plugin-tslint": "^5.54.0",
|
||||||
|
"@typescript-eslint/parser": "^5.54.0",
|
||||||
"codelyzer": "^0.0.28",
|
"codelyzer": "^0.0.28",
|
||||||
|
"eslint": "^8.35.0",
|
||||||
|
"eslint-config-prettier": "^8.6.0",
|
||||||
|
"eslint-plugin-import": "^2.27.5",
|
||||||
"jasmine-core": "^4.3.0",
|
"jasmine-core": "^4.3.0",
|
||||||
"jasmine-spec-reporter": "^7.0.0",
|
"jasmine-spec-reporter": "^7.0.0",
|
||||||
"karma": "^6.3.20",
|
"karma": "^6.3.20",
|
||||||
@@ -77,7 +84,6 @@
|
|||||||
"ng-packagr": "^14.1.0",
|
"ng-packagr": "^14.1.0",
|
||||||
"protractor": "~7.0.0",
|
"protractor": "~7.0.0",
|
||||||
"ts-node": "^8.8.1",
|
"ts-node": "^8.8.1",
|
||||||
"tslint": "~6.1.0",
|
|
||||||
"typescript": "~4.6.4"
|
"typescript": "~4.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
projects/common-map/.eslintrc.js
Normal file
22
projects/common-map/.eslintrc.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
25
projects/common-map/package-lock.json
generated
25
projects/common-map/package-lock.json
generated
@@ -1,10 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "@farmmaps/common-map",
|
"name": "@farmmaps/common-map",
|
||||||
"version": "0.0.1",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"packages": {
|
||||||
"tslib": {
|
"": {
|
||||||
|
"name": "@farmmaps/common-map",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/core": ">=14.0.0",
|
||||||
|
"@ngrx/effects": ">=14.0.0",
|
||||||
|
"@ngrx/router-store": ">=14.0.0",
|
||||||
|
"@ngrx/store": ">=14.0.0",
|
||||||
|
"ngrx-store-localstorage": ">=14.0.0",
|
||||||
|
"ngx-openlayers": ">=1.0.0-next.19",
|
||||||
|
"ol": ">=6.8.1",
|
||||||
|
"tassign": ">=1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tslib": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
|
||||||
"integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ=="
|
"integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ=="
|
||||||
|
@@ -79,13 +79,13 @@ export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any
|
|||||||
const r2 = reducer(state, action);
|
const r2 = reducer(state, action);
|
||||||
|
|
||||||
if(action.type == "@ngrx/store/update-reducers") {
|
if(action.type == "@ngrx/store/update-reducers") {
|
||||||
let ms = window.localStorage.getItem(MODULE_NAME+"_mapState");
|
const ms = window.localStorage.getItem(MODULE_NAME+"_mapState");
|
||||||
if(ms) {
|
if(ms) {
|
||||||
r2["mapState"] = JSON.parse(ms);
|
r2["mapState"] = JSON.parse(ms);
|
||||||
}
|
}
|
||||||
let sp = window.localStorage.getItem(MODULE_NAME+"_searchPeriod");
|
const sp = window.localStorage.getItem(MODULE_NAME+"_searchPeriod");
|
||||||
if(sp) {
|
if(sp) {
|
||||||
let p = JSON.parse(sp);
|
const p = JSON.parse(sp);
|
||||||
r2["period"] = { startDate: new Date(Date.parse(p.startDate)),endDate:new Date(Date.parse(p.endDate))};
|
r2["period"] = { startDate: new Date(Date.parse(p.startDate)),endDate:new Date(Date.parse(p.endDate))};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ export class FileDropTargetComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.element = this.map.instance.getViewport();
|
this.element = this.map.instance.getViewport();
|
||||||
let other = this;
|
const other = this;
|
||||||
this.element.addEventListener('drop', this.onDrop, false);
|
this.element.addEventListener('drop', this.onDrop, false);
|
||||||
this.element.addEventListener('dragover', this.preventDefault, false);
|
this.element.addEventListener('dragover', this.preventDefault, false);
|
||||||
this.element.addEventListener('dragenter', this.preventDefault, false);
|
this.element.addEventListener('dragenter', this.preventDefault, false);
|
||||||
@@ -36,20 +36,20 @@ export class FileDropTargetComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private onDrop = (event: DragEvent) => {
|
private onDrop = (event: DragEvent) => {
|
||||||
this.stopEvent(event);
|
this.stopEvent(event);
|
||||||
let geojsonFormat = new GeoJSON();
|
const geojsonFormat = new GeoJSON();
|
||||||
var parentCode = this.parentCode;
|
let parentCode = this.parentCode;
|
||||||
var coordinate = this.map.instance.getEventCoordinate(event);
|
const coordinate = this.map.instance.getEventCoordinate(event);
|
||||||
//coordinate = proj.transform(coordinate, this.map.instance.getView().getProjection(), 'EPSG:4326');
|
//coordinate = proj.transform(coordinate, this.map.instance.getView().getProjection(), 'EPSG:4326');
|
||||||
var geometry:Geometry = new Point(coordinate);
|
let geometry:Geometry = new Point(coordinate);
|
||||||
var hitFeatures = this.map.instance.getFeaturesAtPixel([event.pageX, event.pageY]);
|
const hitFeatures = this.map.instance.getFeaturesAtPixel([event.pageX, event.pageY]);
|
||||||
var hitFeature = hitFeatures && hitFeatures.length > 0 ? hitFeatures[0] : null;
|
const hitFeature = hitFeatures && hitFeatures.length > 0 ? hitFeatures[0] : null;
|
||||||
if (hitFeature) {
|
if (hitFeature) {
|
||||||
if (hitFeature.get("code")) {
|
if (hitFeature.get("code")) {
|
||||||
parentCode = hitFeature.get("code");
|
parentCode = hitFeature.get("code");
|
||||||
}
|
}
|
||||||
geometry = geojsonFormat.readGeometry(geojsonFormat.writeGeometry(geometry)); // create copy instead of reference
|
geometry = geojsonFormat.readGeometry(geojsonFormat.writeGeometry(geometry)); // create copy instead of reference
|
||||||
}
|
}
|
||||||
var projectedGeometry = geometry.transform(this.map.instance.getView().getProjection(), 'EPSG:4326');
|
const projectedGeometry = geometry.transform(this.map.instance.getView().getProjection(), 'EPSG:4326');
|
||||||
|
|
||||||
if (event.dataTransfer && event.dataTransfer.files) {
|
if (event.dataTransfer && event.dataTransfer.files) {
|
||||||
this.onFileDropped.emit({ files: event.dataTransfer.files, event: event, geometry: JSON.parse(geojsonFormat.writeGeometry(projectedGeometry)),parentCode:parentCode})
|
this.onFileDropped.emit({ files: event.dataTransfer.files, event: event, geometry: JSON.parse(geojsonFormat.writeGeometry(projectedGeometry)),parentCode:parentCode})
|
||||||
|
@@ -15,16 +15,16 @@ export class GpsLocation implements OnInit,OnChanges{
|
|||||||
public instance: Overlay;
|
public instance: Overlay;
|
||||||
@Input() position: GeolocationPosition;
|
@Input() position: GeolocationPosition;
|
||||||
@Input() location: number[]=[0,0];
|
@Input() location: number[]=[0,0];
|
||||||
@Input() locationTolerance: number = 0;
|
@Input() locationTolerance = 0;
|
||||||
@Input() showHeading: boolean = false;
|
@Input() showHeading = false;
|
||||||
@Input() showTolerance: boolean = false;
|
@Input() showTolerance = false;
|
||||||
@Input() heading: number = 0;
|
@Input() heading = 0;
|
||||||
@Input() headingTolerance: number = 0;
|
@Input() headingTolerance = 0;
|
||||||
public locTolerancePixels: number = 0;
|
public locTolerancePixels = 0;
|
||||||
public path: string = "";
|
public path = "";
|
||||||
public rotate: string = "";
|
public rotate = "";
|
||||||
private resolution: number = 0;
|
private resolution = 0;
|
||||||
initialized:boolean = false;
|
initialized = false;
|
||||||
@ViewChild('location', { static: true }) locationElement: ElementRef;
|
@ViewChild('location', { static: true }) locationElement: ElementRef;
|
||||||
|
|
||||||
constructor(private map: MapComponent) {
|
constructor(private map: MapComponent) {
|
||||||
@@ -42,12 +42,12 @@ export class GpsLocation implements OnInit,OnChanges{
|
|||||||
position: fromLonLat( this.location),
|
position: fromLonLat( this.location),
|
||||||
element: this.locationElement.nativeElement
|
element: this.locationElement.nativeElement
|
||||||
});
|
});
|
||||||
var x = Math.tan(this.headingTolerance * Math.PI / 180)*40;
|
const x = Math.tan(this.headingTolerance * Math.PI / 180)*40;
|
||||||
var y = Math.cos(this.headingTolerance * Math.PI / 180) * 40;
|
const y = Math.cos(this.headingTolerance * Math.PI / 180) * 40;
|
||||||
var y1 = Math.round(500 - y);
|
const y1 = Math.round(500 - y);
|
||||||
var x1 = Math.round(500 - x);
|
const x1 = Math.round(500 - x);
|
||||||
var y2 = Math.round(y1);
|
const y2 = Math.round(y1);
|
||||||
var x2 = Math.round(500 + x);
|
const x2 = Math.round(500 + x);
|
||||||
this.path = "M " + x2 + " " + y2 + " A 45 45,0,0,0, " + x1 + " " + y1 + " L 493 500 L 507 500 Z";
|
this.path = "M " + x2 + " " + y2 + " A 45 45,0,0,0, " + x1 + " " + y1 + " L 493 500 L 507 500 Z";
|
||||||
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;
|
||||||
@@ -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 GeolocationPosition;
|
const 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;
|
||||||
|
@@ -35,7 +35,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
@Output() onFeatureHover: EventEmitter<any> = new EventEmitter<any>();
|
@Output() onFeatureHover: EventEmitter<any> = new EventEmitter<any>();
|
||||||
@Output() onPrerender: EventEmitter<any> = new EventEmitter<any>();
|
@Output() onPrerender: EventEmitter<any> = new EventEmitter<any>();
|
||||||
private _apiEndPoint: string;
|
private _apiEndPoint: string;
|
||||||
private initialized:boolean = false;
|
private initialized = false;
|
||||||
private mapEventHandlerInstalled = false;
|
private mapEventHandlerInstalled = false;
|
||||||
private topLayerPrerenderEventhandlerInstalled = false;
|
private topLayerPrerenderEventhandlerInstalled = false;
|
||||||
private selectedFeatures = {};
|
private selectedFeatures = {};
|
||||||
@@ -49,7 +49,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
private styleCache = {}
|
private styleCache = {}
|
||||||
|
|
||||||
componentToHex(c) {
|
componentToHex(c) {
|
||||||
var hex = c.toString(16);
|
const hex = c.toString(16);
|
||||||
return hex.length == 1 ? "0" + hex : hex;
|
return hex.length == 1 ? "0" + hex : hex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,28 +58,28 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
getColorFromGradient(layer: ILayer, value: number): IColor {
|
getColorFromGradient(layer: ILayer, value: number): IColor {
|
||||||
var gradient: IGradientstop[] = layer.renderer.colorMap.gradient;
|
const gradient: IGradientstop[] = layer.renderer.colorMap.gradient;
|
||||||
var histogram: IHistogram = layer.renderer.band.histogram;
|
const histogram: IHistogram = layer.renderer.band.histogram;
|
||||||
var index = (value - histogram.min) / histogram.max;
|
const index = (value - histogram.min) / histogram.max;
|
||||||
var min = gradient[0];
|
let min = gradient[0];
|
||||||
var max = gradient[gradient.length - 1];
|
let max = gradient[gradient.length - 1];
|
||||||
for (var n = 0; n < gradient.length; n++) {
|
for (let n = 0; n < gradient.length; n++) {
|
||||||
var s = gradient[n];
|
const s = gradient[n];
|
||||||
if (s.relativestop <= index && min.relativestop < s.relativestop && n < gradient.length - 1) min = s;
|
if (s.relativestop <= index && min.relativestop < s.relativestop && n < gradient.length - 1) min = s;
|
||||||
if (s.relativestop >= index && max.relativestop > s.relativestop && n > 0) max = s;
|
if (s.relativestop >= index && max.relativestop > s.relativestop && n > 0) max = s;
|
||||||
}
|
}
|
||||||
var i = index - min.relativestop;
|
const i = index - min.relativestop;
|
||||||
var size = max.relativestop - min.relativestop;
|
const size = max.relativestop - min.relativestop;
|
||||||
var alpha = Math.round(min.color.alpha + ((max.color.alpha - min.color.alpha) * i / size));
|
const 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));
|
const 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));
|
const 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));
|
const blue = Math.round(min.color.blue + ((max.color.blue - min.color.blue) * i / size));
|
||||||
|
|
||||||
return { alpha: alpha, red: red, green: green, blue: blue };
|
return { alpha: alpha, red: red, green: green, blue: blue };
|
||||||
}
|
}
|
||||||
|
|
||||||
getColorForValue(layer: ILayer, value: number): IColor {
|
getColorForValue(layer: ILayer, value: number): IColor {
|
||||||
var color: IColor = { alpha:0,red:0,green:0,blue:0};
|
let color: IColor = { alpha:0,red:0,green:0,blue:0};
|
||||||
if(layer.renderer.colorMap.entries.length>0) {
|
if(layer.renderer.colorMap.entries.length>0) {
|
||||||
color=layer.renderer.colorMap.noValue;
|
color=layer.renderer.colorMap.noValue;
|
||||||
}
|
}
|
||||||
@@ -94,10 +94,10 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
getColor(item: IItem, layer: ILayer, feature): style.Style {
|
getColor(item: IItem, layer: ILayer, feature): style.Style {
|
||||||
var value = layer.indexKey ? feature.get(layer.indexKey) : feature.get(layer.name);
|
const value = layer.indexKey ? feature.get(layer.indexKey) : feature.get(layer.name);
|
||||||
var key = item.code + "_" + value;
|
const key = item.code + "_" + value;
|
||||||
if (!this.styleCache[key]) {
|
if (!this.styleCache[key]) {
|
||||||
var color: IColor;
|
let color: IColor;
|
||||||
if(layer.renderer.colorMap.colormapType == "manual") {
|
if(layer.renderer.colorMap.colormapType == "manual") {
|
||||||
color = this.getColorForValue(layer, value);
|
color = this.getColorForValue(layer, value);
|
||||||
} else {
|
} else {
|
||||||
@@ -125,32 +125,32 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
let layerIndex = -1;
|
||||||
var layer: Layer<Source> = null;
|
let 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)}` });
|
const 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 });
|
||||||
var data = item.data;
|
const data = item.data;
|
||||||
var l = (data && data.layers && data.layers.length > 0) ? data.layers[0] : null;
|
const l = (data && data.layers && data.layers.length > 0) ? data.layers[0] : null;
|
||||||
if (l && l.rendering && l.rendering.renderoutputType == "Tiles") {
|
if (l && l.rendering && l.rendering.renderoutputType == "Tiles") {
|
||||||
var rt = l.rendering as IRenderoutputTiles;
|
const rt = l.rendering as IRenderoutputTiles;
|
||||||
let source = new XYZ({crossOrigin: 'use-credentials', maxZoom: rt.maxzoom, minZoom: rt.minzoom, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${Date.parse(item.updated)}` });
|
const source = new XYZ({crossOrigin: 'use-credentials', maxZoom: rt.maxzoom, minZoom: rt.minzoom, 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 });
|
||||||
}
|
}
|
||||||
if (l && l.rendering && l.rendering.renderoutputType == "Image") {
|
if (l && l.rendering && l.rendering.renderoutputType == "Image") {
|
||||||
var ri = l.rendering as IRenderoutputImage;
|
const ri = l.rendering as IRenderoutputImage;
|
||||||
let source = new ImageStatic({ imageExtent:ri.extent,projection:'EPSG:3857', crossOrigin: 'use-credentials', url: `${this._apiEndPoint}/api/v1/items/${item.code}/mapimage/${layerIndex}?v=${Date.parse(item.updated)}` });
|
const source = new ImageStatic({ imageExtent:ri.extent,projection:'EPSG:3857', crossOrigin: 'use-credentials', url: `${this._apiEndPoint}/api/v1/items/${item.code}/mapimage/${layerIndex}?v=${Date.parse(item.updated)}` });
|
||||||
layer = new Image({ source: source });
|
layer = new Image({ source: source });
|
||||||
}
|
}
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
let layerIndex = -1;
|
||||||
var layer: Layer<Source> = null;
|
let 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;
|
const data = item.data;
|
||||||
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
const 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") {
|
||||||
var rt = l.rendering as IRenderoutputTiles;
|
var rt = l.rendering as IRenderoutputTiles;
|
||||||
layer = new VectorTileLayer({
|
layer = new VectorTileLayer({
|
||||||
@@ -175,15 +175,15 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let __this = this;
|
const __this = this;
|
||||||
let format = new GeoJSON();
|
const format = new GeoJSON();
|
||||||
let source = new VectorSource({
|
const 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<Geometry>;
|
const 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);
|
const features = format.readFeatures(data);
|
||||||
for (let f of features) {
|
for (const f of features) {
|
||||||
if (f.get("code")) {
|
if (f.get("code")) {
|
||||||
f.setId(f.get("code"));
|
f.setId(f.get("code"));
|
||||||
}
|
}
|
||||||
@@ -196,9 +196,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
declutter: true,
|
declutter: true,
|
||||||
source: source,
|
source: source,
|
||||||
style: (feature) => {
|
style: (feature) => {
|
||||||
var key =feature.get("code") + "_" + feature.get("color");
|
const key =feature.get("code") + "_" + feature.get("color");
|
||||||
if (!this.styleCache[key]) {
|
if (!this.styleCache[key]) {
|
||||||
var color = feature.get("color");
|
const color = feature.get("color");
|
||||||
this.styleCache[key] = new style.Style(
|
this.styleCache[key] = new style.Style(
|
||||||
{
|
{
|
||||||
fill: new style.Fill({
|
fill: new style.Fill({
|
||||||
@@ -235,11 +235,11 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
createSelectionLayer(itemLayer:IItemLayer):Layer<Source> {
|
createSelectionLayer(itemLayer:IItemLayer):Layer<Source> {
|
||||||
var layerIndex = -1;
|
let layerIndex = -1;
|
||||||
var layer: Layer<Source> = null;
|
const 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;
|
const data = itemLayer.item.data;
|
||||||
var l:ILayer = (data && data.layers && data.layers.length > 0) ? data.layers[layerIndex] : null;
|
const 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',
|
||||||
@@ -250,8 +250,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
return new style.Style(
|
return new style.Style(
|
||||||
{
|
{
|
||||||
stroke: new style.Stroke({
|
stroke: new style.Stroke({
|
||||||
color: 'red',
|
color: '#0d6efd',
|
||||||
width: 2
|
width: 3
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -265,36 +265,36 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer<Source> {
|
||||||
let data = item.data as ILayerData;
|
const data = item.data as ILayerData;
|
||||||
var layer: Layer<Source> = null;
|
let layer: Layer<Source> = null;
|
||||||
switch (data.interfaceType) {
|
switch (data.interfaceType) {
|
||||||
case 'OSM': {
|
case 'OSM': {
|
||||||
let source = new OSM();
|
const source = new OSM();
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'BingMaps': {
|
case 'BingMaps': {
|
||||||
let source = new BingMaps(data.options);
|
const source = new BingMaps(data.options);
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'TileWMS': {
|
case 'TileWMS': {
|
||||||
let source = new TileWMS(data.options);
|
const source = new TileWMS(data.options);
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'TileJSON': {
|
case 'TileJSON': {
|
||||||
let source = new TileJSON(data.options);
|
const source = new TileJSON(data.options);
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'TileArcGISRest': {
|
case 'TileArcGISRest': {
|
||||||
let source = new TileArcGISRest(data.options);
|
const source = new TileArcGISRest(data.options);
|
||||||
layer = new Tile({ source: source });
|
layer = new Tile({ source: source });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'VectorWFSJson': {
|
case 'VectorWFSJson': {
|
||||||
let source = new VectorSource({
|
const source = new VectorSource({
|
||||||
format: new GeoJSON(),
|
format: new GeoJSON(),
|
||||||
url: function (extent) {
|
url: function (extent) {
|
||||||
return (
|
return (
|
||||||
@@ -317,8 +317,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
createLayer(itemLayer: IItemLayer): Layer<Source> {
|
createLayer(itemLayer: IItemLayer): Layer<Source> {
|
||||||
var layer: Layer<Source> = null;
|
let layer: Layer<Source> = null;
|
||||||
var layerIndex = -1;
|
const 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);
|
||||||
} else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.shape.processed') {
|
} else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.shape.processed') {
|
||||||
@@ -327,8 +327,8 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
layer = this.createExternalLayer(itemLayer.item,itemLayer);
|
layer = this.createExternalLayer(itemLayer.item,itemLayer);
|
||||||
}
|
}
|
||||||
if (layer) {
|
if (layer) {
|
||||||
let geometry = new GeoJSON().readGeometry(itemLayer.item.geometry);
|
const geometry = new GeoJSON().readGeometry(itemLayer.item.geometry);
|
||||||
let extent = geometry ? proj.transformExtent(geometry.getExtent(), 'EPSG:4326', 'EPSG:3857') : null;
|
const extent = geometry ? proj.transformExtent(geometry.getExtent(), 'EPSG:4326', 'EPSG:3857') : null;
|
||||||
if (extent) layer.setExtent(extent);
|
if (extent) layer.setExtent(extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
if(this.topLayerPrerenderEventhandlerInstalled && this.onPrerender.observers.length > 0 )
|
if(this.topLayerPrerenderEventhandlerInstalled && this.onPrerender.observers.length > 0 )
|
||||||
{
|
{
|
||||||
if(this.instance.getVisible()) {
|
if(this.instance.getVisible()) {
|
||||||
var olLayers = this.instance.getLayers().getArray().forEach((l:any) => {
|
const olLayers = this.instance.getLayers().getArray().forEach((l:any) => {
|
||||||
l.un('prerender',this.topLayerPrerenderEventhandler);
|
l.un('prerender',this.topLayerPrerenderEventhandler);
|
||||||
l.un('postrender',this.topLayerPostrenderEventhandler);
|
l.un('postrender',this.topLayerPostrenderEventhandler);
|
||||||
});
|
});
|
||||||
@@ -390,9 +390,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
|
|
||||||
addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer<Source> {
|
addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer<Source> {
|
||||||
if(!itemLayer) return null;
|
if(!itemLayer) return null;
|
||||||
var olLayers = this.instance.getLayers();
|
const olLayers = this.instance.getLayers();
|
||||||
var layer = itemLayer.layer;
|
let layer = itemLayer.layer;
|
||||||
let olIndex = olLayers.getArray().indexOf(layer);
|
const olIndex = olLayers.getArray().indexOf(layer);
|
||||||
if (olIndex < 0) {
|
if (olIndex < 0) {
|
||||||
// New layer: we add it to the map
|
// New layer: we add it to the map
|
||||||
layer = this.createLayer(itemLayer);
|
layer = this.createLayer(itemLayer);
|
||||||
@@ -415,33 +415,33 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
updateLayers(itemLayers: IItemLayer[] | IItemLayer) {
|
updateLayers(itemLayers: IItemLayer[] | IItemLayer) {
|
||||||
this.unInstallTopLayerPrerenderEventhandler();
|
this.unInstallTopLayerPrerenderEventhandler();
|
||||||
let dataLayer = false;
|
let dataLayer = false;
|
||||||
var ils:IItemLayer[] = [];
|
let ils:IItemLayer[] = [];
|
||||||
if(Array.isArray(itemLayers)) {
|
if(Array.isArray(itemLayers)) {
|
||||||
ils = itemLayers;
|
ils = itemLayers;
|
||||||
} else {
|
} else {
|
||||||
dataLayer=true;
|
dataLayer=true;
|
||||||
ils=[itemLayers];
|
ils=[itemLayers];
|
||||||
}
|
}
|
||||||
let newLayers: Layer<Source>[] = [];
|
const newLayers: Layer<Source>[] = [];
|
||||||
if (ils) {
|
if (ils) {
|
||||||
ils.forEach((itemLayer, index) => {
|
ils.forEach((itemLayer, index) => {
|
||||||
if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
||||||
let il = itemLayer as ITemporalItemLayer;
|
const il = itemLayer as ITemporalItemLayer;
|
||||||
let previousLayer = this.addOrUpdateOlLayer(il.previousItemLayer,newLayers.length);
|
const previousLayer = this.addOrUpdateOlLayer(il.previousItemLayer,newLayers.length);
|
||||||
if(previousLayer) newLayers.push(previousLayer);
|
if(previousLayer) newLayers.push(previousLayer);
|
||||||
let selectedLayer = this.addOrUpdateOlLayer(il.selectedItemLayer,newLayers.length);
|
const selectedLayer = this.addOrUpdateOlLayer(il.selectedItemLayer,newLayers.length);
|
||||||
if(selectedLayer) newLayers.push(selectedLayer);
|
if(selectedLayer) newLayers.push(selectedLayer);
|
||||||
let nextLayer = this.addOrUpdateOlLayer(il.nextItemLayer,newLayers.length);
|
const nextLayer = this.addOrUpdateOlLayer(il.nextItemLayer,newLayers.length);
|
||||||
if(nextLayer) newLayers.push(nextLayer);
|
if(nextLayer) newLayers.push(nextLayer);
|
||||||
this.installTopLayerPrerenderEventhandler(selectedLayer);
|
this.installTopLayerPrerenderEventhandler(selectedLayer);
|
||||||
} else {
|
} else {
|
||||||
let layer = this.addOrUpdateOlLayer(itemLayer,newLayers.length);
|
const layer = this.addOrUpdateOlLayer(itemLayer,newLayers.length);
|
||||||
if(layer) newLayers.push(layer);
|
if(layer) newLayers.push(layer);
|
||||||
this.installTopLayerPrerenderEventhandler(layer);
|
this.installTopLayerPrerenderEventhandler(layer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Remove the layers that have disapeared from childrenLayers
|
// Remove the layers that have disapeared from childrenLayers
|
||||||
var olLayers = this.instance.getLayers();
|
const olLayers = this.instance.getLayers();
|
||||||
while(olLayers.getLength() > newLayers.length) {
|
while(olLayers.getLength() > newLayers.length) {
|
||||||
olLayers.removeAt(newLayers.length);
|
olLayers.removeAt(newLayers.length);
|
||||||
}
|
}
|
||||||
@@ -466,21 +466,21 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
mapEventHandler = (event) => {
|
mapEventHandler = (event) => {
|
||||||
// select only when having observers
|
// select only when having observers
|
||||||
if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
if(event.type === 'click' && !this.onFeatureSelected.observers.length) return;
|
||||||
if(event.type === 'pointermove' && !this.onFeatureHover.observers.length) return;
|
if(event.type === 'pointermove' && !this.onFeatureHover.observers.length) return;
|
||||||
let itemLayer= this.getItemlayer(this.itemLayer);
|
const itemLayer= this.getItemlayer(this.itemLayer);
|
||||||
if(itemLayer && itemLayer.layer) {
|
if(itemLayer && itemLayer.layer) {
|
||||||
this.selectedFeatures = {};
|
this.selectedFeatures = {};
|
||||||
if(itemLayer.layer ) {
|
if(itemLayer.layer ) {
|
||||||
let minZoom = itemLayer.layer.getMinZoom();
|
const minZoom = itemLayer.layer.getMinZoom();
|
||||||
let currentZoom = this.map.instance.getView().getZoom();
|
const currentZoom = this.map.instance.getView().getZoom();
|
||||||
if(currentZoom>minZoom) {
|
if(currentZoom>minZoom) {
|
||||||
itemLayer.layer.getFeatures(event.pixel).then((features) => {
|
itemLayer.layer.getFeatures(event.pixel).then((features) => {
|
||||||
if(!features.length) {
|
if(!features.length) {
|
||||||
this.onFeatureHover.emit(null);
|
this.onFeatureHover.emit(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let fid = features[0].getId();
|
const fid = features[0].getId();
|
||||||
let feature = features[0];
|
const feature = features[0];
|
||||||
if(event.type === 'pointermove') {
|
if(event.type === 'pointermove') {
|
||||||
this.selectedFeatures[fid] = features[0];
|
this.selectedFeatures[fid] = features[0];
|
||||||
this.onFeatureHover.emit({ "feature": feature,"itemCode":itemLayer.item.code });
|
this.onFeatureHover.emit({ "feature": feature,"itemCode":itemLayer.item.code });
|
||||||
@@ -502,11 +502,11 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.instance && this.initialized) {
|
if (this.instance && this.initialized) {
|
||||||
if (changes['itemLayers']) {
|
if (changes['itemLayers']) {
|
||||||
var itemLayers = changes['itemLayers'].currentValue as IItemLayer[];
|
const itemLayers = changes['itemLayers'].currentValue as IItemLayer[];
|
||||||
this.updateLayers(itemLayers);
|
this.updateLayers(itemLayers);
|
||||||
}
|
}
|
||||||
if (changes['itemLayer']) {
|
if (changes['itemLayer']) {
|
||||||
var itemLayer = changes['itemLayer'].currentValue as IItemLayer;
|
const itemLayer = changes['itemLayer'].currentValue as IItemLayer;
|
||||||
this.itemLayer = itemLayer
|
this.itemLayer = itemLayer
|
||||||
if(itemLayer) {
|
if(itemLayer) {
|
||||||
if(this.getItemlayer(this.itemLayer).item.itemType == 'vnd.farmmaps.itemtype.shape.processed') {
|
if(this.getItemlayer(this.itemLayer).item.itemType == 'vnd.farmmaps.itemtype.shape.processed') {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
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, OnDestroy, LOCALE_ID } 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, FolderService } from '@farmmaps/common';
|
||||||
|
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
import { Point,Geometry } from 'ol/geom';
|
import { Point, Geometry } from 'ol/geom';
|
||||||
import { MapBrowserEvent } from 'ol';
|
import { MapBrowserEvent } from 'ol';
|
||||||
import { Types } from 'ol/MapBrowserEventType';
|
import { Types } from 'ol/MapBrowserEventType';
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
@@ -11,80 +11,96 @@ 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,Source} 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';
|
||||||
import {IStyles} from '../../../models/style.cache';
|
import { IStyles } from '../../../models/style.cache';
|
||||||
import {FeatureIconService} from '../../../services/feature-icon.service';
|
import { FeatureIconService } from '../../../services/feature-icon.service';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
import { getCenter } from 'ol/extent';
|
||||||
|
import { formatNumber } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-item-source-vector',
|
selector: 'fm-map-item-source-vector',
|
||||||
template: `<ng-content></ng-content>`,
|
template: `<ng-content></ng-content>`,
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: SourceVectorComponent , useExisting: forwardRef(() => ItemVectorSourceComponent) }
|
{ provide: SourceVectorComponent, useExisting: forwardRef(() => ItemVectorSourceComponent) }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges {
|
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
instance: Vector<Geometry>;
|
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 = 0.05;
|
||||||
@Input() features: Array<Feature<Geometry>>;
|
@Input() features: Array<Feature<Geometry>>;
|
||||||
@Input() selectedFeature: Feature<Geometry>;
|
@Input() selectedFeature: Feature<Geometry>;
|
||||||
@Input() selectedItem: IItem;
|
@Input() selectedItem: IItem;
|
||||||
@Input() styles:IStyles;
|
@Input() styles: IStyles;
|
||||||
@Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
@Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
||||||
@Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
@Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
|
||||||
private stylesCache:IStyles = {};
|
private stylesCache: IStyles = {};
|
||||||
|
private sub: Subscription;
|
||||||
|
private displayMapFeatureSettings: { [code: string]: string[] } = defaultDisplayMapFeatureSettings();
|
||||||
|
|
||||||
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, private folderService: FolderService, @Inject(LOCALE_ID) private locale: string) {
|
||||||
super(layer);
|
super(layer);
|
||||||
this._format = new GeoJSON();
|
this._format = new GeoJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry(feature: Feature<Geometry>) {
|
geometry(feature: Feature<Geometry>) {
|
||||||
let view = this.map.instance.getView();
|
const view = this.map.instance.getView();
|
||||||
let resolution = view.getResolution();
|
const resolution = view.getResolution();
|
||||||
var geometry = feature.getGeometry();
|
let geometry = feature.getGeometry();
|
||||||
let e = geometry.getExtent();
|
const e = geometry.getExtent();
|
||||||
//var size = Math.max((e[2] - e[0]) / resolution, (e[3] - e[1]) / resolution);
|
//var size = Math.max((e[2] - e[0]) / resolution, (e[3] - e[1]) / resolution);
|
||||||
if (resolution > 12) {
|
if (resolution > 12) {
|
||||||
geometry = new Point(extent.getCenter(e));
|
geometry = new Point(extent.getCenter(e));
|
||||||
}
|
}
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedStyle(feature:Feature<Geometry>):style.Style {
|
getSelectedStyle(feature: Feature<Geometry>): style.Style {
|
||||||
let key = feature.get('itemType')+"_selected";
|
const key = feature.get('itemType') + "_selected";
|
||||||
let evaluatedStyle: style.Style =undefined;
|
let evaluatedStyle: style.Style = undefined;
|
||||||
var styleEntry = this.stylesCache[key];
|
const styleEntry = this.stylesCache[key];
|
||||||
if(styleEntry) {
|
if (styleEntry) {
|
||||||
if(typeof styleEntry === 'function') {
|
if (typeof styleEntry === 'function') {
|
||||||
evaluatedStyle = styleEntry(feature);
|
evaluatedStyle = styleEntry(feature);
|
||||||
} else {
|
} else {
|
||||||
evaluatedStyle = styleEntry;
|
evaluatedStyle = styleEntry;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
evaluatedStyle = this.stylesCache["selected"] as style.Style;
|
evaluatedStyle = this.stylesCache["selected"] as style.Style;
|
||||||
}
|
}
|
||||||
if(evaluatedStyle ) {
|
if (evaluatedStyle) {
|
||||||
evaluatedStyle .setGeometry((feature:Feature<Geometry>) => this.geometry(feature));
|
evaluatedStyle.setGeometry((feature: Feature<Geometry>) => this.geometry(feature));
|
||||||
}
|
}
|
||||||
return evaluatedStyle as style.Style
|
return evaluatedStyle as style.Style
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.sub = this.folderService.getFolder('my_settings').subscribe(
|
||||||
|
userSettingsRoot => {
|
||||||
|
this.itemService.getChildItemList(userSettingsRoot.code, 'vnd.farmmaps.itemtype.settings.general').subscribe(
|
||||||
|
items => {
|
||||||
|
if (items && items.length > 0 && items[0].data?.displayMapFeatureSettings) {
|
||||||
|
this.displayMapFeatureSettings = items[0].data?.displayMapFeatureSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
);
|
||||||
this.strategy = loadingstrategy.bbox;
|
this.strategy = loadingstrategy.bbox;
|
||||||
this.format = new GeoJSON();
|
this.format = new GeoJSON();
|
||||||
this._select = new Select({
|
this._select = new Select({
|
||||||
style:null,
|
style: null,
|
||||||
hitTolerance: 10,
|
hitTolerance: 10,
|
||||||
layers: [this.layer.instance as Layer<Source>]
|
layers: [this.layer.instance as Layer<Source>]
|
||||||
});
|
});
|
||||||
this._hoverSelect = new Select({
|
this._hoverSelect = new Select({
|
||||||
style: (feature:Feature<Geometry>) => {
|
style: (feature: Feature<Geometry>) => {
|
||||||
return this.getSelectedStyle(feature);
|
return this.getSelectedStyle(feature);
|
||||||
},
|
},
|
||||||
hitTolerance: 10,
|
hitTolerance: 10,
|
||||||
@@ -94,7 +110,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
layers: [this.layer.instance as Layer<Source>]
|
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);
|
||||||
this._select.on('select', (e) => {
|
this._select.on('select', (e) => {
|
||||||
if (e.selected.length > 0 && e.selected[0]) {
|
if (e.selected.length > 0 && e.selected[0]) {
|
||||||
this.onFeatureSelected.emit(e.selected[0]);
|
this.onFeatureSelected.emit(e.selected[0]);
|
||||||
@@ -111,48 +127,53 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
});
|
});
|
||||||
this.instance = new Vector(this);
|
this.instance = new Vector(this);
|
||||||
this.host.instance.setSource(this.instance);
|
this.host.instance.setSource(this.instance);
|
||||||
|
|
||||||
this.host.instance.setStyle((feature) => {
|
this.host.instance.setStyle((feature) => {
|
||||||
var itemType = feature.get('itemType');
|
const itemType = feature.get('itemType');
|
||||||
var key = itemType + (this.selectedItem?"_I":"");
|
let key = itemType + (this.selectedItem ? "_I" : "");
|
||||||
if (!this.stylesCache[key]) {
|
if (!this.stylesCache[key]) {
|
||||||
if (this.itemTypeService.itemTypes[itemType]) {
|
if (this.itemTypeService.itemTypes[itemType]) {
|
||||||
let itemTypeEntry = this.itemTypeService.itemTypes[itemType];
|
const itemTypeEntry = this.itemTypeService.itemTypes[itemType];
|
||||||
let fillColor = color.asArray(itemTypeEntry.iconColor);
|
const fillColor = color.asArray(itemTypeEntry.iconColor);
|
||||||
fillColor[3] = 0;
|
fillColor[3] = 0;
|
||||||
this.stylesCache[key] = new style.Style({
|
this.stylesCache[key] = new style.Style({
|
||||||
image: itemTypeEntry.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(itemTypeEntry.icon)
|
src: this.featureIconService$.getIconImageDataUrl(itemTypeEntry.icon)
|
||||||
}):null,
|
}) : null,
|
||||||
stroke: new style.Stroke({
|
stroke: new style.Stroke({
|
||||||
color: 'red',
|
color: 'red',
|
||||||
width: 1
|
width: 1
|
||||||
}),
|
}),
|
||||||
fill: new style.Fill({
|
fill: new style.Fill({
|
||||||
color: fillColor
|
color: fillColor
|
||||||
}),
|
}),
|
||||||
geometry:(feature:Feature<Geometry>) => this.geometry(feature)
|
geometry: (feature: Feature<Geometry>) => this.geometry(feature),
|
||||||
});
|
text: this.getDisplayTextForFeature(feature, this.map.instance.getView().getZoom())
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
key = 'file';
|
key = 'file';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let evaluatedStyle =null;
|
let evaluatedStyle = null;
|
||||||
var styleEntry = this.stylesCache[key];
|
const styleEntry = this.stylesCache[key];
|
||||||
if(typeof styleEntry === 'function') {
|
if (typeof styleEntry === 'function') {
|
||||||
evaluatedStyle = styleEntry(feature);
|
evaluatedStyle = styleEntry(feature);
|
||||||
} else {
|
} else {
|
||||||
evaluatedStyle = styleEntry;
|
evaluatedStyle = styleEntry;
|
||||||
}
|
}
|
||||||
if(evaluatedStyle && evaluatedStyle.geometry_ == null) {
|
if (evaluatedStyle && evaluatedStyle.geometry_ == null && !Array.isArray(evaluatedStyle)) {
|
||||||
evaluatedStyle.setGeometry((feature) => this.geometry(feature));
|
evaluatedStyle.setGeometry((feature) => this.geometry(feature));
|
||||||
}
|
}
|
||||||
return evaluatedStyle;
|
return evaluatedStyle;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (this.sub) this.sub.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes["features"] && this.instance) {
|
if (changes["features"] && this.instance) {
|
||||||
this.instance.clear(true);
|
this.instance.clear(true);
|
||||||
@@ -161,31 +182,78 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (changes["selectedFeature"] && this.instance) {
|
if (changes["selectedFeature"] && this.instance) {
|
||||||
var features = this._hoverSelect.getFeatures();
|
const features = this._hoverSelect.getFeatures();
|
||||||
var feature = changes["selectedFeature"].currentValue
|
const feature = changes["selectedFeature"].currentValue
|
||||||
//this.instance.clear(false);
|
//this.instance.clear(false);
|
||||||
//this.instance.addFeatures(features.getArray());
|
//this.instance.addFeatures(features.getArray());
|
||||||
features.clear();
|
features.clear();
|
||||||
if (feature) {
|
if (feature) {
|
||||||
//this.instance.removeFeature(feature);
|
//this.instance.removeFeature(feature);
|
||||||
features.push(feature)
|
features.push(feature)
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changes["selectedItem"] && this.instance) {
|
|
||||||
var item = changes["selectedItem"].currentValue
|
|
||||||
if (item) {
|
|
||||||
this.map.instance.removeInteraction(this._hoverSelect);
|
|
||||||
} else {
|
|
||||||
this.map.instance.addInteraction(this._hoverSelect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changes["styles"] && this.instance) {
|
if (changes["selectedItem"] && this.instance) {
|
||||||
let styles = changes["styles"].currentValue;
|
const item = changes["selectedItem"].currentValue
|
||||||
|
if (item) {
|
||||||
|
this.map.instance.removeInteraction(this._hoverSelect);
|
||||||
|
} else {
|
||||||
|
this.map.instance.addInteraction(this._hoverSelect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changes["styles"]) {
|
||||||
|
const styles = changes["styles"].currentValue;
|
||||||
for (const key in styles) {
|
for (const key in styles) {
|
||||||
if (styles.hasOwnProperty(key)) {
|
if (styles.hasOwnProperty(key)) {
|
||||||
this.stylesCache[key]=styles[key];
|
this.stylesCache[key] = styles[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDisplayTextForFeature(feature: Feature<Geometry>, zoom: number, overrule?: style.Text) {
|
||||||
|
if (!feature) return null;
|
||||||
|
|
||||||
|
const propertiesToShow: string[] = this.displayMapFeatureSettings[feature.get('itemType')];
|
||||||
|
if (!propertiesToShow) return null;
|
||||||
|
if (propertiesToShow.length <= 0) return null;
|
||||||
|
if (zoom < 14) return null;
|
||||||
|
|
||||||
|
let displayText = '';
|
||||||
|
for (let i = 0; i < propertiesToShow.length; i++) {
|
||||||
|
let value = feature.get(propertiesToShow[i]);
|
||||||
|
switch (propertiesToShow[i]) {
|
||||||
|
case "area": value = formatNumber(value, this.locale, '0.1-2') + ' ha'; break;
|
||||||
|
case "centroid": {
|
||||||
|
if (feature.getGeometry()) {
|
||||||
|
const centroid = getCenter(feature.getGeometry().getExtent());
|
||||||
|
value = Math.round(centroid[0]) + ',' + Math.round(centroid[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value) {
|
||||||
|
displayText += value + (i < propertiesToShow.length ? '\n' : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const styleText = new style.Text({
|
||||||
|
font: '13px Calibri,sans-serif',
|
||||||
|
fill: new style.Fill({ color: '#ffffff' }),
|
||||||
|
stroke: new style.Stroke({ color: '#000000', width: 2 }),
|
||||||
|
text: displayText
|
||||||
|
});
|
||||||
|
|
||||||
|
if (overrule) {
|
||||||
|
if (overrule.getFont()) styleText.setFont(overrule.getFont());
|
||||||
|
if (overrule.getFill()) styleText.setFill(overrule.getFill());
|
||||||
|
if (overrule.getStroke()) styleText.setStroke(overrule.getStroke());
|
||||||
|
}
|
||||||
|
|
||||||
|
return styleText;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultDisplayMapFeatureSettings() {
|
||||||
|
return {
|
||||||
|
'vnd.farmmaps.itemtype.cropfield': ['name', 'cropTypeName', 'area']
|
||||||
|
};
|
||||||
|
}
|
@@ -9,8 +9,8 @@ import { IItemLayer } from '../../../models/item.layer';
|
|||||||
|
|
||||||
export class LayerListComponent {
|
export class LayerListComponent {
|
||||||
@Input() itemLayers: IItemLayer[] = [];
|
@Input() itemLayers: IItemLayer[] = [];
|
||||||
@Input() baseLayers: boolean = false;
|
@Input() baseLayers = false;
|
||||||
@Input() dataLayers: boolean = false;
|
@Input() dataLayers = 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>();
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
<li class="border-top pt-1 pb-1 value" *ngFor="let layerValue of layers">
|
||||||
<div>{{layerValue.layerName}}</div>
|
<div>{{layerValue.layerName}}</div>
|
||||||
<div>{{layerValue.date|date}}</div>
|
<div>{{layerValue.date|date}}</div>
|
||||||
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{layerValue.value}}</span><span>{{layerValue.unit}}</span></div>
|
<div><span *ngIf="layerValue.quantity"><span class="me-1">{{layerValue.quantity}}</span> </span><span class="me-1 font-weight-bold">{{getScaledValue(layerValue)}}</span><span>{{layerValue.unit}}</span></div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ng-template #no_data>
|
<ng-template #no_data>
|
||||||
@@ -15,4 +15,4 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>>
|
</div>
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
import { Component, OnInit,Input,ViewChild,ElementRef,AfterViewInit } from '@angular/core';
|
import { Component, OnInit, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
|
||||||
import {IItemLayer} from '../../../models/item.layer';
|
import { IItemLayer } from '../../../models/item.layer';
|
||||||
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 * as mapActions from '../../../actions/map.actions';
|
import * as mapActions from '../../../actions/map.actions';
|
||||||
import { MapComponent } from 'ngx-openlayers';
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
import { ILayervalue } from '../../../models/layer.value';
|
import { ILayervalue } from '../../../models/layer.value';
|
||||||
import { Observable,interval,Subject } from 'rxjs';
|
import { Observable, interval, Subject } from 'rxjs';
|
||||||
import { debounce, throttle } from 'rxjs/operators';
|
import { debounce, throttle } from 'rxjs/operators';
|
||||||
import { toLonLat } from 'ol/proj';
|
import { toLonLat } from 'ol/proj';
|
||||||
import { toStringHDMS } from 'ol/coordinate';
|
import { toStringHDMS } from 'ol/coordinate';
|
||||||
import { ClipboardService } from 'ngx-clipboard'
|
import { ClipboardService } from 'ngx-clipboard'
|
||||||
import {GeoJSON,WKT} from 'ol/format';
|
import { GeoJSON, WKT } from 'ol/format';
|
||||||
import { Point } from 'ol/geom';
|
import { Point } from 'ol/geom';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -18,45 +18,53 @@ import { Point } from 'ol/geom';
|
|||||||
templateUrl: './layer-values.component.html',
|
templateUrl: './layer-values.component.html',
|
||||||
styleUrls: ['./layer-values.component.scss']
|
styleUrls: ['./layer-values.component.scss']
|
||||||
})
|
})
|
||||||
export class LayerValuesComponent implements OnInit,AfterViewInit {
|
export class LayerValuesComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
@ViewChild('layerValues') containerRef:ElementRef;
|
@ViewChild('layerValues') containerRef: ElementRef;
|
||||||
offsetX$:number =0;
|
offsetX$ = 0;
|
||||||
offsetY$:number =0;
|
offsetY$ = 0;
|
||||||
lonlat$: string="";
|
lonlat$ = "";
|
||||||
wkt$= "";
|
wkt$ = "";
|
||||||
layerValues$:Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
layerValues$: Observable<Array<ILayervalue>> = this.store.select(mapReducers.selectGetLayerValues);
|
||||||
enabled$:Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
enabled$: Observable<boolean> = this.store.select(mapReducers.selectGetLayerValuesEnabled);
|
||||||
wktFormat$:WKT;
|
wktFormat$: WKT;
|
||||||
|
|
||||||
constructor( private store: Store<mapReducers.State>,private map: MapComponent,private clipboardService$:ClipboardService) {
|
constructor(private store: Store<mapReducers.State>, private map: MapComponent, private clipboardService$: ClipboardService) {
|
||||||
this.wktFormat$=new WKT();
|
this.wktFormat$ = new WKT();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
moveEndSubject = new Subject<any>();
|
moveEndSubject = new Subject<any>();
|
||||||
|
|
||||||
ngAfterViewInit():void {
|
ngAfterViewInit(): void {
|
||||||
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
this.offsetY$ = this.containerRef.nativeElement.offsetTop;
|
||||||
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
this.offsetX$ = this.containerRef.nativeElement.offsetLeft;
|
||||||
this.map.instance.on('moveend', () => {
|
this.map.instance.on('moveend', () => {
|
||||||
this.moveEndSubject.next({});
|
this.moveEndSubject.next({});
|
||||||
});
|
});
|
||||||
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
this.moveEndSubject.pipe(throttle(ev => interval(100))).subscribe(() => this.updateValuesLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateValuesLocation() {
|
updateValuesLocation() {
|
||||||
var xy = this.map.instance.getCoordinateFromPixel([this.offsetX$,this.offsetY$])
|
const xy = this.map.instance.getCoordinateFromPixel([this.offsetX$, this.offsetY$])
|
||||||
var lonlat = toLonLat(xy);
|
const lonlat = toLonLat(xy);
|
||||||
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
this.wkt$ = this.wktFormat$.writeGeometry(new Point(lonlat))
|
||||||
this.lonlat$ = toStringHDMS(lonlat);
|
this.lonlat$ = toStringHDMS(lonlat);
|
||||||
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0],xy[1]));
|
this.store.dispatch(new mapActions.SetLayerValuesLocation(xy[0], xy[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
copyToClipboard() {
|
copyToClipboard() {
|
||||||
this.clipboardService$.copy(this.wkt$);
|
this.clipboardService$.copy(this.wkt$);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getScaledValue(layerValue: ILayervalue): number {
|
||||||
|
let v = layerValue.value;
|
||||||
|
if (layerValue.scale && layerValue.scale != 0) {
|
||||||
|
v = layerValue.scale * layerValue.value;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,12 +43,12 @@ export class PanToLocation implements OnInit,OnChanges{
|
|||||||
|
|
||||||
public centered():boolean {
|
public centered():boolean {
|
||||||
if(this.position && this.mapState) {
|
if(this.position && this.mapState) {
|
||||||
let center = this.view.getCenter();
|
const center = this.view.getCenter();
|
||||||
let newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]);
|
const newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]);
|
||||||
let x1 = newCenter[0].toFixed(0);
|
const x1 = newCenter[0].toFixed(0);
|
||||||
let x2 = center[0].toFixed(0);
|
const x2 = center[0].toFixed(0);
|
||||||
let y1 = newCenter[1].toFixed(0);
|
const y1 = newCenter[1].toFixed(0);
|
||||||
let y2 = center[1].toFixed(0);
|
const y2 = center[1].toFixed(0);
|
||||||
return x1==x2 && y1==y2;
|
return x1==x2 && y1==y2;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -60,17 +60,17 @@ export class PanToLocation implements OnInit,OnChanges{
|
|||||||
|
|
||||||
handleClick(event:Event) {
|
handleClick(event:Event) {
|
||||||
if(this.position) {
|
if(this.position) {
|
||||||
let view = this.map.instance.getView();
|
const view = this.map.instance.getView();
|
||||||
let newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]);
|
const newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]);
|
||||||
let extent = [newCenter[0]-500,newCenter[1]-500,newCenter[0]+500,newCenter[1]+500];
|
const extent = [newCenter[0]-500,newCenter[1]-500,newCenter[0]+500,newCenter[1]+500];
|
||||||
var options = { padding: [0, 0, 0, 0],minResolution:1 };
|
const options = { padding: [0, 0, 0, 0],minResolution:1 };
|
||||||
let size = this.map.instance.getSize();
|
const size = this.map.instance.getSize();
|
||||||
let rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||||
let threshold = 44 * rem;
|
const threshold = 44 * rem;
|
||||||
var left = 1 * rem;
|
let left = 1 * rem;
|
||||||
var right = 1 * rem;
|
const right = 1 * rem;
|
||||||
var bottom = Math.round(size[1] / 2);
|
let bottom = Math.round(size[1] / 2);
|
||||||
var top = 1 * rem;
|
const top = 1 * rem;
|
||||||
if (size[0] > threshold) {
|
if (size[0] > threshold) {
|
||||||
bottom = 1 * rem;
|
bottom = 1 * rem;
|
||||||
left = 23 * rem;
|
left = 23 * rem;
|
||||||
|
@@ -14,7 +14,7 @@ export class RotationResetComponent implements OnInit {
|
|||||||
view: View;
|
view: View;
|
||||||
|
|
||||||
public Rotation() {
|
public Rotation() {
|
||||||
let rotation = this.view ? this.view.getRotation() : 0;
|
const rotation = this.view ? this.view.getRotation() : 0;
|
||||||
return `rotate(${rotation}rad)`;
|
return `rotate(${rotation}rad)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,19 +10,19 @@ 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;
|
paddingTop = 0;
|
||||||
paddingLeft: number = 0;
|
paddingLeft = 0;
|
||||||
paddingBottom: number = 0;
|
paddingBottom = 0;
|
||||||
paddingRight: number = 0;
|
paddingRight = 0;
|
||||||
|
|
||||||
@Input() extent: number[];
|
@Input() extent: number[];
|
||||||
@Input() animate: boolean = false;
|
@Input() animate = false;
|
||||||
|
|
||||||
constructor(@Host() view: ViewComponent, @Host() map: MapComponent,route: ActivatedRoute ) {
|
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"]) {
|
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"];
|
const params = route.snapshot.data["fm-map-zoom-to-extent"];
|
||||||
this.paddingTop = params["padding-top"] ? params["padding-top"] : 0;
|
this.paddingTop = params["padding-top"] ? params["padding-top"] : 0;
|
||||||
this.paddingBottom = params["padding-bottom"] ? params["padding-bottom"] : 0;
|
this.paddingBottom = params["padding-bottom"] ? params["padding-bottom"] : 0;
|
||||||
this.paddingLeft = params["padding-left"] ? params["padding-left"] : 0;
|
this.paddingLeft = params["padding-left"] ? params["padding-left"] : 0;
|
||||||
@@ -32,14 +32,14 @@ export class ZoomToExtentComponent implements OnChanges {
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (this.extent) {
|
if (this.extent) {
|
||||||
var options = { padding: [0, 0, 0, 0],minResolution:1 };
|
const options = { padding: [0, 0, 0, 0],minResolution:1 };
|
||||||
let size = this.map.instance.getSize();
|
const size = this.map.instance.getSize();
|
||||||
let rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||||
let threshold = 40 * rem;
|
const threshold = 40 * rem;
|
||||||
var left = 1 * rem;
|
let left = 1 * rem;
|
||||||
var right = 1 * rem;
|
const right = 1 * rem;
|
||||||
var bottom = Math.round((size[1] / 2) + (4*rem));
|
let bottom = Math.round((size[1] / 2) + (4*rem));
|
||||||
var top = 1 * rem;
|
const top = 1 * rem;
|
||||||
if (size[0] > threshold) {
|
if (size[0] > threshold) {
|
||||||
bottom = 5 * rem;
|
bottom = 5 * rem;
|
||||||
left = 23 * rem;
|
left = 23 * rem;
|
||||||
|
@@ -33,7 +33,7 @@ export class FeatureListContainerComponent {
|
|||||||
let componentFactory: ComponentFactory<AbstractFeatureListComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListComponent); // default
|
let componentFactory: ComponentFactory<AbstractFeatureListComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListComponent); // default
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
let maxMatches =0;
|
let maxMatches =0;
|
||||||
let showItem = true;
|
const showItem = true;
|
||||||
for (let i = 0; i < this.featureLists.length; i++) {
|
for (let i = 0; i < this.featureLists.length; i++) {
|
||||||
let matches=0;
|
let matches=0;
|
||||||
let criteria=0;
|
let criteria=0;
|
||||||
|
@@ -25,7 +25,7 @@ export class FeatureListCroppingschemeComponent extends AbstractFeatureListCompo
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAction(feature:Feature<Geometry>):Action {
|
getAction(feature:Feature<Geometry>):Action {
|
||||||
var queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" });
|
const queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" });
|
||||||
return new mapActions.DoQuery(queryState);
|
return new mapActions.DoQuery(queryState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ export class FeatureListFeatureContainerComponent {
|
|||||||
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
||||||
|
|
||||||
loadComponent() {
|
loadComponent() {
|
||||||
var componentFactory: ComponentFactory<AbstractFeatureListFeatureComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListFeatureComponent); // default
|
let componentFactory: ComponentFactory<AbstractFeatureListFeatureComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListFeatureComponent); // default
|
||||||
|
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
let maxMatches =0;
|
let maxMatches =0;
|
||||||
|
@@ -27,7 +27,7 @@ export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFea
|
|||||||
areaInHa(feature:Feature<Geometry>):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');
|
const a = feature.get('area');
|
||||||
if(a) return a;
|
if(a) return a;
|
||||||
return getArea(feature.getGeometry(),{projection:"EPSG:3857"}) / 10000;
|
return getArea(feature.getGeometry(),{projection:"EPSG:3857"}) / 10000;
|
||||||
}
|
}
|
||||||
|
@@ -23,13 +23,13 @@ export abstract class AbstractFeatureListComponent {
|
|||||||
|
|
||||||
handleFeatureClick(feature:Feature<Geometry>) {
|
handleFeatureClick(feature:Feature<Geometry>) {
|
||||||
if(feature) {
|
if(feature) {
|
||||||
let action = this.getAction(feature);
|
const action = this.getAction(feature);
|
||||||
this.store.dispatch(action);
|
this.store.dispatch(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAction(feature:Feature<Geometry>):Action {
|
getAction(feature:Feature<Geometry>):Action {
|
||||||
var newQuery: any = tassign(mapReducers.initialState.queryState);
|
const 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');
|
||||||
newQuery.itemType = feature.get('itemType');
|
newQuery.itemType = feature.get('itemType');
|
||||||
|
@@ -30,7 +30,7 @@ export class GeometryThumbnailComponent implements AfterViewInit {
|
|||||||
this.geometry,
|
this.geometry,
|
||||||
this.width,
|
this.width,
|
||||||
this.height);
|
this.height);
|
||||||
};
|
}
|
||||||
|
|
||||||
private defaultStyle:style.Style = new style.Style({
|
private defaultStyle:style.Style = new style.Style({
|
||||||
stroke: new style.Stroke({ color: 'black',width:1.5 })
|
stroke: new style.Stroke({ color: 'black',width:1.5 })
|
||||||
@@ -52,24 +52,24 @@ export class GeometryThumbnailComponent implements AfterViewInit {
|
|||||||
this.height);
|
this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private width:number = 0;
|
private width = 0;
|
||||||
private height:number = 0;
|
private height = 0;
|
||||||
|
|
||||||
render(canvas,style:style.Style,geometry:Geometry,width:number,height:number) {
|
render(canvas,style:style.Style,geometry:Geometry,width:number,height:number) {
|
||||||
if(canvas && canvas.nativeElement && geometry && style) {
|
if(canvas && canvas.nativeElement && geometry && style) {
|
||||||
let renderContext = render.toContext(canvas.nativeElement.getContext( '2d'),{ size: [width, height] });
|
const renderContext = render.toContext(canvas.nativeElement.getContext( '2d'),{ size: [width, height] });
|
||||||
|
|
||||||
let geom = geometry.clone() as Polygon,
|
const geom = geometry.clone() as Polygon,
|
||||||
line = geom.getCoordinates()[0],
|
line = geom.getCoordinates()[0],
|
||||||
e = extent.boundingExtent( line );
|
e = extent.boundingExtent( line );
|
||||||
|
|
||||||
let dxy = extent.getCenter(e),
|
const dxy = extent.getCenter(e),
|
||||||
sxy = [
|
sxy = [
|
||||||
(width - 2 ) / extent.getWidth(e),
|
(width - 2 ) / extent.getWidth(e),
|
||||||
(height - 2 ) / extent.getHeight(e)
|
(height - 2 ) / extent.getHeight(e)
|
||||||
];
|
];
|
||||||
|
|
||||||
let dx = dxy[0],
|
const dx = dxy[0],
|
||||||
dy = dxy[1],
|
dy = dxy[1],
|
||||||
sx = sxy[0],
|
sx = sxy[0],
|
||||||
sy = sxy[1];
|
sy = sxy[1];
|
||||||
|
@@ -43,9 +43,9 @@ export class ifZoomToShowDirective implements OnInit {
|
|||||||
|
|
||||||
checkZoom() {
|
checkZoom() {
|
||||||
if(this.layer$ && this.map$.instance) {
|
if(this.layer$ && this.map$.instance) {
|
||||||
let minZoom = this.layer$.getMinZoom();
|
const minZoom = this.layer$.getMinZoom();
|
||||||
let currentZoom = this.map$.instance.getView().getZoom();
|
const currentZoom = this.map$.instance.getView().getZoom();
|
||||||
let view = currentZoom < minZoom;
|
const view = currentZoom < minZoom;
|
||||||
if(view!= this.showView) {
|
if(view!= this.showView) {
|
||||||
this.viewContainerRef$.clear();
|
this.viewContainerRef$.clear();
|
||||||
this.showView=view;
|
this.showView=view;
|
||||||
|
@@ -23,11 +23,11 @@ export class ItemListItemContainerComponent {
|
|||||||
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
|
||||||
|
|
||||||
loadComponent() {
|
loadComponent() {
|
||||||
var componentFactory: ComponentFactory<AbstractItemListItemComponent> = this.componentFactoryResolver.resolveComponentFactory(ItemListItemComponent); // default
|
let componentFactory: ComponentFactory<AbstractItemListItemComponent> = this.componentFactoryResolver.resolveComponentFactory(ItemListItemComponent); // default
|
||||||
|
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
let maxMatches =0;
|
let maxMatches =0;
|
||||||
let showItem = true;
|
const showItem = true;
|
||||||
for (let i = 0; i < this.itemComponentList.length; i++) {
|
for (let i = 0; i < this.itemComponentList.length; i++) {
|
||||||
let matches=0;
|
let matches=0;
|
||||||
let criteria=0;
|
let criteria=0;
|
||||||
|
@@ -13,7 +13,7 @@ export abstract class AbstractItemListItemComponent {
|
|||||||
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService) {
|
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getScaledValue(value:number,scale:number = 0):number {
|
getScaledValue(value:number,scale = 0):number {
|
||||||
let v = value;
|
let v = value;
|
||||||
if(scale && scale != 0) {
|
if(scale && scale != 0) {
|
||||||
v=scale*value;
|
v=scale*value;
|
||||||
@@ -30,7 +30,7 @@ export abstract class AbstractItemWidgetComponent {
|
|||||||
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService) {
|
constructor(public store: Store<mapReducers.State | commonReducers.State>, public itemTypeService: ItemTypeService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getScaledValue(value:number,scale:number = 0):number {
|
getScaledValue(value:number,scale = 0):number {
|
||||||
let v = value;
|
let v = value;
|
||||||
if(scale && scale != 0) {
|
if(scale && scale != 0) {
|
||||||
v=scale*value;
|
v=scale*value;
|
||||||
|
@@ -15,7 +15,7 @@ export abstract class AbstractItemListComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleItemClick(item:IListItem) {
|
handleItemClick(item:IListItem) {
|
||||||
var newQuery: any = tassign(mapReducers.initialState.query);
|
const newQuery: any = tassign(mapReducers.initialState.query);
|
||||||
newQuery.itemCode = item.code;
|
newQuery.itemCode = item.code;
|
||||||
this.store.dispatch(new mapActions.DoQuery(newQuery));
|
this.store.dispatch(new mapActions.DoQuery(newQuery));
|
||||||
}
|
}
|
||||||
|
@@ -23,10 +23,10 @@ export class ItemWidgetListComponent implements AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
let targets = this.widgetTargets.toArray();
|
const targets = this.widgetTargets.toArray();
|
||||||
if(this.widgets) {
|
if(this.widgets) {
|
||||||
for (var i = 0; i < this.widgets.length; i++) {
|
for (let i = 0; i < this.widgets.length; i++) {
|
||||||
var componentFactory: ComponentFactory<AbstractItemWidgetComponent> = this.componentFactoryResolver.resolveComponentFactory(this.widgets[i]['constructor'] as any);
|
const componentFactory: ComponentFactory<AbstractItemWidgetComponent> = this.componentFactoryResolver.resolveComponentFactory(this.widgets[i]['constructor'] as any);
|
||||||
const viewContainerRef = targets[i];
|
const viewContainerRef = targets[i];
|
||||||
viewContainerRef.clear();
|
viewContainerRef.clear();
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ export class LayerSwitcher implements OnInit,OnChanges{
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleZoomToExtent(itemLayer: IItemLayer) {
|
handleZoomToExtent(itemLayer: IItemLayer) {
|
||||||
var extent = createEmpty();
|
const extent = createEmpty();
|
||||||
extend(extent, itemLayer.layer.getExtent());
|
extend(extent, itemLayer.layer.getExtent());
|
||||||
if (extent) {
|
if (extent) {
|
||||||
this.store.dispatch(new mapActions.SetExtent(extent));
|
this.store.dispatch(new mapActions.SetExtent(extent));
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
<td colspan="4" class="pb-1 pt-1">
|
<td colspan="4" class="pb-1 pt-1">
|
||||||
<div class="info" [ngbCollapse]="hideHistogramDetails">
|
<div class="info" [ngbCollapse]="hideHistogramDetails">
|
||||||
<ng-container *ngIf="bandContainsStatistics(); else histogram">
|
<ng-container *ngIf="bandContainsStatistics(); else histogram">
|
||||||
<fm-map-statistics-details [statistics]="layer.renderer.band.statistics"></fm-map-statistics-details>
|
<fm-map-statistics-details [statistics]="layer.renderer.band.statistics" [scale]="layer.scale"></fm-map-statistics-details>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-template #histogram>
|
<ng-template #histogram>
|
||||||
|
@@ -29,7 +29,7 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
histogram: string;
|
histogram: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showTitle: boolean = true;
|
showTitle = true;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
histogramenabled: boolean;
|
histogramenabled: boolean;
|
||||||
@@ -40,7 +40,7 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
@Input()
|
@Input()
|
||||||
histogramunit: string;
|
histogramunit: string;
|
||||||
|
|
||||||
public hideHistogramDetails:boolean = true;
|
public hideHistogramDetails = true;
|
||||||
|
|
||||||
onClickHistoGram(): void {
|
onClickHistoGram(): void {
|
||||||
this.histogramenabled = !this.histogramenabled;
|
this.histogramenabled = !this.histogramenabled;
|
||||||
@@ -63,9 +63,9 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getPart(renderer: IRenderer, index: number): string {
|
public getPart(renderer: IRenderer, index: number): string {
|
||||||
let max = renderer.band.histogram.entries.reduce((max, entry) => entry.freqency > max ? entry.freqency : max, 0);
|
const max = renderer.band.histogram.entries.reduce((max, entry) => entry.freqency > max ? entry.freqency : max, 0);
|
||||||
let scale = 65 / max;
|
const scale = 65 / max;
|
||||||
let part = (renderer.band.histogram.entries[index].freqency * scale) + "%";
|
const part = (renderer.band.histogram.entries[index].freqency * scale) + "%";
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
@@ -79,8 +79,8 @@ export class LegendComponent implements OnInit,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getPercentage(renderer: IRenderer, index: number): number {
|
public getPercentage(renderer: IRenderer, index: number): number {
|
||||||
let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
|
const scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
|
||||||
let percent = renderer.band.histogram.entries[index].freqency * scale;
|
const percent = renderer.band.histogram.entries[index].freqency * scale;
|
||||||
return percent < 0.1 ? null : percent;
|
return percent < 0.1 ? null : percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,23 +2,23 @@
|
|||||||
<div class="col-8 nopadding"><span i18n>Data points</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Data points</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.populationCount}}</div>
|
<div class="col-4 pull-left nopadding">{{statistics.populationCount}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Min</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Min</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.min| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.min)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Max</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Max</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.max| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.max)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Min+1</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Min+1</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.minPlus| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.minPlus)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Max-1</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Max-1</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.maxMinus| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.maxMinus)| number:'1.0-2'}}</div>
|
||||||
|
|
||||||
<div class="col-8 nopadding"><span i18n>Average</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Average</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.mean| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.mean)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Standard deviation</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Standard deviation</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.stddev| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.stddev)| number:'1.0-2'}}</div>
|
||||||
|
|
||||||
<div class="col-8 nopadding"><span i18n>Mode</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Mode</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.mode| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.mode)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Median</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Median</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.median| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.median)| number:'1.0-2'}}</div>
|
||||||
|
|
||||||
<div class="col-8 nopadding"><span i18n>Kurtosis</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Kurtosis</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.curtosis| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{statistics.curtosis| number:'1.0-2'}}</div>
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
<div class="col-4 pull-left nopadding">{{statistics.skewness| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{statistics.skewness| number:'1.0-2'}}</div>
|
||||||
|
|
||||||
<div class="col-8 nopadding"><span i18n>Variance</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Variance</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.variance| number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getSquaredScaledValue(statistics.variance)| number:'1.0-2'}}</div>
|
||||||
<div class="col-8 nopadding"><span i18n>Coefficient of variation</span>:</div>
|
<div class="col-8 nopadding"><span i18n>Coefficient of variation</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.variationCoefficient | number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{statistics.variationCoefficient | number:'1.0-2'}}</div>
|
||||||
<ng-container *ngIf="statistics.confidenceIntervalLow !== undefined">
|
<ng-container *ngIf="statistics.confidenceIntervalLow !== undefined">
|
||||||
<div class="col-8 nopadding">90% <span i18n>Confidence interval</span>:</div>
|
<div class="col-8 nopadding">90% <span i18n>Confidence interval</span>:</div>
|
||||||
<div class="col-4 pull-left nopadding">{{statistics.confidenceIntervalLow | number:'1.0-2'}} - {{statistics.confidenceIntervalHigh | number:'1.0-2'}}</div>
|
<div class="col-4 pull-left nopadding">{{getScaledValue(statistics.confidenceIntervalLow) | number:'1.0-2'}} - {{getScaledValue(statistics.confidenceIntervalHigh) | number:'1.0-2'}}</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,16 +1,35 @@
|
|||||||
import {Component, Input} from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import {IStatistics} from '../../../models/color.map';
|
import { IStatistics } from '../../../models/color.map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-statistics-details',
|
selector: 'fm-map-statistics-details',
|
||||||
templateUrl: './statistics-details.component.html',
|
templateUrl: './statistics-details.component.html',
|
||||||
styles: ['.nopadding{\n' +
|
styles: ['.nopadding{\n' +
|
||||||
' padding: 0 !important;\n' +
|
' padding: 0 !important;\n' +
|
||||||
' margin: 0 !important;\n' +
|
' margin: 0 !important;\n' +
|
||||||
'}']
|
'}']
|
||||||
})
|
})
|
||||||
export class StatisticsDetailsComponent {
|
export class StatisticsDetailsComponent {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
statistics: IStatistics;
|
statistics: IStatistics;
|
||||||
|
@Input()
|
||||||
|
scale: number | null;
|
||||||
|
|
||||||
|
public getScaledValue(value: number): number {
|
||||||
|
let v = value;
|
||||||
|
if (this.scale && this.scale != 0) {
|
||||||
|
v = this.scale * value;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSquaredScaledValue(value: number): number {
|
||||||
|
let v = value;
|
||||||
|
if (this.scale && this.scale != 0) {
|
||||||
|
v = (this.scale * this.scale) * value;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -50,21 +50,21 @@ export class MapSearchComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public collapsedLocal: boolean = true;
|
public collapsedLocal = true;
|
||||||
public searchMinifiedLocal: boolean = false;
|
public searchMinifiedLocal = 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 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 = true;
|
||||||
public startEndCaption: string = this.timespanService.getCaption(this.periodLocal.startDate, this.periodLocal.endDate, 4);
|
public startEndCaption: string = this.timespanService.getCaption(this.periodLocal.startDate, this.periodLocal.endDate, 4);
|
||||||
|
|
||||||
searching = false;
|
searching = false;
|
||||||
searchFailed = false;
|
searchFailed = false;
|
||||||
hideSearchingWhenUnsubscribed = new Observable(() => () => this.searching = false);
|
hideSearchingWhenUnsubscribed = new Observable(() => () => this.searching = false);
|
||||||
|
|
||||||
public disabled: boolean = true;
|
public disabled = true;
|
||||||
|
|
||||||
constructor(private typeaheadService: TypeaheadService, private timespanService: TimespanService) {
|
constructor(private typeaheadService: TypeaheadService, private timespanService: TimespanService) {
|
||||||
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:[] };
|
||||||
|
@@ -45,7 +45,7 @@ import * as style from 'ol/style';
|
|||||||
})
|
})
|
||||||
|
|
||||||
export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
||||||
title: string = 'Map';
|
title = 'Map';
|
||||||
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);
|
||||||
@@ -81,20 +81,20 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
public query$: Observable<IQuery> = this.store.select(mapReducers.selectGetQuery);
|
public query$: Observable<IQuery> = this.store.select(mapReducers.selectGetQuery);
|
||||||
public position$: Observable<GeolocationPosition> = 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 = true;
|
||||||
public overlayLayersCollapsed: boolean = true;
|
public overlayLayersCollapsed = true;
|
||||||
public extent$: Observable<Extent> = this.store.select(mapReducers.selectGetExtent);
|
public extent$: Observable<Extent> = this.store.select(mapReducers.selectGetExtent);
|
||||||
public styles$:Observable<IStyles> = this.store.select(mapReducers.selectGetStyles);
|
public styles$:Observable<IStyles> = this.store.select(mapReducers.selectGetStyles);
|
||||||
public fullscreen$: Observable<boolean> = this.store.select(commonReducers.selectGetFullScreen);
|
public fullscreen$: Observable<boolean> = this.store.select(commonReducers.selectGetFullScreen);
|
||||||
private lastUrl = "";
|
private lastUrl = "";
|
||||||
private initialized: boolean = false;
|
private initialized = false;
|
||||||
public noContent: boolean = false;
|
public noContent = false;
|
||||||
public overrideSelectedItemLayer: boolean = false;
|
public overrideSelectedItemLayer = false;
|
||||||
public overrideOverlayLayers: boolean = false;
|
public overrideOverlayLayers = false;
|
||||||
public dataLayerSlideValue:number = 50;
|
public dataLayerSlideValue = 50;
|
||||||
public dataLayerSlideEnabled = false;
|
public dataLayerSlideEnabled = false;
|
||||||
private visibleAreaBottom = 0;
|
private visibleAreaBottom = 0;
|
||||||
private viewEnabled: boolean = true;
|
private viewEnabled = true;
|
||||||
|
|
||||||
@ViewChild('map') map;
|
@ViewChild('map') map;
|
||||||
@ViewChild('contentDiv') contentDiv: ElementRef;
|
@ViewChild('contentDiv') contentDiv: ElementRef;
|
||||||
@@ -112,18 +112,18 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
private deviceorientationService:DeviceOrientationService,
|
private deviceorientationService:DeviceOrientationService,
|
||||||
public devicesService:DeviceService) {
|
public devicesService:DeviceService) {
|
||||||
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-map"]) {
|
if(route && route.snapshot && route.snapshot.data && route.snapshot.data["fm-map-map"]) {
|
||||||
let params = route.snapshot.data["fm-map-map"];
|
const params = route.snapshot.data["fm-map-map"];
|
||||||
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
||||||
this.overrideOverlayLayers = params["overrideOverlayLayers"] ? params["overrideOverlayLayers"] : false;
|
this.overrideOverlayLayers = params["overrideOverlayLayers"] ? params["overrideOverlayLayers"] : false;
|
||||||
}
|
}
|
||||||
this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$)).subscribe(([query,mapState]) =>{
|
this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$)).subscribe(([query,mapState]) =>{
|
||||||
if(query && query.querystate) {
|
if(query && query.querystate) {
|
||||||
let newQueryState = tassign(mapReducers.initialQueryState);
|
let newQueryState = tassign(mapReducers.initialQueryState);
|
||||||
console.debug(`Do Query`);
|
//console.debug(`Do Query`);
|
||||||
let urlparts=[];
|
const urlparts=[];
|
||||||
if (query.querystate.itemCode && query.querystate.itemCode != "") {
|
if (query.querystate.itemCode && query.querystate.itemCode != "") {
|
||||||
if(query.querystate.itemType && query.querystate.itemType!= "") {
|
if(query.querystate.itemType && query.querystate.itemType!= "") {
|
||||||
let itemType = this.itemTypeService.itemTypes[query.querystate.itemType];
|
const 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);
|
||||||
@@ -154,7 +154,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
@HostListener('document:keyup', ['$event'])
|
@HostListener('document:keyup', ['$event'])
|
||||||
escapeClose(event: KeyboardEvent) {
|
escapeClose(event: KeyboardEvent) {
|
||||||
let x = event.keyCode;
|
const x = event.keyCode;
|
||||||
if (x === 27) {
|
if (x === 27) {
|
||||||
this.handleCloseModal()
|
this.handleCloseModal()
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
console.debug("Init");
|
//console.debug("Init");
|
||||||
this.store.dispatch(new mapActions.Clear());
|
this.store.dispatch(new mapActions.Clear());
|
||||||
this.selectedFeatures$.next({x:0,y:0,features:[]});
|
this.selectedFeatures$.next({x:0,y:0,features:[]});
|
||||||
this.selectedFeatures$.next(null);
|
this.selectedFeatures$.next(null);
|
||||||
@@ -268,19 +268,19 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
round(value:number,decimals:number):number {
|
round(value:number,decimals:number):number {
|
||||||
let d = Math.pow(10, decimals);
|
const d = Math.pow(10, decimals);
|
||||||
return Math.round((value + Number.EPSILON)*d)/d;
|
return Math.round((value + Number.EPSILON)*d)/d;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMapStateFromUrl(params:ParamMap):IMapState {
|
getMapStateFromUrl(params:ParamMap):IMapState {
|
||||||
var hasUrlmapState = params.has("xCenter") && params.has("yCenter");
|
const hasUrlmapState = params.has("xCenter") && params.has("yCenter");
|
||||||
if (hasUrlmapState) {
|
if (hasUrlmapState) {
|
||||||
let xCenter = parseFloat(params.get("xCenter"));
|
const xCenter = parseFloat(params.get("xCenter"));
|
||||||
let yCenter = parseFloat(params.get("yCenter"));
|
const yCenter = parseFloat(params.get("yCenter"));
|
||||||
let zoom = parseFloat(params.get("zoom"));
|
const zoom = parseFloat(params.get("zoom"));
|
||||||
let rotation = parseFloat(params.get("rotation"));
|
const rotation = parseFloat(params.get("rotation"));
|
||||||
let baseLayer = params.get("baseLayer")?params.get("baseLayer"):"";
|
const baseLayer = params.get("baseLayer")?params.get("baseLayer"):"";
|
||||||
var newMapState = {zoom: zoom, rotation: rotation, xCenter: xCenter, yCenter: yCenter, baseLayerCode: baseLayer };
|
const newMapState = {zoom: zoom, rotation: rotation, xCenter: xCenter, yCenter: yCenter, baseLayerCode: baseLayer };
|
||||||
return newMapState;
|
return newMapState;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@@ -302,8 +302,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
getQueryStateFromUrl(params:ParamMap):IQueryState {
|
getQueryStateFromUrl(params:ParamMap):IQueryState {
|
||||||
if (params.has("queryState")) {
|
if (params.has("queryState")) {
|
||||||
let queryState = params.get("queryState");
|
const queryState = params.get("queryState");
|
||||||
var newQueryState = tassign(mapReducers.initialQueryState);
|
let newQueryState = tassign(mapReducers.initialQueryState);
|
||||||
if (queryState != "") {
|
if (queryState != "") {
|
||||||
newQueryState = this.serializeService.deserialize(queryState);
|
newQueryState = this.serializeService.deserialize(queryState);
|
||||||
}
|
}
|
||||||
@@ -314,7 +314,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
console.debug("View init");
|
//console.debug("View init");
|
||||||
this.noContent=true;
|
this.noContent=true;
|
||||||
this.route.children.forEach((entry) => {
|
this.route.children.forEach((entry) => {
|
||||||
if(entry.outlet=="primary") {
|
if(entry.outlet=="primary") {
|
||||||
@@ -326,8 +326,8 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
// url to state
|
// url to state
|
||||||
|
|
||||||
let urlMapState = this.getMapStateFromUrl(this.route.snapshot.paramMap);
|
const urlMapState = this.getMapStateFromUrl(this.route.snapshot.paramMap);
|
||||||
let urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap);
|
const urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap);
|
||||||
if(urlQueryState && urlMapState && this.noContent) {
|
if(urlQueryState && urlMapState && this.noContent) {
|
||||||
this.store.dispatch(new mapActions.SetState(urlMapState,urlQueryState));
|
this.store.dispatch(new mapActions.SetState(urlMapState,urlQueryState));
|
||||||
window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(urlMapState));
|
window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(urlMapState));
|
||||||
@@ -339,7 +339,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.state$),switchMap(([params,state]) => {
|
this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.state$),switchMap(([params,state]) => {
|
||||||
if(this.initialized && this.noContent) {
|
if(this.initialized && this.noContent) {
|
||||||
let urlQueryState = this.getQueryStateFromUrl(params);
|
const urlQueryState = this.getQueryStateFromUrl(params);
|
||||||
if( this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState)) {
|
if( this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState)) {
|
||||||
return of(new mapActions.SetState(state.mapState,urlQueryState));
|
return of(new mapActions.SetState(state.mapState,urlQueryState));
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
})).subscribe((action) => {
|
})).subscribe((action) => {
|
||||||
if(action) {
|
if(action) {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
console.debug("Url to state");
|
//console.debug("Url to state");
|
||||||
this.store.dispatch(action);
|
this.store.dispatch(action);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -357,7 +357,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
// state to url
|
// state to url
|
||||||
|
|
||||||
this.stateSub = this.state$.pipe(switchMap((state) => {
|
this.stateSub = this.state$.pipe(switchMap((state) => {
|
||||||
let newUrl = this.serializeMapState(state.mapState) + "_" + this.serializeService.serialize(state.queryState);
|
const newUrl = this.serializeMapState(state.mapState) + "_" + this.serializeService.serialize(state.queryState);
|
||||||
if(this.lastUrl!=newUrl) {
|
if(this.lastUrl!=newUrl) {
|
||||||
this.lastUrl=newUrl;
|
this.lastUrl=newUrl;
|
||||||
return of(state);
|
return of(state);
|
||||||
@@ -365,9 +365,9 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
else {
|
else {
|
||||||
return of(null);
|
return of(null);
|
||||||
}
|
}
|
||||||
})).subscribe((newUrlState) =>{
|
})).subscribe((newUrlState: any) => {
|
||||||
if(newUrlState) {
|
if(newUrlState) {
|
||||||
console.debug(`State to url`);
|
//console.debug(`State to url`);
|
||||||
this.replaceUrl(newUrlState.mapState,newUrlState.queryState,newUrlState.replaceUrl);
|
this.replaceUrl(newUrlState.mapState,newUrlState.queryState,newUrlState.replaceUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -405,19 +405,19 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
|
|
||||||
handlePredefinedQuery(event: MouseEvent, query: any) {
|
handlePredefinedQuery(event: MouseEvent, query: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var queryState = tassign(mapReducers.initialQueryState, query);
|
const queryState = tassign(mapReducers.initialQueryState, query);
|
||||||
this.store.dispatch(new mapActions.DoQuery(queryState));
|
this.store.dispatch(new mapActions.DoQuery(queryState));
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) {
|
replaceUrl(mapState: IMapState, queryState: IQueryState, replace = true) {
|
||||||
if(this.noContent) {
|
if(this.noContent) {
|
||||||
let newMapState = this.serializeMapState(mapState);
|
const newMapState = this.serializeMapState(mapState);
|
||||||
let newQueryState = this.serializeService.serialize(queryState);
|
const newQueryState = this.serializeService.serialize(queryState);
|
||||||
let currentMapState = this.serializeMapState(this.getMapStateFromUrl(this.route.snapshot.paramMap));
|
const currentMapState = this.serializeMapState(this.getMapStateFromUrl(this.route.snapshot.paramMap));
|
||||||
let urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap);
|
const urlQueryState = this.getQueryStateFromUrl(this.route.snapshot.paramMap);
|
||||||
let currentQueryState = urlQueryState==null?"":this.serializeService.serialize(urlQueryState);
|
const currentQueryState = urlQueryState==null?"":this.serializeService.serialize(urlQueryState);
|
||||||
if(mapState.baseLayerCode!="" && ((newMapState!= currentMapState) || (newQueryState!=currentQueryState))) {
|
if(mapState.baseLayerCode!="" && ((newMapState!= currentMapState) || (newQueryState!=currentQueryState))) {
|
||||||
let parts =["."];
|
const parts =["."];
|
||||||
parts.push(mapState.xCenter.toFixed(5));
|
parts.push(mapState.xCenter.toFixed(5));
|
||||||
parts.push(mapState.yCenter.toFixed(5));
|
parts.push(mapState.yCenter.toFixed(5));
|
||||||
parts.push( mapState.zoom.toFixed(0));
|
parts.push( mapState.zoom.toFixed(0));
|
||||||
@@ -425,7 +425,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
parts.push(mapState.baseLayerCode);
|
parts.push(mapState.baseLayerCode);
|
||||||
parts.push( this.serializeService.serialize(queryState));
|
parts.push( this.serializeService.serialize(queryState));
|
||||||
|
|
||||||
console.debug("Replace url",parts);
|
//console.debug("Replace url",parts);
|
||||||
this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent });
|
this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -434,20 +434,20 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
handleOnMoveEnd(event) {
|
handleOnMoveEnd(event) {
|
||||||
if(this.initialized && this.viewEnabled) {
|
if(this.initialized && this.viewEnabled) {
|
||||||
this.zone.run(() =>{
|
this.zone.run(() =>{
|
||||||
console.debug("Move end");
|
//console.debug("Move end");
|
||||||
var map = event.map;
|
const map = event.map;
|
||||||
var view = map.getView();
|
const view = map.getView();
|
||||||
var rotation = view.getRotation();
|
const rotation = view.getRotation();
|
||||||
var zoom = view.getZoom();
|
const zoom = view.getZoom();
|
||||||
var center = transform(view.getCenter(), view.getProjection(), "EPSG:4326");
|
const center = transform(view.getCenter(), view.getProjection(), "EPSG:4326");
|
||||||
var viewExtent = view.calculateExtent(this.map.instance.getSize());
|
const viewExtent = view.calculateExtent(this.map.instance.getSize());
|
||||||
let mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null };
|
const mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null };
|
||||||
let state = { mapState: mapState, viewExtent: viewExtent };
|
const state = { mapState: mapState, viewExtent: viewExtent };
|
||||||
console.debug("Center: ",center[0],center[1] );
|
//console.debug("Center: ",center[0],center[1] );
|
||||||
let source = from([state]);
|
const source = from([state]);
|
||||||
source.pipe(withLatestFrom(this.selectedBaseLayer$)).subscribe(([state, baselayer]) => {
|
source.pipe(withLatestFrom(this.selectedBaseLayer$)).subscribe(([state, baselayer]) => {
|
||||||
if (mapState && baselayer) { // do not react on first move
|
if (mapState && baselayer) { // do not react on first move
|
||||||
let newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code });
|
const newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code });
|
||||||
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
this.store.dispatch(new mapActions.SetMapState(newMapState));
|
||||||
this.store.dispatch(new mapActions.SetViewExtent(state.viewExtent));
|
this.store.dispatch(new mapActions.SetViewExtent(state.viewExtent));
|
||||||
}
|
}
|
||||||
@@ -491,7 +491,7 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleZoomToExtent(itemLayer: IItemLayer) {
|
handleZoomToExtent(itemLayer: IItemLayer) {
|
||||||
var extent = createEmpty();
|
const extent = createEmpty();
|
||||||
extend(extent, itemLayer.layer.getExtent());
|
extend(extent, itemLayer.layer.getExtent());
|
||||||
if (extent) {
|
if (extent) {
|
||||||
this.store.dispatch(new mapActions.SetExtent(extent));
|
this.store.dispatch(new mapActions.SetExtent(extent));
|
||||||
@@ -513,10 +513,10 @@ export class MapComponent implements OnInit, OnDestroy,AfterViewInit {
|
|||||||
handleCitySearch(location:string) {
|
handleCitySearch(location:string) {
|
||||||
this.geolocaterService.geocode(location).subscribe(locations => {
|
this.geolocaterService.geocode(location).subscribe(locations => {
|
||||||
if( locations.length > 0) {
|
if( locations.length > 0) {
|
||||||
let point = new Point([locations[0].coordinates.lon,locations[0].coordinates.lat]);
|
const point = new Point([locations[0].coordinates.lon,locations[0].coordinates.lat]);
|
||||||
point.transform('EPSG:4326', 'EPSG:3857');
|
point.transform('EPSG:4326', 'EPSG:3857');
|
||||||
let circle = new Circle(point.getCoordinates(),5000);//
|
const circle = new Circle(point.getCoordinates(),5000);//
|
||||||
let extent = createEmpty();
|
const extent = createEmpty();
|
||||||
extend(extent, circle.getExtent());
|
extend(extent, circle.getExtent());
|
||||||
this.store.dispatch(new mapActions.SetExtent(extent))
|
this.store.dispatch(new mapActions.SetExtent(extent))
|
||||||
}
|
}
|
||||||
|
@@ -15,12 +15,12 @@ export interface IMetaData {
|
|||||||
})
|
})
|
||||||
export class MetaDataModalComponent {
|
export class MetaDataModalComponent {
|
||||||
|
|
||||||
private modalName: string = 'metaDataModal';
|
private modalName = 'metaDataModal';
|
||||||
private modalRef: NgbModalRef;
|
private modalRef: NgbModalRef;
|
||||||
|
|
||||||
@ViewChild('content', { static: true }) _templateModal:ElementRef;
|
@ViewChild('content', { static: true }) _templateModal:ElementRef;
|
||||||
@Input() droppedFile: IDroppedFile;
|
@Input() droppedFile: IDroppedFile;
|
||||||
@Input() set modalState(_modalState:any) {;
|
@Input() set modalState(_modalState:any) {
|
||||||
if(_modalState == this.modalName) {
|
if(_modalState == this.modalName) {
|
||||||
this.openModal()
|
this.openModal()
|
||||||
} else if(this.modalRef) {
|
} else if(this.modalRef) {
|
||||||
|
@@ -22,7 +22,7 @@ const after = (one: NgbDateStruct, two: NgbDateStruct) =>
|
|||||||
})
|
})
|
||||||
export class SelectPeriodModalComponent {
|
export class SelectPeriodModalComponent {
|
||||||
|
|
||||||
private modalName: string = 'selectPeriodModal';
|
private modalName = 'selectPeriodModal';
|
||||||
private modalRef: NgbModalRef;
|
private modalRef: NgbModalRef;
|
||||||
private dateAdapter = new NgbDateNativeAdapter();
|
private dateAdapter = new NgbDateNativeAdapter();
|
||||||
hoveredDate: NgbDateStruct;
|
hoveredDate: NgbDateStruct;
|
||||||
@@ -31,7 +31,7 @@ export class SelectPeriodModalComponent {
|
|||||||
|
|
||||||
@ViewChild('content', { static: true }) _templateModal:ElementRef;
|
@ViewChild('content', { static: true }) _templateModal:ElementRef;
|
||||||
|
|
||||||
@Input() set modalState(_modalState:any) {;
|
@Input() set modalState(_modalState:any) {
|
||||||
if(_modalState == this.modalName) {
|
if(_modalState == this.modalName) {
|
||||||
this.openModal()
|
this.openModal()
|
||||||
} else if(this.modalRef) {
|
} else if(this.modalRef) {
|
||||||
@@ -44,7 +44,7 @@ export class SelectPeriodModalComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Input() set endDate(_modalState: Date) {
|
@Input() set endDate(_modalState: Date) {
|
||||||
var d = new Date(_modalState);
|
const d = new Date(_modalState);
|
||||||
d.setDate(d.getDate() - 1);
|
d.setDate(d.getDate() - 1);
|
||||||
this.toDate = this.dateAdapter.fromModel(d);
|
this.toDate = this.dateAdapter.fromModel(d);
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ export class SelectPeriodModalComponent {
|
|||||||
handleSelect(event:MouseEvent) {
|
handleSelect(event:MouseEvent) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (this.fromDate && this.toDate && before(this.fromDate, this.toDate)) {
|
if (this.fromDate && this.toDate && before(this.fromDate, this.toDate)) {
|
||||||
var endDate = new Date(this.dateAdapter.toModel(this.toDate));
|
const endDate = new Date(this.dateAdapter.toModel(this.toDate));
|
||||||
endDate.setDate(endDate.getDate() + 1);
|
endDate.setDate(endDate.getDate() + 1);
|
||||||
this.onSelect.emit({startDate:this.dateAdapter.toModel(this.fromDate),endDate:endDate})
|
this.onSelect.emit({startDate:this.dateAdapter.toModel(this.fromDate),endDate:endDate})
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ export class SelectedItemContainerComponent {
|
|||||||
|
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
let maxMatches =0;
|
let maxMatches =0;
|
||||||
let showItem = true;
|
const showItem = true;
|
||||||
for (let i = 0; i < this.selectedItemComponents.length; i++) {
|
for (let i = 0; i < this.selectedItemComponents.length; i++) {
|
||||||
let matches=0;
|
let matches=0;
|
||||||
let criteria=0;
|
let criteria=0;
|
||||||
|
@@ -31,28 +31,28 @@ export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponen
|
|||||||
areaInHa(item:IItem):number {
|
areaInHa(item:IItem):number {
|
||||||
if(!item) return 0;
|
if(!item) return 0;
|
||||||
// get area from faeture if 0 calculate from polygon
|
// get area from faeture if 0 calculate from polygon
|
||||||
let a = item.data.area;
|
const a = item.data.area;
|
||||||
if(a) return a;
|
if(a) return a;
|
||||||
let format = new GeoJSON();
|
const format = new GeoJSON();
|
||||||
let polygon = format.readGeometry(item.geometry);
|
const polygon = format.readGeometry(item.geometry);
|
||||||
return getArea(polygon,{projection:"EPSG:4326"}) / 10000;
|
return getArea(polygon,{projection:"EPSG:4326"}) / 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
var childItems = this.folderService$.getItems(this.item.code, 0, 1000);
|
const childItems = this.folderService$.getItems(this.item.code, 0, 1000);
|
||||||
var atLocationItems = this.itemService$.getItemList(null,null,null,this.item.code,true);
|
const atLocationItems = this.itemService$.getItemList(null,null,null,this.item.code,true);
|
||||||
this.items = childItems.pipe(
|
this.items = childItems.pipe(
|
||||||
combineLatest(atLocationItems),
|
combineLatest(atLocationItems),
|
||||||
switchMap(([ci,ali]) => {
|
switchMap(([ci,ali]) => {
|
||||||
let retVal:IListItem[] = [];
|
const retVal:IListItem[] = [];
|
||||||
let codes = {};
|
const codes = {};
|
||||||
ci.forEach((listItem) => {
|
ci.forEach((listItem) => {
|
||||||
retVal.push(listItem);
|
retVal.push(listItem);
|
||||||
codes[listItem.code]=listItem;
|
codes[listItem.code]=listItem;
|
||||||
});
|
});
|
||||||
ali.forEach((atlocationitem) => {
|
ali.forEach((atlocationitem) => {
|
||||||
let listItem = atlocationitem as IListItem;
|
const listItem = atlocationitem as IListItem;
|
||||||
let allowedItemTypes = "vnd.farmmaps.itemtype.device.senml"; // this is a hack
|
const allowedItemTypes = "vnd.farmmaps.itemtype.device.senml"; // this is a hack
|
||||||
if(!codes[listItem.code] && allowedItemTypes.indexOf(listItem.itemType) >= 0) {
|
if(!codes[listItem.code] && allowedItemTypes.indexOf(listItem.itemType) >= 0) {
|
||||||
retVal.push(listItem);
|
retVal.push(listItem);
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
<li *ngIf="!getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)"><i class="fas fa-layer-plus" aria-hidden="true" i18n-title title="Add as layer"></i> <span i18n>Add as overlay</span></a></li>
|
<li *ngIf="!getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)"><i class="fas fa-layer-plus" aria-hidden="true" i18n-title title="Add as layer"></i> <span i18n>Add as overlay</span></a></li>
|
||||||
<li *ngIf="getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleRemoveLayer(item,itemLayer.layerIndex)"><i class="fas fa-layer-minus" aria-hidden="true" i18n-title title="Remove overlay"></i> <span i18n>Remove overlay</span></a></li>
|
<li *ngIf="getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleRemoveLayer(item,itemLayer.layerIndex)"><i class="fas fa-layer-minus" aria-hidden="true" i18n-title title="Remove overlay"></i> <span i18n>Remove overlay</span></a></li>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
<li><fm-item-link class="text-primary p-0" [itemCode]="item.code" pathSuffix="data" [showText]="true"></fm-item-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<fm-map-zoom-to-show-alert [layer]="itemLayer?.layer"></fm-map-zoom-to-show-alert>
|
<fm-map-zoom-to-show-alert [layer]="itemLayer?.layer"></fm-map-zoom-to-show-alert>
|
||||||
|
@@ -23,7 +23,7 @@ export class SelectedItemShapeComponent extends AbstractSelectedItemComponent {
|
|||||||
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
|
||||||
super(store, itemTypeService,location,router);
|
super(store, itemTypeService,location,router);
|
||||||
}
|
}
|
||||||
public selectedLayer: number = 0;
|
public selectedLayer = 0;
|
||||||
|
|
||||||
onLayerChanged(layerIndex: number) {
|
onLayerChanged(layerIndex: number) {
|
||||||
this.store.dispatch(new mapActions.SetLayerIndex(layerIndex));
|
this.store.dispatch(new mapActions.SetLayerIndex(layerIndex));
|
||||||
|
@@ -46,7 +46,7 @@ export class SelectedItemTemporalComponent extends AbstractSelectedItemComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedItem():IItem {
|
selectedItem():IItem {
|
||||||
let temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
||||||
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
|
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
|
||||||
return temporalItemLayer.selectedItemLayer.item;
|
return temporalItemLayer.selectedItemLayer.item;
|
||||||
}
|
}
|
||||||
|
@@ -20,39 +20,39 @@ export abstract class AbstractSelectedItemComponent {
|
|||||||
|
|
||||||
handleOnView(item: IItem) {
|
handleOnView(item: IItem) {
|
||||||
if (this.itemTypeService.hasViewer(item)) {
|
if (this.itemTypeService.hasViewer(item)) {
|
||||||
let viewer = this.itemTypeService.itemTypes[item.itemType].viewer;
|
const viewer = this.itemTypeService.itemTypes[item.itemType].viewer;
|
||||||
let url = `/viewer/${viewer}/item/${item.code}`;
|
const url = `/viewer/${viewer}/item/${item.code}`;
|
||||||
this.router.navigate([url]);
|
this.router.navigate([url]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOnEdit(item: IItem) {
|
handleOnEdit(item: IItem) {
|
||||||
var editor = "property";
|
let editor = "property";
|
||||||
if(this.itemTypeService.hasEditor(item)) {
|
if(this.itemTypeService.hasEditor(item)) {
|
||||||
editor = this.itemTypeService.itemTypes[item.itemType].editor;
|
editor = this.itemTypeService.itemTypes[item.itemType].editor;
|
||||||
}
|
}
|
||||||
let url = `/editor/${editor}/item/${item.code}`
|
const url = `/editor/${editor}/item/${item.code}`
|
||||||
this.router.navigate([url]);
|
this.router.navigate([url]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAddAsLayer(item: IItem,layerIndex:number = -1) {
|
handleAddAsLayer(item: IItem,layerIndex = -1) {
|
||||||
this.store.dispatch(new mapActions.AddLayer(item,layerIndex));
|
this.store.dispatch(new mapActions.AddLayer(item,layerIndex));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRemoveLayer(item: IItem,layerIndex:number = -1) {
|
handleRemoveLayer(item: IItem,layerIndex = -1) {
|
||||||
let itemLayer = this.getItemLayer(item,layerIndex);
|
const itemLayer = this.getItemLayer(item,layerIndex);
|
||||||
if(itemLayer) {
|
if(itemLayer) {
|
||||||
this.store.dispatch(new mapActions.RemoveLayer(itemLayer));
|
this.store.dispatch(new mapActions.RemoveLayer(itemLayer));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemLayer(item:IItem,layerIndex:number = -1):IItemLayer {
|
getItemLayer(item:IItem,layerIndex = -1):IItemLayer {
|
||||||
let li = layerIndex==-1?0:layerIndex;
|
const li = layerIndex==-1?0:layerIndex;
|
||||||
let selected = this.overlayLayers.filter(ol => ol.item.code == item.code && ol.layerIndex == li);
|
const selected = this.overlayLayers.filter(ol => ol.item.code == item.code && ol.layerIndex == li);
|
||||||
if(selected.length==0) return null;
|
if(selected.length==0) return null;
|
||||||
return selected[0];
|
return selected[0];
|
||||||
}
|
}
|
||||||
|
@@ -1,34 +1,34 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Store, Action,createFeatureSelector } from '@ngrx/store';
|
import { Store, Action, createFeatureSelector } from '@ngrx/store';
|
||||||
import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store';
|
import { ROUTER_NAVIGATED, RouterReducerState } from '@ngrx/router-store';
|
||||||
import * as fromRouter from '@ngrx/router-store';
|
import * as fromRouter from '@ngrx/router-store';
|
||||||
import { createEffect, Actions,ofType } from '@ngrx/effects';
|
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,Geometry} from 'ol/geom'
|
import { Point, Geometry } from 'ol/geom'
|
||||||
|
|
||||||
|
|
||||||
import * as mapActions from '../actions/map.actions';
|
import * as mapActions from '../actions/map.actions';
|
||||||
import * as mapReducers from '../reducers/map.reducer';
|
import * as mapReducers from '../reducers/map.reducer';
|
||||||
import {commonReducers} from '@farmmaps/common';
|
import { commonReducers } from '@farmmaps/common';
|
||||||
|
|
||||||
import {commonActions} from '@farmmaps/common';
|
import { commonActions } from '@farmmaps/common';
|
||||||
|
|
||||||
import { IItem } from '@farmmaps/common';
|
import { IItem } from '@farmmaps/common';
|
||||||
import { FolderService, ItemService } from '@farmmaps/common';
|
import { FolderService, ItemService } from '@farmmaps/common';
|
||||||
import { tassign } from 'tassign';
|
import { tassign } from 'tassign';
|
||||||
|
|
||||||
import {FeatureIconService} from '../services/feature-icon.service';
|
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'
|
import { TemporalItemLayer } from '../models/item.layer'
|
||||||
|
|
||||||
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
|
export const getRouterState = createFeatureSelector<RouterReducerState>('router');
|
||||||
@@ -48,33 +48,33 @@ export const {
|
|||||||
export class MapEffects {
|
export class MapEffects {
|
||||||
private _geojsonFormat: GeoJSON;
|
private _geojsonFormat: GeoJSON;
|
||||||
private _wktFormat: WKT;
|
private _wktFormat: WKT;
|
||||||
private overrideSelectedItemLayer: boolean = false;
|
private overrideSelectedItemLayer = false;
|
||||||
|
|
||||||
private updateFeatureGeometry(feature:Feature<Geometry>, updateEvent:commonActions.DeviceUpdateEvent): Feature<Geometry> {
|
private updateFeatureGeometry(feature: Feature<Geometry>, updateEvent: commonActions.DeviceUpdateEvent): Feature<Geometry> {
|
||||||
let newFeature = feature.clone();
|
const newFeature = feature.clone();
|
||||||
var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{
|
const f = this._wktFormat.readFeature(updateEvent.attributes["geometry"], {
|
||||||
dataProjection: 'EPSG:4326',
|
dataProjection: 'EPSG:4326',
|
||||||
featureProjection: 'EPSG:3857'
|
featureProjection: 'EPSG:3857'
|
||||||
});
|
});
|
||||||
var centroid = getCenter(f.getGeometry().getExtent());
|
const centroid = getCenter(f.getGeometry().getExtent());
|
||||||
newFeature.setId(feature.getId());
|
newFeature.setId(feature.getId());
|
||||||
newFeature.setGeometry(new Point(centroid));
|
newFeature.setGeometry(new Point(centroid));
|
||||||
return newFeature;
|
return newFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
init$ = createEffect(() => this.actions$.pipe(
|
init$ = createEffect(() => 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]) => {
|
||||||
let actions=[];
|
const actions = [];
|
||||||
for (let rootItem of rootItems) {
|
for (const rootItem of rootItems) {
|
||||||
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
||||||
}
|
}
|
||||||
// initialize default feature styles
|
// initialize default feature styles
|
||||||
actions.push(new mapActions.SetStyle('file',new style.Style({
|
actions.push(new mapActions.SetStyle('file', new style.Style({
|
||||||
image: new style.Icon({
|
image: new style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
scale: 0.05,
|
scale: 0.05,
|
||||||
src: this.featureIconService$.getIconImageDataUrl("fal fa-file")
|
src: this.featureIconService$.getIconImageDataUrl("fal fa-file")
|
||||||
}),
|
}),
|
||||||
stroke: new style.Stroke({
|
stroke: new style.Stroke({
|
||||||
@@ -85,7 +85,7 @@ export class MapEffects {
|
|||||||
color: 'rgba(0, 0, 0,0)'
|
color: 'rgba(0, 0, 0,0)'
|
||||||
})
|
})
|
||||||
})));
|
})));
|
||||||
actions.push(new mapActions.SetStyle('selected',new style.Style({
|
actions.push(new mapActions.SetStyle('selected', new style.Style({
|
||||||
image: new style.Icon({
|
image: new style.Icon({
|
||||||
anchor: [0.5, 1],
|
anchor: [0.5, 1],
|
||||||
scale: 0.08,
|
scale: 0.08,
|
||||||
@@ -104,13 +104,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
initBaseLayers$ = createEffect(() => this.actions$.pipe(
|
initBaseLayers$ = createEffect(() => 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)))
|
||||||
);
|
);
|
||||||
|
|
||||||
loadBaseLayers$ = createEffect(() => this.actions$.pipe(
|
loadBaseLayers$ = createEffect(() => 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(
|
||||||
@@ -118,17 +118,17 @@ export class MapEffects {
|
|||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
})));
|
})));
|
||||||
|
|
||||||
startSearch$ = createEffect(() => this.actions$.pipe(
|
startSearch$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.STARTSEARCH),
|
ofType(mapActions.STARTSEARCH),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as mapActions.StartSearch;
|
const a = action as mapActions.StartSearch;
|
||||||
var startDate = a.queryState.startDate;
|
const startDate = a.queryState.startDate;
|
||||||
var endDate = a.queryState.endDate;
|
const endDate = a.queryState.endDate;
|
||||||
var newAction:Observable<Action>;
|
let 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, a.queryState.dataFilter, a.queryState.level).pipe(
|
newAction = this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode, a.queryState.dataFilter, a.queryState.level).pipe(
|
||||||
switchMap((features: any) => {
|
switchMap((features: any) => {
|
||||||
for (let f of features.features) {
|
for (const f of features.features) {
|
||||||
if (f.properties && f.properties["code"]) {
|
if (f.properties && f.properties["code"]) {
|
||||||
f.id = f.properties["code"];
|
f.id = f.properties["code"];
|
||||||
}
|
}
|
||||||
@@ -144,18 +144,18 @@ export class MapEffects {
|
|||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
||||||
zoomToExtent$ = createEffect(() => this.actions$.pipe(
|
zoomToExtent$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.STARTSEARCHSUCCESS),
|
ofType(mapActions.STARTSEARCHSUCCESS),
|
||||||
mergeMap((action: mapActions.StartSearchSuccess) => {
|
mergeMap((action: mapActions.StartSearchSuccess) => {
|
||||||
let actions =[];
|
const actions = [];
|
||||||
actions.push(new commonActions.SetMenuVisible(false));
|
actions.push(new commonActions.SetMenuVisible(false));
|
||||||
let extent = createEmpty();
|
const extent = createEmpty();
|
||||||
if (!action.query.bboxFilter) {
|
if (!action.query.bboxFilter) {
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (let f of action.features) {
|
for (const f of action.features) {
|
||||||
extend(extent, (f as Feature<Geometry>).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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,64 +163,64 @@ export class MapEffects {
|
|||||||
return actions;
|
return actions;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
|
zoomToExtent2$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SETFEATURES),
|
ofType(mapActions.SETFEATURES),
|
||||||
switchMap((action: mapActions.SetFeatures) => {
|
switchMap((action: mapActions.SetFeatures) => {
|
||||||
let extent = createEmpty();
|
const extent = createEmpty();
|
||||||
if (extent) {
|
if (extent) {
|
||||||
for (let f of action.features) {
|
for (const f of action.features) {
|
||||||
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
extend(extent, (f as Feature<Geometry>).getGeometry().getExtent());
|
||||||
}
|
|
||||||
if(action.features.length>0) return of(new mapActions.SetExtent(extent));
|
|
||||||
}
|
}
|
||||||
return EMPTY;
|
if (action.features.length > 0) return of(new mapActions.SetExtent(extent));
|
||||||
})));
|
}
|
||||||
|
return EMPTY;
|
||||||
|
})));
|
||||||
|
|
||||||
hideMenu$ = createEffect(() => this.actions$.pipe(
|
hideMenu$ = createEffect(() => 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));
|
||||||
})));
|
})));
|
||||||
|
|
||||||
selectItem$ = createEffect(() => this.actions$.pipe(
|
selectItem$ = createEffect(() => 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]) => {
|
||||||
let a = action as mapActions.SelectItem;
|
const a = action as mapActions.SelectItem;
|
||||||
let itemCode = selectedItem ? selectedItem.code : "";
|
const itemCode = selectedItem ? selectedItem.code : "";
|
||||||
if (a.itemCode != itemCode) {
|
if (a.itemCode != itemCode) {
|
||||||
return this.itemService$.getItem(a.itemCode).pipe(
|
return this.itemService$.getItem(a.itemCode).pipe(
|
||||||
switchMap(child => {
|
switchMap(child => {
|
||||||
return this.itemService$.getItem(child.parentCode)
|
return this.itemService$.getItem(child.parentCode)
|
||||||
.pipe(map(parent => {
|
.pipe(map(parent => {
|
||||||
return {child, parent};
|
return { child, parent };
|
||||||
}),catchError(() => { let parent:IItem = null;return of({child,parent})})
|
}), catchError(() => { const parent: IItem = null; return of({ child, parent }) })
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
||||||
catchError(error => of(new commonActions.Fail(error))))
|
catchError(error => of(new commonActions.Fail(error))))
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
|
selectItemSuccessSetLayer$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
|
||||||
map((action:mapActions.SelectItemSuccess) =>
|
|
||||||
new mapActions.SetSelectedItemLayer(action.item)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
|
|
||||||
ofType(mapActions.SELECTITEMSUCCESS),
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
switchMap((action:mapActions.SelectItemSuccess) => {
|
map((action: mapActions.SelectItemSuccess) =>
|
||||||
if(!this.overrideSelectedItemLayer) {
|
new mapActions.SetSelectedItemLayer(action.item)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
selectItemSuccess$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(mapActions.SELECTITEMSUCCESS),
|
||||||
|
switchMap((action: mapActions.SelectItemSuccess) => {
|
||||||
|
if (!this.overrideSelectedItemLayer) {
|
||||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||||
map((feature: any) => {
|
map((feature: any) => {
|
||||||
let f = this._geojsonFormat.readFeature(feature);
|
const f = this._geojsonFormat.readFeature(feature);
|
||||||
f.setId(action.item.code);
|
f.setId(action.item.code);
|
||||||
return new mapActions.AddFeatureSuccess(f );
|
return new mapActions.AddFeatureSuccess(f);
|
||||||
}),
|
}),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
} else {
|
} else {
|
||||||
@@ -229,59 +229,59 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
selectItemSuccessTemporal$ = createEffect(() => this.actions$.pipe(
|
selectItemSuccessTemporal$ = createEffect(() => 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") {
|
||||||
return this.itemService$.getChildItemList(action.item.code,null).pipe(
|
return this.itemService$.getChildItemList(action.item.code, null).pipe(
|
||||||
map(items => new mapActions.SelectTemporalItemsSuccess(
|
map(items => new mapActions.SelectTemporalItemsSuccess(
|
||||||
items.sort((a, b) =>
|
items.sort((a, b) =>
|
||||||
-(Date.parse(b.dataDate) - Date.parse(a.dataDate))
|
-(Date.parse(b.dataDate) - Date.parse(a.dataDate))
|
||||||
)
|
)
|
||||||
)),
|
)),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)));
|
}
|
||||||
|
|
||||||
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
|
|
||||||
ofType(commonActions.UPLOADEDFILECLICK),
|
|
||||||
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query.querystate, {itemCode:action.itemCode})))
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
featureUpdate$ = createEffect(() => this.actions$.pipe(
|
uploadedItemClick$ = createEffect(() => this.actions$.pipe(
|
||||||
|
ofType(commonActions.UPLOADEDFILECLICK),
|
||||||
|
switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query.querystate, { itemCode: action.itemCode })))
|
||||||
|
)));
|
||||||
|
|
||||||
|
featureUpdate$ = createEffect(() => 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;
|
const deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent;
|
||||||
var feature: Feature<Geometry> = null;
|
let feature: Feature<Geometry> = null;
|
||||||
for (let f of features) {
|
for (const f of features) {
|
||||||
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
if (f.getId() == deviceUpdateEventAction.itemCode) {
|
||||||
feature = f;
|
feature = f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (feature) {
|
if (feature) {
|
||||||
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature,deviceUpdateEventAction)));
|
return of(new mapActions.UpdateFeatureSuccess(this.updateFeatureGeometry(feature, deviceUpdateEventAction)));
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
itemUpdate$ = createEffect(() => this.actions$.pipe(
|
itemUpdate$ = createEffect(() => 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]) => {
|
||||||
let itemChangedAction = action as commonActions.ItemChangedEvent;
|
const itemChangedAction = action as commonActions.ItemChangedEvent;
|
||||||
if (selectedItem && selectedItem.code == itemChangedAction.itemCode) {
|
if (selectedItem && selectedItem.code == itemChangedAction.itemCode) {
|
||||||
return this.itemService$.getItem(itemChangedAction.itemCode).pipe(
|
return this.itemService$.getItem(itemChangedAction.itemCode).pipe(
|
||||||
switchMap(child => {
|
switchMap(child => {
|
||||||
return this.itemService$.getItem(child.parentCode)
|
return this.itemService$.getItem(child.parentCode)
|
||||||
.pipe(map(parent => {
|
.pipe(map(parent => {
|
||||||
return {child, parent};
|
return { child, parent };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
map(data => new mapActions.SelectItemSuccess(data.child, data.parent)),
|
||||||
@@ -291,13 +291,13 @@ export class MapEffects {
|
|||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
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)) {
|
||||||
var newAction:Action;
|
var newAction: Action;
|
||||||
if (queryState.itemCode && queryState.itemCode != "") {
|
if (queryState.itemCode && queryState.itemCode != "") {
|
||||||
newAction= new mapActions.SelectItem(queryState.itemCode);
|
newAction = new mapActions.SelectItem(queryState.itemCode);
|
||||||
} else {
|
} else {
|
||||||
newAction= new mapActions.StartSearch(queryState);
|
newAction = new mapActions.StartSearch(queryState);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -306,104 +306,104 @@ export class MapEffects {
|
|||||||
return of(newAction);
|
return of(newAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
getLayerValue$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.GETLAYERVALUE),
|
ofType(mapActions.GETLAYERVALUE),
|
||||||
mergeMap((action:mapActions.GetLayerValue) => {
|
mergeMap((action: mapActions.GetLayerValue) => {
|
||||||
var l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
const l = action.itemLayer.item.data["layers"][action.itemLayer.layerIndex];
|
||||||
var scale = l.scale?l.scale:1;
|
const scale = l.scale ? l.scale : 1;
|
||||||
return this.itemService$.getLayerValue(action.itemLayer.item.code,action.itemLayer.layerIndex,action.x,action.y).pipe(
|
return this.itemService$.getLayerValue(action.itemLayer.item.code, action.itemLayer.layerIndex, action.x, action.y).pipe(
|
||||||
mergeMap((v: number) => {
|
mergeMap((v: number) => {
|
||||||
let a=[];
|
const a = [];
|
||||||
if(v !== null) {
|
if (v !== null) {
|
||||||
if(l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
if (l.renderer && l.renderer.colorMap && l.renderer.colorMap.colormapType == "manual") {
|
||||||
l.renderer.colorMap.entries.forEach((e) => {
|
l.renderer.colorMap.entries.forEach((e) => {
|
||||||
if(e.value == v && e.label) {
|
if (e.value == v && e.label) {
|
||||||
v=e.label;
|
v = e.label;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v,layerName:l.name,quantity:"",unit:l.unit}));
|
a.push(new mapActions.GetLayerValueSuccess({ date: action.itemLayer.item.dataDate, value: v, layerName: l.name, quantity: "", unit: l.unit, scale: l.scale }));
|
||||||
} else {
|
} else {
|
||||||
a.push(new mapActions.GetLayerValueSuccess({date:action.itemLayer.item.dataDate,value:v*scale,layerName:l.name,quantity:l.quantity,unit:l.unit}));
|
a.push(new mapActions.GetLayerValueSuccess({ date: action.itemLayer.item.dataDate, value: v * scale, layerName: l.name, quantity: l.quantity, unit: l.unit, scale: l.scale }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
)));
|
)));
|
||||||
|
|
||||||
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
updateLayerValuesOnLayerAddedOrRemoved$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.ADDLAYER,mapActions.REMOVELAYER,mapActions.SELECTITEMSUCCESS,mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL,mapActions.PREVIOUSTEMPORAL,mapActions.TOGGLELAYERVALUESENABLED,mapActions.SETLAYERINDEX,mapActions.SETSELECTEDITEMLAYER),
|
ofType(mapActions.ADDLAYER, mapActions.REMOVELAYER, mapActions.SELECTITEMSUCCESS, mapActions.SELECTTEMPORALITEMSSUCCESS, mapActions.NEXTTEMPORAL, mapActions.PREVIOUSTEMPORAL, mapActions.TOGGLELAYERVALUESENABLED, mapActions.SETLAYERINDEX, mapActions.SETSELECTEDITEMLAYER),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesX)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesY)),
|
||||||
map(([[action,x],y]) => new mapActions.SetLayerValuesLocation(x,y))
|
map(([[action, x], y]) => new mapActions.SetLayerValuesLocation(x, y))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
getLayerValues$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(mapActions.SETLAYERVALUESLOCATION),
|
ofType(mapActions.SETLAYERVALUESLOCATION),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItemLayer)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetLayerValuesEnabled)),
|
||||||
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
withLatestFrom(this.store$.select(mapReducers.selectGetOverlayLayers)),
|
||||||
mergeMap(([[[action, selected], enabled],overlayLayers]) => {
|
mergeMap(([[[action, selected], enabled], overlayLayers]) => {
|
||||||
let layers = [];
|
const layers = [];
|
||||||
if(selected) {
|
if (selected) {
|
||||||
if(selected && (selected as TemporalItemLayer).selectedItemLayer ) {
|
if (selected && (selected as TemporalItemLayer).selectedItemLayer) {
|
||||||
selected=(selected as TemporalItemLayer).selectedItemLayer;
|
selected = (selected as TemporalItemLayer).selectedItemLayer;
|
||||||
}
|
}
|
||||||
layers.push(selected);
|
layers.push(selected);
|
||||||
}
|
}
|
||||||
overlayLayers.forEach((ol) => {
|
overlayLayers.forEach((ol) => {
|
||||||
if(ol!=selected) layers.push(ol);
|
if (ol != selected) layers.push(ol);
|
||||||
});
|
});
|
||||||
let a = action as mapActions.SetLayerValuesLocation;
|
const a = action as mapActions.SetLayerValuesLocation;
|
||||||
let actions = [];
|
const actions = [];
|
||||||
if(enabled) {
|
if (enabled) {
|
||||||
layers.forEach((ol) => {
|
layers.forEach((ol) => {
|
||||||
if("vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(ol.item.itemType)>=0) {
|
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));
|
actions.push(new mapActions.GetLayerValue(ol, a.x, a.y));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return actions;
|
return actions;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
||||||
setState$ = createEffect(() => this.actions$.pipe(
|
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;
|
const a = action as mapActions.SetState;
|
||||||
return this.getActionFromQueryState(a.queryState,inSearch);
|
return this.getActionFromQueryState(a.queryState, inSearch);
|
||||||
})));
|
})));
|
||||||
|
|
||||||
escape$ = createEffect(() => this.actions$.pipe(
|
escape$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(commonActions.ESCAPE),
|
ofType(commonActions.ESCAPE),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as commonActions.Escape;
|
const a = action as commonActions.Escape;
|
||||||
if(a.escapeKey) {
|
if (a.escapeKey) {
|
||||||
return of(new mapActions.Clear());
|
return of(new mapActions.Clear());
|
||||||
} else {
|
} else {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
setOverride$ = createEffect(() => this.actions$.pipe(
|
setOverride$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(ROUTER_NAVIGATED),
|
ofType(ROUTER_NAVIGATED),
|
||||||
switchMap(() => this.store$.select(selectRouteData as any)),
|
switchMap(() => this.store$.select(selectRouteData as any)),
|
||||||
switchMap((data: any) => {
|
switchMap((data: any) => {
|
||||||
if(data && data["fm-map-map"]) {
|
if (data && data["fm-map-map"]) {
|
||||||
let params = data["fm-map-map"];
|
const params = data["fm-map-map"];
|
||||||
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
this.overrideSelectedItemLayer = params["overrideSelectedItemlayer"] ? params["overrideSelectedItemlayer"] : false;
|
||||||
} else {
|
} else {
|
||||||
this.overrideSelectedItemLayer = false;
|
this.overrideSelectedItemLayer = false;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
|
|
||||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) {
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,13 +15,13 @@ export interface IItemLayer {
|
|||||||
export class ItemLayer implements IItemLayer {
|
export class ItemLayer implements IItemLayer {
|
||||||
public item: IItem;
|
public item: IItem;
|
||||||
public layer: Layer<Source> = null;
|
public layer: Layer<Source> = null;
|
||||||
public visible: boolean = true;
|
public visible = true;
|
||||||
public legendVisible: boolean = false;
|
public legendVisible = false;
|
||||||
public projection: string;
|
public projection: string;
|
||||||
public opacity: number = 1;
|
public opacity = 1;
|
||||||
public layerIndex: number = -1;
|
public layerIndex = -1;
|
||||||
|
|
||||||
constructor(item:IItem,opacity:number = 1, visible:boolean = true,layerIndex:number=-1) {
|
constructor(item:IItem,opacity = 1, visible = true,layerIndex=-1) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.opacity = opacity;
|
this.opacity = opacity;
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
@@ -42,7 +42,7 @@ export class TemporalItemLayer extends ItemLayer implements ITemporalItemLayer {
|
|||||||
public nextItemLayer:IItemLayer = null;
|
public nextItemLayer:IItemLayer = null;
|
||||||
public temporalItems:IItem[] = [];
|
public temporalItems:IItem[] = [];
|
||||||
|
|
||||||
constructor(item:IItem,opacity:number = 1, visible:boolean = true) {
|
constructor(item:IItem,opacity = 1, visible = true) {
|
||||||
super(item,opacity,visible)
|
super(item,opacity,visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
export interface ILayervalue {
|
export interface ILayervalue {
|
||||||
date:string;
|
date: string;
|
||||||
layerName:string;
|
layerName: string;
|
||||||
unit:string;
|
unit: string;
|
||||||
quantity:string;
|
quantity: string;
|
||||||
value:number;
|
value: number;
|
||||||
|
scale: number;
|
||||||
}
|
}
|
@@ -4,4 +4,4 @@ import {Geometry } from 'ol/geom';
|
|||||||
|
|
||||||
export interface IStyles{
|
export interface IStyles{
|
||||||
[id: string]: Style | ((featue:Feature<Geometry>) => Style);
|
[id: string]: Style | ((featue:Feature<Geometry>) => Style);
|
||||||
};
|
}
|
@@ -123,56 +123,56 @@ export const initialState: State = {
|
|||||||
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ROUTER_NAVIGATION: {
|
case ROUTER_NAVIGATION: {
|
||||||
let a = action as RouterNavigationAction;
|
const a = action as RouterNavigationAction;
|
||||||
return tassign(state);
|
return tassign(state);
|
||||||
}
|
}
|
||||||
case mapActions.SETMAPSTATE: {
|
case mapActions.SETMAPSTATE: {
|
||||||
let a = action as mapActions.SetMapState;
|
const a = action as mapActions.SetMapState;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
mapState: a.mapState
|
mapState: a.mapState
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SETQUERYSTATE: {
|
case mapActions.SETQUERYSTATE: {
|
||||||
let a = action as mapActions.SetQueryState;
|
const a = action as mapActions.SetQueryState;
|
||||||
return tassign(state, { queryState: tassign(a.queryState ),replaceUrl:a.replaceUrl});
|
return tassign(state, { queryState: tassign(a.queryState ),replaceUrl:a.replaceUrl});
|
||||||
}
|
}
|
||||||
case mapActions.SETSTATE: {
|
case mapActions.SETSTATE: {
|
||||||
let a = action as mapActions.SetState;
|
const a = action as mapActions.SetState;
|
||||||
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
|
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
|
||||||
}
|
}
|
||||||
case mapActions.SETVIEWEXTENT: {
|
case mapActions.SETVIEWEXTENT: {
|
||||||
let a = action as mapActions.SetViewExtent;
|
const a = action as mapActions.SetViewExtent;
|
||||||
return tassign(state, { viewExtent: a.extent });
|
return tassign(state, { viewExtent: a.extent });
|
||||||
}
|
}
|
||||||
case mapActions.SETPARENT: {
|
case mapActions.SETPARENT: {
|
||||||
let a = action as mapActions.SetParent;
|
const a = action as mapActions.SetParent;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
parentCode : a.parentCode
|
parentCode : a.parentCode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.STARTSEARCHSUCCESS: {
|
case mapActions.STARTSEARCHSUCCESS: {
|
||||||
let a = action as mapActions.StartSearchSuccess;
|
const a = action as mapActions.StartSearchSuccess;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
features: a.features,
|
features: a.features,
|
||||||
inSearch:false
|
inSearch:false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SETFEATURES: {
|
case mapActions.SETFEATURES: {
|
||||||
let a = action as mapActions.SetFeatures;
|
const a = action as mapActions.SetFeatures;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
features: a.features
|
features: a.features
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTFEATURE: {
|
case mapActions.SELECTFEATURE: {
|
||||||
let a = action as mapActions.SelectFeature;
|
const a = action as mapActions.SelectFeature;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
selectedFeature: state.selectedItem?state.selectedFeature: a.feature
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTITEM: {
|
case mapActions.SELECTITEM: {
|
||||||
let a = action as mapActions.SelectItem;
|
const a = action as mapActions.SelectItem;
|
||||||
let itemCode = state.selectedItem ? state.selectedItem.code : "";
|
const itemCode = state.selectedItem ? state.selectedItem.code : "";
|
||||||
let inSearch = a.itemCode != itemCode;
|
const inSearch = a.itemCode != itemCode;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
selectedItemLayer: null,
|
selectedItemLayer: null,
|
||||||
@@ -182,7 +182,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTITEMSUCCESS: {
|
case mapActions.SELECTITEMSUCCESS: {
|
||||||
let a = action as mapActions.SelectItemSuccess;
|
const a = action as mapActions.SelectItemSuccess;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
inSearch:false,
|
inSearch:false,
|
||||||
selectedItem: a.item,
|
selectedItem: a.item,
|
||||||
@@ -195,8 +195,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SETSELECTEDITEMLAYER: {
|
case mapActions.SETSELECTEDITEMLAYER: {
|
||||||
let a = action as mapActions.SetSelectedItemLayer;
|
const a = action as mapActions.SetSelectedItemLayer;
|
||||||
var itemLayer = null;
|
let itemLayer = null;
|
||||||
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
||||||
itemLayer = new ItemLayer(a.item);
|
itemLayer = new ItemLayer(a.item);
|
||||||
itemLayer.layerIndex = a.layerIndex>=0?a.layerIndex:a.item.data.layers?a.item.data.layers[0].index:-1;
|
itemLayer.layerIndex = a.layerIndex>=0?a.layerIndex:a.item.data.layers?a.item.data.layers[0].index:-1;
|
||||||
@@ -209,12 +209,12 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SELECTTEMPORALITEMSSUCCESS:{
|
case mapActions.SELECTTEMPORALITEMSSUCCESS:{
|
||||||
let a = action as mapActions.SelectTemporalItemsSuccess;
|
const a = action as mapActions.SelectTemporalItemsSuccess;
|
||||||
let selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
const selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
||||||
let layerIndex=-1;
|
let layerIndex=-1;
|
||||||
selectedItemLayer.temporalItems = a.temporalItems;
|
selectedItemLayer.temporalItems = a.temporalItems;
|
||||||
if(a.temporalItems.length>0) {
|
if(a.temporalItems.length>0) {
|
||||||
let item = a.temporalItems[a.temporalItems.length-1];
|
const item = a.temporalItems[a.temporalItems.length-1];
|
||||||
layerIndex = item.data.layers[0].index;
|
layerIndex = item.data.layers[0].index;
|
||||||
selectedItemLayer.selectedItemLayer = new ItemLayer(item,1,true,layerIndex);
|
selectedItemLayer.selectedItemLayer = new ItemLayer(item,1,true,layerIndex);
|
||||||
} else {
|
} else {
|
||||||
@@ -223,16 +223,16 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2],0,true,layerIndex):null;
|
selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2],0,true,layerIndex):null;
|
||||||
selectedItemLayer.nextItemLayer = null;
|
selectedItemLayer.nextItemLayer = null;
|
||||||
if(selectedItemLayer.selectedItemLayer) {
|
if(selectedItemLayer.selectedItemLayer) {
|
||||||
let layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index;
|
const layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index;
|
||||||
selectedItemLayer.layerIndex = layerIndex;
|
selectedItemLayer.layerIndex = layerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
|
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
|
||||||
}
|
}
|
||||||
case mapActions.NEXTTEMPORAL: {
|
case mapActions.NEXTTEMPORAL: {
|
||||||
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
const temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||||
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
||||||
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
const index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||||
if(index == (temporalLayer.temporalItems.length-1)) {
|
if(index == (temporalLayer.temporalItems.length-1)) {
|
||||||
return state;
|
return state;
|
||||||
} else {
|
} else {
|
||||||
@@ -258,9 +258,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case mapActions.PREVIOUSTEMPORAL: {
|
case mapActions.PREVIOUSTEMPORAL: {
|
||||||
let temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
const temporalLayer = state.selectedItemLayer as ITemporalItemLayer;
|
||||||
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) {
|
||||||
let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
const index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item);
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
return state;
|
return state;
|
||||||
} else {
|
} else {
|
||||||
@@ -289,8 +289,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
//todo implement
|
//todo implement
|
||||||
}
|
}
|
||||||
case mapActions.STARTSEARCH: {
|
case mapActions.STARTSEARCH: {
|
||||||
let a = action as mapActions.StartSearch;
|
const a = action as mapActions.StartSearch;
|
||||||
let panelVisible = a.queryState.itemCode!=null ||a.queryState.itemType!=null||a.queryState.parentCode!=null || a.queryState.query != null || a.queryState.tags != null;
|
const panelVisible = a.queryState.itemCode!=null ||a.queryState.itemType!=null||a.queryState.parentCode!=null || a.queryState.query != null || a.queryState.tags != null;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
features:[],
|
features:[],
|
||||||
@@ -306,7 +306,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
return tassign(state,{inSearch:false});
|
return tassign(state,{inSearch:false});
|
||||||
}
|
}
|
||||||
case mapActions.DOQUERY: {
|
case mapActions.DOQUERY: {
|
||||||
let a = action as mapActions.DoQuery;
|
const a = action as mapActions.DoQuery;
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
query: tassign(state.query,
|
query: tassign(state.query,
|
||||||
{
|
{
|
||||||
@@ -321,8 +321,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
}
|
}
|
||||||
|
|
||||||
case mapActions.ADDFEATURESUCCESS: {
|
case mapActions.ADDFEATURESUCCESS: {
|
||||||
let a = action as mapActions.AddFeatureSuccess;
|
const a = action as mapActions.AddFeatureSuccess;
|
||||||
let features = state.features.slice();
|
const features = state.features.slice();
|
||||||
features.push(a.feature);
|
features.push(a.feature);
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
panelVisible: true,
|
panelVisible: true,
|
||||||
@@ -334,8 +334,8 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.UPDATEFEATURESUCCESS: {
|
case mapActions.UPDATEFEATURESUCCESS: {
|
||||||
let a = action as mapActions.UpdateFeatureSuccess;
|
const a = action as mapActions.UpdateFeatureSuccess;
|
||||||
let features: any[] = [];
|
const features: any[] = [];
|
||||||
var index = -1;
|
var index = -1;
|
||||||
for (var i = 0; i < state.features.length; i++) {
|
for (var i = 0; i < state.features.length; i++) {
|
||||||
if (state.features[i].getId() == a.feature.getId()) {
|
if (state.features[i].getId() == a.feature.getId()) {
|
||||||
@@ -356,15 +356,15 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
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: {
|
||||||
let a = action as mapActions.SetExtent;
|
const a = action as mapActions.SetExtent;
|
||||||
return tassign(state, { extent: a.extent });
|
return tassign(state, { extent: a.extent });
|
||||||
}
|
}
|
||||||
case mapActions.ADDLAYER: {
|
case mapActions.ADDLAYER: {
|
||||||
let a = action as mapActions.AddLayer;
|
const a = action as mapActions.AddLayer;
|
||||||
let itemLayers = state.overlayLayers.slice(0);
|
const itemLayers = state.overlayLayers.slice(0);
|
||||||
let itemLayer = new ItemLayer(a.item);
|
const itemLayer = new ItemLayer(a.item);
|
||||||
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex;
|
||||||
let existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex);
|
const existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex);
|
||||||
if(existing.length==0) {
|
if(existing.length==0) {
|
||||||
itemLayers.push(itemLayer);
|
itemLayers.push(itemLayer);
|
||||||
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer });
|
||||||
@@ -374,10 +374,10 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
|
|
||||||
}
|
}
|
||||||
case mapActions.REMOVELAYER: {
|
case mapActions.REMOVELAYER: {
|
||||||
let a = action as mapActions.RemoveLayer;
|
const a = action as mapActions.RemoveLayer;
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
const newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
var selectedOverlayLayer: IItemLayer = null;
|
let selectedOverlayLayer: IItemLayer = null;
|
||||||
if (i>0 && state.overlayLayers.length > 1)
|
if (i>0 && state.overlayLayers.length > 1)
|
||||||
selectedOverlayLayer = state.overlayLayers[i - 1];
|
selectedOverlayLayer = state.overlayLayers[i - 1];
|
||||||
else if (i == 0 && state.overlayLayers.length > 1)
|
else if (i == 0 && state.overlayLayers.length > 1)
|
||||||
@@ -389,49 +389,49 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
return tassign(state, {overlayLayers: [], selectedOverlayLayer: null});
|
return tassign(state, {overlayLayers: [], selectedOverlayLayer: null});
|
||||||
}
|
}
|
||||||
case mapActions.SETVISIBILITY: {
|
case mapActions.SETVISIBILITY: {
|
||||||
let a = action as mapActions.SetVisibility;
|
const a = action as mapActions.SetVisibility;
|
||||||
if(state.selectedItemLayer == a.itemLayer) {
|
if(state.selectedItemLayer == a.itemLayer) {
|
||||||
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{visible:a.visibility})});
|
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{visible:a.visibility})});
|
||||||
} else {
|
} else {
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
const newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].visible = a.visibility;
|
newLayers[i].visible = a.visibility;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case mapActions.SETOPACITY: {
|
case mapActions.SETOPACITY: {
|
||||||
let a = action as mapActions.SetOpacity;
|
const a = action as mapActions.SetOpacity;
|
||||||
if(state.selectedItemLayer == a.itemLayer) {
|
if(state.selectedItemLayer == a.itemLayer) {
|
||||||
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{opacity:a.opacity})});
|
return tassign(state,{selectedItemLayer: tassign(state.selectedItemLayer,{opacity:a.opacity})});
|
||||||
} else {
|
} else {
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
const newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].opacity = a.opacity;
|
newLayers[i].opacity = a.opacity;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case mapActions.SETLAYERINDEX: {
|
case mapActions.SETLAYERINDEX: {
|
||||||
let a = action as mapActions.SetLayerIndex;
|
const a = action as mapActions.SetLayerIndex;
|
||||||
if (a.itemLayer == null) {
|
if (a.itemLayer == null) {
|
||||||
if(state.selectedItemLayer.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
if(state.selectedItemLayer.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||||
var newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex});
|
var newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex});
|
||||||
let tl = newItemlayer as ITemporalItemLayer;
|
const tl = newItemlayer as ITemporalItemLayer;
|
||||||
if(tl.previousItemLayer) {
|
if(tl.previousItemLayer) {
|
||||||
let nl = new ItemLayer(tl.previousItemLayer.item);
|
const nl = new ItemLayer(tl.previousItemLayer.item);
|
||||||
nl.opacity = tl.previousItemLayer.opacity;
|
nl.opacity = tl.previousItemLayer.opacity;
|
||||||
nl.visible = tl.previousItemLayer.visible;
|
nl.visible = tl.previousItemLayer.visible;
|
||||||
nl.layerIndex = a.layerIndex;
|
nl.layerIndex = a.layerIndex;
|
||||||
tl.previousItemLayer = nl;
|
tl.previousItemLayer = nl;
|
||||||
}
|
}
|
||||||
if(tl.selectedItemLayer) {
|
if(tl.selectedItemLayer) {
|
||||||
let nl = new ItemLayer(tl.selectedItemLayer.item);
|
const nl = new ItemLayer(tl.selectedItemLayer.item);
|
||||||
nl.opacity = tl.selectedItemLayer.opacity;
|
nl.opacity = tl.selectedItemLayer.opacity;
|
||||||
nl.visible = tl.selectedItemLayer.visible;
|
nl.visible = tl.selectedItemLayer.visible;
|
||||||
nl.layerIndex = a.layerIndex;
|
nl.layerIndex = a.layerIndex;
|
||||||
tl.selectedItemLayer = nl;
|
tl.selectedItemLayer = nl;
|
||||||
}
|
}
|
||||||
if(tl.nextItemLayer) {
|
if(tl.nextItemLayer) {
|
||||||
let nl = new ItemLayer(tl.nextItemLayer.item);
|
const nl = new ItemLayer(tl.nextItemLayer.item);
|
||||||
nl.opacity = tl.nextItemLayer.opacity;
|
nl.opacity = tl.nextItemLayer.opacity;
|
||||||
nl.visible = tl.nextItemLayer.visible;
|
nl.visible = tl.nextItemLayer.visible;
|
||||||
nl.layerIndex = a.layerIndex;
|
nl.layerIndex = a.layerIndex;
|
||||||
@@ -444,24 +444,24 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
}
|
}
|
||||||
return tassign(state, { selectedItemLayer: newItemlayer})
|
return tassign(state, { selectedItemLayer: newItemlayer})
|
||||||
} else {
|
} else {
|
||||||
let newLayers = state.overlayLayers.slice(0);
|
const newLayers = state.overlayLayers.slice(0);
|
||||||
let i = state.overlayLayers.indexOf(a.itemLayer);
|
const i = state.overlayLayers.indexOf(a.itemLayer);
|
||||||
newLayers[i].layerIndex = a.layerIndex;
|
newLayers[i].layerIndex = a.layerIndex;
|
||||||
return tassign(state, { overlayLayers: newLayers });
|
return tassign(state, { overlayLayers: newLayers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case mapActions.LOADBASELAYERSSUCCESS: {
|
case mapActions.LOADBASELAYERSSUCCESS: {
|
||||||
let a =action as mapActions.LoadBaseLayersSuccess;
|
const a =action as mapActions.LoadBaseLayersSuccess;
|
||||||
let baseLayers:ItemLayer[] = [];
|
const baseLayers:ItemLayer[] = [];
|
||||||
for (let item of a.items) {
|
for (const item of a.items) {
|
||||||
var l = new ItemLayer(item);
|
const l = new ItemLayer(item);
|
||||||
l.visible = false;
|
l.visible = false;
|
||||||
baseLayers.push(l);
|
baseLayers.push(l);
|
||||||
}
|
}
|
||||||
var selectedBaseLayer: IItemLayer = null;
|
let selectedBaseLayer: IItemLayer = null;
|
||||||
var mapState = tassign(state.mapState);
|
var mapState = tassign(state.mapState);
|
||||||
let sb = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode);
|
const sb = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode);
|
||||||
let db = baseLayers.filter(layer => layer.item.data && layer.item.data.default === true);
|
const db = baseLayers.filter(layer => layer.item.data && layer.item.data.default === true);
|
||||||
if (baseLayers.length > 0 && mapState.baseLayerCode != "" && sb.length>0) {
|
if (baseLayers.length > 0 && mapState.baseLayerCode != "" && sb.length>0) {
|
||||||
selectedBaseLayer = sb[0];
|
selectedBaseLayer = sb[0];
|
||||||
selectedBaseLayer.visible = true;
|
selectedBaseLayer.visible = true;
|
||||||
@@ -476,22 +476,22 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer });
|
return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer });
|
||||||
}
|
}
|
||||||
case mapActions.SELECTBASELAYER: {
|
case mapActions.SELECTBASELAYER: {
|
||||||
let a = action as mapActions.SelectBaseLayer;
|
const a = action as mapActions.SelectBaseLayer;
|
||||||
let baseLayers = state.baseLayers.slice(0);
|
const baseLayers = state.baseLayers.slice(0);
|
||||||
baseLayers.forEach((l) => l.visible = false);
|
baseLayers.forEach((l) => l.visible = false);
|
||||||
let i = state.baseLayers.indexOf(a.itemLayer);
|
const i = state.baseLayers.indexOf(a.itemLayer);
|
||||||
baseLayers[i].visible = true;
|
baseLayers[i].visible = true;
|
||||||
var mapState = tassign(state.mapState);
|
var mapState = tassign(state.mapState);
|
||||||
mapState.baseLayerCode = a.itemLayer.item.code;
|
mapState.baseLayerCode = a.itemLayer.item.code;
|
||||||
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
|
return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer });
|
||||||
}
|
}
|
||||||
case mapActions.SELECTOVERLAYLAYER: {
|
case mapActions.SELECTOVERLAYLAYER: {
|
||||||
let a = action as mapActions.SelectOverlayLayer;
|
const a = action as mapActions.SelectOverlayLayer;
|
||||||
return tassign(state, { selectedOverlayLayer: a.itemLayer });
|
return tassign(state, { selectedOverlayLayer: a.itemLayer });
|
||||||
}
|
}
|
||||||
|
|
||||||
case mapActions.CLEAR: {
|
case mapActions.CLEAR: {
|
||||||
let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
const newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null });
|
||||||
return tassign(state, {
|
return tassign(state, {
|
||||||
panelVisible: false,
|
panelVisible: false,
|
||||||
panelCollapsed:false,
|
panelCollapsed:false,
|
||||||
@@ -511,41 +511,41 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case mapActions.SETSTYLE:{
|
case mapActions.SETSTYLE:{
|
||||||
let a = action as mapActions.SetStyle;
|
const a = action as mapActions.SetStyle;
|
||||||
let styles = tassign(state.styles);
|
const styles = tassign(state.styles);
|
||||||
styles[a.itemType] = a.style;
|
styles[a.itemType] = a.style;
|
||||||
return tassign(state,{styles:styles});
|
return tassign(state,{styles:styles});
|
||||||
}
|
}
|
||||||
case mapActions.SHOWLAYERSWITCHER:{
|
case mapActions.SHOWLAYERSWITCHER:{
|
||||||
let a = action as mapActions.ShowLayerSwitcher;
|
const a = action as mapActions.ShowLayerSwitcher;
|
||||||
return tassign(state,{showLayerSwitcher:a.show});
|
return tassign(state,{showLayerSwitcher:a.show});
|
||||||
}
|
}
|
||||||
case mapActions.TOGGLESHOWDATALAYERSLIDE:{
|
case mapActions.TOGGLESHOWDATALAYERSLIDE:{
|
||||||
return tassign(state,{showDataLayerSlide:!state.showDataLayerSlide});
|
return tassign(state,{showDataLayerSlide:!state.showDataLayerSlide});
|
||||||
}
|
}
|
||||||
case mapActions.SETREPLACEURL: {
|
case mapActions.SETREPLACEURL: {
|
||||||
let a= action as mapActions.SetReplaceUrl;
|
const a= action as mapActions.SetReplaceUrl;
|
||||||
return tassign(state,{replaceUrl:a.replaceUrl});
|
return tassign(state,{replaceUrl:a.replaceUrl});
|
||||||
}
|
}
|
||||||
case mapActions.TOGGLELAYERVALUESENABLED: {
|
case mapActions.TOGGLELAYERVALUESENABLED: {
|
||||||
return tassign(state,{layerValuesEnabled:!state.layerValuesEnabled});
|
return tassign(state,{layerValuesEnabled:!state.layerValuesEnabled});
|
||||||
}
|
}
|
||||||
case mapActions.SETLAYERVALUESLOCATION: {
|
case mapActions.SETLAYERVALUESLOCATION: {
|
||||||
let a= action as mapActions.SetLayerValuesLocation;
|
const a= action as mapActions.SetLayerValuesLocation;
|
||||||
return tassign(state,{layerValuesX: a.x, layerValuesY:a.y,layerValues:[]});
|
return tassign(state,{layerValuesX: a.x, layerValuesY:a.y,layerValues:[]});
|
||||||
}
|
}
|
||||||
case mapActions.GETLAYERVALUESUCCESS:{
|
case mapActions.GETLAYERVALUESUCCESS:{
|
||||||
let a= action as mapActions.GetLayerValueSuccess;
|
const a= action as mapActions.GetLayerValueSuccess;
|
||||||
let v = state.layerValues.slice(0);
|
const v = state.layerValues.slice(0);
|
||||||
v.push(a.layervalue);
|
v.push(a.layervalue);
|
||||||
return tassign(state,{layerValues:v});
|
return tassign(state,{layerValues:v});
|
||||||
}
|
}
|
||||||
case mapActions.SETVIEWSTATE:{
|
case mapActions.SETVIEWSTATE:{
|
||||||
let a= action as mapActions.SetViewState;
|
const a= action as mapActions.SetViewState;
|
||||||
return tassign(state,{viewEnabled:a.enabled});
|
return tassign(state,{viewEnabled:a.enabled});
|
||||||
}
|
}
|
||||||
case commonActions.ITEMDELETEDEVENT:{
|
case commonActions.ITEMDELETEDEVENT:{
|
||||||
let a= action as commonActions.ItemDeletedEvent;
|
const a= action as commonActions.ItemDeletedEvent;
|
||||||
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
|
if(state.selectedItem && state.selectedItem.code == a.itemCode) {
|
||||||
return tassign(state,{
|
return tassign(state,{
|
||||||
selectedItem: null,
|
selectedItem: null,
|
||||||
@@ -562,7 +562,7 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(index>=0) {
|
if(index>=0) {
|
||||||
let newFeatures = state.features.slice(0);
|
const newFeatures = state.features.slice(0);
|
||||||
newFeatures.splice(index,1);
|
newFeatures.splice(index,1);
|
||||||
return tassign(state,{features:newFeatures});
|
return tassign(state,{features:newFeatures});
|
||||||
}
|
}
|
||||||
@@ -588,6 +588,7 @@ export const getClearEnabled = (state: State) => state.clearEnabled;
|
|||||||
export const getSearchCollapsed = (state: State) => state.searchCollapsed;
|
export const getSearchCollapsed = (state: State) => state.searchCollapsed;
|
||||||
export const getSearchMinified = (state: State) => state.searchMinified;
|
export const getSearchMinified = (state: State) => state.searchMinified;
|
||||||
export const getExtent = (state: State) => state.extent;
|
export const getExtent = (state: State) => state.extent;
|
||||||
|
export const getViewExtent = (state: State) => state.viewExtent;
|
||||||
export const getOverlayLayers = (state: State) => state.overlayLayers;
|
export const getOverlayLayers = (state: State) => state.overlayLayers;
|
||||||
export const getBaseLayers = (state: State) => state.baseLayers;
|
export const getBaseLayers = (state: State) => state.baseLayers;
|
||||||
export const getProjection = (state: State) => state.projection;
|
export const getProjection = (state: State) => state.projection;
|
||||||
@@ -622,6 +623,7 @@ export const selectGetClearEnabled = createSelector(selectMapState, getClearEnab
|
|||||||
export const selectGetSearchCollapsed = createSelector(selectMapState, getSearchCollapsed);
|
export const selectGetSearchCollapsed = createSelector(selectMapState, getSearchCollapsed);
|
||||||
export const selectGetSearchMinified = createSelector(selectMapState, getSearchMinified);
|
export const selectGetSearchMinified = createSelector(selectMapState, getSearchMinified);
|
||||||
export const selectGetExtent = createSelector(selectMapState, getExtent);
|
export const selectGetExtent = createSelector(selectMapState, getExtent);
|
||||||
|
export const selectGetViewExtent = createSelector(selectMapState, getViewExtent);
|
||||||
export const selectGetOverlayLayers = createSelector(selectMapState, getOverlayLayers);
|
export const selectGetOverlayLayers = createSelector(selectMapState, getOverlayLayers);
|
||||||
export const selectGetBaseLayers = createSelector(selectMapState, getBaseLayers);
|
export const selectGetBaseLayers = createSelector(selectMapState, getBaseLayers);
|
||||||
export const selectGetProjection = createSelector(selectMapState, getProjection);
|
export const selectGetProjection = createSelector(selectMapState, getProjection);
|
||||||
|
@@ -8,25 +8,25 @@ export class DeviceOrientationService {
|
|||||||
compassHeading(alpha, beta, gamma):number {
|
compassHeading(alpha, beta, gamma):number {
|
||||||
|
|
||||||
// Convert degrees to radians
|
// Convert degrees to radians
|
||||||
var alphaRad = alpha * (Math.PI / 180);
|
const alphaRad = alpha * (Math.PI / 180);
|
||||||
var betaRad = beta * (Math.PI / 180);
|
const betaRad = beta * (Math.PI / 180);
|
||||||
var gammaRad = gamma * (Math.PI / 180);
|
const gammaRad = gamma * (Math.PI / 180);
|
||||||
|
|
||||||
// Calculate equation components
|
// Calculate equation components
|
||||||
var cA = Math.cos(alphaRad);
|
const cA = Math.cos(alphaRad);
|
||||||
var sA = Math.sin(alphaRad);
|
const sA = Math.sin(alphaRad);
|
||||||
var cB = Math.cos(betaRad);
|
const cB = Math.cos(betaRad);
|
||||||
var sB = Math.sin(betaRad);
|
const sB = Math.sin(betaRad);
|
||||||
var cG = Math.cos(gammaRad);
|
const cG = Math.cos(gammaRad);
|
||||||
var sG = Math.sin(gammaRad);
|
const sG = Math.sin(gammaRad);
|
||||||
|
|
||||||
// Calculate A, B, C rotation components
|
// Calculate A, B, C rotation components
|
||||||
var rA = - cA * sG - sA * sB * cG;
|
const rA = - cA * sG - sA * sB * cG;
|
||||||
var rB = - sA * sG + cA * sB * cG;
|
const rB = - sA * sG + cA * sB * cG;
|
||||||
var rC = - cB * cG;
|
const rC = - cB * cG;
|
||||||
|
|
||||||
// Calculate compass heading
|
// Calculate compass heading
|
||||||
var compassHeading = Math.atan(rA / rB);
|
let compassHeading = Math.atan(rA / rB);
|
||||||
|
|
||||||
// Convert from half unit circle to whole unit circle
|
// Convert from half unit circle to whole unit circle
|
||||||
if(rB < 0) {
|
if(rB < 0) {
|
||||||
@@ -40,7 +40,7 @@ export class DeviceOrientationService {
|
|||||||
getCurrentCompassHeading(): Observable<number> {
|
getCurrentCompassHeading(): Observable<number> {
|
||||||
return Observable.create((observer: Observer<number>) => {
|
return Observable.create((observer: Observer<number>) => {
|
||||||
window.addEventListener("deviceorientation", (event:DeviceOrientationEvent)=>{
|
window.addEventListener("deviceorientation", (event:DeviceOrientationEvent)=>{
|
||||||
let heading = this.compassHeading(event.alpha,event.beta,event.gamma);
|
const heading = this.compassHeading(event.alpha,event.beta,event.gamma);
|
||||||
if(!Number.isNaN(heading)) {
|
if(!Number.isNaN(heading)) {
|
||||||
observer.next(heading);
|
observer.next(heading);
|
||||||
}
|
}
|
||||||
|
@@ -7,31 +7,31 @@ import * as extent from 'ol/extent';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class FeatureIconService {
|
export class FeatureIconService {
|
||||||
|
|
||||||
getIconImageDataUrl(iconClass:string, backgroundColor: string = "#c80a6e",color:string = "#ffffff"): string {
|
getIconImageDataUrl(iconClass:string, backgroundColor = "#c80a6e",color = "#ffffff"): string {
|
||||||
var canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = 365;
|
canvas.width = 365;
|
||||||
canvas.height = 560;
|
canvas.height = 560;
|
||||||
var ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.lineWidth = 6;
|
ctx.lineWidth = 6;
|
||||||
ctx.fillStyle = backgroundColor;
|
ctx.fillStyle = backgroundColor;
|
||||||
ctx.strokeStyle = "#000000";
|
ctx.strokeStyle = "#000000";
|
||||||
var path = new Path2D("m182.9 551.7c0 0.1 0.2 0.3 0.2 0.3s175.2-269 175.2-357.4c0-130.1-88.8-186.7-175.4-186.9-86.6 0.2-175.4 56.8-175.4 186.9 0 88.4 175.3 357.4 175.3 357.4z");
|
const path = new Path2D("m182.9 551.7c0 0.1 0.2 0.3 0.2 0.3s175.2-269 175.2-357.4c0-130.1-88.8-186.7-175.4-186.9-86.6 0.2-175.4 56.8-175.4 186.9 0 88.4 175.3 357.4 175.3 357.4z");
|
||||||
ctx.fill(path)
|
ctx.fill(path)
|
||||||
|
|
||||||
var iconCharacter = "";
|
let iconCharacter = "";
|
||||||
if (iconClass != null) {
|
if (iconClass != null) {
|
||||||
var element = document.createElement("i");
|
const element = document.createElement("i");
|
||||||
element.style.display = "none";
|
element.style.display = "none";
|
||||||
element.className = iconClass;
|
element.className = iconClass;
|
||||||
document.body.appendChild(element);
|
document.body.appendChild(element);
|
||||||
iconCharacter = getComputedStyle(element, "::before").content.replace(/"/g, '');
|
iconCharacter = getComputedStyle(element, "::before").content.replace(/"/g, '');
|
||||||
let iconFont = "200px " +getComputedStyle(element, "::before").fontFamily
|
const iconFont = "200px " +getComputedStyle(element, "::before").fontFamily
|
||||||
document.body.removeChild(element);
|
document.body.removeChild(element);
|
||||||
ctx.strokeStyle = color;
|
ctx.strokeStyle = color;
|
||||||
ctx.fillStyle = color;
|
ctx.fillStyle = color;
|
||||||
ctx.lineWidth = 15;
|
ctx.lineWidth = 15;
|
||||||
ctx.font = iconFont;
|
ctx.font = iconFont;
|
||||||
var ts = ctx.measureText(iconCharacter);
|
const ts = ctx.measureText(iconCharacter);
|
||||||
ctx.fillText(iconCharacter, 182.9 - (ts.width / 2), 250);
|
ctx.fillText(iconCharacter, 182.9 - (ts.width / 2), 250);
|
||||||
ctx.strokeText(iconCharacter, 182.9 - (ts.width / 2), 250);
|
ctx.strokeText(iconCharacter, 182.9 - (ts.width / 2), 250);
|
||||||
}
|
}
|
||||||
|
@@ -9,19 +9,19 @@ export class TemporalService {
|
|||||||
constructor(private timespanService$:TimespanService,private datePipe$: DatePipe) {}
|
constructor(private timespanService$:TimespanService,private datePipe$: DatePipe) {}
|
||||||
|
|
||||||
hasNext(itemLayer:IItemLayer):boolean {
|
hasNext(itemLayer:IItemLayer):boolean {
|
||||||
let temporalItemLayer = itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = itemLayer as ITemporalItemLayer;
|
||||||
return temporalItemLayer && temporalItemLayer.nextItemLayer != null;
|
return temporalItemLayer && temporalItemLayer.nextItemLayer != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedDate(itemLayer:IItemLayer):string {
|
selectedDate(itemLayer:IItemLayer):string {
|
||||||
let temporalItemLayer = itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = itemLayer as ITemporalItemLayer;
|
||||||
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
|
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
|
||||||
if(temporalItemLayer && temporalItemLayer.selectedItemLayer.item.dataDate && temporalItemLayer.selectedItemLayer.item.dataEndDate) {
|
if(temporalItemLayer && temporalItemLayer.selectedItemLayer.item.dataDate && temporalItemLayer.selectedItemLayer.item.dataEndDate) {
|
||||||
let sd = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataDate));
|
const sd = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataDate));
|
||||||
let ed = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataEndDate));
|
const ed = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataEndDate));
|
||||||
return this.timespanService$.getCaption(sd,ed);
|
return this.timespanService$.getCaption(sd,ed);
|
||||||
} else {
|
} else {
|
||||||
let d = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataDate));
|
const d = new Date(Date.parse(temporalItemLayer.selectedItemLayer.item.dataDate));
|
||||||
return this.datePipe$.transform(d, "shortDate");
|
return this.datePipe$.transform(d, "shortDate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,14 +29,14 @@ export class TemporalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nextDate(itemLayer:IItemLayer):string {
|
nextDate(itemLayer:IItemLayer):string {
|
||||||
let temporalItemLayer = itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = itemLayer as ITemporalItemLayer;
|
||||||
if(temporalItemLayer && temporalItemLayer.nextItemLayer && temporalItemLayer.nextItemLayer.item) {
|
if(temporalItemLayer && temporalItemLayer.nextItemLayer && temporalItemLayer.nextItemLayer.item) {
|
||||||
if(temporalItemLayer.nextItemLayer.item.dataDate && temporalItemLayer.nextItemLayer.item.dataEndDate) {
|
if(temporalItemLayer.nextItemLayer.item.dataDate && temporalItemLayer.nextItemLayer.item.dataEndDate) {
|
||||||
let sd = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataDate));
|
const sd = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataDate));
|
||||||
let ed = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataEndDate));
|
const ed = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataEndDate));
|
||||||
return this.timespanService$.getCaption(sd,ed);
|
return this.timespanService$.getCaption(sd,ed);
|
||||||
} else {
|
} else {
|
||||||
let d = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataDate));
|
const d = new Date(Date.parse(temporalItemLayer.nextItemLayer.item.dataDate));
|
||||||
return this.datePipe$.transform(d, "shortDate");
|
return this.datePipe$.transform(d, "shortDate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,19 +44,19 @@ export class TemporalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasPrevious(itemLayer:IItemLayer):boolean {
|
hasPrevious(itemLayer:IItemLayer):boolean {
|
||||||
let temporalItemLayer = itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = itemLayer as ITemporalItemLayer;
|
||||||
return temporalItemLayer && temporalItemLayer.previousItemLayer != null;
|
return temporalItemLayer && temporalItemLayer.previousItemLayer != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
previousDate(itemLayer:IItemLayer):string {
|
previousDate(itemLayer:IItemLayer):string {
|
||||||
let temporalItemLayer = itemLayer as ITemporalItemLayer;
|
const temporalItemLayer = itemLayer as ITemporalItemLayer;
|
||||||
if(temporalItemLayer && temporalItemLayer.previousItemLayer && temporalItemLayer.previousItemLayer.item) {
|
if(temporalItemLayer && temporalItemLayer.previousItemLayer && temporalItemLayer.previousItemLayer.item) {
|
||||||
if(temporalItemLayer.previousItemLayer.item.dataDate && temporalItemLayer.previousItemLayer.item.dataEndDate) {
|
if(temporalItemLayer.previousItemLayer.item.dataDate && temporalItemLayer.previousItemLayer.item.dataEndDate) {
|
||||||
let sd = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataDate));
|
const sd = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataDate));
|
||||||
let ed = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataEndDate));
|
const ed = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataEndDate));
|
||||||
return this.timespanService$.getCaption(sd,ed);
|
return this.timespanService$.getCaption(sd,ed);
|
||||||
} else {
|
} else {
|
||||||
let d = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataDate));
|
const d = new Date(Date.parse(temporalItemLayer.previousItemLayer.item.dataDate));
|
||||||
return this.datePipe$.transform(d, "shortDate");
|
return this.datePipe$.transform(d, "shortDate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../tslint.json",
|
|
||||||
"rules": {
|
|
||||||
"directive-selector": [
|
|
||||||
true,
|
|
||||||
"attribute",
|
|
||||||
"fm-map",
|
|
||||||
"camelCase"
|
|
||||||
],
|
|
||||||
"component-selector": [
|
|
||||||
true,
|
|
||||||
"element",
|
|
||||||
"fm-map",
|
|
||||||
"kebab-case"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
22
projects/common-map3d/.eslintrc.js
Normal file
22
projects/common-map3d/.eslintrc.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
27
projects/common-map3d/package-lock.json
generated
Normal file
27
projects/common-map3d/package-lock.json
generated
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "@farmmaps/common-map3d",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "@farmmaps/common-map3d",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": ">=14.0.0",
|
||||||
|
"@angular/core": ">=14.0.0",
|
||||||
|
"cesium": ">=1.82.1",
|
||||||
|
"ngx-openlayers": "1.0.0-next.19",
|
||||||
|
"ol-cesium": ">=2.13.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tslib": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||||
|
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -15,10 +15,10 @@ import { Store } from '@ngrx/store';
|
|||||||
export class Switch2D3DComponent {
|
export class Switch2D3DComponent {
|
||||||
|
|
||||||
@Input() enable:boolean;
|
@Input() enable:boolean;
|
||||||
public label: string = "3D";
|
public label = "3D";
|
||||||
private ol3d: OLCesium;
|
private ol3d: OLCesium;
|
||||||
private synchronizers:any[];
|
private synchronizers:any[];
|
||||||
public loading:boolean = true;
|
public loading = true;
|
||||||
private interactions:Interaction[] = [];
|
private interactions:Interaction[] = [];
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../../tslint.json",
|
|
||||||
"rules": {
|
|
||||||
"directive-selector": [
|
|
||||||
true,
|
|
||||||
"attribute",
|
|
||||||
"lib",
|
|
||||||
"camelCase"
|
|
||||||
],
|
|
||||||
"component-selector": [
|
|
||||||
true,
|
|
||||||
"element",
|
|
||||||
"lib",
|
|
||||||
"kebab-case"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
22
projects/common/.eslintrc.js
Normal file
22
projects/common/.eslintrc.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
module.exports = {
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
}
|
||||||
|
}
|
30
projects/common/package-lock.json
generated
30
projects/common/package-lock.json
generated
@@ -8,22 +8,22 @@
|
|||||||
"name": "@farmmaps/common",
|
"name": "@farmmaps/common",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": "^14.0.0",
|
"@angular/common": ">=14.0.0",
|
||||||
"@angular/core": "^14.0.0",
|
"@angular/core": ">=14.0.0",
|
||||||
"@angular/forms": "^14",
|
"@angular/forms": ">=14.0.0",
|
||||||
"@microsoft/signalr": "^3.1.3",
|
"@microsoft/signalr": ">=3.1.3",
|
||||||
"@ng-bootstrap/ng-bootstrap": ">=10.0.0",
|
"@ng-bootstrap/ng-bootstrap": ">=10.0.0",
|
||||||
"@ngrx/effects": "^14.0.0",
|
"@ngrx/effects": ">=14.0.0",
|
||||||
"@ngrx/router-store": "^14.0.0",
|
"@ngrx/router-store": ">=14.0.0",
|
||||||
"@ngrx/store": "^14.0.0",
|
"@ngrx/store": ">=14.0.0",
|
||||||
"angular-oauth2-oidc": "^13",
|
"angular-oauth2-oidc": ">=13.0.0",
|
||||||
"bootstrap": "^4.4.1",
|
"bootstrap": ">=4.4.1",
|
||||||
"moment": "^2.27.0",
|
"moment": ">=2.27.0",
|
||||||
"ngx-avatar": "^4.1.0",
|
"ngx-avatar": ">=4.1.0",
|
||||||
"ngx-clipboard": "^14.0.1",
|
"ngx-clipboard": ">=14.0.1",
|
||||||
"ngx-image-cropper": "^3.3.5",
|
"ngx-image-cropper": ">=3.3.5",
|
||||||
"ngx-uploadx": "^5.2.0",
|
"ngx-uploadx": ">=5.1.0",
|
||||||
"tassign": "^1.0.0"
|
"tassign": ">=1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -126,7 +126,7 @@ export class InitUserSettingsRoot implements Action {
|
|||||||
export class InitUserSettingsRootSuccess implements Action {
|
export class InitUserSettingsRootSuccess implements Action {
|
||||||
readonly type = INITUSERSETTINGSROOTSUCCESS;
|
readonly type = INITUSERSETTINGSROOTSUCCESS;
|
||||||
|
|
||||||
constructor(public item: IItem ) { }
|
constructor(public item: IListItem ) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InitRoot implements Action {
|
export class InitRoot implements Action {
|
||||||
|
@@ -13,6 +13,7 @@ import { SchemaService } from './services/schema.service';
|
|||||||
import { FolderService } from './services/folder.service';
|
import { FolderService } from './services/folder.service';
|
||||||
import { TimespanService } from './services/timespan.service';
|
import { TimespanService } from './services/timespan.service';
|
||||||
import { ItemService } from './services/item.service';
|
import { ItemService } from './services/item.service';
|
||||||
|
import { AdminService } from './services/admin.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';
|
||||||
@@ -42,6 +43,7 @@ export {
|
|||||||
ItemTypeService,
|
ItemTypeService,
|
||||||
TimespanService,
|
TimespanService,
|
||||||
ItemService,
|
ItemService,
|
||||||
|
AdminService,
|
||||||
EventService,
|
EventService,
|
||||||
TypeaheadService,
|
TypeaheadService,
|
||||||
UserService,
|
UserService,
|
||||||
|
@@ -33,7 +33,8 @@ import { TagInputComponent } from './components/tag-input/tag-input.component';
|
|||||||
import { MenuBackgroundComponent } from './components/menu-background/menu-background.component';
|
import { MenuBackgroundComponent } from './components/menu-background/menu-background.component';
|
||||||
import { HasPackageDirective} from './components/has-package/has-package.directive';
|
import { HasPackageDirective} from './components/has-package/has-package.directive';
|
||||||
import { PackageExistsDirective} from './components/package-exists/package-exists.directive';
|
import { PackageExistsDirective} from './components/package-exists/package-exists.directive';
|
||||||
import { HasClaimDirective} from './components/has-claim/has-claim.directive';
|
import { HasClaimDirective } from './components/has-claim/has-claim.directive';
|
||||||
|
import { HasRoleDirective } from './components/has-role/has-role.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 { ThumbnailComponent } from './components/thumbnail/thumbnail.component';
|
||||||
import { Alert } from './enumerations/alert.enum';
|
import { Alert } from './enumerations/alert.enum';
|
||||||
@@ -41,6 +42,8 @@ import { IEventMessage } from './models/event.message';
|
|||||||
import { IItem, Item } from './models/item';
|
import { IItem, Item } from './models/item';
|
||||||
import { WeatherCurrentObservation } from './models/weatherCurrentObservation';
|
import { WeatherCurrentObservation } from './models/weatherCurrentObservation';
|
||||||
import { IItemType } from './models/item.type';
|
import { IItemType } from './models/item.type';
|
||||||
|
import { IItemLinkType} from './models/itemlink.type';
|
||||||
|
import {IUrlType} from './models/url.type';
|
||||||
import { IItemTypes } from './models/item.types';
|
import { IItemTypes } from './models/item.types';
|
||||||
import { IItemTask, ItemTask } from './models/itemTask';
|
import { IItemTask, ItemTask } from './models/itemTask';
|
||||||
import { IListItem } from './models/list.item';
|
import { IListItem } from './models/list.item';
|
||||||
@@ -64,6 +67,7 @@ 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 { EditImageModalComponent } from './components/edit-image-modal/edit-image-modal.component';
|
||||||
import { AvatarComponent } from './components/avatar/avatar.component';
|
import { AvatarComponent } from './components/avatar/avatar.component';
|
||||||
|
import { ItemLinkComponent } from './components/item-link/item-link.component';
|
||||||
import { AvatarModule } from 'ngx-avatar';
|
import { AvatarModule } from 'ngx-avatar';
|
||||||
import { ImageCropperModule } from 'ngx-image-cropper';
|
import { ImageCropperModule } from 'ngx-image-cropper';
|
||||||
|
|
||||||
@@ -85,11 +89,14 @@ export {
|
|||||||
HasPackageDirective,
|
HasPackageDirective,
|
||||||
PackageExistsDirective,
|
PackageExistsDirective,
|
||||||
HasClaimDirective,
|
HasClaimDirective,
|
||||||
|
HasRoleDirective,
|
||||||
Alert,
|
Alert,
|
||||||
IEventMessage,
|
IEventMessage,
|
||||||
IItem,
|
IItem,
|
||||||
Item,
|
Item,
|
||||||
IItemType,
|
IItemType,
|
||||||
|
IItemLinkType,
|
||||||
|
IUrlType,
|
||||||
IItemTypes,
|
IItemTypes,
|
||||||
IItemTask,
|
IItemTask,
|
||||||
ItemTask,
|
ItemTask,
|
||||||
@@ -113,6 +120,7 @@ export {
|
|||||||
IGradientstop,
|
IGradientstop,
|
||||||
BackButtonComponent,
|
BackButtonComponent,
|
||||||
AvatarComponent,
|
AvatarComponent,
|
||||||
|
ItemLinkComponent,
|
||||||
EditImageModalComponent,
|
EditImageModalComponent,
|
||||||
GradientComponent,
|
GradientComponent,
|
||||||
GradientSelectComponent
|
GradientSelectComponent
|
||||||
@@ -148,6 +156,7 @@ export {
|
|||||||
HasPackageDirective,
|
HasPackageDirective,
|
||||||
PackageExistsDirective,
|
PackageExistsDirective,
|
||||||
HasClaimDirective,
|
HasClaimDirective,
|
||||||
|
HasRoleDirective,
|
||||||
UserMenuComponent,
|
UserMenuComponent,
|
||||||
GradientComponent,
|
GradientComponent,
|
||||||
GradientSelectComponent,
|
GradientSelectComponent,
|
||||||
@@ -157,7 +166,8 @@ export {
|
|||||||
BackButtonComponent,
|
BackButtonComponent,
|
||||||
ThumbnailComponent,
|
ThumbnailComponent,
|
||||||
EditImageModalComponent,
|
EditImageModalComponent,
|
||||||
AvatarComponent
|
AvatarComponent,
|
||||||
|
ItemLinkComponent
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
NgbModule,
|
NgbModule,
|
||||||
@@ -179,12 +189,14 @@ export {
|
|||||||
HasPackageDirective,
|
HasPackageDirective,
|
||||||
PackageExistsDirective,
|
PackageExistsDirective,
|
||||||
HasClaimDirective,
|
HasClaimDirective,
|
||||||
|
HasRoleDirective,
|
||||||
UserMenuComponent,
|
UserMenuComponent,
|
||||||
GradientComponent,
|
GradientComponent,
|
||||||
GradientSelectComponent,
|
GradientSelectComponent,
|
||||||
BackButtonComponent,
|
BackButtonComponent,
|
||||||
ThumbnailComponent,
|
ThumbnailComponent,
|
||||||
AvatarComponent,
|
AvatarComponent,
|
||||||
|
ItemLinkComponent,
|
||||||
EditImageModalComponent
|
EditImageModalComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@@ -14,7 +14,7 @@ export class AppMenuComponent implements OnInit {
|
|||||||
|
|
||||||
@Input() user:IUser;
|
@Input() user:IUser;
|
||||||
@Input() showMenu:boolean;
|
@Input() showMenu:boolean;
|
||||||
public noContent: boolean = true;
|
public noContent = true;
|
||||||
|
|
||||||
constructor(private store: Store<appReducers.State>) { }
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, OnDestroy, Inject, Optional,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,7 +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';
|
import { FM_COMMON_STARTPAGE } from '../../common.module';
|
||||||
|
|
||||||
//AppCommon
|
//AppCommon
|
||||||
import { IEventMessage } from '../../models/event.message';
|
import { IEventMessage } from '../../models/event.message';
|
||||||
@@ -29,9 +29,9 @@ import * as appReducers from '../../reducers/app-common.reducer';
|
|||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
// This will go at the END of your title for example "Home - Angular Universal..." <-- after the dash (-)
|
// This will go at the END of your title for example "Home - Angular Universal..." <-- after the dash (-)
|
||||||
private endPageTitle: string = 'Farmmaps';
|
private endPageTitle = 'Farmmaps';
|
||||||
// If no Title is provided, we'll use a default one before the dash(-)
|
// If no Title is provided, we'll use a default one before the dash(-)
|
||||||
private defaultPageTitle: string = 'Farmmaps';
|
private defaultPageTitle = 'Farmmaps';
|
||||||
|
|
||||||
private routerSub$: Subscription;
|
private routerSub$: Subscription;
|
||||||
private eventSub$: Subscription;
|
private eventSub$: Subscription;
|
||||||
@@ -48,8 +48,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
public helpMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetHelpMenuVisible);
|
public helpMenuVisible: Observable<boolean> = this.store$.select(appReducers.SelectGetHelpMenuVisible);
|
||||||
public unreadNotifications: Observable<number> = this.store$.select(appReducers.SelectgetUnreadNotifications);
|
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 = true;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() @Inject(FM_COMMON_STARTPAGE) public startPage: string,
|
@Optional() @Inject(FM_COMMON_STARTPAGE) public startPage: string,
|
||||||
@@ -68,8 +68,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
|
|
||||||
getActionFromEvent(event: IEventMessage): Action {
|
getActionFromEvent(event: IEventMessage): Action {
|
||||||
var action: Action = null;
|
let action: Action = null;
|
||||||
console.debug(`${event.eventType} Event received`);
|
//console.debug(`${event.eventType} Event received`);
|
||||||
switch (event.eventType) {
|
switch (event.eventType) {
|
||||||
case "ItemChanged": {
|
case "ItemChanged": {
|
||||||
action = new commonActions.ItemChangedEvent(event.itemCode, event.attributes);
|
action = new commonActions.ItemChangedEvent(event.itemCode, event.attributes);
|
||||||
@@ -106,32 +106,25 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
case "notification": {
|
case "notification": {
|
||||||
action = new commonActions.NotificationEvent(event.attributes);
|
action = new commonActions.NotificationEvent(event.attributes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DeleteUser": {
|
case "DeleteUser": {
|
||||||
action = new commonActions.Logout();
|
action = new commonActions.Logout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadItemTypes() {
|
|
||||||
await this.itemTypeService$.load(this.appConfig$)
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.InstallRouteEventHandler();
|
this.InstallRouteEventHandler();
|
||||||
this.InstallEventServiceEventHandler();
|
this.InstallEventServiceEventHandler();
|
||||||
this.InstallAuthenticationEventHandler();
|
this.InstallAuthenticationEventHandler();
|
||||||
this.InstallHealthCheck();
|
this.InstallHealthCheck();
|
||||||
|
|
||||||
//load item types
|
|
||||||
this.loadItemTypes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('document:keyup', ['$event'])
|
@HostListener('document:keyup', ['$event'])
|
||||||
onKeyUp(event: KeyboardEvent) {
|
onKeyUp(event: KeyboardEvent) {
|
||||||
let x = event.keyCode;
|
const x = event.keyCode;
|
||||||
if (x === 27) {
|
if (x === 27) {
|
||||||
this.store$.dispatch(new commonActions.Escape(true, false));
|
this.store$.dispatch(new commonActions.Escape(true, false));
|
||||||
}
|
}
|
||||||
@@ -146,35 +139,36 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
private InstallAuthenticationEventHandler() {
|
private InstallAuthenticationEventHandler() {
|
||||||
// auth event handler
|
// auth event handler
|
||||||
this.oauthService$.events.subscribe((event) => {
|
this.oauthService$.events.subscribe((event) => {
|
||||||
console.debug(event.type);
|
//console.debug(event.type);
|
||||||
if (event.type == 'token_error' || event.type == 'silent_refresh_timeout' || event.type == 'logout') {
|
if (event.type == 'token_error' || event.type == 'silent_refresh_timeout' || event.type == 'logout') {
|
||||||
let e = event as OAuthErrorEvent;
|
const e = event as OAuthErrorEvent;
|
||||||
let p = e.params as any;
|
const p = e.params as any;
|
||||||
if (event.type == 'silent_refresh_timeout' || event.type == 'logout' || (p.error && p.error == 'login_required')) {
|
if (event.type == 'silent_refresh_timeout' || event.type == 'logout' || (p.error && p.error == 'login_required')) {
|
||||||
console.debug("Session expired");
|
//console.debug("Session expired");
|
||||||
this.router.navigate(['loggedout'], { queryParams: { redirectTo: this.router.url } });
|
this.router.navigate(['loggedout'], { queryParams: { redirectTo: this.router.url } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(event.type == 'token_received') {
|
if (event.type == 'token_received') {
|
||||||
|
this.oauthService$.loadUserProfile();
|
||||||
this.store$.dispatch(new commonActions.InitUser());
|
this.store$.dispatch(new commonActions.InitUser());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(this.oauthService$.hasValidAccessToken()) {
|
if (this.oauthService$.hasValidAccessToken()) {
|
||||||
this.store$.dispatch(new commonActions.InitUser());
|
this.store$.dispatch(new commonActions.InitUser());
|
||||||
} else {
|
} else {
|
||||||
if(this.oauthService$.getRefreshToken() !=null) {
|
if (this.oauthService$.getRefreshToken() != null) {
|
||||||
this.oauthService$.refreshToken();
|
this.oauthService$.refreshToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InstallRouteEventHandler() {
|
private InstallRouteEventHandler() {
|
||||||
var other = this;
|
const other = this;
|
||||||
this.routerSub$ = this.router.events.subscribe(event => {
|
this.routerSub$ = this.router.events.subscribe(event => {
|
||||||
if (event instanceof RouteConfigLoadStart) {
|
if (event instanceof RouteConfigLoadStart) {
|
||||||
other.store$.dispatch(new commonActions.StartRouteLoading());
|
other.store$.dispatch(new commonActions.StartRouteLoading());
|
||||||
}
|
}
|
||||||
if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content") )) {
|
if (event instanceof NavigationEnd && (event.url == "/" || event.url.startsWith("/content"))) {
|
||||||
other.store$.dispatch(new commonActions.SetPageMode(true));
|
other.store$.dispatch(new commonActions.SetPageMode(true));
|
||||||
} else if (event instanceof NavigationEnd) {
|
} else if (event instanceof NavigationEnd) {
|
||||||
other.store$.dispatch(new commonActions.SetPageMode(false));
|
other.store$.dispatch(new commonActions.SetPageMode(false));
|
||||||
@@ -189,16 +183,16 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private InstallEventServiceEventHandler() {
|
private InstallEventServiceEventHandler() {
|
||||||
var other = this;
|
const other = this;
|
||||||
this.eventSub$ = this.eventService$.event.subscribe(event => {
|
this.eventSub$ = this.eventService$.event.subscribe(event => {
|
||||||
var action = other.getActionFromEvent(event);
|
const action = other.getActionFromEvent(event);
|
||||||
if (action) other.store$.dispatch(action);
|
if (action) other.store$.dispatch(action);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private InstallHealthCheck() {
|
private InstallHealthCheck() {
|
||||||
//check health every 30 seconds
|
//check health every 30 seconds
|
||||||
this.healthCheckService$.check(30000).pipe(distinctUntilChanged()).subscribe((online) => {
|
this.healthCheckService$.check(30000).pipe(distinctUntilChanged()).subscribe((online) => {
|
||||||
if (online) {
|
if (online) {
|
||||||
this.store$.dispatch(new commonActions.Online());
|
this.store$.dispatch(new commonActions.Online());
|
||||||
} else {
|
} else {
|
||||||
|
@@ -12,8 +12,8 @@ export class AvatarComponent implements OnInit {
|
|||||||
@Input() user: IUser;
|
@Input() user: IUser;
|
||||||
@Input() bgColor: string;
|
@Input() bgColor: string;
|
||||||
@Input() fgColor: string;
|
@Input() fgColor: string;
|
||||||
@Input() size: number = 75;
|
@Input() size = 75;
|
||||||
@Input() round: boolean = true;
|
@Input() round = true;
|
||||||
|
|
||||||
@Output() click = new EventEmitter();
|
@Output() click = new EventEmitter();
|
||||||
|
|
||||||
|
@@ -16,16 +16,16 @@ export class EditImageModalComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private modalService: NgbModal,public imageService:ImageService) { }
|
constructor(private modalService: NgbModal,public imageService:ImageService) { }
|
||||||
|
|
||||||
isImageLoaded:boolean = false;
|
isImageLoaded = false;
|
||||||
aspectRatio:number = 4/3;
|
aspectRatio:number = 4/3;
|
||||||
imageChangedEvent: any = '';
|
imageChangedEvent: any = '';
|
||||||
croppedImage: string = '';
|
croppedImage = '';
|
||||||
endpointUrl:string = null;
|
endpointUrl:string = null;
|
||||||
imageUrl:string = null;
|
imageUrl:string = null;
|
||||||
maxWidth:number = 200;
|
maxWidth = 200;
|
||||||
roundImage:boolean = false;
|
roundImage = false;
|
||||||
imageType:string = "jpeg";
|
imageType = "jpeg";
|
||||||
saveImage:boolean = true;
|
saveImage = true;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ export class EditImageModalComponent implements OnInit {
|
|||||||
|
|
||||||
save() {
|
save() {
|
||||||
if(this.croppedImage) {
|
if(this.croppedImage) {
|
||||||
var blob = this.imageService.dataUrltoBlob(this.croppedImage);
|
const blob = this.imageService.dataUrltoBlob(this.croppedImage);
|
||||||
if(this.saveImage) {
|
if(this.saveImage) {
|
||||||
this.imageService.putImage(this.endpointUrl,blob).subscribe(() => {
|
this.imageService.putImage(this.endpointUrl,blob).subscribe(() => {
|
||||||
this.changed.emit({});
|
this.changed.emit({});
|
||||||
|
@@ -8,10 +8,10 @@ import { IItem } from '../../models/item';
|
|||||||
})
|
})
|
||||||
export class GradientSelectComponent implements OnChanges {
|
export class GradientSelectComponent implements OnChanges {
|
||||||
|
|
||||||
public listVisible:boolean = false;
|
public listVisible = false;
|
||||||
@Input() showLabel:boolean = true;
|
@Input() showLabel = true;
|
||||||
@Input() gradientItems:IItem[];
|
@Input() gradientItems:IItem[];
|
||||||
@Input() showAdd:boolean = false;
|
@Input() showAdd = false;
|
||||||
@Input() selectedItem:IItem;
|
@Input() selectedItem:IItem;
|
||||||
@Output() onSelect:EventEmitter<any> = new EventEmitter<any>();
|
@Output() onSelect:EventEmitter<any> = new EventEmitter<any>();
|
||||||
@Output() onAdd:EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
|
@Output() onAdd:EventEmitter<MouseEvent> = new EventEmitter<MouseEvent>();
|
||||||
@@ -44,8 +44,8 @@ export class GradientSelectComponent implements OnChanges {
|
|||||||
|
|
||||||
isSelected(item:IItem):boolean {
|
isSelected(item:IItem):boolean {
|
||||||
if(this.selectedItem && this.selectedItem.data && this.selectedItem.data.gradient && item && item.data && item.data.gradient) {
|
if(this.selectedItem && this.selectedItem.data && this.selectedItem.data.gradient && item && item.data && item.data.gradient) {
|
||||||
let sid = JSON.stringify(this.selectedItem.data.gradient)+this.selectedItem.name;
|
const sid = JSON.stringify(this.selectedItem.data.gradient)+this.selectedItem.name;
|
||||||
let id = JSON.stringify( item.data.gradient) + item.name;
|
const id = JSON.stringify( item.data.gradient) + item.name;
|
||||||
return sid == id;
|
return sid == id;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -19,7 +19,7 @@ export class GradientComponent implements OnInit,OnChanges {
|
|||||||
|
|
||||||
getGradientStyle(item:IItem):any {
|
getGradientStyle(item:IItem):any {
|
||||||
if(item.data && item.data.gradient) {
|
if(item.data && item.data.gradient) {
|
||||||
let gradient = item.data.gradient as IGradientstop[];
|
const gradient = item.data.gradient as IGradientstop[];
|
||||||
return this.gradientService.getGradientStyle(gradient);
|
return this.gradientService.getGradientStyle(gradient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ export class GradientComponent implements OnInit,OnChanges {
|
|||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if(changes['gradientItem']) {
|
if(changes['gradientItem']) {
|
||||||
let gradientItem = changes['gradientItem'].currentValue;
|
const gradientItem = changes['gradientItem'].currentValue;
|
||||||
if(gradientItem && gradientItem.itemType == "vnd.farmmaps.itemtype.gradient") {
|
if(gradientItem && gradientItem.itemType == "vnd.farmmaps.itemtype.gradient") {
|
||||||
this.gradientStyle = this.getGradientStyle(changes['gradientItem'].currentValue);
|
this.gradientStyle = this.getGradientStyle(changes['gradientItem'].currentValue);
|
||||||
this.ref.markForCheck();
|
this.ref.markForCheck();
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input, OnDestroy } from '@angular/core';
|
||||||
|
import { Store} from '@ngrx/store';
|
||||||
|
import * as appCommonReducer from '../../reducers/app-common.reducer'
|
||||||
|
import { Observable, Subscription } from 'rxjs';
|
||||||
|
import { IUser } from '../../models/user';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[fmHasRole]',
|
||||||
|
})
|
||||||
|
export class HasRoleDirective implements OnInit, OnDestroy{
|
||||||
|
@Input('fmHasRole') role:string;
|
||||||
|
|
||||||
|
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private store$: Store<appCommonReducer.State>) { }
|
||||||
|
private user$:Observable<IUser> = this.store$.select(appCommonReducer.SelectGetUser);
|
||||||
|
private hasView = false;
|
||||||
|
private roleClaim = 'role';
|
||||||
|
private sub: Subscription;
|
||||||
|
ngOnInit() {
|
||||||
|
this.sub = this.user$.subscribe((user) => {
|
||||||
|
if (user && user.claims[this.roleClaim]?.includes(this.role)) {
|
||||||
|
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
||||||
|
this.hasView=true;
|
||||||
|
} else if (this.hasView) {
|
||||||
|
this.viewContainerRef$.clear();
|
||||||
|
this.hasView = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ngOnDestroy() {
|
||||||
|
if (this.sub) {this.sub.unsubscribe() }
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,7 @@ export class HelpMenuComponent implements OnInit {
|
|||||||
|
|
||||||
@Input() user:IUser;
|
@Input() user:IUser;
|
||||||
@Input() showMenu:boolean;
|
@Input() showMenu:boolean;
|
||||||
public noContent: boolean = true;
|
public noContent = true;
|
||||||
|
|
||||||
constructor(private store: Store<appReducers.State>) { }
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
<span class="item-link" (click)="copylink(copiedtt)" triggers="manual" ngbTooltip="Link copied" #copiedtt="ngbTooltip" ><i ngbTooltip='Copy link' class="fa-solid fa-link"></i> <span *ngIf="showText" i18n>Copy link</span></span>
|
@@ -0,0 +1,44 @@
|
|||||||
|
import { Component, Input, OnDestroy} from '@angular/core';
|
||||||
|
import { IItemLinkType} from '../../models/itemlink.type'
|
||||||
|
import { IUrlType } from '../../models/url.type';
|
||||||
|
import { ItemService } from '../../common-service.module';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
import { ClipboardService } from 'ngx-clipboard'
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'fm-item-link',
|
||||||
|
templateUrl: './item-link.component.html'
|
||||||
|
})
|
||||||
|
export class ItemLinkComponent implements OnDestroy {
|
||||||
|
|
||||||
|
@Input() itemCode:string;
|
||||||
|
@Input() pathSuffix:string;
|
||||||
|
@Input() query:string;
|
||||||
|
@Input() validMinutes:number;
|
||||||
|
@Input() showText:boolean;
|
||||||
|
|
||||||
|
private sub : Subscription = null;
|
||||||
|
|
||||||
|
constructor(private itemService:ItemService,private clipboardService$: ClipboardService) { }
|
||||||
|
|
||||||
|
copylink(tooltip) {
|
||||||
|
if(this.sub) {
|
||||||
|
this.sub.unsubscribe();
|
||||||
|
}
|
||||||
|
let link: IItemLinkType = {itemcode:this.itemCode,pathsuffix:this.pathSuffix,query:this.query,validminutes:this.validMinutes}
|
||||||
|
this.sub = this.itemService.getItemLink(link).subscribe((url:IUrlType) => {
|
||||||
|
this.clipboardService$.copy(url.url);
|
||||||
|
tooltip.open();
|
||||||
|
setTimeout(() => {
|
||||||
|
tooltip.close();
|
||||||
|
}, 2000);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if(this.sub) {
|
||||||
|
this.sub.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,7 @@ import * as commonActions from '../../actions/app-common.actions';
|
|||||||
styleUrls: ['./menu-background.component.scss'],
|
styleUrls: ['./menu-background.component.scss'],
|
||||||
})
|
})
|
||||||
export class MenuBackgroundComponent implements OnInit {
|
export class MenuBackgroundComponent implements OnInit {
|
||||||
@Input() visible:boolean = false;
|
@Input() visible = false;
|
||||||
constructor(private store: Store<appReducers.State>) { }
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
@@ -15,7 +15,7 @@ export class NotificationMenuComponent implements OnInit {
|
|||||||
@Input() unread:number;
|
@Input() unread:number;
|
||||||
@Input() user:IUser;
|
@Input() user:IUser;
|
||||||
@Input() showMenu:boolean;
|
@Input() showMenu:boolean;
|
||||||
public noContent: boolean = true;
|
public noContent = true;
|
||||||
|
|
||||||
constructor(private store: Store<appReducers.State>) { }
|
constructor(private store: Store<appReducers.State>) { }
|
||||||
|
|
||||||
|
@@ -40,9 +40,9 @@ export class ResumableFileUploadService implements OnDestroy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatetotalprogress() {
|
updatetotalprogress() {
|
||||||
var totalProgress =0;
|
let totalProgress =0;
|
||||||
var n=0;
|
let n=0;
|
||||||
for(var i =0;i<this.files.length;i++) {
|
for(let i =0;i<this.files.length;i++) {
|
||||||
if(!this.files[i].error) {
|
if(!this.files[i].error) {
|
||||||
totalProgress+=this.files[i].progress;
|
totalProgress+=this.files[i].progress;
|
||||||
n++;
|
n++;
|
||||||
@@ -53,9 +53,9 @@ export class ResumableFileUploadService implements OnDestroy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleState(state:UploadState) {
|
handleState(state:UploadState) {
|
||||||
var file =this.files.find((f) => f.identifier == state.uploadId )
|
const file =this.files.find((f) => f.identifier == state.uploadId )
|
||||||
if(state.status != "cancelled" && !file) {
|
if(state.status != "cancelled" && !file) {
|
||||||
let file = new File(state);
|
const file = new File(state);
|
||||||
this.files.push(file);
|
this.files.push(file);
|
||||||
this.isClosed=false;
|
this.isClosed=false;
|
||||||
this.addedFiles.next(file)
|
this.addedFiles.next(file)
|
||||||
@@ -66,29 +66,29 @@ export class ResumableFileUploadService implements OnDestroy{
|
|||||||
this.isUploading = true;
|
this.isUploading = true;
|
||||||
file.progress = (state.progress?state.progress:0);
|
file.progress = (state.progress?state.progress:0);
|
||||||
}
|
}
|
||||||
};break;
|
}break;
|
||||||
case "complete": {
|
case "complete": {
|
||||||
if(file) {
|
if(file) {
|
||||||
var parts = state.url.split("/");
|
const parts = state.url.split("/");
|
||||||
file.itemCode = parts[parts.length-1];
|
file.itemCode = parts[parts.length-1];
|
||||||
file.progress = (state.progress?state.progress:0);
|
file.progress = (state.progress?state.progress:0);
|
||||||
file.success=true;
|
file.success=true;
|
||||||
}
|
}
|
||||||
};break;
|
}break;
|
||||||
case "error": {
|
case "error": {
|
||||||
if(file) {
|
if(file) {
|
||||||
file.error=true;
|
file.error=true;
|
||||||
file.errorMessage = state.response as string;
|
file.errorMessage = state.response as string;
|
||||||
}
|
}
|
||||||
};break;
|
}break;
|
||||||
}
|
}
|
||||||
this.updatetotalprogress();
|
this.updatetotalprogress();
|
||||||
this.refresh.next({});
|
this.refresh.next({});
|
||||||
}
|
}
|
||||||
|
|
||||||
addFiles = (files: any[], event: any, metadata:any) => {
|
addFiles = (files: any[], event: any, metadata:any) => {
|
||||||
for (let f of files) {
|
for (const f of files) {
|
||||||
var options:UploadxOptions = {metadata:metadata};
|
const options:UploadxOptions = {metadata:metadata};
|
||||||
this.uploadService.handleFiles(f,options);
|
this.uploadService.handleFiles(f,options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export class ResumableFileUploadService implements OnDestroy{
|
|||||||
|
|
||||||
cancelFile = function (file) {
|
cancelFile = function (file) {
|
||||||
this.uploadService.control({action:'cancel',uploadId:file.identifier});
|
this.uploadService.control({action:'cancel',uploadId:file.identifier});
|
||||||
var index = this.files.indexOf(file, 0);
|
const index = this.files.indexOf(file, 0);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.files.splice(index, 1);
|
this.files.splice(index, 1);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ export class ResumableFileUploadService implements OnDestroy{
|
|||||||
};
|
};
|
||||||
|
|
||||||
doClose = function () {
|
doClose = function () {
|
||||||
var toCancel = this.files.filter((f) => !f.success);
|
const toCancel = this.files.filter((f) => !f.success);
|
||||||
toCancel.forEach(f => {
|
toCancel.forEach(f => {
|
||||||
this.uploadService.control({action:'cancel',uploadId:f.identifier});
|
this.uploadService.control({action:'cancel',uploadId:f.identifier});
|
||||||
});
|
});
|
||||||
|
@@ -11,15 +11,15 @@ export class SidePanelComponent implements OnChanges {
|
|||||||
@Input() public visible: boolean;
|
@Input() public visible: boolean;
|
||||||
@Input() public collapsed: boolean;
|
@Input() public collapsed: boolean;
|
||||||
@Input() public collapsable: boolean;
|
@Input() public collapsable: boolean;
|
||||||
@Input() public resizeable: boolean = false;
|
@Input() public resizeable = false;
|
||||||
@Input() public left: boolean = false;
|
@Input() public left = false;
|
||||||
@Output() onResize: EventEmitter<number> = new EventEmitter<number>();
|
@Output() onResize: EventEmitter<number> = new EventEmitter<number>();
|
||||||
@ViewChild("resizeGrip") elementView: ElementRef;
|
@ViewChild("resizeGrip") elementView: ElementRef;
|
||||||
public mobile:boolean = true;
|
public mobile = true;
|
||||||
private parentHeight:number = 0;
|
private parentHeight = 0;
|
||||||
public top = "100%";
|
public top = "100%";
|
||||||
private resizeTop:number=50;
|
private resizeTop=50;
|
||||||
public resizing:boolean=false;
|
public resizing=false;
|
||||||
|
|
||||||
constructor(private element: ElementRef,private ref: ChangeDetectorRef) {
|
constructor(private element: ElementRef,private ref: ChangeDetectorRef) {
|
||||||
this.collapsable = false;
|
this.collapsable = false;
|
||||||
@@ -27,9 +27,9 @@ export class SidePanelComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkMobile():boolean {
|
checkMobile():boolean {
|
||||||
let size = parseFloat(getComputedStyle(document.documentElement).width);
|
const size = parseFloat(getComputedStyle(document.documentElement).width);
|
||||||
let rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
||||||
let threshold = 40 * rem;
|
const threshold = 40 * rem;
|
||||||
return !(size>threshold);
|
return !(size>threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ export class SidePanelComponent implements OnChanges {
|
|||||||
handleStartGripDrag(event:DragEvent|TouchEvent) {
|
handleStartGripDrag(event:DragEvent|TouchEvent) {
|
||||||
this.resizing=true;
|
this.resizing=true;
|
||||||
if(event instanceof DragEvent) {
|
if(event instanceof DragEvent) {
|
||||||
var crt = new Image();
|
const crt = new Image();
|
||||||
crt.style.display = "none";
|
crt.style.display = "none";
|
||||||
document.body.appendChild(crt);
|
document.body.appendChild(crt);
|
||||||
event.dataTransfer.setDragImage(crt,0,0);
|
event.dataTransfer.setDragImage(crt,0,0);
|
||||||
@@ -66,7 +66,7 @@ export class SidePanelComponent implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleGripDrag(event:DragEvent|TouchEvent) {
|
handleGripDrag(event:DragEvent|TouchEvent) {
|
||||||
var clientY = 0;
|
let clientY = 0;
|
||||||
if((event instanceof TouchEvent)) {
|
if((event instanceof TouchEvent)) {
|
||||||
clientY = (event as TouchEvent).changedTouches[0].clientY;
|
clientY = (event as TouchEvent).changedTouches[0].clientY;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -16,8 +16,8 @@ import { AppConfig } from "../../shared/app.config";
|
|||||||
|
|
||||||
export class ThumbnailComponent {
|
export class ThumbnailComponent {
|
||||||
@Input() public item: IListItem;
|
@Input() public item: IListItem;
|
||||||
@Input() public edit: boolean = false;
|
@Input() public edit = false;
|
||||||
@Input() public save: boolean = true;
|
@Input() public save = true;
|
||||||
@Output() changed = new EventEmitter();
|
@Output() changed = new EventEmitter();
|
||||||
@ViewChild('thumbnail') el:ElementRef;
|
@ViewChild('thumbnail') el:ElementRef;
|
||||||
@ViewChild('modal') modal:EditImageModalComponent;
|
@ViewChild('modal') modal:EditImageModalComponent;
|
||||||
@@ -40,7 +40,7 @@ import { AppConfig } from "../../shared/app.config";
|
|||||||
|
|
||||||
getFontSize():string {
|
getFontSize():string {
|
||||||
if(this.el) {
|
if(this.el) {
|
||||||
var h = this.el.nativeElement.offsetHeight - (this.el.nativeElement.offsetHeight / 5 )
|
const h = this.el.nativeElement.offsetHeight - (this.el.nativeElement.offsetHeight / 5 )
|
||||||
return h + "px";
|
return h + "px";
|
||||||
} else {
|
} else {
|
||||||
return "1em";
|
return "1em";
|
||||||
|
@@ -18,55 +18,55 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
unitScales:number[] = [1,1000,1000*60,1000*60*60,1000*60*60*24,1000*60*60*24*7,1000*60*60*24*31,1000*60*60*24*31*3,1000*60*60*24*365.25];
|
unitScales:number[] = [1,1000,1000*60,1000*60*60,1000*60*60*24,1000*60*60*24*7,1000*60*60*24*31,1000*60*60*24*31*3,1000*60*60*24*365.25];
|
||||||
units:string[] = [ 'millisecond','second','minute','hour','day','week','month','quarter','year'];
|
units:string[] = [ 'millisecond','second','minute','hour','day','week','month','quarter','year'];
|
||||||
quarters:string[] = ['KW1','KW2','KW3','KW4'];
|
quarters:string[] = ['KW1','KW2','KW3','KW4'];
|
||||||
unitScale:number = 3;
|
unitScale = 3;
|
||||||
viewMinDate:Date;
|
viewMinDate:Date;
|
||||||
viewMaxDate:Date;
|
viewMaxDate:Date;
|
||||||
extentMinDate:Date;
|
extentMinDate:Date;
|
||||||
extentMaxDate:Date;
|
extentMaxDate:Date;
|
||||||
cursorDate:Date;
|
cursorDate:Date;
|
||||||
leftGripMove:boolean = false;
|
leftGripMove = false;
|
||||||
rightGripMove:boolean = false;
|
rightGripMove = false;
|
||||||
rangeGripMove:boolean = false;
|
rangeGripMove = false;
|
||||||
viewPan:boolean = false;
|
viewPan = false;
|
||||||
downX:number = -1;
|
downX = -1;
|
||||||
mouseX: number = -1;
|
mouseX = -1;
|
||||||
mouseY: number = -1;
|
mouseY = -1;
|
||||||
elementWidth:number;
|
elementWidth:number;
|
||||||
elementHeight:number;
|
elementHeight:number;
|
||||||
lastOffsetInPixels:number=0;
|
lastOffsetInPixels=0;
|
||||||
@ViewChild('timeLine', { static: true }) canvasRef;
|
@ViewChild('timeLine', { static: true }) canvasRef;
|
||||||
@ViewChild('popoverStart', { static: true }) public popoverStart:NgbPopover;
|
@ViewChild('popoverStart', { static: true }) public popoverStart:NgbPopover;
|
||||||
@ViewChild('popoverEnd', { static: true }) public popoverEnd:NgbPopover;
|
@ViewChild('popoverEnd', { static: true }) public popoverEnd:NgbPopover;
|
||||||
@Input() collapsed: boolean = true;
|
@Input() collapsed = true;
|
||||||
@Input() startDate: Date = new Date(2018,1,3);
|
@Input() startDate: Date = new Date(2018,1,3);
|
||||||
@Input() endDate: Date = new Date(2018,1,5);
|
@Input() endDate: Date = new Date(2018,1,5);
|
||||||
@Input() unit:string;
|
@Input() unit:string;
|
||||||
@Input() color:string = '#000000';
|
@Input() color = '#000000';
|
||||||
@Input() background:string = '#ffffff';
|
@Input() background = '#ffffff';
|
||||||
@Input() hoverColor:string ='#ffffff';
|
@Input() hoverColor ='#ffffff';
|
||||||
@Input() hoverBackground:string ='#0000ff';
|
@Input() hoverBackground ='#0000ff';
|
||||||
@Input() lineColor:string='#000000';
|
@Input() lineColor='#000000';
|
||||||
@Input() lineWidth:number=1;
|
@Input() lineWidth=1;
|
||||||
@Input() padding:number = 4;
|
@Input() padding = 4;
|
||||||
@Output() change:EventEmitter<TimeSpan> = new EventEmitter();
|
@Output() change:EventEmitter<TimeSpan> = new EventEmitter();
|
||||||
public caption:string = "2016/2017";
|
public caption = "2016/2017";
|
||||||
public marginLeft:number = 100;
|
public marginLeft = 100;
|
||||||
public startPopoverLeft:number=110;
|
public startPopoverLeft=110;
|
||||||
public endPopoverLeft:number=120;
|
public endPopoverLeft=120;
|
||||||
public rangeWidth:number =75;
|
public rangeWidth =75;
|
||||||
public startCaption={};
|
public startCaption={};
|
||||||
public endCaption={};
|
public endCaption={};
|
||||||
private ratio:number=1;
|
private ratio=1;
|
||||||
private initialized:boolean=false;
|
private initialized=false;
|
||||||
private ctx:CanvasRenderingContext2D;
|
private ctx:CanvasRenderingContext2D;
|
||||||
public posibleUnits:number[] = [];
|
public posibleUnits:number[] = [];
|
||||||
public height:number = 0;
|
public height = 0;
|
||||||
public lineHeight:number = 0;
|
public lineHeight = 0;
|
||||||
|
|
||||||
constructor(private changeDetectorRef: ChangeDetectorRef,private datePipe: DatePipe) { }
|
constructor(private changeDetectorRef: ChangeDetectorRef,private datePipe: DatePipe) { }
|
||||||
|
|
||||||
setCanvasSize() {
|
setCanvasSize() {
|
||||||
let canvas = this.canvasRef.nativeElement;
|
const canvas = this.canvasRef.nativeElement;
|
||||||
this.elementWidth = canvas.offsetWidth;
|
this.elementWidth = canvas.offsetWidth;
|
||||||
this.elementHeight = canvas.offsetHeight;
|
this.elementHeight = canvas.offsetHeight;
|
||||||
canvas.height = this.elementHeight * this.ratio;
|
canvas.height = this.elementHeight * this.ratio;
|
||||||
@@ -74,8 +74,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPosibleUnits(scale:number):number[] {
|
getPosibleUnits(scale:number):number[] {
|
||||||
let posibleUnits = [];
|
const posibleUnits = [];
|
||||||
for(let u of [3,4,6,8]) {
|
for(const u of [3,4,6,8]) {
|
||||||
if((this.unitScale <=u) )
|
if((this.unitScale <=u) )
|
||||||
posibleUnits.push(u);
|
posibleUnits.push(u);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.ratio = 2;
|
this.ratio = 2;
|
||||||
this.unitScale = this.getUnitScale(this.unit);
|
this.unitScale = this.getUnitScale(this.unit);
|
||||||
let canvas:HTMLCanvasElement = this.canvasRef.nativeElement;
|
const canvas:HTMLCanvasElement = this.canvasRef.nativeElement;
|
||||||
this.ctx = canvas.getContext('2d');
|
this.ctx = canvas.getContext('2d');
|
||||||
this.elementWidth = canvas.offsetWidth;
|
this.elementWidth = canvas.offsetWidth;
|
||||||
this.elementHeight = canvas.offsetHeight;
|
this.elementHeight = canvas.offsetHeight;
|
||||||
@@ -102,13 +102,13 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
this.startDate = new Date(this.startDate.getTime() + this.getUnitDateOffset(this.startDate,this.unitScale,0));
|
this.startDate = new Date(this.startDate.getTime() + this.getUnitDateOffset(this.startDate,this.unitScale,0));
|
||||||
this.endDate = new Date(this.endDate.getTime() + this.getUnitDateOffset(this.endDate,this.unitScale,1));
|
this.endDate = new Date(this.endDate.getTime() + this.getUnitDateOffset(this.endDate,this.unitScale,1));
|
||||||
this.change.emit({startDate:this.startDate,endDate:this.endDate});
|
this.change.emit({startDate:this.startDate,endDate:this.endDate});
|
||||||
let rangeInMilliseconds = this.endDate.getTime() - this.startDate.getTime();
|
const rangeInMilliseconds = this.endDate.getTime() - this.startDate.getTime();
|
||||||
this.scale = this.getFitScale(rangeInMilliseconds,this.elementWidth);
|
this.scale = this.getFitScale(rangeInMilliseconds,this.elementWidth);
|
||||||
this.posibleUnits=this.getPosibleUnits(this.scale);
|
this.posibleUnits=this.getPosibleUnits(this.scale);
|
||||||
this.height=this.getHeight();
|
this.height=this.getHeight();
|
||||||
this.lineHeight= this.getLineHeight();
|
this.lineHeight= this.getLineHeight();
|
||||||
this.setCanvasSize();
|
this.setCanvasSize();
|
||||||
let center = (this.startDate.getTime()+this.endDate.getTime())/2;
|
const center = (this.startDate.getTime()+this.endDate.getTime())/2;
|
||||||
this.viewMinDate = new Date(center - (this.elementWidth/2* this.scale));
|
this.viewMinDate = new Date(center - (this.elementWidth/2* this.scale));
|
||||||
this.viewMaxDate = new Date(center + (this.elementWidth/2* this.scale));
|
this.viewMaxDate = new Date(center + (this.elementWidth/2* this.scale));
|
||||||
this.updateStyle(this.startDate,this.endDate);
|
this.updateStyle(this.startDate,this.endDate);
|
||||||
@@ -118,8 +118,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
this.initialized=true;
|
this.initialized=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix:boolean = false,extended:boolean=true):string {
|
getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix = false,extended=true):string {
|
||||||
let showSuffix = false;
|
const showSuffix = false;
|
||||||
otherDate=new Date(otherDate.getTime()-1); // fix year edge case
|
otherDate=new Date(otherDate.getTime()-1); // fix year edge case
|
||||||
if(unitScale == 3) {
|
if(unitScale == 3) {
|
||||||
let format="HH:00";
|
let format="HH:00";
|
||||||
@@ -152,7 +152,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
return this.datePipe.transform(date,format);
|
return this.datePipe.transform(date,format);
|
||||||
}
|
}
|
||||||
if(unitScale == 7) {
|
if(unitScale == 7) {
|
||||||
let q = Math.trunc(date.getMonth() /3 );
|
const q = Math.trunc(date.getMonth() /3 );
|
||||||
return this.quarters[q];
|
return this.quarters[q];
|
||||||
}
|
}
|
||||||
if(unitScale == 8) {
|
if(unitScale == 8) {
|
||||||
@@ -161,17 +161,17 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
getStartCaption(startDate:Date,unitScale:number,suffix:boolean=false,extended:boolean=true):string {
|
getStartCaption(startDate:Date,unitScale:number,suffix=false,extended=true):string {
|
||||||
return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale]/2)), this.endDate,unitScale,suffix,extended);
|
return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale]/2)), this.endDate,unitScale,suffix,extended);
|
||||||
}
|
}
|
||||||
|
|
||||||
getEndCaption(endDate:Date,unitScale:number,suffix:boolean=true):string {
|
getEndCaption(endDate:Date,unitScale:number,suffix=true):string {
|
||||||
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale]/2)),this.startDate, unitScale,suffix);
|
return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale]/2)),this.startDate, unitScale,suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCaption(startDate:Date,endDate:Date,unitScale:number):string {
|
getCaption(startDate:Date,endDate:Date,unitScale:number):string {
|
||||||
let startCaption=this.getStartCaption(startDate,unitScale);
|
const startCaption=this.getStartCaption(startDate,unitScale);
|
||||||
let endCaption=this.getEndCaption(endDate,unitScale);
|
const endCaption=this.getEndCaption(endDate,unitScale);
|
||||||
if((endDate.getTime() - startDate.getTime()) < (1.5*this.unitScales[this.unitScale]))
|
if((endDate.getTime() - startDate.getTime()) < (1.5*this.unitScales[this.unitScale]))
|
||||||
return endCaption;
|
return endCaption;
|
||||||
return `${startCaption}-${endCaption}`;
|
return `${startCaption}-${endCaption}`;
|
||||||
@@ -186,20 +186,20 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFitScale(rangeInMilliSeconds:number,elementWidth:number):number {
|
getFitScale(rangeInMilliSeconds:number,elementWidth:number):number {
|
||||||
let width = elementWidth*0.33;
|
const width = elementWidth*0.33;
|
||||||
return rangeInMilliSeconds/width;
|
return rangeInMilliSeconds/width;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnitScale(unit:string):number {
|
getUnitScale(unit:string):number {
|
||||||
if(!unit) return 3; // hour
|
if(!unit) return 3; // hour
|
||||||
for(var _i=0;_i<this.units.length;_i++) {
|
for(let _i=0;_i<this.units.length;_i++) {
|
||||||
if(this.units[_i]==unit.toLowerCase()) return _i;
|
if(this.units[_i]==unit.toLowerCase()) return _i;
|
||||||
}
|
}
|
||||||
throw new Error(`Invalid unit : {{unit}} `);
|
throw new Error(`Invalid unit : {{unit}} `);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnitDateOffset(date:Date, unitScale:number,tick:number):number {
|
getUnitDateOffset(date:Date, unitScale:number,tick:number):number {
|
||||||
var offsetDate:Date;
|
let offsetDate:Date;
|
||||||
if(unitScale==0)
|
if(unitScale==0)
|
||||||
offsetDate = new Date(date.getFullYear(),date.getMonth(),date.getDate() ,date.getHours() ,date.getMinutes(),date.getSeconds(),date.getMilliseconds()+ tick);
|
offsetDate = new Date(date.getFullYear(),date.getMonth(),date.getDate() ,date.getHours() ,date.getMinutes(),date.getSeconds(),date.getMilliseconds()+ tick);
|
||||||
if(unitScale==1)
|
if(unitScale==1)
|
||||||
@@ -213,7 +213,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
if(unitScale==6)
|
if(unitScale==6)
|
||||||
offsetDate = new Date(date.getFullYear(),date.getMonth()+tick,1,0,0,0,0);
|
offsetDate = new Date(date.getFullYear(),date.getMonth()+tick,1,0,0,0,0);
|
||||||
if(unitScale==7) {
|
if(unitScale==7) {
|
||||||
var month = (tick * 3);
|
const month = (tick * 3);
|
||||||
offsetDate = new Date(date.getFullYear(),month,1,0,0,0,0);
|
offsetDate = new Date(date.getFullYear(),month,1,0,0,0,0);
|
||||||
}
|
}
|
||||||
if(unitScale==8)
|
if(unitScale==8)
|
||||||
@@ -234,12 +234,12 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getNextTick(viewStartDate:Date, tick:number,step:number,unitScale:number):number {
|
getNextTick(viewStartDate:Date, tick:number,step:number,unitScale:number):number {
|
||||||
let unitTextWidth = this.getUnitTextWidth(unitScale);
|
const unitTextWidth = this.getUnitTextWidth(unitScale);
|
||||||
let dateOffset =this.getUnitDateOffset(viewStartDate,unitScale,tick);
|
const dateOffset =this.getUnitDateOffset(viewStartDate,unitScale,tick);
|
||||||
let date = new Date(viewStartDate.getTime() + dateOffset);
|
const date = new Date(viewStartDate.getTime() + dateOffset);
|
||||||
let nextTick=tick+step+Math.trunc(step/2);
|
let nextTick=tick+step+Math.trunc(step/2);
|
||||||
let nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
|
const nextDateOffset =this.getUnitDateOffset(viewStartDate,unitScale,nextTick);
|
||||||
let nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
|
const nextDate = new Date(viewStartDate.getTime() + nextDateOffset);
|
||||||
let n=1;
|
let n=1;
|
||||||
switch(unitScale) {
|
switch(unitScale) {
|
||||||
case 4:n=nextDate.getDate()-1;break;
|
case 4:n=nextDate.getDate()-1;break;
|
||||||
@@ -247,7 +247,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
case 8:n=nextDate.getFullYear();break;
|
case 8:n=nextDate.getFullYear();break;
|
||||||
default: n = 1;break;
|
default: n = 1;break;
|
||||||
}
|
}
|
||||||
let a = Math.trunc(n / step)*step;
|
const a = Math.trunc(n / step)*step;
|
||||||
nextTick=nextTick-n+a;
|
nextTick=nextTick-n+a;
|
||||||
if(nextTick<=tick) return tick+step;
|
if(nextTick<=tick) return tick+step;
|
||||||
return nextTick;
|
return nextTick;
|
||||||
@@ -262,16 +262,16 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawUnits(yOffset:number,width:number,viewStartDate:Date,unitScale:number):number {
|
drawUnits(yOffset:number,width:number,viewStartDate:Date,unitScale:number):number {
|
||||||
let oneUnit = (this.getUnitDateOffset(viewStartDate,unitScale,1)- this.getUnitDateOffset(viewStartDate,unitScale,0)) / this.scale;
|
const oneUnit = (this.getUnitDateOffset(viewStartDate,unitScale,1)- this.getUnitDateOffset(viewStartDate,unitScale,0)) / this.scale;
|
||||||
this.ctx.font=`normal ${this.ratio*10}pt Sans-serif`;
|
this.ctx.font=`normal ${this.ratio*10}pt Sans-serif`;
|
||||||
let lineHeight = this.getLineHeight();
|
const lineHeight = this.getLineHeight();
|
||||||
let dateOffset = this.getUnitDateOffset(viewStartDate,unitScale,0);
|
let dateOffset = this.getUnitDateOffset(viewStartDate,unitScale,0);
|
||||||
let pixelOffset = (dateOffset / this.scale);
|
let pixelOffset = (dateOffset / this.scale);
|
||||||
let caption = this.getStartCaption(new Date(viewStartDate.getTime()+dateOffset),unitScale,false,false);
|
let caption = this.getStartCaption(new Date(viewStartDate.getTime()+dateOffset),unitScale,false,false);
|
||||||
let unitTextWidth=this.getUnitTextWidth(unitScale);
|
const unitTextWidth=this.getUnitTextWidth(unitScale);
|
||||||
this.ctx.beginPath();
|
this.ctx.beginPath();
|
||||||
this.ctx.strokeStyle=this.lineColor;
|
this.ctx.strokeStyle=this.lineColor;
|
||||||
let steps=this.getSteps(unitScale);
|
const steps=this.getSteps(unitScale);
|
||||||
let s=0;
|
let s=0;
|
||||||
let step=steps[s];
|
let step=steps[s];
|
||||||
let steppedOneUnit=oneUnit*step;
|
let steppedOneUnit=oneUnit*step;
|
||||||
@@ -283,10 +283,10 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
this.ctx.moveTo(0,yOffset*this.ratio);
|
this.ctx.moveTo(0,yOffset*this.ratio);
|
||||||
this.ctx.lineTo(width*this.ratio,yOffset*this.ratio);
|
this.ctx.lineTo(width*this.ratio,yOffset*this.ratio);
|
||||||
this.ctx.stroke();
|
this.ctx.stroke();
|
||||||
var x:number = pixelOffset;
|
let x:number = pixelOffset;
|
||||||
var nextDateOffset = this.getUnitDateOffset(viewStartDate,unitScale,1);
|
let nextDateOffset = this.getUnitDateOffset(viewStartDate,unitScale,1);
|
||||||
var nextX:number = (nextDateOffset / this.scale);
|
let nextX:number = (nextDateOffset / this.scale);
|
||||||
var n=0;
|
let n=0;
|
||||||
while(x < width) {
|
while(x < width) {
|
||||||
this.ctx.fillStyle=this.color;
|
this.ctx.fillStyle=this.color;
|
||||||
//mouseover
|
//mouseover
|
||||||
@@ -320,12 +320,12 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
redraw() {
|
redraw() {
|
||||||
let yOffset=0;
|
let yOffset=0;
|
||||||
let canvas = this.canvasRef.nativeElement;
|
const canvas = this.canvasRef.nativeElement;
|
||||||
let height = canvas.offsetHeight;
|
const height = canvas.offsetHeight;
|
||||||
let width = canvas.offsetWidth;
|
const width = canvas.offsetWidth;
|
||||||
this.ctx.lineWidth = this.lineWidth;// *this.ratio;
|
this.ctx.lineWidth = this.lineWidth;// *this.ratio;
|
||||||
this.ctx.clearRect(0,0,width *this.ratio,height*this.ratio);
|
this.ctx.clearRect(0,0,width *this.ratio,height*this.ratio);
|
||||||
for(let unit of this.posibleUnits) {
|
for(const unit of this.posibleUnits) {
|
||||||
if(this.unitScale <=unit) yOffset+=this.drawUnits(yOffset,width,this.viewMinDate,unit);
|
if(this.unitScale <=unit) yOffset+=this.drawUnits(yOffset,width,this.viewMinDate,unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,9 +335,9 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateStyle(startDate:Date,endDate:Date) {
|
updateStyle(startDate:Date,endDate:Date) {
|
||||||
let rangeInMilliseconds = endDate.getTime() - startDate.getTime();
|
const rangeInMilliseconds = endDate.getTime() - startDate.getTime();
|
||||||
let range = rangeInMilliseconds / this.scale;
|
const range = rangeInMilliseconds / this.scale;
|
||||||
let left = (startDate.getTime() - this.viewMinDate.getTime()) / this.scale;
|
const left = (startDate.getTime() - this.viewMinDate.getTime()) / this.scale;
|
||||||
this.startPopoverLeft=(left-10);
|
this.startPopoverLeft=(left-10);
|
||||||
this.endPopoverLeft=(left+range+10);
|
this.endPopoverLeft=(left+range+10);
|
||||||
this.marginLeft = (left - 15);
|
this.marginLeft = (left - 15);
|
||||||
@@ -348,14 +348,14 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snapToUnit(date:Date,unitScale:number):Date {
|
snapToUnit(date:Date,unitScale:number):Date {
|
||||||
var d = new Date(date.getTime() + (this.unitScales[this.unitScale]/2));
|
const d = new Date(date.getTime() + (this.unitScales[this.unitScale]/2));
|
||||||
var offsetInMilliseconds =this.getUnitDateOffset(d,this.unitScale,0)
|
const offsetInMilliseconds =this.getUnitDateOffset(d,this.unitScale,0)
|
||||||
return new Date(d.getTime()+offsetInMilliseconds);
|
return new Date(d.getTime()+offsetInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
getEndDate(offsetInPixels:number):Date {
|
getEndDate(offsetInPixels:number):Date {
|
||||||
let oneUnit = this.unitScales[this.unitScale];
|
const oneUnit = this.unitScales[this.unitScale];
|
||||||
let offsetInMilliseconds = offsetInPixels * this.scale;
|
const offsetInMilliseconds = offsetInPixels * this.scale;
|
||||||
if(this.leftGripMove) {
|
if(this.leftGripMove) {
|
||||||
if(this.startDate.getTime() + offsetInMilliseconds > this.endDate.getTime() - oneUnit) {
|
if(this.startDate.getTime() + offsetInMilliseconds > this.endDate.getTime() - oneUnit) {
|
||||||
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds + oneUnit),this.unitScale);
|
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds + oneUnit),this.unitScale);
|
||||||
@@ -367,8 +367,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getStartDate(offsetInPixels:number):Date {
|
getStartDate(offsetInPixels:number):Date {
|
||||||
let oneUnit = this.unitScales[this.unitScale];
|
const oneUnit = this.unitScales[this.unitScale];
|
||||||
let offsetInMilliseconds = offsetInPixels * this.scale;
|
const offsetInMilliseconds = offsetInPixels * this.scale;
|
||||||
if(this.leftGripMove || this.rangeGripMove) {
|
if(this.leftGripMove || this.rangeGripMove) {
|
||||||
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds),this.unitScale);
|
return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds),this.unitScale);
|
||||||
} else if(this.rightGripMove) {
|
} else if(this.rightGripMove) {
|
||||||
@@ -380,14 +380,14 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateControl(event:MouseEvent|TouchEvent) {
|
updateControl(event:MouseEvent|TouchEvent) {
|
||||||
let offsetInPixels = this.getClientX(event) - this.downX;
|
const offsetInPixels = this.getClientX(event) - this.downX;
|
||||||
if(this.leftGripMove || this.rightGripMove || this.rangeGripMove) {
|
if(this.leftGripMove || this.rightGripMove || this.rangeGripMove) {
|
||||||
let startDate = this.getStartDate(offsetInPixels);
|
const startDate = this.getStartDate(offsetInPixels);
|
||||||
let endDate = this.getEndDate(offsetInPixels);
|
const endDate = this.getEndDate(offsetInPixels);
|
||||||
this.updateStyle(startDate,endDate)
|
this.updateStyle(startDate,endDate)
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
} else if(this.viewPan) {
|
} else if(this.viewPan) {
|
||||||
let offsetInMilliseconds = offsetInPixels*this.scale;
|
const offsetInMilliseconds = offsetInPixels*this.scale;
|
||||||
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
|
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
|
||||||
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
|
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
|
||||||
this.updateStyle(this.startDate,this.endDate);
|
this.updateStyle(this.startDate,this.endDate);
|
||||||
@@ -510,10 +510,10 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
nextScale*=1.1;
|
nextScale*=1.1;
|
||||||
let canZoom=false;
|
const canZoom=false;
|
||||||
let oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale;
|
const oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale;
|
||||||
let unitTextWidth=this.getUnitTextWidth(8);
|
const unitTextWidth=this.getUnitTextWidth(8);
|
||||||
let steps=this.getSteps(8);
|
const steps=this.getSteps(8);
|
||||||
let s=0;
|
let s=0;
|
||||||
let step=steps[s];
|
let step=steps[s];
|
||||||
let steppedOneUnit=oneUnit*step;
|
let steppedOneUnit=oneUnit*step;
|
||||||
@@ -527,7 +527,7 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
handleMouseWheel(event:WheelEvent) {
|
handleMouseWheel(event:WheelEvent) {
|
||||||
if(!this.canZoom(this.scale,event.deltaY)) return;
|
if(!this.canZoom(this.scale,event.deltaY)) return;
|
||||||
let oldOffsetInMilliseconds = event.clientX * this.scale;
|
const oldOffsetInMilliseconds = event.clientX * this.scale;
|
||||||
if(event.deltaY>=0)
|
if(event.deltaY>=0)
|
||||||
this.scale*=1.1;
|
this.scale*=1.1;
|
||||||
else
|
else
|
||||||
@@ -536,8 +536,8 @@ export class TimespanComponent implements OnInit, OnChanges {
|
|||||||
this.height=this.getHeight();
|
this.height=this.getHeight();
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
this.setCanvasSize();
|
this.setCanvasSize();
|
||||||
let newOffsetInMilliseconds = event.clientX * this.scale;
|
const newOffsetInMilliseconds = event.clientX * this.scale;
|
||||||
let offsetInMilliseconds = newOffsetInMilliseconds-oldOffsetInMilliseconds;
|
const offsetInMilliseconds = newOffsetInMilliseconds-oldOffsetInMilliseconds;
|
||||||
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
|
this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds);
|
||||||
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
|
this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds);
|
||||||
this.updateStyle(this.startDate,this.endDate);
|
this.updateStyle(this.startDate,this.endDate);
|
||||||
|
@@ -21,7 +21,7 @@ export class AppCommonEffects {
|
|||||||
ofType(appCommonActions.LOGIN),
|
ofType(appCommonActions.LOGIN),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)),
|
||||||
mergeMap(([action, initialized]) => {
|
mergeMap(([action, initialized]) => {
|
||||||
var a = (action as appCommonActions.Login);
|
const a = (action as appCommonActions.Login);
|
||||||
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
|
this.oauthService$.initCodeFlow(a.url,{"prompt":"login"});
|
||||||
return [];
|
return [];
|
||||||
})),{dispatch:false});
|
})),{dispatch:false});
|
||||||
@@ -75,7 +75,7 @@ export class AppCommonEffects {
|
|||||||
userPackagesChanged$ = createEffect(() => this.actions$.pipe(
|
userPackagesChanged$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as appCommonActions.ItemChangedEvent;
|
const a = action as appCommonActions.ItemChangedEvent;
|
||||||
if(a.itemCode.endsWith(":USER_PACKAGES"))
|
if(a.itemCode.endsWith(":USER_PACKAGES"))
|
||||||
return of(new appCommonActions.InitUserPackages());
|
return of(new appCommonActions.InitUserPackages());
|
||||||
else
|
else
|
||||||
@@ -85,9 +85,8 @@ export class AppCommonEffects {
|
|||||||
|
|
||||||
initUserSettingsRoot$ = createEffect(() => this.actions$.pipe(
|
initUserSettingsRoot$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(appCommonActions.INITUSERSETTINGSROOT),
|
ofType(appCommonActions.INITUSERSETTINGSROOT),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.SelectGetUser)),
|
switchMap(_ => {
|
||||||
switchMap(([, user]) => {
|
return this.folderService$.getFolder('my_settings').pipe(
|
||||||
return this.itemService$.getItem(user.code + ':USER_SETTINGS').pipe(
|
|
||||||
switchMap((item) => of(new appCommonActions.InitUserSettingsRootSuccess(item))),
|
switchMap((item) => of(new appCommonActions.InitUserSettingsRootSuccess(item))),
|
||||||
catchError(error => of(new appCommonActions.Fail(error)))
|
catchError(error => of(new appCommonActions.Fail(error)))
|
||||||
)
|
)
|
||||||
@@ -97,7 +96,7 @@ export class AppCommonEffects {
|
|||||||
initUserSettingsRootChanged$ = createEffect(() => this.actions$.pipe(
|
initUserSettingsRootChanged$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
ofType(appCommonActions.ITEMCHANGEDEVENT),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
let a = action as appCommonActions.ItemChangedEvent;
|
const a = action as appCommonActions.ItemChangedEvent;
|
||||||
if(a.itemCode.endsWith(":USER_SETTINGS"))
|
if(a.itemCode.endsWith(":USER_SETTINGS"))
|
||||||
return of(new appCommonActions.InitUserSettingsRoot());
|
return of(new appCommonActions.InitUserSettingsRoot());
|
||||||
else
|
else
|
||||||
@@ -134,10 +133,10 @@ export class AppCommonEffects {
|
|||||||
ofType(appCommonActions.EDITITEM),
|
ofType(appCommonActions.EDITITEM),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
||||||
switchMap(([action, itemtypes]) => {
|
switchMap(([action, itemtypes]) => {
|
||||||
var a = action as appCommonActions.EditItem;
|
const a = action as appCommonActions.EditItem;
|
||||||
var editor = "property";
|
var editor = "property";
|
||||||
if(a.item.itemType) {
|
if(a.item.itemType) {
|
||||||
var itemType = itemtypes[a.item.itemType];
|
const itemType = itemtypes[a.item.itemType];
|
||||||
var editor = itemType && itemType.editor ? itemType.editor : editor;
|
var editor = itemType && itemType.editor ? itemType.editor : editor;
|
||||||
}
|
}
|
||||||
this.router$.navigate(['/editor',editor,'item', a.item.code])
|
this.router$.navigate(['/editor',editor,'item', a.item.code])
|
||||||
@@ -149,12 +148,12 @@ export class AppCommonEffects {
|
|||||||
ofType(appCommonActions.VIEWITEM),
|
ofType(appCommonActions.VIEWITEM),
|
||||||
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)),
|
||||||
switchMap(([action, itemtypes]) => {
|
switchMap(([action, itemtypes]) => {
|
||||||
var a = action as appCommonActions.EditItem;
|
const a = action as appCommonActions.EditItem;
|
||||||
var itemType = itemtypes[a.item.itemType];
|
const itemType = itemtypes[a.item.itemType];
|
||||||
var viewer = itemType.viewer;
|
const viewer = itemType.viewer;
|
||||||
var editor = itemType.editor;
|
const editor = itemType.editor;
|
||||||
if(viewer == 'select_as_mapitem') {
|
if(viewer == 'select_as_mapitem') {
|
||||||
let queryState = {
|
const queryState = {
|
||||||
itemCode: a.item.code,
|
itemCode: a.item.code,
|
||||||
parentCode: null,
|
parentCode: null,
|
||||||
level: 1,
|
level: 1,
|
||||||
@@ -166,11 +165,11 @@ export class AppCommonEffects {
|
|||||||
startDate: null,
|
startDate: null,
|
||||||
bbox: []
|
bbox: []
|
||||||
};
|
};
|
||||||
let query = this.stateSerializerService$.serialize(queryState);
|
const query = this.stateSerializerService$.serialize(queryState);
|
||||||
this.router$.navigate(['/map', query ])
|
this.router$.navigate(['/map', query ])
|
||||||
}else if(viewer == 'edit_in_editor') {
|
}else if(viewer == 'edit_in_editor') {
|
||||||
this.router$.navigate(['/editor', editor, 'item', a.item.code])
|
this.router$.navigate(['/editor', editor, 'item', a.item.code])
|
||||||
} else {
|
} else if(viewer) {
|
||||||
this.router$.navigate(['/viewer', viewer, 'item', a.item.code])
|
this.router$.navigate(['/viewer', viewer, 'item', a.item.code])
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@@ -181,19 +180,19 @@ export class AppCommonEffects {
|
|||||||
fail$ = createEffect(() => this.actions$.pipe(
|
fail$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(appCommonActions.FAIL),
|
ofType(appCommonActions.FAIL),
|
||||||
map((action) => {
|
map((action) => {
|
||||||
let failAction = action as appCommonActions.Fail;
|
const failAction = action as appCommonActions.Fail;
|
||||||
console.debug(failAction.payload)
|
//console.debug(failAction.payload)
|
||||||
return null;
|
return null;
|
||||||
})),{dispatch:false});
|
})),{dispatch:false});
|
||||||
|
|
||||||
online$ = createEffect(() => this.actions$.pipe(
|
online$ = createEffect(() => this.actions$.pipe(
|
||||||
ofType(appCommonActions.ONLINE),
|
ofType(appCommonActions.ONLINE),
|
||||||
switchMap((action) => {
|
switchMap((action) => {
|
||||||
console.debug("Online: Check token");
|
//console.debug("Online: Check token");
|
||||||
if(!this.oauthService$.hasValidAccessToken()) {
|
if(!this.oauthService$.hasValidAccessToken()) {
|
||||||
console.debug("No valid token, try to refresh");
|
//console.debug("No valid token, try to refresh");
|
||||||
if(this.oauthService$.getRefreshToken() != null ) {
|
if(this.oauthService$.getRefreshToken() != null ) {
|
||||||
console.debug("We have a refresh token");
|
//console.debug("We have a refresh token");
|
||||||
this.oauthService$.refreshToken();
|
this.oauthService$.refreshToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,4 +2,4 @@ import { IItemType } from './item.type';
|
|||||||
|
|
||||||
export interface IItemTypes{
|
export interface IItemTypes{
|
||||||
[id: string]: IItemType;
|
[id: string]: IItemType;
|
||||||
};
|
}
|
||||||
|
6
projects/common/src/fm/models/itemlink.type.ts
Normal file
6
projects/common/src/fm/models/itemlink.type.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export interface IItemLinkType {
|
||||||
|
itemcode: string;
|
||||||
|
pathsuffix?: string;
|
||||||
|
query?: string;
|
||||||
|
validminutes?: number;
|
||||||
|
}
|
3
projects/common/src/fm/models/url.type.ts
Normal file
3
projects/common/src/fm/models/url.type.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface IUrlType {
|
||||||
|
url: string;
|
||||||
|
}
|
@@ -58,12 +58,9 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state,{initialized: true});
|
return tassign(state,{initialized: true});
|
||||||
}
|
}
|
||||||
case appCommonActions.INITUSERSUCCESS: {
|
case appCommonActions.INITUSERSUCCESS: {
|
||||||
let a = action as appCommonActions.InitUserSuccess;
|
const a = action as appCommonActions.InitUserSuccess;
|
||||||
let claims = {}
|
const claims = { ...a.userinfo.info };
|
||||||
Object.getOwnPropertyNames(a.userinfo.info).forEach((k) => {
|
const user:IUser = {
|
||||||
claims[k] = a.userinfo[k];
|
|
||||||
});
|
|
||||||
var user:IUser = {
|
|
||||||
code:a.user.code,
|
code:a.user.code,
|
||||||
email:claims["email"]!== undefined ? claims["email"] : a.user.name,
|
email:claims["email"]!== undefined ? claims["email"] : a.user.name,
|
||||||
name:claims["name"]!== undefined?claims["name"] : a.user.email,
|
name:claims["name"]!== undefined?claims["name"] : a.user.email,
|
||||||
@@ -73,7 +70,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state, { user: user });
|
return tassign(state, { user: user });
|
||||||
}
|
}
|
||||||
case appCommonActions.INITROOTSUCCESS: {
|
case appCommonActions.INITROOTSUCCESS: {
|
||||||
let a = action as appCommonActions.InitRootSuccess;
|
const a = action as appCommonActions.InitRootSuccess;
|
||||||
return tassign(state, { rootItems:a.items});
|
return tassign(state, { rootItems:a.items});
|
||||||
}
|
}
|
||||||
case appCommonActions.OPENMODAL: {
|
case appCommonActions.OPENMODAL: {
|
||||||
@@ -83,7 +80,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state, { openedModalName: null });
|
return tassign(state, { openedModalName: null });
|
||||||
}
|
}
|
||||||
case appCommonActions.LOADITEMTYPESSUCCESS: {
|
case appCommonActions.LOADITEMTYPESSUCCESS: {
|
||||||
let a = action as appCommonActions.LoadItemTypesSuccess;
|
const a = action as appCommonActions.LoadItemTypesSuccess;
|
||||||
return tassign(state, { itemTypes: a.itemTypes });
|
return tassign(state, { itemTypes: a.itemTypes });
|
||||||
}
|
}
|
||||||
case appCommonActions.FULLSCREEN: {
|
case appCommonActions.FULLSCREEN: {
|
||||||
@@ -125,12 +122,12 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state, { menuVisible: false,accountMenuVisible:false,appMenuVisible: false,notificationMenuVisible:false,helpMenuVisible:false });
|
return tassign(state, { menuVisible: false,accountMenuVisible:false,appMenuVisible: false,notificationMenuVisible:false,helpMenuVisible:false });
|
||||||
}
|
}
|
||||||
case appCommonActions.SETMENUVISIBLE: {
|
case appCommonActions.SETMENUVISIBLE: {
|
||||||
let a = action as appCommonActions.SetMenuVisible;
|
const a = action as appCommonActions.SetMenuVisible;
|
||||||
return tassign(state, { menuVisible: a.visible,accountMenuVisible:a.visible?false:state.accountMenuVisible,appMenuVisible:a.visible?false:state.appMenuVisible,notificationMenuVisible:a.visible?false:state.notificationMenuVisible,helpMenuVisible:a.visible?false:state.helpMenuVisible });
|
return tassign(state, { menuVisible: a.visible,accountMenuVisible:a.visible?false:state.accountMenuVisible,appMenuVisible:a.visible?false:state.appMenuVisible,notificationMenuVisible:a.visible?false:state.notificationMenuVisible,helpMenuVisible:a.visible?false:state.helpMenuVisible });
|
||||||
}
|
}
|
||||||
case appCommonActions.INITUSERPACKAGESSUCCESS:{
|
case appCommonActions.INITUSERPACKAGESSUCCESS:{
|
||||||
let a = action as appCommonActions.InitUserPackagesSuccess;
|
const a = action as appCommonActions.InitUserPackagesSuccess;
|
||||||
let packages = {}
|
const packages = {}
|
||||||
a.items.forEach((item) => {
|
a.items.forEach((item) => {
|
||||||
item.data.dataDate = item.dataDate;
|
item.data.dataDate = item.dataDate;
|
||||||
item.data.dataEndDate = item.dataEndDate;
|
item.data.dataEndDate = item.dataEndDate;
|
||||||
@@ -143,8 +140,8 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state,{userPackages:packages});
|
return tassign(state,{userPackages:packages});
|
||||||
}
|
}
|
||||||
case appCommonActions.INITPACKAGESSUCCESS:{
|
case appCommonActions.INITPACKAGESSUCCESS:{
|
||||||
let a = action as appCommonActions.InitPackagesSuccess;
|
const a = action as appCommonActions.InitPackagesSuccess;
|
||||||
let packages = {}
|
const packages = {}
|
||||||
a.items.forEach((item) => {
|
a.items.forEach((item) => {
|
||||||
packages[item.data.id] = item.data;
|
packages[item.data.id] = item.data;
|
||||||
});
|
});
|
||||||
@@ -152,7 +149,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state,{packages:packages});
|
return tassign(state,{packages:packages});
|
||||||
}
|
}
|
||||||
case appCommonActions.INITUSERSETTINGSROOTSUCCESS:{
|
case appCommonActions.INITUSERSETTINGSROOTSUCCESS:{
|
||||||
let a = action as appCommonActions.InitUserSettingsRootSuccess;
|
const a = action as appCommonActions.InitUserSettingsRootSuccess;
|
||||||
return tassign(state, { userSettingsRoot : a.item });
|
return tassign(state, { userSettingsRoot : a.item });
|
||||||
}
|
}
|
||||||
case appCommonActions.LOGOUT:{
|
case appCommonActions.LOGOUT:{
|
||||||
@@ -168,11 +165,11 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state,{isOnline:false});
|
return tassign(state,{isOnline:false});
|
||||||
}
|
}
|
||||||
case appCommonActions.SETPAGEMODE: {
|
case appCommonActions.SETPAGEMODE: {
|
||||||
let a = action as appCommonActions.SetPageMode;
|
const a = action as appCommonActions.SetPageMode;
|
||||||
return tassign(state,{isPageMode:a.pageMode});
|
return tassign(state,{isPageMode:a.pageMode});
|
||||||
}
|
}
|
||||||
case appCommonActions.NOTIFICATIONEVENT: {
|
case appCommonActions.NOTIFICATIONEVENT: {
|
||||||
let a = action as appCommonActions.NotificationEvent;
|
const a = action as appCommonActions.NotificationEvent;
|
||||||
let unread = 0;
|
let unread = 0;
|
||||||
if(a.attributes["unread"]) {
|
if(a.attributes["unread"]) {
|
||||||
unread = parseInt(a.attributes["unread"]);
|
unread = parseInt(a.attributes["unread"]);
|
||||||
@@ -180,7 +177,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
|
|||||||
return tassign(state,{unreadNotifications:unread});
|
return tassign(state,{unreadNotifications:unread});
|
||||||
}
|
}
|
||||||
case appCommonActions.SETUNREADNOTIFICATIONS: {
|
case appCommonActions.SETUNREADNOTIFICATIONS: {
|
||||||
let a = action as appCommonActions.SetUnreadNotifications;
|
const a = action as appCommonActions.SetUnreadNotifications;
|
||||||
return tassign(state,{unreadNotifications:a.unread});
|
return tassign(state,{unreadNotifications:a.unread});
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
45
projects/common/src/fm/services/admin.service.ts
Normal file
45
projects/common/src/fm/services/admin.service.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { IItem } from '../models/item';
|
||||||
|
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||||
|
import { AppConfig } from "../shared/app.config";
|
||||||
|
import {ItemTypeService} from './itemtype.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class AdminService {
|
||||||
|
constructor(public httpClient: HttpClient, public appConfig: AppConfig,private itemTypeService:ItemTypeService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiEndpoint() {
|
||||||
|
return this.appConfig.getConfig("apiEndPoint");
|
||||||
|
}
|
||||||
|
|
||||||
|
getItem(code: string): Observable<IItem> {
|
||||||
|
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/admin/${code}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean): Observable<IItem[]> {
|
||||||
|
let params = new HttpParams();
|
||||||
|
if(itemType) params = params.append("it", itemType);
|
||||||
|
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
|
||||||
|
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
|
||||||
|
if(indexed) params = params.append("ind",indexed?"true":"false");
|
||||||
|
if (level) params = params.append("lvl", level.toFixed());
|
||||||
|
if (validToday) params = params.append("vt", validToday ? "true" : "false");
|
||||||
|
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/admin/`, { params: params });
|
||||||
|
}
|
||||||
|
|
||||||
|
postItem(item:IItem): Observable<IItem> {
|
||||||
|
return this.httpClient.post<IItem>(`${this.ApiEndpoint()}/api/v1/admin`,item);
|
||||||
|
}
|
||||||
|
|
||||||
|
putItem(item:IItem): Observable<IItem> {
|
||||||
|
return this.httpClient.put<IItem>(`${this.ApiEndpoint()}/api/v1/admin/${item.code}`,item);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteItem(code: string): Observable<any> {
|
||||||
|
return this.httpClient.delete<any>(`${this.ApiEndpoint()}/api/v1/admin/${code}`);
|
||||||
|
}
|
||||||
|
}
|
@@ -2,16 +2,18 @@ import { Injectable } from '@angular/core';
|
|||||||
import {
|
import {
|
||||||
CanActivate, Router, CanLoad, Route, CanActivateChild ,
|
CanActivate, Router, CanLoad, Route, CanActivateChild ,
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
RouterStateSnapshot
|
RouterStateSnapshot,
|
||||||
|
UrlSegment,
|
||||||
|
UrlTree
|
||||||
} from '@angular/router';
|
} from '@angular/router';
|
||||||
|
|
||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { OAuthService } from 'angular-oauth2-oidc';
|
import { OAuthService } from 'angular-oauth2-oidc';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
import * as appCommonReducer from '../reducers/app-common.reducer'
|
import * as appCommonReducer from '../reducers/app-common.reducer';
|
||||||
import * as appCommonActions from '../actions/app-common.actions';
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@@ -19,33 +21,57 @@ import * as appCommonActions from '../actions/app-common.actions';
|
|||||||
})
|
})
|
||||||
export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
|
export class AuthGuard implements CanActivate, CanLoad, CanActivateChild {
|
||||||
|
|
||||||
constructor(private oauthService: OAuthService, private router: Router, private store: Store<appCommonReducer.State> ) { }
|
constructor(private oauthService: OAuthService, private router: Router, private store: Store<appCommonReducer.State>) { }
|
||||||
|
|
||||||
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {
|
||||||
|
//console.debug("AuthGuard->canActivate", route, state);
|
||||||
|
const url: string = state.url;
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
return this.checkLogin(url, route);
|
||||||
let url: string = state.url;
|
}
|
||||||
|
|
||||||
|
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {
|
||||||
|
//console.debug("AuthGuard->canActivateChild", childRoute, state);
|
||||||
|
const url: string = state.url;
|
||||||
|
|
||||||
return this.checkLogin(url);
|
return this.checkLogin(url, childRoute);
|
||||||
|
}
|
||||||
|
|
||||||
|
canLoad(route: Route, segments: UrlSegment[]): boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {
|
||||||
|
//console.debug("AuthGuard->canLoad", route, segments);
|
||||||
|
return this.checkLogin(route.path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
checkLogin(url: string, route: ActivatedRouteSnapshot): boolean {
|
||||||
let url: string = state.url;
|
//console.debug("AuthGuard->checkLogin", url, route);
|
||||||
|
if (!this.oauthService.hasValidAccessToken()) {
|
||||||
return this.checkLogin(url);
|
//console.debug("No valid token");
|
||||||
}
|
this.oauthService.initCodeFlow(url);
|
||||||
|
return false;
|
||||||
canLoad(route: Route): Promise<boolean> {
|
} else {
|
||||||
return this.checkLogin(route.path);
|
const requiredRoleClaim = route.data.role;
|
||||||
}
|
if (!requiredRoleClaim) { return true; }
|
||||||
|
const ownedClaims = this.oauthService.getIdentityClaims();
|
||||||
checkLogin(url: string): Promise<boolean> {
|
if (!ownedClaims) {
|
||||||
return new Promise<boolean>((resolve) => {
|
//console.debug("No owned claims");
|
||||||
if (!this.oauthService.hasValidAccessToken()) {
|
return false;
|
||||||
console.debug("No valid token");
|
|
||||||
this.oauthService.initCodeFlow(url);
|
|
||||||
resolve(false);
|
|
||||||
} else {
|
|
||||||
resolve(true);
|
|
||||||
}
|
}
|
||||||
});
|
const ownedRoleClaims: string[] = ownedClaims['role'];
|
||||||
|
if (!ownedRoleClaims) {
|
||||||
|
// console.debug("No owned role claims");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Array.isArray(ownedRoleClaims)) {
|
||||||
|
if (ownedRoleClaims.findIndex(r => r === requiredRoleClaim) <= -1) {
|
||||||
|
//console.debug("No required role claim", ownedRoleClaims, requiredRoleClaim);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ownedRoleClaims !== requiredRoleClaim) { console.debug("No required role claim", ownedRoleClaims, requiredRoleClaim); return false; }
|
||||||
|
}
|
||||||
|
//console.debug("Has required role claim", requiredRoleClaim);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,9 @@ import { Injectable } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class DeviceService {
|
export class DeviceService {
|
||||||
public IsMobile() {
|
public IsMobile() {
|
||||||
let w = window as any;
|
const w = window as any;
|
||||||
let check = false;
|
let check = false;
|
||||||
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||w.opera);
|
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||w.opera);
|
||||||
return check;
|
return check;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ export class EventService {
|
|||||||
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
|
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
|
||||||
private _connection: HubConnection = null;
|
private _connection: HubConnection = null;
|
||||||
private _apiEndPoint: string;
|
private _apiEndPoint: string;
|
||||||
public authenticated:boolean = false;
|
public authenticated = false;
|
||||||
|
|
||||||
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
|
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
|
||||||
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
|
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
|
||||||
@@ -42,7 +42,7 @@ export class EventService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Authenticate() {
|
private Authenticate() {
|
||||||
var accessToken = this.oauthService.getAccessToken();
|
const accessToken = this.oauthService.getAccessToken();
|
||||||
if (this.oauthService.hasValidAccessToken()) {
|
if (this.oauthService.hasValidAccessToken()) {
|
||||||
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
||||||
this.authenticated=true;
|
this.authenticated=true;
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import { Observable , Observer } from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {map} from 'rxjs/operators';
|
import {IListItem} from '../models/list.item';
|
||||||
import { IListItem } from '../models/list.item';
|
import {IItem} from '../models/item';
|
||||||
import { IItem } from '../models/item';
|
import {HttpClient} from '@angular/common/http';
|
||||||
import { HttpClient } from "@angular/common/http";
|
import {AppConfig} from '../shared/app.config';
|
||||||
import { AppConfig } from "../shared/app.config";
|
import {ItemService} from './item.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class FolderService {
|
export class FolderService {
|
||||||
|
|
||||||
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
|
constructor(public httpClient: HttpClient, public appConfig: AppConfig, public itemService: ItemService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiEndpoint() {
|
ApiEndpoint() {
|
||||||
@@ -19,23 +19,24 @@ export class FolderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFolder(code: string): Observable<IListItem> {
|
getFolder(code: string): Observable<IListItem> {
|
||||||
return this.httpClient.get<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/${code}`);
|
return this.httpClient.get<IListItem>(`${this.ApiEndpoint()}/api/v1/folders/${code}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyRoots(): Observable<IListItem[]> {
|
getMyRoots(): Observable<IListItem[]> {
|
||||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/my_roots`);
|
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/my_roots`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFolderParents(code: string): Observable<IListItem[]> {
|
getFolderParents(code: string): Observable<IListItem[]> {
|
||||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`);
|
return this.itemService.getBreadcrumbs(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildFolders(code: string): Observable<IListItem[]> {
|
getChildFolders(code: string): Observable<IListItem[]> {
|
||||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`);
|
const folderItemTypes = "FOLDER,FTP_FOLDER";
|
||||||
|
return this.itemService.getChildItemList(code, folderItemTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
getItems(code: string,skip:number, take:number): Observable<IListItem[]> {
|
getItems(code: string,skip:number, take:number): Observable<IListItem[]> {
|
||||||
return this.httpClient.get<IListItem[]>(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`);
|
return this.itemService.getChildItemList(code, null, null, 1, true, null, null, skip, take);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveItem(itemCode: string, newParentCode: string): Observable<IListItem> {
|
moveItem(itemCode: string, newParentCode: string): Observable<IListItem> {
|
||||||
|
@@ -8,10 +8,10 @@ export class GradientService {
|
|||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getGradientStyle(gradient:IGradientstop[],portrait:boolean = false ):any {
|
getGradientStyle(gradient:IGradientstop[],portrait = false ):any {
|
||||||
let gd = '{ "background": "linear-gradient(to ' + (portrait?'bottom':'right') +',';
|
let gd = '{ "background": "linear-gradient(to ' + (portrait?'bottom':'right') +',';
|
||||||
for(var i=0;i<gradient.length;i++) {
|
for(let i=0;i<gradient.length;i++) {
|
||||||
let gs = gradient[i];
|
const gs = gradient[i];
|
||||||
if(i>0) gd+=",";
|
if(i>0) gd+=",";
|
||||||
gd += `rgba(${gs.color.red},${gs.color.green},${gs.color.blue},${gs.color.alpha/255})`;
|
gd += `rgba(${gs.color.red},${gs.color.green},${gs.color.blue},${gs.color.alpha/255})`;
|
||||||
gd +=` ${gs.relativestop*100}%`
|
gd +=` ${gs.relativestop*100}%`
|
||||||
|
@@ -19,7 +19,7 @@ import { AppConfig } from "../shared/app.config";
|
|||||||
}
|
}
|
||||||
|
|
||||||
check(interval:number): Observable<boolean> {
|
check(interval:number): Observable<boolean> {
|
||||||
let retval = new BehaviorSubject<boolean>(true);
|
const retval = new BehaviorSubject<boolean>(true);
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.httpClient.get(`${this.ApiEndpoint()}/api/v1/healthcheck`).pipe(map(() => true),catchError((error) => of(false))).toPromise().then((status) => {
|
this.httpClient.get(`${this.ApiEndpoint()}/api/v1/healthcheck`).pipe(map(() => true),catchError((error) => of(false))).toPromise().then((status) => {
|
||||||
retval.next(status);
|
retval.next(status);
|
||||||
|
@@ -22,8 +22,8 @@ export class ImageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataUrltoBlob(dataURI:string):Blob {
|
dataUrltoBlob(dataURI:string):Blob {
|
||||||
var mime = dataURI.split( ';base64,')[0].split(':')[1];
|
const mime = dataURI.split( ';base64,')[0].split(':')[1];
|
||||||
var byteCharacters = atob(dataURI.split( ';base64,')[1]);
|
const byteCharacters = atob(dataURI.split( ';base64,')[1]);
|
||||||
|
|
||||||
|
|
||||||
const sliceSize = 512;
|
const sliceSize = 512;
|
||||||
@@ -52,7 +52,7 @@ export class ImageService {
|
|||||||
blobToDataUrl(blob:File):Promise<string> {
|
blobToDataUrl(blob:File):Promise<string> {
|
||||||
|
|
||||||
return new Promise<string>((resolve) => {
|
return new Promise<string>((resolve) => {
|
||||||
let reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.addEventListener('error', () => {
|
reader.addEventListener('error', () => {
|
||||||
resolve("");
|
resolve("");
|
||||||
});
|
});
|
||||||
|
@@ -2,12 +2,15 @@ import { Injectable } from '@angular/core';
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { IItemType } from '../models/item.type';
|
import { IItemType } from '../models/item.type';
|
||||||
|
import { IItemLinkType } from '../models/itemlink.type';
|
||||||
|
import { IUrlType } from '../models/url.type';
|
||||||
import { IItem } from '../models/item';
|
import { IItem } from '../models/item';
|
||||||
import { IJsonline } from '../models/json-line';
|
import { IJsonline } from '../models/json-line';
|
||||||
import { IItemTask } from '../models/itemTask';
|
import { IItemTask } from '../models/itemTask';
|
||||||
import { HttpClient, HttpParams,HttpHeaders } from "@angular/common/http";
|
import { HttpClient, HttpParams,HttpHeaders } from "@angular/common/http";
|
||||||
import { AppConfig } from "../shared/app.config";
|
import { AppConfig } from "../shared/app.config";
|
||||||
import {ItemTypeService} from './itemtype.service';
|
import {ItemTypeService} from './itemtype.service';
|
||||||
|
import {IListItem} from '../models/list.item';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -25,7 +28,7 @@ export class ItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFeatures(extent: number[], crs: string, searchText?: string, searchTags?:string,startDate?:Date,endDate?:Date,itemType?:string,parentCode?:string,dataFilter?:string,level?:number,indexed?:boolean): Observable<any> {
|
getFeatures(extent: number[], crs: string, searchText?: string, searchTags?:string,startDate?:Date,endDate?:Date,itemType?:string,parentCode?:string,dataFilter?:string,level?:number,indexed?:boolean): Observable<any> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("crs", crs);
|
params = params.append("crs", crs);
|
||||||
if (extent) params =params.append("bbox", extent.join(","));
|
if (extent) params =params.append("bbox", extent.join(","));
|
||||||
if (searchText) params = params.append("q", searchText);
|
if (searchText) params = params.append("q", searchText);
|
||||||
@@ -34,7 +37,7 @@ export class ItemService {
|
|||||||
if (endDate) params = params.append("ed", endDate.toISOString());
|
if (endDate) params = params.append("ed", endDate.toISOString());
|
||||||
if (itemType) {
|
if (itemType) {
|
||||||
params = params.append("it", itemType);
|
params = params.append("it", itemType);
|
||||||
let extraAttributes = this.itemTypeService.getExtraAttributes(itemType);
|
const extraAttributes = this.itemTypeService.getExtraAttributes(itemType);
|
||||||
if(extraAttributes) {
|
if(extraAttributes) {
|
||||||
params = params.append("da", extraAttributes);
|
params = params.append("da", extraAttributes);
|
||||||
}
|
}
|
||||||
@@ -47,13 +50,13 @@ export class ItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFeature(code:string, crs: string): Observable<any> {
|
getFeature(code:string, crs: string): Observable<any> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("crs", crs);
|
params = params.append("crs", crs);
|
||||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/`, { params: params });
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemFeature(code:string, fid:number, crs: string): Observable<any> {
|
getItemFeature(code:string, fid:number, crs: string): Observable<any> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("crs", crs);
|
params = params.append("crs", crs);
|
||||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/${fid}`, { params: params });
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/${fid}`, { params: params });
|
||||||
}
|
}
|
||||||
@@ -62,8 +65,12 @@ export class ItemService {
|
|||||||
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`);
|
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getItemLink(itemLink: IItemLinkType): Observable<any> {
|
||||||
|
return this.httpClient.post<IItemLinkType>(`${this.ApiEndpoint()}/api/v1/itemlink`,itemLink);
|
||||||
|
}
|
||||||
|
|
||||||
getItemData(code: string,start?:number,size?:number): Observable<ArrayBuffer> {
|
getItemData(code: string,start?:number,size?:number): Observable<ArrayBuffer> {
|
||||||
var headers = new HttpHeaders();
|
let headers = new HttpHeaders();
|
||||||
if(start !== undefined && size !== undefined) headers=headers.set("Range",`bytes=${start}-${size-1}`);
|
if(start !== undefined && size !== undefined) headers=headers.set("Range",`bytes=${start}-${size-1}`);
|
||||||
return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/data`,{ headers: headers,responseType: 'arraybuffer' });
|
return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/data`,{ headers: headers,responseType: 'arraybuffer' });
|
||||||
}
|
}
|
||||||
@@ -72,20 +79,22 @@ export class ItemService {
|
|||||||
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}/${itemType}`);
|
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}/${itemType}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean): Observable<IItem[]> {
|
getItemList(itemType?: string, dataFilter?: any, level?: number, atItemLocationItemCode?: string, indexed?: boolean, validToday?: boolean,tags?:string,crs?:string): Observable<IItem[]> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
if(itemType) params = params.append("it", itemType);
|
if(itemType) params = params.append("it", itemType);
|
||||||
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
|
if(dataFilter) params = params.append("df", JSON.stringify(dataFilter));
|
||||||
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
|
if(atItemLocationItemCode) params = params.append("ail",atItemLocationItemCode);
|
||||||
if(indexed) params = params.append("ind",indexed?"true":"false");
|
if(indexed) params = params.append("ind",indexed?"true":"false");
|
||||||
if (level) params = params.append("lvl", level.toFixed());
|
if (level) params = params.append("lvl", level.toFixed());
|
||||||
if (validToday) params = params.append("vt", validToday ? "true" : "false");
|
if (validToday) params = params.append("vt", validToday ? "true" : "false");
|
||||||
|
if (tags) params = params.append("t", tags);
|
||||||
|
if (crs) params = params.append("crs", crs);
|
||||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params });
|
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level: number = 1, deep: boolean = true,
|
getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level = 1, deep = true,
|
||||||
startDate?: Date, endDate?: Date): Observable<IItem[]> {
|
startDate?: Date, endDate?: Date, skip?: number, take?: number): Observable<IItem[]> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
if(itemType != null) {
|
if(itemType != null) {
|
||||||
params = params.append("it", itemType);
|
params = params.append("it", itemType);
|
||||||
}
|
}
|
||||||
@@ -96,20 +105,23 @@ export class ItemService {
|
|||||||
params = params.append("deep", deep.toString());
|
params = params.append("deep", deep.toString());
|
||||||
if (startDate) params = params.append("sDate", startDate.toISOString());
|
if (startDate) params = params.append("sDate", startDate.toISOString());
|
||||||
if (endDate) params = params.append("eDate", endDate.toISOString());
|
if (endDate) params = params.append("eDate", endDate.toISOString());
|
||||||
|
|
||||||
|
if(skip) params = params.append("skip", skip);
|
||||||
|
if(take) params = params.append("take", take);
|
||||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
|
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildItemListCount(parentcode: string, itemType: string,dataFilter?: any): Observable<Number> {
|
getChildItemListCount(parentcode: string, itemType: string,dataFilter?: any): Observable<number> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("it", itemType);
|
params = params.append("it", itemType);
|
||||||
if (dataFilter != null) {
|
if (dataFilter != null) {
|
||||||
params = params.append("df", JSON.stringify(dataFilter));
|
params = params.append("df", JSON.stringify(dataFilter));
|
||||||
}
|
}
|
||||||
return this.httpClient.get<Number>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children/count`, { params: params });
|
return this.httpClient.get<number>(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children/count`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildItemListByExtent(parentcode: string, itemType: string, extent: number[], crs: string, dataFilter?: any, level: number = 1): Observable<IItem[]> {
|
getChildItemListByExtent(parentcode: string, itemType: string, extent: number[], crs: string, dataFilter?: any, level = 1): Observable<IItem[]> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("it", itemType);
|
params = params.append("it", itemType);
|
||||||
params = params.append("bbox", extent.join(","));
|
params = params.append("bbox", extent.join(","));
|
||||||
params = params.append("crs", crs);
|
params = params.append("crs", crs);
|
||||||
@@ -121,7 +133,7 @@ export class ItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable<any> {
|
getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable<any> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("crs", crs);
|
params = params.append("crs", crs);
|
||||||
if(extent != null) {
|
if(extent != null) {
|
||||||
params = params.append("bbox", extent.join(","));
|
params = params.append("bbox", extent.join(","));
|
||||||
@@ -153,7 +165,7 @@ export class ItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTemporal(code: string, startDate?: Date, endDate?: Date): Observable<any> {
|
getTemporal(code: string, startDate?: Date, endDate?: Date): Observable<any> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
if (startDate) params = params.append("sd", startDate.toISOString());
|
if (startDate) params = params.append("sd", startDate.toISOString());
|
||||||
if (endDate) params = params.append("ed", endDate.toISOString());
|
if (endDate) params = params.append("ed", endDate.toISOString());
|
||||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/`, { params: params });
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/`, { params: params });
|
||||||
@@ -164,21 +176,25 @@ export class ItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemTaskList(itemcode: string, unfinishedOnly?: boolean): Observable<IItemTask[]> {
|
getItemTaskList(itemcode: string, unfinishedOnly?: boolean): Observable<IItemTask[]> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
if (unfinishedOnly) params = params.append("unfinishedOnly", unfinishedOnly.toString());
|
if (unfinishedOnly) params = params.append("unfinishedOnly", unfinishedOnly.toString());
|
||||||
return this.httpClient.get<IItemTask[]>(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params });
|
return this.httpClient.get<IItemTask[]>(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getItemListUsingRelationship(itemType: string, relationshipItemType: string, relationshipDataFilter: any): Observable<IItem[]> {
|
getItemListUsingRelationship(itemType: string, relationshipItemType: string, relationshipDataFilter: any): Observable<IItem[]> {
|
||||||
var params = new HttpParams();
|
let params = new HttpParams();
|
||||||
params = params.append("it", itemType);
|
params = params.append("it", itemType);
|
||||||
params = params.append("rsit", relationshipItemType);
|
params = params.append("rsit", relationshipItemType);
|
||||||
params = params.append("rsdf", JSON.stringify(relationshipDataFilter));
|
params = params.append("rsdf", JSON.stringify(relationshipDataFilter));
|
||||||
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/userelationship`, { params: params });
|
return this.httpClient.get<IItem[]>(`${this.ApiEndpoint()}/api/v1/items/userelationship`, { params: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayerValue(itemCode: string, layerIndex:number,x:number,y:number,crs:string = "EPSG:3857"): Observable<number> {
|
getLayerValue(itemCode: string, layerIndex:number,x:number,y:number,crs = "EPSG:3857"): Observable<number> {
|
||||||
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${itemCode}/value/layer/${layerIndex}?c=${x},${y}&crs=${crs}`);
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${itemCode}/value/layer/${layerIndex}?c=${x},${y}&crs=${crs}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBreadcrumbs(itemCode: string): Observable<IListItem[]> {
|
||||||
|
return this.httpClient.get<any>(`${this.ApiEndpoint()}/api/v1/items/${itemCode}/breadcrumbs`);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -14,19 +14,19 @@ export class ItemTypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getIcon(itemType: string) {
|
getIcon(itemType: string) {
|
||||||
var icon = "fal fa-file";
|
let icon = "fal fa-file";
|
||||||
if (this.itemTypes[itemType]) icon = this.itemTypes[itemType].icon;
|
if (this.itemTypes[itemType]) icon = this.itemTypes[itemType].icon;
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
getColor(itemType: string) {
|
getColor(itemType: string) {
|
||||||
var color = "#000000";
|
let color = "#000000";
|
||||||
if (this.itemTypes[itemType]) color = this.itemTypes[itemType].iconColor;
|
if (this.itemTypes[itemType]) color = this.itemTypes[itemType].iconColor;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
getExtraAttributes(itemType: string) {
|
getExtraAttributes(itemType: string) {
|
||||||
var extraAttributes = null;
|
let extraAttributes = null;
|
||||||
if (this.itemTypes[itemType]) extraAttributes = this.itemTypes[itemType].extraAttributes;
|
if (this.itemTypes[itemType]) extraAttributes = this.itemTypes[itemType].extraAttributes;
|
||||||
return extraAttributes;
|
return extraAttributes;
|
||||||
}
|
}
|
||||||
@@ -38,25 +38,25 @@ export class ItemTypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasViewer(item: IItem) {
|
hasViewer(item: IItem) {
|
||||||
let itemType: string = item.itemType;
|
const itemType: string = item.itemType;
|
||||||
if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined;
|
if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasEditor(item: IItem) {
|
hasEditor(item: IItem) {
|
||||||
let itemType: string = item.itemType;
|
const itemType: string = item.itemType;
|
||||||
if (this.itemTypes[itemType]) return this.itemTypes[itemType].editor !== undefined;
|
if (this.itemTypes[itemType]) return this.itemTypes[itemType].editor !== undefined;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
isLayer(item: IItem) {
|
isLayer(item: IItem) {
|
||||||
let itemType: string = item.itemType;
|
const itemType: string = item.itemType;
|
||||||
return itemType == "vnd.farmmaps.itemtype.geotiff.processed" || itemType == "vnd.farmmaps.itemtype.layer" || itemType == "vnd.farmmaps.itemtype.shape.processed";
|
return itemType == "vnd.farmmaps.itemtype.geotiff.processed" || itemType == "vnd.farmmaps.itemtype.layer" || itemType == "vnd.farmmaps.itemtype.shape.processed";
|
||||||
}
|
}
|
||||||
|
|
||||||
public load(config:AppConfig): Promise<any> {
|
public load(config:AppConfig): Promise<any> {
|
||||||
if(this.itemTypes==null) {
|
if(this.itemTypes==null) {
|
||||||
var url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/`
|
const url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/`
|
||||||
return this.httpClient.get(url)
|
return this.httpClient.get(url)
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then((itemTypes:IItemTypes) => {
|
.then((itemTypes:IItemTypes) => {
|
||||||
@@ -67,5 +67,5 @@ export class ItemTypeService {
|
|||||||
} else {
|
} else {
|
||||||
return new Promise<void>((resolve) => {resolve()});
|
return new Promise<void>((resolve) => {resolve()});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user