AW-1301 Initial project based on FarmMapsLib.

This commit is contained in:
Peter (extern) 2020-06-10 13:21:03 +02:00
parent e0d585e125
commit f837f1bf3a
203 changed files with 0 additions and 10260 deletions

View File

@ -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).

View File

@ -1,10 +0,0 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/common-map",
"lib": {
"entryFile": "src/public-api.ts"
},
"whitelistedNonPeerDependencies": [
"."
]
}

View File

@ -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=="
}
}
}

View File

@ -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"
}
}

View File

@ -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<Feature>, 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;

View File

@ -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 { }

View File

@ -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<any>): ActionReducer<any> {
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<MetaReducer<any, any>> = [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<AppCommonMapModule> {
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 }
]
};
}
}

View File

@ -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<IDroppedFile>();
@Input() parentCode: string;
@Input() features: Array<Feature>;
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);
}
}

View File

@ -1,15 +0,0 @@
<div class="gps-location">
<svg #location height="1000" width="1000">
<defs>
<linearGradient id="grad1" x1="0%" y1="100%" x2="0%" y2="0%">
<stop offset="0%" class="stop1" />
<stop offset="100%" class="stop2" />
</linearGradient>
</defs>
<circle class="tolerance" cx="500" cy="500" stroke="none" [attr.r]="locTolerancePixels" />
<path *ngIf="showHeading" class="heading" stroke="none" [attr.d]="path" fill="url(#grad1)" [attr.transform]="rotate"></path>
<circle class="border" cx="500" cy="500" r="7" stroke="none" />
<circle class="center" cx="500" cy="500" r="6" stroke="none" />
</svg>
</div>

View File

@ -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;
}

View File

@ -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)";
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -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: `<ng-content></ng-content>`,
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([]);
}
}
}
}
}

View File

@ -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: `<ng-content></ng-content>`,
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<Feature>;
@Input() selectedFeature: Feature;
@Input() selectedItem: IItem;
@Input() styles:IStyles;
@Output() onFeaturesSelected: EventEmitter<Feature> = new EventEmitter<Feature>();
@Output() onFeatureHover: EventEmitter<Feature> = new EventEmitter<Feature>();
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];
}
}
}
}
}

View File

@ -1,31 +0,0 @@
<div>
<div class="layerlist" *ngIf="itemLayers.length > 0;else noLayers">
<div class="list-group">
<div *ngFor="let itemLayer of itemLayers" class="list-group-item list-group-item-action p-2 text-truncate" [ngClass]="{'active' : selectedLayer==itemLayer}">
<div (click)="handleSelectLayer($event,itemLayer)" [title]="itemLayer.item.name">{{itemLayer.item.name}}</div>
<div class="mt-1" *ngIf="selectedLayer==itemLayer && !baseLayers">
<span class="btn-group">
<a title="Toggle visibility"href="#" class="btn btn-light btn-sm" (click)="handleToggleVisibility($event,itemLayer)"><i class="fa" aria-hidden="true" [ngClass]="{'fa-eye':!itemLayer.visible,'fa-eye-slash':itemLayer.visible}"></i></a>
<a title="Transparency 25%" *ngIf="itemLayer.visible" href="#" class="btn btn-light btn-sm" (click)="handleSetOpacity($event,itemLayer,0.25)">25%</a>
<a title="Transparency 50%" *ngIf="itemLayer.visible" href="#" class="btn btn-light btn-sm" (click)="handleSetOpacity($event,itemLayer,0.5)">50%</a>
<a title="Transparency 75%" *ngIf="itemLayer.visible" href="#" class="btn btn-light btn-sm" (click)="handleSetOpacity($event,itemLayer,0.75)">75%</a>
<a title="No transparency" *ngIf="itemLayer.visible" href="#" class="btn btn-light btn-sm" (click)="handleSetOpacity($event,itemLayer,1)">100%</a>
</span>
<a href="#" title="Zoom to extent" class="btn btn-light btn-sm" (click)="handleZoomToExtent($event,itemLayer)"><i class="fa fa-search-plus" aria-hidden="true"></i></a>
<span *ngIf="firstLayer(itemLayer)"><a href="#" title="Toggle legend" class="btn btn-light btn-sm" (click)="itemLayer.legendVisible=toggleLegend($event,itemLayer.legendVisible)"><i class="fa fa-bar-chart" aria-hidden="true"></i></a></span>
<span class="float-right"><a href="#" title="Remove overlay" class="btn btn-light btn-sm" (click)="handleDelete($event,itemLayer)"><i class="fa fa-minus" aria-hidden="true"></i></a></span>
</div>
<div *ngIf="itemLayer.legendVisible">
<div class="card legend">
<fm-map-layer-legend [layer]="firstLayer(itemLayer)" (click)="handleLegendClick($event,itemLayer);"></fm-map-layer-legend>
</div>
</div>
</div>
</div>
</div>
</div>
<ng-template #noLayers>
<div class="list-group">
<div class="list-group-item" i18n>No layers</div>
</div>
</ng-template>

View File

@ -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;
}

View File

@ -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<IItemLayer>();
@Output() onSetOpacity = new EventEmitter<{layer: IItemLayer,opacity:number }>();
@Output() onDelete = new EventEmitter<IItemLayer>();
@Output() onZoomToExtent = new EventEmitter<IItemLayer>();
@Output() onSelectLayer = new EventEmitter<IItemLayer>();
@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();
}
}

View File

@ -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: `
<ng-content></ng-content>
`,
})
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);
}
}

View File

