Add common-map library
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				FarmMaps.Develop/FarmMapsLib/develop There was a failure building this commit
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	FarmMaps.Develop/FarmMapsLib/develop There was a failure building this commit
				
			This commit is contained in:
		@@ -0,0 +1,13 @@
 | 
			
		||||
<div *ngIf="(item$|async) as item" class="widget d-flex flex-column p-1" (click)="onWidgetClicked($event)">
 | 
			
		||||
  <ng-container *ngIf="getLastDailyOutput(item) as dailyOutput">
 | 
			
		||||
    <div class="head" i18n>Yield forecast</div>
 | 
			
		||||
    <div class="d-flex flex-row justify-content-between">
 | 
			
		||||
      <div>(<span class="unit">ton/ha</span>)</div>
 | 
			
		||||
      <div class="dateformat">{{dailyOutput.date | date : 'd/M/yy'}}</div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="d-flex flex-column">
 | 
			
		||||
      <div class="fm fa-5x fm-potato"></div>
 | 
			
		||||
      <div class="value align-self-end">{{dailyOutput.tuberwt[1] | number:'0.1-1'}}</div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </ng-container>
 | 
			
		||||
</div>
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
.head {
 | 
			
		||||
  color: grey;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  /*border-bottom:1px solid black;*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.body {
 | 
			
		||||
  display: block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.value {
 | 
			
		||||
  text-align: center;
 | 
			
		||||
  font-weight: bold;
 | 
			
		||||
  font-size: 1.9rem;
 | 
			
		||||
  color: deeppink;
 | 
			
		||||
  /*border-right:1px solid black;*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.widget {
 | 
			
		||||
  display: block;
 | 
			
		||||
  height: 100%;
 | 
			
		||||
  width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.unit {
 | 
			
		||||
  font-size: 0.8rem;
 | 
			
		||||
  color: gray;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.dateformat {
 | 
			
		||||
  font-size: 0.8rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.fm-potato {
 | 
			
		||||
  color: saddlebrown;
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,50 @@
 | 
			
		||||
import {Component, Injectable, Input, OnInit} from '@angular/core';
 | 
			
		||||
import {Store} from '@ngrx/store';
 | 
			
		||||
import * as mapReducers from '../../reducers/map.reducer';
 | 
			
		||||
import {commonReducers, IItem, IListItem, ItemService, ItemTypeService} 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 {Observable} from "rxjs";
 | 
			
		||||
import {Router} from "@angular/router";
 | 
			
		||||
 | 
			
		||||
@ForItemType("vnd.farmmaps.itemtype.tipstar")
 | 
			
		||||
@ForSourceTask("vnd.farmmaps.task.tipstar")
 | 
			
		||||
@Injectable()
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'item-list-item-tipstar',
 | 
			
		||||
  templateUrl: './item-list-item-tipstar.component.html',
 | 
			
		||||
  styleUrls: ['./item-list-item-tipstar.component.scss']
 | 
			
		||||
})
 | 
			
		||||
export class ItemListItemTipstarComponent extends AbstractItemListItemComponent implements OnInit {
 | 
			
		||||
  @Input() item: IListItem;
 | 
			
		||||
 | 
			
		||||
  item$: Observable<IItem>;
 | 
			
		||||
 | 
			
		||||
  constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService,
 | 
			
		||||
              private itemService$: ItemService, private router: Router) {
 | 
			
		||||
    super(store, itemTypeService);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.item$ = this.itemService$.getItem(this.item.code);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  onWidgetClicked(event: MouseEvent) {
 | 
			
		||||
    event.stopPropagation();
 | 
			
		||||
    this.router.navigate(['viewer/tipstar/item', this.item.code]);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getLastDailyOutput(item) {
 | 
			
		||||
    if (item == null || item.data == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const itemData = item.data;
 | 
			
		||||
    if (itemData.dailyOutput == null) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return itemData.dailyOutput[itemData.dailyOutput.length - 1]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user