From f837f1bf3a898c7feaec7530412a65f69cc62833 Mon Sep 17 00:00:00 2001 From: Peter Bastiani Date: Wed, 10 Jun 2020 13:21:03 +0200 Subject: [PATCH] AW-1301 Initial project based on FarmMapsLib. --- projects/common-map/README.md | 24 - projects/common-map/ng-package.json | 10 - projects/common-map/package-lock.json | 82 --- projects/common-map/package.json | 18 - .../src/fm-map/actions/map.actions.ts | 295 --------- .../src/fm-map/common-map-routing.module.ts | 29 - .../src/fm-map/common-map.module.ts | 276 --------- .../file-drop-target.component.ts | 73 --- .../gps-location/gps-location.component.html | 15 - .../gps-location/gps-location.component.scss | 35 -- .../gps-location/gps-location.component.ts | 72 --- .../item-layers/item-layers.component.js.map | 1 - .../aol/item-layers/item-layers.component.ts | 316 ---------- .../item-vector-source.component.ts | 189 ------ .../aol/layer-list/layer-list.component.html | 31 - .../aol/layer-list/layer-list.component.scss | 18 - .../aol/layer-list/layer-list.component.ts | 64 -- .../layer-vector-image.component.ts | 31 - .../pan-to-location.component.html | 13 - .../pan-to-location.component.scss | 37 -- .../pan-to-location.component.ts | 84 --- .../rotation-reset.component.html | 35 -- .../rotation-reset.component.scss | 67 -- .../rotation-reset.component.ts | 39 -- .../aol/switch2d3d/switch2d3d.component.ts | 40 -- .../zoom-to-extent.component.ts | 39 -- .../feature-list-container.component.html | 3 - .../feature-list-container.component.scss | 18 - .../feature-list-container.component.ts | 74 --- .../feature-list-cropfield.component.html | 14 - .../feature-list-cropfield.component.scss | 22 - .../feature-list-cropfield.component.ts | 30 - ...feature-list-croppingscheme.component.html | 13 - ...feature-list-croppingscheme.component.scss | 22 - .../feature-list-croppingscheme.component.ts | 30 - ...eature-list-feature-container.component.ts | 43 -- ...ture-list-feature-cropfield.component.html | 12 - ...ture-list-feature-cropfield.component.scss | 26 - ...eature-list-feature-cropfield.component.ts | 75 --- ...list-feature-croppingscheme.component.html | 6 - ...list-feature-croppingscheme.component.scss | 29 - ...e-list-feature-croppingscheme.component.ts | 22 - .../feature-list-feature.component.html | 12 - .../feature-list-feature.component.scss | 29 - .../feature-list-feature.component.ts | 29 - .../feature-list/feature-list.component.html | 6 - .../feature-list/feature-list.component.scss | 15 - .../feature-list/feature-list.component.ts | 68 -- .../for-item/for-child.decorator.ts | 5 - .../for-item/for-itemtype.decorator.ts | 5 - .../for-item/for-sourcetask.decorator.js.map | 1 - .../for-item/for-sourcetask.decorator.ts | 5 - .../item-list-item-container.component.ts | 47 -- .../item-list-item.component.html | 4 - .../item-list-item.component.scss | 26 - .../item-list-item.component.ts | 53 -- .../item-list/item-list.component.html | 7 - .../item-list/item-list.component.scss | 41 -- .../item-list/item-list.component.ts | 40 -- .../item-widget-list.component.html | 7 - .../item-widget-list.component.scss | 41 -- .../item-widget-list.component.ts | 38 -- .../layer-switcher.component.html | 25 - .../layer-switcher.component.scss | 71 --- .../layer-switcher.component.ts | 75 --- .../components/legend/legend.component.html | 44 -- .../components/legend/legend.component.scss | 71 --- .../components/legend/legend.component.ts | 96 --- .../map-search/map-search.component.html | 36 -- .../map-search/map-search.component.scss | 122 ---- .../map-search/map-search.component.ts | 178 ------ .../fm-map/components/map/map.component.html | 71 --- .../fm-map/components/map/map.component.scss | 166 ----- .../fm-map/components/map/map.component.ts | 406 ------------ .../meta-data-modal.component.html | 19 - .../meta-data-modal.component.ts | 61 -- .../select-period-modal.component.html | 31 - .../select-period-modal.component.scss | 20 - .../select-period-modal.component.ts | 93 --- .../selected-item-container.component.html | 3 - .../selected-item-container.component.scss | 13 - .../selected-item-container.component.ts | 62 -- .../selected-item-cropfield.component.html | 19 - .../selected-item-cropfield.component.scss | 36 -- .../selected-item-cropfield.component.ts | 43 -- .../selected-item-geotiff.component.html | 30 - .../selected-item-geotiff.component.scss | 41 -- .../selected-item-geotiff.component.ts | 32 - .../selected-item-shape.component.html | 30 - .../selected-item-shape.component.scss | 48 -- .../selected-item-shape.component.ts | 35 -- .../selected-item-temporal.component.html | 43 -- .../selected-item-temporal.component.scss | 41 -- .../selected-item-temporal.component.ts | 80 --- .../selected-item.component.html | 24 - .../selected-item.component.scss | 29 - .../selected-item/selected-item.component.ts | 76 --- .../widget-host/widget-host.directive.ts | 8 - .../widget-status/widget-status.component.css | 0 .../widget-status.component.html | 6 - .../widget-status/widget-status.component.ts | 24 - .../src/fm-map/effects/map.effects.ts | 293 --------- .../src/fm-map/models/color.map.js.map | 1 - .../common-map/src/fm-map/models/color.map.ts | 74 --- .../common-map/src/fm-map/models/index.js.map | 1 - .../src/fm-map/models/item.layer.js.map | 1 - .../src/fm-map/models/item.layer.ts | 50 -- .../src/fm-map/models/layer.data.ts | 6 - .../common-map/src/fm-map/models/map.state.ts | 7 - .../src/fm-map/models/period.state.ts | 4 - .../src/fm-map/models/selected.features.ts | 5 - .../src/fm-map/models/style.cache.ts | 5 - projects/common-map/src/fm-map/module-name.ts | 1 - .../src/fm-map/reducers/map.reducer.ts | 527 ---------------- .../services/device-orientation.service.ts | 51 -- .../fm-map/services/feature-icon.service.ts | 41 -- .../fm-map/services/geolocation.service.ts | 34 - projects/common-map/src/public-api.ts | 5 - projects/common-map/src/test.ts | 22 - projects/common-map/tsconfig.lib.json | 32 - projects/common-map/tsconfig.spec.json | 17 - projects/common-map/tslint.json | 17 - projects/common/README.md | 24 - projects/common/karma.conf.js | 32 - projects/common/ng-package.json | 13 - projects/common/package-lock.json | 35 -- projects/common/package.json | 22 - projects/common/scss-bundle.config.json | 0 .../src/fm/actions/app-common.actions.ts | 265 -------- .../common/src/fm/common-routing.module.ts | 33 - .../common/src/fm/common-service.module.ts | 86 --- projects/common/src/fm/common.module.ts | 134 ---- .../src/fm/components/app/app.component.html | 26 - .../src/fm/components/app/app.component.scss | 78 --- .../src/fm/components/app/app.component.ts | 145 ----- .../auth-callback/auth-callback.component.ts | 19 - .../auth-callback/auth-callback.guard.ts | 17 - .../has-package/has-package.directive.ts | 32 - .../menu-background.component.html | 3 - .../menu-background.component.scss | 18 - .../menu-background.component.ts | 23 - .../not-found/not-found.component.html | 5 - .../not-found/not-found.component.ts | 12 - .../not-implemented.component.html | 5 - .../not-implemented.component.ts | 11 - .../resumable-file-upload.component.html | 23 - .../resumable-file-upload.component.scss | 111 ---- .../resumable-file-upload.component.ts | 53 -- .../resumable-file-upload.service.ts | 149 ----- .../session-cleared.component.html | 8 - .../session-cleared.component.scss | 6 - .../session-cleared.component.ts | 24 - .../side-panel/side-panel.component.html | 14 - .../side-panel/side-panel.component.scss | 123 ---- .../side-panel/side-panel.component.ts | 87 --- .../tag-input/tag-input.component.html | 3 - .../tag-input/tag-input.component.scss | 16 - .../tag-input/tag-input.component.ts | 104 ---- .../timespan/timespan.component.css | 77 --- .../timespan/timespan.component.html | 34 - .../components/timespan/timespan.component.ts | 583 ------------------ .../src/fm/effects/app-common.effects.ts | 156 ----- .../common/src/fm/enumerations/alert.enum.ts | 5 - .../common/src/fm/models/code.list.item.ts | 28 - .../common/src/fm/models/event.message.ts | 6 - projects/common/src/fm/models/item.ts | 30 - projects/common/src/fm/models/item.type.ts | 8 - projects/common/src/fm/models/item.types.ts | 5 - projects/common/src/fm/models/itemTask.ts | 23 - projects/common/src/fm/models/list.item.ts | 13 - projects/common/src/fm/models/package.ts | 9 - projects/common/src/fm/models/query.state.ts | 12 - .../common/src/fm/models/typeahead.item.ts | 4 - projects/common/src/fm/models/user.ts | 5 - .../fm/models/weatherCurrentObservation.ts | 13 - projects/common/src/fm/module-name.ts | 1 - .../src/fm/reducers/app-common.reducer.ts | 121 ---- .../src/fm/services/auth-guard.service.ts | 66 -- .../src/fm/services/codelistitem.service.ts | 25 - .../src/fm/services/date-adapter.service.ts | 16 - .../common/src/fm/services/event.service.ts | 62 -- .../common/src/fm/services/folder.service.ts | 56 -- .../fm/services/full-screen-guard.service.ts | 30 - .../common/src/fm/services/item.service.ts | 157 ----- .../src/fm/services/itemtype.service.ts | 62 -- .../src/fm/services/nav-bar-guard.service.ts | 30 - .../common/src/fm/services/package.service.ts | 24 - .../fm/services/state-serializer.service.ts | 53 -- .../src/fm/services/timespan.service.ts | 75 --- .../src/fm/services/typeahead.service.ts | 25 - .../common/src/fm/services/user.service.ts | 21 - .../common/src/fm/services/weather.service.ts | 23 - .../src/fm/shared/accesstoken.interceptor.ts | 47 -- .../src/fm/shared/app.config.factory.ts | 37 -- projects/common/src/fm/shared/app.config.ts | 34 - .../common/src/fm/shared/authconfigFactory.ts | 22 - projects/common/src/fm/shared/safe.pipe.ts | 13 - .../src/fm/shared/secureOAuthStorage.ts | 36 -- projects/common/src/public-api.ts | 6 - projects/common/src/test.ts | 22 - projects/common/tsconfig.lib.json | 39 -- projects/common/tsconfig.spec.json | 17 - projects/common/tslint.json | 17 - 203 files changed, 10260 deletions(-) delete mode 100644 projects/common-map/README.md delete mode 100644 projects/common-map/ng-package.json delete mode 100644 projects/common-map/package-lock.json delete mode 100644 projects/common-map/package.json delete mode 100644 projects/common-map/src/fm-map/actions/map.actions.ts delete mode 100644 projects/common-map/src/fm-map/common-map-routing.module.ts delete mode 100644 projects/common-map/src/fm-map/common-map.module.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.html delete mode 100644 projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.scss delete mode 100644 projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.js.map delete mode 100644 projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.html delete mode 100644 projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.scss delete mode 100644 projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.html delete mode 100644 projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.scss delete mode 100644 projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.html delete mode 100644 projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.scss delete mode 100644 projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts delete mode 100644 projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts delete mode 100644 projects/common-map/src/fm-map/components/feature-list/feature-list.component.html delete mode 100644 projects/common-map/src/fm-map/components/feature-list/feature-list.component.scss delete mode 100644 projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts delete mode 100644 projects/common-map/src/fm-map/components/for-item/for-child.decorator.ts delete mode 100644 projects/common-map/src/fm-map/components/for-item/for-itemtype.decorator.ts delete mode 100644 projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.js.map delete mode 100644 projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.ts delete mode 100644 projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts delete mode 100644 projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.html delete mode 100644 projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.scss delete mode 100644 projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.ts delete mode 100644 projects/common-map/src/fm-map/components/item-list/item-list.component.html delete mode 100644 projects/common-map/src/fm-map/components/item-list/item-list.component.scss delete mode 100644 projects/common-map/src/fm-map/components/item-list/item-list.component.ts delete mode 100644 projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.html delete mode 100644 projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.scss delete mode 100644 projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.ts delete mode 100644 projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.html delete mode 100644 projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.scss delete mode 100644 projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.ts delete mode 100644 projects/common-map/src/fm-map/components/legend/legend.component.html delete mode 100644 projects/common-map/src/fm-map/components/legend/legend.component.scss delete mode 100644 projects/common-map/src/fm-map/components/legend/legend.component.ts delete mode 100644 projects/common-map/src/fm-map/components/map-search/map-search.component.html delete mode 100644 projects/common-map/src/fm-map/components/map-search/map-search.component.scss delete mode 100644 projects/common-map/src/fm-map/components/map-search/map-search.component.ts delete mode 100644 projects/common-map/src/fm-map/components/map/map.component.html delete mode 100644 projects/common-map/src/fm-map/components/map/map.component.scss delete mode 100644 projects/common-map/src/fm-map/components/map/map.component.ts delete mode 100644 projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.html delete mode 100644 projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.ts delete mode 100644 projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.html delete mode 100644 projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.scss delete mode 100644 projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.ts delete mode 100644 projects/common-map/src/fm-map/components/selected-item/selected-item.component.html delete mode 100644 projects/common-map/src/fm-map/components/selected-item/selected-item.component.scss delete mode 100644 projects/common-map/src/fm-map/components/selected-item/selected-item.component.ts delete mode 100644 projects/common-map/src/fm-map/components/widget-host/widget-host.directive.ts delete mode 100644 projects/common-map/src/fm-map/components/widget-status/widget-status.component.css delete mode 100644 projects/common-map/src/fm-map/components/widget-status/widget-status.component.html delete mode 100644 projects/common-map/src/fm-map/components/widget-status/widget-status.component.ts delete mode 100644 projects/common-map/src/fm-map/effects/map.effects.ts delete mode 100644 projects/common-map/src/fm-map/models/color.map.js.map delete mode 100644 projects/common-map/src/fm-map/models/color.map.ts delete mode 100644 projects/common-map/src/fm-map/models/index.js.map delete mode 100644 projects/common-map/src/fm-map/models/item.layer.js.map delete mode 100644 projects/common-map/src/fm-map/models/item.layer.ts delete mode 100644 projects/common-map/src/fm-map/models/layer.data.ts delete mode 100644 projects/common-map/src/fm-map/models/map.state.ts delete mode 100644 projects/common-map/src/fm-map/models/period.state.ts delete mode 100644 projects/common-map/src/fm-map/models/selected.features.ts delete mode 100644 projects/common-map/src/fm-map/models/style.cache.ts delete mode 100644 projects/common-map/src/fm-map/module-name.ts delete mode 100644 projects/common-map/src/fm-map/reducers/map.reducer.ts delete mode 100644 projects/common-map/src/fm-map/services/device-orientation.service.ts delete mode 100644 projects/common-map/src/fm-map/services/feature-icon.service.ts delete mode 100644 projects/common-map/src/fm-map/services/geolocation.service.ts delete mode 100644 projects/common-map/src/public-api.ts delete mode 100644 projects/common-map/src/test.ts delete mode 100644 projects/common-map/tsconfig.lib.json delete mode 100644 projects/common-map/tsconfig.spec.json delete mode 100644 projects/common-map/tslint.json delete mode 100644 projects/common/README.md delete mode 100644 projects/common/karma.conf.js delete mode 100644 projects/common/ng-package.json delete mode 100644 projects/common/package-lock.json delete mode 100644 projects/common/package.json delete mode 100644 projects/common/scss-bundle.config.json delete mode 100644 projects/common/src/fm/actions/app-common.actions.ts delete mode 100644 projects/common/src/fm/common-routing.module.ts delete mode 100644 projects/common/src/fm/common-service.module.ts delete mode 100644 projects/common/src/fm/common.module.ts delete mode 100644 projects/common/src/fm/components/app/app.component.html delete mode 100644 projects/common/src/fm/components/app/app.component.scss delete mode 100644 projects/common/src/fm/components/app/app.component.ts delete mode 100644 projects/common/src/fm/components/auth-callback/auth-callback.component.ts delete mode 100644 projects/common/src/fm/components/auth-callback/auth-callback.guard.ts delete mode 100644 projects/common/src/fm/components/has-package/has-package.directive.ts delete mode 100644 projects/common/src/fm/components/menu-background/menu-background.component.html delete mode 100644 projects/common/src/fm/components/menu-background/menu-background.component.scss delete mode 100644 projects/common/src/fm/components/menu-background/menu-background.component.ts delete mode 100644 projects/common/src/fm/components/not-found/not-found.component.html delete mode 100644 projects/common/src/fm/components/not-found/not-found.component.ts delete mode 100644 projects/common/src/fm/components/not-implemented/not-implemented.component.html delete mode 100644 projects/common/src/fm/components/not-implemented/not-implemented.component.ts delete mode 100644 projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.html delete mode 100644 projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.scss delete mode 100644 projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.ts delete mode 100644 projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.service.ts delete mode 100644 projects/common/src/fm/components/session-cleared/session-cleared.component.html delete mode 100644 projects/common/src/fm/components/session-cleared/session-cleared.component.scss delete mode 100644 projects/common/src/fm/components/session-cleared/session-cleared.component.ts delete mode 100644 projects/common/src/fm/components/side-panel/side-panel.component.html delete mode 100644 projects/common/src/fm/components/side-panel/side-panel.component.scss delete mode 100644 projects/common/src/fm/components/side-panel/side-panel.component.ts delete mode 100644 projects/common/src/fm/components/tag-input/tag-input.component.html delete mode 100644 projects/common/src/fm/components/tag-input/tag-input.component.scss delete mode 100644 projects/common/src/fm/components/tag-input/tag-input.component.ts delete mode 100644 projects/common/src/fm/components/timespan/timespan.component.css delete mode 100644 projects/common/src/fm/components/timespan/timespan.component.html delete mode 100644 projects/common/src/fm/components/timespan/timespan.component.ts delete mode 100644 projects/common/src/fm/effects/app-common.effects.ts delete mode 100644 projects/common/src/fm/enumerations/alert.enum.ts delete mode 100644 projects/common/src/fm/models/code.list.item.ts delete mode 100644 projects/common/src/fm/models/event.message.ts delete mode 100644 projects/common/src/fm/models/item.ts delete mode 100644 projects/common/src/fm/models/item.type.ts delete mode 100644 projects/common/src/fm/models/item.types.ts delete mode 100644 projects/common/src/fm/models/itemTask.ts delete mode 100644 projects/common/src/fm/models/list.item.ts delete mode 100644 projects/common/src/fm/models/package.ts delete mode 100644 projects/common/src/fm/models/query.state.ts delete mode 100644 projects/common/src/fm/models/typeahead.item.ts delete mode 100644 projects/common/src/fm/models/user.ts delete mode 100644 projects/common/src/fm/models/weatherCurrentObservation.ts delete mode 100644 projects/common/src/fm/module-name.ts delete mode 100644 projects/common/src/fm/reducers/app-common.reducer.ts delete mode 100644 projects/common/src/fm/services/auth-guard.service.ts delete mode 100644 projects/common/src/fm/services/codelistitem.service.ts delete mode 100644 projects/common/src/fm/services/date-adapter.service.ts delete mode 100644 projects/common/src/fm/services/event.service.ts delete mode 100644 projects/common/src/fm/services/folder.service.ts delete mode 100644 projects/common/src/fm/services/full-screen-guard.service.ts delete mode 100644 projects/common/src/fm/services/item.service.ts delete mode 100644 projects/common/src/fm/services/itemtype.service.ts delete mode 100644 projects/common/src/fm/services/nav-bar-guard.service.ts delete mode 100644 projects/common/src/fm/services/package.service.ts delete mode 100644 projects/common/src/fm/services/state-serializer.service.ts delete mode 100644 projects/common/src/fm/services/timespan.service.ts delete mode 100644 projects/common/src/fm/services/typeahead.service.ts delete mode 100644 projects/common/src/fm/services/user.service.ts delete mode 100644 projects/common/src/fm/services/weather.service.ts delete mode 100644 projects/common/src/fm/shared/accesstoken.interceptor.ts delete mode 100644 projects/common/src/fm/shared/app.config.factory.ts delete mode 100644 projects/common/src/fm/shared/app.config.ts delete mode 100644 projects/common/src/fm/shared/authconfigFactory.ts delete mode 100644 projects/common/src/fm/shared/safe.pipe.ts delete mode 100644 projects/common/src/fm/shared/secureOAuthStorage.ts delete mode 100644 projects/common/src/public-api.ts delete mode 100644 projects/common/src/test.ts delete mode 100644 projects/common/tsconfig.lib.json delete mode 100644 projects/common/tsconfig.spec.json delete mode 100644 projects/common/tslint.json diff --git a/projects/common-map/README.md b/projects/common-map/README.md deleted file mode 100644 index f03f493..0000000 --- a/projects/common-map/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# CommonMap - -This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0. - -## Code scaffolding - -Run `ng generate component component-name --project common-map` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project common-map`. -> Note: Don't forget to add `--project common-map` or else it will be added to the default project in your `angular.json` file. - -## Build - -Run `ng build common-map` to build the project. The build artifacts will be stored in the `dist/` directory. - -## Publishing - -After building your library with `ng build common-map`, go to the dist folder `cd dist/common-map` and run `npm publish`. - -## Running unit tests - -Run `ng test common-map` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/projects/common-map/ng-package.json b/projects/common-map/ng-package.json deleted file mode 100644 index 1e00865..0000000 --- a/projects/common-map/ng-package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", - "dest": "../../dist/common-map", - "lib": { - "entryFile": "src/public-api.ts" - }, - "whitelistedNonPeerDependencies": [ - "." - ] -} \ No newline at end of file diff --git a/projects/common-map/package-lock.json b/projects/common-map/package-lock.json deleted file mode 100644 index 12c549e..0000000 --- a/projects/common-map/package-lock.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "name": "@farmmaps/common-map", - "version": "0.0.1", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@openlayers/pepjs": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/@openlayers/pepjs/-/pepjs-0.5.3.tgz", - "integrity": "sha512-Bgvi5c14BS0FJWyYWWFstNEnXsB30nK8Jt8hkAAdqr7E0gDdBBWVDglF3Ub19wTxvgJ/CVHyTY6VuCtnyRzglg==" - }, - "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" - }, - "ngx-openlayers": { - "version": "1.0.0-next.13", - "resolved": "https://registry.npmjs.org/ngx-openlayers/-/ngx-openlayers-1.0.0-next.13.tgz", - "integrity": "sha512-6y724s5JV6n1oxEhryxP3wcbwzpierj9RLiMLXInfKOG3l5IO1AtPNkeK9+mKctVDUVm5URIfzzZH02Ld+bvSQ==", - "requires": { - "tslib": "^1.9.0" - } - }, - "ol": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/ol/-/ol-6.1.1.tgz", - "integrity": "sha512-0dL3i3eJqgOpqIjDKEY3grkeQnjAYfV5L/JCxhOu4SxiaizRwFrFgeas6LILRoxKa03jhQFbut2r2bbgcLGQeA==", - "requires": { - "@openlayers/pepjs": "^0.5.3", - "pbf": "3.2.1", - "pixelworks": "1.1.0", - "rbush": "^3.0.1" - } - }, - "pbf": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz", - "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==", - "requires": { - "ieee754": "^1.1.12", - "resolve-protobuf-schema": "^2.1.0" - } - }, - "pixelworks": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pixelworks/-/pixelworks-1.1.0.tgz", - "integrity": "sha1-Hwla1I3Ki/ihyCWOAJIDGkTyLKU=" - }, - "protocol-buffers-schema": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.4.0.tgz", - "integrity": "sha512-G/2kcamPF2S49W5yaMGdIpkG6+5wZF0fzBteLKgEHjbNzqjZQ85aAs1iJGto31EJaSTkNvHs5IXuHSaTLWBAiA==" - }, - "quickselect": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz", - "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==" - }, - "rbush": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rbush/-/rbush-3.0.1.tgz", - "integrity": "sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==", - "requires": { - "quickselect": "^2.0.0" - } - }, - "resolve-protobuf-schema": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz", - "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==", - "requires": { - "protocol-buffers-schema": "^3.3.1" - } - }, - "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" - } - } -} diff --git a/projects/common-map/package.json b/projects/common-map/package.json deleted file mode 100644 index 627a2ad..0000000 --- a/projects/common-map/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@farmmaps/common-map", - "version": "0.0.1", - "publishConfig": { - "registry": "https://repository.akkerweb.nl/repository/npm-hosted/" - }, - "peerDependencies": { - "@angular/core": "^9.1.0", - "ngrx-store-localstorage": "^9.0", - "@ngrx/effects": "^9.0", - "@ngrx/router-store": "^9.0", - "@ngrx/store": "^9.0", - "tassign": "^1.0.0", - "@farmmaps/common": ">=0.0.1-prerelease.265 <0.0.1", - "ngx-openlayers": "1.0.0-next.13", - "ol": "6.1.1" - } -} diff --git a/projects/common-map/src/fm-map/actions/map.actions.ts b/projects/common-map/src/fm-map/actions/map.actions.ts deleted file mode 100644 index 0658192..0000000 --- a/projects/common-map/src/fm-map/actions/map.actions.ts +++ /dev/null @@ -1,295 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { IMapState } from '../models/map.state'; -import { IItemLayer } from '../models/item.layer'; -import { IQueryState } from '@farmmaps/common'; -import { IItem } from '@farmmaps/common'; -import { Feature,Style } from 'ol'; - -export const SETSTATE = '[Map] SetState'; -export const SETMAPSTATE = '[Map] MapState'; -export const SETVIEWEXTENT = '[Map] SetViewExtent'; -export const INIT = '[Map] Init'; -export const SETPARENT = '[Map] SetParent'; -export const STARTSEARCH = '[Map] StartSearch'; -export const STARTSEARCHSUCCESS = '[Map] StartSearchSuccess'; -export const SELECTFEATURE = '[Map] SelectFeature'; -export const SELECTITEM = '[Map] SelectItem'; -export const SELECTITEMSUCCESS = '[Map] SelectItemSuccess'; -export const SELECTTEMPORALITEMSSUCCESS = '[Map] SelectTemporalItemsSuccess'; -export const NEXTTEMPORAL = '[Map] NextTemporal'; -export const PREVIOUSTEMPORAL = '[Map] PreviousTemporal'; -export const SELECTTEMPORAL = '[Map] SelectTemporal'; -export const ADDFEATURESUCCESS = '[Map] AddFeatureSuccess'; -export const UPDATEFEATURESUCCESS = '[Map] UpdateFeatureSuccess'; -export const EXPANDSEARCH = '[Map] ExpandSearch'; -export const COLLAPSESEARCH = '[Map] CollapseSearch'; -export const SETEXTENT = '[Map] SetExtent'; -export const SETQUERYSTATE = '[Map] SetQueryState'; -export const SETTIMESPAN = '[Map] SetTimeSpan'; -export const ADDLAYER = '[Map] AddLayer'; -export const SETVISIBILITY = '[Map] SetVisibility'; -export const SETOPACITY = '[Map] SetOpacity'; -export const SETLAYERINDEX = '[Map] SetLayerIndex'; -export const REMOVELAYER = '[Map] RemoveLayer'; -export const LOADBASELAYERS = '[Map] LoadLayers'; -export const LOADBASELAYERSSUCCESS = '[Map] LoadLayersSuccess'; -export const SELECTBASELAYER = '[Map] SelectBaseLayers'; -export const SELECTOVERLAYLAYER = '[Map] SelectOverlayLayers'; -export const ZOOMTOEXTENT = '[Map] ZoomToExtent'; -export const DOQUERY = '[Map] DoQuery'; -export const SETSTYLE = '[Map] SetStyle'; -export const SHOWLAYERSWITCHER = '[Map] ShowLayerSwitcher'; -export const CLEAR = '[Map] Clear'; -export const SETREPLACEURL = '[Map] SetReplaceUrl'; - -export class Clear implements Action { - readonly type = CLEAR; - constructor() {} -} - -export class SetState implements Action { - readonly type = SETSTATE; - - constructor(public mapState: IMapState,public queryState:IQueryState) { } -} - -export class SetMapState implements Action { - readonly type = SETMAPSTATE; - - constructor(public mapState: IMapState) { } -} - -export class SetViewExtent implements Action { - readonly type = SETVIEWEXTENT; - - constructor(public extent:number[]) { } -} - -export class Init implements Action { - readonly type = INIT; - - constructor() { } -} - -export class SetParent implements Action { - readonly type = SETPARENT; - - constructor(public parentCode:string) { } -} - -export class StartSearch implements Action { - readonly type = STARTSEARCH; - - constructor(public queryState: IQueryState) { } -} - -export class StartSearchSuccess implements Action { - readonly type = STARTSEARCHSUCCESS; - - constructor(public features: Array, public query:IQueryState,public setStateCount:number) { } -} - -export class SelectFeature implements Action { - readonly type = SELECTFEATURE; - - constructor(public feature:Feature) { } -} - -export class SelectItem implements Action { - readonly type = SELECTITEM; - - constructor(public itemCode:string) { } -} - -export class SelectItemSuccess implements Action { - readonly type = SELECTITEMSUCCESS; - - constructor(public item: IItem) { } -} - -export class SelectTemporalItemsSuccess implements Action { - readonly type = SELECTTEMPORALITEMSSUCCESS; - - constructor(public temporalItems: IItem[]) { } -} - -export class NextTemporal implements Action { - readonly type = NEXTTEMPORAL; - - constructor() { } -} - -export class PreviousTemporal implements Action { - readonly type = PREVIOUSTEMPORAL; - - constructor() { } -} - -export class SelectTemporal implements Action { - readonly type = SELECTTEMPORAL; - - constructor(item:IItem) { } -} - -export class AddFeatureSuccess implements Action { - readonly type = ADDFEATURESUCCESS; - - constructor(public feature: Feature) { } -} - -export class UpdateFeatureSuccess implements Action { - readonly type = UPDATEFEATURESUCCESS; - - constructor(public feature: Feature) { } -} - -export class ExpandSearch implements Action { - readonly type = EXPANDSEARCH; - - constructor() { } -} - -export class CollapseSearch implements Action { - readonly type = COLLAPSESEARCH; - - constructor() { } -} - -export class SetExtent implements Action { - readonly type = SETEXTENT; - - constructor(public extent:number[]) { } -} - -export class SetQueryState implements Action { - readonly type = SETQUERYSTATE; - - constructor(public queryState: IQueryState,public replaceUrl:boolean = true) { } -} - -export class SetTimeSpan implements Action { - readonly type = SETTIMESPAN; - - constructor(public startDate: Date, public endDate: Date) { } -} - -export class AddLayer implements Action { - readonly type = ADDLAYER; - - constructor(public item:IItem,public layerIndex=-1) { } -} - -export class SetVisibility implements Action { - readonly type = SETVISIBILITY; - - constructor(public itemLayer:IItemLayer,public visibility:boolean) { } -} - -export class SetOpacity implements Action { - readonly type = SETOPACITY; - - constructor(public itemLayer: IItemLayer, public opacity: number) { } -} - -export class SetLayerIndex implements Action { - readonly type = SETLAYERINDEX; - - constructor(public layerIndex: number, public itemLayer: IItemLayer = null) { } -} - -export class RemoveLayer implements Action { - readonly type = REMOVELAYER; - - constructor(public itemLayer: IItemLayer) { } -} - -export class LoadBaseLayers implements Action { - readonly type = LOADBASELAYERS; - - constructor(public projection: string) { } -} - -export class LoadBaseLayersSuccess implements Action { - readonly type = LOADBASELAYERSSUCCESS; - - constructor(public items: IItem[] ) { } -} - -export class SelectBaseLayer implements Action { - readonly type = SELECTBASELAYER; - - constructor(public itemLayer: IItemLayer) { } -} - -export class SelectOverlayLayer implements Action { - readonly type = SELECTOVERLAYLAYER; - - constructor(public itemLayer: IItemLayer) { } -} - -export class ZoomToExtent implements Action { - readonly type = ZOOMTOEXTENT; - - constructor(public itemLayer: IItemLayer) { } -} - -export class DoQuery implements Action { - readonly type = DOQUERY; - - constructor(public query:IQueryState) { } -} - -export class SetStyle implements Action { - readonly type = SETSTYLE; - - constructor(public itemType:string,public style: Style | (Feature)) { } -} - -export class ShowLayerSwitcher implements Action { - readonly type = SHOWLAYERSWITCHER; - constructor(public show:boolean) {} -} - -export class SetReplaceUrl implements Action { - readonly type = SETREPLACEURL; - constructor(public replaceUrl:boolean) {} -} - -export type Actions = SetMapState - | Init - | Clear - | SetParent - | StartSearch - | StartSearchSuccess - | SelectFeature - | SelectItem - | SelectItemSuccess - | SelectTemporalItemsSuccess - | NextTemporal - | PreviousTemporal - | SelectTemporal - | AddFeatureSuccess - | UpdateFeatureSuccess - | ExpandSearch - | CollapseSearch - | SetExtent - | SetQueryState - | SetTimeSpan - | AddLayer - | RemoveLayer - | SetVisibility - | SetOpacity - | SetLayerIndex - | LoadBaseLayers - | LoadBaseLayersSuccess - | SelectBaseLayer - | SelectOverlayLayer - | ZoomToExtent - | SetState - | SetViewExtent - | DoQuery - | SetStyle - | ShowLayerSwitcher - | SetReplaceUrl; - diff --git a/projects/common-map/src/fm-map/common-map-routing.module.ts b/projects/common-map/src/fm-map/common-map-routing.module.ts deleted file mode 100644 index 5f744a8..0000000 --- a/projects/common-map/src/fm-map/common-map-routing.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; -import { MapComponent } from './components/map/map.component'; -import { AuthGuard } from '@farmmaps/common'; - -const routes = [ - { - path: '', children: [ - { - path: '', - component: MapComponent - } - ] - }, - { - path: ':xCenter/:yCenter/:zoom/:rotation/:baseLayer/:queryState', children: [ - { - path: '', - component: MapComponent - } - ] - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class MapRoutingModule { } diff --git a/projects/common-map/src/fm-map/common-map.module.ts b/projects/common-map/src/fm-map/common-map.module.ts deleted file mode 100644 index 735b36d..0000000 --- a/projects/common-map/src/fm-map/common-map.module.ts +++ /dev/null @@ -1,276 +0,0 @@ -import { NgModule ,ModuleWithProviders} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; - -//external modules -import { AngularOpenlayersModule } from 'ngx-openlayers'; -import { StoreModule, ActionReducer, MetaReducer } from '@ngrx/store'; -import { EffectsModule } from '@ngrx/effects'; -import { NgbModule } from "@ng-bootstrap/ng-bootstrap"; - -//common modules -import { AppCommonModule } from '@farmmaps/common'; - -import { MODULE_NAME } from './module-name'; -import * as mapReducers from './reducers/map.reducer'; -import * as mapActions from './actions/map.actions'; -import * as mapEffects from './effects/map.effects'; - -import { IMapState} from './models/map.state'; -import { ISelectedFeatures } from './models/selected.features'; -import { IItemLayer } from './models/item.layer'; -import { ItemLayer} from './models/item.layer'; -import { IPeriodState } from './models/period.state'; - -// components -import { GpsLocation} from './components/aol/gps-location/gps-location.component'; -//import {Switch2D3DComponent } from './components/aol/switch2d3d/switch2d3d.component'; -import {FeatureListFeatureCropfieldComponent } from './components/feature-list-feature-cropfield/feature-list-feature-cropfield.component'; -import { FeatureListFeatureCroppingschemeComponent} from './components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component'; -import { ItemWidgetListComponent} from './components/item-widget-list/item-widget-list.component'; -import { AbstractItemListItemComponent, ItemListItemComponent, AbstractItemWidgetComponent } from './components/item-list-item/item-list-item.component'; -import { ItemListItemContainerComponent } from './components/item-list-item-container/item-list-item-container.component'; -import { AbstractItemListComponent,ItemListComponent} from './components/item-list/item-list.component'; -import { AbstractSelectedItemComponent, SelectedItemComponent } from './components/selected-item/selected-item.component'; -import { SelectedItemCropfieldComponent } from './components/selected-item-cropfield/selected-item-cropfield.component'; -import { SelectedItemGeotiffComponent } from './components/selected-item-geotiff/selected-item-geotiff.component'; -import { SelectedItemTemporalComponent} from './components/selected-item-temporal/selected-item-temporal.component'; -import {SelectedItemShapeComponent } from './components/selected-item-shape/selected-item-shape.component'; -import { SelectedItemContainerComponent } from './components/selected-item-container/selected-item-container.component'; -import { AbstractFeatureListFeatureComponent, FeatureListFeatureComponent } from './components/feature-list-feature/feature-list-feature.component'; -import {FeatureListFeatureContainerComponent } from './components/feature-list-feature-container/feature-list-feature-container.component'; -import { FeatureListCroppingschemeComponent } from './components/feature-list-croppingscheme/feature-list-croppingscheme.component'; -import {FeatureListCropfieldComponent } from './components/feature-list-cropfield/feature-list-cropfield.component'; -import {FeatureListContainerComponent } from './components/feature-list-container/feature-list-container.component'; -import { WidgetHostDirective} from './components/widget-host/widget-host.directive'; -import { FeatureListComponent,AbstractFeatureListComponent} from './components/feature-list/feature-list.component'; -import { FileDropTargetComponent } from './components/aol/file-drop-target/file-drop-target.component'; -import { ItemVectorSourceComponent } from './components/aol/item-vector-source/item-vector-source.component'; -import { ItemLayersComponent } from './components/aol/item-layers/item-layers.component'; -import { ZoomToExtentComponent } from './components/aol/zoom-to-extent/zoom-to-extent.component'; -import { RotationResetComponent } from './components/aol/rotation-reset/rotation-reset.component'; -import { LayerListComponent } from './components/aol/layer-list/layer-list.component'; -import { MetaDataModalComponent } from './components/meta-data-modal/meta-data-modal.component'; -import { SelectPeriodModalComponent } from './components/select-period-modal/select-period-modal.component'; -import { MapComponent } from './components/map/map.component'; -import { MapSearchComponent } from './components/map-search/map-search.component'; -import { MapRoutingModule } from './common-map-routing.module'; -import { LegendComponent } from './components/legend/legend.component'; -import { LayerVectorImageComponent } from './components/aol/layer-vector-image/layer-vector-image.component'; -import {FeatureIconService} from './services/feature-icon.service'; -import { GeolocationService } from './services/geolocation.service'; -import {DeviceOrientationService} from './services/device-orientation.service'; -import { WidgetStatusComponent } from './components/widget-status/widget-status.component'; -import { ForChild} from './components/for-item/for-child.decorator'; -import {ForItemType } from './components/for-item/for-itemtype.decorator'; -import { ForSourceTask} from './components/for-item/for-sourcetask.decorator'; -import { PanToLocation} from './components/aol/pan-to-location/pan-to-location.component'; -import {LayerSwitcher} from './components/layer-switcher/layer-switcher.component'; - -export function LocalStorageSync(reducer: ActionReducer): ActionReducer { - const r = function(state, action) { - const r2 = reducer(state, action); - - if(action.type == "@ngrx/store/update-reducers") { - let ms = window.localStorage.getItem(MODULE_NAME+"_mapState"); - if(ms) { - r2["mapState"] = JSON.parse(ms); - } - } - if(action.type == "[Map] MapState" || action.type == "[Map] SetState") { - window.localStorage.setItem(MODULE_NAME + "_mapState",JSON.stringify(r2["mapState"])); - } - - return r2; - }; - return r; - } - -const metaReducers: Array> = [LocalStorageSync]; - -export { - mapEffects, - mapReducers, - mapActions, - ZoomToExtentComponent, - ItemVectorSourceComponent, - ItemLayersComponent, - FileDropTargetComponent, - MapComponent, - MetaDataModalComponent, - RotationResetComponent, - MapSearchComponent, - SelectPeriodModalComponent, - LayerListComponent, - LegendComponent, - LayerVectorImageComponent, - FeatureListComponent, - WidgetHostDirective, - FeatureListContainerComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureContainerComponent, - FeatureListFeatureComponent, - FeatureListFeatureCroppingschemeComponent, - FeatureListFeatureCropfieldComponent, - SelectedItemContainerComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListItemComponent, - ItemListItemContainerComponent, - ItemListComponent, - ItemWidgetListComponent, - WidgetStatusComponent, - GpsLocation, - PanToLocation, - LayerSwitcher, - AbstractFeatureListComponent, - AbstractFeatureListFeatureComponent, - AbstractSelectedItemComponent, - AbstractItemWidgetComponent, - AbstractItemListItemComponent, - AbstractItemListComponent, - FeatureIconService, - GeolocationService, - DeviceOrientationService, - IMapState, - ISelectedFeatures, - IItemLayer, - ItemLayer, - IPeriodState, - ForChild, - ForItemType, - ForSourceTask -} - -@NgModule({ - imports: [ - CommonModule, - AngularOpenlayersModule, - MapRoutingModule, - StoreModule.forFeature(MODULE_NAME, mapReducers.reducer,{metaReducers:metaReducers}), - EffectsModule.forFeature([mapEffects.MapEffects]), - NgbModule, - FormsModule, - ReactiveFormsModule, - AppCommonModule - ], - declarations: [ - ZoomToExtentComponent, - ItemVectorSourceComponent, - ItemLayersComponent, - FileDropTargetComponent, - MapComponent, - MetaDataModalComponent, - RotationResetComponent, - MapSearchComponent, - SelectPeriodModalComponent, - LayerListComponent, - LegendComponent, - LayerVectorImageComponent, - FeatureListComponent, - WidgetHostDirective, - FeatureListContainerComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureContainerComponent, - FeatureListFeatureComponent, - FeatureListFeatureCroppingschemeComponent, - FeatureListFeatureCropfieldComponent, - SelectedItemContainerComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListItemComponent, - ItemListItemContainerComponent, - ItemListComponent, - ItemWidgetListComponent, - WidgetStatusComponent, - GpsLocation, - PanToLocation, - LayerSwitcher - ], - entryComponents: [ - FeatureListComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureComponent, - FeatureListFeatureCroppingschemeComponent, - FeatureListFeatureCropfieldComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListComponent, - ItemListItemComponent, - ], - exports: [ - ItemVectorSourceComponent, - ItemLayersComponent, - FileDropTargetComponent, - MetaDataModalComponent, - MapComponent, - GpsLocation, - PanToLocation, - LayerSwitcher, - FeatureListFeatureComponent, - FeatureListFeatureCropfieldComponent, - FeatureListFeatureCroppingschemeComponent, - SelectedItemContainerComponent, - SelectedItemComponent, - SelectedItemCropfieldComponent, - SelectedItemGeotiffComponent, - SelectedItemTemporalComponent, - SelectedItemShapeComponent, - ItemListItemComponent, - ItemListItemContainerComponent, - ItemListComponent, - ItemWidgetListComponent, - WidgetStatusComponent, - RotationResetComponent, - MapSearchComponent, - SelectPeriodModalComponent, - LayerListComponent, - LegendComponent, - LayerVectorImageComponent, - FeatureListComponent, - WidgetHostDirective, - FeatureListContainerComponent, - FeatureListCroppingschemeComponent, - FeatureListCropfieldComponent, - FeatureListFeatureContainerComponent, - ZoomToExtentComponent - ] -}) - - -export class AppCommonMapModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: AppCommonMapModule, - providers: [ - FeatureIconService, - GeolocationService, - DeviceOrientationService, - { provide: AbstractFeatureListComponent, useClass: FeatureListCroppingschemeComponent, multi: true }, - { provide: AbstractFeatureListComponent, useClass: FeatureListCropfieldComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCroppingschemeComponent, multi: true }, - { provide: AbstractFeatureListFeatureComponent, useClass: FeatureListFeatureCropfieldComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemCropfieldComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemGeotiffComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemTemporalComponent, multi: true }, - { provide: AbstractSelectedItemComponent, useClass: SelectedItemShapeComponent, multi: true }, - { provide: AbstractItemListItemComponent, useClass: ItemListItemComponent, multi: true }, - { provide: AbstractItemListComponent, useClass: ItemListComponent, multi: true } - ] - }; - } -} diff --git a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts b/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts deleted file mode 100644 index ab9273a..0000000 --- a/projects/common-map/src/fm-map/components/aol/file-drop-target/file-drop-target.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Component, Input, OnDestroy, OnInit, EventEmitter, Output, Inject } from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; - -import * as proj from 'ol/proj'; -import {Point,Geometry} from 'ol/geom'; -import { GeoJSON } from 'ol/format'; -import { Feature } from 'ol'; - -export interface IDroppedFile { - files: any, - event: any, - geometry: any - parentCode: string; -} - -@Component({ - selector: 'fm-map-file-drop-target', - template: '' -}) -export class FileDropTargetComponent implements OnInit, OnDestroy { - element: Element; - @Output() onFileDropped = new EventEmitter(); - @Input() parentCode: string; - @Input() features: Array; - - constructor(private map: MapComponent) { - } - - ngOnInit() { - this.element = this.map.instance.getViewport(); - let other = this; - this.element.addEventListener('drop', this.onDrop, false); - this.element.addEventListener('dragover', this.preventDefault, false); - this.element.addEventListener('dragenter', this.preventDefault, false); - } - - private onDrop = (event: DragEvent) => { - this.stopEvent(event); - let geojsonFormat = new GeoJSON(); - var parentCode = this.parentCode; - var coordinate = this.map.instance.getEventCoordinate(event); - //coordinate = proj.transform(coordinate, this.map.instance.getView().getProjection(), 'EPSG:4326'); - var geometry:Geometry = new Point(coordinate); - var hitFeatures = this.map.instance.getFeaturesAtPixel([event.pageX, event.pageY]); - var hitFeature = hitFeatures && hitFeatures.length > 0 ? hitFeatures[0] : null; - if (hitFeature) { - if (hitFeature.get("code")) { - parentCode = hitFeature.get("code"); - } - geometry = geojsonFormat.readGeometry(geojsonFormat.writeGeometry(geometry)); // create copy instead of reference - } - var projectedGeometry = geometry.transform(this.map.instance.getView().getProjection(), 'EPSG:4326'); - - if (event.dataTransfer && event.dataTransfer.files) { - this.onFileDropped.emit({ files: event.dataTransfer.files, event: event, geometry: JSON.parse(geojsonFormat.writeGeometry(projectedGeometry)),parentCode:parentCode}) - } - } - - private preventDefault(event) { - event.preventDefault(); - } - - private stopEvent(event) { - event.stopPropagation(); - event.preventDefault(); - } - - ngOnDestroy() { - this.element.removeEventListener('drop', this.onDrop); - this.element.removeEventListener('dragover', this.preventDefault); - this.element.removeEventListener('dragenter', this.preventDefault); - } -} diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.html b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.html deleted file mode 100644 index d06dab1..0000000 --- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.html +++ /dev/null @@ -1,15 +0,0 @@ -
- - - - - - - - - - - - - -
diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.scss b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.scss deleted file mode 100644 index 20916c6..0000000 --- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - -.gps-location { - display:none; -} - -.center, .tolerance, .border { - stroke-width: 0; -} - -.tolerance { - fill: $primary; - fill-opacity:0.4; -} - -.border { - fill: $white; -} - -.center { - fill: $primary; -} - -.stop1 { - stop-color: $primary; - stop-opacity:1; -} - -.stop2 { - stop-color:$primary; - stop-opacity: 0; -} - - diff --git a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts b/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts deleted file mode 100644 index 2bb45fc..0000000 --- a/projects/common-map/src/fm-map/components/aol/gps-location/gps-location.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges } from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; -import Overlay from 'ol/Overlay'; -import { fromLonLat, toLonLat } from 'ol/proj'; - - -@Component({ - selector: 'fm-map-gps-location', - templateUrl: './gps-location.component.html', - styleUrls: ['./gps-location.component.scss'] -}) -export class GpsLocation implements OnInit,OnChanges{ - - @Input() enable:boolean; - public instance: Overlay; - @Input() position: Position; - @Input() location: number[]=[0,0]; - @Input() locationTolerance: number = 0; - @Input() showHeading: boolean = false; - @Input() heading: number = 0; - @Input() headingTolerance: number = 0; - public locTolerancePixels: number = 0; - public path: string = ""; - public rotate: string = ""; - private resolution: number = 0; - @ViewChild('location', { static: true }) locationElement: ElementRef; - - constructor(private map: MapComponent) { - - } - - recalcLocationTolerance() { - this.locTolerancePixels = this.resolution >0? this.locationTolerance / this.resolution:0; - } - - ngOnInit() { - this.instance = new Overlay({ - stopEvent:false, - positioning: 'center-center', - position: fromLonLat( this.location), - element: this.locationElement.nativeElement - }); - var x = Math.tan(this.headingTolerance * Math.PI / 180)*40; - var y = Math.cos(this.headingTolerance * Math.PI / 180) * 40; - var y1 = Math.round(500 - y); - var x1 = Math.round(500 - x); - var y2 = Math.round(y1); - var 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.rotate = "rotate(" + Math.round(this.heading) + " 500 500)"; - this.locTolerancePixels = this.locationTolerance; - this.map.instance.addOverlay(this.instance); - this.map.instance.getView().on('change:resolution', (evt) => { - this.resolution = evt.target.get('resolution'); - this.recalcLocationTolerance(); - }); - } - - ngOnChanges(changes: SimpleChanges) { - if (changes.position && this.instance) { - var p = changes.position.currentValue as Position; - if(p) { - this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude])); - this.locationTolerance = p.coords.accuracy; - this.recalcLocationTolerance(); - } - } - if(changes.heading && this.instance) { - this.rotate = "rotate(" + Math.round(changes.heading.currentValue) + " 500 500)"; - } - } -} diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.js.map b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.js.map deleted file mode 100644 index 3147cbe..0000000 --- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"item-layers.component.js","sourceRoot":"","sources":["item-layers.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAiM;AAEjM,+BAAiC;AACjC,iDAA2I;AAK3I,6DAAgE;AAUhE;IAAyC,uCAAmB;IAI1D,6BAA8C,SAAc,EAAU,WAAwB,EAAkB,GAAiB,EAAS,SAAoB;QAA9J,YACE,kBAAM,SAAS,EAAE,GAAG,CAAC,SAEtB;QAH6C,eAAS,GAAT,SAAS,CAAK;QAAU,iBAAW,GAAX,WAAW,CAAa;QAAkB,SAAG,GAAH,GAAG,CAAc;QAAS,eAAS,GAAT,SAAS,CAAW;QAKtJ,gBAAU,GAAG,EAAE,CAAA;QAHrB,KAAI,CAAC,YAAY,GAAG,EAAE,CAAC,CAAA,qCAAqC;;IAC9D,CAAC;4BAPU,mBAAmB;IAW9B,yCAAW,GAAX,UAAY,SAAqB;QAAjC,iBAyFC;QAxFC,IAAI,KAAK,GAAmB,IAAI,CAAC;QACjC,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,yCAAyC,EAAE;YACxE,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAK,IAAI,CAAC,YAAY,sBAAiB,SAAS,CAAC,IAAI,CAAC,IAAI,2BAAwB,EAAE,CAAC,CAAC;YAC/J,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;SAC3D;aAAM,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,uCAAuC,EAAE;YAC7E,IAAI,QAAM,GAAG,IAAI,CAAC;YAClB,IAAI,QAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACjD,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC5C,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI;gBAC7C,MAAM,EAAE,UAAU,MAAiB,EAAE,UAAkB,EAAE,UAA8B;oBACrF,IAAI,MAAM,GAAG,IAAI,CAAC;oBAClB,QAAM,CAAC,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,IAAI;wBAC5G,IAAI,QAAQ,GAAG,QAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;wBACzC,KAAc,UAAQ,EAAR,qBAAQ,EAAR,sBAAQ,EAAR,IAAQ,EAAE;4BAAnB,IAAI,CAAC,iBAAA;4BACR,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gCACxC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;6BAC7B;yBACF;wBACD,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;oBAC/B,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;YACH,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;gBACtC,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,UAAC,OAAO;oBACb,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAC/B,IAAI,CAAC,KAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;wBACzB,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBACjC,KAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CACnD;4BACE,IAAI,EAAE,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;gCAClC,KAAK,EAAE,KAAK;6BACb,CAAC;4BACF,MAAM,EAAE,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;gCACtC,KAAK,EAAE,KAAK;gCACZ,KAAK,EAAE,IAAI;6BACZ,CAAC;4BACF,KAAK,EAAE,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;gCACrC,IAAI,EAAE,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;oCAClC,KAAK,EAAE,KAAK;iCACb,CAAC;gCACF,MAAM,EAAE,IAAI,KAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;oCACtC,KAAK,EAAE,KAAK;oCACZ,KAAK,EAAE,IAAI;iCACZ,CAAC;gCACF,MAAM,EAAE,CAAC;6BACV,CAAC;yBACH,CACF,CAAA;qBACF;oBACD,OAAO,KAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBAC9B,CAAC;aACF,CAAC,CAAC;SACJ;aAAM,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,IAAI,6BAA6B,EAAE;YACnE,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAkB,CAAC;YAC7C,QAAQ,IAAI,CAAC,aAAa,EAAE;gBAC1B,KAAK,KAAK,CAAC,CAAC;oBACV,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;oBAC7C,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBAC1D,MAAM;iBACP;gBACD,KAAK,UAAU,CAAC,CAAC;oBACf,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBAC9D,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBAC1D,MAAM;iBACP;gBACD,KAAK,SAAS,CAAC,CAAC;oBACd,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBAC7D,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBAC1D,MAAM;iBACP;gBACD,KAAK,gBAAgB,CAAC,CAAC;oBACrB,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACpE,KAAK,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBAC1D,MAAM;iBACP;gBACD,OAAO,CAAC,CAAC;oBACP,MAAM;iBACP;aACF;SACF;QACD,IAAI,KAAK,EAAE;YACT,IAAI,QAAQ,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7E,IAAI,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACvG,IAAI,MAAM;gBAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;SACrC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sCAAQ,GAAR;QACE,iBAAM,QAAQ,WAAE,CAAC;QACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAED,0CAAY,GAAZ,UAAa,UAAwB;QAArC,iBA2BC;QA1BC,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACzC,UAAU,CAAC,OAAO,CAAC,UAAC,SAAS,EAAE,KAAK;YAElC,IAAI,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;YAC5B,IAAI,OAAO,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACjD,IAAI,OAAO,GAAG,CAAC,EAAE;gBACd,kCAAkC;gBACnC,KAAK,GAAG,KAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBACpC,IAAI,KAAK,EAAE;oBACT,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC;iBACzB;gBACD,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aACjC;iBAAM,IAAI,KAAK,KAAK,OAAO,EAAE;gBAC5B,yCAAyC;gBACzC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAC3B,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aACjC;YACD,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACpC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,6DAA6D;QAC7D,IAAI,QAAQ,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE;YAC5C,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;gBAC7D,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aACtB;SACF;IACH,CAAC;IAED,yCAAW,GAAX,UAAY,OAAsB;QAChC,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,OAAO,CAAC,YAAY,CAAC,EAAE;gBACzB,IAAI,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,YAA4B,CAAC;gBACpE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;aAC/B;SACF;IACH,CAAC;;IA9IQ;QAAR,YAAK,EAAE;2DAA0B;IADvB,mBAAmB;QAR/B,gBAAS,CAAC;YACT,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,2BAA2B;YACrC,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,+BAAc,EAAE,WAAW,EAAE,iBAAU,CAAC,cAAM,OAAA,qBAAmB,EAAnB,CAAmB,CAAC,EAAE;aAChF;SACF,CAAC;QAMa,WAAA,aAAM,CAAC,2BAAc,CAAC,CAAA,EAA8D,WAAA,WAAI,EAAE,CAAA;OAJ5F,mBAAmB,CAgJ/B;IAAD,0BAAC;CAAA,AAhJD,CAAyC,oCAAmB,GAgJ3D;AAhJY,kDAAmB"} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts b/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts deleted file mode 100644 index cb51398..0000000 --- a/projects/common-map/src/fm-map/components/aol/item-layers/item-layers.component.ts +++ /dev/null @@ -1,316 +0,0 @@ -import { Component, Host, Input, Output, EventEmitter, Optional, QueryList, OnInit, AfterViewInit, OnChanges, SimpleChanges, SkipSelf, forwardRef, Inject, InjectionToken } from '@angular/core'; -import { HttpClient } from "@angular/common/http"; -import { LayerVectorComponent, LayerTileComponent, LayerGroupComponent, MapComponent } from 'ngx-openlayers'; -import { ItemService,IItem,AppConfig } from '@farmmaps/common'; -import { IItemLayer,ItemLayer, ITemporalItemLayer} from '../../../models/item.layer'; -import { ILayerData} from '../../../models/layer.data'; -import { IRenderoutputTiles,IRenderoutputImage,IGradientstop,ILayer,IHistogram} from '../../../models/color.map'; -import {Extent} from 'ol/extent'; -import Projection from 'ol/proj/Projection'; -import * as proj from 'ol/proj'; -import * as loadingstrategy from 'ol/loadingstrategy'; -import * as style from 'ol/style'; -import {Tile,Layer,Image} from 'ol/layer'; -import {XYZ,ImageStatic,OSM,BingMaps,TileWMS,TileArcGISRest} from 'ol/source'; -import {Vector as VectorSource} from 'ol/source'; -import { Vector as VectorLayer } from 'ol/layer'; -import VectorTileSource from 'ol/source/VectorTile'; -import VectorTileLayer from 'ol/layer/VectorTile'; -import {GeoJSON,MVT} from 'ol/format'; -import { from } from 'rxjs'; - -@Component({ - selector: 'fm-map-item-layers', - template: ``, - providers: [ - { provide: LayerGroupComponent, useExisting: forwardRef(() => ItemLayersComponent) } - ] -}) - -export class ItemLayersComponent extends LayerGroupComponent implements OnChanges, OnInit { - @Input() itemLayers: IItemLayer[]; - @Input() itemLayer: IItemLayer; - private _apiEndPoint: string; - - constructor(private itemService: ItemService, @Host() private map: MapComponent, public appConfig: AppConfig) { - super(map); - this._apiEndPoint = appConfig.getConfig("apiEndPoint"); - } - - private styleCache = {} - - componentToHex(c) { - var hex = c.toString(16); - return hex.length == 1 ? "0" + hex : hex; - } - - rgbaToHex(r, g, b,a) { - return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b) + this.componentToHex(a); - } - - getColorFromGradient(layer: ILayer, feature): style.Style { - var value = feature.get(layer.name); - var gradient: IGradientstop[] = layer.renderer.colorMap.gradient; - var histogram: IHistogram = layer.renderer.band.histogram; - var index = (value - histogram.min) / histogram.max; - var min = gradient[0]; - var max = gradient[gradient.length - 1]; - for (var n = 0; n < gradient.length; n++) { - var s = gradient[n]; - 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; - } - var i = index - min.relativestop; - var size = max.relativestop - min.relativestop; - var alpha = Math.round( min.color.alpha + ((max.color.alpha - min.color.alpha) * i / size)); - var red = Math.round(min.color.red + ((max.color.red - min.color.red) * i / size)); - var 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)); - - return new style.Style( - { - image: new style.Circle({ - fill: new style.Fill({ - color: this.rgbaToHex(red,green,blue,alpha) - }), - radius: 3 - }), - fill: new style.Fill({ - color: this.rgbaToHex(red, green, blue, alpha) - }), - stroke: new style.Stroke({ - color: this.rgbaToHex(red, green, blue, alpha), - width: 1.25 - }), - }); - } - - createGeotiffLayer(item:IItem,itemLayer:IItemLayer):Layer { - var layerIndex = -1; - var layer: Layer = null; - 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=${item.updated.getTime()}` }); - layer = new Tile({ source: source }); - var data = item.data; - var l = (data && data.layers && data.layers.length > 0) ? data.layers[0] : null; - if (l && l.rendering && l.rendering.renderoutputType == "Tiles") { - var rt = l.rendering as IRenderoutputTiles; - let source = new XYZ({ maxZoom: rt.maxzoom, minZoom: rt.minzoom, url: `${this._apiEndPoint}/api/v1/items/${item.code}/tiles/${layerIndex}/{z}/{x}/{y}.png?v=${item.updated.getTime()}` }); - layer = new Tile({ source: source }); - } - if (l && l.rendering && l.rendering.renderoutputType == "Image") { - var ri = l.rendering as IRenderoutputImage; - let projection = new Projection({ - code: 'image', - units: 'pixels', - extent: ri.extent - }); - let source = new ImageStatic({ imageExtent: ri.extent, projection: projection, url: `${this._apiEndPoint}/api/v1/items/${item.code}/mapimage/${layerIndex}?v=${item.updated.getTime()}` }); - layer = new Image({ source: source }); - } - return layer; - } - - createShapeLayer(item:IItem,itemLayer:IItemLayer):Layer { - var layerIndex = -1; - var layer: Layer = null; - layerIndex = itemLayer.layerIndex != -1 ? itemLayer.layerIndex : item.data.layers[0].index; - var data = item.data; - var l = (data && data.layers && data.layers.length > 0) ? data.layers[0] : null; - if (l && l.rendering && l.rendering.renderoutputType == "VectorTiles") { - var rt = item.data.layers[layerIndex].rendering as IRenderoutputTiles; - layer = new VectorTileLayer({ - declutter: true, - source: new VectorTileSource({ - maxZoom: rt.maxzoom, - minZoom: rt.minzoom, - format: new MVT(), - url: `${this._apiEndPoint}/api/v1/items/${item.code}/vectortiles/{z}/{x}/{y}.pbf?v=${item.updated.getTime()}` - }), - style: (feature) => { - return this.getColorFromGradient(l, feature); - } - }) - } else if (l && l.rendering && l.rendering.renderoutputType == "Tiles") { - var rt = l.rendering as IRenderoutputTiles; - layer = new Tile({ - source: new XYZ({ - maxZoom: rt.maxzoom, - minZoom: rt.minzoom, - url: `${this._apiEndPoint}/api/v1/items/${item.code}/vectortiles/image_tiles/${layerIndex}/{z}/{x}/{y}.png?v=${item.updated.getTime()}` - }) - }); - } else { - let __this = this; - let format = new GeoJSON(); - let source = new VectorSource({ - strategy: loadingstrategy.bbox, - loader: function (extent: Extent, resolution: number, projection: Projection) { - var source = this as VectorSource; - __this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) { - var features = format.readFeatures(data); - for (let f of features) { - if (f.get("code")) { - f.setId(f.get("code")); - } - } - source.addFeatures(features); - }); - } - }); - layer = new VectorLayer({ - source: source, - style: (feature) => { - var key = feature.get("color"); - if (!this.styleCache[key]) { - var color = feature.get("color"); - this.styleCache[key] = new style.Style( - { - fill: new style.Fill({ - color: color - }), - stroke: new style.Stroke({ - color: color, - width: 1.25 - }), - image: new style.Circle({ - fill: new style.Fill({ - color: color - }), - stroke: new style.Stroke({ - color: color, - width: 1.25 - }), - radius: 5 - }), - } - ) - } - return this.styleCache[key]; - } - }); - } - return layer; - } - - createExternalLayer(item:IItem,itemLayer:IItemLayer):Layer { - let data = item.data as ILayerData; - var layer: Layer = null; - switch (data.interfaceType) { - case 'OSM': { - let source = new OSM(); - layer = new Tile({ source: source }); - break; - } - case 'BingMaps': { - let source = new BingMaps(data.options); - layer = new Tile({ source: source }); - break; - } - case 'TileWMS': { - let source = new TileWMS(data.options); - layer = new Tile({ source: source }); - break; - } - case 'TileArcGISRest': { - let source = new TileArcGISRest(data.options); - layer = new Tile({ source: source }); - break; - } - default: { - break; - } - } - return layer; - } - - createLayer(itemLayer: IItemLayer): Layer { - var layer: Layer = null; - var layerIndex = -1; - if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.geotiff.processed') { - layer = this.createGeotiffLayer(itemLayer.item,itemLayer); - } else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.shape.processed') { - layer = this.createShapeLayer(itemLayer.item,itemLayer); - } else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.layer') { - layer = this.createExternalLayer(itemLayer.item,itemLayer); - } - if (layer) { - let geometry = new GeoJSON().readGeometry(itemLayer.item.geometry); - let extent = geometry ? proj.transformExtent(geometry.getExtent(), 'EPSG:4326', 'EPSG:3857') : null; - if (extent) layer.setExtent(extent); - } - - return layer; - } - - ngOnInit() { - super.ngOnInit(); - this.updateLayers(this.itemLayers); - } - - addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer { - if(!itemLayer) return null; - var olLayers = this.instance.getLayers(); - var layer = itemLayer.layer; - let olIndex = olLayers.getArray().indexOf(layer); - if (olIndex < 0) { - // New layer: we add it to the map - layer = this.createLayer(itemLayer); - if (layer) { - olLayers.insertAt(index, layer); - } - } else if (index !== olIndex) { - // layer has moved inside the layers list - olLayers.removeAt(olIndex); - olLayers.insertAt(index, layer); - } - if(layer) { - itemLayer.layer = layer; - layer.setOpacity(itemLayer.opacity); - layer.setVisible(itemLayer.visible); - } - return layer; - } - - updateLayers(itemLayers: IItemLayer[]) { - let newLayers: IItemLayer[] = []; - if (itemLayers) { - itemLayers.forEach((itemLayer, index) => { - if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') { - let il = itemLayer as ITemporalItemLayer; - let previousLayer = this.addOrUpdateOlLayer(il.previousItemLayer,newLayers.length); - if(previousLayer) newLayers.push(previousLayer); - let selectedLayer = this.addOrUpdateOlLayer(il.selectedItemLayer,newLayers.length); - if(selectedLayer) newLayers.push(selectedLayer); - let nextLayer = this.addOrUpdateOlLayer(il.nextItemLayer,newLayers.length); - if(nextLayer) newLayers.push(nextLayer); - } else { - let layer = this.addOrUpdateOlLayer(itemLayer,newLayers.length); - if(layer) newLayers.push(layer); - } - }); - // Remove the layers that have disapeared from childrenLayers - var olLayers = this.instance.getLayers(); - while(olLayers.getLength() > newLayers.length) { - olLayers.removeAt(newLayers.length); - } - } - } - - ngOnChanges(changes: SimpleChanges) { - if (this.instance) { - if (changes['itemLayers']) { - var itemLayers = changes['itemLayers'].currentValue as IItemLayer[]; - this.updateLayers(itemLayers); - } - if (changes['itemLayer']) { - var itemLayer = changes['itemLayer'].currentValue as IItemLayer; - if(itemLayer) { - this.updateLayers([itemLayer]); - } else { - this.updateLayers([]); - } - } - } - } -} diff --git a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts b/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts deleted file mode 100644 index 171a136..0000000 --- a/projects/common-map/src/fm-map/components/aol/item-vector-source/item-vector-source.component.ts +++ /dev/null @@ -1,189 +0,0 @@ -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 { Feature } from 'ol'; -import { Point } from 'ol/geom'; -import { MapBrowserEvent } from 'ol'; -import * as style from 'ol/style'; -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} 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: ``, - providers: [ - { provide: SourceVectorComponent , useExisting: forwardRef(() => ItemVectorSourceComponent) } - ] -}) -export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnChanges { - instance: Vector; - private _format: GeoJSON; - private _select: Select; - private _hoverSelect: Select; - private _iconScale: number = 0.05; - @Input() features: Array; - @Input() selectedFeature: Feature; - @Input() selectedItem: IItem; - @Input() styles:IStyles; - @Output() onFeaturesSelected: EventEmitter = new EventEmitter(); - @Output() onFeatureHover: EventEmitter = new EventEmitter(); - private stylesCache:IStyles = {}; - - constructor(@Host() private layer: LayerVectorComponent, private itemService: ItemService, @Host() private map: MapComponent, private itemTypeService: ItemTypeService,private featureIconService$:FeatureIconService) { - super(layer); - this._format = new GeoJSON(); - } - - geometry(feature: Feature) { - let view = this.map.instance.getView(); - let resolution = view.getResolution(); - var geometry = feature.getGeometry(); - let e = geometry.getExtent(); - //var size = Math.max((e[2] - e[0]) / resolution, (e[3] - e[1]) / resolution); - if (resolution > 12) { - geometry = new Point(extent.getCenter(e)); - } - return geometry; - } - - getSelectedStyle(feature:Feature):style.Style { - let key = feature.get('itemType')+"_selected"; - let evaluatedStyle =null; - var styleEntry = this.stylesCache[key]; - if(styleEntry) { - if(typeof styleEntry === 'function') { - evaluatedStyle = styleEntry(feature); - } else { - evaluatedStyle = styleEntry; - } - } else { - evaluatedStyle = this.stylesCache["selected"]; - } - if(evaluatedStyle ) { - evaluatedStyle.setGeometry((feature) => this.geometry(feature)); - } - return evaluatedStyle - } - - ngOnInit() { - this.strategy = loadingstrategy.bbox; - this.format = new GeoJSON(); - this._select = new Select({ - style:null, - hitTolerance: 10, - layers: [this.layer.instance as Layer] - }); - this._hoverSelect = new Select({ - style: (feature) => { - return this.getSelectedStyle(feature); - }, - hitTolerance: 10, - condition: (e: MapBrowserEvent) => { - return e.type == 'pointermove'; - }, - layers: [this.layer.instance as Layer] - }); - this.map.instance.addInteraction(this._select); - this.map.instance.addInteraction(this._hoverSelect); - this._select.on('select', (e) => { - if (e.selected.length > 0 && e.selected[0]) { - this.onFeaturesSelected.emit(e.selected[0]); - } else { - this.onFeaturesSelected.emit(null); - } - }); - this._hoverSelect.on('select', (e) => { - if (e.selected.length > 0 && e.selected[0]) { - this.onFeatureHover.emit(e.selected[0]); - } else { - this.onFeatureHover.emit(null); - } - }); - this.instance = new Vector(this); - this.host.instance.setSource(this.instance); - - this.host.instance.setStyle((feature) => { - var key = feature.get('itemType') + (this.selectedItem?"_I":""); - if (!this.stylesCache[key]) { - if (this.itemTypeService.itemTypes[key]) { - let itemType = this.itemTypeService.itemTypes[key]; - let fillColor = color.asArray(itemType.iconColor); - fillColor[3] = this.selectedItem?0:0.5; - this.stylesCache[key] = new style.Style({ - image: itemType.icon ? new style.Icon({ - anchor: [0.5, 1], - scale: 0.05, - src: this.featureIconService$.getIconImageDataUrl(itemType.icon) - }):null, - stroke: new style.Stroke({ - color: 'red', - width: 1 - }), - fill: new style.Fill({ - color: fillColor - }), - geometry:(feature) => this.geometry(feature) - }); - } else { - key = 'file'; - } - } - let evaluatedStyle =null; - var styleEntry = this.stylesCache[key]; - if(typeof styleEntry === 'function') { - evaluatedStyle = styleEntry(feature); - } else { - evaluatedStyle = styleEntry; - } - if(evaluatedStyle && evaluatedStyle.geometry_ == null) { - evaluatedStyle.setGeometry((feature) => this.geometry(feature)); - } - return evaluatedStyle; - }); - } - - ngOnChanges(changes: SimpleChanges) { - if (changes["features"] && this.instance) { - this.instance.clear(true); - this._select.getFeatures().clear(); - this.instance.addFeatures(changes["features"].currentValue); - } - - if (changes["selectedFeature"] && this.instance) { - var features = this._hoverSelect.getFeatures(); - var feature = changes["selectedFeature"].currentValue - //this.instance.clear(false); - //this.instance.addFeatures(features.getArray()); - features.clear(); - if (feature) { - //this.instance.removeFeature(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) { - let styles = changes["styles"].currentValue; - for (const key in styles) { - if (styles.hasOwnProperty(key)) { - this.stylesCache[key]=styles[key]; - } - } - } - } -} diff --git a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.html b/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.html deleted file mode 100644 index b1b0624..0000000 --- a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.html +++ /dev/null @@ -1,31 +0,0 @@ -
-
-
-
-
{{itemLayer.item.name}}
-
- - - 25% - 50% - 75% - 100% - - - - -
-
-
- -
-
-
-
-
-
- -
-
No layers
-
-
diff --git a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.scss b/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.scss deleted file mode 100644 index 5f8de97..0000000 --- a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -.layerlist ul { - list-style:none; - padding:0; -} - -.active span.btn.btn-lnk.p-0.border-0 { - color:white; -} - -.btn-sm { - padding:0.25rem 0.3rem; -} - -.legend { - margin-top:0.5rem; - color:black; - padding:0.25rem; -} diff --git a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.ts b/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.ts deleted file mode 100644 index 4f90e86..0000000 --- a/projects/common-map/src/fm-map/components/aol/layer-list/layer-list.component.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Component,Input,Output,EventEmitter } from '@angular/core'; -import { IItemLayer } from '../../../models/item.layer'; - -@Component({ - selector: 'fm-map-layer-list', - templateUrl: './layer-list.component.html', - styleUrls: ['./layer-list.component.scss'] -}) - -export class LayerListComponent { - @Input() itemLayers: IItemLayer[] = []; - @Input() baseLayers: boolean = false; - @Output() onToggleVisibility = new EventEmitter(); - @Output() onSetOpacity = new EventEmitter<{layer: IItemLayer,opacity:number }>(); - @Output() onDelete = new EventEmitter(); - @Output() onZoomToExtent = new EventEmitter(); - @Output() onSelectLayer = new EventEmitter(); - @Input() selectedLayer: IItemLayer; - - constructor( ) { - } - - handleDelete(event:MouseEvent, item:IItemLayer) { - this.onDelete.emit(item); - event.preventDefault(); - } - - handleToggleVisibility(event:MouseEvent, item: IItemLayer) { - this.onToggleVisibility.emit(item); - item.legendVisible = item.visible && item.legendVisible; - event.preventDefault(); - } - - handleSetOpacity(event: MouseEvent, layer: IItemLayer,opacity:number) { - this.onSetOpacity.emit({ layer,opacity }); - event.preventDefault(); - } - - handleZoomToExtent(event: MouseEvent, item: IItemLayer) { - this.onZoomToExtent.emit(item); - event.preventDefault(); - } - - handleSelectLayer(event: MouseEvent, item: IItemLayer) { - this.onSelectLayer.emit(item); - event.preventDefault(); - } - - firstLayer(item: IItemLayer): any { - if (item && item.item && item.item.data && item.item.data.layers && item.item.data.layers.length > 0) return item.item.data.layers[0]; - return null; - } - - toggleLegend(event: MouseEvent, lg: boolean) { - event.preventDefault(); - return !lg; - } - - handleLegendClick(event: MouseEvent, item: IItemLayer) { - this.onSelectLayer.emit(item); - this.onZoomToExtent.emit(item); - event.preventDefault(); - } -} diff --git a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts b/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts deleted file mode 100644 index 2fc6306..0000000 --- a/projects/common-map/src/fm-map/components/aol/layer-vector-image/layer-vector-image.component.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, OnDestroy, OnInit, Input, Optional, OnChanges, SimpleChanges } from '@angular/core'; -import { Vector } from 'ol/layer'; -import { Style } from 'ol/style'; -import { StyleFunction } from 'ol/style/Style'; -import { LayerVectorComponent, LayerGroupComponent, MapComponent } from 'ngx-openlayers'; -import { RenderType } from 'ol/layer/Vector'; - -@Component({ - selector: 'fm-map-aol-layer-vector-image', - template: ` - - `, -}) -export class LayerVectorImageComponent extends LayerVectorComponent implements OnInit, OnDestroy, OnChanges { - public source: Vector; - - @Input() - renderMode: RenderType | string = "image"; - - constructor(map: MapComponent) { - super(map); - } - - ngOnInit() { - super.ngOnInit(); - } - - ngOnChanges(changes: SimpleChanges) { - super.ngOnChanges(changes); - } -} diff --git a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.html b/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.html deleted file mode 100644 index 079f1fa..0000000 --- a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
- - - -
diff --git a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.scss b/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.scss deleted file mode 100644 index 208843e..0000000 --- a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.scss +++ /dev/null @@ -1,37 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - -.gps-location { - display:block; - width:2.5em; - height:2.5em; - background-color: $body-bg; - background-size: contain; - margin-top:0.5em; - border-radius: 1.75em; - padding:0 -} - -.center, .tolerance, .border { - stroke-width: 0; -} - -.pan-to { - fill: $secondary; -} - -div.gps-location:hover .pan-to { - fill: $white; -} - -.pan-to-centered { - fill: $primary; -} - -div.gps-location:hover .pan-to-centered { - fill: theme-color-level($color-name: "primary", $level: -10) -} - -.pan-to.pan-to-disabled { - fill: $gray-300; -} diff --git a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts b/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts deleted file mode 100644 index b709e64..0000000 --- a/projects/common-map/src/fm-map/components/aol/pan-to-location/pan-to-location.component.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Component, OnInit, Input, Host, OnChanges, SimpleChanges,ChangeDetectorRef } from '@angular/core'; -import { MapComponent } from 'ngx-openlayers'; -import {IMapState} from '../../../models/map.state' -import {View} from 'ol'; -import { fromLonLat } from 'ol/proj'; - - -@Component({ - selector: 'fm-map-pan-to-location', - templateUrl: './pan-to-location.component.html', - styleUrls: ['./pan-to-location.component.scss'] -}) -export class PanToLocation implements OnInit,OnChanges{ - - view: View; - map: MapComponent; - @Input() position: Position; - @Input() mapState: IMapState; - @Input() animate: boolean; - - constructor(@Host() map: MapComponent,private changeDetectorRef$: ChangeDetectorRef ) { - this.map = map; - } - - ngOnInit() { - this.view = this.map.instance.getView(); - this.view.on('change:center', () => { - this.changeDetectorRef$.detectChanges(); - }); - } - - ngOnChanges(changes: SimpleChanges) { - // if (changes.position && this.instance) { - // var p = changes.position.currentValue as Position; - // this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude])); - // this.locationTolerance = p.coords.accuracy; - // this.recalcLocationTolerance(); - // this.heading = p.coords.heading; - // } - } - - p - - public centered():boolean { - if(this.position && this.mapState) { - let center = this.view.getCenter(); - let newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]); - let x1 = newCenter[0].toFixed(0); - let x2 = center[0].toFixed(0); - let y1 = newCenter[1].toFixed(0); - let y2 = center[1].toFixed(0); - return x1==x2 && y1==y2; - } - return false; - } - - public disabled():boolean { - return !this.position; - } - - handleClick(event:Event) { - if(this.position) { - let view = this.map.instance.getView(); - let newCenter = fromLonLat([this.position.coords.longitude,this.position.coords.latitude]); - let extent = [newCenter[0]-500,newCenter[1]-500,newCenter[0]+500,newCenter[1]+500]; - var options = { padding: [0, 0, 0, 0],minResolution:1 }; - let size = this.map.instance.getSize(); - let rem = parseFloat(getComputedStyle(document.documentElement).fontSize); - let threshold = 44 * rem; - var left = 1 * rem; - var right = 1 * rem; - var bottom = Math.round(size[1] / 2); - var top = 1 * rem; - if (size[0] > threshold) { - bottom = 1 * rem; - left = 23 * rem; - } - //options.padding = [top, right, bottom, left]; - if (this.animate) options["duration"] = 2000; - view.fit(extent, options); - } - event.preventDefault(); - } -} diff --git a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.html b/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.html deleted file mode 100644 index 63a1221..0000000 --- a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.html +++ /dev/null @@ -1,35 +0,0 @@ -
- - - - - - - - - - - - -
\ No newline at end of file diff --git a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.scss b/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.scss deleted file mode 100644 index 3d304c4..0000000 --- a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.scss +++ /dev/null @@ -1,67 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.compass { - width:2.5em; - height:2.5em; - background-color: white; - opacity: 1; - border-radius:1.75em; - padding:0; - margin-top:0.5em; -} - -#north { - display: none; - fill:$black; -} - -#top-l { - fill:#d40000; -} - -#top-r { - fill:#ff0000; -} - -#bottom-l { - fill:#000000; -} - -#bottom-r { - fill:#666666; -} - -div.compass:hover #top-l { - fill:$white; -} - -div.compass:hover #top-r { - fill:$gray-300; -} - -div.compass:hover #bottom-l { - fill:$gray-300; -} - -div.compass:hover #bottom-r { - fill:$white; -} - -div.compass:hover #north { - fill:$white; -} - -.compass-n { - transition: opacity 1s ease-out 2s,height 1s ease-out 3s,margin-top 1s ease-out 3s; - opacity:0; - height:0; - margin-top:0; -} - -.compass-n #bottom-l, .compass-n #bottom-r { - display: none; -} - -.compass-n #north { - display: inline; -} diff --git a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts b/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts deleted file mode 100644 index f4234e4..0000000 --- a/projects/common-map/src/fm-map/components/aol/rotation-reset/rotation-reset.component.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Component, Host, Input, OnInit, ChangeDetectorRef } from '@angular/core'; -import { ViewComponent, MapComponent } from 'ngx-openlayers'; - -import {View} from 'ol'; - - - -@Component({ - selector: 'fm-map-rotation-reset', - templateUrl: './rotation-reset.component.html', - styleUrls: ['./rotation-reset.component.scss'] -}) -export class RotationResetComponent implements OnInit { - view: View; - - public Rotation() { - let rotation = this.view ? this.view.getRotation() : 0; - return `rotate(${rotation}rad)`; - } - - public IsNorth() { - return this.view ? this.view.getRotation() == 0 : true; - } - - ngOnInit(): void { - this.view = this.map.instance.getView(); - this.view.on('change:rotation', () => { - this.changeDetectorRef$.detectChanges(); - }); - } - - constructor( @Host() private map: MapComponent, private changeDetectorRef$: ChangeDetectorRef ) { - } - - handleClick(event:Event) { - this.view.animate({ rotation: 0 }); - event.preventDefault(); - } -} diff --git a/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts b/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts deleted file mode 100644 index 5e1c22a..0000000 --- a/projects/common-map/src/fm-map/components/aol/switch2d3d/switch2d3d.component.ts +++ /dev/null @@ -1,40 +0,0 @@ -// import { Component, OnInit,Input } from '@angular/core'; -//import { MapComponent } from 'ngx-openlayers'; -//import OLCesium from 'olcs/OLCesium.js'; - - -// @Component({ -// selector: 'fm-map-switch2d3d', -// template: '
{{label}}
', -// styles: [`.twotreed { -// width:2.5em; -// height:2.5em; -// background-color: white; -// text-align:center; -// line-height:2.5em; -// font-weight:bold; -// cursor:default;}`] - -// }) -// export class Switch2D3DComponent { - -// @Input() enable:boolean; -// public label: string = "3D"; -// private ol3d: OLCesium; - - -// constructor(private map: MapComponent) { - -// } - -// ngOnInit() { -// this.ol3d = new OLCesium({ map: this.map.instance }); // ol2dMap is the ol.Map instance -// } - -// handleClick(event) { -// this.enable = !this.enable; -// if (this.enable) -// this.ol3d.setEnabled(this.enable); -// this.label = this.enable?"2D":"3D"; -// } -// } diff --git a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts b/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts deleted file mode 100644 index 83d4990..0000000 --- a/projects/common-map/src/fm-map/components/aol/zoom-to-extent/zoom-to-extent.component.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Component, Host, Input, OnInit, OnChanges, SimpleChanges, forwardRef } from '@angular/core'; -import { ViewComponent, MapComponent } from 'ngx-openlayers'; - - -@Component({ - selector: 'fm-map-zoom-to-extent', - template: `` -}) -export class ZoomToExtentComponent implements OnChanges { - view: ViewComponent; - map: MapComponent; - @Input() extent: number[]; - @Input() animate: boolean = false; - - constructor(@Host() view: ViewComponent, @Host() map: MapComponent) { - this.view = view; - this.map = map; - } - - ngOnChanges(changes: SimpleChanges) { - if (this.extent) { - var options = { padding: [0, 0, 0, 0],minResolution:1 }; - let size = this.map.instance.getSize(); - let rem = parseFloat(getComputedStyle(document.documentElement).fontSize); - let threshold = 40 * rem; - var left = 1 * rem; - var right = 1 * rem; - var bottom = Math.round(size[1] / 2); - var top = 1 * rem; - if (size[0] > threshold) { - bottom = 1 * rem; - left = 23 * rem; - } - options.padding = [top, right, bottom, left]; - if (this.animate) options["duration"] = 1000; - this.view.instance.fit(this.extent, options); - } - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.html b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.html deleted file mode 100644 index dbbcc97..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.scss b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.scss deleted file mode 100644 index c14a57a..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - - -.row { - border-bottom: 1px solid gray('500'); - user-select: none; -} - -.row.selected { - background-color: gray('100'); -} - -@media screen and (min-width: 44rem) { - .feature-list-container { - margin-top: 4rem; - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts deleted file mode 100644 index e312a99..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject} from '@angular/core'; -import { Feature } from 'ol'; -import { FeatureListComponent,AbstractFeatureListComponent } from '../feature-list/feature-list.component'; -import { WidgetHostDirective } from '../widget-host/widget-host.directive'; -import {IQueryState } from '@farmmaps/common'; -import * as mapReducers from '../../reducers/map.reducer'; -import * as mapActions from '../../actions/map.actions'; -import { Store } from '@ngrx/store'; -import { Observable } from 'rxjs'; - - -@Component({ - selector: 'fm-map-feature-list-container', - templateUrl: './feature-list-container.component.html', - styleUrls: ['./feature-list-container.component.scss'] -}) -export class FeatureListContainerComponent { - - constructor(private store: Store,private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractFeatureListComponent) public featureLists: AbstractFeatureListComponent[] ) { - } - - @Input() features: Array - @Input() queryState: IQueryState; - @Input() selectedFeature: Feature; - @Input() clickedFeature:Observable; - - @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; - componentRef:any; - - loadComponent(queryState:IQueryState) { - var componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(FeatureListComponent); // default - var selected = -1; - for (var i = 0; i < this.featureLists.length; i++) { - if (this.featureLists[i]['forItemType'] == queryState.itemType && this.featureLists[i]['forChild'] && queryState.parentCode && queryState.parentCode != "") { - selected = i; - break; - } else if (this.featureLists[i]['forItemType'] == queryState.itemType) { - selected = i; - break; - } - } - if (selected >= 0) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[i]['constructor'] as any); - if (this.featureLists[selected]['collapseSearch'] === true) { - this.store.dispatch(new mapActions.CollapseSearch()); - } - } - const viewContainerRef = this.widgetHost.viewContainerRef; - viewContainerRef.clear(); - - this.componentRef = viewContainerRef.createComponent(componentFactory); - (this.componentRef.instance).features = null; - (this.componentRef.instance).queryState = queryState; - (this.componentRef.instance).selectedFeature = null; - } - - ngOnInit() { - this.clickedFeature.subscribe((feature => { - (this.componentRef.instance).handleFeatureClick(feature); - })); - } - - ngOnChanges(changes: SimpleChanges) { - if ((changes["queryState"] && changes["queryState"].currentValue)) { - this.loadComponent(changes["queryState"].currentValue); - } - if ((changes["features"] && changes["features"].currentValue)) { - (this.componentRef.instance).features = changes["features"].currentValue; - } - if(changes["selectedFeature"]) { - (this.componentRef.instance).selectedFeature = changes["selectedFeature"].currentValue; - } - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html b/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html deleted file mode 100644 index 1990c9c..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
- -

Farm

-

{{schemeItem.name}}

-
-
-
- -
-
-
-
-
diff --git a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.scss b/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.scss deleted file mode 100644 index 091b8bb..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.scss +++ /dev/null @@ -1,22 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -fm-map-feature-list-feature-container { - width:100%; - pointer-events:none; -} - -.row { - border-bottom: 1px solid gray('500'); - user-select: none; - padding-left:1.5rem; -} - -.row.selected { - background-color: gray('100'); -} - -.cropfields { - border-top: 1px solid gray('500'); - margin-left: -1.25rem; - margin-right: -1.25rem; -} diff --git a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.ts b/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.ts deleted file mode 100644 index 9e28814..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-cropfield/feature-list-cropfield.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, Injectable,AfterViewInit, OnInit,SimpleChanges, ChangeDetectorRef} from '@angular/core'; -import { Location } from '@angular/common'; -import { AbstractFeatureListComponent } from '../feature-list/feature-list.component'; -import {ForItemType } from '../for-item/for-itemtype.decorator'; -import {ForChild } from '../for-item/for-child.decorator'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService, IItem,ItemService } from '@farmmaps/common'; -import { Observable } from 'rxjs'; - -@ForChild() -@ForItemType("vnd.farmmaps.itemtype.cropfield") -@Injectable() -@Component({ - selector: 'fm-map-feature-list-cropfield', - templateUrl: './feature-list-cropfield.component.html', - styleUrls: ['./feature-list-cropfield.component.scss'] -}) -export class FeatureListCropfieldComponent extends AbstractFeatureListComponent implements OnInit { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, private itemService: ItemService) { - super(store, itemTypeService,location); - } - - public schemeItem: Observable - - ngOnInit() { - this.schemeItem = this.itemService.getItem(this.queryState.parentCode); - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html deleted file mode 100644 index d46dd63..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
- -

 Farms

-
-
-
- -
-
-
-
-
diff --git a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.scss b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.scss deleted file mode 100644 index 2bcf68b..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.scss +++ /dev/null @@ -1,22 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -fm-map-feature-list-feature-container { - width:100%; - pointer-events:none; -} - -.row { - border-bottom: 1px solid gray('500'); - user-select: none; - padding-left:1.5rem; -} - -.row.selected { - background-color: gray('100'); -} - -.farms { - border-top: 1px solid gray('500'); - margin-left: -1.25rem; - margin-right: -1.25rem; -} diff --git a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts b/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts deleted file mode 100644 index 9e359c3..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-croppingscheme/feature-list-croppingscheme.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, Injectable } from '@angular/core'; -import { Location } from '@angular/common'; -import { AbstractFeatureListComponent } from '../feature-list/feature-list.component'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import { Store,Action } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService } from '@farmmaps/common'; -import * as mapActions from '../../actions/map.actions'; -import { tassign } from 'tassign'; -import { Router } from '@angular/router'; -import { Feature } from 'ol'; - -@ForItemType("vnd.farmmaps.itemtype.croppingscheme") -@Injectable() -@Component({ - selector: 'fm-map-feature-list-croppingscheme', - templateUrl: './feature-list-croppingscheme.component.html', - styleUrls: ['./feature-list-croppingscheme.component.scss'] -}) -export class FeatureListCroppingschemeComponent extends AbstractFeatureListComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, private router: Router) { - super(store, itemTypeService, location); - } - - getAction(feature:Feature):Action { - var queryState = tassign(mapReducers.initialState.queryState, { parentCode: feature.get('code'), itemType: "vnd.farmmaps.itemtype.cropfield" }); - return new mapActions.DoQuery(queryState); - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts deleted file mode 100644 index b8771b8..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core'; -import { Feature } from 'ol'; -import { AbstractFeatureListFeatureComponent,FeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component'; -import { WidgetHostDirective } from '../widget-host/widget-host.directive'; - - -@Component({ - selector: 'fm-map-feature-list-feature-container', - template: ` -
- -
- ` -}) -export class FeatureListFeatureContainerComponent { - - constructor(private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractFeatureListFeatureComponent) public featureLists: AbstractFeatureListFeatureComponent[] ) { - } - - @Input() feature: Feature; - - @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; - - loadComponent() { - var componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(FeatureListFeatureComponent); // default - for (var i = 0; i < this.featureLists.length; i++) { - if (this.featureLists[i]['forItemType'] == this.feature.get("itemType")) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[i]['constructor'] as any); - } - } - const viewContainerRef = this.widgetHost.viewContainerRef; - viewContainerRef.clear(); - - const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance).feature = this.feature; - } - - ngOnChanges(changes: SimpleChanges) { - if (changes["feature"] && changes["feature"].currentValue) { - this.loadComponent(); - } - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.html b/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.html deleted file mode 100644 index f4f6829..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
-
- -
-
-
-

{{feature.get('name')}}

-
{{areaInHa(feature)| number:'1.2-2'}} ha {{feature.get('cropTypeName')}}
-
{{feature.get('datadate')|date}} - {{feature.get('dataenddate')|date}}
-
-
diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.scss b/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.scss deleted file mode 100644 index eed8c6a..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.scss +++ /dev/null @@ -1,26 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - - -.card-title { - font-size: 1rem; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.card-text { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - -.col { - overflow: hidden; -} - -.thumbnail { - width: 4em; - height: 4em; -} - diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts deleted file mode 100644 index 5607324..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-cropfield/feature-list-feature-cropfield.component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Component, Injectable,ViewChild,AfterViewInit} from '@angular/core'; -import { Feature } from 'ol'; -import * as extent from 'ol/extent'; -import * as render from 'ol/render'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; -import { AbstractFeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import {getArea} from 'ol/sphere'; -import * as style from 'ol/style'; - - -@ForItemType("vnd.farmmaps.itemtype.cropfield") -@Injectable() -@Component({ - selector: 'fm-map-feature-list-feature-cropfield', - templateUrl: './feature-list-feature-cropfield.component.html', - styleUrls: ['./feature-list-feature-cropfield.component.scss'] -}) -export class FeatureListFeatureCropfieldComponent extends AbstractFeatureListFeatureComponent implements AfterViewInit { - - @ViewChild('canvas') canvas; - @ViewChild('container') container; - - constructor(store: Store, itemTypeService: ItemTypeService,config:AppConfig) { - super(store, itemTypeService,config); - } - - areaInHa(feature:Feature):number { - if(!feature) return 0; - // get area from faeture if 0 calculate from polygon - let a = feature.get('area'); - if(a) return a; - return getArea(feature.getGeometry(),{projectio:"EPSG:3857"}) / 10000; - } - - - render(canvas,width,height,feature:Feature) { - let renderContext = render.toContext(canvas.getContext( '2d'),{ size: [width, height] }); - - let strokeStyle = new style.Style({ - stroke: new style.Stroke({ color: 'black',width:1.5 }) - }); - - let geom = feature.getGeometry().clone(), - line = geom.getCoordinates()[0], - e = extent.boundingExtent( line ); - - let dxy = extent.getCenter(e), - sxy = [ - (width - 2 ) / extent.getWidth(e), - (height - 2 ) / extent.getHeight(e) - ]; - - let dx = dxy[0], - dy = dxy[1], - sx = sxy[0], - sy = sxy[1]; - - geom.translate( -dx, -dy ); - geom.scale( Math.min(sx, sy), -Math.min(sx, sy)); - geom.translate( width / 2, height / 2 ); - - renderContext.setStyle( strokeStyle ); - renderContext.drawGeometry( geom ); - } - - ngAfterViewInit() { - this.render(this.canvas.nativeElement, - this.container.nativeElement.offsetWidth, - this.container.nativeElement.offsetHeight, - this.feature); - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.html b/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.html deleted file mode 100644 index c817671..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
-

{{feature.get('name')}}

-
{{feature.get('datadate')|date:'shortDate'}}
-
-
diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.scss b/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.scss deleted file mode 100644 index da7a010..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - - -.card-title { - font-size: 1rem; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.thumbnail > img { - width: 100%; - height: auto; -} - -.thumbnail > div { - width: 100%; - font-size: 2rem; - text-align: center; - min-height: 3rem; - color: white; - padding-top: 0.5rem; -} - -.col { - overflow: hidden; -} - diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.ts deleted file mode 100644 index 1ff3c64..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature-croppingscheme/feature-list-feature-croppingscheme.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, Input, Injectable} from '@angular/core'; -import { Feature } from 'ol'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; -import { AbstractFeatureListFeatureComponent } from '../feature-list-feature/feature-list-feature.component'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; - - -@ForItemType("vnd.farmmaps.itemtype.croppingscheme") -@Injectable() -@Component({ - selector: 'fm-map-feature-list-feature-croppingscheme', - templateUrl: './feature-list-feature-croppingscheme.component.html', - styleUrls: ['./feature-list-feature-croppingscheme.component.scss'] -}) -export class FeatureListFeatureCroppingschemeComponent extends AbstractFeatureListFeatureComponent { - - constructor(store: Store, itemTypeService: ItemTypeService,config:AppConfig) { - super(store, itemTypeService,config); - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.html b/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.html deleted file mode 100644 index 5eca85c..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
- -
- -
-
-
-

 {{feature.get('name')}}

-
{{feature.get('datadate')|date:'shortDate'}}
-
-
diff --git a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.scss b/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.scss deleted file mode 100644 index da7a010..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - - -.card-title { - font-size: 1rem; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.thumbnail > img { - width: 100%; - height: auto; -} - -.thumbnail > div { - width: 100%; - font-size: 2rem; - text-align: center; - min-height: 3rem; - color: white; - padding-top: 0.5rem; -} - -.col { - overflow: hidden; -} - diff --git a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts deleted file mode 100644 index 8a37cdb..0000000 --- a/projects/common-map/src/fm-map/components/feature-list-feature/feature-list-feature.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Component, Input, Injectable,Directive} from '@angular/core'; -import { Feature } from 'ol'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService,AppConfig } from '@farmmaps/common'; - - - -@Injectable() -@Directive() -export abstract class AbstractFeatureListFeatureComponent { - @Input() feature: Feature - - constructor(public store: Store, public itemTypeService: ItemTypeService,public config:AppConfig) { - } -} - -@Injectable() -@Component({ - selector: 'fm-map-feature-list-feature', - templateUrl: './feature-list-feature.component.html', - styleUrls: ['./feature-list-feature.component.scss'] -}) -export class FeatureListFeatureComponent extends AbstractFeatureListFeatureComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, config:AppConfig) { - super(store, itemTypeService,config); - } -} diff --git a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.html b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.html deleted file mode 100644 index be62e8b..0000000 --- a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.html +++ /dev/null @@ -1,6 +0,0 @@ -
- Go back -
- -
-
diff --git a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.scss b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.scss deleted file mode 100644 index 6a0803d..0000000 --- a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.scss +++ /dev/null @@ -1,15 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -fm-map-feature-list-feature-container { - width: 100%; - pointer-events: none; -} - -.row { - border-bottom: 1px solid gray('500'); - user-select: none; -} - -.row.selected { - background-color: gray('100'); -} diff --git a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts b/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts deleted file mode 100644 index 241de46..0000000 --- a/projects/common-map/src/fm-map/components/feature-list/feature-list.component.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Component, Input, Injectable,Directive,SimpleChanges } from '@angular/core'; -import { Location } from '@angular/common'; -import { Feature } from 'ol'; -import { Store,Action} from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService, IItem, Item } from '@farmmaps/common'; -import * as mapActions from '../../actions/map.actions'; -import { Observable, from } from 'rxjs'; -import { withLatestFrom } from 'rxjs/operators'; -import { tassign } from 'tassign'; -import { IQueryState } from '@farmmaps/common'; - - -@Injectable() -@Directive() -export abstract class AbstractFeatureListComponent { - @Input() features: Array; - @Input() queryState: IQueryState; - @Input() selectedFeature: Feature; - constructor(public store: Store, public itemTypeService: ItemTypeService, private location: Location) { - } - - handleFeatureClick(feature:Feature) { - if(feature) { - let action = this.getAction(feature); - this.store.dispatch(action); - } - } - - getAction(feature:Feature):Action { - var newQuery: any = tassign(mapReducers.initialState.queryState); - newQuery.parentCode = feature.get('parentCode'); - newQuery.itemCode = feature.get('code'); - newQuery.itemType = feature.get('itemType'); - return new mapActions.DoQuery(newQuery) - } - - handleFeatureMouseEnter(feature) { - this.store.dispatch(new mapActions.SelectFeature(feature)); - } - - handleFeatureMouseLeave(feature) { - this.store.dispatch(new mapActions.SelectFeature(null)); - } - - handleBackClick(event: MouseEvent) { - event.preventDefault(); - this.location.back(); - } - - isFeatureSelected(feature:Feature):boolean { - if(!this.selectedFeature) return false; - return feature.getId() == this.selectedFeature.getId(); - } -} - -@Injectable() -@Component({ - selector: 'fm-map-feature-list', - templateUrl: './feature-list.component.html', - styleUrls: ['./feature-list.component.scss'] -}) -export class FeatureListComponent extends AbstractFeatureListComponent { - - constructor(store: Store, itemTypeService: ItemTypeService,location:Location) { - super(store, itemTypeService,location); - } -} diff --git a/projects/common-map/src/fm-map/components/for-item/for-child.decorator.ts b/projects/common-map/src/fm-map/components/for-item/for-child.decorator.ts deleted file mode 100644 index d150ff1..0000000 --- a/projects/common-map/src/fm-map/components/for-item/for-child.decorator.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function ForChild() { - return function (constructor:Function) { - constructor.prototype.forChild = true; - }; -} diff --git a/projects/common-map/src/fm-map/components/for-item/for-itemtype.decorator.ts b/projects/common-map/src/fm-map/components/for-item/for-itemtype.decorator.ts deleted file mode 100644 index 8887239..0000000 --- a/projects/common-map/src/fm-map/components/for-item/for-itemtype.decorator.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function ForItemType(itemType: string) { - return function (constructor:Function) { - constructor.prototype.forItemType = itemType; - }; -} diff --git a/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.js.map b/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.js.map deleted file mode 100644 index dced9bf..0000000 --- a/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"for-sourcetask.decorator.js","sourceRoot":"","sources":["for-sourcetask.decorator.ts"],"names":[],"mappings":";;AAAA,SAAgB,aAAa,CAAC,UAAkB;IAC9C,OAAO,UAAU,WAAoB;QACnC,WAAW,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,CAAC;IACnD,CAAC,CAAC;AACJ,CAAC;AAJD,sCAIC"} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.ts b/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.ts deleted file mode 100644 index 03d4664..0000000 --- a/projects/common-map/src/fm-map/components/for-item/for-sourcetask.decorator.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function ForSourceTask(sourceTask: string) { - return function (constructor:Function) { - constructor.prototype.forSourceTask = sourceTask; - }; -} diff --git a/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts b/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts deleted file mode 100644 index 29e22e3..0000000 --- a/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core'; -import { AbstractItemListItemComponent,ItemListItemComponent } from '../item-list-item/item-list-item.component'; -import { WidgetHostDirective } from '../widget-host/widget-host.directive'; -import { IItem, IListItem } from '@farmmaps/common'; - - -@Component({ - selector: 'fm-map-item-list-item-container', - template: ` -
- -
- ` -}) -export class ItemListItemContainerComponent { - - constructor(private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractItemListItemComponent) public itemComponentList: AbstractItemListItemComponent[] ) { - } - - @Input() item: IListItem; - - @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; - - loadComponent() { - var componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(ItemListItemComponent); // default - for (var i = 0; i < this.itemComponentList.length; i++) { - if (this.itemComponentList[i]['forItemType'] && - this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0 && - this.itemComponentList[i]['forSourceTask'] && - this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0 ) - { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.itemComponentList[i]['constructor'] as any); - } - } - const viewContainerRef = this.widgetHost.viewContainerRef; - viewContainerRef.clear(); - - const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance).item = this.item; - } - - ngOnChanges(changes: SimpleChanges) { - if (changes["item"] && changes["item"].currentValue) { - this.loadComponent(); - } - } -} diff --git a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.html b/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.html deleted file mode 100644 index 2904dc3..0000000 --- a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
-
-
{{item.name}}
-
diff --git a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.scss b/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.scss deleted file mode 100644 index ed170c3..0000000 --- a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.scss +++ /dev/null @@ -1,26 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.widget { - padding:0.8rem; - height:100%; - width:100%; - color:#ffffff; - position:relative; -} - -.icon { - display:block; - font-size:6rem; - text-align:center; -} -.title { - display:block; - position:absolute; - width:calc(100% - 1.6rem ); - padding-top:0.5rem; - bottom:0.8rem; - height:2rem; - overflow:hidden; - white-space:nowrap; - text-overflow:ellipsis; -} diff --git a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.ts b/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.ts deleted file mode 100644 index 84ea054..0000000 --- a/projects/common-map/src/fm-map/components/item-list-item/item-list-item.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Component, Input, Injectable,Directive} from '@angular/core'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService,IListItem } from '@farmmaps/common'; - - - -@Injectable() -@Directive() -export abstract class AbstractItemListItemComponent { - @Input() item: IListItem - - constructor(public store: Store, public itemTypeService: ItemTypeService) { - } - - getScaledValue(value:number,scale:number = 0):number { - let v = value; - if(scale && scale != 0) { - v=scale*value; - } - return v; - } -} - -@Injectable() -@Directive() -export abstract class AbstractItemWidgetComponent { - @Input() item: IListItem - - constructor(public store: Store, public itemTypeService: ItemTypeService) { - } - - getScaledValue(value:number,scale:number = 0):number { - let v = value; - if(scale && scale != 0) { - v=scale*value; - } - return v; - } -} - -@Injectable() -@Component({ - selector: 'fm-map-item-list-item', - templateUrl: './item-list-item.component.html', - styleUrls: ['./item-list-item.component.scss'] -}) -export class ItemListItemComponent extends AbstractItemListItemComponent { - - constructor(store: Store, itemTypeService: ItemTypeService) { - super(store, itemTypeService); - } -} diff --git a/projects/common-map/src/fm-map/components/item-list/item-list.component.html b/projects/common-map/src/fm-map/components/item-list/item-list.component.html deleted file mode 100644 index f705380..0000000 --- a/projects/common-map/src/fm-map/components/item-list/item-list.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
- -
-
-
diff --git a/projects/common-map/src/fm-map/components/item-list/item-list.component.scss b/projects/common-map/src/fm-map/components/item-list/item-list.component.scss deleted file mode 100644 index 16982ec..0000000 --- a/projects/common-map/src/fm-map/components/item-list/item-list.component.scss +++ /dev/null @@ -1,41 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.widget-container { - overflow:auto; - margin-bottom:1rem; -} - -.widget { - position:relative; - border: 1px solid gray('500'); - user-select: none; - display:inline-block; - width:50%; - overflow:hidden; - float:left; -} - -.widget:after { - content: ""; - display: block; - padding-bottom: 66%; -} - -.content { - position:absolute; - width:100%; - height:100%; -} - -.widget:hover { - background-color: gray('100'); -} - -.widget-container { - padding:1rem; -} - -.item-container { - display:block; - height:100%; -} diff --git a/projects/common-map/src/fm-map/components/item-list/item-list.component.ts b/projects/common-map/src/fm-map/components/item-list/item-list.component.ts deleted file mode 100644 index d154a21..0000000 --- a/projects/common-map/src/fm-map/components/item-list/item-list.component.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Component, Input, Injectable, Directive } from '@angular/core'; -import { Location } from '@angular/common'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService,IListItem } from '@farmmaps/common'; -import * as mapActions from '../../actions/map.actions'; -import { tassign } from 'tassign'; - - -@Injectable() -@Directive() -export abstract class AbstractItemListComponent { - @Input() items: Array - constructor(public store: Store, public itemTypeService: ItemTypeService, private location: Location) { - } - - handleItemClick(item:IListItem) { - var newQuery: any = tassign(mapReducers.initialState.query); - newQuery.itemCode = item.code; - this.store.dispatch(new mapActions.DoQuery(newQuery)); - } - - handleBackClick(event: MouseEvent) { - event.preventDefault(); - this.location.back(); - } -} - -@Injectable() -@Component({ - selector: 'fm-map-item-list', - templateUrl: './item-list.component.html', - styleUrls: ['./item-list.component.scss'] -}) -export class ItemListComponent extends AbstractItemListComponent { - - constructor(store: Store, itemTypeService: ItemTypeService,location:Location) { - super(store, itemTypeService,location); - } -} diff --git a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.html b/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.html deleted file mode 100644 index 081275c..0000000 --- a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
- -
-
-
diff --git a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.scss b/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.scss deleted file mode 100644 index 622a821..0000000 --- a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.scss +++ /dev/null @@ -1,41 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.widget-container { - overflow:auto; - margin-bottom:1rem; -} - -.widget { - position:relative; - border: 1px solid gray('500'); - user-select: none; - display:inline-block; - width:50%; - overflow:hidden; - float:left; -} - -.widget:after { - content: ""; - display: block; - padding-bottom: 100%; -} - -.content { - position:absolute; - width:100%; - height:100%; -} - -.widget:hover { - background-color: gray('100'); -} - -.widget-container { - padding:1rem; -} - -.item-container { - display:block; - height:100%; -} diff --git a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.ts b/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.ts deleted file mode 100644 index bdda476..0000000 --- a/projects/common-map/src/fm-map/components/item-widget-list/item-widget-list.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Component, Input, Injectable, Inject, Optional,ComponentFactoryResolver, ViewContainerRef, QueryList, ComponentFactory, ViewChildren,AfterViewInit } from '@angular/core'; -import { Location } from '@angular/common'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers,ItemTypeService, IItem, Item,IListItem } from '@farmmaps/common'; -import { AbstractItemWidgetComponent } from '../item-list-item/item-list-item.component'; - - -@Injectable() -@Component({ - selector: 'fm-map-item-widget-list', - templateUrl: './item-widget-list.component.html', - styleUrls: ['./item-widget-list.component.scss'] -}) -export class ItemWidgetListComponent implements AfterViewInit { - - @Input() item: IListItem; - public widgets: AbstractItemWidgetComponent[]; - @ViewChildren('widgetTemplate', { read: ViewContainerRef }) private widgetTargets: QueryList; - - constructor(public store: Store, public itemTypeService: ItemTypeService, public location: Location, private componentFactoryResolver: ComponentFactoryResolver, @Optional() @Inject(AbstractItemWidgetComponent) itemWidgetComponentList: AbstractItemWidgetComponent[]) { - this.widgets = itemWidgetComponentList; //todo filter this list on widgets available for user - } - - ngAfterViewInit() { - let targets = this.widgetTargets.toArray(); - if(this.widgets) { - for (var i = 0; i < this.widgets.length; i++) { - var componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(this.widgets[i]['constructor'] as any); - const viewContainerRef = targets[i]; - viewContainerRef.clear(); - - const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance).item = this.item; - } - } - } -} diff --git a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.html b/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.html deleted file mode 100644 index 0c43ffd..0000000 --- a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.html +++ /dev/null @@ -1,25 +0,0 @@ -
- - -
diff --git a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.scss b/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.scss deleted file mode 100644 index 47a85e4..0000000 --- a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.scss +++ /dev/null @@ -1,71 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - -.layer-switcher { - display:block; - width:2.5em; - height:2.5em; - background-color: $body-bg; - background-size: contain; - margin-top:0.5em; - text-align: center; - line-height: 2.5em; - border-radius: 1.75em; - padding: 0; - color: $secondary; -} - -.layer-switcher i { - font-weight: bold; -} - -.layers { - color:$secondary; - position: absolute; - overflow: hidden; - bottom: -1em; - right: -1em; - text-align: left; - min-width: 100vw; - z-index: 4; - // transition: max-height 0.3s ease-out,max-width 0.3s ease-out,min-height 0.3s ease-out,min-width 0.3s ease-out; -} - -.hidden { - max-width:0; - max-height: 0; - min-height: 0; - min-width: 0; -} - -.navbar-nav { - padding-left: 7px; - padding-right: 7px; - margin-bottom: 7px; - overflow-x: hidden; - overflow-y: auto; - bottom:-3rem; - height: 50vh; -} - -@media screen and (min-width:44rem) { - .layer-switcher { - position: relative; - } - - .layers { - max-width: 100%; - min-width: 22em; - bottom: 2.5em; - right: 2.5em; - min-height: 0; - max-height: calc(100vh - 9rem); - } - - .hidden { - max-width:0; - max-height: 0; - min-height: 0; - min-width: 0; - } -} diff --git a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.ts b/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.ts deleted file mode 100644 index 484fc80..0000000 --- a/projects/common-map/src/fm-map/components/layer-switcher/layer-switcher.component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Component, OnInit, OnChanges, SimpleChanges } from '@angular/core'; -import {IItemLayer} from '../../models/item.layer'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import * as mapActions from '../../actions/map.actions'; -import {createEmpty,extend } from 'ol/extent'; -import { Observable } from 'rxjs'; - -@Component({ - selector: 'fm-map-layer-switcher', - templateUrl: './layer-switcher.component.html', - styleUrls: ['./layer-switcher.component.scss'] -}) -export class LayerSwitcher implements OnInit,OnChanges{ - - public showLayerSwitcher:Observable; - public overlayLayers: Observable>; - public selectedOverlayLayer: Observable; - public baseLayers: Observable>; - public selectedBaseLayer: Observable; - - constructor( private store: Store) { - } - - ngOnInit() { - this.overlayLayers = this.store.select(mapReducers.selectGetOverlayLayers); - this.selectedOverlayLayer = this.store.select(mapReducers.selectGetSelectedOverlayLayer); - this.baseLayers = this.store.select(mapReducers.selectGetBaseLayers); - this.selectedBaseLayer = this.store.select(mapReducers.selectGetSelectedBaseLayer); - this.showLayerSwitcher = this.store.select(mapReducers.selectGetShowLayerSwitcher); - } - - ngOnChanges(changes: SimpleChanges) { - } - - - - handleClick(event:Event) { - this.store.dispatch(new mapActions.ShowLayerSwitcher(true)); - } - - close(event:Event) { - this.store.dispatch(new mapActions.ShowLayerSwitcher(false)); - } - - - - handleOnToggleVisibility(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SetVisibility(itemLayer,!itemLayer.visible)); - } - - handleOnSetOpacity(event:{ layer: IItemLayer,opacity:number }) { - this.store.dispatch(new mapActions.SetOpacity(event.layer, event.opacity)); - } - - handleOnDelete(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.RemoveLayer(itemLayer)); - } - - handleZoomToExtent(itemLayer: IItemLayer) { - var extent = createEmpty(); - extend(extent, itemLayer.layer.getExtent()); - if (extent) { - this.store.dispatch(new mapActions.SetExtent(extent)); - } - } - - handleSelectOverlayLayer(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SelectOverlayLayer(itemLayer)); - } - - handleSelectBaseLayer(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SelectBaseLayer(itemLayer)); - } -} diff --git a/projects/common-map/src/fm-map/components/legend/legend.component.html b/projects/common-map/src/fm-map/components/legend/legend.component.html deleted file mode 100644 index e66953f..0000000 --- a/projects/common-map/src/fm-map/components/legend/legend.component.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - -
-
-

{{layer.name}}

- ({{layer.unit}}) -
-
-
-

{{histogram}}

- ({{histogramunit}}) -
-
{{getScaledValue(entry.value,layer.scale) | number:'1.0-2'}} {{legendunit}}{{entry.label}} -
- - - {{getLabel(layer.renderer,i)}} -
-
- -
-
Average: {{layer.renderer.band.histogram.mean| number:'1.0-3'}}
-
Standard deviation: {{layer.renderer.band.histogram.stddev| number:'1.0-3'}}
-
Min: {{layer.renderer.band.histogram.min| number:'1.0-3'}}
-
Max: {{layer.renderer.band.histogram.max| number:'1.0-3'}}
-
Confidence interval: {{layer.renderer.band.histogram.confidence * 100| number:'1.0-0'}}%
-
-
- - - - - diff --git a/projects/common-map/src/fm-map/components/legend/legend.component.scss b/projects/common-map/src/fm-map/components/legend/legend.component.scss deleted file mode 100644 index 8ba4fd7..0000000 --- a/projects/common-map/src/fm-map/components/legend/legend.component.scss +++ /dev/null @@ -1,71 +0,0 @@ - -.container { - max-width: 40em; - border-spacing: 0.5em; - font-family: inherit; -} - -.title { - padding: 7px; - text-align: center; - font-size: 14px; - line-height: 28px; -} - -.title > h4 { - margin-bottom: 0; -} - -span.color { - display:inline-block; - width: 1.5em; - height: 1.5em; -} - -.legend-items { - padding: 0.1em; - border-style: none; - border-width: 0.05em; -} - -.legend-items div { - width:100%; - height:100%; -} - -.legend-items-text { - max-width: 20em; - padding-left: 0.5em; - text-align: left; - white-space: nowrap; -} - -.histogram-items { - width: 100%; - padding-left: 1em; -} - - -.histogram-items-text { - max-width: 20em; - font-size: 14pt; - padding-left: 1em; - text-align: left; -} - -.bar { - display:inline-block; - height: 1em; - vertical-align: middle; -} - -.bar-label { - margin-left:0.3em; - font-size:0.7em; -} - -.info { - line-height: 1.3em; -} - - diff --git a/projects/common-map/src/fm-map/components/legend/legend.component.ts b/projects/common-map/src/fm-map/components/legend/legend.component.ts deleted file mode 100644 index 2244a27..0000000 --- a/projects/common-map/src/fm-map/components/legend/legend.component.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { Component, OnInit, Input,AfterViewInit } from '@angular/core'; -import { IColorMap, IColor, IColorEntry,ILayer, IRenderer } from '../../models/color.map'; - - -@Component({ - selector: 'fm-map-layer-legend', - templateUrl: './legend.component.html', - styleUrls: ['./legend.component.scss'] -}) -export class LegendComponent implements OnInit,AfterViewInit { - - constructor() { - - } - - ngOnInit() { - } - - ngAfterViewInit() { - } - - @Input() - layer: ILayer; - - @Input() - legend: string; - - @Input() - histogram: string; - - @Input() - showTitle: boolean = true; - - @Input() - histogramenabled: boolean; - - @Input() - legendunit: string; - - @Input() - histogramunit: string; - - public hideHistogramDetails:boolean = true; - - onClickHistoGram(): void { - this.histogramenabled = !this.histogramenabled; - } - - - - - public getHex(color: IColor): string { - return '#' + this.componentToHex(color.red) + this.componentToHex(color.green) + this.componentToHex(color.blue); - } - - private componentToHex(c: number): string { - const hex = c.toString(16); - return hex.length === 1 ? `0${hex}` : hex; - } - - public getPart(renderer: IRenderer, index: number): string { - let max = renderer.band.histogram.entries.reduce((max, entry) => entry.freqency > max ? entry.freqency : max, 0); - let scale = 65 / max; - let part = (renderer.band.histogram.entries[index].freqency * scale) + "%"; - - return part; - } - - public getScaledValue(value:number,scale:number):number { - let v = value; - if(scale && scale != 0) { - v=scale*value; - } - return v; - } - - public getLabel(renderer: IRenderer, index: number): string { - let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0); - let percent = renderer.band.histogram.entries[index].freqency * scale; - return percent < 0.1 ? "" : percent.toFixed(1) + " %"; - } - - showLegend(): boolean { - return this.layer && this.layer.renderer && this.layer.renderer.renderType != "MULTIBAND_COLOR"; - } - - showHistogram(): boolean { - return this.histogramenabled && this.layer.renderer.band.histogram.entries && this.layer.renderer.band.histogram.entries.length > 0 && this.layer.renderer.colorMap.colormapType == "minmax"; - } - - showConfidenceInterval():boolean { - return this.histogramenabled && this.layer.renderer.band.histogram.confidence != null && this.layer.renderer.band.histogram.confidence != 1; - } -} - - diff --git a/projects/common-map/src/fm-map/components/map-search/map-search.component.html b/projects/common-map/src/fm-map/components/map-search/map-search.component.html deleted file mode 100644 index f90acf6..0000000 --- a/projects/common-map/src/fm-map/components/map-search/map-search.component.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - diff --git a/projects/common-map/src/fm-map/components/map-search/map-search.component.scss b/projects/common-map/src/fm-map/components/map-search/map-search.component.scss deleted file mode 100644 index 65b673c..0000000 --- a/projects/common-map/src/fm-map/components/map-search/map-search.component.scss +++ /dev/null @@ -1,122 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -div.map-search { - position: absolute; - top: 0.5rem; - left: 0.5rem; - transition: opacity 0.5s ease-out, left 0.3s,max-height 0.3s ease-out,max-width 0.3s ease-out; - max-height: 10rem; - min-width: calc(100vw - 1rem); - box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); - z-index:3; -} - -.input-group { - flex-wrap:nowrap; -} - -.disabled { - color:lighten(#000000,80%); -} - -:host ::ng-deep ngb-typeahead-window.dropdown-menu { - width: 20rem; - left:-2.5rem !important; -} - -:host ::ng-deep button.dropdown-item { - overflow:hidden; - text-overflow:ellipsis; - padding: 0.375rem 0.75rem; -} - -div.map-search input[type=text] { - transition: width 0.3s ease-out; -} - -div.map-search button { - transition: width 0.3s ease-out; -} - -div.map-search.collapsed { - max-height:3.5rem; - max-width:10rem; - min-width: 0; -} - -div.map-search.searchcollapsed { - max-height: 3.5rem; - max-width: 6rem; - min-width: unset; -} - -div.map-search div.options { - padding-top: 0.5rem; - line-height: 1.5rem; - overflow: hidden; - transition: max-height 0.3s ease-in-out; - max-height:4.5rem; -} - -div.map-search div.shortcuts { - padding-top: 0.5rem; - line-height: 1.5rem; - overflow: hidden; - max-height: 50vh; - transition: max-height 0.3s ease-in-out; -} - -div.map-search.collapsed div.options, div.map-search.searchcollapsed div.options { - max-height: 0; - padding:0; -} - -div.map-search.collapsed div.shortcuts, div.map-search.searchcollapsed div.shortcuts { - max-height: 0; - padding:0; -} - -div.map-search button { - overflow: hidden; -} - -div.map-search.collapsed input[type=text] { - border-top-right-radius: 0.25rem; - border-bottom-right-radius: 0.25rem; -} - -div.map-search.searchcollapsed input[type=text] { - display: none; -} - -div.map-search.collapsed button.clear, div.map-search.collapsed button[type="submit"] { - width: 0; - padding: 0; - border-color:transparent; -} - -div.map-search.searchcollapsed button[type="submit"] { - width: 0; - padding: 0; - border-color: transparent; -} - -.options label { - white-space:nowrap; -} - -.form-control, .form-control:focus { - border-color: $secondary; -} - - -@media screen and (min-width:44rem) { - div.map-search { - width: 21rem; - max-width: 21rem; - min-width:0; - } -} - - - diff --git a/projects/common-map/src/fm-map/components/map-search/map-search.component.ts b/projects/common-map/src/fm-map/components/map-search/map-search.component.ts deleted file mode 100644 index a31750d..0000000 --- a/projects/common-map/src/fm-map/components/map-search/map-search.component.ts +++ /dev/null @@ -1,178 +0,0 @@ -import { Component, Input, Output, OnInit, EventEmitter, SimpleChanges, OnChanges, ViewChild } from '@angular/core'; -import { Observable , of } from 'rxjs'; -import { debounceTime,distinctUntilChanged,tap,switchMap,merge,catchError} from 'rxjs/operators'; -import { TypeaheadService, TimespanService } from '@farmmaps/common'; -import { IQueryState } from '@farmmaps/common'; -import { IPeriodState } from '../../models/period.state'; -import { tassign } from 'tassign'; - -@Component({ - selector: 'fm-map-map-search', - templateUrl: './map-search.component.html', - styleUrls: ['./map-search.component.scss'] -}) -export class MapSearchComponent { - - @ViewChild('searchText', { static: true }) searchText; - @Input() clearEnabled: boolean - @Input() set collapsed(collapsed: boolean) { - this.collapsedLocal = collapsed; - if (collapsed) this.searchText.nativeElement.blur(); - } - @Input() set searchMinified(minified: boolean) { - this.searchMinifiedLocal = minified; - } - @Input() period: IPeriodState - @Output() onSearch = new EventEmitter(); - @Output() onClear = new EventEmitter(); - @Output() onSearchCollapse = new EventEmitter(); - @Output() onSearchExpand = new EventEmitter(); - @Output() onToggleMenu = new EventEmitter(); - @Output() onOpenModal = new EventEmitter(); - @Output() onCloseModal = new EventEmitter(); - @Input() openedModalName: string; - @Input() set filterOptions(filterOptions: IQueryState) { - if (filterOptions && filterOptions.query && filterOptions.query.length > 0) { - this.disabled = false; - } else { - this.disabled = true; - } - this.filterOptionsLocal = tassign(this.filterOptionsLocal, { tags: filterOptions.tags, query: filterOptions.query,bbox:filterOptions.bbox }); - if (filterOptions.tags) { - this.searchTextLocal = { name: filterOptions.tags }; - } else { - this.searchTextLocal = { name: filterOptions.query }; - } - if (this.dateFilter) { - this.filterOptionsLocal.startDate = this.startDate; - this.filterOptionsLocal.endDate = this.endDate; - } - } - - public collapsedLocal: boolean = true; - public searchMinifiedLocal: boolean = false; - public filterOptionsLocal: IQueryState; - private extent: number[]; - public searchTextLocal: any; - public searchTextLocalOutput: string; - public dateFilter: boolean = true; - public startDate: Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1); - public endDate: Date = new Date(Date.now()); - public startEndCaption: string = this.timespanService.getCaption(this.startDate, this.endDate, 4); - - searching = false; - searchFailed = false; - hideSearchingWhenUnsubscribed = new Observable(() => () => this.searching = false); - - public disabled: boolean = true; - - 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:[] }; - } - - search = (text$: Observable) => - text$.pipe( - debounceTime(300), - distinctUntilChanged(), - tap(() => this.searching = true), - switchMap(term => term.length < 1 ? of([]) : - this.typeaheadService.getSearchTypeaheadItems(term).pipe( - tap(() => this.searchFailed = false), - catchError(() => { - this.searchFailed = true; - return of([]); - })) ), - tap(() => this.searching = false), - merge(this.hideSearchingWhenUnsubscribed)); - - formatter = (x: { name: string }) => x.name; - - handleSearch(event) { - this.filterOptionsLocal.tags = null; - this.filterOptionsLocal.itemType = null; - this.filterOptionsLocal.itemCode = null; - this.filterOptionsLocal.parentCode = null; - this.filterOptionsLocal.query = this.searchTextLocalOutput; - if (this.dateFilter) { - this.filterOptionsLocal.startDate = this.startDate; - this.filterOptionsLocal.endDate = this.endDate; - } - this.onSearch.emit(this.filterOptionsLocal); - } - - handleOpenSelectPeriodModal(event: MouseEvent) { - event.preventDefault(); - this.onOpenModal.emit('selectPeriodModal'); - } - - handleCloseModal() { - this.onCloseModal.emit({}); - } - - handleSelect(event) { - event.preventDefault(); - this.filterOptionsLocal.query = null; - this.filterOptionsLocal.itemType = null; - this.filterOptionsLocal.itemCode = null; - this.filterOptionsLocal.parentCode = null; - this.filterOptionsLocal.tags = event.item.name; - if (this.dateFilter) { - this.filterOptionsLocal.startDate = this.startDate; - this.filterOptionsLocal.endDate = this.endDate; - } - this.onSearch.emit(this.filterOptionsLocal); - this.searchTextLocal = { name: this.filterOptionsLocal.tags }; - } - - handleSelectPeriod(event: { startDate: Date, endDate: Date }) { - this.startDate = event.startDate; - this.endDate = event.endDate; - this.handleCloseModal(); - this.startEndCaption = this.timespanService.getCaption(event.startDate, event.endDate, 4); - this.onSearch.emit(this.filterOptionsLocal); - } - - handleChangeEnableDateFilter(enabled) { - this.dateFilter = enabled; - if (enabled) { - this.filterOptionsLocal.startDate = this.startDate; - this.filterOptionsLocal.endDate = this.endDate; - } else { - this.filterOptionsLocal.startDate = null; - this.filterOptionsLocal.endDate = null; - } - if(this.filterOptionsLocal.query || this.filterOptionsLocal.tags) - this.onSearch.emit(this.filterOptionsLocal); - } - - handleChangeEnableBBOXFilter(enabled) { - this.filterOptionsLocal.bboxFilter = enabled; - if (this.filterOptionsLocal.query || this.filterOptionsLocal.tags) - this.onSearch.emit(this.filterOptionsLocal); - } - - - handleToggleMenu(event) { - this.onToggleMenu.emit({}); - } - - handleFocus(event) { - this.onSearchExpand.emit({}); - } - - handleChange(event: string) { - this.searchTextLocalOutput = event; - if (event && event.length == 1) { - this.onSearchExpand.emit({}); - } - if (event && event.length > 0) - this.disabled = false; - else - this.disabled = true; - } - - handleClearClick(event) { - this.onClear.emit({}); - } -} - diff --git a/projects/common-map/src/fm-map/components/map/map.component.html b/projects/common-map/src/fm-map/components/map/map.component.html deleted file mode 100644 index ddead55..0000000 --- a/projects/common-map/src/fm-map/components/map/map.component.html +++ /dev/null @@ -1,71 +0,0 @@ - - -
- -
- - - - - - - - - - - - - -
- - - - -
- -
- - -
-
-
-
- -
- -
- -
- -
-
-
Cannot find {{state.queryState?.query}}
-
Cannot find tag {{state.queryState?.tags}}
-
-
-
-
-
- - diff --git a/projects/common-map/src/fm-map/components/map/map.component.scss b/projects/common-map/src/fm-map/components/map/map.component.scss deleted file mode 100644 index f02b622..0000000 --- a/projects/common-map/src/fm-map/components/map/map.component.scss +++ /dev/null @@ -1,166 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -aol-map { position:absolute;width:100%;height:100%;} - -.arrow { - top: 3rem; -} - -.popover { - max-height:22rem; - min-width:15rem; -} - -.popover-body { - max-height:19rem; - overflow:hidden; - overflow-y:auto; -} - -.card-title { - font-size:1rem; -} - -.menu-card { - margin-left:-7px; - padding-left:7px; - margin-right:-7px; - padding-right:7px; - margin-bottom:7px; -} - -.icon-top { - font-size: 6rem; - text-align: center; - height: 9.75rem; -} - -.icon-top i { - padding-top: 1.875rem; -} - -.card-title { - white-space:nowrap; - overflow:hidden; - text-overflow:ellipsis; -} - - -.control-container { - position: absolute; - right: 1em; - bottom: 1em; -} - -switch2d3d { - position: absolute; - right: 1em; - bottom: 1em; -} - -.panel-wrapper { - display: flex; - flex-direction: column; - align-items: stretch; - width: 100%; - height: 100%; -} - -.panel-top { - display: block; - height:0; -} - -.panel-bottom { - overflow:auto; - flex:1; -} - -.no-results { - font-weight:bold; -} - -.no-results > span { - font-style:italic; -} - -div.header { - display:flex; - padding-top:1em; - margin-bottom:1em; -} - -div.header button { - margin-left:1em; -} - -.logo { - overflow: hidden; - max-height: 2.5em; -} - -timespan { - position: absolute; - transition: left 0.5s; - bottom: 0; - left: 0; - right: 0; - background-color: rgba(255, 255, 255, 0.5); -} - -timespan.menuVisible { - left: 22rem; -} - -:host ::ng-deep .timespan div.clearfix { - transition: height 0.5s; -} - - -@media screen and (min-width:44rem) { - .panel-top { - height: 8.1rem; - } -} - -.map { - transition: margin-left 0.3s; -} - -.shortcut-icon { - display: inline-block; - text-align: center; - margin: 0.5rem; - cursor:pointer; -} - -.shortcut-icon > .icon { - width: 3rem; - height: 3rem; - background-color: #731e64; - display: inline-block; - text-align: center; - line-height: 3rem; - color: #ffffff; - font-size: 2rem; -} - -.shortcut-icon > .caption { - text-align: center; - width: 4rem; - overflow: hidden; - text-overflow: ellipsis; - color: theme-color(); -} - -.shortcut-icon > .farm-icon { - background-color: #731E64; -} - -.shortcut-icon > .trijntje-icon { - background-color: #FAA33F; -} - -/*.panel-visible { - margin-left:22rem; -}*/ diff --git a/projects/common-map/src/fm-map/components/map/map.component.ts b/projects/common-map/src/fm-map/components/map/map.component.ts deleted file mode 100644 index 23c0c8f..0000000 --- a/projects/common-map/src/fm-map/components/map/map.component.ts +++ /dev/null @@ -1,406 +0,0 @@ -import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit,NgZone } from '@angular/core'; -import { Location } from '@angular/common'; -import { Observable, Subject, Subscription, from,of } from 'rxjs'; -import { withLatestFrom, switchMap,skip } from 'rxjs/operators'; -import { Router, ActivatedRoute, ParamMap } from '@angular/router'; -import { Store } from '@ngrx/store'; -//import { proj,Map } from 'openlayers'; - -// Map -import * as mapReducers from '../../reducers/map.reducer'; -import * as mapActions from '../../actions/map.actions'; -import { IMapState} from '../../models/map.state'; -import { ISelectedFeatures } from '../../models/selected.features'; -import { IItemLayer } from '../../models/item.layer'; -import { IQueryState } from '@farmmaps/common'; -import { IPeriodState } from '../../models/period.state'; -import {IStyles} from '../../models/style.cache'; -import { IDroppedFile } from '../aol/file-drop-target/file-drop-target.component'; -import { StateSerializerService } from '@farmmaps/common'; -import { GeolocationService} from '../../services/geolocation.service'; -import {DeviceOrientationService} from '../../services/device-orientation.service'; - -// AppCommon -import { ResumableFileUploadService, ItemTypeService } from '@farmmaps/common'; -import { IItemType, IItem } from '@farmmaps/common'; -import {commonReducers} from '@farmmaps/common'; -import {commonActions} from '@farmmaps/common'; - -import {Feature} from 'ol'; -import {Extent,createEmpty,extend } from 'ol/extent'; -import {transform} from 'ol/proj'; -import { tassign } from 'tassign'; -import * as style from 'ol/style'; - - -@Component({ - selector: 'fm-map-map', - templateUrl: './map.component.html', - styleUrls: ['./map.component.scss'] -}) - -export class MapComponent implements OnInit, OnDestroy,AfterViewInit { - title: string = 'Map'; - public openedModalName$: Observable = this.store.select(commonReducers.selectOpenedModalName); - public itemTypes$: Observable<{ [id: string]: IItemType }>; - public mapState$: Observable = this.store.select(mapReducers.selectGetMapState); - public features$: Observable> = this.store.select(mapReducers.selectGetFeatures); - public overlayLayers$: Observable> = this.store.select(mapReducers.selectGetOverlayLayers); - public selectedOverlayLayer$: Observable = this.store.select(mapReducers.selectGetSelectedOverlayLayer); - public selectedItemLayer$: Observable = this.store.select(mapReducers.selectGetSelectedItemLayer); - public baseLayers$: Observable> = this.store.select(mapReducers.selectGetBaseLayers); - public selectedBaseLayer$: Observable = this.store.select(mapReducers.selectGetSelectedBaseLayer); - public projection$: Observable = this.store.select(mapReducers.selectGetProjection); - public selectedFeatures$: Subject = new Subject(); - public droppedFile$: Subject = new Subject(); - private paramSub: Subscription; - private itemTypeSub: Subscription; - private stateSub: Subscription; - private queryStateSub: Subscription; - private querySub: Subscription; - public parentCode$: Observable =this.store.select(mapReducers.selectGetParentCode); - public panelVisible$: Observable = this.store.select(mapReducers.selectGetPanelVisible); - public panelCollapsed$: Observable = this.store.select(mapReducers.selectGetPanelCollapsed); - public selectedFeature$: Observable = this.store.select(mapReducers.selectGetSelectedFeature); - public clickedFeature: Subject = new Subject(); - public selectedItem$: Observable = this.store.select(mapReducers.selectGetSelectedItem); - public queryState$: Observable = this.store.select(mapReducers.selectGetQueryState); - public state$:Observable<{mapState:IMapState,queryState:IQueryState,setStateCount:number}> = this.store.select(mapReducers.selectGetState); - public period$: Observable = this.store.select(mapReducers.selectGetPeriod); - public clearEnabled$: Observable = this.store.select(mapReducers.selectGetClearEnabled); - public searchCollapsed$: Observable = this.store.select(mapReducers.selectGetSearchCollapsed); - public searchMinified$: Observable = this.store.select(mapReducers.selectGetSearchMinified); - public menuVisible$: Observable; - public query$: Observable = this.store.select(mapReducers.selectGetQuery); - public position$: Observable = this.geolocationService.getCurrentPosition(); - public compassHeading$: Observable = this.deviceorientationService.getCurrentCompassHeading(); - public baseLayersCollapsed:boolean = true; - public overlayLayersCollapsed: boolean = true; - public extent$: Observable = this.store.select(mapReducers.selectGetExtent); - public styles$:Observable = this.store.select(mapReducers.selectGetStyles); - private setStateCount$:Observable = this.store.select(mapReducers.selectgetSetStateCount); - private lastUrl = ""; - - @ViewChild('map') map; - - constructor(private store: Store, - private route: ActivatedRoute, - private router: Router, - private uploadService: ResumableFileUploadService, - private serializeService: StateSerializerService, - public itemTypeService: ItemTypeService, - private location: Location, - private geolocationService: GeolocationService, - private zone: NgZone, - private deviceorientationService:DeviceOrientationService) { - this.querySub = this.query$.pipe(skip(1), withLatestFrom(this.mapState$),withLatestFrom(this.setStateCount$)).subscribe(([[queryState,mapState],setStateCount]) =>{ - if(queryState) { - let newQueryState = tassign(mapReducers.initialQueryState); - console.debug(`Do Query ${setStateCount}`); - let urlparts=[]; - if (queryState.itemCode && queryState.itemCode != "") { - if(queryState.itemType && queryState.itemType!= "") { - let itemType = this.itemTypeService.itemTypes[queryState.itemType]; - if (itemType && itemType.viewer && itemType.viewer == "edit_in_editor" && itemType.editor) { - urlparts.push('/editor'); - urlparts.push(itemType.editor); - urlparts.push('item'); - urlparts.push(queryState.itemCode); - } - } - } else { - newQueryState= queryState; - } - if(urlparts.length==0 ) { - newQueryState.itemCode = queryState.itemCode; - this.zone.run(() => { - this.store.dispatch(new mapActions.SetQueryState(newQueryState,false)); - }) - } else { - this.router.navigate(urlparts); - } - } - }); - } - - @HostListener('document:keyup', ['$event']) - escapeClose(event: KeyboardEvent) { - let x = event.keyCode; - if (x === 27) { - this.handleCloseModal() - } - } - - handleOpenModal(modalName: string) { - this.store.dispatch(new commonActions.OpenModal(modalName)); - } - - handleCloseModal() { - this.store.dispatch(new commonActions.CloseModal()); - } - - handleFileDropped(droppedFile: IDroppedFile) { - this.uploadService.addFiles(droppedFile.files, droppedFile.event, { parentCode:droppedFile.parentCode, geometry:droppedFile.geometry }); - } - - handleFeatureClick(feature: Feature) { - this.clickedFeature.next(feature); - } - - handleFeatureHover(feature: Feature) { - this.store.dispatch(new mapActions.SelectFeature(feature)); - } - - handleSearch(queryState: IQueryState) { - this.store.dispatch(new mapActions.DoQuery(queryState)); - } - - ngOnInit() { - console.debug("Init"); - this.store.dispatch(new mapActions.Clear()); - this.selectedFeatures$.next({x:0,y:0,features:[]}); - this.selectedFeatures$.next(null); - } - - initCustomStyles() { - this.store.dispatch(new mapActions.SetStyle('vnd.farmmaps.itemtype.layer',new style.Style({ - stroke: new style.Stroke({ - color: 'red', - lineDash: [ 5,5], - width: 1 - }), - geometry:(feature) =>feature.getGeometry() - }))); - this.store.dispatch(new mapActions.SetStyle('vnd.farmmaps.itemtype.layer_selected',new style.Style({ - stroke: new style.Stroke({ - color: 'red', - lineDash: [ 5,5], - width: 3 - }), - geometry:(feature) =>feature.getGeometry() - }))); - } - - round(value:number,decimals:number):number { - let d = Math.pow(10, decimals); - return Math.round((value + Number.EPSILON)*d)/d; - } - - getMapStateFromUrl(params:ParamMap):IMapState { - var hasUrlmapState = params.has("xCenter") && params.has("yCenter"); - if (hasUrlmapState) { - let xCenter = parseFloat(params.get("xCenter")); - let yCenter = parseFloat(params.get("yCenter")); - let zoom = parseFloat(params.get("zoom")); - let rotation = parseFloat(params.get("rotation")); - let baseLayer = params.get("baseLayer")?params.get("baseLayer"):""; - var newMapState = {zoom: zoom, rotation: rotation, xCenter: xCenter, yCenter: yCenter, baseLayerCode: baseLayer }; - return newMapState; - } else { - return null; - } - } - - normalizeMapState(mapState:IMapState):IMapState { - if(!mapState) return null; - return {zoom: this.round(mapState.zoom,0), - rotation: this.round(mapState.rotation,2), - xCenter: this.round(mapState.xCenter,5), - yCenter: this.round(mapState.yCenter,5), - baseLayerCode: mapState.baseLayerCode }; - } - - serializeMapState(mapState:IMapState):string { - return JSON.stringify(this.normalizeMapState(mapState)); - } - - getQueryStateFromUrl(params:ParamMap):IQueryState { - if (params.has("queryState")) { - let queryState = params.get("queryState"); - var newQueryState = tassign(mapReducers.initialQueryState); - if (queryState != "") { - newQueryState = this.serializeService.deserialize(queryState); - } - return newQueryState; - } else { - return null; - } - } - - ngAfterViewInit() { - console.debug("View init"); - this.initCustomStyles(); - - // url to state - - this.paramSub = this.route.paramMap.pipe(withLatestFrom(this.state$),switchMap(([params,state]) => { - var newMapState: IMapState = state.mapState; - var newQueryState: IQueryState = state.queryState; - - var queryStateChanged = false; - var mapStateChanged = false; - let urlMapState = this.getMapStateFromUrl(params); - if(urlMapState) { - newMapState = urlMapState; - mapStateChanged = this.serializeMapState(state.mapState) != this.serializeMapState(newMapState); - } - - let urlQueryState = this.getQueryStateFromUrl(params); - if(urlQueryState) { - newQueryState = urlQueryState; - queryStateChanged = this.serializeService.serialize(state.queryState) != this.serializeService.serialize(urlQueryState); - } - - if(queryStateChanged && mapStateChanged && state.setStateCount ==0) { - return of(new mapActions.SetState(newMapState,newQueryState)); - window.localStorage.setItem("FarmMapsCommonMap_mapState",this.serializeMapState(newMapState)); - } else if(queryStateChanged) { - return of(new mapActions.SetQueryState(newQueryState)); - } return of(new mapActions.SetReplaceUrl(true)); - })).subscribe((action) => { - if(action) { - this.zone.run(() => { - console.debug("Url to state"); - this.store.dispatch(action); - }); - } - }); - - // state to url - - this.stateSub = this.state$.pipe(switchMap((state) => { - let newUrl = this.serializeMapState(state.mapState) + "_" + this.serializeService.serialize(state.queryState); - if(this.lastUrl!=newUrl && state.setStateCount>0) { - this.lastUrl=newUrl; - return of(state); - } - else { - return of(null); - } - })).subscribe((newUrlState) =>{ - if(newUrlState) { - console.debug(`State to url ${newUrlState.setStateCount}`); - this.replaceUrl(newUrlState.mapState,newUrlState.queryState,newUrlState.replaceUrl); - } - }); - - setTimeout(() => { - this.map.instance.updateSize(); - }, 500); - } - - handleSearchCollapse(event) { - this.store.dispatch(new mapActions.CollapseSearch()); - } - - handleSearchExpand(event) { - this.store.dispatch(new mapActions.ExpandSearch()); - } - - handleToggleMenu(event) { - this.store.dispatch(new commonActions.ToggleMenu()); - } - - handleToggleBaseLayers(event:MouseEvent) { - this.baseLayersCollapsed = !this.baseLayersCollapsed; - event.preventDefault(); - } - - handleToggleOverlayLayers(event: MouseEvent) { - this.overlayLayersCollapsed = !this.overlayLayersCollapsed; - event.preventDefault(); - } - - handlePredefinedQuery(event: MouseEvent, query: any) { - event.preventDefault(); - var queryState = tassign(mapReducers.initialQueryState, query); - this.store.dispatch(new mapActions.DoQuery(queryState)); - } - - replaceUrl(mapState: IMapState, queryState: IQueryState, replace: boolean = true) { - let parts =["."]; - parts.push(mapState.xCenter.toFixed(5)); - parts.push(mapState.yCenter.toFixed(5)); - parts.push( mapState.zoom.toFixed(0)); - parts.push( mapState.rotation.toFixed(2)); - if(mapState.baseLayerCode!="") { - parts.push(mapState.baseLayerCode); - parts.push( this.serializeService.serialize(queryState)); - console.debug("Replace url",parts); - this.router.navigate(parts, { replaceUrl: replace,relativeTo:this.route.parent }); - } - } - - handleOnMoveEnd(event) { - console.debug("Move end"); - this.zone.run(() =>{ - var map = event.map; - var view = map.getView(); - var rotation = view.getRotation(); - var zoom = view.getZoom(); - var center = transform(view.getCenter(), view.getProjection(), "EPSG:4326"); - var extent = view.calculateExtent(this.map.instance.getSize()); - let mapState: IMapState = { xCenter: center[0], yCenter: center[1], zoom: zoom, rotation: rotation, baseLayerCode: null }; - let state = { mapState: mapState, extent: extent }; - let source = from([state]); - source.pipe(withLatestFrom(this.selectedBaseLayer$),withLatestFrom(this.setStateCount$)).subscribe(([[state, baselayer],setStateCount]) => { - if (mapState && baselayer) { // do not react on first move - let newMapState = tassign(state.mapState, { baseLayerCode: baselayer.item.code }); - this.store.dispatch(new mapActions.SetMapState(newMapState)); - this.store.dispatch(new mapActions.SetViewExtent(state.extent)); - } - }); - }); - } - - handleOnMouseDown(event: MouseEvent) { - event.stopPropagation(); - this.zone.run(() =>{ - this.store.dispatch(new mapActions.CollapseSearch()); - }); - } - - handleOnDownload(event) { - - } - - handleClearSearch(event) { - this.store.dispatch(new commonActions.Escape(true, false)); - } - - handleOnDelete(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.RemoveLayer(itemLayer)); - } - - handleOnToggleVisibility(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SetVisibility(itemLayer,!itemLayer.visible)); - } - - handleOnSetOpacity(event:{ layer: IItemLayer,opacity:number }) { - this.store.dispatch(new mapActions.SetOpacity(event.layer, event.opacity)); - } - - handleZoomToExtent(itemLayer: IItemLayer) { - var extent = createEmpty(); - extend(extent, itemLayer.layer.getExtent()); - if (extent) { - this.store.dispatch(new mapActions.SetExtent(extent)); - } - } - - handleSelectBaseLayer(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SelectBaseLayer(itemLayer)); - } - - handleSelectOverlayLayer(itemLayer: IItemLayer) { - this.store.dispatch(new mapActions.SelectOverlayLayer(itemLayer)); - } - - ngOnDestroy() { - if (this.paramSub) this.paramSub.unsubscribe(); - if (this.itemTypeSub) this.itemTypeSub.unsubscribe(); - if (this.stateSub) this.stateSub.unsubscribe(); - if (this.queryStateSub) this.queryStateSub.unsubscribe(); - if (this.querySub) this.querySub.unsubscribe(); - } -} diff --git a/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.html b/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.html deleted file mode 100644 index c81a936..0000000 --- a/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.html +++ /dev/null @@ -1,19 +0,0 @@ - -
- - - -
-
- - diff --git a/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.ts b/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.ts deleted file mode 100644 index 786a9f0..0000000 --- a/projects/common-map/src/fm-map/components/meta-data-modal/meta-data-modal.component.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Component, Output, ViewChild, EventEmitter, Input, ElementRef, HostListener } from '@angular/core'; -import { FormGroup,FormBuilder, Validators } from '@angular/forms'; -import { IListItem } from '@farmmaps/common'; -import { IDroppedFile } from '../aol/file-drop-target/file-drop-target.component'; -import {NgbModal, NgbModalRef} from "@ng-bootstrap/ng-bootstrap"; - -export interface IMetaData { - droppedFile: IDroppedFile, - attributes: any -} - -@Component({ - selector: 'fm-map-meta-data-modal', - templateUrl: 'meta-data-modal.component.html' -}) -export class MetaDataModalComponent { - - private modalName: string = 'metaDataModal'; - private modalRef: NgbModalRef; - - @ViewChild('content', { static: true }) _templateModal:ElementRef; - @Input() droppedFile: IDroppedFile; - @Input() set modalState(_modalState:any) {; - if(_modalState == this.modalName) { - this.openModal() - } else if(this.modalRef) { - this.closeModal(); - } - } - - @Input() event: IListItem; - - @Output() onCloseModal = new EventEmitter(); - @Output() onAddFilesWithMetaData = new EventEmitter(); - - constructor(private modalService: NgbModal, public fb: FormBuilder) { } - - public metaDataForm: FormGroup; - - handleMetaDataEntered(event) { - if (this.metaDataForm.valid) { - this.onAddFilesWithMetaData.emit({ droppedFile: this.droppedFile, attributes: { name: this.metaDataForm.value.name } }); - } - } - - openModal() { - //Timeout trick to avoid ExpressionChangedAfterItHasBeenCheckedError - setTimeout(() => this.modalRef = this.modalService.open(this._templateModal, { backdrop: 'static', keyboard: false })); - } - - closeModal() { - this.modalRef.close(); - this.metaDataForm.patchValue({ name: "" }); - } - - ngOnInit(): void { - this.metaDataForm = this.fb.group({ - name: ["", Validators.compose([Validators.required, Validators.pattern("[a-zA-Z0-9_].*")])] - }); - } -} diff --git a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.html b/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.html deleted file mode 100644 index f667231..0000000 --- a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - diff --git a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.scss b/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.scss deleted file mode 100644 index 3b024d8..0000000 --- a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.scss +++ /dev/null @@ -1,20 +0,0 @@ -.custom-day { - text-align: center; - padding: 0.185rem 0.25rem; - display: inline-block; - height: 2rem; - width: 2rem; -} - -.custom-day.focused { - background-color: #e6e6e6; -} - -.custom-day.range, .custom-day:hover { - background-color: rgb(2, 117, 216); - color: white; -} - -.custom-day.faded { - background-color: rgba(2, 117, 216, 0.5); -} diff --git a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.ts b/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.ts deleted file mode 100644 index 05a471b..0000000 --- a/projects/common-map/src/fm-map/components/select-period-modal/select-period-modal.component.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { Component, Output, ViewChild, EventEmitter, Input, ElementRef, HostListener } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { NgbModal, NgbModalRef, NgbDateStruct, NgbCalendar, NgbDateAdapter } from "@ng-bootstrap/ng-bootstrap"; -import { NgbDateNativeAdapter } from '@farmmaps/common'; - - -const equals = (one: NgbDateStruct, two: NgbDateStruct) => - one && two && two.year === one.year && two.month === one.month && two.day === one.day; - -const before = (one: NgbDateStruct, two: NgbDateStruct) => - !one || !two ? false : one.year === two.year ? one.month === two.month ? one.day === two.day - ? false : one.day < two.day : one.month < two.month : one.year < two.year; - -const after = (one: NgbDateStruct, two: NgbDateStruct) => - !one || !two ? false : one.year === two.year ? one.month === two.month ? one.day === two.day - ? false : one.day > two.day : one.month > two.month : one.year > two.year; - -@Component({ - selector: 'fm-map-select-period-modal', - templateUrl: 'select-period-modal.component.html', - styleUrls: ['select-period-modal.component.scss'] -}) -export class SelectPeriodModalComponent { - - private modalName: string = 'selectPeriodModal'; - private modalRef: NgbModalRef; - private dateAdapter = new NgbDateNativeAdapter(); - hoveredDate: NgbDateStruct; - fromDate: NgbDateStruct; - toDate: NgbDateStruct; - - @ViewChild('content', { static: true }) _templateModal:ElementRef; - - @Input() set modalState(_modalState:any) {; - if(_modalState == this.modalName) { - this.openModal() - } else if(this.modalRef) { - this.closeModal(); - } - } - - @Input() set startDate(_modalState: Date) { - this.fromDate = this.dateAdapter.fromModel(_modalState); - } - - @Input() set endDate(_modalState: Date) { - var d = new Date(_modalState); - d.setDate(d.getDate() - 1); - this.toDate = this.dateAdapter.fromModel(d); - } - - @Output() onCloseModal = new EventEmitter(); - @Output() onSelect = new EventEmitter<{ startDate: Date, endDate: Date }>(); - - constructor(private modalService: NgbModal, private calendar: NgbCalendar) { } - - openModal() { - //Timeout trick to avoid ExpressionChangedAfterItHasBeenCheckedError - setTimeout(() => this.modalRef = this.modalService.open(this._templateModal, { backdrop: 'static', keyboard: false})); - } - - closeModal() { - this.modalRef.close(); - } - - ngOnInit(): void { - } - - onDateChange(date: NgbDateStruct) { - if (!this.fromDate && !this.toDate) { - this.fromDate = date; - } else if (this.fromDate && !this.toDate && after(date, this.fromDate)) { - this.toDate = date; - } else { - this.toDate = null; - this.fromDate = date; - } - } - - handleSelect(event:MouseEvent) { - event.preventDefault(); - if (this.fromDate && this.toDate && before(this.fromDate, this.toDate)) { - var endDate = new Date(this.dateAdapter.toModel(this.toDate)); - endDate.setDate(endDate.getDate() + 1); - this.onSelect.emit({startDate:this.dateAdapter.toModel(this.fromDate),endDate:endDate}) - } - } - - isHovered = date => this.fromDate && !this.toDate && this.hoveredDate && after(date, this.fromDate) && before(date, this.hoveredDate); - isInside = date => after(date, this.fromDate) && before(date, this.toDate); - isFrom = date => equals(date, this.fromDate); - isTo = date => equals(date, this.toDate); -} diff --git a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.html b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.html deleted file mode 100644 index 6647459..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.scss b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.scss deleted file mode 100644 index 8bd6f0a..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.scss +++ /dev/null @@ -1,13 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - - - -.row { - border-bottom: 1px solid gray('500'); - user-select: none; -} - -.row:hover { - background-color: gray('100'); -} - diff --git a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts deleted file mode 100644 index b909f00..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Component, Input, OnInit, ComponentFactoryResolver, ViewChild, SimpleChanges, ComponentFactory, Inject, Type} from '@angular/core'; -import { IItem } from '@farmmaps/common'; -import { AbstractSelectedItemComponent, SelectedItemComponent } from '../selected-item/selected-item.component'; -import { WidgetHostDirective } from '../widget-host/widget-host.directive'; -import { IItemLayer } from '../../models/item.layer'; - - -@Component({ - selector: 'fm-map-selected-item-container', - templateUrl: './selected-item-container.component.html', - styleUrls: ['./selected-item-container.component.scss'] -}) -export class SelectedItemContainerComponent { - - constructor(private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractSelectedItemComponent) public selectedItemComponents: AbstractSelectedItemComponent[] ) { - } - - @Input() item: IItem; - @Input() itemLayer:IItemLayer; - @Input() overlayLayers:Array; - - @ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective; - - loadComponent() { - let componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default - let firstComponentWithTypeAndTask = this.selectedItemComponents - .find(value => value['forSourceTask'] == this.item.sourceTask && - value['forItemType'] == this.item.itemType - ); - - if (firstComponentWithTypeAndTask) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithTypeAndTask['constructor'] as any); - } else { - let firstComponentWithType = this.selectedItemComponents - .find(value => value['forSourceTask'] == null && - value['forItemType'] == this.item.itemType); - - if (firstComponentWithType) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithType['constructor'] as any); - } - } - const viewContainerRef = this.widgetHost.viewContainerRef; - viewContainerRef.clear(); - - const componentRef = viewContainerRef.createComponent(componentFactory); - (componentRef.instance).item = this.item; - (componentRef.instance).itemLayer = this.itemLayer; - (componentRef.instance).overlayLayers = this.overlayLayers; - } - - ngOnChanges(changes: SimpleChanges) { - if (changes["item"] && changes["item"].currentValue) { - this.loadComponent(); - } - if (changes["itemLayer"] && changes["itemLayer"].currentValue) { - this.loadComponent(); - } - if (changes["overlayLayers"] && changes["overlayLayers"].currentValue) { - this.loadComponent(); - } - } -} diff --git a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.html b/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.html deleted file mode 100644 index b55e5e7..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.html +++ /dev/null @@ -1,19 +0,0 @@ -
-
-
-
- - -
- - -
-
diff --git a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.scss b/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.scss deleted file mode 100644 index 9a2f30f..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.scss +++ /dev/null @@ -1,36 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.big-icon { - width: 100%; - color: white; - font-size: 9rem; - padding: 3rem; - text-align: center; -} - -.card-title { - font-size: 1rem; -} - -.card-body { - padding-bottom: unset; -} - -.spacer { - display: none; - height: 4rem; -} - -@media screen and (min-width:44rem) { - .spacer { - display: block; - } -} - -.menu-card { - margin-left: -7px; - padding-left: 7px; - margin-right: -7px; - padding-right: 7px; - margin-bottom: 7px; -} diff --git a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts b/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts deleted file mode 100644 index 5617547..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-cropfield/selected-item-cropfield.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Component, Input, Injectable, OnInit } from '@angular/core'; -import { Location } from '@angular/common'; -import { Feature } from 'ol'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderService, IListItem} from '@farmmaps/common'; -import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component'; -import { Observable } from 'rxjs'; -import {GeoJSON} from 'ol/format'; -import {getArea} from 'ol/sphere'; - - -@ForItemType("vnd.farmmaps.itemtype.cropfield") -@Injectable() -@Component({ - selector: 'fm-map-selected-item-cropfield', - templateUrl: './selected-item-cropfield.component.html', - styleUrls: ['./selected-item-cropfield.component.scss'] -}) -export class SelectedItemCropfieldComponent extends AbstractSelectedItemComponent implements OnInit{ - - public items: Observable; - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) { - super(store, itemTypeService,location,router); - } - - areaInHa(item:IItem):number { - if(!item) return 0; - // get area from faeture if 0 calculate from polygon - let a = item.data.area; - if(a) return a; - let format = new GeoJSON(); - let polygon = format.readGeometry(item.geometry); - return getArea(polygon,{projection:"EPSG:4326"}) / 10000; - } - - ngOnInit() { - this. items = this.folderService$.getItems(this.item.code, 0, 1000); - } -} diff --git a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html b/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html deleted file mode 100644 index 9b1412b..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.html +++ /dev/null @@ -1,30 +0,0 @@ -
-
-
-
- - -
- -
- -
-
-
diff --git a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.scss b/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.scss deleted file mode 100644 index 0dc571f..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.scss +++ /dev/null @@ -1,41 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.big-icon { - width: 100%; - color: white; - font-size: 9rem; - padding: 3rem; - text-align: center; -} - -.card-title { - font-size: 1rem; -} - -ul { - list-style:none; -} - -li { - margin-top:1rem; -} - -.spacer { - display:none; - height:4rem; -} - -@media screen and (min-width:44rem) { - .spacer { - display:block; - } -} - -.menu-card { - margin-left: -7px; - padding-left: 7px; - margin-right: -7px; - padding-right: 7px; - margin-bottom: 7px; -} - diff --git a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.ts b/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.ts deleted file mode 100644 index b633d3d..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-geotiff/selected-item-geotiff.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Component, Injectable } from '@angular/core'; -import { Location } from '@angular/common'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService, ItemService, FolderService } from '@farmmaps/common'; -import { Router } from '@angular/router'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component'; -import * as mapActions from '../../actions/map.actions'; - - -@ForItemType("vnd.farmmaps.itemtype.geotiff.processed") -@Injectable() -@Component({ - selector: 'fm-map-selected-item-geotiff', - templateUrl: './selected-item-geotiff.component.html', - styleUrls: ['./selected-item-geotiff.component.scss'] -}) -export class SelectedItemGeotiffComponent extends AbstractSelectedItemComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) { - super(store, itemTypeService,location,router); - } - - onLayerChanged(layerIndex: number) { - this.store.dispatch(new mapActions.SetLayerIndex(layerIndex)); - } - - layer(layers:any,layerIndex:number) { - return layers.find(l => l.index == layerIndex); - } -} diff --git a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.html b/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.html deleted file mode 100644 index 5df8f70..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.html +++ /dev/null @@ -1,30 +0,0 @@ -
-
-
-
- - -
- -
- -
-
-
diff --git a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.scss b/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.scss deleted file mode 100644 index e4995c5..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.scss +++ /dev/null @@ -1,48 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.big-icon { - width: 100%; - color: white; - font-size: 9rem; - padding: 3rem; - text-align: center; -} - -.card-title { - font-size: 1rem; -} - -ul { - list-style:none; -} - -li { - margin-top:1rem; -} - -.spacer { - display: none; - height: 4rem; -} - -.legend-container { - margin-top: 2rem; -} - -.legend-container select { - font-size: 1.5rem; -} - -@media screen and (min-width:44rem) { - .spacer { - display: block; - } -} - -.menu-card { - margin-left: -7px; - padding-left: 7px; - margin-right: -7px; - padding-right: 7px; - margin-bottom: 7px; -} diff --git a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.ts b/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.ts deleted file mode 100644 index fefa1c9..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-shape/selected-item-shape.component.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Component, Input, Injectable, OnInit } from '@angular/core'; -import { Location } from '@angular/common'; -import { Feature } from 'ol'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderService, IListItem} from '@farmmaps/common'; -import * as mapActions from '../../actions/map.actions'; -import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component'; -import { Observable } from 'rxjs'; - - -@ForItemType("vnd.farmmaps.itemtype.shape.processed") -@Injectable() -@Component({ - selector: 'fm-map-selected-item-shape', - templateUrl: './selected-item-shape.component.html', - styleUrls: ['./selected-item-shape.component.scss'] -}) -export class SelectedItemShapeComponent extends AbstractSelectedItemComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) { - super(store, itemTypeService,location,router); - } - public selectedLayer: number = 0; - - onLayerChanged(layerIndex: number) { - this.store.dispatch(new mapActions.SetLayerIndex(layerIndex)); - } - - layer(layers:any,layerIndex:number) { - return layers.find(l => l.index == layerIndex); - } -} diff --git a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.html b/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.html deleted file mode 100644 index 32b070e..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.html +++ /dev/null @@ -1,43 +0,0 @@ -
-
-
-
- - -
- - -
- -
-
-
diff --git a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.scss b/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.scss deleted file mode 100644 index 0dc571f..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.scss +++ /dev/null @@ -1,41 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.big-icon { - width: 100%; - color: white; - font-size: 9rem; - padding: 3rem; - text-align: center; -} - -.card-title { - font-size: 1rem; -} - -ul { - list-style:none; -} - -li { - margin-top:1rem; -} - -.spacer { - display:none; - height:4rem; -} - -@media screen and (min-width:44rem) { - .spacer { - display:block; - } -} - -.menu-card { - margin-left: -7px; - padding-left: 7px; - margin-right: -7px; - padding-right: 7px; - margin-bottom: 7px; -} - diff --git a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.ts b/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.ts deleted file mode 100644 index d7d0fe5..0000000 --- a/projects/common-map/src/fm-map/components/selected-item-temporal/selected-item-temporal.component.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { Component, Injectable } from '@angular/core'; -import { Location } from '@angular/common'; -import { Store } from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import { commonReducers, ItemTypeService, ItemService, FolderService,IItem } from '@farmmaps/common'; -import { Router } from '@angular/router'; -import { ForItemType } from '../for-item/for-itemtype.decorator'; -import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component'; -import { ITemporalItemLayer} from '../../models/item.layer'; -import * as mapActions from '../../actions/map.actions'; - - -@ForItemType("vnd.farmmaps.itemtype.temporal") -@Injectable() -@Component({ - selector: 'fm-map-selected-item-temporal', - templateUrl: './selected-item-temporal.component.html', - styleUrls: ['./selected-item-temporal.component.scss'] -}) -export class SelectedItemTemporalComponent extends AbstractSelectedItemComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) { - super(store, itemTypeService,location,router); - } - - onLayerChanged(layerIndex: number) { - this.store.dispatch(new mapActions.SetLayerIndex(layerIndex)); - } - - hasNext():boolean { - let temporalItemLayer = this.itemLayer as ITemporalItemLayer; - return temporalItemLayer && temporalItemLayer.nextItemLayer != null; - } - - nextDate():Date { - let temporalItemLayer = this.itemLayer as ITemporalItemLayer; - if(temporalItemLayer.nextItemLayer.item) - return temporalItemLayer.nextItemLayer.item.dataDate; - return null; - } - - hasPrevious():boolean { - let temporalItemLayer = this.itemLayer as ITemporalItemLayer; - return temporalItemLayer && temporalItemLayer.previousItemLayer != null; - } - - previousDate():Date { - let temporalItemLayer = this.itemLayer as ITemporalItemLayer; - if(temporalItemLayer.previousItemLayer.item) - return temporalItemLayer.previousItemLayer.item.dataDate; - return null; - } - - handleNextTemporal(event:MouseEvent) { - this.store.dispatch(new mapActions.NextTemporal()); - event.preventDefault(); - } - - handlePreviousTemporal(event:MouseEvent) { - this.store.dispatch(new mapActions.PreviousTemporal()); - event.preventDefault(); - } - - selectedItem():IItem { - let temporalItemLayer = this.itemLayer as ITemporalItemLayer; - if(temporalItemLayer && temporalItemLayer.selectedItemLayer) { - return temporalItemLayer.selectedItemLayer.item; - } - return null; - } - - layer(layers:any,layerIndex:number) { - return layers.find(l => l.index == layerIndex); - } - - handleGoToChart(item: IItem) { - this.router.navigate(['/viewer', 'temporal', 'item', item.parentCode, item.dataDate.getUTCFullYear()]); - return false; - } -} diff --git a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.html b/projects/common-map/src/fm-map/components/selected-item/selected-item.component.html deleted file mode 100644 index 5d29bad..0000000 --- a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
- -
- -
-
-
-
- -

{{item.name}}

- -
-
-
diff --git a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.scss b/projects/common-map/src/fm-map/components/selected-item/selected-item.component.scss deleted file mode 100644 index a30d27c..0000000 --- a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import "~bootstrap/scss/bootstrap.scss"; - -.big-icon { - width: 100%; - color: white; - font-size: 9rem; - padding: 3rem; - text-align: center; -} - -.card-title { - font-size: 1rem; -} - -ul { - list-style:none; -} - -li { - margin-top:1rem; -} - -.menu-card { - margin-left: -7px; - padding-left: 7px; - margin-right: -7px; - padding-right: 7px; - margin-bottom: 7px; -} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.ts b/projects/common-map/src/fm-map/components/selected-item/selected-item.component.ts deleted file mode 100644 index da374b3..0000000 --- a/projects/common-map/src/fm-map/components/selected-item/selected-item.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import {Component, Injectable, Input, Directive} from '@angular/core'; -import {Location} from '@angular/common'; -import {Store} from '@ngrx/store'; -import * as mapReducers from '../../reducers/map.reducer'; -import {AppConfig, commonReducers, IItem, ItemTypeService} from '@farmmaps/common'; -import * as mapActions from '../../actions/map.actions'; -import {Router} from '@angular/router'; -import { IItemLayer } from '../../models/item.layer'; - - -@Injectable() -@Directive() -export abstract class AbstractSelectedItemComponent { - @Input() item: IItem - @Input() itemLayer: IItemLayer; - @Input() overlayLayers: Array; - constructor(public store: Store, public itemTypeService: ItemTypeService, private location: Location, public router: Router) { - } - - handleOnView(item: IItem) { - if (this.itemTypeService.hasViewer(item)) { - let viewer = this.itemTypeService.itemTypes[item.itemType].viewer; - let url = `/viewer/${viewer}/item/${item.code}`; - this.router.navigate([url]); - } - return false; - } - - handleOnEdit(item: IItem) { - var editor = "property"; - if(this.itemTypeService.hasEditor(item)) { - editor = this.itemTypeService.itemTypes[item.itemType].editor; - } - let url = `/editor/${editor}/item/${item.code}` - this.router.navigate([url]); - return false; - } - - handleAddAsLayer(item: IItem,layerIndex:number = -1) { - this.store.dispatch(new mapActions.AddLayer(item,layerIndex)); - return false; - } - - handleRemoveLayer(item: IItem,layerIndex:number = -1) { - let itemLayer = this.getItemLayer(item,layerIndex); - if(itemLayer) { - this.store.dispatch(new mapActions.RemoveLayer(itemLayer)); - } - return false; - } - - getItemLayer(item:IItem,layerIndex:number = -1):IItemLayer { - let li = layerIndex==-1?0:layerIndex; - let selected = this.overlayLayers.filter(ol => ol.item.code == item.code && ol.layerIndex == li); - if(selected.length==0) return null; - return selected[0]; - } - - handleBackToList(event: MouseEvent) { - event.preventDefault(); - this.location.back(); - } -} - -@Injectable() -@Component({ - selector: 'fm-map-selected-item', - templateUrl: './selected-item.component.html', - styleUrls: ['./selected-item.component.scss'] -}) -export class SelectedItemComponent extends AbstractSelectedItemComponent { - - constructor(store: Store, itemTypeService: ItemTypeService, location: Location, router: Router, public config:AppConfig) { - super(store, itemTypeService,location,router); - } -} diff --git a/projects/common-map/src/fm-map/components/widget-host/widget-host.directive.ts b/projects/common-map/src/fm-map/components/widget-host/widget-host.directive.ts deleted file mode 100644 index caff9c5..0000000 --- a/projects/common-map/src/fm-map/components/widget-host/widget-host.directive.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Directive, ViewContainerRef } from '@angular/core'; - -@Directive({ - selector: '[fm-map-widget-host]', -}) -export class WidgetHostDirective { - constructor(public viewContainerRef: ViewContainerRef) { } -} diff --git a/projects/common-map/src/fm-map/components/widget-status/widget-status.component.css b/projects/common-map/src/fm-map/components/widget-status/widget-status.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/projects/common-map/src/fm-map/components/widget-status/widget-status.component.html b/projects/common-map/src/fm-map/components/widget-status/widget-status.component.html deleted file mode 100644 index 94cfdae..0000000 --- a/projects/common-map/src/fm-map/components/widget-status/widget-status.component.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
Stage:Pre-alpha
-
Stage:Alpha
-
Stage:Beta
-
Stage:RC
-
diff --git a/projects/common-map/src/fm-map/components/widget-status/widget-status.component.ts b/projects/common-map/src/fm-map/components/widget-status/widget-status.component.ts deleted file mode 100644 index 37370c4..0000000 --- a/projects/common-map/src/fm-map/components/widget-status/widget-status.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; - -@Component({ - selector: 'fm-map-widget-status', - templateUrl: './widget-status.component.html', - styleUrls: ['./widget-status.component.css'] -}) -export class WidgetStatusComponent implements OnInit { - @Input() stage: Stage; - @Input() info: string; - StageEnum = Stage; - - constructor() { } - - ngOnInit() { } - -} -export enum Stage { - DevelopmentPreAlpha, - DevelopmentAlpha, - DevelopmentBeta, - ReleaseCandidate, - Final -} diff --git a/projects/common-map/src/fm-map/effects/map.effects.ts b/projects/common-map/src/fm-map/effects/map.effects.ts deleted file mode 100644 index e676913..0000000 --- a/projects/common-map/src/fm-map/effects/map.effects.ts +++ /dev/null @@ -1,293 +0,0 @@ -import { Injectable } from '@angular/core'; - -import { Store, Action } from '@ngrx/store'; -import { Effect, Actions,ofType } from '@ngrx/effects'; - -import { Observable , of, interval } from 'rxjs'; -import { withLatestFrom, switchMap, map, catchError, mergeMap,delayWhen } from 'rxjs/operators'; - -import {GeoJSON,WKT} from 'ol/format'; -import {Feature} from 'ol'; -import { getCenter,createEmpty,extend } from 'ol/extent'; -import {Point} from 'ol/geom' - - -import * as mapActions from '../actions/map.actions'; -import * as mapReducers from '../reducers/map.reducer'; -import {commonReducers} from '@farmmaps/common'; - -import {commonActions} from '@farmmaps/common'; - -import { IItem } from '@farmmaps/common'; -import { FolderService, ItemService } from '@farmmaps/common'; -import { tassign } from 'tassign'; - -import {FeatureIconService} from '../services/feature-icon.service'; - -import * as style from 'ol/style'; - -import { ItemTypeService,IQueryState } from '@farmmaps/common'; - - -@Injectable() -export class MapEffects { - private _geojsonFormat: GeoJSON; - private _wktFormat: WKT; - - private toPointFeature(updateEvent:commonActions.DeviceUpdateEvent): Feature { - var f = this._wktFormat.readFeature(updateEvent.attributes["geometry"],{ - dataProjection: 'EPSG:4326', - featureProjection: 'EPSG:3857' - }); - f.setId(updateEvent.itemCode); - var centroid = getCenter(f.getGeometry().getExtent()); - f.setGeometry(new Point(centroid)); - return f; - } - - @Effect() - init$: Observable = this.actions$.pipe( - ofType(mapActions.INIT), - withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)), - switchMap(([action, rootItems]) => { - let actions=[]; - for (let rootItem of rootItems) { - if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code)); - } - // initialize default feature styles - actions.push(new mapActions.SetStyle('file',new style.Style({ - image: new style.Icon({ - anchor: [0.5, 1], - scale: 0.05, - src: this.featureIconService$.getIconImageDataUrl("fa fa-file-o") - }), - stroke: new style.Stroke({ - color: 'red', - width: 1 - }), - fill: new style.Fill({ - color: 'rgba(0, 0, 255, 0.1)' - }) - }))); - actions.push(new mapActions.SetStyle('selected',new style.Style({ - image: new style.Icon({ - anchor: [0.5, 1], - scale: 0.08, - src: this.featureIconService$.getIconImageDataUrl(null) - }), - stroke: new style.Stroke({ - color: 'red', - width: 3 - }), - fill: new style.Fill({ - color: 'rgba(0, 0, 255, 0.1)' - }) - }))); - - return actions; - } - )); - - @Effect() - initBaseLayers$: Observable = this.actions$.pipe( - ofType(mapActions.INIT), - withLatestFrom(this.store$.select(mapReducers.selectGetProjection)), - map(([action, projection]) => new mapActions.LoadBaseLayers(projection))); - - @Effect() - loadBaseLayers$: Observable = this.actions$.pipe( - ofType(mapActions.LOADBASELAYERS), - switchMap((action: mapActions.LoadBaseLayers) => { - return this.itemService$.getItemList("vnd.farmmaps.itemtype.layer", { "isBaseLayer": true }).pipe( - map((items: IItem[]) => new mapActions.LoadBaseLayersSuccess(items)), - catchError(error => of(new commonActions.Fail(error)))); - })); - - @Effect() - initRootItems$: Observable = this.actions$.pipe( - ofType(commonActions.INITROOTSUCCESS), - map((action) => new mapActions.Init() - )); - - @Effect() - startSearch$: Observable = this.actions$.pipe( - ofType(mapActions.STARTSEARCH), - withLatestFrom(this.store$.select(mapReducers.selectgetSetStateCount)), - switchMap(([action,setStateCount]) => { - let a = action as mapActions.StartSearch; - var startDate = a.queryState.startDate; - var endDate = a.queryState.endDate; - var newAction:Observable; - if (a.queryState.itemCode || a.queryState.parentCode || a.queryState.itemType || a.queryState.query || a.queryState.tags) { - newAction= this.itemService$.getFeatures(a.queryState.bbox, "EPSG:3857", a.queryState.query, a.queryState.tags, startDate, endDate, a.queryState.itemType, a.queryState.parentCode).pipe( - switchMap((features: any) => { - for (let f of features.features) { - if (f.properties && f.properties["code"]) { - f.id = f.properties["code"]; - } - } - return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), a.queryState,setStateCount)); - } - ), - catchError(error => of(new commonActions.Fail(error)))); - } else { - return []; - } - return newAction; - })); - - - @Effect() - zoomToExtent$: Observable = this.actions$.pipe( - ofType(mapActions.STARTSEARCHSUCCESS), - delayWhen(action => (action as mapActions.StartSearchSuccess).setStateCount == 1 ? interval(500):interval(0)), - mergeMap((action: mapActions.StartSearchSuccess) => { - let actions =[]; - actions.push(new commonActions.SetMenuVisible(false)); - let extent = createEmpty(); - if (!action.query.bboxFilter) { - if (extent) { - for (let f of action.features) { - extend(extent, (f as Feature).getGeometry().getExtent()); - } - } - actions.push(new mapActions.SetExtent(extent)); - } - return actions; - })); - - @Effect() - hideMenu$: Observable = this.actions$.pipe( - ofType(mapActions.STARTSEARCHSUCCESS), - mergeMap((action: mapActions.StartSearchSuccess) => { - return of(new commonActions.SetMenuVisible(false)); - })); - - @Effect() - selectItem$: Observable = this.actions$.pipe( - ofType(mapActions.SELECTITEM), - withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)), - withLatestFrom(this.store$.select(mapReducers.getSetStateCount)), - switchMap(([[action, selectedItem],setStateCount]) => { - let a = action as mapActions.SelectItem; - let itemCode = selectedItem ? selectedItem.code : ""; - if (a.itemCode != itemCode || setStateCount == 1) { - return this.itemService$.getItem(a.itemCode).pipe( - map((item: IItem) => new mapActions.SelectItemSuccess(item)), - catchError(error => of(new commonActions.Fail(error)))) - } else { - return []; - } - } - )); - - @Effect() - selectItemSuccess$: Observable = this.actions$.pipe( - ofType(mapActions.SELECTITEMSUCCESS), - switchMap((action:mapActions.SelectItemSuccess) => { - return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe( - map((feature: any) => { - let f = this._geojsonFormat.readFeature(feature); - f.setId(action.item.code); - return new mapActions.AddFeatureSuccess(f ); - }), - catchError(error => of(new commonActions.Fail(error)))); - } - )); - - @Effect() - selectItemSuccessTemporal$: Observable = this.actions$.pipe( - ofType(mapActions.SELECTITEMSUCCESS), - switchMap((action:mapActions.SelectItemSuccess) => { - if(action.item.itemType == "vnd.farmmaps.itemtype.temporal") { - return this.itemService$.getChildItemList(action.item.code,null).pipe( - map(items => new mapActions.SelectTemporalItemsSuccess( - items.sort((a, b) => - -(b.dataDate.getTime() - a.dataDate.getTime()) - ) - )), - catchError(error => of(new commonActions.Fail(error)))); - } else { - return []; - } - } - )); - - @Effect() - uploadedItemClick$: Observable = this.actions$.pipe( - ofType(commonActions.UPLOADEDFILECLICK), - switchMap((action: commonActions.UploadedFileClick) => of(new mapActions.DoQuery(tassign(mapReducers.initialState.query, {itemCode:action.itemCode}))) - )); - - @Effect() - featureUpdate$: Observable = this.actions$.pipe( - ofType(commonActions.DEVICEUPDATEEVENT), - withLatestFrom(this.store$.select(mapReducers.selectGetFeatures)), - mergeMap(([action, features]) => { - let deviceUpdateEventAction = action as commonActions.DeviceUpdateEvent; - var feature: Feature = null; - for (let f of features) { - if (f.getId() == deviceUpdateEventAction.itemCode) { - feature = f; - break; - } - } - if (feature) { - return of(new mapActions.UpdateFeatureSuccess(this.toPointFeature(deviceUpdateEventAction))); - } else { - return []; - } - })); - - @Effect() - itemUpdate$: Observable = this.actions$.pipe( - ofType(commonActions.ITEMCHANGEDEVENT), - withLatestFrom(this.store$.select(mapReducers.selectGetSelectedItem)), - mergeMap(([action, selectedItem]) => { - let itemChangedAction = action as commonActions.ItemChangedEvent; - if (selectedItem && selectedItem.code == itemChangedAction.itemCode) { - return this.itemService$.getItem(itemChangedAction.itemCode).pipe( - map((item: IItem) => new mapActions.SelectItemSuccess(item)), - catchError(error => of(new commonActions.Fail(error)))); - } else { - return []; - } - })); - - getActionFromQueryState(queryState:IQueryState, inSearch:boolean):Observable|[] { - if(!inSearch && (queryState.itemType || queryState.parentCode || queryState.itemCode || queryState.query || queryState.tags)) { - var newAction:Action; - if (queryState.itemCode && queryState.itemCode != "") { - newAction= new mapActions.SelectItem(queryState.itemCode); - } else { - newAction= new mapActions.StartSearch(queryState); - } - return of(newAction); - } else { - return of(new commonActions.Escape(true,false)); - } - } - - @Effect() - setQueryState$: Observable = this.actions$.pipe( - ofType(mapActions.SETQUERYSTATE), - withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)), - switchMap(([action,inSearch]) => { - let a = action as mapActions.SetQueryState; - return this.getActionFromQueryState(a.queryState,inSearch); - })); - - @Effect() - setState$: Observable = this.actions$.pipe( - ofType(mapActions.SETSTATE), - withLatestFrom(this.store$.select(mapReducers.selectGetInSearch)), - switchMap(([action,inSearch]) => { - let a = action as mapActions.SetState; - return this.getActionFromQueryState(a.queryState,inSearch); - })); - - constructor(private actions$: Actions, private store$: Store, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService,private itemTypeService$:ItemTypeService) { - this._geojsonFormat = new GeoJSON(); - this._wktFormat = new WKT(); - } -} diff --git a/projects/common-map/src/fm-map/models/color.map.js.map b/projects/common-map/src/fm-map/models/color.map.js.map deleted file mode 100644 index 5dbe652..0000000 --- a/projects/common-map/src/fm-map/models/color.map.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"color.map.js","sourceRoot":"","sources":["color.map.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/models/color.map.ts b/projects/common-map/src/fm-map/models/color.map.ts deleted file mode 100644 index ed7438c..0000000 --- a/projects/common-map/src/fm-map/models/color.map.ts +++ /dev/null @@ -1,74 +0,0 @@ -export interface IColor { - red: number, - green: number, - blue: number, - alpha: number, -} - -export interface IColorEntry { - value: number, - color: IColor, - label: string -} - -export interface IHistogramEntry { - value: number, - freqency: number -} - -export interface IHistogram { - min: number, - max: number, - mean: number, - stddev: number, - classes: number, - entries: IHistogramEntry[], - confidence?: number; -} - -export interface IGradientstop { - relativestop: number, - color: IColor -} - -export interface IColorMap { - gradient: IGradientstop[], - noValue: IColorEntry, - entries: IColorEntry[], - colormapType: string -} - -export interface IBand { - histogram: IHistogram -} - - -export interface IRenderer { - band:IBand, - colorMap: IColorMap, - renderType:string -} - -export interface IRenderoutput { - renderoutputType: string -} - -export interface IRenderoutputTiles { - renderoutputType: string, - minzoom: number, - maxzoom: number -} - -export interface IRenderoutputImage { - renderoutputType: string, - extent: [number,number,number,number] -} - -export interface ILayer { - name: string, - unit: string, - index: number, - scale: number, - renderer: IRenderer, - rendering: IRenderoutput -} diff --git a/projects/common-map/src/fm-map/models/index.js.map b/projects/common-map/src/fm-map/models/index.js.map deleted file mode 100644 index 04a7089..0000000 --- a/projects/common-map/src/fm-map/models/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAEA,kCAA4B"} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/models/item.layer.js.map b/projects/common-map/src/fm-map/models/item.layer.js.map deleted file mode 100644 index 38b034f..0000000 --- a/projects/common-map/src/fm-map/models/item.layer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"item.layer.js","sourceRoot":"","sources":["item.layer.ts"],"names":[],"mappings":";;AAaA;IASE,mBAAY,IAAU;QAPf,UAAK,GAAU,IAAI,CAAC;QACpB,YAAO,GAAY,IAAI,CAAC;QACxB,kBAAa,GAAY,KAAK,CAAC;QAE/B,YAAO,GAAW,CAAC,CAAC;QACpB,eAAU,GAAW,CAAC,CAAC,CAAC;QAG7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACH,gBAAC;AAAD,CAAC,AAZD,IAYC;AAZY,8BAAS"} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/models/item.layer.ts b/projects/common-map/src/fm-map/models/item.layer.ts deleted file mode 100644 index ede7354..0000000 --- a/projects/common-map/src/fm-map/models/item.layer.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { IItem,IListItem } from '@farmmaps/common'; -import {Layer} from 'ol/layer'; - -export interface IItemLayer { - item: IItem, - layer: Layer, - visible: boolean, - legendVisible:boolean, - projection: string, - opacity: number, - layerIndex:number -} - -export class ItemLayer implements IItemLayer { - public item: IItem; - public layer: Layer = null; - public visible: boolean = true; - public legendVisible: boolean = false; - public projection: string; - public opacity: number = 1; - public layerIndex: number = -1; - - constructor(item:IItem,opacity:number = 1, visible:boolean = true,layerIndex:number=-1) { - this.item = item; - this.opacity = opacity; - this.visible = visible; - this.layerIndex = layerIndex; - } -} - -export interface ITemporalItemLayer extends IItemLayer { - previousItemLayer: IItemLayer, - selectedItemLayer: IItemLayer, - nextItemLayer: IItemLayer, - temporalItems: IItem[], -} - -export class TemporalItemLayer extends ItemLayer implements ITemporalItemLayer { - public previousItemLayer:IItemLayer = null; - public selectedItemLayer:IItemLayer =null; - public nextItemLayer:IItemLayer = null; - public temporalItems:IItem[] = []; - - constructor(item:IItem,opacity:number = 1, visible:boolean = true) { - super(item,opacity,visible) - } -} - - - diff --git a/projects/common-map/src/fm-map/models/layer.data.ts b/projects/common-map/src/fm-map/models/layer.data.ts deleted file mode 100644 index 9b4016a..0000000 --- a/projects/common-map/src/fm-map/models/layer.data.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ILayerData { - interfaceType:string, - projection: string, - options: any, - url:string -} diff --git a/projects/common-map/src/fm-map/models/map.state.ts b/projects/common-map/src/fm-map/models/map.state.ts deleted file mode 100644 index f80ce69..0000000 --- a/projects/common-map/src/fm-map/models/map.state.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface IMapState { - zoom: number; - rotation: number; - xCenter: number; - yCenter: number; - baseLayerCode: string; -} diff --git a/projects/common-map/src/fm-map/models/period.state.ts b/projects/common-map/src/fm-map/models/period.state.ts deleted file mode 100644 index 65a7429..0000000 --- a/projects/common-map/src/fm-map/models/period.state.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface IPeriodState { - startDate: Date, - endDate:Date -} diff --git a/projects/common-map/src/fm-map/models/selected.features.ts b/projects/common-map/src/fm-map/models/selected.features.ts deleted file mode 100644 index 494cd73..0000000 --- a/projects/common-map/src/fm-map/models/selected.features.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface ISelectedFeatures { - x: number; - y: number; - features: any[]; -} diff --git a/projects/common-map/src/fm-map/models/style.cache.ts b/projects/common-map/src/fm-map/models/style.cache.ts deleted file mode 100644 index 667760b..0000000 --- a/projects/common-map/src/fm-map/models/style.cache.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {Style,Feature} from 'ol'; - -export interface IStyles{ - [id: string]: Style | (Feature); -}; \ No newline at end of file diff --git a/projects/common-map/src/fm-map/module-name.ts b/projects/common-map/src/fm-map/module-name.ts deleted file mode 100644 index 59eec1f..0000000 --- a/projects/common-map/src/fm-map/module-name.ts +++ /dev/null @@ -1 +0,0 @@ -export const MODULE_NAME = "FarmMapsCommonMap"; diff --git a/projects/common-map/src/fm-map/reducers/map.reducer.ts b/projects/common-map/src/fm-map/reducers/map.reducer.ts deleted file mode 100644 index ca249c2..0000000 --- a/projects/common-map/src/fm-map/reducers/map.reducer.ts +++ /dev/null @@ -1,527 +0,0 @@ -import { tassign } from 'tassign'; -import { IItem,Item } from '@farmmaps/common'; -import { IItemLayer,ItemLayer,ITemporalItemLayer,TemporalItemLayer} from '../models/item.layer'; -import { IMapState} from '../models/map.state'; -import { IQueryState} from '@farmmaps/common'; -import { IPeriodState} from '../models/period.state'; -import { IStyles} from '../models/style.cache'; -import * as mapActions from '../actions/map.actions'; -import {commonActions} from '@farmmaps/common'; -import { createSelector, createFeatureSelector } from '@ngrx/store'; - -import {Feature} from 'ol'; - - -import { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store'; - -import { MODULE_NAME } from '../module-name'; - -const startDate:Date = new Date(new Date(Date.now()).getFullYear(), new Date(Date.now()).getMonth() - 3, 1); -const endDate:Date = new Date(Date.now()); - -export const initialQueryState: IQueryState = { - itemCode: null, - parentCode: null, - level: 1, - itemType: null, - bboxFilter: false, - query: null, - tags: null, - endDate: null, - startDate: null, - bbox: [] -}; - -export interface State { - period:IPeriodState, - mapState: IMapState, - viewExtent: number[], - queryState: IQueryState, - query:IQueryState, - parentCode: string, - features: Array, - panelVisible: boolean, - panelCollapsed: boolean, - selectedFeature: Feature, - selectedItem:IItem, - clearEnabled: boolean, - searchCollapsed: boolean, - searchMinified: boolean, - extent: number[], - baseLayers: Array - overlayLayers: Array, - selectedItemLayer: IItemLayer, - projection: string, - selectedBaseLayer: IItemLayer, - selectedOverlayLayer: IItemLayer, - styles:IStyles, - showLayerSwitcher:boolean, - setStateCount:number, - inSearch:boolean, - replaceUrl:boolean -} - -export const initialState: State = { - period: { - startDate: startDate, - endDate: endDate - }, - mapState: { - zoom: 8, - rotation: 0, - xCenter: 5.377554, - yCenter: 52.162422, - baseLayerCode: "" - }, - viewExtent:[], - queryState: tassign(initialQueryState), - query: null, - parentCode: null, - features: [], - panelVisible: false, - panelCollapsed: false, - selectedFeature: null, - selectedItem: null, - clearEnabled: false, - searchCollapsed: true, - searchMinified:false, - extent: null, - baseLayers: [], - overlayLayers: [], - projection: "EPSG:3857", - selectedBaseLayer: null, - selectedOverlayLayer: null, - selectedItemLayer: null, - styles: {}, - showLayerSwitcher: false, - setStateCount: 0, - inSearch:false, - replaceUrl:true -} - -export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State { - switch (action.type) { - case ROUTER_NAVIGATION: { - let a = action as RouterNavigationAction; - return tassign(state); - } - case mapActions.SETMAPSTATE: { - let a = action as mapActions.SetMapState; - return tassign(state, { - mapState: a.mapState,setStateCount: state.setStateCount+1 - }); - } - case mapActions.SETQUERYSTATE: { - let a = action as mapActions.SetQueryState; - return tassign(state, { queryState: tassign(a.queryState ),setStateCount: state.setStateCount+1,replaceUrl:a.replaceUrl}); - } - case mapActions.SETSTATE: { - let a = action as mapActions.SetState; - return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState),setStateCount: state.setStateCount+1}); - } - case mapActions.SETVIEWEXTENT: { - let a = action as mapActions.SetViewExtent; - return tassign(state, { viewExtent: a.extent }); - } - case mapActions.SETPARENT: { - let a = action as mapActions.SetParent; - return tassign(state, { - parentCode : a.parentCode - }); - } - case mapActions.STARTSEARCHSUCCESS: { - let a = action as mapActions.StartSearchSuccess; - return tassign(state, { - features: a.features, - inSearch:false - }); - } - case mapActions.SELECTFEATURE: { - let a = action as mapActions.SelectFeature; - return tassign(state, { - selectedFeature: state.selectedItem?state.selectedFeature: a.feature - }); - } - case mapActions.SELECTITEM: { - let a = action as mapActions.SelectItem; - let itemCode = state.selectedItem ? state.selectedItem.code : ""; - let inSearch = (a.itemCode != itemCode || state.setStateCount == 1) - return tassign(state, { - selectedItem: null, - selectedItemLayer: null, - features:[], - inSearch:inSearch - }); - } - case mapActions.SELECTITEMSUCCESS: { - let a = action as mapActions.SelectItemSuccess; - var itemLayer = null; - 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.layerIndex = a.item.data.layers?a.item.data.layers[0].index:-1; - } else if (a.item && a.item.itemType == "vnd.farmmaps.itemtype.temporal") { - itemLayer = new TemporalItemLayer(a.item); - } - return tassign(state, { - inSearch:false, - selectedItem: a.item, - selectedItemLayer: itemLayer, - panelVisible: a.item != null, - clearEnabled: a.item != null, - searchCollapsed: false, - searchMinified: true, - queryState: tassign(state.queryState, {itemCode:a.item ? a.item.code:null}) - }); - } - case mapActions.SELECTTEMPORALITEMSSUCCESS:{ - let a = action as mapActions.SelectTemporalItemsSuccess; - let selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer; - let layerIndex=-1; - selectedItemLayer.temporalItems = a.temporalItems; - if(a.temporalItems.length>0) { - let item = a.temporalItems[a.temporalItems.length-1]; - layerIndex = item.data.layers[0].index; - selectedItemLayer.selectedItemLayer = new ItemLayer(item,1,true,layerIndex); - } else { - selectedItemLayer.selectedItemLayer = null; - } - selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2],0,true,layerIndex):null; - selectedItemLayer.nextItemLayer = null; - if(selectedItemLayer.selectedItemLayer) { - let layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index; - selectedItemLayer.layerIndex = layerIndex; - } - - return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)}); - } - case mapActions.NEXTTEMPORAL: { - let temporalLayer = state.selectedItemLayer as ITemporalItemLayer; - if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) { - let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item); - if(index == (temporalLayer.temporalItems.length-1)) { - return state; - } else { - temporalLayer.previousItemLayer = temporalLayer.selectedItemLayer; - if( temporalLayer.previousItemLayer) { - temporalLayer.previousItemLayer.opacity=0; - temporalLayer.previousItemLayer.layerIndex = temporalLayer.layerIndex; - } - temporalLayer.selectedItemLayer = temporalLayer.nextItemLayer; - if( temporalLayer.selectedItemLayer) { - temporalLayer.selectedItemLayer.opacity=1; - temporalLayer.selectedItemLayer.layerIndex=temporalLayer.layerIndex; - } - temporalLayer.nextItemLayer = index+2 < temporalLayer.temporalItems.length ? new ItemLayer(temporalLayer.temporalItems[index+2],0,true,temporalLayer.layerIndex):null; - if( temporalLayer.nextItemLayer) { - temporalLayer.nextItemLayer.opacity=0; - temporalLayer.nextItemLayer.layerIndex = temporalLayer.layerIndex; - } - return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)}); - } - } else { - return state; - } - } - case mapActions.PREVIOUSTEMPORAL: { - let temporalLayer = state.selectedItemLayer as ITemporalItemLayer; - if(temporalLayer.temporalItems && temporalLayer.temporalItems.length>0) { - let index = temporalLayer.temporalItems.indexOf(temporalLayer.selectedItemLayer.item); - if(index == 0) { - return state; - } else { - temporalLayer.nextItemLayer = temporalLayer.selectedItemLayer; - if( temporalLayer.nextItemLayer) { - temporalLayer.nextItemLayer.opacity=0; - temporalLayer.nextItemLayer.layerIndex = temporalLayer.layerIndex; - } - temporalLayer.selectedItemLayer = temporalLayer.previousItemLayer; - if( temporalLayer.selectedItemLayer) { - temporalLayer.selectedItemLayer.opacity=1; - temporalLayer.selectedItemLayer.layerIndex = temporalLayer.layerIndex; - } - temporalLayer.previousItemLayer = index-2 >=0? new ItemLayer(temporalLayer.temporalItems[index-2],0,true,temporalLayer.layerIndex):null; - if( temporalLayer.previousItemLayer) { - temporalLayer.previousItemLayer.opacity=0; - temporalLayer.previousItemLayer.layerIndex = temporalLayer.layerIndex; - } - return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)}); - } - } else { - return state; - } - } - case mapActions.SELECTTEMPORAL:{ - //todo implement - } - case mapActions.STARTSEARCH: { - let 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; - return tassign(state, { - selectedItem: null, - features:[], - selectedItemLayer:null, - searchCollapsed: !panelVisible, - panelVisible: panelVisible, - clearEnabled: panelVisible, - searchMinified: panelVisible, - inSearch:panelVisible - }); - } - case commonActions.FAIL:{ - return tassign(state,{inSearch:false}); - } - case mapActions.DOQUERY: { - let a = action as mapActions.DoQuery; - return tassign(state, { - query: tassign(a.query, { bbox: a.query.bboxFilter ? state.viewExtent : [] })}); - } - case mapActions.ADDFEATURESUCCESS: { - let a = action as mapActions.AddFeatureSuccess; - let features = state.features.slice(); - features.push(a.feature); - return tassign(state, { - panelVisible: true, - selectedFeature: a.feature, - extent: a.feature.getGeometry().getExtent(), - searchCollapsed: false, - clearEnabled:true, - features:features - }); - } - case mapActions.UPDATEFEATURESUCCESS: { - let a = action as mapActions.UpdateFeatureSuccess; - let features: any[] = []; - var index = -1; - for (var i = 0; i < state.features.length; i++) { - if (state.features[i].getId() == a.feature.getId()) { - features.push(a.feature); - } else { - features.push(state.features[i]); - } - } - return tassign(state, { features: features }); - } - case mapActions.EXPANDSEARCH: { - return tassign(state, { searchCollapsed: false }); - } - case mapActions.COLLAPSESEARCH: { - return tassign(state, { searchCollapsed: state.panelVisible ? false: true}); - } - case mapActions.SETEXTENT: { - let a = action as mapActions.SetExtent; - return tassign(state, { extent: a.extent }); - } - case mapActions.ADDLAYER: { - let a = action as mapActions.AddLayer; - let itemLayers = state.overlayLayers.slice(0); - let itemLayer = new ItemLayer(a.item); - itemLayer.layerIndex = a.layerIndex == -1 ? 0 : a.layerIndex; - let existing = itemLayers.filter(il => il.item.code == itemLayer.item.code && il.layerIndex == itemLayer.layerIndex); - if(existing.length==0) { - itemLayers.push(itemLayer); - return tassign(state, { overlayLayers: itemLayers, selectedOverlayLayer: itemLayer }); - } else { - return state; - } - - } - case mapActions.REMOVELAYER: { - let a = action as mapActions.RemoveLayer; - let newLayers = state.overlayLayers.slice(0); - let i = state.overlayLayers.indexOf(a.itemLayer); - var selectedOverlayLayer: IItemLayer = null; - if (i>0 && state.overlayLayers.length > 1) - selectedOverlayLayer = state.overlayLayers[i - 1]; - else if (i == 0 && state.overlayLayers.length > 1) - selectedOverlayLayer = state.overlayLayers[i + 1]; - newLayers.splice(i, 1); - return tassign(state, { overlayLayers: newLayers, selectedOverlayLayer: selectedOverlayLayer }); - } - case mapActions.SETVISIBILITY: { - let a = action as mapActions.SetVisibility; - let newLayers = state.overlayLayers.slice(0); - let i = state.overlayLayers.indexOf(a.itemLayer); - newLayers[i].visible = a.visibility; - return tassign(state, { overlayLayers: newLayers }); - } - case mapActions.SETOPACITY: { - let a = action as mapActions.SetOpacity; - let newLayers = state.overlayLayers.slice(0); - let i = state.overlayLayers.indexOf(a.itemLayer); - newLayers[i].opacity = a.opacity; - return tassign(state, { overlayLayers: newLayers }); - } - case mapActions.SETLAYERINDEX: { - let a = action as mapActions.SetLayerIndex; - if (a.itemLayer == null) { - if(state.selectedItemLayer.item.itemType == "vnd.farmmaps.itemtype.temporal") { - var newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex}); - let tl = newItemlayer as ITemporalItemLayer; - if(tl.previousItemLayer) { - let nl = new ItemLayer(tl.previousItemLayer.item); - nl.opacity = tl.previousItemLayer.opacity; - nl.visible = tl.previousItemLayer.visible; - nl.layerIndex = a.layerIndex; - tl.previousItemLayer = nl; - } - if(tl.selectedItemLayer) { - let nl = new ItemLayer(tl.selectedItemLayer.item); - nl.opacity = tl.selectedItemLayer.opacity; - nl.visible = tl.selectedItemLayer.visible; - nl.layerIndex = a.layerIndex; - tl.selectedItemLayer = nl; - } - if(tl.nextItemLayer) { - let nl = new ItemLayer(tl.nextItemLayer.item); - nl.opacity = tl.nextItemLayer.opacity; - nl.visible = tl.nextItemLayer.visible; - nl.layerIndex = a.layerIndex; - tl.nextItemLayer = nl; - } - } else { - var newItemlayer = new ItemLayer(state.selectedItemLayer.item); - newItemlayer.layerIndex = a.layerIndex; - - } - return tassign(state, { selectedItemLayer: newItemlayer}) - } else { - let newLayers = state.overlayLayers.slice(0); - let i = state.overlayLayers.indexOf(a.itemLayer); - newLayers[i].layerIndex = a.layerIndex; - return tassign(state, { overlayLayers: newLayers }); - } - } - case mapActions.LOADBASELAYERSSUCCESS: { - let a =action as mapActions.LoadBaseLayersSuccess; - let baseLayers:ItemLayer[] = []; - for (let item of a.items) { - var l = new ItemLayer(item); - l.visible = false; - baseLayers.push(l); - } - var selectedBaseLayer: IItemLayer = null; - var mapState = tassign(state.mapState); - let sb = baseLayers.filter(layer => layer.item.code === mapState.baseLayerCode)[0]; - if (baseLayers.length > 0 && mapState.baseLayerCode != "" && sb) { - selectedBaseLayer = sb; - selectedBaseLayer.visible = true; - } else if (baseLayers.length > 0) { - selectedBaseLayer = baseLayers[0]; - selectedBaseLayer.visible = true; - mapState.baseLayerCode = selectedBaseLayer.item.code; - } - return tassign(state, { mapState:mapState, baseLayers: baseLayers, selectedBaseLayer: selectedBaseLayer }); - } - case mapActions.SELECTBASELAYER: { - let a = action as mapActions.SelectBaseLayer; - let baseLayers = state.baseLayers.slice(0); - baseLayers.forEach((l) => l.visible = false); - let i = state.baseLayers.indexOf(a.itemLayer); - baseLayers[i].visible = true; - var mapState = tassign(state.mapState); - mapState.baseLayerCode = a.itemLayer.item.code; - return tassign(state, {mapState:mapState, baseLayers:baseLayers,selectedBaseLayer:a.itemLayer }); - } - case mapActions.SELECTOVERLAYLAYER: { - let a = action as mapActions.SelectOverlayLayer; - return tassign(state, { selectedOverlayLayer: a.itemLayer }); - } - case commonActions.ESCAPE: { - let a = action as commonActions.Escape; - let newQueryState = tassign(state.queryState, { query: null, tags: null, itemCode: null, parentCode: null, itemType: null }); - if (a.escapeKey) { - return tassign(state, { - panelVisible: false, - panelCollapsed:false, - selectedItem: null, - selectedItemLayer: null, - selectedFeature: null, - queryState: newQueryState, - clearEnabled: false, - searchCollapsed: true, - searchMinified: false, - features: [], - query:initialState.query, - showLayerSwitcher: false - }); - } else { - return tassign(state, {}); - } - } - case mapActions.SETSTYLE:{ - let a = action as mapActions.SetStyle; - let styles = tassign(state.styles); - styles[a.itemType] = a.style; - return tassign(state,{styles:styles}); - } - case mapActions.SHOWLAYERSWITCHER:{ - let a = action as mapActions.ShowLayerSwitcher; - return tassign(state,{showLayerSwitcher:a.show}); - } - case mapActions.SETREPLACEURL: { - let a= action as mapActions.SetReplaceUrl; - return tassign(state,{replaceUrl:a.replaceUrl}); - } - case mapActions.CLEAR: { - return tassign(state,{setStateCount:0}); - } - default: { - return state; - } - } -} - -export const getMapState = (state: State) => state.mapState; -export const getParentCode = (state: State) => state.parentCode; -export const getFeatures = (state: State) => state.features; -export const getPanelVisible = (state: State) => state.panelVisible; -export const getPanelCollapsed = (state: State) => state.panelCollapsed; -export const getSelectedFeature = (state: State) => state.selectedFeature; -export const getSelectedItem = (state: State) => state.selectedItem; -export const getQueryState = (state: State) => state.queryState; -export const getClearEnabled = (state: State) => state.clearEnabled; -export const getSearchCollapsed = (state: State) => state.searchCollapsed; -export const getSearchMinified = (state: State) => state.searchMinified; -export const getExtent = (state: State) => state.extent; -export const getOverlayLayers = (state: State) => state.overlayLayers; -export const getBaseLayers = (state: State) => state.baseLayers; -export const getProjection = (state: State) => state.projection; -export const getSelectedBaseLayer = (state: State) => state.selectedBaseLayer; -export const getSelectedOverlayLayer = (state: State) => state.selectedOverlayLayer; -export const getQuery = (state: State) => state.query; -export const getSelectedItemLayer = (state: State) => state.selectedItemLayer; -export const getPeriod = (state:State) => state.period; -export const getStyles = (state:State) => state.styles; -export const getShowLayerSwitcher = (state:State) => state.showLayerSwitcher; -export const getSetStateCount = (state:State) => state.setStateCount; -export const getInSearch = (state:State) => state.inSearch; -export const getState = (state:State) => {return {mapState:state.mapState,queryState:state.queryState,setStateCount:state.setStateCount,replaceUrl:state.replaceUrl};} - -export const selectMapState = createFeatureSelector(MODULE_NAME); -export const selectGetMapState= createSelector(selectMapState, getMapState); -export const selectGetParentCode = createSelector(selectMapState, getParentCode); -export const selectGetFeatures = createSelector(selectMapState, getFeatures); -export const selectGetPanelVisible = createSelector(selectMapState, getPanelVisible); -export const selectGetPanelCollapsed = createSelector(selectMapState, getPanelCollapsed); -export const selectGetSelectedFeature = createSelector(selectMapState, getSelectedFeature); -export const selectGetSelectedItem = createSelector(selectMapState, getSelectedItem); -export const selectGetQueryState = createSelector(selectMapState, getQueryState); -export const selectGetClearEnabled = createSelector(selectMapState, getClearEnabled); -export const selectGetSearchCollapsed = createSelector(selectMapState, getSearchCollapsed); -export const selectGetSearchMinified = createSelector(selectMapState, getSearchMinified); -export const selectGetExtent = createSelector(selectMapState, getExtent); -export const selectGetOverlayLayers = createSelector(selectMapState, getOverlayLayers); -export const selectGetBaseLayers = createSelector(selectMapState, getBaseLayers); -export const selectGetProjection = createSelector(selectMapState, getProjection); -export const selectGetSelectedBaseLayer = createSelector(selectMapState, getSelectedBaseLayer); -export const selectGetSelectedOverlayLayer = createSelector(selectMapState, getSelectedOverlayLayer); -export const selectGetQuery = createSelector(selectMapState, getQuery); -export const selectGetSelectedItemLayer = createSelector(selectMapState, getSelectedItemLayer); -export const selectGetPeriod = createSelector(selectMapState, getPeriod); -export const selectGetStyles = createSelector(selectMapState, getStyles); -export const selectGetShowLayerSwitcher = createSelector(selectMapState,getShowLayerSwitcher); -export const selectgetSetStateCount = createSelector(selectMapState,getSetStateCount); -export const selectGetInSearch = createSelector(selectMapState,getInSearch); -export const selectGetState = createSelector(selectMapState,getState); - - diff --git a/projects/common-map/src/fm-map/services/device-orientation.service.ts b/projects/common-map/src/fm-map/services/device-orientation.service.ts deleted file mode 100644 index c7978f2..0000000 --- a/projects/common-map/src/fm-map/services/device-orientation.service.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observer, Observable } from 'rxjs'; - - -@Injectable() -export class DeviceOrientationService { - - compassHeading(alpha, beta, gamma):number { - - // Convert degrees to radians - var alphaRad = alpha * (Math.PI / 180); - var betaRad = beta * (Math.PI / 180); - var gammaRad = gamma * (Math.PI / 180); - - // Calculate equation components - var cA = Math.cos(alphaRad); - var sA = Math.sin(alphaRad); - var cB = Math.cos(betaRad); - var sB = Math.sin(betaRad); - var cG = Math.cos(gammaRad); - var sG = Math.sin(gammaRad); - - // Calculate A, B, C rotation components - var rA = - cA * sG - sA * sB * cG; - var rB = - sA * sG + cA * sB * cG; - var rC = - cB * cG; - - // Calculate compass heading - var compassHeading = Math.atan(rA / rB); - - // Convert from half unit circle to whole unit circle - if(rB < 0) { - compassHeading += Math.PI; - }else if(rA < 0) { - compassHeading += 2 * Math.PI; - } - return compassHeading * (180/Math.PI); - } - - getCurrentCompassHeading(): Observable { - return Observable.create((observer: Observer) => { - window.addEventListener("deviceorientation", (event:DeviceOrientationEvent)=>{ - let heading = this.compassHeading(event.alpha,event.beta,event.gamma); - if(!Number.isNaN(heading)) { - observer.next(heading); - } - } ); - }); - } - -} diff --git a/projects/common-map/src/fm-map/services/feature-icon.service.ts b/projects/common-map/src/fm-map/services/feature-icon.service.ts deleted file mode 100644 index 70a5a17..0000000 --- a/projects/common-map/src/fm-map/services/feature-icon.service.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Injectable} from '@angular/core'; -import { Feature } from 'ol'; -import { Point } from 'ol/geom'; -import * as extent from 'ol/extent'; - - -@Injectable() -export class FeatureIconService { - - getIconImageDataUrl(iconClass:string, backgroundColor: string = "#c80a6e",color:string = "#ffffff"): string { - var canvas = document.createElement('canvas'); - canvas.width = 365; - canvas.height = 560; - var ctx = canvas.getContext('2d'); - ctx.lineWidth = 6; - ctx.fillStyle = backgroundColor; - 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"); - ctx.fill(path) - - var iconCharacter = ""; - if (iconClass != null) { - var element = document.createElement("i"); - element.style.display = "none"; - element.className = iconClass; - document.body.appendChild(element); - iconCharacter = getComputedStyle(element, "::before").content.replace(/"/g, ''); - let iconFont = "200px " +getComputedStyle(element, "::before").fontFamily - document.body.removeChild(element); - ctx.strokeStyle = color; - ctx.fillStyle = color; - ctx.lineWidth = 15; - ctx.font = iconFont; - var ts = ctx.measureText(iconCharacter); - ctx.fillText(iconCharacter, 182.9 - (ts.width / 2), 250); - ctx.strokeText(iconCharacter, 182.9 - (ts.width / 2), 250); - } - - return canvas.toDataURL(); - } -} \ No newline at end of file diff --git a/projects/common-map/src/fm-map/services/geolocation.service.ts b/projects/common-map/src/fm-map/services/geolocation.service.ts deleted file mode 100644 index 8fa0038..0000000 --- a/projects/common-map/src/fm-map/services/geolocation.service.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observer, Observable,BehaviorSubject } from 'rxjs'; - -/** - * GeolocationService class. - * https://developers.google.com/maps/documentation/javascript/ - * https://dev.w3.org/geo/api/spec-source.html - */ -@Injectable() -export class GeolocationService { - - private positionObserver$:BehaviorSubject = new BehaviorSubject(null); - - constructor() { - navigator.geolocation.watchPosition( - (position: Position) => { - this.positionObserver$.next(position); - }, - (error: PositionError) => { - console.debug('Geolocation service: ' + error.message); - }, - { - enableHighAccuracy: true, - timeout: 5000, - maximumAge: 0 - } - ); - } - - - getCurrentPosition(): Observable { - return this.positionObserver$; - } -} diff --git a/projects/common-map/src/public-api.ts b/projects/common-map/src/public-api.ts deleted file mode 100644 index 0bf240f..0000000 --- a/projects/common-map/src/public-api.ts +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Public API Surface of common-map - */ - -export * from './fm-map/common-map.module'; diff --git a/projects/common-map/src/test.ts b/projects/common-map/src/test.ts deleted file mode 100644 index e11ff1c..0000000 --- a/projects/common-map/src/test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'core-js/es7/reflect'; -import 'zone.js/dist/zone'; -import 'zone.js/dist/zone-testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -declare const require: any; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/projects/common-map/tsconfig.lib.json b/projects/common-map/tsconfig.lib.json deleted file mode 100644 index 250ae7a..0000000 --- a/projects/common-map/tsconfig.lib.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/lib", - "target": "es2015", - "module": "es2015", - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "types": [], - "lib": [ - "dom", - "es2018" - ] - }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false - }, - "exclude": [ - "src/test.ts", - "**/*.spec.ts" - ] -} diff --git a/projects/common-map/tsconfig.spec.json b/projects/common-map/tsconfig.spec.json deleted file mode 100644 index 16da33d..0000000 --- a/projects/common-map/tsconfig.spec.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/spec", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "src/test.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/projects/common-map/tslint.json b/projects/common-map/tslint.json deleted file mode 100644 index 54923c8..0000000 --- a/projects/common-map/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tslint.json", - "rules": { - "directive-selector": [ - true, - "attribute", - "fm-map", - "camelCase" - ], - "component-selector": [ - true, - "element", - "fm-map", - "kebab-case" - ] - } -} diff --git a/projects/common/README.md b/projects/common/README.md deleted file mode 100644 index 9811f98..0000000 --- a/projects/common/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Common - -This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0. - -## Code scaffolding - -Run `ng generate component component-name --project common` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project common`. -> Note: Don't forget to add `--project common` or else it will be added to the default project in your `angular.json` file. - -## Build - -Run `ng build common` to build the project. The build artifacts will be stored in the `dist/` directory. - -## Publishing - -After building your library with `ng build common`, go to the dist folder `cd dist/common` and run `npm publish`. - -## Running unit tests - -Run `ng test common` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/projects/common/karma.conf.js b/projects/common/karma.conf.js deleted file mode 100644 index 3d0ddf2..0000000 --- a/projects/common/karma.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - coverageIstanbulReporter: { - dir: require('path').join(__dirname, '../../coverage/common'), - reports: ['html', 'lcovonly'], - fixWebpackSourcePaths: true - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true - }); -}; diff --git a/projects/common/ng-package.json b/projects/common/ng-package.json deleted file mode 100644 index 23ce9f8..0000000 --- a/projects/common/ng-package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", - "dest": "../../dist/common", - "lib": { - "entryFile": "src/public-api.ts", - "umdModuleIds": { - "my-data": "my-data" - } - }, - "whitelistedNonPeerDependencies": [ - "." - ] -} \ No newline at end of file diff --git a/projects/common/package-lock.json b/projects/common/package-lock.json deleted file mode 100644 index 32042d8..0000000 --- a/projects/common/package-lock.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@farmmaps/common", - "version": "0.0.1", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "angular-oauth2-oidc": { - "version": "8.0.4", - "resolved": "https://registry.npmjs.org/angular-oauth2-oidc/-/angular-oauth2-oidc-8.0.4.tgz", - "integrity": "sha512-7/3niJBqD7rnElcW+SudE36g7zMWChW4gSq7NpJSzDA4aQadBgvg0hn317MfPm9tpYGrpE3G/z2NMnbzek4TMA==", - "requires": { - "jsrsasign": "^8.0.12", - "tslib": "^1.9.0" - } - }, - "jsrsasign": { - "version": "8.0.12", - "resolved": "https://registry.npmjs.org/jsrsasign/-/jsrsasign-8.0.12.tgz", - "integrity": "sha1-Iqu5ZW00owuVMENnIINeicLlwxY=" - }, - "ngx-uploadx": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/ngx-uploadx/-/ngx-uploadx-3.3.2.tgz", - "integrity": "sha512-gRdXXq2cRU9HE6dj65qay9GV8NRC7n8y5LtMzJWqsfu2k3CHMQxo2TqZwA9/l/PqJ76RoO7sTPy1OenFQ+krkQ==", - "requires": { - "tslib": "^1.9.0" - } - }, - "tslib": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" - } - } -} diff --git a/projects/common/package.json b/projects/common/package.json deleted file mode 100644 index c61cd08..0000000 --- a/projects/common/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@farmmaps/common", - "version": "0.0.1", - "publishConfig": { - "registry": "https://repository.akkerweb.nl/repository/npm-hosted/" - }, - "peerDependencies": { - "@ng-bootstrap/ng-bootstrap": "^6.0", - "@angular/common": "~9.1.0", - "@angular/core": "~9.1.0", - "@angular/forms": "~9.1.0", - "@ngrx/effects": "^9.0", - "@ngrx/router-store": "^9.0", - "@ngrx/store": "^9.0", - "tassign": "^1.0.0", - "bootstrap": "^4.4.1", - "@aspnet/signalr": "^1.1.4", - "font-awesome": "^4.7.0", - "ngx-uploadx": "^3.3.4", - "angular-oauth2-oidc": "^9.1" - } -} diff --git a/projects/common/scss-bundle.config.json b/projects/common/scss-bundle.config.json deleted file mode 100644 index e69de29..0000000 diff --git a/projects/common/src/fm/actions/app-common.actions.ts b/projects/common/src/fm/actions/app-common.actions.ts deleted file mode 100644 index 2bd72fc..0000000 --- a/projects/common/src/fm/actions/app-common.actions.ts +++ /dev/null @@ -1,265 +0,0 @@ -import { Action } from '@ngrx/store'; - -import { IItemTypes } from '../models/item.types'; -import { IListItem } from '../models/list.item'; -import { IUser } from '../models/user'; -import { IItem } from '../models/item'; - -export const INITUSER = '[AppCommon] InitUser'; -export const INITUSERSUCCESS = '[AppCommon] InitUserSuccess'; - -export const INITUSERPACKAGES = '[AppCommon] InitUserPackages'; -export const INITUSERPACKAGESSUCCESS = '[AppCommon] InitUserPackagesSuccess'; - -export const INITROOT = '[Explorer] InitRoot'; -export const INITROOTSUCCESS = '[Explorer] InitRootSuccess'; - -export const OPENMODAL = '[AppCommon] OpenModal'; -export const CLOSEMODAL = '[AppCommon] CloseModal'; -export const LOGIN = '[AppCommon] Login'; -export const ESCAPE = '[AppCommon] Escape'; - -export const LOADITEMTYPES = '[AppCommon] LoadItemTypes'; -export const LOADITEMTYPESSUCCESS = '[AppCommon] LoadItemTypesSuccess'; - -export const ITEMCHANGEDEVENT = '[AppCommon] ItemChangedEvent'; -export const ITEMADDEDEVENT = '[AppCommon] ItemAddedEvent'; -export const ITEMDELETEDEVENT = '[AppCommon] ItemDeletedEvent'; - -export const TASKSTARTEVENT = '[AppCommon] TaskStartEvent'; -export const TASKENDEVENT = '[AppCommon] TaskEndEvent'; -export const TASKERRORTEVENT = '[AppCommon] TaskErrorEvent'; - -export const DEVICEUPDATEEVENT = '[AppCommon] DeviceUpdateEvent'; - -export const DELETEITEMS = '[AppCommon] DeleteItems'; -export const DELETEITEMSSUCCESS = '[AppCommon] DeleteItemsSuccess'; - -export const STARTROUTELOADING = '[AppCommon] StartRouteLoading'; -export const ENDROUTELOADING = '[AppCommon] EndRouteLoading'; - -export const FULLSCREEN = '[AppCommon] FullScreen'; -export const SHOWNAVBAR = '[AppCommon] ShowNavBar'; - -export const EDITITEM = "[AppCommon] EditItem"; - -export const VIEWITEM = "[AppCommon] ViewItem"; - -export const FAIL = '[AppCommon] Fail'; - -export const UPLOADEDFILECLICK = '[AppCommon] UploadedFileClick'; - -export const TOGGLEMENU = '[AppCommon] ToggleMenu'; - -export const SETMENUVISIBLE = '[AppCommon] SetMenuVisible'; - -export class InitUser implements Action { - readonly type = INITUSER; - - constructor() { } -} - -export class InitUserSuccess implements Action { - readonly type = INITUSERSUCCESS; - - constructor(public user:IUser ) { } -} - -export class InitUserPackagesSuccess implements Action { - readonly type = INITUSERPACKAGESSUCCESS; - - constructor(public items:IItem[] ) { } -} - -export class InitRoot implements Action { - readonly type = INITROOT; - - constructor() { } -} - -export class InitRootSuccess implements Action { - readonly type = INITROOTSUCCESS; - - constructor(public items:IListItem[]) { } -} - -export class OpenModal implements Action { - readonly type = OPENMODAL; - - constructor(public modalName: string) { } -} - -export class CloseModal implements Action { - readonly type = CLOSEMODAL; - - constructor() { } -} - -export class StartRouteLoading implements Action { - readonly type = STARTROUTELOADING; - - constructor() { } -} - -export class EndRouteLoading implements Action { - readonly type = ENDROUTELOADING; - - constructor() { } -} - -export class Login implements Action { - readonly type = LOGIN; - - constructor(public url: string) { } -} - -export class Escape implements Action { - readonly type = ESCAPE; - - constructor(public escapeKey:boolean, public click:boolean) { } -} - -export class LoadItemTypes implements Action { - readonly type = LOADITEMTYPES; - - constructor() { } -} - -export class LoadItemTypesSuccess implements Action { - readonly type = LOADITEMTYPESSUCCESS; - - constructor(public itemTypes: IItemTypes) { } -} - -export class Fail implements Action { - readonly type = FAIL; - - constructor(public payload: string) { } -} - -export class ItemChangedEvent implements Action { - readonly type = ITEMCHANGEDEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class ItemAddedEvent implements Action { - readonly type = ITEMADDEDEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class ItemDeletedEvent implements Action { - readonly type = ITEMDELETEDEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class TaskStartEvent implements Action { - readonly type = TASKSTARTEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class TaskEndEvent implements Action { - readonly type = TASKENDEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class TaskErrorEvent implements Action { - readonly type = TASKERRORTEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class DeviceUpdateEvent implements Action { - readonly type = DEVICEUPDATEEVENT; - - constructor(public itemCode: string, public attributes: any) { } -} - -export class DeleteItems implements Action { - readonly type = DELETEITEMS; - - constructor(public itemCodes: string[]) { } -} - -export class DeleteItemsSuccess implements Action { - readonly type = DELETEITEMSSUCCESS; - - constructor(public deletedItemCodes: string[]) { } -} - -export class EditItem implements Action { - readonly type = EDITITEM; - - constructor(public item: IListItem) { } -} - -export class ViewItem implements Action { - readonly type = VIEWITEM; - - constructor(public item: IListItem) { } -} - -export class FullScreen implements Action { - readonly type = FULLSCREEN; - - constructor() { } -} - -export class ShowNavBar implements Action { - readonly type = SHOWNAVBAR; - - constructor() { } -} - -export class UploadedFileClick implements Action { - readonly type = UPLOADEDFILECLICK; - constructor(public itemCode:string) { } -} - -export class ToggleMenu implements Action { - readonly type = TOGGLEMENU; - - constructor() { } -} - -export class SetMenuVisible implements Action { - readonly type = SETMENUVISIBLE; - - constructor(public visible:boolean) { } -} - - -export type Actions = OpenModal - | InitRoot - | InitRootSuccess - | CloseModal - | Login - | ItemChangedEvent - | ItemAddedEvent - | ItemDeletedEvent - | Escape - | LoadItemTypes - | LoadItemTypesSuccess - | DeleteItems - | DeleteItemsSuccess - | Fail - | EditItem - | ViewItem - | FullScreen - | ShowNavBar - | StartRouteLoading - | EndRouteLoading - | InitUser - | InitUserSuccess - | TaskStartEvent - | TaskEndEvent - | TaskErrorEvent - | DeviceUpdateEvent - | ToggleMenu - | SetMenuVisible - | InitUserPackagesSuccess; - diff --git a/projects/common/src/fm/common-routing.module.ts b/projects/common/src/fm/common-routing.module.ts deleted file mode 100644 index d02f375..0000000 --- a/projects/common/src/fm/common-routing.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule} from '@angular/router'; - -import {AuthCallbackComponent} from './components/auth-callback/auth-callback.component'; -import {AuthCallbackGuard} from './components/auth-callback/auth-callback.guard'; -import {NavBarGuard} from './services/nav-bar-guard.service'; -import {FullScreenGuard} from './services/full-screen-guard.service'; -import {SessionClearedComponent} from './components/session-cleared/session-cleared.component'; -import {NotFoundComponent} from './components/not-found/not-found.component'; - - -const routes = [ - { - path: 'cb', - component: AuthCallbackComponent - }, - { - path: 'loggedout', - component: SessionClearedComponent, - canActivate: [FullScreenGuard], - }, - { - path: '**', component: NotFoundComponent, - canActivate: [NavBarGuard] - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], -}) -export class AppCommonRoutingModule { -} diff --git a/projects/common/src/fm/common-service.module.ts b/projects/common/src/fm/common-service.module.ts deleted file mode 100644 index cff3204..0000000 --- a/projects/common/src/fm/common-service.module.ts +++ /dev/null @@ -1,86 +0,0 @@ -// angular modules -import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector, Optional, SkipSelf } from '@angular/core'; -import { DatePipe } from '@angular/common'; -import { HTTP_INTERCEPTORS } from '@angular/common/http'; - -// external modules -import { OAuthModule, OAuthService, OAuthStorage } from 'angular-oauth2-oidc'; - - -//components -import { ItemTypeService } from './services/itemtype.service'; -import { FolderService } from './services/folder.service'; -import { TimespanService } from './services/timespan.service'; -import { ItemService } from './services/item.service'; -import { EventService } from './services/event.service'; -import { TypeaheadService } from './services/typeahead.service'; -import { UserService } from './services/user.service'; -import { WeatherService} from './services/weather.service'; -import { AppConfig } from './shared/app.config'; -import { AccessTokenInterceptor } from "./shared/accesstoken.interceptor"; -import { appConfigFactory } from "./shared/app.config.factory"; -import { AuthGuard } from './services/auth-guard.service'; -import { NavBarGuard } from './services/nav-bar-guard.service'; -import { FullScreenGuard } from './services/full-screen-guard.service'; -import { CodeListItemService } from './services/codelistitem.service'; -import { AuthCallbackGuard } from './components/auth-callback/auth-callback.guard'; -import { ResumableFileUploadService } from './components/resumable-file-upload/resumable-file-upload.service'; -import { NgbDateNativeAdapter } from './services/date-adapter.service' -import { AuthConfigFactory } from './shared/authconfigFactory'; -import { StateSerializerService } from './services/state-serializer.service'; - -export { - FolderService, - ItemTypeService, - TimespanService, - ItemService, - EventService, - TypeaheadService, - UserService, - WeatherService, - CodeListItemService, - AppConfig, - AccessTokenInterceptor, - AuthGuard, - NavBarGuard, - FullScreenGuard, - AuthCallbackGuard, - ResumableFileUploadService, - NgbDateNativeAdapter, - StateSerializerService -}; - -@NgModule({ - imports: [ - OAuthModule.forRoot(), - ] -}) -export class AppCommonServiceModule { - constructor(@Optional() @SkipSelf() parentModule: AppCommonServiceModule) { - if (parentModule) { - throw new Error( - 'AppCommonServiceModule is already loaded. Import it in the AppModule only'); - } - } - static forRoot(): ModuleWithProviders { - return { - ngModule: AppCommonServiceModule, - providers: [ - AppConfig, - ItemTypeService, - { - provide: APP_INITIALIZER, - useFactory: appConfigFactory, - deps: [Injector, AppConfig, OAuthService, AuthConfigFactory, OAuthStorage,ItemTypeService], - multi: true - }, - { - provide: HTTP_INTERCEPTORS, - useClass: AccessTokenInterceptor, - multi: true - }, - DatePipe - ] - }; - } -} diff --git a/projects/common/src/fm/common.module.ts b/projects/common/src/fm/common.module.ts deleted file mode 100644 index 34909e7..0000000 --- a/projects/common/src/fm/common.module.ts +++ /dev/null @@ -1,134 +0,0 @@ -// angular modules -import { NgModule, APP_INITIALIZER, ModuleWithProviders, Injector, Optional, SkipSelf } from '@angular/core'; -import { CommonModule, DatePipe } from '@angular/common'; -import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; - -// external modules -import { OAuthModule, AuthConfig, OAuthService, OAuthStorage } from 'angular-oauth2-oidc'; -import { StoreModule, Store } from '@ngrx/store'; -import { EffectsModule } from '@ngrx/effects'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { UploadxModule } from 'ngx-uploadx'; - - -// routing module -import { AppCommonRoutingModule } from './common-routing.module'; - -import { MODULE_NAME } from './module-name'; - -//components -import { SafePipe } from './shared/safe.pipe'; -import { AuthConfigFactory, IAuthconfigFactory } from './shared/authconfigFactory'; -import { AppComponent } from './components/app/app.component'; -import { AuthCallbackComponent } from './components/auth-callback/auth-callback.component'; -import { SessionClearedComponent } from './components/session-cleared/session-cleared.component'; -import { ResumableFileUploadComponent } from './components/resumable-file-upload/resumable-file-upload.component'; -import { NotFoundComponent } from './components/not-found/not-found.component'; -import { NotImplementedComponent } from './components/not-implemented/not-implemented.component'; -import { SidePanelComponent } from './components/side-panel/side-panel.component'; -import { TimespanComponent } from './components/timespan/timespan.component'; -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 { Alert } from './enumerations/alert.enum'; -import { IEventMessage } from './models/event.message'; -import { IItem, Item } from './models/item'; -import { WeatherCurrentObservation } from './models/weatherCurrentObservation'; -import { IItemType } from './models/item.type'; -import { IItemTypes } from './models/item.types'; -import { IItemTask, ItemTask } from './models/itemTask'; -import { IListItem } from './models/list.item'; -import { ITypeaheadItem } from './models/typeahead.item'; -import { IPackage,IPackages } from './models/package'; -import { IUser } from './models/user'; -import { IQueryState } from './models/query.state'; -import { ICodeListItem } from './models/code.list.item'; -import * as commonActions from './actions/app-common.actions'; -import * as commonReducers from './reducers/app-common.reducer'; -import * as commonEffects from './effects/app-common.effects'; -import { SecureOAuthStorage} from './shared/secureOAuthStorage'; - -export { - SafePipe, - AuthCallbackComponent, - AppComponent, - SessionClearedComponent, - ResumableFileUploadComponent, - NotFoundComponent, - NotImplementedComponent, - SidePanelComponent, - TimespanComponent, - TagInputComponent, - HasPackageDirective, - Alert, - IEventMessage, - IItem, - Item, - IItemType, - IItemTypes, - IItemTask, - ItemTask, - IListItem, - ITypeaheadItem, - IUser, - ICodeListItem, - IQueryState, - IPackage, - IPackages, - commonActions, - commonReducers, - IAuthconfigFactory, - AuthConfigFactory, - MenuBackgroundComponent, - SecureOAuthStorage, - WeatherCurrentObservation -}; - -@NgModule({ - imports: [ - CommonModule, - HttpClientModule, - AppCommonRoutingModule, - StoreModule.forFeature(MODULE_NAME, commonReducers.reducer), - EffectsModule.forFeature([commonEffects.AppCommonEffects]), - OAuthModule.forRoot(), - NgbModule, - FormsModule, - UploadxModule - ], - declarations: [ - AppComponent, - AuthCallbackComponent, - SidePanelComponent, - SafePipe, - NotFoundComponent, - NotImplementedComponent, - ResumableFileUploadComponent, - TimespanComponent, - TagInputComponent, - SessionClearedComponent, - MenuBackgroundComponent, - HasPackageDirective - ], - exports: [ - NgbModule, - UploadxModule, - CommonModule, - AppComponent, - ResumableFileUploadComponent, - AuthCallbackComponent, - SidePanelComponent, - SafePipe, - NotFoundComponent, - NotImplementedComponent, - ResumableFileUploadComponent, - TimespanComponent, - TagInputComponent, - SessionClearedComponent, - MenuBackgroundComponent, - HasPackageDirective - ] -}) -export class AppCommonModule { -} diff --git a/projects/common/src/fm/components/app/app.component.html b/projects/common/src/fm/components/app/app.component.html deleted file mode 100644 index 8d83e0e..0000000 --- a/projects/common/src/fm/components/app/app.component.html +++ /dev/null @@ -1,26 +0,0 @@ -
- -
- -
- - -
-
-
- -
-
-
- -
-
-
-
- - - -
diff --git a/projects/common/src/fm/components/app/app.component.scss b/projects/common/src/fm/components/app/app.component.scss deleted file mode 100644 index 25bca4c..0000000 --- a/projects/common/src/fm/components/app/app.component.scss +++ /dev/null @@ -1,78 +0,0 @@ -/* Import Bootstrap & Fonts */ - -@import "~bootstrap/scss/bootstrap.scss"; - - -// custom styles - -.btn:focus { - box-shadow:none; -} - -.input-group > .form-control:focus { - z-index: auto; -} - -.form-control:focus { - box-shadow: none; - border-color: $input-border-color; -} - - -/* *** Overall APP Styling can go here *** - -------------------------------------------- - Note: This Component has ViewEncapsulation.None so the styles will bleed out - -*/ - -body { background: #f1f1f1; line-height: 18px; user-select:none;} - -.navbar-brand { - padding-top: .5rem; - padding-bottom: .5rem; -} - -.app { - width:100vw; - height:100vh; -} - -.app > .navbar { - position: absolute; - transition: top 0.5s ease-out; - top:0; - left: 0; - right: 0; - height: 3.1rem; -} - -.app > .body { - position: absolute; - transition: top 0.5s ease-out; - top: 3.1rem; - bottom: 0; - left: 0; - right: 0; - overflow:hidden; -} - -.app.fullscreen > .navbar { - top: -3.1rem; -} - -.app.fullscreen > .body { - top:0; -} - -.btn-primary, .btn-primary:hover { - color: #ffffff; -} - -.menu .side-panel { - z-index: 100; - background-color: rgb(245,245,245); -} - -.logo { - margin-left: 1rem; -} diff --git a/projects/common/src/fm/components/app/app.component.ts b/projects/common/src/fm/components/app/app.component.ts deleted file mode 100644 index df42be7..0000000 --- a/projects/common/src/fm/components/app/app.component.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener, Input } from '@angular/core'; -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 { Subscription , Observable } from 'rxjs'; -import { Store, Action } from '@ngrx/store'; - -//AppCommon -import { IEventMessage } from '../../models/event.message'; -import { IListItem} from '../../models/list.item'; -import { EventService } from '../../services/event.service'; -import * as commonActions from '../../actions/app-common.actions'; - -import * as appReducers from '../../reducers/app-common.reducer'; - -@Component({ - selector: 'fm-app', - templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'], - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class AppComponent implements OnInit, OnDestroy { - - // This will go at the END of your title for example "Home - Angular Universal..." <-- after the dash (-) - private endPageTitle: string = 'Farmmaps'; - // If no Title is provided, we'll use a default one before the dash(-) - private defaultPageTitle: string = 'Farmmaps'; - - private routerSub$: Subscription; - private eventSub$: Subscription; - - public currentFolder: Observable; - public folderParents: Observable; - public fullScreen: Observable; - public routeLoading: Observable; - public menuVisible: Observable; - @Input() showUploadProgress: boolean =true; - - constructor( - private router: Router, - private activatedRoute: ActivatedRoute, - private title: Title, - private meta: Meta, - private store: Store, - private eventService: EventService, - ) { - } - - - - getActionFromEvent(event: IEventMessage): Action { - var action: Action = null; - console.debug(`${event.eventType} Event received`); - switch (event.eventType) { - case "ItemChanged": { - action = new commonActions.ItemChangedEvent(event.itemCode, event.attributes); - break; - } - case "ItemAdded": { - action = new commonActions.ItemAddedEvent(event.itemCode, event.attributes); - break; - } - case "ItemDeleted": { - action = new commonActions.ItemDeletedEvent(event.itemCode, event.attributes); - break; - } - case "taskStart": { - action = new commonActions.TaskStartEvent(event.itemCode, event.attributes); - break; - } - case "taskEnd": { - action = new commonActions.TaskEndEvent(event.itemCode, event.attributes); - break; - } - case "taskError": { - action = new commonActions.TaskErrorEvent(event.itemCode, event.attributes); - break; - } - case "deviceUpdate": { - action = new commonActions.DeviceUpdateEvent(event.itemCode, event.attributes); - break; - } - } - return action; - } - - ngOnInit() { - this.fullScreen = this.store.select(appReducers.selectGetFullScreen); - this.routeLoading = this.store.select(appReducers.selectGetRouteLoading); - this.menuVisible = this.store.select(appReducers.SelectGetMenuVisible); - this.InstallRouteEventHandler(); - this.InstallEventServiceEventHandler(); - } - - @HostListener('document:keyup', ['$event']) - keyUp(event: KeyboardEvent) { - let x = event.keyCode; - if (x === 27) { - this.store.dispatch(new commonActions.Escape(true,false)); - } - } - - ngOnDestroy() { - // Subscription clean-up - if(this.routerSub$) this.routerSub$.unsubscribe(); - if(this.eventSub$) this.eventSub$.unsubscribe(); - } - - private InstallRouteEventHandler() { - var other = this; - this.routerSub$ = this.router.events.subscribe(event => { - if (event instanceof RouteConfigLoadStart) { - other.store.dispatch(new commonActions.StartRouteLoading()); - } - if (event instanceof RouteConfigLoadEnd) { - other.store.dispatch(new commonActions.EndRouteLoading()); - } - if(event instanceof NavigationStart) { - other.store.dispatch(new commonActions.SetMenuVisible(false)); - } - }); - } - - private InstallEventServiceEventHandler() { - var other = this; - this.eventSub$ = this.eventService.event.subscribe(event => { - var action = other.getActionFromEvent(event); - if (action) other.store.dispatch(action); - }); - } - - handleClick(event: MouseEvent) { - this.store.dispatch(new commonActions.Escape(false,true)); - } - - handleStopBubble(event: MouseEvent) { - event.stopPropagation(); - } - - handleToggleMenu(event:MouseEvent) { - event.stopPropagation(); - this.store.dispatch(new commonActions.ToggleMenu()); - } -} - diff --git a/projects/common/src/fm/components/auth-callback/auth-callback.component.ts b/projects/common/src/fm/components/auth-callback/auth-callback.component.ts deleted file mode 100644 index 74ccef2..0000000 --- a/projects/common/src/fm/components/auth-callback/auth-callback.component.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Component } from '@angular/core'; -import { Router } from '@angular/router'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { Location} from '@angular/common'; - -@Component({ - selector: 'fm-auth-callback', - template:'
' -}) -export class AuthCallbackComponent { - - constructor(private router$: Router,private oauthService$:OAuthService) { - oauthService$.loadDiscoveryDocument().then(() => { - oauthService$.tryLoginCodeFlow().then(() => { - router$.navigateByUrl((oauthService$.state && oauthService$.state!="")?decodeURIComponent(oauthService$.state):""); - }); - }) - } -} diff --git a/projects/common/src/fm/components/auth-callback/auth-callback.guard.ts b/projects/common/src/fm/components/auth-callback/auth-callback.guard.ts deleted file mode 100644 index 14b70e6..0000000 --- a/projects/common/src/fm/components/auth-callback/auth-callback.guard.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Router, CanActivate } from '@angular/router'; -import { Injectable } from '@angular/core'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { } from '@angular/router'; - -@Injectable({ - providedIn: 'root', -}) -export class AuthCallbackGuard implements CanActivate { - - constructor(private router$: Router,private oauthService$:OAuthService) {} - - canActivate() { - this.router$.navigateByUrl(this.oauthService$.state); - return false; - } -} diff --git a/projects/common/src/fm/components/has-package/has-package.directive.ts b/projects/common/src/fm/components/has-package/has-package.directive.ts deleted file mode 100644 index 9a4d202..0000000 --- a/projects/common/src/fm/components/has-package/has-package.directive.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Directive, ViewContainerRef,TemplateRef,OnInit,Input,OnDestroy } from '@angular/core'; -import { Store} from '@ngrx/store'; -import * as appCommonReducer from '../../reducers/app-common.reducer' -import { IPackages } from '../../models/package'; -import { Observable, Subscription } from 'rxjs'; - -@Directive({ - selector: '[fm-haspackage]', -}) -export class HasPackageDirective implements OnInit,OnDestroy{ - @Input('fm-haspackage') package:string; - - constructor(private templateRef$: TemplateRef,private viewContainerRef$: ViewContainerRef,private store$: Store) { } - private packages$:Observable = this.store$.select(appCommonReducer.SelectGetUserPackages); - private hasView = false; - private packSub:Subscription; - ngOnInit() { - this.packages$.subscribe((packages) => { - if (packages[this.package] && packages[this.package].enabled) { - this.viewContainerRef$.createEmbeddedView(this.templateRef$); - this.hasView=true; - } else if (this.hasView) { - this.viewContainerRef$.clear(); - this.hasView = false; - } - }); - } - - ngOnDestroy() { - if(this.packSub) this.packSub.unsubscribe(); - } -} \ No newline at end of file diff --git a/projects/common/src/fm/components/menu-background/menu-background.component.html b/projects/common/src/fm/components/menu-background/menu-background.component.html deleted file mode 100644 index abf4cab..0000000 --- a/projects/common/src/fm/components/menu-background/menu-background.component.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/projects/common/src/fm/components/menu-background/menu-background.component.scss b/projects/common/src/fm/components/menu-background/menu-background.component.scss deleted file mode 100644 index 8622cf5..0000000 --- a/projects/common/src/fm/components/menu-background/menu-background.component.scss +++ /dev/null @@ -1,18 +0,0 @@ -.menu-background { - display: block; - position: absolute; - top:0; - left:0; - right:0; - bottom:0; - opacity: 0; - background-color: #000000; - transition: opacity 0s ease-out 1s; - pointer-events: none; - z-index:99; -} - -.menu-background.show { - pointer-events: all; - opacity: 0.3; -} \ No newline at end of file diff --git a/projects/common/src/fm/components/menu-background/menu-background.component.ts b/projects/common/src/fm/components/menu-background/menu-background.component.ts deleted file mode 100644 index b790d94..0000000 --- a/projects/common/src/fm/components/menu-background/menu-background.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, OnInit,Input } from '@angular/core'; -import { Store, Action } from '@ngrx/store'; -import * as appReducers from '../../reducers/app-common.reducer'; -import * as commonActions from '../../actions/app-common.actions'; - -@Component({ - selector: 'fm-menu-background', - templateUrl: './menu-background.component.html', - styleUrls: ['./menu-background.component.scss'], -}) -export class MenuBackgroundComponent implements OnInit { - @Input() visible:boolean = false; - constructor(private store: Store) { } - - ngOnInit() { } - - handleOnClick(event:MouseEvent) { - if(this.visible) { - this.store.dispatch(new commonActions.SetMenuVisible(false)); - event.stopPropagation(); - } - } -} diff --git a/projects/common/src/fm/components/not-found/not-found.component.html b/projects/common/src/fm/components/not-found/not-found.component.html deleted file mode 100644 index 75d48f6..0000000 --- a/projects/common/src/fm/components/not-found/not-found.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
-

This page doesn't exist

-
-
diff --git a/projects/common/src/fm/components/not-found/not-found.component.ts b/projects/common/src/fm/components/not-found/not-found.component.ts deleted file mode 100644 index e36c407..0000000 --- a/projects/common/src/fm/components/not-found/not-found.component.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'fm-not-found', - templateUrl: './not-found.component.html' - // styleUrls: ['./not-found.component.css'] -}) -export class NotFoundComponent implements OnInit { - constructor() { } - - ngOnInit() { } -} diff --git a/projects/common/src/fm/components/not-implemented/not-implemented.component.html b/projects/common/src/fm/components/not-implemented/not-implemented.component.html deleted file mode 100644 index 04fa4f8..0000000 --- a/projects/common/src/fm/components/not-implemented/not-implemented.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
-

Function is not implemented in this code

-
-
diff --git a/projects/common/src/fm/components/not-implemented/not-implemented.component.ts b/projects/common/src/fm/components/not-implemented/not-implemented.component.ts deleted file mode 100644 index 9d44aed..0000000 --- a/projects/common/src/fm/components/not-implemented/not-implemented.component.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'fm-not-implemented', - templateUrl: './not-implemented.component.html' -}) -export class NotImplementedComponent implements OnInit { - constructor() { } - - ngOnInit() { } -} diff --git a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.html b/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.html deleted file mode 100644 index a062114..0000000 --- a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.html +++ /dev/null @@ -1,23 +0,0 @@ -
-
-
-
- Uploading files ({{uploadService.totalProgress | number:'1.1-1'}} %) - Uploaded {{uploadService.files.length}} files - -
-
-
- -
-
-
-
-
diff --git a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.scss b/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.scss deleted file mode 100644 index 3369815..0000000 --- a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.scss +++ /dev/null @@ -1,111 +0,0 @@ -/* Import Bootstrap & Fonts */ - -@import "~bootstrap/scss/bootstrap.scss"; - -div.resumable-file-upload { - position: fixed; - right: 0px; - bottom: 0px; - width: 300px; - max-height: 250px; - /*z-index:2000 !important;*/ -} - -div.minimized { - height: 0px; -} - -div.closed { - height: 0px; -} - -div.card { - margin-bottom: 0px; -} - -div.card-block { - max-height: calc(250px - 41px); - overflow-y: auto; -} - -div.minimized div.card-block { - height: 0px; -} - -div.card-header span.fa { - padding-left: 5px; -} - -.upload-file { - padding-top: 3px; -} - - .upload-file .progress-container { - height: 3px; - width: 100%; - margin-top:4px; - } - - .upload-file .progress-container .progress-bar { - display: block; - background-color: color("green"); - width: 0%; - height: 100%; - } - - .upload-file.done .progress-container .progress-bar { - display: none; - } - - .upload-file > div > span.file-name { - display: inline-block; - width: calc(100% - 20px); - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - vertical-align: middle; - } - - .upload-file > div > a.file-name { - display: inline-block; - width: calc(100% - 20px); - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - vertical-align: middle; - } - -.upload-file.busy > div > span.fa-times { - color: theme-color("danger"); - width: 20px; - display: inline-block; - vertical-align: middle; -} - - .upload-file.done > div > span.fa-times { - display: none; - } - - .upload-file.done > div > span.fa-check { - color: color("green"); - width: 20px; - display: inline-block; - vertical-align: middle; - } - - .upload-file > div.errormessage { - color: theme-color("danger"); - display: none; - } - - .upload-file.error > div.errormessage { - display: block; - } - - .upload-file.busy > div > span.fa-check { - display: none; - } - -.resumable-file-upload ul { - padding:0px; -} diff --git a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.ts b/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.ts deleted file mode 100644 index 0e6076f..0000000 --- a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Component, Input,Output, HostListener, ChangeDetectorRef, OnDestroy, OnInit,EventEmitter } from '@angular/core'; -import { ResumableFileUploadService, File } from './resumable-file-upload.service'; -import { Subscription } from 'rxjs'; -import { Store } from '@ngrx/store'; -import * as commonReducer from '../../reducers/app-common.reducer'; -import * as commonActions from '../../actions/app-common.actions'; - - -@Component({ - selector: 'fm-resumable-file-upload', - templateUrl: './resumable-file-upload.component.html', - styleUrls: ['./resumable-file-upload.component.scss'] -}) - -export class ResumableFileUploadComponent implements OnInit, OnDestroy { - - @Input('parentCode') - set parentCode(parentCode: string) { - if (parentCode && parentCode != "null" && parentCode != "") - this.uploadService.parentCode = parentCode; - else - this.uploadService.parentCode = null; - } - - constructor(private cd: ChangeDetectorRef, public uploadService: ResumableFileUploadService,public store: Store) { - } - - private refreshSub: Subscription; - - ngOnInit() { - this.uploadService.init(); - this.refreshSub = this.uploadService.refresh.subscribe((e: any) => { - this.cd.markForCheck(); - }); - } - - ngOnDestroy() { - if(this.refreshSub) this.refreshSub.unsubscribe(); - } - - handleUploadedFileClick(event:MouseEvent,file:File) { - event.preventDefault(); - this.store.dispatch(new commonActions.UploadedFileClick(file.itemCode)); - } - - //TODO do this with an canunload guard - @HostListener('window:beforeunload') - windowBeforeUnload = function () { - if (this.uploadService.isUploading) { - return false; - } - } -} diff --git a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.service.ts b/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.service.ts deleted file mode 100644 index 390df73..0000000 --- a/projects/common/src/fm/components/resumable-file-upload/resumable-file-upload.service.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { Injectable, OnDestroy } from '@angular/core'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { Subject , Subscription } from 'rxjs'; -import { HttpClient } from "@angular/common/http"; -import { UploadxService, UploadState,UploadxOptions} from 'ngx-uploadx'; -import { AppConfig } from '../../shared/app.config'; - - -@Injectable({ providedIn: 'root' }) -export class ResumableFileUploadService implements OnDestroy{ - public files: Array = new Array(); - public isUploading = false; - public totalProgress = 0; - public isClosed = true; - public isMinimized = false; - public parentCode: string; - public refresh: Subject = new Subject(); - private _eventSub:Subscription; - private initialized = false; - - constructor(private httpClient: HttpClient,private oauthService: OAuthService,private uploadService: UploadxService,public appConfig: AppConfig) { - - } - - endPoint() { - return `${this.appConfig.getConfig("apiEndPoint")}/api/v1/file`; - } - - init() { - if(!this.initialized) { - this._eventSub=this.uploadService.init({ - endpoint:this.endPoint(), - token:() => this.oauthService.getAccessToken(), - chunkSize: 2097152}).subscribe((uploadState:UploadState) => { - this.handleState(uploadState); - } ); - this.initialized=true; - } - } - - updatetotalprogress() { - var totalProgress =0; - var n=0; - for(var i =0;i f.identifier == state.uploadId ) - if(file) { - file.progress = (state.progress?state.progress:0); - } - };break; - case "complete": { - var file =this.files.find((f) => f.identifier == state.uploadId ) - if(file) { - var parts = state.url.split("/"); - file.itemCode = parts[parts.length-1]; - file.progress = (state.progress?state.progress:0); - file.success=true; - } - };break; - case "error": { - var file =this.files.find((f) => f.identifier == state.uploadId ) - if(file) { - file.error=true; - file.errorMessage = state.response; - } - };break; - } - this.updatetotalprogress(); - this.refresh.next({}); - } - - addFiles = (files: any[], event: any, metadata:any) => { - for (let f of files) { - var options:UploadxOptions = {metadata:metadata}; - this.uploadService.handleFile(f,options); - } - } - - toggleMinimize = function () { - this.isMinimized = !this.isMinimized; - }; - - cancelFile = function (file) { - this.uploadService.control({action:'cancel',uploadId:file.identifier}); - var index = this.files.indexOf(file, 0); - if (index > -1) { - this.files.splice(index, 1); - } - }; - - doClose = function () { - this.uploadService.control({action:'cancelAll'}); - this.files = new Array(); - this.isClosed = true; - } - - close = function () { - let close = true; - if (this.isUploading) { - close = false; - } - if (close) { - this.doClose(); - } - } - - ngOnDestroy() { - if(this._eventSub) this._eventSub.unsubscribe(); - } -} - -export class File { - private file: any; - public fileName: string; - public progress: number; - public identifier: string; - public itemCode: string; - public success: boolean; - public error: boolean; - public errorMessage: string; - - - constructor(state: UploadState) { - this.file = state; - this.fileName = state.file.name; - this.progress = state.progress?state.progress:0; - this.identifier = state.uploadId; - this.success = false; - this.error = false; - this.errorMessage = ""; - this.itemCode = null; - } -} diff --git a/projects/common/src/fm/components/session-cleared/session-cleared.component.html b/projects/common/src/fm/components/session-cleared/session-cleared.component.html deleted file mode 100644 index 16640d8..0000000 --- a/projects/common/src/fm/components/session-cleared/session-cleared.component.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
-

You have been logged out

- -
-
-
diff --git a/projects/common/src/fm/components/session-cleared/session-cleared.component.scss b/projects/common/src/fm/components/session-cleared/session-cleared.component.scss deleted file mode 100644 index 246c0a0..0000000 --- a/projects/common/src/fm/components/session-cleared/session-cleared.component.scss +++ /dev/null @@ -1,6 +0,0 @@ -.session-cleared { - display: flex; - align-items: center; - justify-content: center; - min-height: 100%; -} diff --git a/projects/common/src/fm/components/session-cleared/session-cleared.component.ts b/projects/common/src/fm/components/session-cleared/session-cleared.component.ts deleted file mode 100644 index 9b61f13..0000000 --- a/projects/common/src/fm/components/session-cleared/session-cleared.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { Router, ActivatedRoute, ParamMap } from '@angular/router'; -import { Store } from '@ngrx/store'; -import * as appCommonReducers from '../../reducers/app-common.reducer'; -import * as appCommonActions from '../../actions/app-common.actions'; - - - -@Component({ - selector: 'fm-session-cleared', - templateUrl: 'session-cleared.component.html', - styleUrls: ['session-cleared.component.scss'] -}) - - -export class SessionClearedComponent { - - constructor(private route: ActivatedRoute, private store: Store) { - } - - handleLoginClick() { - this.store.dispatch(new appCommonActions.Login(this.route.snapshot.queryParamMap.get('redirectTo'))); - } -} diff --git a/projects/common/src/fm/components/side-panel/side-panel.component.html b/projects/common/src/fm/components/side-panel/side-panel.component.html deleted file mode 100644 index 7f6f944..0000000 --- a/projects/common/src/fm/components/side-panel/side-panel.component.html +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/projects/common/src/fm/components/side-panel/side-panel.component.scss b/projects/common/src/fm/components/side-panel/side-panel.component.scss deleted file mode 100644 index 16c57db..0000000 --- a/projects/common/src/fm/components/side-panel/side-panel.component.scss +++ /dev/null @@ -1,123 +0,0 @@ -.side-panel { - position: absolute; - bottom: 0px; - width: 100%; - left: 0px; - top:50%; - transition: left 0.2s, top 0.2s; - background-color: white; - box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); -} - -.side-panel.resizing { - transition: left 0s, top 0s; -} - -.side-panel.collapsed { - left:-22rem; -} - -.arrow { - position: absolute; - top: 1rem; - left: 100%; - background-color: inherit; - cursor:pointer; -} - -.arrow i { - transition: transform 0.2s; -} - -.collapsed .arrow i { - -webkit-transform: rotate(180deg); - transform: rotate(180deg); -} - -.side-panel.hidden { - top:100%; -} - -.content { - height:100% ; - width:100%; - overflow:hidden; - overflow-y:auto; - position: relative; - z-index: 1; - background-color: rgb(255,255,255); -} - -.resizegrip { - height:2rem; - line-height: 1rem; - display: none; - text-align: center; - position: relative; - z-index: 2; -} -div.resizegrip > div { - position: absolute; - top:0px; - height: 1rem; - width: 100%; - background-color: rgb(255,255,255); -} - -div.resizegrip > span { - position: relative; - display: inline-block; - height:0.3rem; - width:4rem; - background-color:rgba(0, 0, 0, 0.3); - top:-0.3rem; -} - -.resizeable .resizegrip { - display:block; - -} - -.resizeable .content { - height:calc(100% - 1rem); - top:-1rem; -} - -@media screen and (min-width:40rem) { - .side-panel { - top:0px; - width: 22rem; - height:100%; - left:0px; - } - - .side-panel.hidden { - width: 22rem; - left:-24rem; - height:100%; - top: 0px; - } -} - - -.side-panel.left { - top:0px; - width: 80%; - height:100%; - left:0px; -} - -.side-panel.left.hidden { - width: 80%; - left:-80%; - height:100%; -} - -@media screen and (min-width:40rem) { - .side-panel.left { - width:22rem; - } - .side-panel.left.hidden { - width:22rem; - } -} \ No newline at end of file diff --git a/projects/common/src/fm/components/side-panel/side-panel.component.ts b/projects/common/src/fm/components/side-panel/side-panel.component.ts deleted file mode 100644 index 3ba19e3..0000000 --- a/projects/common/src/fm/components/side-panel/side-panel.component.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Component, Input,ViewChild,ElementRef,OnChanges,SimpleChanges,HostListener,ChangeDetectorRef } from '@angular/core'; - -@Component({ - selector: 'fm-side-panel', - templateUrl: 'side-panel.component.html', - styleUrls: ['side-panel.component.scss'] -}) - - -export class SidePanelComponent implements OnChanges { - @Input() public visible: boolean; - @Input() public collapsed: boolean; - @Input() public collapsable: boolean; - @Input() public resizeable: boolean = false; - @Input() public left: boolean = false; - @ViewChild("resizeGrip") elementView: ElementRef; - public mobile:boolean = true; - private parentHeight:number = 0; - public top = "100%"; - private resizeTop:number=50; - public resizing:boolean=false; - - constructor(private element: ElementRef,private ref: ChangeDetectorRef) { - this.collapsable = false; - this.setTop(); - } - - checkMobile():boolean { - let size = parseFloat(getComputedStyle(document.documentElement).width); - let rem = parseFloat(getComputedStyle(document.documentElement).fontSize); - let threshold = 40 * rem; - return !(size>threshold); - } - - setTop() { - this.mobile = this.left?false: this.checkMobile(); - this.resizeTop = this.mobile?50:0; - this.top = (this.visible?this.resizeTop: (this.mobile? 100:0)) + "%"; - } - - ngAfterViewInit() { - this.parentHeight = this.element.nativeElement.offsetParent.clientHeight; - this.setTop(); - } - - handleToggleClick(event) { - if (this.collapsable) { - this.collapsed = !this.collapsed; - } - } - - handleStartGripDrag(event:DragEvent|TouchEvent) { - this.resizing=true; - if(event instanceof DragEvent) { - var crt = new Image(); - crt.style.display = "none"; - document.body.appendChild(crt); - event.dataTransfer.setDragImage(crt,0,0); - } - } - - handleEndGripDrag() { - this.resizing = false; - } - - handleGripDrag(event:DragEvent|TouchEvent) { - var clientY = 0; - if((event instanceof TouchEvent)) { - clientY = (event as TouchEvent).changedTouches[0].clientY; - } else { - clientY=(event as DragEvent).clientY; - } - this.resizeTop = Math.min(98, Math.max(0, clientY / (this.parentHeight / 100))); - this.top = (this.visible? this.resizeTop:(this.mobile? 100:0)) + "%"; - } - - ngOnChanges(changes: SimpleChanges) { - if(changes.visible) { - this.top = (changes.visible.currentValue?this.resizeTop:(this.mobile? 100:0)) + "%"; - } - } - - @HostListener('window:resize', ['$event']) - onResize(event) { - this.setTop(); - } -} diff --git a/projects/common/src/fm/components/tag-input/tag-input.component.html b/projects/common/src/fm/components/tag-input/tag-input.component.html deleted file mode 100644 index f5a7795..0000000 --- a/projects/common/src/fm/components/tag-input/tag-input.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- {{tag}} -
diff --git a/projects/common/src/fm/components/tag-input/tag-input.component.scss b/projects/common/src/fm/components/tag-input/tag-input.component.scss deleted file mode 100644 index e95384b..0000000 --- a/projects/common/src/fm/components/tag-input/tag-input.component.scss +++ /dev/null @@ -1,16 +0,0 @@ -.tag { - display:inline-block; - padding:0.5rem; - margin-bottom:0.5rem; - margin-top:0.5rem; - margin-right:1rem; -} - -:host(tag-input) { - height: auto ; -} - -input { - margin-bottom: 0.5rem; - margin-top: 0.5rem; -} diff --git a/projects/common/src/fm/components/tag-input/tag-input.component.ts b/projects/common/src/fm/components/tag-input/tag-input.component.ts deleted file mode 100644 index 5be11dc..0000000 --- a/projects/common/src/fm/components/tag-input/tag-input.component.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { Component, Input, forwardRef,ElementRef,ViewChild } from '@angular/core'; -import { ControlValueAccessor, NG_VALUE_ACCESSOR,NgModel } from '@angular/forms'; -import { Observable,of } from 'rxjs'; -import { tap,catchError,debounceTime,distinctUntilChanged,switchMap } from 'rxjs/operators' -import { TypeaheadService } from '../../services/typeahead.service'; - -@Component({ - selector: 'fm-tag-input', - templateUrl: 'tag-input.component.html', - styleUrls: ['tag-input.component.scss'], - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => TagInputComponent), - multi: true - } - ] -}) - -export class TagInputComponent implements ControlValueAccessor { - @Input() tags: string[] - @ViewChild('taginput', { static: true }) tagInputElement: ElementRef; - public tag: string; - searching = false; - searchFailed = false; - - constructor(private typeaheadService: TypeaheadService) { - } - - tagExists(tag) { - if (tag.length == 0) return true; - for (let t of this.tags) { - if (t.toLowerCase() == tag.toLowerCase()) return true; - } - return false; - } - - handleDeleteTag(tag) { - let tags = []; - for (let t of this.tags) { - if (t != tag) tags.push(t); - } - this.tags = tags; - this.propagateChange(tags); - } - - handleAddTag(event) { - if (!this.tagExists(this.tag)) { - this.tags.push(this.tag); - this.propagateChange(this.tags); - } - this.tag = ""; - this.tagInputElement.nativeElement.focus(); - } - - handleCheckAddTag(event: KeyboardEvent) { - if (event.keyCode == 188) { - let tag = this.tag.substr(0, this.tag.length - 1); // strip , - if (!this.tagExists(tag)) { - this.tags.push(tag); - this.propagateChange(this.tags); - } - this.tag = ""; - } - } - - handleSelect(event) { - if (!this.tagExists(event.item)) { - this.tags.push(event.item); - this.propagateChange(this.tags); - } - event.preventDefault(); - this.tag = ""; - } - - propagateChange = (_: any) => { }; - - registerOnChange(fn) { - this.propagateChange = fn; - } - - findTag = (text$: Observable) => - text$.pipe( - debounceTime(200), - distinctUntilChanged(), - tap(() => this.searching = true), - switchMap(term => term.length < 1 ? of([]) : - this.typeaheadService.getTagTypeaheadItems(term).pipe( - tap(() => this.searchFailed = false), - catchError(() => { - this.searchFailed = true; - return of([]); - })) - ), - tap(() => this.searching = false) - ); - - writeValue(value: any) { - this.tags = value; - this.tag = ""; - } - - registerOnTouched() { } -} diff --git a/projects/common/src/fm/components/timespan/timespan.component.css b/projects/common/src/fm/components/timespan/timespan.component.css deleted file mode 100644 index 9166a14..0000000 --- a/projects/common/src/fm/components/timespan/timespan.component.css +++ /dev/null @@ -1,77 +0,0 @@ -.timespan { - width:100%; - position: relative; - user-select: none; -} - -.collapsed { - height:0; - overflow: hidden; -} - -.timeline { - position: relative; - height: 6rem; - width: 100%; - margin-top: 0.5rem; - overflow: hidden; -} - -.timeline canvas { - top:0; - left:0; - width:100%; - height:100%; -} - -.control-container { - position: absolute; - top:0px; - width:100%; - overflow: hidden; - font-size: 0; - white-space: nowrap; - pointer-events: none; -} - -.leftGrip,.rightGrip,.range { - pointer-events: all; - display: inline-block; - height:100%; - /* float: left; */ - font-size: 9pt; - text-align: center; - vertical-align: top; - overflow: hidden; -} - -.range { - /* height:100%; */ -} - -.leftGrip,.rightGrip { - width:15px; - background-color: rgb(204, 200, 200); - border:1px solid black; -} - -.rightGrip { - cursor: e-resize; -} - -.leftGrip { - left: -100px; - cursor:w-resize; -} - -.range { - /* background: linear-gradient( rgba(0, 140, 255, 0.856),transparent); */ - background-color:rgba(0, 140, 255, 0.856); - cursor: move; -} - -.popover-anchor { - position:absolute; - top:2rem; - font-size: 0.8rem; -} \ No newline at end of file diff --git a/projects/common/src/fm/components/timespan/timespan.component.html b/projects/common/src/fm/components/timespan/timespan.component.html deleted file mode 100644 index babee09..0000000 --- a/projects/common/src/fm/components/timespan/timespan.component.html +++ /dev/null @@ -1,34 +0,0 @@ -
-
{{caption}}
- {{caption}} -
 
-
 
- -
diff --git a/projects/common/src/fm/components/timespan/timespan.component.ts b/projects/common/src/fm/components/timespan/timespan.component.ts deleted file mode 100644 index 8e523b7..0000000 --- a/projects/common/src/fm/components/timespan/timespan.component.ts +++ /dev/null @@ -1,583 +0,0 @@ -import { Component, OnInit,Input,ViewChild,OnChanges,ChangeDetectorRef,Output, EventEmitter,SimpleChanges } from '@angular/core'; -import { DatePipe } from '@angular/common'; -import {NgbPopover} from '@ng-bootstrap/ng-bootstrap'; - -export interface TimeSpan { - startDate:Date; - endDate:Date; -} - -@Component({ - selector: 'fm-timespan', - templateUrl: './timespan.component.html', - styleUrls: ['./timespan.component.css'] -}) -export class TimespanComponent implements OnInit, OnChanges { - - scale:number = 1000 * 60 * 60 ; // milliseconds / pixel ( 1 hour ) - 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']; - quarters:string[] = ['KW1','KW2','KW3','KW4']; - unitScale:number = 3; - viewMinDate:Date; - viewMaxDate:Date; - extentMinDate:Date; - extentMaxDate:Date; - cursorDate:Date; - leftGripMove:boolean = false; - rightGripMove:boolean = false; - rangeGripMove:boolean = false; - viewPan:boolean = false; - downX:number = -1; - mouseX: number = -1; - mouseY: number = -1; - elementWidth:number; - elementHeight:number; - lastOffsetInPixels:number=0; - @ViewChild('timeLine', { static: true }) canvasRef; - @ViewChild('popoverStart', { static: true }) public popoverStart:NgbPopover; - @ViewChild('popoverEnd', { static: true }) public popoverEnd:NgbPopover; - @Input() collapsed: boolean = true; - @Input() startDate: Date = new Date(2018,1,3); - @Input() endDate: Date = new Date(2018,1,5); - @Input() unit:string; - @Input() color:string = '#000000'; - @Input() background:string = '#ffffff'; - @Input() hoverColor:string ='#ffffff'; - @Input() hoverBackground:string ='#0000ff'; - @Input() lineColor:string='#000000'; - @Input() lineWidth:number=1; - @Input() padding:number = 4; - @Output() change:EventEmitter = new EventEmitter(); - public caption:string = "2016/2017"; - public marginLeft:number = 100; - public startPopoverLeft:number=110; - public endPopoverLeft:number=120; - public rangeWidth:number =75; - public startCaption={}; - public endCaption={}; - private ratio:number=1; - private initialized:boolean=false; - private ctx:CanvasRenderingContext2D; - public posibleUnits:number[] = []; - public height:number = 0; - public lineHeight:number = 0; - - constructor(private changeDetectorRef: ChangeDetectorRef,private datePipe: DatePipe) { } - - setCanvasSize() { - let canvas = this.canvasRef.nativeElement; - this.elementWidth = canvas.offsetWidth; - this.elementHeight = canvas.offsetHeight; - canvas.height = this.elementHeight * this.ratio; - canvas.width = this.elementWidth * this.ratio; - } - - getPosibleUnits(scale:number):number[] { - let posibleUnits = []; - for(let u of [3,4,6,8]) { - if((this.unitScale <=u) ) - posibleUnits.push(u); - } - return posibleUnits; - } - - getLineHeight():number { - return (parseInt(this.ctx.font.match(/\d+/)[0], 10)/ this.ratio) + (2*this.padding) ; - } - - getHeight():number { - - return (this.posibleUnits.length * this.getLineHeight()); - } - - ngOnInit() { - this.ratio = 2; - this.unitScale = this.getUnitScale(this.unit); - let canvas:HTMLCanvasElement = this.canvasRef.nativeElement; - this.ctx = canvas.getContext('2d'); - this.elementWidth = canvas.offsetWidth; - this.elementHeight = canvas.offsetHeight; - this.ctx.font=`normal ${this.ratio*10}pt Sans-serif`; - 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.change.emit({startDate:this.startDate,endDate:this.endDate}); - let rangeInMilliseconds = this.endDate.getTime() - this.startDate.getTime(); - this.scale = this.getFitScale(rangeInMilliseconds,this.elementWidth); - this.posibleUnits=this.getPosibleUnits(this.scale); - this.height=this.getHeight(); - this.lineHeight= this.getLineHeight(); - this.setCanvasSize(); - let center = (this.startDate.getTime()+this.endDate.getTime())/2; - this.viewMinDate = 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.startCaption={popoverCaption:this.getStartCaption(this.startDate,this.unitScale,true)}; - this.endCaption={popoverCaption:this.getEndCaption(this.endDate,this.unitScale,true)}; - this.redraw(); - this.initialized=true; - } - - getStartEndCaption(date:Date,otherDate:Date,unitScale:number,suffix:boolean = false,extended:boolean=true):string { - let showSuffix = false; - otherDate=new Date(otherDate.getTime()-1); // fix year edge case - if(unitScale == 3) { - let format="HH:00"; - if(extended) { - if(suffix || date.getFullYear() != otherDate.getFullYear()) - format="d MMM yyyy:HH:00"; - else if(date.getMonth() !== otherDate.getMonth()) - format="d MMM HH:00"; - } - return this.datePipe.transform(date,format); - - } - if(unitScale == 4) { - let format="d"; - if(extended) { - if(suffix || date.getFullYear() != otherDate.getFullYear()) - format="d MMM yyyy"; - else if(date.getMonth() !== otherDate.getMonth()) - format="d MMM" - } - return this.datePipe.transform(date,format); - - } - if(unitScale == 6) { - let format = "MMM"; - if(extended) { - if(suffix || date.getFullYear() != otherDate.getFullYear()) - format="MMM yyyy"; - } - return this.datePipe.transform(date,format); - } - if(unitScale == 7) { - let q = Math.trunc(date.getMonth() /3 ); - return this.quarters[q]; - } - if(unitScale == 8) { - return this.datePipe.transform(date,"yyyy"); - } - return ""; - } - - getStartCaption(startDate:Date,unitScale:number,suffix:boolean=false,extended:boolean=true):string { - 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 { - return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale]/2)),this.startDate, unitScale,suffix); - } - - getCaption(startDate:Date,endDate:Date,unitScale:number):string { - let startCaption=this.getStartCaption(startDate,unitScale); - let endCaption=this.getEndCaption(endDate,unitScale); - if((endDate.getTime() - startDate.getTime()) < (1.5*this.unitScales[this.unitScale])) - return endCaption; - return `${startCaption}-${endCaption}`; - } - - public updatePopoverText(popover:NgbPopover, text:string): void { - const isOpen = popover.isOpen(); - if (isOpen) { - popover.close(); - popover.open({popoverCaption:text}); - } - } - - getFitScale(rangeInMilliSeconds:number,elementWidth:number):number { - let width = elementWidth*0.33; - return rangeInMilliSeconds/width; - } - - getUnitScale(unit:string):number { - if(!unit) return 3; // hour - for(var _i=0;_i (steppedOneUnit-(2*this.padding)) && s < steps.length -1) { - step=steps[++s]; - steppedOneUnit=oneUnit*step; - } - if(steppedOneUnit - (2*this.padding) < unitTextWidth) return yOffset; - this.ctx.moveTo(0,yOffset*this.ratio); - this.ctx.lineTo(width*this.ratio,yOffset*this.ratio); - this.ctx.stroke(); - var x:number = pixelOffset; - var nextDateOffset = this.getUnitDateOffset(viewStartDate,unitScale,1); - var nextX:number = (nextDateOffset / this.scale); - var n=0; - while(x < width) { - this.ctx.fillStyle=this.color; - //mouseover - if(this.mouseX> x && this.mouseX yOffset && this.mouseY <( yOffset + lineHeight) && !this.leftGripMove && !this.rightGripMove && !this.rangeGripMove&& !this.viewPan) { - this.ctx.fillStyle=this.hoverBackground; - this.ctx.fillRect((x+0.5)*this.ratio,(yOffset+0.5)*this.ratio,(nextX-x)*this.ratio,lineHeight*this.ratio); - this.ctx.fillStyle=this.hoverColor; - } - - this.ctx.moveTo((x+0.5)*this.ratio,(yOffset+0.5)*this.ratio); - this.ctx.lineTo((x+0.5)*this.ratio,(yOffset+lineHeight+0.5)*this.ratio); - this.ctx.stroke(); - - if(unitTextWidth < steppedOneUnit - (2*this.padding) && x > 0) { - this.ctx.fillText(caption,(x+this.padding)*this.ratio,(yOffset+lineHeight-this.padding)*this.ratio); - } else if((unitTextWidth < (steppedOneUnit - (2*this.padding) +pixelOffset)) && (unitTextWidth < (steppedOneUnit-(2*this.padding)))) { - this.ctx.fillText(caption, (this.padding*this.ratio),(yOffset+lineHeight-this.padding)*this.ratio); - } else if(x < 0 && (unitTextWidth this.endDate.getTime() - oneUnit) { - return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds + oneUnit),this.unitScale); - } - } else if(this.rightGripMove || this.rangeGripMove) { - return this.snapToUnit(new Date(this.endDate.getTime() + offsetInMilliseconds),this.unitScale); - } - return this.endDate; - } - - getStartDate(offsetInPixels:number):Date { - let oneUnit = this.unitScales[this.unitScale]; - let offsetInMilliseconds = offsetInPixels * this.scale; - if(this.leftGripMove || this.rangeGripMove) { - return this.snapToUnit(new Date(this.startDate.getTime() + offsetInMilliseconds),this.unitScale); - } else if(this.rightGripMove) { - if(this.endDate.getTime() + offsetInMilliseconds < this.startDate.getTime() + oneUnit) { - return this.snapToUnit(new Date(this.endDate.getTime() + offsetInMilliseconds - oneUnit),this.unitScale); - } - } - return this.startDate; - } - - updateControl(event:MouseEvent|TouchEvent) { - let offsetInPixels = this.getClientX(event) - this.downX; - if(this.leftGripMove || this.rightGripMove || this.rangeGripMove) { - let startDate = this.getStartDate(offsetInPixels); - let endDate = this.getEndDate(offsetInPixels); - this.updateStyle(startDate,endDate) - this.changeDetectorRef.detectChanges(); - } else if(this.viewPan) { - let offsetInMilliseconds = offsetInPixels*this.scale; - this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds); - this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds); - this.updateStyle(this.startDate,this.endDate); - this.redraw(); - this.changeDetectorRef.detectChanges(); - this.downX=this.getClientX(event); - } - this.lastOffsetInPixels=offsetInPixels - } - - isMouseEvent(arg: any): arg is MouseEvent { - return arg.clientX !== undefined; - } - - getClientX(event:MouseEvent|TouchEvent) { - if(this.isMouseEvent(event)) { - return (event as MouseEvent).clientX; - } else { - return (event as TouchEvent).touches[0].clientX; - } - } - - handleRightGripMouseDown(event:MouseEvent) { - this.rightGripMove=true; - this.downX = this.getClientX(event); - this.popoverEnd.open(this.endCaption); - event.preventDefault(); - } - - handleRightGripMouseEnter(event:MouseEvent) { - this.mouseX=-1; - this.mouseY=-1; - this.redraw(); - if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverEnd.open(this.endCaption); - } - - handleRightGripMouseLeave(event:MouseEvent) { - if(!this.rightGripMove) this.popoverEnd.close(); - } - - handleLeftGripMouseDown(event:MouseEvent|TouchEvent) { - this.leftGripMove=true; - this.downX = this.getClientX(event); - this.popoverStart.open(this.startCaption); - event.preventDefault(); - } - - handleLeftGripMouseEnter(event:MouseEvent|TouchEvent) { - this.mouseX=-1; - this.mouseY=-1; - this.redraw(); - if(!this.rangeGripMove && !this.leftGripMove && !this.rightGripMove) this.popoverStart.open(this.startCaption); - } - - handleLeftGripMouseLeave(event:MouseEvent) { - if(!this.leftGripMove) this.popoverStart.close(); - } - - handleRangeGripMouseEnter(event:MouseEvent) { - this.mouseX=-1; - this.mouseY=-1; - this.redraw(); - } - - handleRangeGripMouseDown(event:MouseEvent|TouchEvent) { - this.rangeGripMove=true; - this.downX = this.getClientX(event); - event.preventDefault(); - } - - handleViewPanMouseDown(event:MouseEvent|TouchEvent) { - this.viewPan=true; - this.downX =this.getClientX(event); - event.preventDefault(); - } - - handleMouseUp(event:MouseEvent|TouchEvent) { - //this.updateControl(event); - this.startDate = this.getStartDate(this.lastOffsetInPixels); - this.endDate = this.getEndDate(this.lastOffsetInPixels); - this.popoverStart.close(); - this.popoverEnd.close(); - this.startCaption={popoverCaption:this.getStartCaption(this.startDate,this.unitScale,true)}; - this.endCaption={popoverCaption:this.getEndCaption(this.endDate,this.unitScale,true)}; - if(this.leftGripMove || this.rightGripMove || this.rangeGripMove) { - this.change.emit({ startDate:this.startDate,endDate:this.endDate}); - } - this.rightGripMove=false; - this.leftGripMove=false; - this.rangeGripMove=false; - this.viewPan = false; - this.lastOffsetInPixels=0; - } - - handleMouseMove(event:MouseEvent) { - this.mouseX = -1; - this.mouseY = -1; - if(!this.leftGripMove && ! this.rightGripMove && !this.rangeGripMove && !this.viewPan) { - return; - } else { - this.updateControl(event); - } - } - - handleCanvasMouseMove(event:MouseEvent) { - this.mouseX = event.offsetX; - this.mouseY = event.offsetY; - this.redraw(); - } - - handleCanvasMouseLeave(event:MouseEvent) { - this.mouseX = -1; - this.mouseY = -1; - this.redraw(); - } - - canZoom(currentScale:number, direction:number):boolean { - let nextScale=currentScale; - if(direction<0 ) { - return true; - } else { - nextScale*=1.1; - let canZoom=false; - let oneUnit = (this.getUnitDateOffset(this.viewMinDate,8,1)- this.getUnitDateOffset(this.viewMinDate,8,0)) / nextScale; - let unitTextWidth=this.getUnitTextWidth(8); - let steps=this.getSteps(8); - let s=0; - let step=steps[s]; - let steppedOneUnit=oneUnit*step; - while(unitTextWidth > (steppedOneUnit-(2*this.padding)) && s < steps.length -1) { - step=steps[++s]; - steppedOneUnit=oneUnit*step; - } - return unitTextWidth < (steppedOneUnit-(2*this.padding)) && s < steps.length; - } - } - - handleMouseWheel(event:WheelEvent) { - if(!this.canZoom(this.scale,event.deltaY)) return; - let oldOffsetInMilliseconds = event.clientX * this.scale; - if(event.deltaY>=0) - this.scale*=1.1; - else - this.scale/=1.1; - this.posibleUnits=this.getPosibleUnits(this.scale); - this.height=this.getHeight(); - this.changeDetectorRef.detectChanges(); - this.setCanvasSize(); - let newOffsetInMilliseconds = event.clientX * this.scale; - let offsetInMilliseconds = newOffsetInMilliseconds-oldOffsetInMilliseconds; - this.viewMinDate = new Date(this.viewMinDate.getTime()-offsetInMilliseconds); - this.viewMaxDate = new Date(this.viewMaxDate.getTime()-offsetInMilliseconds); - this.updateStyle(this.startDate,this.endDate); - this.redraw(); - this.changeDetectorRef.detectChanges(); - } - - handleZoomOut() { - if(!this.canZoom(this.scale,1)) return; - this.scale*=1.1; - this.posibleUnits=this.getPosibleUnits(this.scale); - this.height=this.getHeight(); - this.setCanvasSize(); - this.redraw(); - this.updateStyle(this.startDate,this.endDate); - } - - handleZoomIn() { - if(!this.canZoom(this.scale,-1)) return; - this.scale/=1.1; - this.posibleUnits=this.getPosibleUnits(this.scale); - this.height=this.getHeight(); - this.setCanvasSize(); - this.redraw(); - this.updateStyle(this.startDate,this.endDate); - } - - handleResize(event:any) { - if(this.initialized) { - this.setCanvasSize(); - this.updateStyle(this.startDate,this.endDate); - this.redraw(); - } - } - - ngOnChanges (changes: SimpleChanges) { - if(this.initialized) { - this.setCanvasSize(); - this.updateStyle(this.startDate,this.endDate); - this.redraw(); - } - } -} diff --git a/projects/common/src/fm/effects/app-common.effects.ts b/projects/common/src/fm/effects/app-common.effects.ts deleted file mode 100644 index 63e2bd2..0000000 --- a/projects/common/src/fm/effects/app-common.effects.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Router } from '@angular/router'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { Store, Action } from '@ngrx/store'; -import { Effect, Actions,ofType } from '@ngrx/effects'; -import { Observable , defer , of } from 'rxjs'; -import { withLatestFrom,mergeMap,switchMap,map,catchError} from 'rxjs/operators'; -import * as appCommonActions from '../actions/app-common.actions'; -import * as appCommonReducers from '../reducers/app-common.reducer'; -import { ItemService } from '../services/item.service'; -import { FolderService } from '../services/folder.service'; -import { UserService } from '../services/user.service'; -import { IItemTypes } from '../models/item.types'; -import { IListItem } from '../models/list.item'; -import { IUser } from '../models/user'; -import {IQueryState} from '../models/query.state'; -import {StateSerializerService} from '../services/state-serializer.service'; - -@Injectable() -export class AppCommonEffects { - - @Effect({ dispatch: false }) - login$: Observable = this.actions$.pipe( - ofType(appCommonActions.LOGIN), - withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)), - mergeMap(([action, initialized]) => { - var a = (action as appCommonActions.Login); - this.oauthService$.initCodeFlow(a.url); - return []; - })); - - @Effect() - loadItemTypes$: Observable = this.actions$.pipe( - ofType(appCommonActions.LOADITEMTYPES), - switchMap((action) => { - return this.itemService$.getItemTypes().pipe( - map((itemTypes: IItemTypes) => new appCommonActions.LoadItemTypesSuccess(itemTypes)), - catchError(error => of(new appCommonActions.Fail(error)))) - } - )); - - @Effect() - initUser$: Observable = this.actions$.pipe( - ofType(appCommonActions.INITUSER), - withLatestFrom(this.store$.select(appCommonReducers.selectGetInitialized)), - switchMap(([action, initialized]) => { - if(!initialized) { - return this.userService$.getCurrentUser().pipe( - map((user: IUser) => new appCommonActions.InitUserSuccess(user)), - catchError(error => of(new appCommonActions.Fail(error)))) - } else { - return []; - } - } - )); - - @Effect() - initUserPackages$:Observable = this.actions$.pipe( - ofType(appCommonActions.INITUSERSUCCESS), - switchMap((action) => { - let a = action as appCommonActions.InitUserSuccess; - return this.itemService$.getChildItemList(a.user.code+":USER_PACKAGES","vnd.farmmaps.itemtype.package").pipe( - switchMap((items) => of(new appCommonActions.InitUserPackagesSuccess(items))), - catchError(error => of(new appCommonActions.Fail(error))) - ) - }) - ); - - @Effect() - initUserSuccess$: Observable = this.actions$.pipe( - ofType(appCommonActions.INITUSERSUCCESS), - switchMap(() => { - return of(new appCommonActions.InitRoot()); - } - )); - - @Effect() - initRoot$: Observable = this.actions$.pipe( - ofType(appCommonActions.INITROOT), - switchMap(() => { - return this.folderService$.getMyRoots().pipe( - map((folders: IListItem[]) => new appCommonActions.InitRootSuccess(folders)), - catchError(error => of(new appCommonActions.Fail(error)))) - } - )); - - @Effect() - deleteItems$: Observable = this.actions$.pipe( - ofType(appCommonActions.DELETEITEMS), - switchMap((action:appCommonActions.DeleteItems) => { - return this.itemService$.deleteItems(action.itemCodes).pipe( - map((deletedItemCodes: string[]) => new appCommonActions.DeleteItemsSuccess(deletedItemCodes)), - catchError(error => of(new appCommonActions.Fail(error)))) - } - )); - - @Effect() - editItem$: Observable = this.actions$.pipe( - ofType(appCommonActions.EDITITEM), - withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)), - switchMap(([action, itemtypes]) => { - var a = action as appCommonActions.EditItem; - var itemType = itemtypes[a.item.itemType]; - var editor = itemType.editor ? itemType.editor : "property"; - this.router$.navigate(['/editor',editor,'item', a.item.code]) - return []; - } - )); - - @Effect() - viewItem$: Observable = this.actions$.pipe( - ofType(appCommonActions.VIEWITEM), - withLatestFrom(this.store$.select(appCommonReducers.selectGetItemTypes)), - switchMap(([action, itemtypes]) => { - var a = action as appCommonActions.EditItem; - var itemType = itemtypes[a.item.itemType]; - var viewer = itemType.viewer; - var editor = itemType.editor; - if(viewer == 'select_as_mapitem') { - let queryState = { - itemCode: a.item.code, - parentCode: null, - level: 1, - itemType: null, - bboxFilter: false, - query: null, - tags: null, - endDate: null, - startDate: null, - bbox: [] - }; - let query = this.stateSerializerService$.serialize(queryState); - this.router$.navigate(['/map', query ]) - }else if(viewer == 'edit_in_editor') { - this.router$.navigate(['/editor', editor, 'item', a.item.code]) - } else { - this.router$.navigate(['/viewer', viewer, 'item', a.item.code]) - } - return []; - } - )); - - - @Effect({ dispatch: false }) - fail$: Observable = this.actions$.pipe( - ofType(appCommonActions.FAIL), - map((action) => { - let failAction = action as appCommonActions.Fail; - console.debug(failAction.payload) - return null; - })); - - constructor(private actions$: Actions, private store$: Store, private oauthService$: OAuthService, private itemService$: ItemService, private folderService$:FolderService, private userService$: UserService, private router$: Router, private stateSerializerService$:StateSerializerService) { - store$.dispatch(new appCommonActions.LoadItemTypes()); - } -} diff --git a/projects/common/src/fm/enumerations/alert.enum.ts b/projects/common/src/fm/enumerations/alert.enum.ts deleted file mode 100644 index 394efd0..0000000 --- a/projects/common/src/fm/enumerations/alert.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum Alert { - Danger = "danger", - Warning = "warning", - Success = "success" - } \ No newline at end of file diff --git a/projects/common/src/fm/models/code.list.item.ts b/projects/common/src/fm/models/code.list.item.ts deleted file mode 100644 index 7c315f5..0000000 --- a/projects/common/src/fm/models/code.list.item.ts +++ /dev/null @@ -1,28 +0,0 @@ -export interface ICodeListItem { - codeList: string; - code: string; - codeGroup?: string; - unit?: string; - description?: string; - validFrom?: Date; - validTo?: Date; - created?: Date; - updated?: Date; - data?:any -} - -export class CodeListItem implements ICodeListItem { - public codeList: string; - public code: string; - public codeGroup?: string; - public unit?: string; - public description:string; - public validFrom?: Date; - public validTo?: Date; - public created?: Date; - public updated?: Date; - public data?:any; - - constructor() { - } -} diff --git a/projects/common/src/fm/models/event.message.ts b/projects/common/src/fm/models/event.message.ts deleted file mode 100644 index ce61261..0000000 --- a/projects/common/src/fm/models/event.message.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface IEventMessage { - eventType: string; - parentCode: string; - itemCode: string; - attributes: any; -} diff --git a/projects/common/src/fm/models/item.ts b/projects/common/src/fm/models/item.ts deleted file mode 100644 index acb3c4d..0000000 --- a/projects/common/src/fm/models/item.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { IListItem } from './list.item'; - -export interface IItem extends IListItem { - parentCode?: string; - geometry?: any; - tags:string[], - data?:any - isEditable?:boolean; -} - -export class Item implements IItem { - public code?:string; - public parentCode?:string; - public tags:string[]; - public geometry?:any; - public url?: string; - public name?: string; - public created?: Date; - public updated?: Date; - public dataDate?: Date; - public itemType?: string; - public sourceTask?: string; - public size?: number; - public state?: number; - public data?:any; - public isEditable?:boolean; - - constructor() { - } -} diff --git a/projects/common/src/fm/models/item.type.ts b/projects/common/src/fm/models/item.type.ts deleted file mode 100644 index 4c19e57..0000000 --- a/projects/common/src/fm/models/item.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface IItemType { - icon?: string; - viewer?: string; - editor?: string; - isFolder?: boolean; - iconColor?: string; - extraAttributes?: string; -} diff --git a/projects/common/src/fm/models/item.types.ts b/projects/common/src/fm/models/item.types.ts deleted file mode 100644 index 594a985..0000000 --- a/projects/common/src/fm/models/item.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { IItemType } from './item.type'; - -export interface IItemTypes{ - [id: string]: IItemType; -}; diff --git a/projects/common/src/fm/models/itemTask.ts b/projects/common/src/fm/models/itemTask.ts deleted file mode 100644 index acc0915..0000000 --- a/projects/common/src/fm/models/itemTask.ts +++ /dev/null @@ -1,23 +0,0 @@ - -export interface IItemTask { - code?: string; - taskType?: string; - attributes?: any; - message?: string, - state?: number, - started?: Date, - finished?: Date -} - -export class ItemTask implements IItemTask { - public code?:string; - public taskType?: string; - public attributes?: any; - public message?: string; - public state?: number; - public started?: Date; - public finished?: Date; - - constructor() { - } -} \ No newline at end of file diff --git a/projects/common/src/fm/models/list.item.ts b/projects/common/src/fm/models/list.item.ts deleted file mode 100644 index fe39561..0000000 --- a/projects/common/src/fm/models/list.item.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface IListItem { - url?: string; - code?: string; - name?: string; - created?: Date; - updated?: Date; - dataDate?: Date; - itemType?: string; - sourceTask?: string; - size?: number; - state?: number; - thumbnail?: boolean; -} diff --git a/projects/common/src/fm/models/package.ts b/projects/common/src/fm/models/package.ts deleted file mode 100644 index 921953b..0000000 --- a/projects/common/src/fm/models/package.ts +++ /dev/null @@ -1,9 +0,0 @@ -export interface IPackage { - id:string - name:string; - enabled?:boolean; -} - -export interface IPackages { - [id: string]: IPackage; -} \ No newline at end of file diff --git a/projects/common/src/fm/models/query.state.ts b/projects/common/src/fm/models/query.state.ts deleted file mode 100644 index ea76fda..0000000 --- a/projects/common/src/fm/models/query.state.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface IQueryState { - itemCode: string; - parentCode: string; - level: number; - itemType: string; - query: string; - tags: string; - bboxFilter: boolean; - startDate: Date; - endDate: Date; - bbox: number[]; -} diff --git a/projects/common/src/fm/models/typeahead.item.ts b/projects/common/src/fm/models/typeahead.item.ts deleted file mode 100644 index 63e0a1f..0000000 --- a/projects/common/src/fm/models/typeahead.item.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ITypeaheadItem { - name: string; - type: string; -} diff --git a/projects/common/src/fm/models/user.ts b/projects/common/src/fm/models/user.ts deleted file mode 100644 index 80e6efe..0000000 --- a/projects/common/src/fm/models/user.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface IUser { - code?: string; - name?: string; - email?: string; -} diff --git a/projects/common/src/fm/models/weatherCurrentObservation.ts b/projects/common/src/fm/models/weatherCurrentObservation.ts deleted file mode 100644 index fd26d9c..0000000 --- a/projects/common/src/fm/models/weatherCurrentObservation.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface WeatherCurrentObservation { - wspd: number; - obs_time_local: number; - decimal_temp: number; - rh: number; - precip_1hour: number; - precip_6hour: number; - precip_24hour: number; - uv_index: number; - icon_code: number; - wdir_cardinal: string; - wdir: number; -} diff --git a/projects/common/src/fm/module-name.ts b/projects/common/src/fm/module-name.ts deleted file mode 100644 index 48e6151..0000000 --- a/projects/common/src/fm/module-name.ts +++ /dev/null @@ -1 +0,0 @@ -export const MODULE_NAME = "FarmMapsCommon"; diff --git a/projects/common/src/fm/reducers/app-common.reducer.ts b/projects/common/src/fm/reducers/app-common.reducer.ts deleted file mode 100644 index ec74a38..0000000 --- a/projects/common/src/fm/reducers/app-common.reducer.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { tassign } from 'tassign'; -import { IItemTypes} from '../models/item.types'; -import { IListItem } from '../models/list.item'; -import { IUser } from '../models/user'; -import { IPackage,IPackages} from '../models/package'; -import * as appCommonActions from '../actions/app-common.actions'; -import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/store'; - -import { MODULE_NAME } from '../module-name'; - -export interface State { - openedModalName: string, - initialized: boolean, - rootItems: IListItem[], - itemTypes: IItemTypes, - user:IUser, - fullScreen: boolean, - routeLoading:boolean, - menuVisible: boolean, - userPackages: IPackages -} - -export const initialState: State = { - openedModalName: null, - initialized: false, - rootItems: [], - itemTypes: {}, - user:null, - fullScreen: true, - routeLoading: false, - menuVisible: false, - userPackages: {} -} - -export function reducer(state = initialState, action: appCommonActions.Actions ): State { - switch (action.type) { - case appCommonActions.INITUSERSUCCESS: { - let a = action as appCommonActions.InitUserSuccess; - return tassign(state, { user: a.user,initialized: true }); - } - case appCommonActions.INITROOTSUCCESS: { - let a = action as appCommonActions.InitRootSuccess; - return tassign(state, { rootItems:a.items}); - } - case appCommonActions.OPENMODAL: { - return tassign(state, { openedModalName: action.modalName }); - } - case appCommonActions.CLOSEMODAL: { - return tassign(state, { openedModalName: null }); - } - case appCommonActions.LOADITEMTYPESSUCCESS: { - let a = action as appCommonActions.LoadItemTypesSuccess; - return tassign(state, { itemTypes: a.itemTypes }); - } - case appCommonActions.FULLSCREEN: { - return tassign(state, { - fullScreen:true - }); - } - case appCommonActions.SHOWNAVBAR: { - return tassign(state, { - fullScreen: false - }); - } - case appCommonActions.STARTROUTELOADING: { - return tassign(state, { - routeLoading: true - }); - } - case appCommonActions.ENDROUTELOADING: { - return tassign(state, { - routeLoading: false - }); - } - case appCommonActions.TOGGLEMENU: { - return tassign(state, { menuVisible: !state.menuVisible }); - } - case appCommonActions.ESCAPE: { - return tassign(state, { menuVisible: false }); - } - case appCommonActions.SETMENUVISIBLE: { - let a = action as appCommonActions.SetMenuVisible; - return tassign(state, { menuVisible: a.visible }); - } - case appCommonActions.INITUSERPACKAGESSUCCESS:{ - let a = action as appCommonActions.InitUserPackagesSuccess; - let packages = {} - a.items.forEach((item) => { - packages[item.data.id]=item.data; - }); - - return tassign(state,{userPackages:packages}); - } - default: { - return state; - } - } -} - -export const getOpenedModalName = (state: State) => state.openedModalName; -export const getInitialized = (state: State) => state.initialized; -export const getItemTypes = (state: State) => state.itemTypes; -export const getRootItems = (state: State) => state.rootItems; -export const getFullScreen = (state: State) => state.fullScreen; -export const getRouteLoading = (state: State) => state.routeLoading; -export const getMenuVisible = (state: State) => state.menuVisible; -export const getUser = (state: State) => state.user; -export const getUserPackages = (state: State) => state.userPackages; - -export const selectAppCommonState = createFeatureSelector(MODULE_NAME); - -export const selectOpenedModalName = createSelector(selectAppCommonState, getOpenedModalName); -export const selectGetInitialized = createSelector(selectAppCommonState, getInitialized); -export const selectGetItemTypes = createSelector(selectAppCommonState, getItemTypes); -export const selectGetRootItems = createSelector(selectAppCommonState, getRootItems); -export const selectGetFullScreen = createSelector(selectAppCommonState, getFullScreen); -export const selectGetRouteLoading = createSelector(selectAppCommonState, getRouteLoading); -export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuVisible); -export const SelectGetUser = createSelector(selectAppCommonState,getUser); -export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages); - diff --git a/projects/common/src/fm/services/auth-guard.service.ts b/projects/common/src/fm/services/auth-guard.service.ts deleted file mode 100644 index ccf160b..0000000 --- a/projects/common/src/fm/services/auth-guard.service.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { Injectable } from '@angular/core'; -import { - CanActivate, Router, CanLoad, Route, CanActivateChild , - ActivatedRouteSnapshot, - RouterStateSnapshot -} from '@angular/router'; - - -import { Store } from '@ngrx/store'; -import { OAuthService } from 'angular-oauth2-oidc'; - - -import * as appCommonReducer from '../reducers/app-common.reducer' -import * as appCommonActions from '../actions/app-common.actions'; - - -@Injectable({ - providedIn: 'root', -}) -export class AuthGuard implements CanActivate, CanLoad, CanActivateChild { - - constructor(private oauthService: OAuthService, private router: Router, private store: Store ) { } - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { - let url: string = state.url; - - return this.checkLogin(url); - } - - canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { - let url: string = state.url; - - return this.checkLogin(url); - } - - canLoad(route: Route): Promise { - return this.checkLogin(route.path); - } - - checkLogin(url: string): Promise { - return new Promise((resolve) => { - if (!this.oauthService.hasValidAccessToken()) { - console.debug("No valid token"); - if(this.oauthService.getRefreshToken() != null ) { - console.debug("We have a refresh token"); - this.oauthService.refreshToken().then(() => { - this.store.dispatch(new appCommonActions.InitUser()); - resolve(true); - }).catch(() => { - console.debug("Error refreshing"); - this.oauthService.initCodeFlow(url); - resolve(false); - }) - } else { - console.debug("No refresh token"); - this.oauthService.initCodeFlow(url); - resolve(false); - } - } else { - console.debug("Valid token init user"); - this.store.dispatch(new appCommonActions.InitUser()); - resolve(true); - } - }); - } -} diff --git a/projects/common/src/fm/services/codelistitem.service.ts b/projects/common/src/fm/services/codelistitem.service.ts deleted file mode 100644 index f47ac45..0000000 --- a/projects/common/src/fm/services/codelistitem.service.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { HttpClient, HttpParams } from "@angular/common/http"; -import { AppConfig } from "../shared/app.config"; -import { ICodeListItem } from '../models/code.list.item'; - -@Injectable({ - providedIn: 'root', -}) -export class CodeListItemService { - constructor(public httpClient: HttpClient, public appConfig: AppConfig) { - } - - ApiEndpoint() { - return this.appConfig.getConfig("apiEndPoint"); - } - - getCodeListItems(codelist: string[]): Observable { - var params = new HttpParams(); - for (const cl of codelist) { - params = params.append('cl', cl); - } - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/codelistitems/`, { params: params }); - } -} diff --git a/projects/common/src/fm/services/date-adapter.service.ts b/projects/common/src/fm/services/date-adapter.service.ts deleted file mode 100644 index fea6b8a..0000000 --- a/projects/common/src/fm/services/date-adapter.service.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component, Injectable } from '@angular/core'; -import { NgbDateAdapter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'; - -@Injectable({ - providedIn: 'root', -}) -export class NgbDateNativeAdapter extends NgbDateAdapter { - - fromModel(date: Date): NgbDateStruct { - return (date && date.getFullYear) ? {year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()} : null; - } - - toModel(date: NgbDateStruct): Date { - return date ? new Date(Date.UTC(date.year, date.month - 1, date.day)) : null; - } -} diff --git a/projects/common/src/fm/services/event.service.ts b/projects/common/src/fm/services/event.service.ts deleted file mode 100644 index d71e489..0000000 --- a/projects/common/src/fm/services/event.service.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Injectable } from '@angular/core'; -import { IEventMessage } from '../models/event.message'; -import { Subject, timer } from 'rxjs'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType,HubConnectionState} from '@microsoft/signalr'; -import { AppConfig } from "../shared/app.config"; - - -@Injectable({ - providedIn: 'root', -}) -export class EventService { - - public event:Subject = new Subject(); - private _connection: HubConnection = null; - private _apiEndPoint: string; - public authenticated:boolean = false; - - constructor(private oauthService: OAuthService, private appConfig: AppConfig) { - this._apiEndPoint = appConfig.getConfig("apiEndPoint"); - this._connection = new HubConnectionBuilder().withUrl(`${ this._apiEndPoint}/eventHub`, - { transport: HttpTransportType.WebSockets, - // accessTokenFactory: () => { - // return oauthService.getAccessToken(); - // }, - skipNegotiation:true - }).withAutomaticReconnect().configureLogging(LogLevel.Information).build(); - this._connection.on('event', eventMessage => { - this.event.next(eventMessage); - }); - this._connection.onreconnected( event => { - this.Authenticate(); - }); - this.Start(); - } - - Start() { - if(this._connection&&!(this._connection.state === HubConnectionState.Connected || this._connection.state === HubConnectionState.Connecting)) - this._connection.start().then(() => { - this.Authenticate(); - }); - } - - private Authenticate() { - var accessToken = this.oauthService.getAccessToken(); - if (accessToken) { - this._connection.send('authenticate', this.oauthService.getAccessToken()); - this.authenticated=true; - } else { - //try again after half a second - setTimeout(() => { - this.Authenticate(); - }, 800); - } - } - - Stop() { - if(this._connection&&(this._connection.state === HubConnectionState.Connected || this._connection.state === HubConnectionState.Connecting)) { - this._connection.stop(); - } - } -} diff --git a/projects/common/src/fm/services/folder.service.ts b/projects/common/src/fm/services/folder.service.ts deleted file mode 100644 index 5ac8740..0000000 --- a/projects/common/src/fm/services/folder.service.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable , Observer } from 'rxjs'; -import {map} from 'rxjs/operators'; -import { IListItem } from '../models/list.item'; -import { IItem } from '../models/item'; -import { HttpClient } from "@angular/common/http"; -import { AppConfig } from "../shared/app.config"; - -@Injectable({ - providedIn: 'root', -}) -export class FolderService { - - constructor(public httpClient: HttpClient, public appConfig: AppConfig) { - } - - ApiEndpoint() { - return this.appConfig.getConfig("apiEndPoint"); - } - - parseDates(item: any): IListItem { - item.created = new Date(Date.parse(item.created)); - item.updated = new Date(Date.parse(item.updated)); - item.dataDate = new Date(Date.parse(item.dataDate)); - return item; - } - - getFolder(code: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}`).pipe(map(i => this.parseDates(i))); - } - - getMyRoots(): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/my_roots`).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getFolderParents(code: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/parents`).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getChildFolders(code: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/listfolders`).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getItems(code: string,skip:number, take:number): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/folders/${code}/list?skip=${skip}&take=${take}`).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - moveItem(itemCode: string, newParentCode: string): Observable { - const body = { itemCode: itemCode,newParentCode: newParentCode }; - return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/move`, body).pipe(map(i => this.parseDates(i))); - } - - createFolder(folder: IItem): Observable { - return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/folders/`, folder).pipe(map(i => this.parseDates(i))); - } -} diff --git a/projects/common/src/fm/services/full-screen-guard.service.ts b/projects/common/src/fm/services/full-screen-guard.service.ts deleted file mode 100644 index 9238eb4..0000000 --- a/projects/common/src/fm/services/full-screen-guard.service.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Injectable } from '@angular/core'; -import { CanActivate, CanActivateChild, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; - -import { Store } from '@ngrx/store'; - -import * as appCommonReducer from '../reducers/app-common.reducer' -import * as appCommonActions from '../actions/app-common.actions'; - - -@Injectable({ - providedIn: 'root', -}) -export class FullScreenGuard implements CanActivate,CanActivateChild { - - private loginDispatched = false; - constructor(private store: Store ) { } - - setFullScreen():boolean { - this.store.dispatch(new appCommonActions.FullScreen()); - return true; - } - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - return this.setFullScreen(); - } - - canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - return this.setFullScreen(); - } -} diff --git a/projects/common/src/fm/services/item.service.ts b/projects/common/src/fm/services/item.service.ts deleted file mode 100644 index 8d1185c..0000000 --- a/projects/common/src/fm/services/item.service.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { IItemType } from '../models/item.type'; -import { IItem } from '../models/item'; -import { IItemTask } from '../models/itemTask'; -import { HttpClient, HttpParams } from "@angular/common/http"; -import { AppConfig } from "../shared/app.config"; -import {ItemTypeService} from './itemtype.service'; - -@Injectable({ - providedIn: 'root', -}) -export class ItemService { - constructor(public httpClient: HttpClient, public appConfig: AppConfig,private itemTypeService:ItemTypeService) { - } - - ApiEndpoint() { - return this.appConfig.getConfig("apiEndPoint"); - } - - parseDates(item: any): IItem { - item.created = new Date(Date.parse(item.created)); - item.updated = new Date(Date.parse(item.updated)); - item.dataDate = new Date(Date.parse(item.dataDate)); - return item; - } - - getItemTypes(): Observable<{ [id: string]: IItemType }> { - return this.httpClient.get<{ [id: string]: IItemType }>(`${this.ApiEndpoint()}/api/v1/itemtypes/`); - } - - getFeatures(extent: number[], crs: string, searchText?: string, searchTags?:string,startDate?:Date,endDate?:Date,itemType?:string,parentCode?:string,dataFilter?:string,level?:number): Observable { - var params = new HttpParams(); - params = params.append("bbox", extent.join(",")); - params = params.append("crs", crs); - if (searchText) params = params.append("q", searchText); - if (searchTags) params = params.append("t", searchTags); - if (startDate) params = params.append("sd", startDate.toISOString()); - if (endDate) params = params.append("ed", endDate.toISOString()); - if (itemType) { - params = params.append("it", itemType); - let extraAttributes = this.itemTypeService.getExtraAttributes(itemType); - if(extraAttributes) { - params = params.append("da", extraAttributes); - } - } - if (parentCode) params = params.append("pc", parentCode); - if (dataFilter) params = params.append("df", dataFilter); - if (level) params = params.append("lvl", dataFilter); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/features/`, {params:params}); - } - - getFeature(code:string, crs: string): Observable { - var params = new HttpParams(); - params = params.append("crs", crs); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/feature/`, { params: params }); - } - - getItem(code: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}`).pipe(map(i => this.parseDates(i))); - } - - getItemByCodeAndType(code: string, itemType: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/${itemType}`); - } - - getItemList(itemType: string, dataFilter?: any, level: number = 1): Observable { - var params = new HttpParams(); - params = params.append("it", itemType); - if(dataFilter != null){ - params = params.append("df", JSON.stringify(dataFilter)); - } - params = params.append("lvl", itemType); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getChildItemList(parentcode: string, itemType: string, dataFilter?: any, level: number = 1, deep: boolean = true): Observable { - var params = new HttpParams(); - if(itemType != null) { - params = params.append("it", itemType); - } - if (dataFilter != null) { - params = params.append("df", JSON.stringify(dataFilter)); - } - params = params.append("lvl", level.toString()); - params = params.append("deep", deep.toString()); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getChildItemListCount(parentcode: string, itemType: string): Observable { - var params = new HttpParams(); - params = params.append("it", itemType); - return this.httpClient.get(`${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 { - var params = new HttpParams(); - params = params.append("it", itemType); - params = params.append("bbox", extent.join(",")); - params = params.append("crs", crs); - if (dataFilter != null) { - params = params.append("df", JSON.stringify(dataFilter)); - } - params = params.append("lvl", level.toString()); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${parentcode}/children`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } - - getItemFeatures(code: string, extent: number[], crs: string, layerIndex?:number): Observable { - var params = new HttpParams(); - params = params.append("crs", crs); - if(extent != null) { - params = params.append("bbox", extent.join(",")); - } - if(layerIndex!=null) - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/features/layer/${layerIndex}`, { params: params }); - else - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/features`, { params: params }); - } - - postItem(item:IItem): Observable { - return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items`,item); - } - - putItem(item:IItem): Observable { - return this.httpClient.put(`${this.ApiEndpoint()}/api/v1/items/${item.code}`,item); - } - - deleteItem(code: string): Observable { - return this.httpClient.delete(`${this.ApiEndpoint()}/api/v1/items/${code}`); - } - - deleteItems(itemCodes:string[]): Observable { - return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/delete`, itemCodes); - } - - getTemporalLast(code: string): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/last`); - } - - getTemporal(code: string, startDate?: Date, endDate?: Date): Observable { - var params = new HttpParams(); - if (startDate) params = params.append("sd", startDate.toISOString()); - if (endDate) params = params.append("ed", endDate.toISOString()); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${code}/temporal/`, { params: params }); - } - - postItemTask(item: IItem, task: IItemTask): Observable { - return this.httpClient.post(`${this.ApiEndpoint()}/api/v1/items/${item.code}/tasks`, task); - } - - getItemTaskList(itemcode: string, unfinishedOnly?: boolean): Observable { - var params = new HttpParams(); - if (unfinishedOnly) params = params.append("unfinishedOnly", unfinishedOnly.toString()); - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/items/${itemcode}/tasks`, { params: params }).pipe(map(ia => ia.map(i => this.parseDates(i)))); - } -} \ No newline at end of file diff --git a/projects/common/src/fm/services/itemtype.service.ts b/projects/common/src/fm/services/itemtype.service.ts deleted file mode 100644 index f81f1ad..0000000 --- a/projects/common/src/fm/services/itemtype.service.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Injectable } from '@angular/core'; -import {IItemTypes} from '../models/item.types' -import {IItem} from '../models/item' -import {AppConfig} from '../shared/app.config'; -import {HttpClient, HttpXhrBackend} from '@angular/common/http'; - -@Injectable() -export class ItemTypeService { - public itemTypes: IItemTypes; - private httpClient: HttpClient; - - constructor(xhrBackend: HttpXhrBackend) { - this.httpClient = new HttpClient(xhrBackend); - } - - getIcon(itemType: string) { - var icon = "fa fa-file-o"; - if (this.itemTypes[itemType]) icon = this.itemTypes[itemType].icon; - return icon; - } - - getColor(itemType: string) { - var color = "#000000"; - if (this.itemTypes[itemType]) color = this.itemTypes[itemType].iconColor; - return color; - } - - getExtraAttributes(itemType: string) { - var extraAttributes = null; - if (this.itemTypes[itemType]) extraAttributes = this.itemTypes[itemType].extraAttributes; - return extraAttributes; - } - - hasViewer(item: IItem) { - let itemType: string = item.itemType; - if (this.itemTypes[itemType]) return this.itemTypes[itemType].viewer !== undefined; - return false; - } - - hasEditor(item: IItem) { - let itemType: string = item.itemType; - if (this.itemTypes[itemType]) return this.itemTypes[itemType].editor !== undefined; - return false; - } - - isLayer(item: IItem) { - let itemType: string = item.itemType; - return itemType == "vnd.farmmaps.itemtype.geotiff.processed" || itemType == "vnd.farmmaps.itemtype.layer" || itemType == "vnd.farmmaps.itemtype.shape.processed"; - } - - public load(config:AppConfig): Promise { - - var url = `${ config.getConfig("apiEndPoint")}/api/v1/itemtypes/` - return this.httpClient.get(url) - .toPromise() - .then((itemTypes:IItemTypes) => { - this.itemTypes = itemTypes; - //return data; - }) - .catch(error => this.itemTypes = null); - }; -} \ No newline at end of file diff --git a/projects/common/src/fm/services/nav-bar-guard.service.ts b/projects/common/src/fm/services/nav-bar-guard.service.ts deleted file mode 100644 index be6b91e..0000000 --- a/projects/common/src/fm/services/nav-bar-guard.service.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Injectable } from '@angular/core'; -import { CanLoad, Route, CanActivate, CanDeactivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; - -import { Store } from '@ngrx/store'; - -import * as appCommonReducer from '../reducers/app-common.reducer' -import * as appCommonActions from '../actions/app-common.actions'; - - -@Injectable({ - providedIn: 'root', -}) -export class NavBarGuard implements CanActivate { - - private loginDispatched = false; - constructor(private store: Store) { } - - setNavBar():boolean { - this.store.dispatch(new appCommonActions.ShowNavBar()); - return true; - } - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - return this.setNavBar(); - } - - canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { - return this.setNavBar(); - } -} diff --git a/projects/common/src/fm/services/package.service.ts b/projects/common/src/fm/services/package.service.ts deleted file mode 100644 index b5b1257..0000000 --- a/projects/common/src/fm/services/package.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Store} from '@ngrx/store'; -import * as appCommonReducer from '../reducers/app-common.reducer' -import { IPackages } from '../models/package'; - - -@Injectable({ - providedIn: 'root', -}) - -export class PackageService { - private packages$:IPackages = {}; - - constructor(private store$: Store) { - store$.select(appCommonReducer.SelectGetUserPackages).subscribe((packages) => { - this.packages$ = packages; - }) - } - - hasPackage(id:string):boolean { - if(!this.packages$[id]) return false; - return this.packages$[id].enabled == true; - } -} \ No newline at end of file diff --git a/projects/common/src/fm/services/state-serializer.service.ts b/projects/common/src/fm/services/state-serializer.service.ts deleted file mode 100644 index f4d8195..0000000 --- a/projects/common/src/fm/services/state-serializer.service.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Injectable, Query } from '@angular/core'; -import { IQueryState } from '../models/query.state'; - -@Injectable({ - providedIn: 'root', -}) -export class StateSerializerService { - - serialize(queryState: IQueryState): string { - - var state = ""; - state += (queryState.itemCode) ? queryState.itemCode : ""; - state += ";"; - state += (queryState.parentCode) ? queryState.parentCode + ";" + queryState.level.toString() : ";"; - state += ";"; - state += (queryState.itemType) ? queryState.itemType : ""; - state += ";"; - state += (queryState.query) ? encodeURIComponent( queryState.query ) : ""; - state += ";"; - state += (queryState.tags) ? encodeURIComponent( queryState.tags ) : ""; - state += ";"; - state += (queryState.bboxFilter) ? "1" : "0"; - state += ";"; - state += (queryState.startDate) ? JSON.stringify(queryState.startDate) : ""; - state += ";"; - state += (queryState.endDate) ? JSON.stringify(queryState.endDate) : ""; - state += ";"; - state += (queryState.bboxFilter && queryState.bbox && queryState.bbox.length>0) ? JSON.stringify(queryState.bbox) : ""; - - return btoa(state); - } - - deserialize(queryState: string): IQueryState { - var state: IQueryState = { itemCode: null, parentCode: null, level: 1, itemType: null, query: null, tags: null, bboxFilter: false, startDate: null, endDate: null,bbox:[] }; - var stateParts = atob(queryState).split(";"); - if (stateParts.length == 10) { - if (stateParts[0] != "") state.itemCode = stateParts[0]; - if (stateParts[1] != "") { - state.parentCode = stateParts[1]; - state.level = parseInt(stateParts[2]); - } - if (stateParts[3] != "") state.itemType = stateParts[3]; - if (stateParts[4] != "") state.query = decodeURIComponent(stateParts[4]); - if (stateParts[5] != "") state.tags = decodeURIComponent( stateParts[5]); - if (stateParts[6] != "") state.bboxFilter = parseInt(stateParts[6]) == 1; - if (stateParts[7] != "") state.startDate = new Date(Date.parse(JSON.parse(stateParts[7]))); - if (stateParts[8] != "") state.endDate = new Date(Date.parse(JSON.parse(stateParts[8]))); - if (stateParts[9] != "") state.bbox = JSON.parse(stateParts[9]); - } - - return state; - } -} diff --git a/projects/common/src/fm/services/timespan.service.ts b/projects/common/src/fm/services/timespan.service.ts deleted file mode 100644 index 6c7ce41..0000000 --- a/projects/common/src/fm/services/timespan.service.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { Injectable } from '@angular/core'; -import { DatePipe } from '@angular/common'; -import { Observable , Observer } from 'rxjs'; -import { ITypeaheadItem } from '../models/typeahead.item'; - -@Injectable({ - providedIn: 'root', -}) -export class TimespanService { - constructor(private datePipe: DatePipe) { - } - 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']; - quarters: string[] = ['KW1', 'KW2', 'KW3', 'KW4']; - - getStartEndCaption(date: Date, otherDate: Date, unitScale: number, suffix: boolean = false, extended: boolean = true): string { - let showSuffix = false; - otherDate = new Date(otherDate.getTime() - 1); // fix year edge case - if (unitScale == 3) { - let format = "HH:00"; - if (extended) { - if (suffix || date.getFullYear() != otherDate.getFullYear()) - format = "d MMM yyyy:HH:00"; - else if (date.getMonth() !== otherDate.getMonth()) - format = "d MMM HH:00"; - } - return this.datePipe.transform(date, format); - - } - if (unitScale == 4) { - let format = "d"; - if (extended) { - if (suffix || date.getFullYear() != otherDate.getFullYear()) - format = "d MMM yyyy"; - else if (date.getMonth() !== otherDate.getMonth()) - format = "d MMM" - } - return this.datePipe.transform(date, format); - - } - if (unitScale == 6) { - let format = "MMM"; - if (extended) { - if (suffix || date.getFullYear() != otherDate.getFullYear()) - format = "MMM yyyy"; - } - return this.datePipe.transform(date, format); - } - if (unitScale == 7) { - let q = Math.trunc(date.getMonth() / 3); - return this.quarters[q]; - } - if (unitScale == 8) { - return this.datePipe.transform(date, "yyyy"); - } - return ""; - } - - getStartCaption(startDate: Date, endDate: Date, unitScale: number, suffix: boolean = false, extended: boolean = true): string { - return this.getStartEndCaption(new Date(startDate.getTime() + (this.unitScales[unitScale] / 2)), endDate, unitScale, suffix, extended); - } - - getEndCaption(startDate: Date,endDate: Date, unitScale: number, suffix: boolean = true): string { - return this.getStartEndCaption(new Date(endDate.getTime() - (this.unitScales[unitScale] / 2)), startDate, unitScale, suffix); - } - - getCaption(startDate: Date, endDate: Date, unitScale: number): string { - let startCaption = this.getStartCaption(startDate, endDate, unitScale); - let endCaption = this.getEndCaption(startDate,endDate, unitScale); - if ((endDate.getTime() - startDate.getTime()) < (1.5 * this.unitScales[unitScale])) - return endCaption; - return `${startCaption}-${endCaption}`; - } - -} diff --git a/projects/common/src/fm/services/typeahead.service.ts b/projects/common/src/fm/services/typeahead.service.ts deleted file mode 100644 index a4e7495..0000000 --- a/projects/common/src/fm/services/typeahead.service.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable , Observer } from 'rxjs'; -import { ITypeaheadItem } from '../models/typeahead.item'; -import { HttpClient, HttpParams } from "@angular/common/http"; -import { AppConfig } from "../shared/app.config"; - -@Injectable({ - providedIn: 'root', -}) -export class TypeaheadService { - constructor(public httpClient: HttpClient, public appConfig: AppConfig) { - } - - ApiEndpoint() { - return this.appConfig.getConfig("apiEndPoint"); - } - - getSearchTypeaheadItems(searchText:string,skip:number = 0,take:number = 10): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/typeahead/search/?q=${searchText}&skip=${skip}&take=${take}`); - } - - getTagTypeaheadItems(searchText: string, skip: number = 0, take: number = 10): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/typeahead/tag/?q=${searchText}&skip=${skip}&take=${take}`); - } -} diff --git a/projects/common/src/fm/services/user.service.ts b/projects/common/src/fm/services/user.service.ts deleted file mode 100644 index fd9e668..0000000 --- a/projects/common/src/fm/services/user.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { IUser } from '../models/user'; -import { HttpClient } from "@angular/common/http"; -import { AppConfig } from "../shared/app.config"; - -@Injectable({ - providedIn: 'root', -}) -export class UserService { - constructor(public httpClient: HttpClient, public appConfig: AppConfig) { - } - - ApiEndpoint() { - return this.appConfig.getConfig("apiEndPoint"); - } - - getCurrentUser(): Observable { - return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/currentuser`); - } -} diff --git a/projects/common/src/fm/services/weather.service.ts b/projects/common/src/fm/services/weather.service.ts deleted file mode 100644 index 109ac10..0000000 --- a/projects/common/src/fm/services/weather.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {Injectable} from '@angular/core'; -import {HttpClient} from '@angular/common/http'; -import {AppConfig} from '../shared/app.config'; -import {Observable} from 'rxjs'; -import {WeatherCurrentObservation} from '../models/weatherCurrentObservation'; - -@Injectable({ - providedIn: 'root', -}) -export class WeatherService { - private apiUrl = '/api/v1/weather/currentobservation'; - - constructor(public httpClient: HttpClient, public appConfig: AppConfig) { - } - - public GetCurrentObservation(centroid: number[]): Observable { - const endpoint = this.appConfig.getConfig('weatherApiEndPoint'); - const apiKey = this.appConfig.getConfig('weatherApiKey'); - const observationUrl = `${endpoint}${this.apiUrl}/?c=${centroid[0]},${centroid[1]}&key=${apiKey}`; - - return this.httpClient.get(observationUrl); - } -} diff --git a/projects/common/src/fm/shared/accesstoken.interceptor.ts b/projects/common/src/fm/shared/accesstoken.interceptor.ts deleted file mode 100644 index 357aabf..0000000 --- a/projects/common/src/fm/shared/accesstoken.interceptor.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Injectable, Injector, Inject } from '@angular/core'; -import { DOCUMENT } from '@angular/common' -import { AppConfig } from "./app.config"; -import { - HttpRequest, - HttpHandler, - HttpEvent, - HttpInterceptor -} from '@angular/common/http'; -import { OAuthService } from 'angular-oauth2-oidc'; -import { Observable } from 'rxjs'; - -@Injectable() -export class AccessTokenInterceptor implements HttpInterceptor { - private oauthService: OAuthService = null; - private audience: string[] = []; - private base: string; - - constructor(private injector: Injector, private appConfig: AppConfig, @Inject(DOCUMENT) private document: any) { - this.base = document.location.href; - } - - hasAudience(url: string): boolean { - let u = new URL(url,this.base); - for (let audience of this.audience) { - if (u.href.startsWith(audience)) return true; - } - return false; - } - - intercept(request: HttpRequest, next: HttpHandler): Observable> { - if (this.oauthService && this.hasAudience(request.url)) { - request = request.clone({ - setHeaders: { - Authorization: `Bearer ${this.oauthService.getAccessToken()}` - } - // Please uncomment the next line if you need to connect to the backend running in Docker. - //, url: `http://localhost:8082${request.url}` - }); - } else { - this.oauthService = this.injector.get(OAuthService, null); - if(this.oauthService && this.oauthService.issuer) this.audience = (this.appConfig.getConfig("audience") as string).split(","); - } - return next.handle(request); - } -} - diff --git a/projects/common/src/fm/shared/app.config.factory.ts b/projects/common/src/fm/shared/app.config.factory.ts deleted file mode 100644 index f804b4e..0000000 --- a/projects/common/src/fm/shared/app.config.factory.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Injector } from '@angular/core'; -import { Location} from '@angular/common'; -import { Router,UrlSerializer } from '@angular/router'; -import { AuthConfig, OAuthService, OAuthErrorEvent, OAuthStorage } from 'angular-oauth2-oidc'; -import { AppConfig } from "./app.config"; -import {ItemTypeService} from '../services/itemtype.service'; -import { IAuthconfigFactory } from './authconfigFactory'; - - - -export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthService: OAuthService, authconfigFactory:IAuthconfigFactory,authStorage:OAuthStorage,itemtypeService:ItemTypeService): () => Promise { - return (): Promise => { - return new Promise((resolve,reject) => { - appConfig.load().then(() => { - oauthService.events.subscribe((event) => { - console.debug(event.type); - if (event.type == 'token_error' || event.type == 'silent_refresh_timeout') { - let e = event as OAuthErrorEvent; - let p = e.params as any; - if (event.type == 'silent_refresh_timeout' || (p.error && p.error == 'login_required')) { - let router = injector.get(Router); - console.debug("Session expired"); - router.navigate(['loggedout'], { queryParams: { redirectTo: router.url } }); - } - } - }); - oauthService.configure(authconfigFactory.getAuthConfig(appConfig)); - oauthService.setStorage(authStorage); - oauthService.setupAutomaticSilentRefresh(); - }).then(() => oauthService.loadDiscoveryDocument() - ).then(() => { - itemtypeService.load(appConfig).then(() => resolve()).catch(() => reject()); - }) - }); - } -} - diff --git a/projects/common/src/fm/shared/app.config.ts b/projects/common/src/fm/shared/app.config.ts deleted file mode 100644 index 309f955..0000000 --- a/projects/common/src/fm/shared/app.config.ts +++ /dev/null @@ -1,34 +0,0 @@ -import {Inject, Injectable} from '@angular/core'; -import { Location,PathLocationStrategy,LocationStrategy } from '@angular/common'; -import {HttpClient, HttpXhrBackend} from '@angular/common/http'; -import {Observable} from 'rxjs'; - -@Injectable() -export class AppConfig { - - private config: Object = null; - private httpClient: HttpClient; - - constructor(xhrBackend: HttpXhrBackend,private location:Location) { - this.httpClient = new HttpClient(xhrBackend); - this.config = null; - } - - public getConfig(key: any) { - if (!this.config.hasOwnProperty(key)) { - console.error(`Config key ${key} not set`); - } - return this.config[key]; - } - - public load(): Promise { - var url = this.location.prepareExternalUrl('/configuration.json'); - return this.httpClient.get(url) - .toPromise() - .then(data => { - this.config = data; - //return data; - }) - .catch(error => this.config = null); - }; -} diff --git a/projects/common/src/fm/shared/authconfigFactory.ts b/projects/common/src/fm/shared/authconfigFactory.ts deleted file mode 100644 index 1ae1689..0000000 --- a/projects/common/src/fm/shared/authconfigFactory.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { AuthConfig } from 'angular-oauth2-oidc'; -import {AppConfig} from './app.config'; - -export interface IAuthconfigFactory { - getAuthConfig(appConfig: AppConfig): AuthConfig; -} - -export class AuthConfigFactory implements IAuthconfigFactory { - getAuthConfig(appConfig: AppConfig): AuthConfig { - let authConfig: AuthConfig = new AuthConfig(); - authConfig.issuer = appConfig.getConfig("issuer"); - authConfig.redirectUri = window.location.origin + "/cb"; - authConfig.silentRefreshRedirectUri = window.location.origin + "/silent-refresh.html"; - authConfig.clientId = appConfig.getConfig("clientId"); - authConfig.customQueryParams = { audience: appConfig.getConfig("audience") }; - authConfig.scope = "openid profile email"; - authConfig.oidc = true; - authConfig.disableAtHashCheck = true; - authConfig.requireHttps = appConfig.getConfig("requireHttps"); - return authConfig; - } - } \ No newline at end of file diff --git a/projects/common/src/fm/shared/safe.pipe.ts b/projects/common/src/fm/shared/safe.pipe.ts deleted file mode 100644 index 3b9b5e4..0000000 --- a/projects/common/src/fm/shared/safe.pipe.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { DomSanitizer } from '@angular/platform-browser'; - -@Pipe({ - name: 'safe' -}) -export class SafePipe implements PipeTransform { - - constructor(private sanitizer: DomSanitizer) { } - transform(url) { - return this.sanitizer.bypassSecurityTrustResourceUrl(url); - } -} diff --git a/projects/common/src/fm/shared/secureOAuthStorage.ts b/projects/common/src/fm/shared/secureOAuthStorage.ts deleted file mode 100644 index dc7d336..0000000 --- a/projects/common/src/fm/shared/secureOAuthStorage.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {OAuthStorage} from 'angular-oauth2-oidc'; -import {Inject, Injectable} from '@angular/core'; - -@Injectable() -export class SecureOAuthStorage extends OAuthStorage { - private storage = {}; - - secureKey(key:string): boolean { - if(key == "nonce") return false; - if(key == "PKCI_verifier") return false; - return true; - } - - getItem(key: string): string { - if(this.secureKey(key)) { - return this.storage[key]; - } else { - return window.sessionStorage.getItem(key); - } - - }; - removeItem(key: string): void { - if(this.secureKey(key)) { - delete this.storage[key]; - } else { - window.sessionStorage.removeItem(key); - } - } - setItem(key: string, data: string): void { - if(this.secureKey(key)) { - this.storage[key]=data; - } else { - window.sessionStorage.setItem(key,data); - } - } -} \ No newline at end of file diff --git a/projects/common/src/public-api.ts b/projects/common/src/public-api.ts deleted file mode 100644 index 1b11ce9..0000000 --- a/projects/common/src/public-api.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Public API Surface of common - */ - -export * from './fm/common.module'; -export * from './fm/common-service.module'; diff --git a/projects/common/src/test.ts b/projects/common/src/test.ts deleted file mode 100644 index e11ff1c..0000000 --- a/projects/common/src/test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'core-js/es7/reflect'; -import 'zone.js/dist/zone'; -import 'zone.js/dist/zone-testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -declare const require: any; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/projects/common/tsconfig.lib.json b/projects/common/tsconfig.lib.json deleted file mode 100644 index 592eaa2..0000000 --- a/projects/common/tsconfig.lib.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/lib", - "target": "es2015", - "module": "es2015", - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "types": [], - "lib": [ - "dom", - "es2018" - ], - "paths": { - "@angular/*": [ - - "node_modules/@angular/*" - - ] - } - }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "enableResourceInlining": true, - "enableIvy": false - }, - "exclude": [ - "src/test.ts", - "**/*.spec.ts" - ] -} diff --git a/projects/common/tsconfig.spec.json b/projects/common/tsconfig.spec.json deleted file mode 100644 index 16da33d..0000000 --- a/projects/common/tsconfig.spec.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "../../out-tsc/spec", - "types": [ - "jasmine", - "node" - ] - }, - "files": [ - "src/test.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/projects/common/tslint.json b/projects/common/tslint.json deleted file mode 100644 index 04e807f..0000000 --- a/projects/common/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../../tslint.json", - "rules": { - "directive-selector": [ - true, - "attribute", - "fm", - "camelCase" - ], - "component-selector": [ - true, - "element", - "fm", - "kebab-case" - ] - } -}