@ -1,13 +0,0 @@
<div (click)="handleClick($event)" class="btn btn-outline-secondary gps-location">
<svg height="100%" width="100%" viewBox="0 0 96 96">
<g
id="XMLID_1_"><circle
class="pan-to" [ngClass]="{'pan-to-centered':centered(),'pan-to-disabled':disabled()}"
cx="48"
cy="48"
r="9.8000002"/><path
class="pan-to" [ngClass]="{'pan-to-centered':centered(),'pan-to-disabled':disabled()}"
d="M 80.5,44.8 H 73.8 C 72.3,33 63,23.7 51.3,22.2 v -6.7 h -6.5 v 6.7 C 33,23.7 23.7,33 22.2,44.8 h -6.7 v 6.5 h 6.7 C 23.7,63 33,72.3 44.8,73.8 v 6.7 h 6.5 V 73.8 C 63,72.3 72.3,63 73.8,51.3 h 6.7 z M 48,67.5 C 37.2,67.5 28.5,58.8 28.5,48 28.5,37.2 37.2,28.5 48,28.5 c 10.8,0 19.5,8.7 19.5,19.5 0,10.8 -8.7,19.5 -19.5,19.5 z"
inkscape:connector-curvature="0"/></g>
</svg>
</div>

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -1,35 +0,0 @@
<div (click)="handleClick($event)" class="btn btn-outline-secondary compass" [style.transform]="Rotation()" [ngClass]="{'compass-n':IsNorth()}">
<svg height="100%" width="100%" viewBox="0 0 132.29166 132.29167">
<g
inkscape:label="Laag 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-164.70832)">
<g
id="g4550"
transform="translate(2.3213753,-1.8555167)">
<path
id="top-r"
d="m 63.824458,179.82737 v 52.8823 H 48.380953 Z"
style="stroke:none;stroke-width:0.15389842px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="top-l"
d="m 63.824458,179.82737 v 52.8823 h 15.443505 z"
style="stroke:none;stroke-width:0.15389842px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="bottom-l"
d="m 63.824458,285.59197 v -52.8823 h -15.4435 z"
style="stroke:none;stroke-width:0.15389842px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="bottom-r"
d="m 63.824458,285.59197 v -52.8823 h 15.443505 z"
style="stroke:none;stroke-width:0.15389842px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
id="north"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';stroke-width:2.95481014"
d="m 50.702335,239.32724 h 9.926315 l 12.534859,23.63848 v -23.63848 h 8.425825 v 34.46509 H 71.663019 L 59.12816,250.15385 v 23.63848 h -8.425825 z" />
</g>
</g>
</svg>
</div>

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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: '<div (click)="handleClick($event)" class="rounded-circle twotreed">{{label}}</div>',
// 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";
// }
// }

View File

@ -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: `<ng-content></ng-content>`
})
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);
}
}
}

View File

@ -1,3 +0,0 @@
<div class="feature-list-container">
<ng-template fm-map-widget-host></ng-template>
</div>

View File

@ -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;
}
}

View File

@ -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<mapReducers.State>,private componentFactoryResolver: ComponentFactoryResolver, @Inject(AbstractFeatureListComponent) public featureLists: AbstractFeatureListComponent[] ) {
}
@Input() features: Array<Feature>
@Input() queryState: IQueryState;
@Input() selectedFeature: Feature;
@Input() clickedFeature:Observable<Feature>;
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
componentRef:any;
loadComponent(queryState:IQueryState) {
var componentFactory: ComponentFactory<AbstractFeatureListComponent> = 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);
(<AbstractFeatureListComponent>this.componentRef.instance).features = null;
(<AbstractFeatureListComponent>this.componentRef.instance).queryState = queryState;
(<AbstractFeatureListComponent>this.componentRef.instance).selectedFeature = null;
}
ngOnInit() {
this.clickedFeature.subscribe((feature => {
(<AbstractFeatureListComponent>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)) {
(<AbstractFeatureListComponent>this.componentRef.instance).features = changes["features"].currentValue;
}
if(changes["selectedFeature"]) {
(<AbstractFeatureListComponent>this.componentRef.instance).selectedFeature = changes["selectedFeature"].currentValue;
}
}
}

View File

@ -1,14 +0,0 @@
<div class="card border-0">
<div class="card-body" *ngIf="(schemeItem|async);let schemeItem">
<div><a href="#" (click)="handleBackClick($event)" i18n>back</a></div>
<h4 i18n>Farm</h4>
<h3>{{schemeItem.name}}</h3>
<div *ngIf="features;let features">
<div class="cropfields">
<div class="row m-0 pl-3 pr-3" *ngFor="let feature of features" [ngClass]="{'selected':isFeatureSelected(feature)}" (click)="handleFeatureClick(feature)" (mouseenter)="handleFeatureMouseEnter(feature)" (mouseleave)="handleFeatureMouseLeave(feature)">
<fm-map-feature-list-feature-container [feature]="feature"></fm-map-feature-list-feature-container>
</div>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, private itemService: ItemService) {
super(store, itemTypeService,location);
}
public schemeItem: Observable<IItem>
ngOnInit() {
this.schemeItem = this.itemService.getItem(this.queryState.parentCode);
}
}

View File

@ -1,13 +0,0 @@
<div class="card border-0">
<div class="card-body">
<div><a href="#" (click)="handleBackClick($event)" i18n>Back</a></div>
<h3><i class="fm fm-farm"></i>&nbsp;<span i18n>Farms</span></h3>
<div *ngIf="features;let features">
<div class="farms">
<div class="row m-0 pl-3 pr-3" *ngFor="let feature of features"[ngClass]="{'selected':isFeatureSelected(feature)}" (click)="handleFeatureClick(feature)" (mouseenter)="handleFeatureMouseEnter(feature)" (mouseleave)="handleFeatureMouseLeave(feature)">
<fm-map-feature-list-feature-container [feature]="feature"></fm-map-feature-list-feature-container>
</div>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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);
}
}

