integracija sa ipmdecisions

parent d9fd62d1
......@@ -27,7 +27,8 @@
"primeng": "~13.2.1",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
"zone.js": "~0.11.4",
"ngx-clipboard": "~15.1.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.2.6",
......
......@@ -50,7 +50,7 @@
</div>
<div class="flex justify-content-center">
<div class="pt-3 pr-3">
<p-button type="submit" label="Search" [disabled] = "isEmptySearch()" icon="pi pi-search" [loading]="false"></p-button>
<p-button type="submit" label="Search" [disabled] = "isEmptySearch()" icon="pi pi-search" [loading]="serachRunning"></p-button>
</div>
<div class="pt-3 pl-3">
<p-button type="submit" label="Reset" icon="pi pi-refresh" (click)="resetSearch()" [loading]="false"></p-button>
......@@ -63,18 +63,18 @@
<p-card>
<p-dataView [value]="resources" [lazy]="true" (onLazyLoad)="onPageChange($event)" (onPage)="onPageChange($event)" [totalRecords]="totalElements" [paginator]="true" [rowsPerPageOptions]=[12,24,48,96] [rows]="12" layout="grid">
<ng-template let-resource pTemplate="gridItem">
<div class="card col-12 md:col-4 flex flex-column p-3 mt-3" routerLink="/resource/{{resource.idResource}}">
<div class="card col-12 md:col-4 flex flex-column p-3 mt-3" >
<div class="pb-1 align-self-end">
<p-tag *ngIf="resource.resourceType" [rounded]=true value="{{resource.resourceType.name}}">
</p-tag>
</div>
<div class="">
<div class="" routerLink="/resource/{{resource.idResource}}">
<img [defaultImage]="'assets/sectors/multi.jpg'" [useSrcset]="true" [lazyLoad]="imagePath+'/'+resource.idResource" class="imageSizeHome"/>
<p class="text-center">{{resource.resourceName}}</p>
</div>
<div class="align-self-center">
<button pButton type="button" routerLink="/resource/{{resource.idResource}}" icon="pi pi-forward" class="p-button-outlined mr-4" pTooltip="See more..."></button>
<!--<button pButton type="button" icon="pi pi-share-alt" class="p-button-outlined" pTooltip="Share"></button>-->
<!--<button pButton type="button" icon="pi pi-share-alt" class="p-button-outlined" pTooltip="Copy link for sharing" ngxClipboard [cbContent]="getPermLink(resource.idResource)" (click)=linkCopied(getPermLink(resource.idResource))></button>-->
</div>
</div>
</ng-template>
......@@ -83,6 +83,8 @@
{{item.value}} - per page
</ng-template>
</p-dataView>
<div class="justify-content-center flex pt-3" *ngIf="totalElements>0">Number of results: {{totalElements}}</div>
</p-card>
</div>
</div>
......@@ -12,7 +12,7 @@ import {
Sector
} from "../../model/resource";
import {ResourceService} from "../../service/resource.service";
import {Message} from "primeng/api";
import {Message, MessageService} from "primeng/api";
import {environment} from "../../../environments/environment";
import {SearchModel} from "../../model/search-model";
import {NavigationEnd, Router} from "@angular/router";
......@@ -23,6 +23,8 @@ import {NavigationEnd, Router} from "@angular/router";
})
export class HomeComponent implements OnInit{
resources: Resource[] = [];
totalResources: Resource[] = [];
search:boolean=false;
pageableResponse?: PageableResource;
pageSize = 10;
totalElements: number = 0;
......@@ -44,14 +46,14 @@ export class HomeComponent implements OnInit{
selectedCrops: Crop[] = [];
selectedPests:Pest[] = [];
selectedPestType: string | undefined;
serachRunning= false;
searchTerm: string = "";
more= false;
imagePath = environment.baseUrl+"/resource/image";
imagePathRaw = environment.baseUrl+"/resource/image/raw";
searchModel:SearchModel = {};
constructor(private resourceService:ResourceService, private router:Router) {
constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService) {
this.pageableResponse = {totalElements:0}
}
......@@ -75,6 +77,8 @@ export class HomeComponent implements OnInit{
this.resources = resources.content;
// @ts-ignore
this.totalElements = resources.totalElements;
this.search = false;
this.serachRunning=false;
});
this.disclaimer = [{severity:"info", summary:"Disclaimer", detail:"This IPMWORKS Resource Toolbox is a repository for IPM resource developed by the EU IPMWORKS project (101000339). The cooperating partners have no economic responsibility whatsoever for losses due to using this service."}];
}
......@@ -85,16 +89,27 @@ export class HomeComponent implements OnInit{
}
public searchResource(){
// @ts-ignore
this.serachRunning = true;
this.resourceService.searchResource(this.searchModel).subscribe((resources: Resource[]) => {
this.resources = resources;
this.totalResources = resources;
this.totalElements = resources.length
this.search = true;
this.serachRunning=false;
},error => {
this.messageService.add({severity: 'error', detail: 'Some error occurred!'})
this.serachRunning=false;
});
}
onPageChange(event:any) {
if (this.search === false){
var pNum = event.first / event.rows
this.resourceService.getAllResources(pNum, event.rows,)
.subscribe(ret => this.populate(ret));
}else {
this.resources = this.totalResources.slice(event.first, this.totalResources.length)
}
}
populate(ret: PageableResource) {
this.pageableResponse = ret;
......@@ -104,16 +119,20 @@ export class HomeComponent implements OnInit{
this.totalElements = this.pageableResponse.totalElements;
}
public resetSearch(){
this.serachRunning=true;
this.resourceService.getAllResources().subscribe((resources: PageableResource) => {
// @ts-ignore
this.resources = resources.content;
// @ts-ignore
this.totalElements = resources.totalElements;
this.searchModel = {};
this.search = false;
this.serachRunning=false;
});
}
isEmptySearch(){
return JSON.stringify(this.searchModel) === '{}';
}
}
......@@ -14,6 +14,7 @@
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Organization name</div><div class="my-0">{{resource.contactInstitution}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0"[ngStyle]="{color:'var(--surface-500)'}">Contact email</div><div class="my-0"></div>{{resource.contactEmail}}</div>
<div class="flex align-items-center"><div class="col-3 inline my-0"[ngStyle]="{color:'var(--surface-500)'}">Contact phone</div><div class="my-0">{{resource.contactPhone}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0"[ngStyle]="{color:'var(--surface-500)'}">Contact address</div><div class="my-0">{{resource.contactAddress}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Citation (DOI)</div><div class="overflow-text my-0">{{resource.citation}}</div></div>
</p-panel>
</div>
......@@ -66,17 +67,29 @@
<div class="col-12 pt-3 flex justify-content-center">
<div class="pr-2">
<p-button label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button>
<p-button label="Share" icon="pi pi-share-alt" class="ml-3"(click)=linkCopied(getPermLink(resource.idResource)) [loading]="false"></p-button>
</div>
<div class="pr-2" *ngIf="!resource.approved && (loggeduser| async)?.roles?.includes('ADMIN')">
<div class="pr-2" *ngIf="!resource.approved && resource.canEdit && (loggeduser| async)?.roles?.includes('ADMIN')">
<p-button label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button>
</div>
<div class="pr-2" *ngIf="(loggeduser| async)?.roles?.includes('ADMIN')">
<div class="pr-2" *ngIf="(loggeduser| async)?.roles?.includes('ADMIN') && resource.canEdit">
<p-button label="Edit" icon="pi pi-pencil" routerLink="/resource/edit/{{resourceId}}" [loading]="false"></p-button>
</div>
<div *ngIf="(loggeduser| async)?.roles?.includes('ADMIN')">
<div *ngIf="(loggeduser| async)?.roles?.includes('ADMIN') && resource.canEdit">
<p-button label="Delete" icon="pi pi-trash" (onClick)="delete($event)" [loading]="false"></p-button>
</div>
</div>
</div>
<p-toast position="bottom-center" key="bc"></p-toast>
<p-confirmDialog></p-confirmDialog>
<p-dialog id="shareModal" name="shareModal" header="Copy link to share" [(visible)]="displayModal" [style]="{width: '40vw'}">
<div class="field">
<label>Link</label>
<input id="link" type="text" [(ngModel)]="copiedLink" pInputText/>
</div>
<div class="field button-center">
<button pButton type="button" class="p-button-help" label="Ok" (click)="displayModal=false" ></button>
</div>
</p-dialog>
......@@ -20,6 +20,8 @@ export class ResourceComponent implements OnInit {
filePath = environment.baseUrl+"/resource/file";
url:any;
resourceId = null;
displayModal=false;
copiedLink="";
// @ts-ignore
public loggeduser: Observable<User> = this.store.select(UserState.userDetails);
......@@ -36,9 +38,8 @@ export class ResourceComponent implements OnInit {
}
downloadFile(fileName: any): void {
console.log("file")
this.resourceService.downloadFile(fileName).subscribe((file: any) => {
const blob = new Blob([file], {type: 'application/pdf'});
const blob = new Blob([file], {type: file.type});
this.url = window.URL.createObjectURL(blob);
/*const link = document.createElement('a');
......@@ -86,4 +87,16 @@ export class ResourceComponent implements OnInit {
showInfo() {
this.messageService.add({severity:'info', summary: 'Info', detail: 'This feature has not been implemented yet!'});
}
getPermLink(resourceId: string|undefined) {
if(resourceId != undefined){
return location.origin + '/toolbox/#/resource/' + resourceId;
}else{
return location.origin + '/toolbox/#/home';
}
}
linkCopied(link: string) {
this.copiedLink=link;
this.displayModal=true;
}
}
......@@ -20,6 +20,8 @@ export interface Resource {
contactInstitution?: string;
contactEmail?: string;
contactPhone?: string;
contactAddress?:string;
canEdit?:boolean;
citation?:string;
creationDate?:Date;
approved?:boolean;
......@@ -49,10 +51,13 @@ export class Sector{
export class Region{
public idRegion!: string;
public name!: string;
public code!:string;
}
export class Language{
public idLanguage!: string;
public name!: string;
public code!:string;
}
export class Project{
public idProject!: string;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment