integracija sa backendom - in progress

parent 07c56dba
......@@ -43,3 +43,4 @@ testem.log
# System Files
.DS_Store
Thumbs.db
/.gradle/
......@@ -8,7 +8,7 @@ import {ButtonModule} from 'primeng/button';
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import {HomeComponent} from './component/home/home.component';
import {AccordionModule} from 'primeng/accordion';
import {SharedModule} from "primeng/api";
import {MessageService, SharedModule} from "primeng/api";
import {CheckboxModule} from 'primeng/checkbox';
import {FormsModule} from "@angular/forms";
import {DataViewModule} from "primeng/dataview";
......@@ -26,6 +26,10 @@ import { AddResourceComponent } from './component/add-resource/add-resource.comp
import {InputTextareaModule} from "primeng/inputtextarea";
import {RadioButtonModule} from "primeng/radiobutton";
import {FileUploadModule} from "primeng/fileupload";
import {ChipsModule} from 'primeng/chips';
import {MessagesModule} from 'primeng/messages';
import {MessageModule} from 'primeng/message';
import {ToastModule} from 'primeng/toast';
@NgModule({
......@@ -61,9 +65,13 @@ import {FileUploadModule} from "primeng/fileupload";
ButtonModule,
RadioButtonModule,
InputTextareaModule,
FileUploadModule
FileUploadModule,
ChipsModule,
MessagesModule,
MessageModule,
ToastModule
],
providers: [],
providers: [MessageService],
bootstrap: [AppComponent]
})
export class AppModule { }
.button-center{
display: flex;
justify-content: space-around;
}
......@@ -4,38 +4,104 @@
<div class="p-field p-grid">
<label for="title" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Title</label>
<div class="p-col-12 p-md-10">
<input id="title" type="text" pInputText>
<input id="title" type="text" pInputText [(ngModel)]="resource.resourceName">
</div>
</div>
<div class="p-field p-grid">
<label for="description" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Description</label>
<div class="p-col-12 p-md-10">
<textarea id="description" type="text" rows="4" pInputTextarea></textarea>
<textarea id="description" type="text" rows="4" pInputTextarea [(ngModel)]="resource.description"></textarea>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Sectors</label>
<div class="p-col-12 p-md-10">
<p-multiSelect defaultLabel="Select sector/crop" [options]="sectors" optionLabel="value"> </p-multiSelect>
<p-multiSelect defaultLabel="Select sector" [options]="sectors" optionLabel="name" [(ngModel)]="resource.sectors"> </p-multiSelect>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Regions</label>
<div class="p-col-12 p-md-10">
<p-multiSelect defaultLabel="Select region" [options]="regions" optionLabel="value"></p-multiSelect>
<p-multiSelect defaultLabel="Select region" [options]="regions" optionLabel="name" [(ngModel)]="resource.regions"></p-multiSelect>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Content type</label>
<div class="p-col-12 p-md-10">
<p-dropdown [options]="contentTypes" optionLabel="value" placeholder="Select content type"></p-dropdown>
<p-dropdown [options]="resourceTypes" optionLabel="name" placeholder="Select content type" [(ngModel)]="resource.resourceType"></p-dropdown>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Language</label>
<div class="p-col-12 p-md-10">
<p-dropdown [options]="languages" optionLabel="value" placeholder="Select language"></p-dropdown>
<p-dropdown [options]="languages" optionLabel="name" placeholder="Select language" [(ngModel)]="resource.language"></p-dropdown>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Keywords</label>
<div class="p-col-12 p-md-10">
<p-chips [(ngModel)]="resource.keywordsTemp" [max]=5 placeholder="Enter keywords" [allowDuplicate]=false></p-chips>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Upload image</label>
<div class="p-col-12 p-md-10">
<p-fileUpload name="image" [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('image',$event)"></p-fileUpload>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Upload resource content</label>
<div class="p-col-12 p-md-10">
<p-fileUpload name="resources" [multiple]=true [fileLimit]=5 [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('content',$event)"></p-fileUpload>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Project</label>
<div class="p-col-12 p-md-10">
<p-dropdown [options]="projects" optionLabel="name" placeholder="Select project" [(ngModel)]="resource.project"></p-dropdown>
</div>
</div>
<div class="p-field p-grid">
<label class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Links</label>
<div class="p-col-12 p-md-10">
<p-chips [(ngModel)]="resource.links" [max]=5 placeholder="Enter relevant links" [allowDuplicate]=false></p-chips>
</div>
</div>
<div class="p-field p-grid">
<label for="source" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Original source</label>
<div class="p-col-12 p-md-10">
<input id="source" type="text" pInputText [(ngModel)]="resource.resourceOrigin">
</div>
</div>
<div class="p-field p-grid">
<label for="contactName" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Contact name</label>
<div class="p-col-12 p-md-10">
<input id="contactName" type="text" pInputText [(ngModel)]="resource.contactName">
</div>
</div>
<div class="p-field p-grid">
<label for="contactOrg" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Contact institution</label>
<div class="p-col-12 p-md-10">
<input id="contactOrg" type="text" pInputText [(ngModel)]="resource.contactInstitution">
</div>
</div>
<div class="p-field p-grid">
<label for="contactEmail" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Contact email</label>
<div class="p-col-12 p-md-10">
<input id="contactEmail" type="text" pInputText [(ngModel)]="resource.contactEmail">
</div>
</div>
<div class="p-field p-grid">
<label for="contactPhone" class="p-col-12 p-mb-2 p-md-2 p-mb-md-0">Contact phone</label>
<div class="p-col-12 p-md-10">
<input id="contactPhone" type="text" pInputText [(ngModel)]="resource.contactPhone">
</div>
</div>
</div>
<div class="p-col-12 p-pt-3 button-center">
<p-button label="Save resource" icon="pi pi-save"[loading]="false" (click)="saveResource()"></p-button>
</div>
</div>
<p-toast></p-toast>
import { Component, OnInit } from '@angular/core';
import {ContentType, Language, Region, Sector} from "../../model/resource";
import {ResourceType, Language, Region, Sector, Project, Resource} from "../../model/resource";
import {ResourceService} from "../../service/resource.service";
import {MessageService} from 'primeng/api';
import {Router} from "@angular/router";
@Component({
selector: 'app-add-resource',
......@@ -10,15 +13,51 @@ import {ResourceService} from "../../service/resource.service";
export class AddResourceComponent implements OnInit {
sectors: Sector[] = [];
regions: Region[] = [];
contentTypes: ContentType[] = [];
resourceTypes: ResourceType[] = [];
languages: Language[] = [];
constructor(private resourceService:ResourceService) { }
projects: Project[] = [];
resource: Resource = {};
image: any;
resourceContent: File[] = [];
constructor(private resourceService:ResourceService,private messageService: MessageService, private router: Router) { }
ngOnInit(): void {
this.sectors = this.resourceService.getAllSectors();
this.regions = this.resourceService.getAllRegions();
this.contentTypes = this.resourceService.getAllContentTypes();
this.languages = this.resourceService.getAllLanguages();
this.resourceService.getAllSectors().subscribe((sectors: Sector[]) => {
this.sectors = sectors;});
this.resourceService.getAllRegions().subscribe((regions: Region[]) => {
this.regions = regions;});
this.resourceService.getAllResourceTypes().subscribe((contentTypes: ResourceType[]) => {
this.resourceTypes = contentTypes;});
this.resourceService.getAllLanguages().subscribe((languages: Language[]) => {
this.languages = languages;});
this.resourceService.getAllProjects().subscribe((projects: Project[]) => {
this.projects = projects;});
}
saveResource(){
this.resourceService.saveResource(this.resource).subscribe((data: Resource) => {
this.resource = data;
this.resourceService.addFiles(this.image,this.resourceContent,this.resource.idResource).
subscribe(data =>{
this.messageService.add({severity:'success', detail:'Resource is saved!'});
this.router.navigate(['/home']);
},error =>{
this.messageService.add({severity: 'error', detail: 'Some error occurred!'})
});
},error => {
//TODO obrisati sve fajlove koji su se mozda sacuvali ako je doslo do greske
this.messageService.add({severity: 'error', detail: 'Some error occurred!'})
});
}
public fileUploader(type:string,event:any){
if(type === 'image'){
this.image = event.files[0]
}else{
this.resourceContent = event.files;
}
}
}
<p-messages [(value)]="disclaimer" [enableService]="false"></p-messages>
<div class="p-grid p-pt-6 p-pl-6">
<div class="p-col-3">
<h3>Sectors</h3>
<p-multiSelect defaultLabel="Select sector/crop" [options]="sectors" [(ngModel)]="selectedSectors" optionLabel="value"></p-multiSelect>
<p-multiSelect defaultLabel="Select sector" [options]="sectors" [(ngModel)]="selectedSectors" optionLabel="name"></p-multiSelect>
<h3>Regions</h3>
<p-multiSelect defaultLabel="Select region" [options]="regions" [(ngModel)]="selectedRegions" optionLabel="value"></p-multiSelect>
<p-multiSelect defaultLabel="Select region" [options]="regions" [(ngModel)]="selectedRegions" optionLabel="name"></p-multiSelect>
<h3>Resource types</h3>
<p-multiSelect defaultLabel="Select resource type" [options]="contentTypes" [(ngModel)]="selectedTypes" optionLabel="value"></p-multiSelect>
<p-multiSelect defaultLabel="Select resource type" [options]="contentTypes" [(ngModel)]="selectedTypes" optionLabel="name"></p-multiSelect>
<h3>Languages</h3>
<p-multiSelect defaultLabel="Select language" [options]="languages" [(ngModel)]="selectedLanguages" optionLabel="value"></p-multiSelect>
<p-multiSelect defaultLabel="Select language" [options]="languages" [(ngModel)]="selectedLanguages" optionLabel="name"></p-multiSelect>
<div class="button-right p-pt-3" *ngIf="!more">
<button pButton type="button" pTooltip="More filters..." icon="pi pi-plus" class="p-button-text p-button-sm p-button-rounded p-button-outlined " (click)="toggleFilters()"></button>
......@@ -21,13 +23,10 @@
</div>
<div *ngIf="more">
<h3>Keywords</h3>
<p-multiSelect defaultLabel="Select keywords" [options]="keywords" [(ngModel)]="selectedKeywords" optionLabel="value" [selectionLimit]='3'></p-multiSelect>
<p-multiSelect defaultLabel="Select keywords" [options]="keywords" [(ngModel)]="selectedKeywords" optionLabel="name" [selectionLimit]='3'></p-multiSelect>
<h3>Projects</h3>
<p-multiSelect defaultLabel="Select project" [options]="keywords" [(ngModel)]="selectedKeywords" optionLabel="value" [selectionLimit]='3'></p-multiSelect>
<h3>Organisations</h3>
<p-multiSelect defaultLabel="Select organisation" [options]="keywords" [(ngModel)]="selectedKeywords" optionLabel="value" [selectionLimit]='3'></p-multiSelect>
<p-multiSelect defaultLabel="Select project" [options]="projects" [(ngModel)]="selectedProjects" optionLabel="name" [selectionLimit]='3'></p-multiSelect>
<h3>Arbitrary text search</h3>
<input type="text" pInputText [(ngModel)]="searchTerm"/>
......@@ -45,26 +44,26 @@
<p-dataView #dv [value]="resources" [paginator]="true" [rows]="6" layout="grid">
<ng-template let-resource pTemplate="gridItem">
<div class="p-col-12 p-md-4">
<p-card header="{{resource.title}}" subheader="" styleClass="p-card-shadow">
<p-card header="{{resource.resourceName}}" subheader="" styleClass="p-card-shadow">
<ng-template pTemplate="header">
<div class="p-pb-1 button-right">
<p-tag *ngIf="resource.contentType" [rounded]=true value="{{resource.contentType.value}}">
<p-tag *ngIf="resource.resourceType" [rounded]=true value="{{resource.resourceType.name}}">
</p-tag>
</div>
<img alt="Card" [src]="resource.imagePath">
<img class="flag" alt="Card" [src]="'assets/flags/'+resource.language.toLowerCase()+'.svg'">
<img alt="Card" [src]="imagePath+'/'+resource.idResource">
<img class="flag" alt="Card" [src]="'assets/flags/'+resource.language.name.toLowerCase()+'.svg'">
</ng-template>
<div *ngFor="let sector of resource.relevantSectors" class="horizontal">
<ng-container [ngSwitch]=sector.sectorId>
<img *ngSwitchCase="1" class="sector" [src]="'assets/sectors/arable.svg'" pTooltip="{{sector.value}}">
<img *ngSwitchCase="5" class="sector" [src]="'assets/sectors/greenhouse.svg'" pTooltip="{{sector.value}}">
<img *ngSwitchCase="3" class="sector"[src]="'assets/sectors/orchard.svg'" pTooltip="{{sector.value}}">
<img *ngSwitchCase="4" class="sector"[src]="'assets/sectors/vegetables.svg'" pTooltip="{{sector.value}}">
<img *ngSwitchCase="2" class="sector" [src]="'assets/sectors/vineyard.svg'" pTooltip="{{sector.value}}">
<ng-container [ngSwitch]=sector.idSector>
<img *ngSwitchCase="1" class="sector" [src]="'assets/sectors/arable.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="5" class="sector" [src]="'assets/sectors/greenhouse.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="3" class="sector"[src]="'assets/sectors/orchard.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="4" class="sector"[src]="'assets/sectors/vegetables.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="2" class="sector" [src]="'assets/sectors/vineyard.svg'" pTooltip="{{sector.name}}">
</ng-container>
</div>
<ng-template pTemplate="footer">
<button pButton type="button" routerLink="/resource/{{resource.resourceId}}" icon="pi pi-forward" class="p-button-outlined p-mr-4" pTooltip="See more..."></button>
<button pButton type="button" routerLink="/resource/{{resource.idResource}}" icon="pi pi-forward" class="p-button-outlined p-mr-4" pTooltip="See more..."></button>
<button pButton type="button" icon="pi pi-share-alt" class="p-button-outlined" pTooltip="Share"></button>
</ng-template>
</p-card>
......
import { Component, OnInit } from '@angular/core';
import {ContentType, Keyword, Language, Region, Resource, Sector} from "../../model/resource";
import {Keyword, Language, Project, Region, Resource, ResourceType, Sector} from "../../model/resource";
import {ResourceService} from "../../service/resource.service";
import {Message} from "primeng/api";
import {environment} from "../../../environments/environment";
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
......@@ -10,28 +12,40 @@ export class HomeComponent implements OnInit {
resources: Resource[] = [];
sectors: Sector[] = [];
regions: Region[] = [];
contentTypes: ContentType[] = [];
projects: Project[] = [];
contentTypes: ResourceType[] = [];
languages: Language[] = [];
keywords: Keyword[] = [];
disclaimer: Message[] = [];
selectedSectors: Sector[] = [];
selectedRegions: Region[] = [];
selectedTypes: ContentType[] = [];
selectedTypes: ResourceType[] = [];
selectedLanguages: Language[] = [];
selectedKeywords: Keyword[] = [];
selectedProjects: Project[] = [];
searchTerm: string = "";
more= false;
imagePath = environment.baseUrl+"/resource/image";
constructor(private resourceService:ResourceService) { }
ngOnInit(): void {
this.sectors = this.resourceService.getAllSectors();
this.regions = this.resourceService.getAllRegions();
this.contentTypes = this.resourceService.getAllContentTypes();
this.languages = this.resourceService.getAllLanguages();
this.resources = this.resourceService.getAllResources()
this.keywords = this.resourceService.getAllKeywords()
this.resourceService.getAllProjects().subscribe((projects: Project[]) => {
this.projects = projects;});
this.resourceService.getAllSectors().subscribe((sectors: Sector[]) => {
this.sectors = sectors;});
this.resourceService.getAllRegions().subscribe((regions: Region[]) => {
this.regions = regions;});
this.resourceService.getAllResourceTypes().subscribe((contentTypes: ResourceType[]) => {
this.contentTypes = contentTypes;});
this.resourceService.getAllLanguages().subscribe((languages: Language[]) => {
this.languages = languages;});
this.resourceService.getAllKeywords().subscribe((keywords: Keyword[]) => {
this.keywords = keywords;})
this.resourceService.getAllResources().subscribe((resources: Resource[]) => {
this.resources = resources;});
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."}];
}
public toggleFilters(){
......
.imageSize{
width:100%;
}
.horizontal{
padding:5px;
display: inline-block;
}
.sector{
width:25px;
height:25px;
}
.button-center{
display: flex;
justify-content: space-around;
}
<div class="p-grid p-pt-6 p-pl-6">
<div class="p-col-6">
<p>ovde ide detaljan opis resursa sa linkovima itd</p>
<p-card header="{{resource.resourceName}}" >
<div *ngFor="let keyword of resource.keywords" class="horizontal">
<p-tag value=" {{keyword.name}}"></p-tag>
</div>
<div>
{{resource.language?.name}}
</div>
<div *ngFor="let sector of resource.sectors" class="horizontal">
<ng-container [ngSwitch]=sector.idSector>
<img *ngSwitchCase="1" class="sector" [src]="'assets/sectors/arable.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="5" class="sector" [src]="'assets/sectors/greenhouse.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="3" class="sector"[src]="'assets/sectors/orchard.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="4" class="sector"[src]="'assets/sectors/vegetables.svg'" pTooltip="{{sector.name}}">
<img *ngSwitchCase="2" class="sector" [src]="'assets/sectors/vineyard.svg'" pTooltip="{{sector.name}}">
</ng-container>
</div>
<div>
<div *ngFor="let region of resource.regions" class="horizontal">
<img class="sector" alt="Card" [src]="'assets/flags/'+region.name.toLowerCase()+'.svg'" pTooltip="{{region.name}}">
</div>
</div>
<hr/>
<div class="p-text-italic" [ngStyle]="{color:'var(--green-200)'}">
Date of upload:{{resource.idResource}}
</div>
<div class="p-text-italic" [ngStyle]="{color:'var(--green-200)'}">
Uploaded by: {{resource.idResource}}
</div>
<div> <h3>Summary description</h3>{{resource.description}}</div>
</p-card>
</div>
<div class="p-col-3">
<img alt="Card" [src]="imagePath+'/'+resource.idResource" class="imageSize">
<div>
<h3>Links and downloads</h3>
<div *ngFor="let link of resource.links" >
<a href="{{link}}">{{link}}</a>
</div>
</div>
</div>
<div class="p-col-12 p-pt-3 button-center">
<p-button label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {ResourceService} from "../../service/resource.service";
import {ActivatedRoute} from "@angular/router";
import {environment} from "../../../environments/environment";
import {Resource} from "../../model/resource";
@Component({
selector: 'app-resource',
......@@ -6,10 +10,18 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./resource.component.css']
})
export class ResourceComponent implements OnInit {
resource: Resource ={};
imagePath = environment.baseUrl+"/resource/image";
constructor() { }
constructor(private resourceService:ResourceService, private route: ActivatedRoute) { }
ngOnInit(): void {
const id = this.route.snapshot.paramMap.get('id');
// @ts-ignore
this.resourceService.getResource(id).subscribe(data =>{
this.resource =data;
});
}
}
[
{
"keywordId": 1,
"value": "IPM technique"
},
{
"keywordId": 2,
"value":"Economic Threshold"
},
{
"keywordId": 3,
"value":"DSS"
},
{
"keywordId": 4,
"value":"EU project"
},
{
"keywordId": 5,
"value":"Forecasts"
},
{
"keywordId": 6,
"value":"Monitoring tools"
},
{
"keywordId": 7,
"value":"Other"
}
]
[
{
"languageId": 1,
"value": "English"
},
{
"resourceTypeId": 2,
"value":"Spanish"
},
{
"resourceTypeId": 3,
"value":"German"
},
{
"resourceTypeId": 4,
"value":"French"
},
{
"resourceTypeId": 5,
"value":"Italian"
},
{
"resourceTypeId": 6,
"value":"Dutch"
},
{
"resourceTypeId": 7,
"value":"Serbian"
}
]
[
{
"regionId": 1,
"value": "Serbia"
},
{
"regionId": 2,
"value": "Italy"
},
{
"regionId": 3,
"value": "France"
},
{
"regionId": 4,
"value": "Germany"
}
]
[
{
"resourceId": 1,
"title": "Resource 1",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset1.jpg",
"language": "Italian",
"relevantSectors": [{
"sectorId": 1,
"value": "Arable field crops"
},
{
"sectorId": 2,
"value":"Vineyard"
}
],
"contentType": {
"resourceTypeId": 6,
"value":"Monitoring tools"
}
},
{
"resourceId": 2,
"title": "Resource 2",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset2.jpg",
"language": "German",
"contentType": {
"resourceTypeId": 5,
"value":"Forecasts"
},
"relevantSectors": [{
"sectorId": 1,
"value": "Arable field crops"
},
{
"sectorId": 4,
"value":"Outdoor vegetables, soft fruits and ornamentals"
},
{
"sectorId": 2,
"value":"Vineyard"
}
]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"title": "Resource 5",
"description": "Some description",
"rating": 1,
"imagePath": "assets/logo.png",
"language": "English",
"contentType":{
"resourceTypeId": 3,
"value":"DSS"
},
"relevantSectors": [ {
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
}
,
{
"resourceId": 5,
"title": "Resource 5",
"description": "Some description",
"rating": 1,
"imagePath": "assets/asset5.jpg",
"language": "French",
"contentType": {
"resourceTypeId": 4,
"value":"EU project"
},
"relevantSectors": [{
"sectorId": 1,
"value": "Arable field crops"
},
{
"sectorId": 4,
"value":"Outdoor vegetables, soft fruits and ornamentals"
},
{
"sectorId": 2,
"value":"Vineyard"
}
]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
},
{
"resourceId": 3,
"title": "Resource 3",
"description": "Some description",
"rating": 5,
"imagePath": "assets/asset3.jpg",
"language": "English",
"contentType": {
"resourceTypeId": 1,
"value": "IPM technique"
},
"relevantSectors": [{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
},
{
"resourceId": 4,
"title": "Resource 4",
"description": "Some description",
"rating": 3,
"imagePath": "assets/asset4.jpg",
"language": "Serbian",
"contentType": {
"resourceTypeId": 2,
"value":"Economic Threshold"
},
"relevantSectors": [{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}]
}
]
[
{
"sectorId": 1,
"value": "Arable field crops"
},
{
"sectorId": 2,
"value":"Vineyard"
},
{
"sectorId": 3,
"value":"Orchards"
},
{
"sectorId": 4,
"value":"Outdoor vegetables, soft fruits and ornamentals"
},
{
"sectorId": 5,
"value":"Greenhouse and protected horticulture"
}
]
[
{
"resourceTypeId": 1,
"value": "IPM technique"
},
{
"resourceTypeId": 2,
"value":"Economic Threshold"
},
{
"resourceTypeId": 3,
"value":"DSS"
},
{
"resourceTypeId": 4,
"value":"EU project"
},
{
"resourceTypeId": 5,
"value":"Forecasts"
},
{
"resourceTypeId": 6,
"value":"Monitoring tools"
},
{
"resourceTypeId": 7,
"value":"Other"
}
]
export interface Resource {
resourceId?: number;
title?: string;
idResource?: string;
resourceName?: string;
description?: string;
contentType: ContentType;
relevantSectors: Sector[];
relevantRegions: Region[];
imagePath?: string;
files: string[];
links:string[];
originalSource: string;
keywords:string[];
language: string;
contactName: string;
contactInstitution: string;
contactDetails: string;
rating?: number;
links?:string[];
resourceOrigin?: string;
resourceType?: ResourceType;
sectors?: Sector[];
regions?: Region[];
keywordsTemp?:string[];
keywords?: Keyword[];
language?: Language;
project?: Project;
contactName?: string;
contactInstitution?: string;
contactEmail?: string;
contactPhone?: string;
}
export class ContentType{
public resourceTypeId!:number;
public value!: string;
export class ResourceType{
public idResourceType!:string;
public name!: string;
}
export class Sector{
public sectorId!: number;
public value!: string;
public idSector!: string;
public name!: string;
}
export class Region{
public regionId!: number;
public value!: string;
public idRegion!: string;
public name!: string;
}
export class Language{
public languageId!: number;
public value!: string;
public idLanguage!: string;
public name!: string;
}
export class Project{
public idProject!: string;
public name!: string;
public description!: string;
}
export class Keyword{
public keywordId!: number;
public value!: string;
public idKeyword!: string;
public name!: string;
}
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import resources from '../json_mockup/resources.json';
import sectors from '../json_mockup/sectors.json'
import regions from '../json_mockup/regions.json'
import types from '../json_mockup/types.json'
import languages from '../json_mockup/language.json'
import keywords from '../json_mockup/keywords.json'
import {AppConfig} from "../../config/app.config";
import {ResourceType, Language, Region, Resource, Sector, Project, Keyword} from "../model/resource";
@Injectable({
providedIn: 'root'
......@@ -22,24 +17,41 @@ export class ResourceService {
this._httpClient = httpClient;
}
public getAllResources() {
//return this._httpClient.get<Resource[]>(`${AppConfig.ApiPaths.getAllResources}`);
//this is just mockup of backend
return resources;
return this._httpClient.get<Resource[]>(`${AppConfig.ApiPaths.getAllResources}`);
}
public getResource(id:number) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.getResource}`+"/"+id);
}
public saveResource(resource: Resource) {
return this._httpClient.post<Resource>(`${AppConfig.ApiPaths.saveResource}`, resource);
}
public addFiles(image:File,resourceContent:File[],idResource:any){
const formData: FormData = new FormData();
formData.append("image", image);
resourceContent.forEach(r =>{
formData.append("files",r);
})
return this._httpClient.post(`${AppConfig.ApiPaths.addFile}`+"/"+idResource,formData)
}
public getAllSectors() {
return sectors;
return this._httpClient.get<Sector[]>(`${AppConfig.ApiPaths.getAllSectors}`);
}
public getAllRegions() {
return regions;
return this._httpClient.get<Region[]>(`${AppConfig.ApiPaths.getAllRegions}`);
}
public getAllContentTypes() {
return types;
public getAllResourceTypes() {
return this._httpClient.get<ResourceType[]>(`${AppConfig.ApiPaths.getAllResourceTypes}`);
}
public getAllLanguages() {
return languages;
return this._httpClient.get<Language[]>(`${AppConfig.ApiPaths.getAllLanguages}`);
}
public getAllProjects() {
return this._httpClient.get<Project[]>(`${AppConfig.ApiPaths.getAllProjects}`);
}
public getAllKeywords() {
return keywords;
return this._httpClient.get<Keyword[]>(`${AppConfig.ApiPaths.getAllKeywords}`);
}
}
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<rect y="85.331" style="fill:#F0F0F0;" width="512" height="341.337"/>
<rect y="85.331" style="fill:#0052B4;" width="170.663" height="341.337"/>
<rect x="341.337" y="85.331" style="fill:#D80027;" width="170.663" height="341.337"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<polygon style="fill:#F0F0F0;" points="341.334,85.33 170.666,85.33 0,85.33 0,426.662 170.666,426.662 341.334,426.662
512,426.662 512,85.33 "/>
<rect y="85.333" style="fill:#6DA544;" width="170.663" height="341.337"/>
<rect x="341.337" y="85.333" style="fill:#D80027;" width="170.663" height="341.337"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
......@@ -5,7 +5,23 @@ export class AppConfig {
public static Origin: string = environment.baseUrl;
public static ApiPaths = {
getAllResources: `${AppConfig.Origin}/getAllResources`,
getAllResources: `${AppConfig.Origin}/resource/getAllResources`,
getResource: `${AppConfig.Origin}/resource/get`,
saveResource: `${AppConfig.Origin}/resource/saveResource`,
addFile: `${AppConfig.Origin}/resource/add`,
getAllLanguages: `${AppConfig.Origin}/codebooks/getAllLanguages`,
getAllSectors: `${AppConfig.Origin}/codebooks/getAllSectors`,
getAllRegions: `${AppConfig.Origin}/codebooks/getAllRegions`,
getAllResourceTypes: `${AppConfig.Origin}/codebooks/getAllResourceTypes`,
getAllProjects: `${AppConfig.Origin}/codebooks/getAllProjects`,
getAllKeywords: `${AppConfig.Origin}/codebooks/getAllKeywords`
};
......
export const environment = {
production: true,
baseUrl: 'http://localhost:8080/ipmworks-back'
baseUrl: 'http://localhost:8080/ipmworks'
};
......@@ -4,7 +4,7 @@
export const environment = {
production: false,
baseUrl: 'http://localhost:8080'
baseUrl: 'http://localhost:8080/ipmworks'
};
/*
......
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