Compare commits
	
		
			10 Commits
		
	
	
		
			AW-4620
			...
			98142fab56
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					98142fab56 | ||
| 
						 | 
					c460d31522 | ||
| 
						 | 
					4c5b89852b | ||
| 
						 | 
					fa90eaf1af | ||
| aeded938bd | |||
| c61a4fe7f4 | |||
| 8c3c40cfe6 | |||
| e6e10c835e | |||
| 07a87175b4 | |||
| e9ace73ddd | 
							
								
								
									
										125
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										125
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,12 +1,12 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "farmmaps-lib-app",
 | 
			
		||||
  "version": "3.0.0",
 | 
			
		||||
  "version": "3.0.1",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "farmmaps-lib-app",
 | 
			
		||||
      "version": "3.0.0",
 | 
			
		||||
      "version": "3.0.1",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@angular/animations": "^14.1.3",
 | 
			
		||||
        "@angular/common": "^14.1.3",
 | 
			
		||||
@@ -40,7 +40,7 @@
 | 
			
		||||
        "ngx-image-cropper": "^3.3.5",
 | 
			
		||||
        "ngx-openlayers": "1.0.0-next.19",
 | 
			
		||||
        "ngx-uploadx": "^5.2.0",
 | 
			
		||||
        "ol": "6.14.1",
 | 
			
		||||
        "ol": "7.2.2",
 | 
			
		||||
        "olcs": "^2.13.1",
 | 
			
		||||
        "resumablejs": "^1.1.0",
 | 
			
		||||
        "rxjs": "^6.6.7",
 | 
			
		||||