View File

@ -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: `
<div>
<ng-template fm-map-widget-host></ng-template>
</div>
`
})
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<AbstractFeatureListFeatureComponent> = 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);
(<AbstractFeatureListFeatureComponent>componentRef.instance).feature = this.feature;
}
ngOnChanges(changes: SimpleChanges) {
if (changes["feature"] && changes["feature"].currentValue) {
this.loadComponent();
}
}
}

View File

@ -1,12 +0,0 @@
<div *ngIf="feature;let feature" class="d-flex m-0">
<div class="p-2">
<div #container class="thumbnail">
<canvas #canvas ></canvas>
</div>
</div>
<div class="flex-grow p-2 overflow-hidden">
<h1 class="card-title" title="{{feature.get('name')}}">{{feature.get('name')}}</h1>
<div class="card-text"><span>{{areaInHa(feature)| number:'1.2-2'}} ha</span>&nbsp;<span>{{feature.get('cropTypeName')}}</span> </div>
<div class="card-text"><span>{{feature.get('datadate')|date}}</span> - <span>{{feature.get('dataenddate')|date}}</span> </div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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);
}
}

View File

@ -1,6 +0,0 @@
<div *ngIf="feature;let feature" class="row m-0">
<div class="col p-2">
<h1 class="card-title" title="{{feature.get('name')}}">{{feature.get('name')}}</h1>
<div class="card-text">{{feature.get('datadate')|date:'shortDate'}}</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,config:AppConfig) {
super(store, itemTypeService,config);
}
}

View File

@ -1,12 +0,0 @@
<div *ngIf="feature;let feature" class="row m-0">
<div class="col-3 m-0 p-2 thumbnail">
<img *ngIf="feature.get('thumbnail')" [src]="config.getConfig('apiEndPoint') + '/api/v1/items/'+feature.get('code')+'/thumbnail'" />
<div *ngIf="!feature.get('thumbnail')" [style.background-color]="itemTypeService.getColor(feature.get('itemType'))">
<i [ngClass]="itemTypeService.getIcon(feature.get('itemType'))"></i>
</div>
</div>
<div class="col p-2">
<h1 class="card-title" title="{{feature.get('name')}}"><i [ngClass]="itemTypeService.getIcon(feature.get('itemType'))" [style.color]="itemTypeService.getColor(feature.get('itemType'))"></i>&nbsp;{{feature.get('name')}}</h1>
<div class="card-text">{{feature.get('datadate')|date:'shortDate'}}</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, config:AppConfig) {
super(store, itemTypeService,config);
}
}

View File

@ -1,6 +0,0 @@
<div *ngIf="features;let features">
<a href="#" (click)="handleBackClick($event)">Go back</a>
<div class="row m-0 pl-3 pr-3" *ngFor="let feature of features" [ngClass]="{'selected':isFeatureSelected(feature)}" (click)="handleFeatureClick(feature)" (mouseenter)="handleFeatureMouseEnter(feature)" (mouseleave)="handleFeatureMouseLeave(feature)">
<fm-map-feature-list-feature-container [feature]="feature"></fm-map-feature-list-feature-container>
</div>
</div>

View File

@ -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');
}

View File

@ -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<Feature>;
@Input() queryState: IQueryState;
@Input() selectedFeature: Feature;
constructor(public store: Store<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,location:Location) {
super(store, itemTypeService,location);
}
}

View File

@ -1,5 +0,0 @@
export function ForChild() {
return function (constructor:Function) {
constructor.prototype.forChild = true;
};
}

View File

@ -1,5 +0,0 @@
export function ForItemType(itemType: string) {
return function (constructor:Function) {
constructor.prototype.forItemType = itemType;
};
}

View File

@ -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"}

View File

@ -1,5 +0,0 @@
export function ForSourceTask(sourceTask: string) {
return function (constructor:Function) {
constructor.prototype.forSourceTask = sourceTask;
};
}

View File

@ -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: `
<div style="height:100%">
<ng-template fm-map-widget-host></ng-template>
</div>
`
})
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<AbstractItemListItemComponent> = 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);
(<AbstractItemListItemComponent>componentRef.instance).item = this.item;
}
ngOnChanges(changes: SimpleChanges) {
if (changes["item"] && changes["item"].currentValue) {
this.loadComponent();
}
}
}

View File

@ -1,4 +0,0 @@
<div *ngIf="item;let item" class="widget" [style.background-color]="itemTypeService.getColor(item.itemType)">
<div class="align-middle icon" [ngClass]="itemTypeService.getIcon(item.itemType)"></div>
<div class="title">{{item.name}}</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService) {
super(store, itemTypeService);
}
}

View File

@ -1,7 +0,0 @@
<div *ngIf="items;let items" class="widget-container pt-0">
<div class="widget" *ngFor="let item of items" (click)="handleItemClick(item)">
<div class="content">
<fm-map-item-list-item-container [item]="item" class="item-container"></fm-map-item-list-item-container>
</div>
</div>
</div>

View File

@ -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%;
}

View File

@ -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<IListItem>
constructor(public store: Store<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,location:Location) {
super(store, itemTypeService,location);
}
}

View File

@ -1,7 +0,0 @@
<div *ngIf="widgets;let widgets" class="widget-container pt-0">
<div class="widget" *ngFor="let widget of widgets">
<div class="content">
<ng-template #widgetTemplate></ng-template>
</div>
</div>
</div>

View File

@ -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%;
}

View File

@ -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<ViewContainerRef>;
constructor(public store: Store<mapReducers.State | commonReducers.State>, 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<AbstractItemWidgetComponent> = this.componentFactoryResolver.resolveComponentFactory(this.widgets[i]['constructor'] as any);
const viewContainerRef = targets[i];
viewContainerRef.clear();
const componentRef = viewContainerRef.createComponent(componentFactory);
(<AbstractItemWidgetComponent>componentRef.instance).item = this.item;
}
}
}
}

View File

@ -1,25 +0,0 @@
<div class="btn btn-outline-secondary layer-switcher" (click)="handleClick($event)">
<i class="fa fa-map-o"></i>
<div class="layers hidden" [ngClass]="{'hidden':!(showLayerSwitcher|async)}" (click)="$event.stopPropagation();">
<div class="card layers-card m-1">
<div class="card-header">
<span i18n>Layers</span>
<i class="float-right fa fa-close" (click)="close($event)"></i>
</div>
<ul class="navbar-nav">
<li class="nav-item py-0">
<span><i class="fa fa-map-o" aria-hidden="true"></i>&nbsp;<span i18n>Base maps</span></span>
<div class="mb-4">
<fm-map-layer-list [baseLayers]="true" [itemLayers]="baseLayers|async" [selectedLayer]="selectedBaseLayer|async" (onSelectLayer)="handleSelectBaseLayer($event)"></fm-map-layer-list>
</div>
</li>
<li class="nav-item py-0">
<span><i class="fa fa-map-o" aria-hidden="true"></i>&nbsp;<span i18n>Overlays</span></span>
<div class="mb-4">
<fm-map-layer-list [itemLayers]="overlayLayers|async" [selectedLayer]="selectedOverlayLayer|async" (onDelete)="handleOnDelete($event)" (onToggleVisibility)="handleOnToggleVisibility($event)" (onSetOpacity)="handleOnSetOpacity($event)" (onZoomToExtent)="handleZoomToExtent($event)" (onSelectLayer)="handleSelectOverlayLayer($event)"></fm-map-layer-list>
</div>
</li>
</ul>
</div>
</div>
</div>

View File

@ -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;
}
}

View File

@ -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<boolean>;
public overlayLayers: Observable<Array<IItemLayer>>;
public selectedOverlayLayer: Observable<IItemLayer>;
public baseLayers: Observable<Array<IItemLayer>>;
public selectedBaseLayer: Observable<IItemLayer>;
constructor( private store: Store<mapReducers.State>) {
}
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));
}
}

View File

@ -1,44 +0,0 @@
<table class="container" *ngIf="showLegend()">
<tr>
<td colspan="2">
<div class="title">
<h4 *ngIf="showTitle">{{layer.name}}</h4>
<b *ngIf="layer.unit">({{layer.unit}})</b>
</div>
</td>
<td colspan="2">
<div class="title" *ngIf="histogramenabled">
<h4>{{histogram}}</h4>
<b *ngIf="histogramunit">({{histogramunit}})</b>
</div>
</td>
</tr>
<tr *ngFor="let entry of layer.renderer.colorMap.entries; let i = index ">
<td class="legend-items"><span [style.background-color]="getHex(entry.color)" class="color"></span></td>
<td class="legend-items-text"><span *ngIf="!entry.label">{{getScaledValue(entry.value,layer.scale) | number:'1.0-2'}} {{legendunit}}</span><span *ngIf="entry.label">{{entry.label}}</span></td>
<td class="histogram-items">
<div *ngIf="showHistogram()">
<span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)">
</span>
<span class="bar-label">{{getLabel(layer.renderer,i)}}</span>
</div>
</td>
</tr>
<tr *ngIf="showHistogram()">
<td colspan="4" class="pb-2 pt-2">
<a i18n-title title="more info"><i class="fa fa-info-circle text-primary" (click)="hideHistogramDetails = !hideHistogramDetails"></i></a>
<div class="info pt-2" [ngbCollapse]="hideHistogramDetails">
<div><span i18n>Average: </span>{{layer.renderer.band.histogram.mean| number:'1.0-3'}}</div>
<div><span i18n>Standard deviation: </span>{{layer.renderer.band.histogram.stddev| number:'1.0-3'}}</div>
<div><span i18n>Min: </span>{{layer.renderer.band.histogram.min| number:'1.0-3'}}</div>
<div><span i18n>Max: </span>{{layer.renderer.band.histogram.max| number:'1.0-3'}}</div>
<div *ngIf="showConfidenceInterval()"><span i18n>Confidence interval:</span> {{layer.renderer.band.histogram.confidence * 100| number:'1.0-0'}}%</div>
</div>
</td>
</tr>
</table>

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -1,36 +0,0 @@
<ng-template #rt let-r="result" let-t="term">
<i class="fa fa-search" aria-hidden="true" style="width:2rem"></i>
<ngb-highlight [result]="formatter(r)" [term]="t"></ngb-highlight>
</ng-template>
<div class="map-search collapsed" [ngClass]="{'collapsed':collapsedLocal,searchcollapsed:searchMinifiedLocal}" (click)="$event.stopPropagation()">
<div class="card p-2">
<form class="form" (ngSubmit)="handleSearch($event)">
<div class="input-group">
<div class="input-group-prepend">
<button type="button" class="btn btn-outline-secondary" (click)="handleToggleMenu($event)"><i class="fa fa-bars" aria-hidden="true"></i></button>
</div>
<input #searchText class="form-control" type="text" (focus)="handleFocus($event)" [ngModel]="searchTextLocal" name="searchTextLocal" (ngModelChange)="handleChange($event)" [ngbTypeahead]="search" [resultTemplate]="rt" [inputFormatter]="formatter" (selectItem)="handleSelect($event)" placeholder="Search" i18n-placeholder />
<div class="input-group-append">
<button type="submit" class="btn btn-outline-secondary" [disabled]="disabled"><i class="fa fa-search"></i></button>
<button type="button" class="clear btn btn-outline-secondary" [disabled]="!clearEnabled" (click)="handleClearClick($event)"><i class="fa fa-remove"></i></button>
</div>
</div>
<div class="options">
<div class="form-check">
<input class="form-check-input" (ngModelChange)="handleChangeEnableDateFilter($event)" [ngModel]="dateFilter" name="datefilterEnabled" type="checkbox" value="" id="filtercheck1">
<label class="form-check-label" for="filtercheck1"><span i18n>from</span> <a (click)="handleOpenSelectPeriodModal($event)" href="#">{{startEndCaption}}</a></label>
</div>
<div class="form-check">
<input class="form-check-input" (ngModelChange)="handleChangeEnableBBOXFilter($event)" [ngModel]="filterOptionsLocal.bboxFilter" name="bboxfilterEnabled" type="checkbox" value="" id="filtercheck2">
<label class="form-check-label" for="filtercheck2" i18n>Restrict to visible area</label>
</div>
</div>
<div class="shortcuts">
<router-outlet name="map-search"></router-outlet>
</div>
</form>
<ng-content></ng-content>
</div>
</div>
<fm-map-select-period-modal [modalState]="openedModalName" (onCloseModal)="handleCloseModal()" (onSelect)="handleSelectPeriod($event)" [startDate]="startDate" [endDate]="endDate"></fm-map-select-period-modal>

