integracija sa ipmdecisions

parent d9fd62d1
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
"primeng": "~13.2.1", "primeng": "~13.2.1",
"rxjs": "~6.6.0", "rxjs": "~6.6.0",
"tslib": "^2.1.0", "tslib": "^2.1.0",
"zone.js": "~0.11.4" "zone.js": "~0.11.4",
"ngx-clipboard": "~15.1.0"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^13.2.6", "@angular-devkit/build-angular": "^13.2.6",
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</div> </div>
<div class="flex justify-content-center"> <div class="flex justify-content-center">
<div class="pt-3 pr-3"> <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>
<div class="pt-3 pl-3"> <div class="pt-3 pl-3">
<p-button type="submit" label="Reset" icon="pi pi-refresh" (click)="resetSearch()" [loading]="false"></p-button> <p-button type="submit" label="Reset" icon="pi pi-refresh" (click)="resetSearch()" [loading]="false"></p-button>
...@@ -63,18 +63,18 @@ ...@@ -63,18 +63,18 @@
<p-card> <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"> <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"> <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"> <div class="pb-1 align-self-end">
<p-tag *ngIf="resource.resourceType" [rounded]=true value="{{resource.resourceType.name}}"> <p-tag *ngIf="resource.resourceType" [rounded]=true value="{{resource.resourceType.name}}">
</p-tag> </p-tag>
</div> </div>
<div class=""> <div class="" routerLink="/resource/{{resource.idResource}}">
<img [defaultImage]="'assets/sectors/multi.jpg'" [useSrcset]="true" [lazyLoad]="imagePath+'/'+resource.idResource" class="imageSizeHome"/> <img [defaultImage]="'assets/sectors/multi.jpg'" [useSrcset]="true" [lazyLoad]="imagePath+'/'+resource.idResource" class="imageSizeHome"/>
<p class="text-center">{{resource.resourceName}}</p> <p class="text-center">{{resource.resourceName}}</p>
</div> </div>
<div class="align-self-center"> <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" 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>
</div> </div>
</ng-template> </ng-template>
...@@ -83,6 +83,8 @@ ...@@ -83,6 +83,8 @@
{{item.value}} - per page {{item.value}} - per page
</ng-template> </ng-template>
</p-dataView> </p-dataView>
<div class="justify-content-center flex pt-3" *ngIf="totalElements>0">Number of results: {{totalElements}}</div>
</p-card> </p-card>
</div> </div>
</div> </div>
...@@ -12,7 +12,7 @@ import { ...@@ -12,7 +12,7 @@ import {
Sector Sector
} from "../../model/resource"; } from "../../model/resource";
import {ResourceService} from "../../service/resource.service"; import {ResourceService} from "../../service/resource.service";
import {Message} from "primeng/api"; import {Message, MessageService} from "primeng/api";
import {environment} from "../../../environments/environment"; import {environment} from "../../../environments/environment";
import {SearchModel} from "../../model/search-model"; import {SearchModel} from "../../model/search-model";
import {NavigationEnd, Router} from "@angular/router"; import {NavigationEnd, Router} from "@angular/router";
...@@ -23,6 +23,8 @@ import {NavigationEnd, Router} from "@angular/router"; ...@@ -23,6 +23,8 @@ import {NavigationEnd, Router} from "@angular/router";
}) })
export class HomeComponent implements OnInit{ export class HomeComponent implements OnInit{
resources: Resource[] = []; resources: Resource[] = [];
totalResources: Resource[] = [];
search:boolean=false;
pageableResponse?: PageableResource; pageableResponse?: PageableResource;
pageSize = 10; pageSize = 10;
totalElements: number = 0; totalElements: number = 0;
...@@ -44,14 +46,14 @@ export class HomeComponent implements OnInit{ ...@@ -44,14 +46,14 @@ export class HomeComponent implements OnInit{
selectedCrops: Crop[] = []; selectedCrops: Crop[] = [];
selectedPests:Pest[] = []; selectedPests:Pest[] = [];
selectedPestType: string | undefined; selectedPestType: string | undefined;
serachRunning= false;
searchTerm: string = ""; searchTerm: string = "";
more= false; more= false;
imagePath = environment.baseUrl+"/resource/image"; imagePath = environment.baseUrl+"/resource/image";
imagePathRaw = environment.baseUrl+"/resource/image/raw"; imagePathRaw = environment.baseUrl+"/resource/image/raw";
searchModel:SearchModel = {}; searchModel:SearchModel = {};
constructor(private resourceService:ResourceService, private router:Router) { constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService) {
this.pageableResponse = {totalElements:0} this.pageableResponse = {totalElements:0}
} }
...@@ -75,6 +77,8 @@ export class HomeComponent implements OnInit{ ...@@ -75,6 +77,8 @@ export class HomeComponent implements OnInit{
this.resources = resources.content; this.resources = resources.content;
// @ts-ignore // @ts-ignore
this.totalElements = resources.totalElements; 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."}]; 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{ ...@@ -85,16 +89,27 @@ export class HomeComponent implements OnInit{
} }
public searchResource(){ public searchResource(){
// @ts-ignore // @ts-ignore
this.serachRunning = true;
this.resourceService.searchResource(this.searchModel).subscribe((resources: Resource[]) => { this.resourceService.searchResource(this.searchModel).subscribe((resources: Resource[]) => {
this.resources = resources; this.resources = resources;
this.totalResources = resources;
this.totalElements = resources.length 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) { onPageChange(event:any) {
var pNum = event.first / event.rows if (this.search === false){
this.resourceService.getAllResources(pNum, event.rows,) var pNum = event.first / event.rows
this.resourceService.getAllResources(pNum, event.rows,)
.subscribe(ret => this.populate(ret)); .subscribe(ret => this.populate(ret));
}else {
this.resources = this.totalResources.slice(event.first, this.totalResources.length)
}
} }
populate(ret: PageableResource) { populate(ret: PageableResource) {
this.pageableResponse = ret; this.pageableResponse = ret;
...@@ -104,16 +119,20 @@ export class HomeComponent implements OnInit{ ...@@ -104,16 +119,20 @@ export class HomeComponent implements OnInit{
this.totalElements = this.pageableResponse.totalElements; this.totalElements = this.pageableResponse.totalElements;
} }
public resetSearch(){ public resetSearch(){
this.serachRunning=true;
this.resourceService.getAllResources().subscribe((resources: PageableResource) => { this.resourceService.getAllResources().subscribe((resources: PageableResource) => {
// @ts-ignore // @ts-ignore
this.resources = resources.content; this.resources = resources.content;
// @ts-ignore // @ts-ignore
this.totalElements = resources.totalElements; this.totalElements = resources.totalElements;
this.searchModel = {}; this.searchModel = {};
this.search = false;
this.serachRunning=false;
}); });
} }
isEmptySearch(){ isEmptySearch(){
return JSON.stringify(this.searchModel) === '{}'; return JSON.stringify(this.searchModel) === '{}';
} }
} }
...@@ -14,6 +14,7 @@ ...@@ -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)'}">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 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 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> <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> </p-panel>
</div> </div>
...@@ -66,17 +67,29 @@ ...@@ -66,17 +67,29 @@
<div class="col-12 pt-3 flex justify-content-center"> <div class="col-12 pt-3 flex justify-content-center">
<div class="pr-2"> <div class="pr-2">
<p-button label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button> <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>
<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> <p-button label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button>
</div> </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> <p-button label="Edit" icon="pi pi-pencil" routerLink="/resource/edit/{{resourceId}}" [loading]="false"></p-button>
</div> </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> <p-button label="Delete" icon="pi pi-trash" (onClick)="delete($event)" [loading]="false"></p-button>
</div> </div>
</div> </div>
</div> </div>
<p-toast position="bottom-center" key="bc"></p-toast> <p-toast position="bottom-center" key="bc"></p-toast>
<p-confirmDialog></p-confirmDialog> <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 { ...@@ -20,6 +20,8 @@ export class ResourceComponent implements OnInit {
filePath = environment.baseUrl+"/resource/file"; filePath = environment.baseUrl+"/resource/file";
url:any; url:any;
resourceId = null; resourceId = null;
displayModal=false;
copiedLink="";
// @ts-ignore // @ts-ignore
public loggeduser: Observable<User> = this.store.select(UserState.userDetails); public loggeduser: Observable<User> = this.store.select(UserState.userDetails);
...@@ -36,9 +38,8 @@ export class ResourceComponent implements OnInit { ...@@ -36,9 +38,8 @@ export class ResourceComponent implements OnInit {
} }
downloadFile(fileName: any): void { downloadFile(fileName: any): void {
console.log("file")
this.resourceService.downloadFile(fileName).subscribe((file: any) => { 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); this.url = window.URL.createObjectURL(blob);
/*const link = document.createElement('a'); /*const link = document.createElement('a');
...@@ -86,4 +87,16 @@ export class ResourceComponent implements OnInit { ...@@ -86,4 +87,16 @@ export class ResourceComponent implements OnInit {
showInfo() { showInfo() {
this.messageService.add({severity:'info', summary: 'Info', detail: 'This feature has not been implemented yet!'}); 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 { ...@@ -20,6 +20,8 @@ export interface Resource {
contactInstitution?: string; contactInstitution?: string;
contactEmail?: string; contactEmail?: string;
contactPhone?: string; contactPhone?: string;
contactAddress?:string;
canEdit?:boolean;
citation?:string; citation?:string;
creationDate?:Date; creationDate?:Date;
approved?:boolean; approved?:boolean;
...@@ -49,10 +51,13 @@ export class Sector{ ...@@ -49,10 +51,13 @@ export class Sector{
export class Region{ export class Region{
public idRegion!: string; public idRegion!: string;
public name!: string; public name!: string;
public code!:string;
} }
export class Language{ export class Language{
public idLanguage!: string; public idLanguage!: string;
public name!: string; public name!: string;
public code!:string;
} }
export class Project{ export class Project{
public idProject!: string; 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