@@ -79,18 +79,59 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "dist/common": {
 | 
			
		||||
      "name": "@farmmaps/common",
 | 
			
		||||
      "version": "2.0.0",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "tslib": "^2.3.0"
 | 
			
		||||
      },
 | 
			
		||||
      "peerDependencies": {
 | 
			
		||||
        "@angular/common": ">=14.0.0",
 | 
			
		||||
        "@angular/core": ">=14.0.0",
 | 
			
		||||
        "@angular/forms": ">=14.0.0",
 | 
			
		||||
        "@microsoft/signalr": ">=3.1.3",
 | 
			
		||||
        "@ng-bootstrap/ng-bootstrap": ">=10.0.0",
 | 
			
		||||
        "@ngrx/effects": ">=14.0.0",
 | 
			
		||||
        "@ngrx/router-store": ">=14.0.0",
 | 
			
		||||
        "@ngrx/store": ">=14.0.0",
 | 
			
		||||
        "angular-oauth2-oidc": ">=13.0.0",
 | 
			
		||||
        "bootstrap": ">=4.4.1",
 | 
			
		||||
        "moment": ">=2.27.0",
 | 
			
		||||
        "ngx-avatar": ">=4.1.0",
 | 
			
		||||
        "ngx-clipboard": ">=14.0.1",
 | 
			
		||||
        "ngx-image-cropper": ">=3.3.5",
 | 
			
		||||
        "ngx-uploadx": ">=5.1.0",
 | 
			
		||||
        "tassign": ">=1.0.0"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "dist/common-map": {
 | 
			
		||||
      "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"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "dist/common-map3d": {
 | 
			
		||||
      "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/@adobe/css-tools": {
 | 
			
		||||
@@ -2866,9 +2907,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/@mapbox/mapbox-gl-style-spec": {
 | 
			
		||||
      "version": "13.26.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.26.0.tgz",
 | 
			
		||||
      "integrity": "sha512-Ya1WiNz1qYau7xPYPQUbionrw9pjgZAIebGQdDXgwJuSAWeVCr02P7rqbYFHbXqX5TeAaq4qVpcaJb9oZtgaVQ==",
 | 
			
		||||
      "version": "13.28.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.28.0.tgz",
 | 
			
		||||
      "integrity": "sha512-B8xM7Fp1nh5kejfIl4SWeY0gtIeewbuRencqO3cJDrCHZpaPg7uY+V8abuR+esMeuOjRl5cLhVTP40v+1ywxbg==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@mapbox/jsonlint-lines-primitives": "~2.0.2",
 | 
			
		||||
        "@mapbox/point-geometry": "^0.1.0",
 | 
			
		||||
@@ -9632,9 +9673,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/mapbox-to-css-font": {
 | 
			
		||||
      "version": "2.4.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/mapbox-to-css-font/-/mapbox-to-css-font-2.4.1.tgz",
 | 
			
		||||
      "integrity": "sha512-QQ/iKiM43DM9+aujTL45Iz5o7gDeSFmy4LPl3HZmNcwCE++NxGazf+yFpY+wCb+YS23sDa1ghpo3zrNFOcHlow=="
 | 
			
		||||
      "version": "2.4.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/mapbox-to-css-font/-/mapbox-to-css-font-2.4.2.tgz",
 | 
			
		||||
      "integrity": "sha512-f+NBjJJY4T3dHtlEz1wCG7YFlkODEjFIYlxDdLIDMNpkSksqTt+l/d4rjuwItxuzkuMFvPyrjzV2lxRM4ePcIA=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/media-typer": {
 | 
			
		||||
      "version": "0.3.0",
 | 
			
		||||
@@ -10604,12 +10645,13 @@
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/ol": {
 | 
			
		||||
      "version": "6.14.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol/-/ol-6.14.1.tgz",
 | 
			
		||||
      "integrity": "sha512-sIcUWkGud3Y2gT3TJubSHlkyMXiPVh1yxfCPHxmY8+qtm79bB9oRnei9xHVIbRRG0Ro6Ldp5E+BMVSvYCxSpaA==",
 | 
			
		||||
      "version": "7.2.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol/-/ol-7.2.2.tgz",
 | 
			
		||||
      "integrity": "sha512-eqJ1hhVQQ3Ap4OhYq9DRu5pz9RMpLhmoTauDoIqpn7logVi1AJE+lXjEHrPrTSuZYjtFbMgqr07sxoLNR65nrw==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "geotiff": "^2.0.2",
 | 
			
		||||
        "ol-mapbox-style": "^7.1.1",
 | 
			
		||||
        "earcut": "^2.2.3",
 | 
			
		||||
        "geotiff": "^2.0.7",
 | 
			
		||||
        "ol-mapbox-style": "^9.2.0",
 | 
			
		||||
        "pbf": "3.2.1",
 | 
			
		||||
        "rbush": "^3.0.1"
 | 
			
		||||
      },
 | 
			
		||||
@@ -10619,13 +10661,12 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/ol-mapbox-style": {
 | 
			
		||||
      "version": "7.1.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-7.1.1.tgz",
 | 
			
		||||
      "integrity": "sha512-GLTEYiH/Ec9Zn1eS4S/zXyR2sierVrUc+OLVP8Ra0FRyqRhoYbXdko0b7OIeSHWdtJfHssWYefDOGxfTRUUZ/A==",
 | 
			
		||||
      "version": "9.6.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-9.6.0.tgz",
 | 
			
		||||
      "integrity": "sha512-5XK1fAikf2q6gFozsdrRUCfRgKeQEj7EORECAb7zzi91MXL97AjSUSaKCMzNXtKhm2yyXx4jQth9KsF5h658Iw==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@mapbox/mapbox-gl-style-spec": "^13.20.1",
 | 
			
		||||
        "mapbox-to-css-font": "^2.4.1",
 | 
			
		||||
        "webfont-matcher": "^1.1.0"
 | 
			
		||||
        "@mapbox/mapbox-gl-style-spec": "^13.23.1",
 | 
			
		||||
        "mapbox-to-css-font": "^2.4.1"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/olcs": {
 | 
			
		||||
@@ -14978,11 +15019,6 @@
 | 
			
		||||
        "node": ">=0.8.0"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/webfont-matcher": {
 | 
			
		||||
      "version": "1.1.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/webfont-matcher/-/webfont-matcher-1.1.0.tgz",
 | 
			
		||||
      "integrity": "sha512-ov8lMvF9wi4PD7fK2Axn9PQEpO9cYI0fIoGqErwd+wi8xacFFDmX114D5Q2Lw0Wlgmb+Qw/dKI2KTtimrJf85g=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/webpack": {
 | 
			
		||||
      "version": "5.74.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.74.0.tgz",
 | 
			
		||||
@@ -17401,9 +17437,9 @@
 | 
			
		||||
      "integrity": "sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ=="
 | 
			
		||||
    },
 | 
			
		||||
    "@mapbox/mapbox-gl-style-spec": {
 | 
			
		||||
      "version": "13.26.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.26.0.tgz",
 | 
			
		||||
      "integrity": "sha512-Ya1WiNz1qYau7xPYPQUbionrw9pjgZAIebGQdDXgwJuSAWeVCr02P7rqbYFHbXqX5TeAaq4qVpcaJb9oZtgaVQ==",
 | 
			
		||||
      "version": "13.28.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.28.0.tgz",
 | 
			
		||||
      "integrity": "sha512-B8xM7Fp1nh5kejfIl4SWeY0gtIeewbuRencqO3cJDrCHZpaPg7uY+V8abuR+esMeuOjRl5cLhVTP40v+1ywxbg==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "@mapbox/jsonlint-lines-primitives": "~2.0.2",
 | 
			
		||||
        "@mapbox/point-geometry": "^0.1.0",
 | 
			
		||||
@@ -22502,9 +22538,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "mapbox-to-css-font": {
 | 
			
		||||
      "version": "2.4.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/mapbox-to-css-font/-/mapbox-to-css-font-2.4.1.tgz",
 | 
			
		||||
      "integrity": "sha512-QQ/iKiM43DM9+aujTL45Iz5o7gDeSFmy4LPl3HZmNcwCE++NxGazf+yFpY+wCb+YS23sDa1ghpo3zrNFOcHlow=="
 | 
			
		||||
      "version": "2.4.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/mapbox-to-css-font/-/mapbox-to-css-font-2.4.2.tgz",
 | 
			
		||||
      "integrity": "sha512-f+NBjJJY4T3dHtlEz1wCG7YFlkODEjFIYlxDdLIDMNpkSksqTt+l/d4rjuwItxuzkuMFvPyrjzV2lxRM4ePcIA=="
 | 
			
		||||
    },
 | 
			
		||||
    "media-typer": {
 | 
			
		||||
      "version": "0.3.0",
 | 
			
		||||
@@ -23224,24 +23260,24 @@
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "ol": {
 | 
			
		||||
      "version": "6.14.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol/-/ol-6.14.1.tgz",
 | 
			
		||||
      "integrity": "sha512-sIcUWkGud3Y2gT3TJubSHlkyMXiPVh1yxfCPHxmY8+qtm79bB9oRnei9xHVIbRRG0Ro6Ldp5E+BMVSvYCxSpaA==",
 | 
			
		||||
      "version": "7.2.2",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol/-/ol-7.2.2.tgz",
 | 
			
		||||
      "integrity": "sha512-eqJ1hhVQQ3Ap4OhYq9DRu5pz9RMpLhmoTauDoIqpn7logVi1AJE+lXjEHrPrTSuZYjtFbMgqr07sxoLNR65nrw==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "geotiff": "^2.0.2",
 | 
			
		||||
        "ol-mapbox-style": "^7.1.1",
 | 
			
		||||
        "earcut": "^2.2.3",
 | 
			
		||||
        "geotiff": "^2.0.7",
 | 
			
		||||
        "ol-mapbox-style": "^9.2.0",
 | 
			
		||||
        "pbf": "3.2.1",
 | 
			
		||||
        "rbush": "^3.0.1"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "ol-mapbox-style": {
 | 
			
		||||
      "version": "7.1.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-7.1.1.tgz",
 | 
			
		||||
      "integrity": "sha512-GLTEYiH/Ec9Zn1eS4S/zXyR2sierVrUc+OLVP8Ra0FRyqRhoYbXdko0b7OIeSHWdtJfHssWYefDOGxfTRUUZ/A==",
 | 
			
		||||
      "version": "9.6.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-9.6.0.tgz",
 | 
			
		||||
      "integrity": "sha512-5XK1fAikf2q6gFozsdrRUCfRgKeQEj7EORECAb7zzi91MXL97AjSUSaKCMzNXtKhm2yyXx4jQth9KsF5h658Iw==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "@mapbox/mapbox-gl-style-spec": "^13.20.1",
 | 
			
		||||
        "mapbox-to-css-font": "^2.4.1",
 | 
			
		||||
        "webfont-matcher": "^1.1.0"
 | 
			
		||||
        "@mapbox/mapbox-gl-style-spec": "^13.23.1",
 | 
			
		||||
        "mapbox-to-css-font": "^2.4.1"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "olcs": {
 | 
			
		||||
@@ -26434,11 +26470,6 @@
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "webfont-matcher": {
 | 
			
		||||
      "version": "1.1.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/webfont-matcher/-/webfont-matcher-1.1.0.tgz",
 | 
			
		||||
      "integrity": "sha512-ov8lMvF9wi4PD7fK2Axn9PQEpO9cYI0fIoGqErwd+wi8xacFFDmX114D5Q2Lw0Wlgmb+Qw/dKI2KTtimrJf85g=="
 | 
			
		||||
    },
 | 
			
		||||
    "webpack": {
 | 
			
		||||
      "version": "5.74.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.74.0.tgz",
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,7 @@
 | 
			
		||||
    "ngx-image-cropper": "^3.3.5",
 | 
			
		||||
    "ngx-openlayers": "1.0.0-next.19",
 | 
			
		||||
    "ngx-uploadx": "^5.2.0",
 | 
			
		||||
    "ol": "6.14.1",
 | 
			
		||||
    "ol": "7.2.2",
 | 
			
		||||
    "olcs": "^2.13.1",
 | 
			
		||||
    "resumablejs": "^1.1.0",
 | 
			
		||||
    "rxjs": "^6.6.7",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
import { Component, Host, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, forwardRef, Inject, InjectionToken } from '@angular/core';
 | 
			
		||||
import { LayerVectorComponent, SourceVectorComponent, MapComponent } from 'ngx-openlayers';
 | 
			
		||||
import { ItemService,ItemTypeService,IItem, IItemType } from '@farmmaps/common';
 | 
			
		||||
import { ItemService, ItemTypeService, IItem, IItemType } from '@farmmaps/common';
 | 
			
		||||
 | 
			
		||||
import { Feature } from 'ol';
 | 
			
		||||
import { Point,Geometry } from 'ol/geom';
 | 
			
		||||
import { Point, Geometry } from 'ol/geom';
 | 
			
		||||
import { MapBrowserEvent } from 'ol';
 | 
			
		||||
import { Types } from 'ol/MapBrowserEventType';
 | 
			
		||||
import * as style from 'ol/style';
 | 
			
		||||
@@ -11,18 +11,18 @@ import * as color from 'ol/color';
 | 
			
		||||
import * as loadingstrategy from 'ol/loadingstrategy';
 | 
			
		||||
import * as condition from 'ol/events/condition';
 | 
			
		||||
import * as extent from 'ol/extent';
 | 
			
		||||
import {Vector,Cluster,Source} from 'ol/source';
 | 
			
		||||
import {Layer} from 'ol/layer';
 | 
			
		||||
import {GeoJSON} from 'ol/format';
 | 
			
		||||
import {Select} from 'ol/interaction';
 | 
			
		||||
import {IStyles} from '../../../models/style.cache';
 | 
			
		||||
import {FeatureIconService} from '../../../services/feature-icon.service';
 | 
			
		||||
import { Vector, Cluster, Source } from 'ol/source';
 | 
			
		||||
import { Layer } from 'ol/layer';
 | 
			
		||||
import { GeoJSON } from 'ol/format';
 | 
			
		||||
import { Select } from 'ol/interaction';
 | 
			
		||||
import { IStyles } from '../../../models/style.cache';
 | 
			
		||||
import { FeatureIconService } from '../../../services/feature-icon.service';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'fm-map-item-source-vector',
 | 
			
		||||
  template: `<ng-content></ng-content>`,
 | 
			
		||||
  providers: [
 | 
			
		||||
    { provide: SourceVectorComponent , useExisting: forwardRef(() => ItemVectorSourceComponent) }
 | 
			
		||||
    { provide: SourceVectorComponent, useExisting: forwardRef(() => ItemVectorSourceComponent) }
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges {
 | 
			
		||||
@@ -34,12 +34,12 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
  @Input() features: Array<Feature<Geometry>>;
 | 
			
		||||
  @Input() selectedFeature: Feature<Geometry>;
 | 
			
		||||
  @Input() selectedItem: IItem;
 | 
			
		||||
  @Input() styles:IStyles;
 | 
			
		||||
  @Input() styles: IStyles;
 | 
			
		||||
  @Output() onFeatureSelected: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
 | 
			
		||||
  @Output() onFeatureHover: EventEmitter<Feature<Geometry>> = new EventEmitter<Feature<Geometry>>();
 | 
			
		||||
  private stylesCache:IStyles = {};
 | 
			
		||||
  private stylesCache: IStyles = {};
 | 
			
		||||
 | 
			
		||||
  constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) {
 | 
			
		||||
  constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, private map: MapComponent, private itemTypeService: ItemTypeService, private featureIconService$: FeatureIconService) {
 | 
			
		||||
    super(layer);
 | 
			
		||||
    this._format = new GeoJSON();
 | 
			
		||||
  }
 | 
			
		||||
@@ -56,12 +56,12 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
    return geometry;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getSelectedStyle(feature:Feature<Geometry>):style.Style {
 | 
			
		||||
    let key = feature.get('itemType')+"_selected";
 | 
			
		||||
    let evaluatedStyle: style.Style =undefined;
 | 
			
		||||
  getSelectedStyle(feature: Feature<Geometry>): style.Style {
 | 
			
		||||
    let key = feature.get('itemType') + "_selected";
 | 
			
		||||
    let evaluatedStyle: style.Style = undefined;
 | 
			
		||||
    var styleEntry = this.stylesCache[key];
 | 
			
		||||
    if(styleEntry) {
 | 
			
		||||
      if(typeof styleEntry === 'function')  {
 | 
			
		||||
    if (styleEntry) {
 | 
			
		||||
      if (typeof styleEntry === 'function') {
 | 
			
		||||
        evaluatedStyle = styleEntry(feature);
 | 
			
		||||
      } else {
 | 
			
		||||
        evaluatedStyle = styleEntry;
 | 
			
		||||
@@ -69,8 +69,8 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
    } else {
 | 
			
		||||
      evaluatedStyle = this.stylesCache["selected"] as style.Style;
 | 
			
		||||
    }
 | 
			
		||||
    if(evaluatedStyle ) {
 | 
			
		||||
      evaluatedStyle .setGeometry((feature:Feature<Geometry>) => this.geometry(feature));
 | 
			
		||||
    if (evaluatedStyle) {
 | 
			
		||||
      evaluatedStyle.setGeometry((feature: Feature<Geometry>) => this.geometry(feature));
 | 
			
		||||
    }
 | 
			
		||||
    return evaluatedStyle as style.Style
 | 
			
		||||
  }
 | 
			
		||||
@@ -79,12 +79,12 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
    this.strategy = loadingstrategy.bbox;
 | 
			
		||||
    this.format = new GeoJSON();
 | 
			
		||||
    this._select = new Select({
 | 
			
		||||
      style:null,
 | 
			
		||||
      style: null,
 | 
			
		||||
      hitTolerance: 10,
 | 
			
		||||
      layers: [this.layer.instance as Layer<Source>]
 | 
			
		||||
    });
 | 
			
		||||
    this._hoverSelect = new Select({
 | 
			
		||||
      style: (feature:Feature<Geometry>) => {        
 | 
			
		||||
      style: (feature: Feature<Geometry>) => {
 | 
			
		||||
        return this.getSelectedStyle(feature);
 | 
			
		||||
      },
 | 
			
		||||
      hitTolerance: 10,
 | 
			
		||||
@@ -114,7 +114,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
 | 
			
		||||
    this.host.instance.setStyle((feature) => {
 | 
			
		||||
      var itemType = feature.get('itemType');
 | 
			
		||||
      var key = itemType + (this.selectedItem?"_I":"");
 | 
			
		||||
      var key = itemType + (this.selectedItem ? "_I" : "");
 | 
			
		||||
      if (!this.stylesCache[key]) {
 | 
			
		||||
        if (this.itemTypeService.itemTypes[itemType]) {
 | 
			
		||||
          let itemTypeEntry = this.itemTypeService.itemTypes[itemType];
 | 
			
		||||
@@ -125,7 +125,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
              anchor: [0.5, 1],
 | 
			
		||||
              scale: 0.05,
 | 
			
		||||
              src: this.featureIconService$.getIconImageDataUrl(itemTypeEntry.icon)
 | 
			
		||||
                }):null,
 | 
			
		||||
            }) : null,
 | 
			
		||||
            stroke: new style.Stroke({
 | 
			
		||||
              color: 'red',
 | 
			
		||||
              width: 1
 | 
			
		||||
@@ -133,20 +133,20 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
            fill: new style.Fill({
 | 
			
		||||
              color: fillColor
 | 
			
		||||
            }),
 | 
			
		||||
              geometry:(feature:Feature<Geometry>) => this.geometry(feature)
 | 
			
		||||
            geometry: (feature: Feature<Geometry>) => this.geometry(feature)
 | 
			
		||||
          });
 | 
			
		||||
        } else {
 | 
			
		||||
          key = 'file';
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      let evaluatedStyle =null;
 | 
			
		||||
      let evaluatedStyle = null;
 | 
			
		||||
      var styleEntry = this.stylesCache[key];
 | 
			
		||||
      if(typeof styleEntry === 'function')  {
 | 
			
		||||
      if (typeof styleEntry === 'function') {
 | 
			
		||||
        evaluatedStyle = styleEntry(feature);
 | 
			
		||||
      } else {
 | 
			
		||||
        evaluatedStyle = styleEntry;
 | 
			
		||||
      }
 | 
			
		||||
      if(evaluatedStyle && evaluatedStyle.geometry_ == null) {
 | 
			
		||||
      if (evaluatedStyle && evaluatedStyle.geometry_ == null && !Array.isArray(evaluatedStyle)) {
 | 
			
		||||
        evaluatedStyle.setGeometry((feature) => this.geometry(feature));
 | 
			
		||||
      }
 | 
			
		||||
      return evaluatedStyle;
 | 
			
		||||
@@ -179,11 +179,11 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
 | 
			
		||||
        this.map.instance.addInteraction(this._hoverSelect);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (changes["styles"] && this.instance) {
 | 
			
		||||
    if (changes["styles"]) {
 | 
			
		||||
      let styles = changes["styles"].currentValue;
 | 
			
		||||
      for (const key in styles) {
 | 
			
		||||
        if (styles.hasOwnProperty(key)) {
 | 
			
		||||
          this.stylesCache[key]=styles[key]; 
 | 
			
		||||
          this.stylesCache[key] = styles[key];
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
    <td colspan="4" class="pb-1 pt-1">
 | 
			
		||||
      <div class="info" [ngbCollapse]="hideHistogramDetails">
 | 
			
		||||
        <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-template #histogram>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,23 +2,23 @@
 | 
			
		||||
  <div class="col-8 nopadding"><span i18n>Data points</span>:</div>
 | 
			
		||||
  <div class="col-4 pull-left nopadding">{{statistics.populationCount}}</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-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-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-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-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-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-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-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-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-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-4 pull-left nopadding">{{statistics.variationCoefficient | number:'1.0-2'}}</div>
 | 
			
		||||
  <ng-container *ngIf="statistics.confidenceIntervalLow !== undefined">
 | 
			
		||||
    <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>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
import {Component, Input} from '@angular/core';
 | 
			
		||||
import {IStatistics} from '../../../models/color.map';
 | 
			
		||||
import { Component, Input } from '@angular/core';
 | 
			
		||||
import { IStatistics } from '../../../models/color.map';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'fm-map-statistics-details',
 | 
			
		||||
@@ -13,4 +13,23 @@ export class StatisticsDetailsComponent {
 | 
			
		||||
 | 
			
		||||
  @Input()
 | 
			
		||||
  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;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ import { SchemaService } from './services/schema.service';
 | 
			
		||||
import { FolderService } from './services/folder.service';
 | 
			
		||||
import { TimespanService } from './services/timespan.service';
 | 
			
		||||
import { ItemService } from './services/item.service';
 | 
			
		||||
import { AdminService } from './services/admin.service';
 | 
			
		||||
import { EventService } from './services/event.service';
 | 
			
		||||
import { TypeaheadService } from './services/typeahead.service';
 | 
			
		||||
import { UserService } from './services/user.service';
 | 
			
		||||
@@ -42,6 +43,7 @@ export {
 | 
			
		||||
  ItemTypeService,
 | 
			
		||||
  TimespanService,
 | 
			
		||||
  ItemService,
 | 
			
		||||
  AdminService,
 | 
			
		||||
  EventService,
 | 
			
		||||
  TypeaheadService,
 | 
			
		||||
  UserService,
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,8 @@ import { TagInputComponent } from './components/tag-input/tag-input.component';
 | 
			
		||||
import { MenuBackgroundComponent } from './components/menu-background/menu-background.component';
 | 
			
		||||
import { HasPackageDirective} from './components/has-package/has-package.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 { ThumbnailComponent } from './components/thumbnail/thumbnail.component';
 | 
			
		||||
import { Alert } from './enumerations/alert.enum';
 | 
			
		||||
@@ -85,6 +86,7 @@ export {
 | 
			
		||||
  HasPackageDirective,
 | 
			
		||||
  PackageExistsDirective,
 | 
			
		||||
  HasClaimDirective,
 | 
			
		||||
  HasRoleDirective,
 | 
			
		||||
  Alert,
 | 
			
		||||
  IEventMessage,
 | 
			
		||||
  IItem,
 | 
			
		||||
@@ -148,6 +150,7 @@ export {
 | 
			
		||||
    HasPackageDirective,
 | 
			
		||||
    PackageExistsDirective,
 | 
			
		||||
    HasClaimDirective,
 | 
			
		||||
    HasRoleDirective,
 | 
			
		||||
    UserMenuComponent,
 | 
			
		||||
    GradientComponent,
 | 
			
		||||
    GradientSelectComponent,
 | 
			
		||||
@@ -179,6 +182,7 @@ export {
 | 
			
		||||
    HasPackageDirective,
 | 
			
		||||
    PackageExistsDirective,
 | 
			
		||||
    HasClaimDirective,
 | 
			
		||||
    HasRoleDirective,
 | 
			
		||||
    UserMenuComponent,
 | 
			
		||||
    GradientComponent,
 | 
			
		||||
    GradientSelectComponent,
 | 
			
		||||
 
 | 
			
		||||
@@ -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() };
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -59,10 +59,7 @@ export function reducer(state = initialState, action: appCommonActions.Actions )
 | 
			
		||||
    }
 | 
			
		||||
    case appCommonActions.INITUSERSUCCESS: {
 | 
			
		||||
      let a = action as appCommonActions.InitUserSuccess;
 | 
			
		||||
      let claims = {}
 | 
			
		||||
      Object.getOwnPropertyNames(a.userinfo.info).forEach((k) => {
 | 
			
		||||
         claims[k] = a.userinfo[k];
 | 
			
		||||
      });
 | 
			
		||||
      let claims = { ...a.userinfo.info };
 | 
			
		||||
      var user:IUser = {
 | 
			
		||||
        code:a.user.code,
 | 
			
		||||
        email:claims["email"]!== undefined ? claims["email"] : a.user.name,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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[]> {
 | 
			
		||||
    var 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}`);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -24,26 +24,33 @@ export class AuthGuard implements CanActivate, CanLoad, CanActivateChild  {
 | 
			
		||||
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
 | 
			
		||||
    let url: string = state.url;
 | 
			
		||||
 | 
			
		||||
    return this.checkLogin(url);
 | 
			
		||||
    return this.checkLogin(url, route);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
 | 
			
		||||
    let url: string = state.url;
 | 
			
		||||
 | 
			
		||||
    return this.checkLogin(url);
 | 
			
		||||
    return this.checkLogin(url, childRoute);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  canLoad(route: Route): Promise<boolean> {
 | 
			
		||||
    return this.checkLogin(route.path);
 | 
			
		||||
    return this.checkLogin(route.path, null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  checkLogin(url: string): Promise<boolean> {
 | 
			
		||||
  checkLogin(url: string, route: ActivatedRouteSnapshot): Promise<boolean> {
 | 
			
		||||
    return new Promise<boolean>((resolve) => {
 | 
			
		||||
      if (!this.oauthService.hasValidAccessToken()) {
 | 
			
		||||
        console.debug("No valid token");
 | 
			
		||||
        this.oauthService.initCodeFlow(url);
 | 
			
		||||
        resolve(false);
 | 
			
		||||
      } else {
 | 
			
		||||
        const requiredRoleClaim = route.data.role;
 | 
			
		||||
        if (!requiredRoleClaim) { resolve(true); }
 | 
			
		||||
        const ownedClaims = this.oauthService.getIdentityClaims();
 | 
			
		||||
        if (!ownedClaims) { resolve(false); }
 | 
			
		||||
        const ownedRoleClaims: string[] = ownedClaims['role'];
 | 
			
		||||
        if (!ownedRoleClaims) { resolve(false); }
 | 
			
		||||
        if (ownedRoleClaims.findIndex(r => r === requiredRoleClaim) <= -1) { resolve(false); }
 | 
			
		||||
        resolve(true);
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								src/app/admin/admin-router.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/app/admin/admin-router.module.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
import { NgModule } from '@angular/core';
 | 
			
		||||
import { RouterModule } from '@angular/router';
 | 
			
		||||
import { AuthGuard } from 'dist/common';
 | 
			
		||||
import { AdminComponent } from './admin.component';
 | 
			
		||||
 | 
			
		||||
const routes = [   
 | 
			
		||||
  {
 | 
			
		||||
      path: '',
 | 
			
		||||
      component: AdminComponent,
 | 
			
		||||
      canActivate: [AuthGuard],
 | 
			
		||||
      data: {
 | 
			
		||||
        role: 'admin'
 | 
			
		||||
      }   
 | 
			
		||||
  }
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
@NgModule({
 | 
			
		||||
  imports: [
 | 
			
		||||
      RouterModule.forChild(routes),
 | 
			
		||||
  ],
 | 
			
		||||
  exports: [
 | 
			
		||||
      RouterModule
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
export class AdminRouterModule { }
 | 
			
		||||
							
								
								
									
										8
									
								
								src/app/admin/admin.component.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/app/admin/admin.component.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
import { Component } from '@angular/core';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-test',
 | 
			
		||||
  template: `<h1>Yes! You have access to the admin component.</h1>`
 | 
			
		||||
})
 | 
			
		||||
export class AdminComponent {
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										14
									
								
								src/app/admin/admin.module.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/app/admin/admin.module.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
import { NgModule } from '@angular/core';
 | 
			
		||||
import { AdminRouterModule} from './admin-router.module';
 | 
			
		||||
import { AdminComponent } from './admin.component';
 | 
			
		||||
 | 
			
		||||
@NgModule({
 | 
			
		||||
  imports: [
 | 
			
		||||
      AdminRouterModule
 | 
			
		||||
  ],
 | 
			
		||||
  declarations: [
 | 
			
		||||
      AdminComponent
 | 
			
		||||
  ]
 | 
			
		||||
})
 | 
			
		||||
  
 | 
			
		||||
export class AdminModule { }
 | 
			
		||||
@@ -65,6 +65,7 @@ const routes = [
 | 
			
		||||
  },
 | 
			
		||||
  { path: 'map', loadChildren: () => import('../../projects/common-map/src/public-api').then(m => m.AppCommonMapModule), canActivateChild: [AuthGuard],canActivate: [FullScreenGuard], },
 | 
			
		||||
  { path: 'map3d', loadChildren: () => import('./map3d/map3d.module').then(m => m.Map3DModule), canActivateChild: [AuthGuard], canActivate: [FullScreenGuard] },
 | 
			
		||||
  { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule), canActivateChild: [AuthGuard], canActivate: [FullScreenGuard], data: { role: 'admin' } },
 | 
			
		||||
  {
 | 
			
		||||
    path: 'registerdevice/:deviceToken',
 | 
			
		||||
    canActivate: [FullScreenGuard],
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
    <div class="card menu-card">
 | 
			
		||||
      <ul class="navbar-nav">
 | 
			
		||||
        <li class="nav-item py-0" *fmHasPackage="'vnd.farmmaps.itemtype.package.agrirouter'"><a [routerLinkActive]="['active']" [routerLink]="['/agrirouter']" class="nav-link"><span><i class="fal fa-plug" aria-hidden="true"></i> <span i18n>agrirouter</span></span></a></li>
 | 
			
		||||
        <li class="nav-item py-0" *fmHasRole="'admin'"><a [routerLinkActive]="['active']" [routerLink]="['/admin']" class="nav-link"><span><i class="fal fa-plug" aria-hidden="true"></i> <span i18n>Admin role</span></span></a></li>
 | 
			
		||||
      </ul>
 | 
			
		||||
    </div> 
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user