View File

@ -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;
}
}

View File

@ -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<IQueryState>();
@Output() onClear = new EventEmitter<any>();
@Output() onSearchCollapse = new EventEmitter<any>();
@Output() onSearchExpand = new EventEmitter<any>();
@Output() onToggleMenu = new EventEmitter<any>();
@Output() onOpenModal = new EventEmitter<string>();
@Output() onCloseModal = new EventEmitter<any>();
@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<string>) =>
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({});
}
}

View File

@ -1,71 +0,0 @@
<ng-container *ngIf="{
mapState:mapState$|async,
extent:extent$|async,
baseLayers:baseLayers$|async,
overlayLayers:overlayLayers$|async,
selectedItemLayer:selectedItemLayer$|async,
features:features$|async,
position:position$|async,
parentCode:parentCode$|async,
panelVisible:panelVisible$|async,
openedModalName:openedModalName$|async,
panelCollapsed:panelCollapsed$|async,
searchMinified:searchMinified$|async,
selectedItem:selectedItem$|async,
queryState:queryState$|async,
searchCollapsed:searchCollapsed$|async,
clearEnabled:clearEnabled$|async,
period:period$|async,
compassHeading:compassHeading$|async,
styles:styles$|async,
selectedFeature:selectedFeature$|async
} as state">
<aol-map #map (moveEnd)="handleOnMoveEnd($event)" (click)="handleOnMouseDown($event)" [ngClass]="{'panel-visible':state.panelVisible}" class="map">
<div>
</div>
<aol-view [zoom]="state.mapState.zoom" [rotation]="state.mapState.rotation">
<aol-coordinate [x]="state.mapState.xCenter" [y]="state.mapState.yCenter" [srid]="'EPSG:4326'"></aol-coordinate>
<fm-map-zoom-to-extent [extent]="state.extent" [animate]="true"></fm-map-zoom-to-extent>
</aol-view>
<aol-interaction-default></aol-interaction-default>
<aol-interaction-dragrotateandzoom></aol-interaction-dragrotateandzoom>
<fm-map-item-layers [itemLayers]="state.baseLayers"></fm-map-item-layers>
<fm-map-item-layers [itemLayers]="state.overlayLayers"></fm-map-item-layers>
<fm-map-item-layers [itemLayer]="state.selectedItemLayer"></fm-map-item-layers>
<aol-layer-vector>
<fm-map-item-source-vector [styles]="state.styles" [features]="state.features" (onFeaturesSelected)="handleFeatureClick($event)" (onFeatureHover)="handleFeatureHover($event)" [selectedFeature]="state.selectedFeature" [selectedItem]="state.selectedItem"></fm-map-item-source-vector>
</aol-layer-vector>
<fm-map-gps-location [position]="state.position" [headingTolerance]="20" [showHeading]="true" [heading]="state.compassHeading"></fm-map-gps-location>
<div class="control-container">
<!-- <switch2d3d></switch2d3d>-->
<fm-map-layer-switcher></fm-map-layer-switcher>
<fm-map-pan-to-location [position]="state.position" [mapState]="state.mapState" [animate]="true"></fm-map-pan-to-location>
<fm-map-rotation-reset></fm-map-rotation-reset>
</div>
<fm-map-file-drop-target [parentCode]="state.parentCode" (onFileDropped)="handleFileDropped($event)"></fm-map-file-drop-target>
</aol-map>
<fm-map-map-search #mapSearch [openedModalName]="state.openedModalName" (onOpenModal)="handleOpenModal($event)" (onCloseModal)="handleCloseModal()" [ngClass]="{'menuVisible':state.menuVisible}" (onToggleMenu)="handleToggleMenu($event)" (onSearchCollapse)="handleSearchCollapse($event)" (onSearchExpand)="handleSearchExpand($event)" [collapsed]="state.searchCollapsed" [searchMinified]="state.searchMinified" (onSearch)="handleSearch($event)" (onClear)="handleClearSearch($event)" [filterOptions]="state.queryState" [clearEnabled]="state.clearEnabled" [period]="state.period"></fm-map-map-search>
<fm-side-panel [resizeable]="true" [visible]="state.panelVisible" [collapsed]="state.panelCollapsed" [collapsable]="false">
<div class="panel-wrapper">
<div class="panel-top bg-secondary" *ngIf="!(state.searchMinified)">
</div>
<div class="panel-bottom">
<div *ngIf="!(state.selectedItem)">
<fm-map-feature-list-container [features]="state.features" [selectedFeature]="state.selectedFeature" [queryState]="state.queryState" [clickedFeature]="clickedFeature"></fm-map-feature-list-container>
</div>
<div *ngIf="state.selectedItem;let item">
<fm-map-selected-item-container [item]="item" [itemLayer]="state.selectedItemLayer" [overlayLayers]="state.overlayLayers"></fm-map-selected-item-container>
</div>
<div *ngIf="state.features.length == 0" class="no-results m-2">
<div *ngIf="state.queryState.query">Cannot find <span>{{state.queryState?.query}}</span></div>
<div *ngIf="state.queryState?.tags">Cannot find tag <span>{{state.queryState?.tags}}</span></div>
</div>
</div>
</div>
</fm-side-panel>
</ng-container>

View File

@ -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;
}*/

View File

@ -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<string> = this.store.select(commonReducers.selectOpenedModalName);
public itemTypes$: Observable<{ [id: string]: IItemType }>;
public mapState$: Observable<IMapState> = this.store.select(mapReducers.selectGetMapState);
public features$: Observable<Array<Feature>> = this.store.select(mapReducers.selectGetFeatures);
public overlayLayers$: Observable<Array<IItemLayer>> = this.store.select(mapReducers.selectGetOverlayLayers);
public selectedOverlayLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedOverlayLayer);
public selectedItemLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedItemLayer);
public baseLayers$: Observable<Array<IItemLayer>> = this.store.select(mapReducers.selectGetBaseLayers);
public selectedBaseLayer$: Observable<IItemLayer> = this.store.select(mapReducers.selectGetSelectedBaseLayer);
public projection$: Observable<string> = this.store.select(mapReducers.selectGetProjection);
public selectedFeatures$: Subject<ISelectedFeatures> = new Subject<ISelectedFeatures>();
public droppedFile$: Subject<IDroppedFile> = new Subject<IDroppedFile>();
private paramSub: Subscription;
private itemTypeSub: Subscription;
private stateSub: Subscription;
private queryStateSub: Subscription;
private querySub: Subscription;
public parentCode$: Observable<string> =this.store.select(mapReducers.selectGetParentCode);
public panelVisible$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelVisible);
public panelCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetPanelCollapsed);
public selectedFeature$: Observable<Feature> = this.store.select(mapReducers.selectGetSelectedFeature);
public clickedFeature: Subject<Feature> = new Subject<Feature>();
public selectedItem$: Observable<IItem> = this.store.select(mapReducers.selectGetSelectedItem);
public queryState$: Observable<IQueryState> = this.store.select(mapReducers.selectGetQueryState);
public state$:Observable<{mapState:IMapState,queryState:IQueryState,setStateCount:number}> = this.store.select(mapReducers.selectGetState);
public period$: Observable<IPeriodState> = this.store.select(mapReducers.selectGetPeriod);
public clearEnabled$: Observable<boolean> = this.store.select(mapReducers.selectGetClearEnabled);
public searchCollapsed$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchCollapsed);
public searchMinified$: Observable<boolean> = this.store.select(mapReducers.selectGetSearchMinified);
public menuVisible$: Observable<boolean>;
public query$: Observable<IQueryState> = this.store.select(mapReducers.selectGetQuery);
public position$: Observable<Position> = this.geolocationService.getCurrentPosition();
public compassHeading$: Observable<number> = this.deviceorientationService.getCurrentCompassHeading();
public baseLayersCollapsed:boolean = true;
public overlayLayersCollapsed: boolean = true;
public extent$: Observable<Extent> = this.store.select(mapReducers.selectGetExtent);
public styles$:Observable<IStyles> = this.store.select(mapReducers.selectGetStyles);
private setStateCount$:Observable<number> = this.store.select(mapReducers.selectgetSetStateCount);
private lastUrl = "";
@ViewChild('map') map;
constructor(private store: Store<mapReducers.State | commonReducers.State>,
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();
}
}

View File

@ -1,19 +0,0 @@
<ng-template #content let-c="close" let-d="dismiss">
<form [formGroup]="metaDataForm" (ngSubmit)="handleMetaDataEntered($event)">
<div class="modal-header">
<h4 class="modal-title" i18n>Add metadata</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click'); onCloseModal.emit()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<input [minLength]=1 formControlName="name" autofocus type="text" i18n-placeholder placeholder="MetaData">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" i18n>Upload</button>
<button type="button" class="btn btn-secondary" (click)="c('Close click'); onCloseModal.emit()" i18n>Close</button>
</div>
</form>
</ng-template>

View File

@ -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<any>();
@Output() onAddFilesWithMetaData = new EventEmitter<IMetaData>();
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_].*")])]
});
}
}

View File

@ -1,31 +0,0 @@
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title" i18n>Select period</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click'); onCloseModal.emit()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<ngb-datepicker #dp ngModel (ngModelChange)="onDateChange($event)" [displayMonths]="2" [dayTemplate]="t">
</ngb-datepicker>
<ng-template #t let-date="date" let-focused="focused">
<span class="custom-day"
[class.focused]="focused"
[class.range]="isFrom(date) || isTo(date) || isInside(date) || isHovered(date)"
[class.faded]="isHovered(date) || isInside(date)"
(mouseenter)="hoveredDate = date"
(mouseleave)="hoveredDate = null">
{{ date.day }}
</span>
</ng-template>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" (click)="handleSelect($event)" i18n>Select</button>
<button type="button" class="btn btn-secondary" (click)="c('Close click'); onCloseModal.emit()" i18n="@@buttonClose">Close</button>
</div>
</ng-template>

