2020-03-02 12:48:10 +00:00
|
|
|
import { Component, Injectable } from '@angular/core';
|
|
|
|
import { Location } from '@angular/common';
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
2020-03-03 09:21:24 +00:00
|
|
|
import { commonReducers, ItemTypeService, ItemService, FolderService,IItem } from '@farmmaps/common';
|
2020-03-02 12:48:10 +00:00
|
|
|
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 {
|
|
|
|
|
2020-03-03 20:16:01 +00:00
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
|
2020-03-02 12:48:10 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-03-03 09:21:24 +00:00
|
|
|
nextDate():Date {
|
|
|
|
let temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
|
|
|
if(temporalItemLayer.nextItemLayer.item)
|
|
|
|
return temporalItemLayer.nextItemLayer.item.dataDate;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-03-02 12:48:10 +00:00
|
|
|
hasPrevious():boolean {
|
|
|
|
let temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
|
|
|
return temporalItemLayer && temporalItemLayer.previousItemLayer != null;
|
|
|
|
}
|
|
|
|
|
2020-03-03 09:21:24 +00:00
|
|
|
previousDate():Date {
|
|
|
|
let temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
|
|
|
if(temporalItemLayer.previousItemLayer.item)
|
|
|
|
return temporalItemLayer.previousItemLayer.item.dataDate;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-03-02 12:48:10 +00:00
|
|
|
handleNextTemporal(event:MouseEvent) {
|
|
|
|
this.store.dispatch(new mapActions.NextTemporal());
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
handlePreviousTemporal(event:MouseEvent) {
|
|
|
|
this.store.dispatch(new mapActions.PreviousTemporal());
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2020-03-03 09:21:24 +00:00
|
|
|
|
|
|
|
selectedItem():IItem {
|
|
|
|
let temporalItemLayer = this.itemLayer as ITemporalItemLayer;
|
|
|
|
if(temporalItemLayer && temporalItemLayer.selectedItemLayer) {
|
|
|
|
return temporalItemLayer.selectedItemLayer.item;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-03 18:43:17 +00:00
|
|
|
|
|
|
|
layer(layers:any,layerIndex:number) {
|
|
|
|
return layers.find(l => l.index == layerIndex);
|
|
|
|
}
|
2020-03-03 20:06:39 +00:00
|
|
|
|
2020-03-20 10:15:47 +00:00
|
|
|
handleGoToChart(item: IItem) {
|
|
|
|
this.router.navigate(['/viewer', 'temporal', 'item', item.code, item.dataDate.getUTCFullYear()]);
|
2020-03-03 20:06:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-02 12:48:10 +00:00
|
|
|
}
|