AW-5495
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2023-09-11 21:59:34 +02:00
parent 2b2e1bfafa
commit ccf77805a0
7 changed files with 70 additions and 1 deletions

View File

@ -25,6 +25,7 @@
<li *ngIf="!getItemLayer(item,itemLayer.layerIndex)"><a href="#" (click)="handleAddAsLayer(item,itemLayer.layerIndex)"><i class="fas fa-layer-plus" 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="fas fa-layer-minus" aria-hidden="true" i18n-title title="Remove overlay"></i>&nbsp;<span i18n>Remove overlay</span></a></li>
</ng-container>
<li><fm-item-link class="text-primary p-0" [itemCode]="item.code" pathSuffix="data" [showText]="true"></fm-item-link></li>
</ul>
</div>
<fm-map-zoom-to-show-alert [layer]="itemLayer?.layer"></fm-map-zoom-to-show-alert>

View File

@ -42,6 +42,8 @@ import { IEventMessage } from './models/event.message';
import { IItem, Item } from './models/item';
import { WeatherCurrentObservation } from './models/weatherCurrentObservation';
import { IItemType } from './models/item.type';
import { IItemLinkType} from './models/itemlink.type';
import {IUrlType} from './models/url.type';
import { IItemTypes } from './models/item.types';
import { IItemTask, ItemTask } from './models/itemTask';
import { IListItem } from './models/list.item';
@ -65,6 +67,7 @@ import { HelpMenuComponent} from './components/help-menu/help-menu.component';
import { BackButtonComponent } from './components/back-button/back-button.component';
import { EditImageModalComponent } from './components/edit-image-modal/edit-image-modal.component';
import { AvatarComponent } from './components/avatar/avatar.component';
import { ItemLinkComponent } from './components/item-link/item-link.component';
import { AvatarModule } from 'ngx-avatar';
import { ImageCropperModule } from 'ngx-image-cropper';
@ -92,6 +95,8 @@ export {
IItem,
Item,
IItemType,
IItemLinkType,
IUrlType,
IItemTypes,
IItemTask,
ItemTask,
@ -115,6 +120,7 @@ export {
IGradientstop,
BackButtonComponent,
AvatarComponent,
ItemLinkComponent,
EditImageModalComponent,
GradientComponent,
GradientSelectComponent
@ -160,7 +166,8 @@ export {
BackButtonComponent,
ThumbnailComponent,
EditImageModalComponent,
AvatarComponent
AvatarComponent,
ItemLinkComponent
],
exports: [
NgbModule,
@ -189,6 +196,7 @@ export {
BackButtonComponent,
ThumbnailComponent,
AvatarComponent,
ItemLinkComponent,
EditImageModalComponent
]
})

View File

@ -0,0 +1 @@
<span class="item-link" (click)="copylink(copiedtt)" triggers="manual" ngbTooltip="Link copied" #copiedtt="ngbTooltip" ><i ngbTooltip='Copy link' class="fa-solid fa-link"></i> <span *ngIf="showText" i18n>Copy link</span></span>

View File

@ -0,0 +1,44 @@
import { Component, Input, OnDestroy} from '@angular/core';
import { IItemLinkType} from '../../models/itemlink.type'
import { IUrlType } from '../../models/url.type';
import { ItemService } from '../../common-service.module';
import { Subscription } from 'rxjs';
import { ClipboardService } from 'ngx-clipboard'
@Component({
selector: 'fm-item-link',
templateUrl: './item-link.component.html'
})
export class ItemLinkComponent implements OnDestroy {
@Input() itemCode:string;
@Input() pathSuffix:string;
@Input() query:string;
@Input() validMinutes:number;
@Input() showText:boolean;
private sub : Subscription = null;
constructor(private itemService:ItemService,private clipboardService$: ClipboardService) { }
copylink(tooltip) {
if(this.sub) {
this.sub.unsubscribe();
}
let link: IItemLinkType = {itemcode:this.itemCode,pathsuffix:this.pathSuffix,query:this.query,validminutes:this.validMinutes}
this.sub = this.itemService.getItemLink(link).subscribe((url:IUrlType) => {
this.clipboardService$.copy(url.url);
tooltip.open();
setTimeout(() => {
tooltip.close();
}, 2000);
})
}
ngOnDestroy(): void {
if(this.sub) {
this.sub.unsubscribe();
}
}
}

View File

@ -0,0 +1,6 @@
export interface IItemLinkType {
itemcode: string;
pathsuffix?: string;
query?: string;
validminutes?: number;
}

View File

@ -0,0 +1,3 @@
export interface IUrlType {
url: string;
}

View File

@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { IItemType } from '../models/item.type';
import { IItemLinkType } from '../models/itemlink.type';
import { IUrlType } from '../models/url.type';
import { IItem } from '../models/item';
import { IJsonline } from '../models/json-line';
import { IItemTask } from '../models/itemTask';
@ -63,6 +65,10 @@ export class ItemService {
return this.httpClient.get<IItem>(`${this.ApiEndpoint()}/api/v1/items/${code}`);
}
getItemLink(itemLink: IItemLinkType): Observable<any> {
return this.httpClient.post<IItemLinkType>(`${this.ApiEndpoint()}/api/v1/itemlink`,itemLink);
}
getItemData(code: string,start?:number,size?:number): Observable<ArrayBuffer> {
let headers = new HttpHeaders();
if(start !== undefined && size !== undefined) headers=headers.set("Range",`bytes=${start}-${size-1}`);