View File

@ -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);
}

View File

@ -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<any>();
@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);
}

View File

@ -1,3 +0,0 @@
<div class="selected-item-container">
<ng-template fm-map-widget-host></ng-template>
</div>

View File

@ -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');
}

View File

@ -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<IItemLayer>;
@ViewChild(WidgetHostDirective, { static: true }) widgetHost: WidgetHostDirective;
loadComponent() {
let componentFactory: ComponentFactory<AbstractSelectedItemComponent> = 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);
(<AbstractSelectedItemComponent>componentRef.instance).item = this.item;
(<AbstractSelectedItemComponent>componentRef.instance).itemLayer = this.itemLayer;
(<AbstractSelectedItemComponent>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();
}
}
}

View File

@ -1,19 +0,0 @@
<div class="spacer"></div>
<div *ngIf="item;let item">
<div class="card border-0">
<div class="card-body">
<div><a href="#" (click)="handleBackToList($event)" i18n>Back</a></div>
<div class="card menu-card">
<h1>Cropfield</h1>
<h4>{{item.name}}</h4>
<div class="card-text"><span>{{areaInHa(item)| number:'1.2-2'}} ha</span>&nbsp;<span>{{item.data.cropTypeName}}</span></div>
<div class="card-text"><span>{{item.data.startDate|date}}</span> - <span>{{item.data.endDate|date}}</span> </div>
<ul class="p-0 mt-2">
<li *ngIf="item.isEditable"><a href="#" (click)="handleOnEdit(item)"><i class="fa fa-pencil" aria-hidden="true" i18n-title title="Edit"></i>&nbsp;<span i18n>Edit</span></a></li>
</ul>
</div>
</div>
<fm-map-item-list [items]="(items|async)"></fm-map-item-list>
<fm-map-item-widget-list [item]="item"></fm-map-item-widget-list>
</div>
</div>

View File

@ -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;
}

View File

@ -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<IListItem[]>;
constructor(store: Store<mapReducers.State | commonReducers.State>, 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);
}
}

View File

@ -1,30 +0,0 @@
<div class="spacer"></div>
<div *ngIf="item;let item">
<div class="card border-0">
<div class="card-body">
<div class="mb-2"><a href="#" (click)="handleBackToList($event)" i18n>Back</a></div>
<div class="card menu-card">
<h1>{{item.name}}</h1>
</div>
<div class="legend-container" *ngIf="item?.data.layers;let layers">
<div class="card menu-card">
<div *ngIf="layers.length>1">
<select (change)="onLayerChanged($event.target.value)">
<option *ngFor="let l of layers;" [value]="l.index" [selected]="itemLayer.layerIndex == l.index">{{l.name}}</option>
</select>
</div>
<fm-map-layer-legend [layer]="layer(layers,itemLayer.layerIndex)" [histogramenabled]="true"></fm-map-layer-legend>
</div>
</div>
<div class="card menu-card">
<ul class="p-0 mt-2">
<li *ngIf="item.isEditable"><a href="#" class="mt-1 mr-1" (click)="handleOnEdit(item)"><i class="fa fa-pencil" aria-hidden="true" i18n-title title="Edit"></i>&nbsp;<span i18n>Edit</span></a></li>
<ng-container *ngIf="itemTypeService.isLayer(item)">
<li *ngIf="!getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)"><i class="fa fa-eye" aria-hidden="true" i18n-title title="Add as layer"></i>&nbsp;<span i18n>Add as overlay</span></a></li>
<li *ngIf="getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleRemoveLayer(item,itemLayer.layerIndex)"><i class="fa fa-eye" aria-hidden="true" i18n-title title="Remove overlay"></i>&nbsp;<span i18n>Remove overlay</span></a></li>
</ng-container>
</ul>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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);
}
}

View File

@ -1,30 +0,0 @@
<div class="spacer"></div>
<div *ngIf="item;let item">
<div class="card border-0">
<div class="card-body">
<div class="mb-2"><a href="#" (click)="handleBackToList($event)" i18n>Back</a></div>
<div class="card menu-card">
<h1>{{item.name}}</h1>
</div>
<div class="legend-container" *ngIf="item?.data.layers;let layers">
<div class="card menu-card">
<div *ngIf="layers.length>1">
<select (change)="onLayerChanged($event.target.value)">
<option *ngFor="let l of layers;" [value]="l.index" [selected]="itemLayer.layerIndex == l.index">{{l.name}}</option>
</select>
</div>
<fm-map-layer-legend [showTitle]="layers.length==1" [layer]="layer(layers,itemLayer.layerIndex)" [histogramenabled]="true"></fm-map-layer-legend>
</div>
</div>
<div class="card menu-card">
<ul class="p-0 mt-2">
<li *ngIf="item.isEditable"><a href="#" class="mt-1 mr-1" (click)="handleOnEdit(item)" ><i class="fa fa-pencil" aria-hidden="true" i18n-title title="Edit"></i>&nbsp;<span i18n>Edit</span></a></li>
<ng-container *ngIf="itemTypeService.isLayer(item)">
<li *ngIf="!getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)" ><i class="fa fa-eye" aria-hidden="true" i18n-title title="Add as layer"></i>&nbsp;<span i18n>Add as overlay</span></a></li>
<li *ngIf="getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleRemoveLayer(item,itemLayer.layerIndex)" ><i class="fa fa-eye" aria-hidden="true" i18n-title title="Remove overlay"></i>&nbsp;<span i18n>Remove overlay</span></a></li>
</ng-container>
</ul>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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);
}
}

View File

