43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import {Component, Injectable, Input, OnInit} from '@angular/core';
|
|
import {Store} from '@ngrx/store';
|
|
import * as mapReducers from '../../reducers/map.reducer';
|
|
import { commonReducers, ItemTypeService, IItem, ItemService, IListItem } from '@farmmaps/common';
|
|
import { ForItemType } from '../for-item/for-itemtype.decorator';
|
|
import { ForSourceTask } from '../for-item/for-sourcetask.decorator';
|
|
import { AbstractItemListItemComponent } from '../item-list-item/item-list-item.component'
|
|
import { map, mergeMap } from 'rxjs/operators';
|
|
import { Observable, of } from 'rxjs';
|
|
import {Router} from "@angular/router";
|
|
|
|
|
|
@ForItemType("vnd.farmmaps.itemtype.temporal")
|
|
@ForSourceTask("vnd.farmmaps.task.vandersat")
|
|
@Injectable()
|
|
@Component({
|
|
selector: 'item-list-item-temporal',
|
|
templateUrl: './item-list-item-temporal.component.html',
|
|
styleUrls: ['./item-list-item-temporal.component.css']
|
|
})
|
|
export class ItemListItemTemporalComponent extends AbstractItemListItemComponent implements OnInit {
|
|
@Input() item: IListItem;
|
|
lastTemporalItem$: Observable<IItem>;
|
|
|
|
constructor(store: Store<mapReducers.State | commonReducers.State>,
|
|
itemTypeService: ItemTypeService, private itemService: ItemService,
|
|
private router: Router) {
|
|
super(store, itemTypeService);
|
|
}
|
|
ngOnInit() {
|
|
this.lastTemporalItem$ = this.itemService
|
|
.getChildItemList(this.item.code, "vnd.farmmaps.itemtype.geotiff.processed")
|
|
.pipe(
|
|
map(list => list.length>0? list.sort().slice(-1)[0]:null),
|
|
mergeMap(li => li==null?of(null):this.itemService.getItem(li.code)));
|
|
}
|
|
|
|
onWidgetClicked() {
|
|
event.stopPropagation();
|
|
this.router.navigate(['viewer/vandersat/item', this.item.code]);
|
|
}
|
|
}
|