@ -1,43 +0,0 @@
<div class="spacer"></div>
<div *ngIf="selectedItem();let item">
<div class="card border-0">
<div class="card-body">
<div class="mb-2"><a href="#" (click)="handleBackToList($event)" i18n>Back</a></div>
<div class="card menu-card">
<h1>{{item.name}}</h1>
</div>
<div class="legend-container" *ngIf="item?.data.layers;let layers">
<div class="card menu-card">
<h5>Date image: {{item.dataDate | date:'shortDate'}}</h5>
<div class="d-flex justify-content-between">
<div *ngIf="hasPrevious()">
<button type="button" class="btn btn-link p-0" (click)="handlePreviousTemporal($event)">
<i class="fa fa-arrow-circle-left" aria-hidden="true" i18n-title title="Previous"></i>&nbsp;{{ previousDate() | date:'shortDate'}}
</button>
</div>
<div *ngIf="hasNext()">
<button type="button" class="btn btn-link p-0" (click)="handleNextTemporal($event)">
{{ nextDate()| date:'shortDate' }}&nbsp;<i class="fa fa-arrow-circle-right" aria-hidden="true" i18n-title title="Next"></i>
</button>
</div>
</div>
</div>
<div class="card menu-card pt-2">
<div *ngIf="layers.length>1">
<select (change)="onLayerChanged($event.target.value)">
<option *ngFor="let l of layers;" [value]="l.index" [selected]="itemLayer.layerIndex == l.index">{{l.name}}</option>
</select>
</div>
<fm-map-layer-legend [layer]="layer(layers,itemLayer.layerIndex)" [histogramenabled]="true"></fm-map-layer-legend>
</div>
</div>
<div class="card menu-card">
<ul class="p-0 mt-2">
<li *ngIf="item.isEditable"><a href="#" class="mt-1 mr-1" (click)="handleOnEdit(item)"><i class="fa fa-pencil" aria-hidden="true" i18n-title title="Edit"></i>&nbsp;<span i18n>Edit</span></a></li>
<li *ngIf="itemTypeService.isLayer(item)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)" class="mt-1 mr-1"><i class="fa fa-eye" aria-hidden="true" i18n-title title="Add as layer"></i>&nbsp;<span i18n>Add as overlay</span></a></li>
<li><a href="#" (click)="handleGoToChart(item)"><i class="fa fa-line-chart" aria-hidden="true" i18m-title title="Show chart"></i>&nbsp;<span i18n>Show chart</span></a></li>
</ul>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<mapReducers.State | commonReducers.State>, 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;
}
}

View File

@ -1,24 +0,0 @@
<div *ngIf="item;let item">
<div class="card border-0">
<img *ngIf="item.thumbnail" class="card-img-top" [src]="config.getConfig('apiEndPoint') +'/api/v1/items/'+item.code+'/thumbnail?v='+item.updated.getTime()" />
<div *ngIf="!item.thumbnail" class="big-icon" [style.background-color]="itemTypeService.getColor(item.itemType)">
<i [ngClass]="itemTypeService.getIcon(item.itemType)"></i>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="mb-2"><a href="#" (click)="handleBackToList($event)" i18n>Back</a></div>
<h1 class="card-title">{{item.name}}</h1>
<div class="card menu-card">
<ul class="p-0 mt-2">
<li *ngIf="itemTypeService.hasViewer(item)"><a href="#" (click)="handleOnView(item)" class="btn btn-outline-secondary"><i class="fa fa-eye" aria-hidden="true" title="View"></i>&nbsp;<span i18n>View</span></a></li>
<li *ngIf="item.isEditable"><a href="#" (click)="handleOnEdit(item)"><i class="fa fa-pencil" aria-hidden="true" title="Edit"></i> <span i18n>Edit</span></a></li>
<ng-container *ngIf="itemTypeService.isLayer(item)">
<li *ngIf="!getItemLayer(item)"><a href="#" (click)="handleAddAsLayer(item)"><i class="fa fa-eye" aria-hidden="true" i18n-title title="Add as layer"></i>&nbsp;<span i18n>Add as overlay</span></a></li>
<li *ngIf="getItemLayer(item)"><a href="#" (click)="handleRemoveLayer(item)"><i class="fa fa-eye" aria-hidden="true" i18n-title title="Remove overlay"></i>&nbsp;<span i18n>Remove overlay</span></a></li>
</ng-container>
</ul>
</div>
</div>
</div>
</div>

View File

@ -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;
}

View File

@ -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<IItemLayer>;
constructor(public store: Store<mapReducers.State | commonReducers.State>, 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<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, public config:AppConfig) {
super(store, itemTypeService,location,router);
}
}

View File

@ -1,8 +0,0 @@
import { Directive, ViewContainerRef } from '@angular/core';
@Directive({
selector: '[fm-map-widget-host]',
})
export class WidgetHostDirective {
constructor(public viewContainerRef: ViewContainerRef) { }
}

View File

@ -1,6 +0,0 @@
<div [ngSwitch]="stage">
<h6 *ngSwitchCase="StageEnum.DevelopmentPreAlpha" style="color:darkred" [ngbTooltip]="info"><b><span i18n>Stage:Pre-alpha</span></b></h6>
<h6 *ngSwitchCase="StageEnum.DevelopmentAlpha" style="color:red" [ngbTooltip]="info"><b><span i18n>Stage:Alpha</span></b></h6>
<h6 *ngSwitchCase="StageEnum.DevelopmentBeta" style="color:orange" [ngbTooltip]="info" ><b><span i18n>Stage:Beta</span></b></h6>
<h6 *ngSwitchCase="StageEnum.ReleaseCandidate" style="color:green" [ngbTooltip]="info" ><b><span i18n>Stage:RC</span></b></h6>
</div>

Some files were not shown because too many files have changed in this diff Show More