some minor changes

parent df535bda
#Sun May 30 15:06:06 CEST 2021
gradle.version=6.7
#Fri Feb 17 18:28:47 CET 2023
gradle.version=7.6
......@@ -7,6 +7,47 @@
"newProjectRoot": "projects",
"projects": {
"ipmworks-web": {
"i18n": {
"sourceLocale": "en",
"locales": {
"sr": {
"translation": "src/locale/messages.sr.xlf"
},
"it": {
"translation": "src/locale/messages.it.xlf"
},
"pt": {
"translation": "src/locale/messages.pt.xlf"
},
"pl": {
"translation": "src/locale/messages.pl.xlf"
},
"fi": {
"translation": "src/locale/messages.fi.xlf"
},
"fr": {
"translation": "src/locale/messages.fr.xlf"
},
"el": {
"translation": "src/locale/messages.el.xlf"
},
"sl": {
"translation": "src/locale/messages.sl.xlf"
},
"es": {
"translation": "src/locale/messages.es.xlf"
},
"nl": {
"translation": "src/locale/messages.nl.xlf"
},
"da": {
"translation": "src/locale/messages.da.xlf"
},
"de": {
"translation": "src/locale/messages.de.xlf"
}
}
},
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
......@@ -20,6 +61,8 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"localize": true,
"aot": true,
"outputPath": "dist/ipmworks-web",
"index": "src/index.html",
"baseHref": "/toolbox/",
......@@ -35,7 +78,9 @@
"./node_modules/primeicons/primeicons.css",
"./node_modules/primeng/resources/themes/mdc-light-indigo/theme.css",
"./node_modules/primeng/resources/primeng.css",
"./node_modules/primeflex/primeflex.css"
"./node_modules/primeflex/primeflex.css",
"./node_modules/quill/dist/quill.core.css",
"./node_modules/quill/dist/quill.snow.css"
],
"scripts": []
},
......@@ -47,12 +92,12 @@
{
"type": "initial",
"maximumWarning": "10mb",
"maximumError": "5mb"
"maximumError": "10mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "5mb",
"maximumError": "4kb"
"maximumWarning": "10mb",
"maximumError": "10mb"
}
],
"fileReplacements": [
......
......@@ -10,8 +10,8 @@ repositories {
}
node {
version = '14.15.5'
npmVersion = '6.14.11'
version = '18.13.0'
npmVersion = '9.4.0'
download = true
}
......
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,19 +22,21 @@
"@ngxs/store": "^3.5.0",
"lazysizes": "^5.3.2",
"ng-lazyload-image": "^9.1.2",
"ngx-clipboard": "~15.1.0",
"primeflex": "~3.1.3",
"primeicons": "~5.0.0",
"primeng": "~13.2.1",
"quill": "^1.3.7",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4",
"ngx-clipboard": "~15.1.0"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.2.6",
"@angular/cdk": "~13.2.6",
"@angular/cli": "~13.2.6",
"@angular/compiler-cli": "~13.2.6",
"@angular/localize": "~13.2.6",
"@types/jasmine": "~3.10.3",
"@types/node": "^14.0.0",
"jasmine-core": "~4.0.1",
......@@ -43,6 +45,7 @@
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"lite-server": "^2.6.1",
"typescript": "~4.4.2"
}
}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import {NgModule, OnInit} from '@angular/core';
import {ActivatedRoute, Router, RouterModule, Routes} from '@angular/router';
import {HomeComponent} from './component/home/home.component';
import {ResourceComponent} from "./component/resource/resource.component";
import {AddResourceComponent} from "./component/add-resource/add-resource.component";
......@@ -7,15 +7,20 @@ import {ApproveResourceComponent} from "./component/approve-resource/approve-res
import {LoginComponent} from "./component/login/login.component";
import {AuthGuard} from "./guard/auth.guard";
import {ChangePasswordComponent} from "./component/change-password/change-password.component";
import {HelpComponent} from "./component/help/help.component";
import {AppComponent} from "./app.component";
const routes: Routes = [
{path: '', component: HomeComponent, pathMatch: 'full'},
{path: 'export', component: HomeComponent, pathMatch: 'full',data:{header:"none"}},
{path: 'home', component: HomeComponent, pathMatch: 'full'},
{path:'resource/approve', component:ApproveResourceComponent, pathMatch:'full',canActivate:[AuthGuard]},
{path:'resource/add', component:AddResourceComponent, pathMatch:'full'},
{path:'resource/edit/:id',component:AddResourceComponent,pathMatch:'full',canActivate:[AuthGuard]},
{path:'resource/:id/:lang', component:ResourceComponent, pathMatch:'full'},
{path:'resource/:id', component:ResourceComponent, pathMatch:'full'},
{path:'login', component:LoginComponent, pathMatch:'full'},
{path:'help', component:HelpComponent, pathMatch:'full'},
{path:'changePassword/:token', component:ChangePasswordComponent, pathMatch:'full'}
......@@ -23,7 +28,9 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forRoot(routes,{ onSameUrlNavigation: 'reload' })],
imports: [RouterModule.forRoot(routes,{onSameUrlNavigation: 'reload', scrollPositionRestoration: 'enabled'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
export class AppRoutingModule{
}
<app-header-menu></app-header-menu>
<app-header-menu [hideheader]="hideheader"> </app-header-menu>
<div class="container-fluid py-4">
<router-outlet></router-outlet>
</div>
......
import {Component, OnDestroy, OnInit} from "@angular/core";
import {LogoutAction, UserState} from "./states/user.state";
import {filter, takeUntil} from "rxjs/operators";
import {NavigationEnd, Router} from "@angular/router";
import {MenuItem, MessageService, PrimeNGConfig} from "primeng/api";
import {Select, Store} from "@ngxs/store";
import {Observable, Subject} from "rxjs";
import {User} from "./model/user";
import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
@Component({
......@@ -14,9 +8,17 @@ import {User} from "./model/user";
styleUrls: ['./app.component.css']
})
export class AppComponent{
export class AppComponent implements OnInit{
title = 'ipmworks-web';
constructor(private primengConfig: PrimeNGConfig, private store: Store, private router: Router,private messageService: MessageService) {}
hideheader?:string
constructor(public router:Router,public route:ActivatedRoute) {
}
ngOnInit(): void {
this.router.events.subscribe(e => {
this.hideheader = this.route.root.firstChild?.snapshot.data['header'];
});
}
}
......
import { NgModule } from '@angular/core';
import {LOCALE_ID, NgModule} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
......@@ -13,7 +13,6 @@ import {CheckboxModule} from 'primeng/checkbox';
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {DataViewModule} from "primeng/dataview";
import {RatingModule} from "primeng/rating";
import {RouterModule} from "@angular/router";
import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http";
import {MultiSelectModule} from 'primeng/multiselect';
import {DropdownModule} from "primeng/dropdown";
......@@ -21,8 +20,8 @@ import {InputTextModule} from "primeng/inputtext";
import {TooltipModule} from "primeng/tooltip";
import {CardModule} from "primeng/card";
import {TagModule} from "primeng/tag";
import { ResourceComponent } from './component/resource/resource.component';
import { AddResourceComponent } from './component/add-resource/add-resource.component';
import {ResourceComponent } from './component/resource/resource.component';
import {AddResourceComponent } from './component/add-resource/add-resource.component';
import {InputTextareaModule} from "primeng/inputtextarea";
import {RadioButtonModule} from "primeng/radiobutton";
import {FileUploadModule} from "primeng/fileupload";
......@@ -47,10 +46,19 @@ import {ImageModule} from "primeng/image";
import {ConfirmPopupModule} from 'primeng/confirmpopup';
import {ConfirmationService} from 'primeng/api';
import {ConfirmDialogModule} from "primeng/confirmdialog";
import {LAZYLOAD_IMAGE_HOOKS, LazyLoadImageModule, ScrollHooks} from 'ng-lazyload-image';
import { FooterComponent } from './component/footer/footer.component';
import { ChangePasswordComponent } from './component/change-password/change-password.component';
import { CheckPasswordDirective } from './validator/check-password.directive';
import {LazyLoadImageModule} from 'ng-lazyload-image';
import {FooterComponent } from './component/footer/footer.component';
import {ChangePasswordComponent } from './component/change-password/change-password.component';
import {CheckPasswordDirective } from './validator/check-password.directive';
import {BadgeModule} from "primeng/badge";
import {ClipboardModule } from 'ngx-clipboard';
import {AvatarModule} from 'primeng/avatar';
import {AvatarGroupModule} from 'primeng/avatargroup';
import {HelpComponent } from './component/help/help.component';
import {DividerModule} from 'primeng/divider';
import {ProgressSpinner, ProgressSpinnerModule} from "primeng/progressspinner";
import {TabViewModule} from 'primeng/tabview';
import {EditorModule} from "primeng/editor";
@NgModule({
declarations: [
......@@ -63,60 +71,67 @@ import { CheckPasswordDirective } from './validator/check-password.directive';
HeaderMenuComponent,
FooterComponent,
ChangePasswordComponent,
CheckPasswordDirective
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
MenubarModule,
ButtonModule,
MenuModule,
AccordionModule,
SharedModule,
CheckboxModule,
FormsModule,
DataViewModule,
RatingModule,
RouterModule,
HttpClientModule,
MultiSelectModule,
DropdownModule,
InputTextModule,
TooltipModule,
CardModule,
TagModule,
InputTextModule,
CheckboxModule,
ButtonModule,
RadioButtonModule,
InputTextareaModule,
FileUploadModule,
ChipsModule,
MessagesModule,
MessageModule,
ToastModule,
PanelModule,
CascadeSelectModule,
DialogModule,
TableModule,
NgxsModule.forRoot([UserState], {developmentMode: !environment.production}),
NgxsStoragePluginModule.forRoot(),
ReactiveFormsModule,
ToastModule,
ImageModule,
ConfirmPopupModule,
ConfirmDialogModule,
LazyLoadImageModule
CheckPasswordDirective,
HelpComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
MenubarModule,
ButtonModule,
MenuModule,
AccordionModule,
SharedModule,
FormsModule,
DataViewModule,
RatingModule,
HttpClientModule,
MultiSelectModule,
DropdownModule,
InputTextModule,
TooltipModule,
CardModule,
TagModule,
InputTextModule,
CheckboxModule,
ButtonModule,
RadioButtonModule,
InputTextareaModule,
FileUploadModule,
ChipsModule,
MessagesModule,
MessageModule,
ToastModule,
PanelModule,
CascadeSelectModule,
DialogModule,
TableModule,
NgxsModule.forRoot([UserState], {developmentMode: !environment.production}),
NgxsStoragePluginModule.forRoot(),
ReactiveFormsModule,
ToastModule,
ImageModule,
ConfirmPopupModule,
ConfirmDialogModule,
LazyLoadImageModule,
BadgeModule,
ClipboardModule,
AvatarModule,
AvatarGroupModule,
DividerModule,
ProgressSpinnerModule,
TabViewModule,
EditorModule
],
providers: [MessageService,ConfirmationService,
{provide: LocationStrategy, useClass: HashLocationStrategy},
{
provide: LocationStrategy, useClass: HashLocationStrategy,
},{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true
}],
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule { }
File mode changed from 100644 to 100755
<div class="card pt-6 pl-6 pr-6">
<p *ngIf="(!edit)" class="text-3xl"> Add resource</p>
<p *ngIf="(edit)" class="text-3xl"> Edit resource</p>
<p *ngIf="(!edit)" class="text-3xl" i18n="@@{add_resource}"> Add resource</p>
<p *ngIf="(edit)" class="text-3xl" i18n="@@{edit_resource}"> Edit resource</p>
<form #resourceForm="ngForm" (ngSubmit)="saveResource()">
<div class="p-fluid">
<div class="field grid">
<label for="title" class="col-12 mb-2 md:col-2 md:mb-0">Short description</label>
<label for="title" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{short_desc}">Short description</label>
<div class="col-12 md:col-10">
<input id="title" name="title" #title='ngModel' type="text" pInputText [(ngModel)]="resource.resourceName" required [ngClass]="!title.valid ? 'ng-invalid ng-dirty' : ''">
<div [hidden]="title.valid" class="text-xs p-error ">
<div [hidden]="title.valid" class="text-xs p-error " i18n="@@{short_desc_required}">
Short description is required
</div>
</div>
</div>
<div class="field grid">
<label for="description" class="col-12 mb-2 md:col-2 md:mb-0">Long description (in English, 500 words)</label>
<label for="description" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{long_desc}">Long description (in English, 500 words)</label>
<div class="col-12 md:col-10">
<textarea id="description" name="description" #description='ngModel' type="text" rows="4" pInputTextarea [(ngModel)]="resource.description" required [ngClass]="!description.valid ? 'ng-invalid ng-dirty' : ''"></textarea>
<div [hidden]="description.valid" class="text-xs p-error">
<!-- <p-editor required id="description" name="descridescription" #description='ngModel' [(ngModel)]="resource.description" [style]="{'height':'320px'}" [ngClass]="!description.valid ? 'ng-invalid ng-dirty' : ''"></p-editor>-->
<div [hidden]="description.valid" class="text-xs p-error" i18n="@@{long_required}">
Long description is required
</div>
</div>
</div>
<div class="field grid">
<label for="description" class="col-12 mb-2 md:col-2 md:mb-0">Long description (in native language, if not English, 500 words)</label>
<label for="descriptionNative" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{long_native}">Long description (in native language, if not English, 500 words)</label>
<div class="col-12 md:col-10">
<textarea id="descriptionNative" name="descriptionNative" type="text" rows="4" pInputTextarea [(ngModel)]="resource.descriptionNative"></textarea>
</div>
. </div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Sectors</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{sectors}">Sectors</label>
<div class="col-12 md:col-10">
<p-multiSelect name="sector" #sector='ngModel' required defaultLabel="Select sector" [options]="sectors" optionLabel="name" [(ngModel)]="resource.sectors" [ngClass]="!sector.valid? 'ng-invalid ng-dirty' : ''" >
<p-multiSelect id="sector" name="sector" #sector='ngModel' required i18n-defaultLabel="@@{select_sector}" [options]="sectors" dataKey="name" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}" [(ngModel)]="resource.sectors" [ngClass]="!sector.valid? 'ng-invalid ng-dirty' : ''" >
</p-multiSelect>
<div [hidden]="sector.valid" class="text-xs p-error">
<div [hidden]="sector.valid" class="text-xs p-error" i18n="@@{sectors_required}">
Sector is required
</div>
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Country of origin</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{country_origin}">Country of origin</label>
<div class="col-12 md:col-10">
<p-multiSelect name="region" #region='ngModel' required defaultLabel="Select region" [options]="regions" optionLabel="name" [(ngModel)]="resource.regions" [ngClass]="!region.valid? 'ng-invalid ng-dirty' : ''"></p-multiSelect>
<div [hidden]="region.valid" class="text-xs p-error">
<p-multiSelect name="region" #region='ngModel' required i18n-defaultLabel="@@{select_region}" dataKey="name" [options]="regions" optionLabel="name" [(ngModel)]="resource.regions" [ngClass]="!region.valid? 'ng-invalid ng-dirty' : ''"></p-multiSelect>
<div [hidden]="region.valid" class="text-xs p-error"i18n="@@{country_required}">
Country of origin is required
</div>
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Relevant pests
<i class="pl-3 pi pi-question-circle" pBadge pTooltip="You can enter common English name, Latin name or EPPO to select pest. Choose Other to add new pest."></i>
<label class="col-12 mb-2 md:col-2 md:mb-0"><ng-container i18n="@@{relevant_pests"}>Relevant pests</ng-container>
<i class="pl-3 pi pi-question-circle" i18n-pTooltip="@@{pest_tooltip}" pTooltip="You can enter common English name, Latin name or EPPO to select pest. Choose Other to add new pest."></i>
</label>
<div class="col-12 md:col-10">
<p-multiSelect name="pests" defaultLabel="Select pests" [options]="pests" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="resource.pests" (onChange)="openPestModal()">
<p-multiSelect name="pests" i18n-defaultLabel="@@{select_pests}" defaultLabel="Select pests" [options]="pests" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="resource.pests" (onChange)="openPestModal()">
<ng-template let-pest pTemplate="item">
<div>{{pest.commonName}} <i *ngIf="pest.latinName !=undefined">
({{pest.latinName}}, {{pest.eppo}})</i></div>
......@@ -62,11 +62,11 @@
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Relevant crops
<i class="pl-3 pi pi-question-circle" pBadge pTooltip="You can enter common English name, Latin name or EPPO to select crop. Choose Other to add new crop."></i>
<label class="col-12 mb-2 md:col-2 md:mb-0"><ng-container i18n="@@{relevant_crops}">Relevant crops</ng-container>
<i class="pl-3 pi pi-question-circle" i18n-pTooltip="@@{crop_tooltip}" pTooltip="You can enter common English name, Latin name or EPPO to select crop. Choose Other to add new crop."></i>
</label>
<div class="col-12 md:col-10">
<p-multiSelect name="crops" defaultLabel="Select crops" [options]="crops" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="resource.crops" (onChange)="openCropModal()">
<p-multiSelect name="crops" i18n-defaultLabel="@@{select_crops}" defaultLabel="Select crops" [options]="crops" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="resource.crops" (onChange)="openCropModal()">
<ng-template let-crop pTemplate="item">
<div>{{crop.commonName}} <i *ngIf="crop.latinName !=undefined">
({{crop.latinName}}, {{crop.eppo}})</i></div>
......@@ -75,42 +75,43 @@
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Relevant project title</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{project}">Relevant project title</label>
<div class="col-12 md:col-10">
<input id="project" name="project" type="text" pInputText [(ngModel)]="resource.project">
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Link to project website</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{projectWeb}">Link to project website</label>
<div class="col-12 md:col-10">
<input id="projectWeb" name="projectWeb" type="text" pInputText [(ngModel)]="resource.projectWeb">
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">If an EU project, add grant code</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{projectGrantNo}">If an EU project, add grant code</label>
<div class="col-12 md:col-10">
<input id="projectGrantNo" name="projectGrantNo" type="text" pInputText [(ngModel)]="resource.projectGrantNo">
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Resource type</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{resourceType}">Resource type</label>
<div class="col-12 md:col-10">
<p-dropdown [options]="resourceTypes" [required]="true" #resourceType='ngModel' name="resourceTypes" optionLabel="name" placeholder="Select resource type" [(ngModel)]="resource.resourceType" [ngClass]="!resourceType.valid ? 'ng-invalid ng-dirty' : ''"></p-dropdown>
<div [hidden]="resourceType.valid" class="text-xs p-error">
<p-dropdown [options]="resourceTypes" [required]="true" #resourceType='ngModel' dataKey="name" name="resourceTypes" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}" i18n-placeholder="@@{select_resource_type}" [(ngModel)]="resource.resourceType" [ngClass]="!resourceType.valid ? 'ng-invalid ng-dirty' : ''"></p-dropdown>
<div [hidden]="resourceType.valid" class="text-xs p-error" i18n="@@{resource_type_required}">
Resource type is required
</div>
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Language</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{language}">Resource language</label>
<div class="col-12 md:col-10">
<p-dropdown [options]="languages" optionLabel="name" name="languages" placeholder="Select language" [(ngModel)]="resource.language"></p-dropdown>
<p-dropdown [showClear]=true [options]="languages" name="language" id="language" dataKey="name" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}" i18n-defaultLabel="@@{select_language}" [(ngModel)]="resource.language"></p-dropdown>
</div>
</div>
<div *ngIf="logoExist" class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Project logo</label>
<!--ne vidim smisao dodavanja slika kad se nigde ne prikazuje-->
<!-- <div *ngIf="logoExist" class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{project_logo}">Project logo</label>
<div class="col-12 md:col-10">
<p-fileUpload name="logo" (onRemove) = removeLogo() [maxFileSize]=5242880 chooseLabel="Change project logo" (onSelect)=hideOldLogo() [previewWidth]=250 [auto]=true accept="image/*" [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('logo',$event)">
<p-fileUpload name="logo" (onRemove) = removeLogo() [maxFileSize]=5242880 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" (onSelect)=hideOldLogo() [previewWidth]=250 [auto]=true accept="image/*" [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('logo',$event)">
<ng-template pTemplate="content" let-files >
<p-image [src]="imagePath+'/'+resource.idResource+'/logo'" *ngIf="showOldLogo" [preview]="true" width="250"></p-image>
</ng-template>
......@@ -118,15 +119,15 @@
</div>
</div>
<div class="field grid" *ngIf="!edit || !logoExist">
<label class="col-12 mb-2 md:col-2 md:mb-0">Upload project logo</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{upload_project_logo}">Upload project logo</label>
<div class="col-12 md:col-10">
<p-fileUpload name="logo" [previewWidth]=250 [auto]=true accept="image/*" [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('logo',$event)"></p-fileUpload>
<p-fileUpload name="logo" [previewWidth]=250 [auto]=true accept="image/*" [maxFileSize]=5242880 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('logo',$event)"></p-fileUpload>
</div>
</div>
<div *ngIf="imageExist" class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Uploaded image</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{uploaded_image}">Uploaded image</label>
<div class="col-12 md:col-10">
<p-fileUpload name="image" (onRemove) = removeImage() [maxFileSize]=5242880 chooseLabel="Change image" (onSelect)=hideOldImage() [previewWidth]=250 [auto]=true accept="image/*" [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('image',$event)">
<p-fileUpload name="image" (onRemove) = removeImage() [maxFileSize]=5242880 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" (onSelect)=hideOldImage() [previewWidth]=250 [auto]=true accept="image/*" [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('image',$event)">
<ng-template pTemplate="content" let-files >
<p-image [src]="imagePath+'/'+resource.idResource+'/image'" *ngIf="showOldImg" [preview]="true" width="250"></p-image>
</ng-template>
......@@ -134,39 +135,53 @@
</div>
</div>
<div class="field grid" *ngIf="!edit || !imageExist">
<label class="col-12 mb-2 md:col-2 md:mb-0">Upload image</label>
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{upload_image}">Upload image</label>
<div class="col-12 md:col-10">
<p-fileUpload name="image" [previewWidth]=250 [auto]=true accept="image/*" [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('image',$event)"></p-fileUpload>
<p-fileUpload name="image" [previewWidth]=250 [auto]=true accept="image/*" [maxFileSize]=5242880 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('image',$event)"></p-fileUpload>
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Upload resource content</label>
</div>-->
<div class="field grid" *ngIf="!edit">
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{upload_resource}">Upload resource content</label>
<div class="col-12 md:col-10">
<p-fileUpload name="resources" required [multiple]=true [fileLimit]=5 [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('content',$event)"></p-fileUpload>
<p-fileUpload name="resources" required [multiple]=true [fileLimit]=5 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" [maxFileSize]=10242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('content',$event)"></p-fileUpload>
</div>
</div>
<div class="field grid" *ngIf="edit">
<label class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{upload_resource}">Change resource content</label>
<div class="col-12 md:col-10 ">
<p-panel class="col-12 md:col-10 p-d-block">
<div *ngFor="let file of resource.files" class="flex justify-content-between mb-2 ">
<div class="col-8 md:col-8">
<button pButton type="button" label="{{file.description}}" class="p-button-link button-link text-left" (click)="downloadFile(file.description)"></button>
</div>
<div class="col-2 md:col-2"><button pButton type="button" label="Delete" icon="pi pi-trash" (click)="delete(file.fileIdentifier)" [loading]="false" class="p-button-danger"></button></div>
</div>
</p-panel>
<p-fileUpload name="resources" required [multiple]=true [fileLimit]=5 i18n-chooseLabel="@@{choose}" chooseLabel="Choose" [maxFileSize]=5242880 [auto]=true [showUploadButton]=false [customUpload]=true (uploadHandler)="fileUploader('content',$event)"></p-fileUpload>
</div>
</div>
<div class="field grid">
<label for="source" class="col-12 mb-2 md:col-2 md:mb-0">Original website address </label>
<label for="source" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{resourceOrigin}">Original website address </label>
<div class="col-12 md:col-10">
<input id="source" type="text" name="source" pInputText [(ngModel)]="resource.resourceOrigin">
</div>
</div>
<div class="field grid">
<label for="citation" class="col-12 mb-2 md:col-2 md:mb-0">DOI</label>
<label for="citation" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{citation}">DOI</label>
<div class="col-12 md:col-10">
<input id="citation" name="citation" type="text" pInputText [(ngModel)]="resource.citation">
</div>
</div>
<div class="field grid">
<label class="col-12 mb-2 md:col-2 md:mb-0">Up to 5 links to further reading</label>
<label class="col-12 mb-2 md:col-2 md:mb-0"i18n="@@{link_restriction}">Up to 5 links to further reading</label>
<div class="col-12 md:col-10">
<p-chips [(ngModel)]="resource.links" name="links" [max]=5 placeholder="Enter relevant links" [allowDuplicate]=false></p-chips>
<p-chips [(ngModel)]="resource.links" name="links" [max]=5 i18n-placeholder="@@{enter_links}" placeholder="Enter relevant links" [allowDuplicate]=false></p-chips>
</div>
</div>
<div class="field grid">
<label for="contactOrg" class="col-12 mb-2 md:col-2 md:mb-0">Contact institution</label>
<label for="contactOrg" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{contactInstitution}" i18n="@@{contactInstitution}">Contact institution</label>
<div class="col-12 md:col-10">
<input id="contactOrg" name="contactOrg" type="text" pInputText [(ngModel)]="resource.contactInstitution">
</div>
......@@ -178,37 +193,51 @@
</div>
</div>-->
<div class="field grid">
<label for="contactEmail" class="col-12 mb-2 md:col-2 md:mb-0">Contact email</label>
<label for="contactEmail" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{contactEmail}">Contact email</label>
<div class="col-12 md:col-10">
<input id="contactEmail" name="contactEmail" type="text" pInputText [(ngModel)]="resource.contactEmail">
</div>
</div>
<div class="field grid">
<label for="contactPhone" class="col-12 mb-2 md:col-2 md:mb-0">Contact phone</label>
<label for="contactPhone" class="col-12 mb-2 md:col-2 md:mb-0" i18n="@@{contactPhone}">Contact phone</label>
<div class="col-12 md:col-10">
<input id="contactPhone" name="contactPhone" type="text" pInputText [(ngModel)]="resource.contactPhone">
</div>
</div>
</div>
<div class="col-12 pt-3 justify-content-center flex" *ngIf="!edit">
<p-button label="Back" icon="pi pi-step-backward" class="pr-5"routerLink="/home" type="button" ></p-button>
<p-button label="Save resource" icon="pi pi-save" [loading]="false" type="submit" [disabled]="resourceForm.form.invalid"></p-button>
</div>
<div class="field grid">
<div class="col-12 field-checkbox">
<p-checkbox [(ngModel)]="termChecked" [binary]="true" name="termCheckede" id="termChecked" [ngClass]="!termChecked? 'ng-invalid ng-dirty' : ''"></p-checkbox>
<label for="termChecked"><ng-container i18n="@@{termCondition1}">by ticking this box you confirm that you have read and accept</ng-container> <a href="https://ipmworks.net/ipmworks/file/get/63b6b7c0d7f8f46f5b2a28b3"><ng-container i18n="@@{part1}"> Part 1 </ng-container></a>
<ng-container i18n="@@{termCondition2}">of the Toolbox Terms and Conditions. You can contact </ng-container><a href="mailto:IPMWORKS-WP4@inrae.fr">IPMWORKS-WP4@inrae.fr </a> <ng-container i18n="@@{termCondiotion3}">at any time to amend or remove your submission.</ng-container>
</label>
<!-- <button pButton type="button" (click)="showTerms()" label="Toolbox Terms and Conditions" [ngStyle]="{color:'var(--red-500)'}" class="p-button-link pl-2"></button>
<p-dialog header="Terms and Conditions" [(visible)]="displayTerms" [style]="{width: '50vw'}">
By completing your submission of IPM-related Resources to the IPMWorks resource Toolbox you confirm that you have read and accept Part 1 one and Part 2 of the Toolbox Terms and Conditions. You can contact <a href="mailto:IPMWORKS-WP4@inrae.fr">IPMWORKS-WP4@inrae.fr</a> at any time to amend or remove your submission.
</p-dialog>-->
</div>
<div [hidden]="termChecked" class="text-xs p-error" i18n="@@{required}">
This is required
</div>
</div>
<div class="col-12 pt-3 justify-content-center flex" *ngIf="!edit">
<p-button i18n-label="@@{back}" label="Back" icon="pi pi-step-backward" class="pr-5"routerLink="/home" type="button" ></p-button>
<p-button i18n-label="save_resource" label="Save resource" icon="pi pi-save" [loading]="false" type="submit" [disabled]="resourceForm.form.invalid || !termChecked"></p-button>
</div>
<div class="col-12 pt-3 justify-content-center flex" *ngIf="edit" >
<p-button label="Back" icon="pi pi-step-backward" class="pr-5"routerLink="/resource/{{resource.idResource}}" type="button" ></p-button>
<p-button label="Save resource" icon="pi pi-save" [loading]="false" type="submit" [disabled]="resourceForm.form.invalid"></p-button>
<p-button i18n-label="@@{back}" label="Back" icon="pi pi-step-backward" class="pr-5"routerLink="/resource/{{resource.idResource}}" type="button" ></p-button>
<p-button i18n-label="save_resource" label="Save resource" icon="pi pi-save" [loading]="false" type="submit" [disabled]="resourceForm.form.invalid || !termChecked"></p-button>
</div>
</div>
</form>
</div>
<p-toast></p-toast>
<p-dialog id="pestModal" header="Add new pest" [(visible)]="displayPestModal">
<div class="field">
<label>English common name</label>
<label i18n="@@{commonName}" >English common name</label>
<input id="commonName" type="text" pInputText [(ngModel)]="newPest.commonName"/>
</div>
<div class="field">
<label>Latin name</label>
<label i18n="@@{latinName}">Latin name</label>
<input id="latinName" type="text" pInputText [(ngModel)]="newPest.latinName"/>
</div>
<div class="field">
......@@ -216,18 +245,18 @@
<input id="eppo" type="text" pInputText [(ngModel)]="newPest.eppo" />
</div>
<div class="field button-center">
<button pButton type="button" class="p-button-help" label="Cancel" (click)="displayPestModal=false" ></button>
<button pButton type="button" class="p-pl-3" label="Submit" (click)="addPest()"></button>
<button pButton type="button" class="p-button-help mr-3" i18n-label="@@{cancel}" label="Cancel" (click)="displayPestModal=false" ></button>
<button pButton type="button" i18n-label="submit" label="Submit" (click)="addPest()"></button>
</div>
</p-dialog>
<p-dialog id="cropModal" name="cropModal" header="Add new crop" [(visible)]="displayCropModal">
<div class="field">
<label>English common name</label>
<label i18n="@@{commonName}">English common name</label>
<input id="commonNameCrop" type="text" pInputText [(ngModel)]="newCrop.commonName" />
</div>
<div class="field">
<label>Latin name</label>
<label i18n="@@{latinName}">Latin name</label>
<input id="latinNameCrop" type="text" pInputText [(ngModel)]="newCrop.latinName"/>
</div>
<div class="field">
......@@ -235,7 +264,8 @@
<input id="eppoCrop" type="text" pInputText [(ngModel)]="newCrop.eppo"/>
</div>
<div class="field button-center">
<button pButton type="button" class="p-button-help" label="Cancel" (click)="displayCropModal=false" ></button>
<button pButton type="button" class="p-pl-3" label="Submit" (click)="addCrop()" ></button>
<button pButton type="button" class="p-button-help mr-3" i18n-label="@@{cancel}" label="Cancel" (click)="displayCropModal=false" ></button>
<button pButton type="button" i18n-label="submit" label="Submit" (click)="addCrop()" ></button>
</div>
</p-dialog>
<p-confirmDialog></p-confirmDialog>
File mode changed from 100644 to 100755
import { Component, OnInit } from '@angular/core';
import {Component, Inject, LOCALE_ID, OnInit} from '@angular/core';
import {ResourceType, Language, Region, Sector, Project, Resource, Pest, Crop} from "../../model/resource";
import {ResourceService} from "../../service/resource.service";
import {MessageService} from 'primeng/api';
import {ConfirmationService, MessageService} from 'primeng/api';
import {ActivatedRoute, Router} from "@angular/router";
import {FormControl} from "@angular/forms";
import {environment} from "../../../environments/environment";
......@@ -36,8 +36,10 @@ export class AddResourceComponent implements OnInit {
logo: any;
showOldLogo = true;
logoExist:boolean = false;
displayTerms = false;
termChecked = false;
constructor(private resourceService:ResourceService, private route: ActivatedRoute, private messageService: MessageService, private router: Router) { }
constructor(private resourceService:ResourceService, private route: ActivatedRoute, private messageService: MessageService, private router: Router, @Inject(LOCALE_ID) public locale: string, private confirmationService: ConfirmationService) { }
ngOnInit(): void {
this.resourceService.getAllSectors().subscribe((sectors: Sector[]) => {
......@@ -75,11 +77,9 @@ export class AddResourceComponent implements OnInit {
}
saveResource(){
this.resource.canEdit=true;
this.resourceService.saveResource(this.resource,this.edit).subscribe((data: Resource) => {
this.resource = data;
console.log(this.image)
console.log(this.logo)
this.resourceService.addFiles(this.image, this.logo, this.resourceContent, this.resource.idResource).subscribe(data => {
if(!this.edit){
this.messageService.add({severity: 'success', detail: 'Resource is saved, but need to be approved by administrator!'});
......@@ -156,4 +156,37 @@ export class AddResourceComponent implements OnInit {
this.logo=undefined;
this.showOldLogo = true;
}
showTerms(){
this.displayTerms = true;
}
delete(fileId?: String) {
this.confirmationService.confirm({
message: 'Are you sure that you want to delete resource?',
icon: 'pi pi-exclamation-triangle',
accept: () => {
// @ts-ignore
this.resourceService.deleteFile(fileId).subscribe(r => {
this.messageService.add({severity: 'success', detail: 'Resource has been deleted.'});
this.router.navigate(['/resource/edit/'+this.resource.idResource]);
}, error => {
this.messageService.add({severity: 'error', detail: 'Some error occurred!'});
}
);
}
});
}
downloadFile(fileName: any): void {
this.resourceService.downloadFile(fileName).subscribe((file: any) => {
const blob = new Blob([file], {type: file.type});
var url = window.URL.createObjectURL(blob);
/*const link = document.createElement('a');
link.href = this.url;
link.target="_blank";
link.download = fileName;*/
window.open(url,"_blank")
}, error => {
console.log(error)
});
}
}
<div class="card pt-6 pl-6 pr-6">
<p class="text-3xl"> Approve resources</p>
<p class="text-3xl" i18n> Approve resources</p>
<p-table [value]="resources" [paginator]="true" [rows]="10" >
<ng-template pTemplate="header">
<tr>
<th>Resource name</th>
<th>Resource type</th>
<th>Creation date</th>
<th i18n>Resource name</th>
<th i18n>Resource type</th>
<th i18n>Creation date</th>
<th i18n>How resource added</th>
<th></th>
</tr>
</ng-template>
......@@ -14,6 +15,7 @@
<td>{{resource.resourceName}}</td>
<td>{{resource.resourceType?.name}}</td>
<td>{{resource.creationDate| date:"d.M.yyyy, h:mm a"}}</td>
<td i18n>Manually</td>
<td>
<button pButton type="button" routerLink="/resource/{{resource.idResource}}" icon="pi pi-pencil"></button>
</td>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -5,22 +5,22 @@
<div class="field">
<span class="p-float-label">
<input type="password" id="password" pInputText formControlName="password">
<label for="password">Enter new password...</label>
<label for="password" i18n="@@{new_password}">Enter new password...</label>
</span>
</div>
<div class="field">
<span class="p-float-label">
<input type="password" id="confirmedPassword" pInputText formControlName="confirmedPassword">
<label for="confirmedPassword">Retype password again...</label>
<label for="confirmedPassword" i18n="@@{retype_pass}">Retype password again...</label>
</span>
</div>
<div *ngIf="changeForm.errors?.['notSame'] && (changeForm.touched || changeForm.dirty)" class="text-xs p-error ">
<div *ngIf="changeForm.errors?.['notSame'] && (changeForm.touched || changeForm.dirty)" class="text-xs p-error " i18n="@@{pass_error}">
Passwords does not match!
</div>
</div>
<div class="field flex justify-content-center pt-4">
<p-button class="pr-4" type="submit" [disabled]="changeForm.invalid" (click)="changePassword()">Change password</p-button>
<p-button class="pr-4" type="submit" [disabled]="changeForm.invalid" (click)="changePassword()" i18n="@@{change_password}">Change password</p-button>
</div>
</form>
</div>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -15,7 +15,7 @@
<img src="assets/EUFlag.png"/>
</div>
<div>
<p class="pl-5 pt-2 align-self-center">
<p class="pl-5 pt-2 align-self-center" i18n="@@{project_ack}">
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No. 101000339.
</p>
</div>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
@media only screen and (min-width: 60.0px) {
.flag{
width: 45px;
}
}
:host ::ng-deep .p-dropdown{
border:0px !important;
}
:host ::ng-deep .p-dropdown:not(.p-disabled).p-focus {
box-shadow: none;
}
:host ::ng-deep .p-menubar-end{
align-self: auto !important;
}
:host ::ng-deep .p-dropdown-trigger {
display: none !important;
}
<p-menubar [model]="items">
<p-menubar [model]="items" [ngStyle]="{'display': hideheader}">
<ng-template pTemplate="start">
<img src="assets/logo.jpg" height="97" class="pl-6 mr-8" routerLink="/home" alt="brand logo">
<a href="http://ipmworks.net">
<img src="assets/logo.jpg" height="97" class="pl-6 mr-8" alt="brand logo">
</a>
</ng-template>
<ng-template pTemplate="end">
<p-dropdown [options]="languages" [(ngModel)]="selectedLanguage" optionLabel="name" class="col-4" (onChange)="reloadTranslate($event)" appendTo="body">
<ng-template pTemplate="selectedItem">
<div *ngIf="selectedLanguage">
<img src="assets/languages/{{locale}}.png" class="flag pr-2"/>
</div>
</ng-template>
<ng-template let-language pTemplate="item">
<div class="flex">
<img src="assets/languages/{{language.code}}.png" class="flag pr-2"/>
<div>{{language.name}}</div>
</div>
</ng-template>
</p-dropdown>
</ng-template>
</p-menubar>
<p-toast></p-toast>
File mode changed from 100644 to 100755
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {MenuItem, MessageService, PrimeNGConfig} from "primeng/api";
import {Observable, Subject} from "rxjs";
import {User} from "../../model/user";
import {LogoutAction, UserState} from "../../states/user.state";
import {Select, Store} from "@ngxs/store";
import {NavigationEnd, Router, RouterEvent} from "@angular/router";
import {ActivatedRoute, NavigationEnd, Router, RouterEvent} from "@angular/router";
import {filter, takeUntil} from "rxjs/operators";
import { LOCALE_ID, Inject } from '@angular/core';
export class LanguageTrans{
public name?: string;
public code?:string;
}
@Component({
selector: 'app-header-menu',
templateUrl: './header-menu.component.html',
......@@ -19,49 +24,53 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
// @ts-ignore
public loggeduser: Observable<User> = this.store.select(UserState.userDetails);
logged?:boolean
selectedLanguage?:LanguageTrans;
languages :LanguageTrans[] = [];
constructor(private primengConfig: PrimeNGConfig, private store: Store, private router: Router,private messageService: MessageService) {}
@Input() hideheader?:string|null;
constructor(private route:ActivatedRoute,private primengConfig: PrimeNGConfig, private store: Store, private router: Router,private messageService: MessageService, @Inject(LOCALE_ID) public locale: string) {}
initialise() {
this.logged = this.isLogged();
// @ts-ignore
this.items = [
{
label: 'Home',
label: $localize `Home`,
routerLink:'/home',
styleClass:"pr-2 ",
},
{
label: 'Add resource',
label: $localize `Add resource`,
url:'#/resource/add',
styleClass:"pr-2",
target:"_blank"
},
{
label: 'Approve',
label: $localize `Approve`,
routerLink:'/resource/approve',
styleClass:"pr-2",
visible:this.isUserAdmin()
},
{
label: 'IPMWORKS Project',
label:$localize `IPMWORKS Project`,
url:'http://ipmworks.net',
styleClass:"pr-2",
target:"_blank"
},
{
label: 'Help and Support',
label: $localize`Help and Support`,
routerLink:'/help',
styleClass:"pr-2",
target:"_blank"
},
{
label: 'Logout',
label: $localize `Logout`,
command:(event) => {this.logout()},
styleClass:"pr-2",
visible:this.logged
},
{
label: 'Login',
label: $localize `Login`,
routerLink:'/login',
styleClass:"pr-2",
visible:!this.logged
......@@ -69,12 +78,38 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
]
}
ngOnInit(): void {
this.languages = [
{ name: $localize `Dutch`, code: "nl" },
{ name: $localize `Danish`, code: "da" },
{ name: $localize `English`, "code": "en" },
{ name: $localize `Finnish`, code: "fi" },
{ name: $localize `French`, code: "fr" },
{ name: $localize `German`, code: "de" },
{ name: $localize `Greek`, code: "el" },
{ name: $localize `Italian`, code: "it" },
{ name: $localize `Polish`, code: "pl" },
{ name: $localize `Portuguese`, code: "pt" },
{ name: $localize `Serbian`, "code": "sr" },
{ name: $localize `Slovenian`, code: "sl" },
{ name: $localize `Spanish`, code: "es" }
]
this.findSelectedLanguage();
this.router.events.pipe(filter((event) => event instanceof NavigationEnd),
takeUntil(this.destroyed)
).subscribe(() => {
this.router.routeReuseStrategy.shouldReuseRoute = function() { return false; };
this.initialise();
});
}
public findSelectedLanguage(){
console.log("locale:"+this.locale)
var selected = this.languages.filter(l=>l.code===this.locale);
if(selected.length !== 0){
this.selectedLanguage =this.languages.filter(l=>l.code===this.locale)[0];
}
}
public isUserAdmin() {
var admin = false;
......@@ -110,6 +145,11 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
this.router.navigate(['/home']);
this.messageService.add({severity:"success", detail:"Goodbye!"})
}
public reloadTranslate(event:any):void{
window.location.href= "/toolbox/"+this.selectedLanguage?.code;
}
}
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -34,3 +34,8 @@
padding:5px;
display: inline-block;
}
.hoverResource:hover{
background: rgba(63, 81, 181, 0.04);
cursor: pointer;
}
<p-messages severity="info" [enableService]="false" *ngIf="!close">
<ng-template pTemplate>
<span class="p-message-icon pi pi-info-circle"></span>
<span class="p-message-summary">Disclaimer</span>
<span class="p-message-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. In continuing to use the IPMWorks Resource Toolbox you agree to <a [ngStyle]="{color:'var(--surface-0)'}" href="#">Part 1</a> of the Toolbox Terms and Conditions.</span>
<span class="p-message-summary" i18n>Disclaimer</span>
<span class="p-message-detail" i18n>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. In continuing to use the IPMWorks Resource Toolbox you agree to <a [ngStyle]="{color:'var(--surface-0)'}" href="https://ipmworks.net/ipmworks/file/get/63b6b7c0d7f8f46f5b2a28b3">Part 1</a> of the Toolbox Terms and Conditions.</span>
<button type="button" (click)="closeDisclaimer()" class="p-message-close p-link"><i class=" p-message-close-icon pi pi-times"></i></button>
</ng-template>
</p-messages>
<div class="grid pt-6 pl-6">
<div class="col-3">
<div class="grid pt-6 pl-6 flex-wrap">
<div class="md:col-3">
<form #searchForm="ngForm" (ngSubmit)="searchResource()">
<p class="text-xl">Sectors</p>
<p-multiSelect defaultLabel="Select sector" [options]="sectors" name="sector" [(ngModel)]="searchModel.sector" optionLabel="name"></p-multiSelect>
<p class="text-xl">Country of origin</p>
<p-multiSelect defaultLabel="Select region" [options]="regions" name="region" [(ngModel)]="searchModel.region" optionLabel="name"></p-multiSelect>
<p class="text-xl" i18n="@@{sectors}">Sectors</p>
<p-multiSelect i18n-defaultLabel="@@{select_sector}" defaultLabel="Select sector" [options]="sectors" name="sector" [(ngModel)]="searchModel.sector" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}">
</p-multiSelect>
<p class="text-xl" i18n="@@{country_origin}">Country of origin</p>
<p-multiSelect i18n-defaultLabel="@@{select_region}" defaultLabel="Select region" [options]="regions" name="region" [(ngModel)]="searchModel.region" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}"></p-multiSelect>
<!-- <div class="field">
<p class="text-xl">Pest type</p>
<p-dropdown autoWidth="false" [style]="{'width':'100%'}" placeholder="Select pest type" [options]="pestType" name="pestType"[(ngModel)]="searchModel.pestType" optionLabel="name" ></p-dropdown>
</div>-->
<p class="text-xl">Project</p>
<p-dropdown autoWidth="false" [style]="{'width':'100%'}" placeholder="Select project" [(ngModel)]="searchModel.project" [options]="projects" name="project" optionLabel="name" ></p-dropdown>
<p class="text-xl">Resource types</p>
<p-multiSelect placeholder="Select resource type" name="resourceType" [(ngModel)]="searchModel.resourceType" [options]="contentTypes" optionLabel="name">
<p class="text-xl" i18n="@@{project}">Project</p>
<p-dropdown autoWidth="false" [style]="{'width':'100%'}" i18n-placeholder="@@{select_project}" placeholder="Select project" [(ngModel)]="searchModel.project" [options]="projects" name="project" optionLabel="name" ></p-dropdown>
<p class="text-xl" i18n="@@{resource_types}">Resource types</p>
<p-multiSelect i18n-placeholder="@@{select_resource_type}" placeholder="Select resource type" name="resourceType" [(ngModel)]="searchModel.resourceType" [options]="contentTypes" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}">
</p-multiSelect>
<div class="button-right 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>
<button pButton type="button" i18n-pTooltip="@@{more_filters}" pTooltip="More filters..." icon="pi pi-plus" class="p-button-text p-button-sm p-button-rounded p-button-outlined " (click)="toggleFilters()"></button>
</div>
<div class="button-right pt-3" *ngIf="more">
<button pButton type="button" icon="pi pi-minus" pTooltip="Less filters..."
<!-- <div class="button-right pt-3" *ngIf="more">
<button pButton type="button" icon="pi pi-minus" i18n-pTooltip="@@{less_filters}" pTooltip="Less filters..."
class="p-button-text p-button-sm p-button-rounded p-button-outlined " (click)="toggleFilters()"></button>
</div>
</div>-->
<div *ngIf="more">
<p class="text-xl">Specific pest</p>
<p-multiSelect defaultLabel="Select pests" [options]="pests" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="searchModel.pest" name="pest">
<p class="text-xl" i18n="@@{search_title}">Resource title</p>
<input id="title" name="title" type="text" pInputText [(ngModel)]="searchModel.title">
<p class="text-xl" i18n="@@{specific_pest}">Specific pest</p>
<p-multiSelect i18n-defaultLabel="@@{select_pests}" defaultLabel="Select pests" [options]="pests" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="searchModel.pest" name="pest">
<ng-template let-pest pTemplate="item">
<div>{{pest.commonName}} <i *ngIf="pest.latinName !=undefined">
({{pest.latinName}}, {{pest.eppo}})</i></div>
......@@ -42,60 +48,69 @@
</p-multiSelect>
<p class="text-xl">Specific crop</p>
<p-multiSelect defaultLabel="Select crops" [options]="crops" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="searchModel.crop" name="crop">
<p class="text-xl" i18n="@specific_crop">Specific crop</p>
<p-multiSelect i18n-defaultLabel="@@{select_crops}" defaultLabel="Select crops" [options]="crops" optionLabel="commonName" filterBy="commonName,latinName,eppo" [(ngModel)]="searchModel.crop" name="crop">
<ng-template let-crop pTemplate="item">
<div>{{crop.commonName}} <i *ngIf="crop.latinName !=undefined">
({{crop.latinName}}, {{crop.eppo}})</i></div>
</ng-template>
</p-multiSelect>
<p class="text-xl">Languages</p>
<p-multiSelect defaultLabel="Select language" [options]="languages" name="language" [(ngModel)]="searchModel.language" optionLabel="name"></p-multiSelect>
<p class="text-xl" i18n="@@{languages}">Resource language</p>
<p-multiSelect i18n-defaultLabel="@@{select_language}" defaultLabel="Select language" [selectionLimit]="1" [options]="languages" name="language" [(ngModel)]="searchModel.language" optionLabel="{{locale === 'en' ? 'name' : 'name_'+locale}}"></p-multiSelect>
<!--<h3>Arbitrary text search</h3>
<input type="text" pInputText [(ngModel)]="searchTerm"/>-->
</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]="serachRunning"></p-button>
<p-button type="submit" i18n-label="@@{search}" 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>
<p-button type="submit" i18n-label="@@{reset}" label="Reset" icon="pi pi-refresh" (click)="resetSearch()" [loading]="false"></p-button>
</div>
</div>
</form>
</div>
<div class="col-9">
<div class="md:col-9">
<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" >
<div class="card col-12 md:col-4 flex flex-column p-3 mt-3 hoverResource">
<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="{{getResourceType(resource)}}">
</p-tag>
<p-avatar *ngIf="resource.external" shape="circle" icon="pi pi-external-link"></p-avatar>
</div>
<div class="" routerLink="/resource/{{resource.idResource}}">
<img [defaultImage]="'assets/sectors/multi.jpg'" [useSrcset]="true" [lazyLoad]="imagePath+'/'+resource.idResource" class="imageSizeHome"/>
<div routerLink="/resource/{{resource.idResource}}">
<img [src]="imagePath+'/'+resource.idResource" class="imageSizeHome"/>
<div class="flex flex-column">
<div class="pt-1 align-self-end">
<p-tag [rounded]=true severity="success" icon="pi pi-globe" value="{{getRegion(resource)}}">
</p-tag>
<p-tag *ngIf="getProject(resource)!== null" [rounded]=true severity="warning" icon="pi pi-book" value="{{getProject(resource)}}">
</p-tag>
</div>
</div>
<p class="text-center">{{resource.resourceName}}</p>
</div>
<div class="align-self-center">
<a routerLink="/resource/{{resource.idResource}}" target="_blank" [style]="'text-decoration:unset'">
<button pButton type="button" icon="pi pi-forward" class="p-button-outlined mr-4" pTooltip="See more..."></button>
<a routerLink="/resource/{{resource.idResource}}/{{getLang()}}" target="_blank" [style]="'text-decoration:unset'">
<button pButton type="button" icon="pi pi-forward" class="p-button-outlined mr-4" i18n-pTooltip="@@{find_more}" pTooltip="See more..."></button>
</a>
<!--<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>
<ng-template let-item pTemplate="paginatordropdownitem">
<ng-template let-item pTemplate="paginatordropdownitem" i18n="@@{per_page}">
{{item.value}} - per page
</ng-template>
</p-dataView>
<div class="justify-content-center flex pt-3" *ngIf="totalElements>0">Number of results: {{totalElements}}</div>
<div class="justify-content-center flex pt-3" *ngIf="totalElements>0" i18n="@@{number_of_results}">Number of results: {{totalElements}}</div>
</p-card>
</div>
......
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Component, Inject, LOCALE_ID, OnDestroy, OnInit} from '@angular/core';
import {
Crop,
Keyword,
......@@ -16,6 +16,7 @@ import {Message, MessageService} from "primeng/api";
import {environment} from "../../../environments/environment";
import {SearchModel} from "../../model/search-model";
import {NavigationEnd, Router} from "@angular/router";
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
......@@ -48,13 +49,14 @@ export class HomeComponent implements OnInit{
selectedPestType: string | undefined;
serachRunning= false;
searchTerm: string = "";
more= false;
more= true;
close = false;
imagePath = environment.baseUrl+"/resource/image";
imagePathRaw = environment.baseUrl+"/resource/image/raw";
searchModel:SearchModel = {};
constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService) {
loading:boolean = true;
counter:number = 0;
constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService, @Inject(LOCALE_ID) public locale: string) {
this.pageableResponse = {totalElements:0}
}
......@@ -121,7 +123,9 @@ export class HomeComponent implements OnInit{
this.totalElements = this.pageableResponse.totalElements;
}
public resetSearch(){
this.serachRunning=true;
this.router.navigate(['home']);
/*this.serachRunning=true;
this.resourceService.getAllResources().subscribe((resources: PageableResource) => {
// @ts-ignore
this.resources = resources.content;
......@@ -129,12 +133,46 @@ export class HomeComponent implements OnInit{
this.totalElements = resources.totalElements;
this.searchModel = {};
this.search = false;
this.serachRunning=false;
this.serachRunning=false;*/
});
//});
}
isEmptySearch(){
return JSON.stringify(this.searchModel) === '{}';
}
public getRegion(resource:Resource){
if (resource.regions !== undefined && resource.regions?.length >1){
return "EU"
}else if (resource.regions?.length ===1){
// if(this.locale !== 'en'){
// return Reflect.get(resource.regions[0],'name_'+this.locale)
// }else{
return resource.regions[0].name;
//}
}else{
return "EU"
}
}
public getResourceType(resource:Resource){
// if(this.locale !== 'en'){
// // @ts-ignore
// return Reflect.get(resource.resourceType,'name_'+this.locale)
// }else{
// @ts-ignore
return resource.resourceType.name;
// }
}
public getProject(resource:Resource){
if (resource.sectors == undefined|| resource.sectors.length==0 ){
return null;
}else{
return resource.project;
}
}
public getLang(){
if (this.searchModel.language !=undefined){
return this.searchModel.language[0].code;
}
return "";
}
}
......@@ -4,27 +4,27 @@
<div class="field">
<span class="p-float-label">
<input type="email" id="username" pInputText formControlName="username">
<label for="username">Username</label>
<label for="username" i18n="@@{username}">Username</label>
</span>
</div>
<div class="field">
<span class="p-float-label">
<input type="password" id="password" pInputText formControlName="password">
<label for="username">Password</label>
<label for="username" i18n="@@{password}">Password</label>
</span>
</div>
<div class="field flex justify-content-center pt-4">
<p-button class="pr-4" type="submit" (click)="signIn()">Login</p-button>
<p-button label="Forgot password?" (click)="displayDialog()" styleClass="p-button-link"></p-button>
<p-button class="pr-4" type="submit" (click)="signIn()" i18n="@@{login}">Login</p-button>
<p-button i18n-label="@@{forgot_password}" label="Forgot password?" (click)="displayDialog()" styleClass="p-button-link"></p-button>
</div>
</form>
</div>
</div>
<p-dialog [(visible)]="display" [breakpoints]="{'960px': '75vw', '640px': '100vw'}" [style]="{width: '50vw'} ">
<p>If you want to change your password, please enter your e-mail used to login. If we find email in our system, we will send you instructions to follow.</p>
<p i18n="@@{change_pass_instr}">If you want to change your password, please enter your e-mail used to login. If we find email in our system, we will send you instructions to follow.</p>
<input type="text" pInputText [(ngModel)]="email">
<div class="pt-4" >
<button type="button" pButton autofocus (click)="sendPasswordChange()" [disabled]="email.length == 0" > Send email</button>
<button type="button" pButton autofocus (click)="sendPasswordChange()" [disabled]="email.length == 0" i18n="@@{send_email}"> Send email</button>
</div>
</p-dialog>
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -27,3 +27,6 @@
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
.keep-format{
white-space: pre-wrap;
}
<div class="grid pt-6 pl-6 flex">
<div class="grid pt-6 pl-6 flex flex-wrap">
<div class="flex col-12 justify-content-center">
<p class="text-3xl">{{resource.resourceName}}
</p>
</div>
<div class="col-6 flex flex-column">
<div class="md:col-6 flex flex-column">
<div class="col-12 text-center">
<img [src]="imagePath+'/'+resourceId" class="imageSize" >
</div>
<div class="col-12">
<p-panel class="col-12 inline">
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource language</div><div class="my-0">{{resource.language?.name}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource origin</div> <div class="my-0 overflow-text"><a href="{{resource.resourceOrigin}}" target="_blank">{{resource.resourceOrigin}}</a></div></div>
<div class="flex align-items-center"> <div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}">Resource type</div><div class="my-0">{{resource.resourceType?.name}}</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 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)'}" i18n="@@{project}">Project</div><div class="my-0">{{resource.project}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{language}">Resource language</div><div class="my-0">{{resource.language?.name}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{resourceOrigin}">Resource origin</div> <div class="my-0 overflow-text"><a href="{{resource.resourceOrigin}}" target="_blank">{{resource.resourceOrigin}}</a></div></div>
<div class="flex align-items-center"> <div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{resourceType}">Resource type</div><div class="my-0">{{resource.resourceType?.name}}</div></div>
<div class="flex align-items-center"><div class="col-3 inline my-0" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{contactInstitution}">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)'}" i18n="@@{contactEmail}">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)'}" i18n="@@{contactPhone}">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)'}" i18n="@@{citation}">Citation (DOI)</div><div class="overflow-text my-0">{{resource.citation}}</div></div>
</p-panel>
</div>
</div>
<div class="col-6 flex flex-column">
<p-panel header="Short summary" class="col-12 p-d-block">
<div class="flex"> {{resource.description}}</div>
<div class="md:col-6 flex flex-column">
<p-panel i18n-header="@@{short_summary}" header="Short summary" class="col-12 p-d-block">
<div *ngIf="resource.descriptionNative == undefined" class="flex keep-format" [innerHTML]="resource.description"></div>
<p-tabView *ngIf="resource.descriptionNative != undefined">
<p-tabPanel i18n-header="@@{tab_english}" header="English" >
<div class="flex keep-format"> {{resource.description}}</div>
</p-tabPanel>
<p-tabPanel i18n-header="@@{tab_native}}" header="Native">
<div class="flex keep-format"> {{resource.descriptionNative}}</div>
</p-tabPanel>
</p-tabView>
<div class="flex mt-5">
<div class="inline col-3 my-0"[ngStyle]="{color:'var(--surface-500)'}">Sectors</div>
<div class="inline col-3 my-0"[ngStyle]="{color:'var(--surface-500)'}" i18n="@@{sectors}">Sectors</div>
<div class="inline my-0" *ngFor="let sector of resource.sectors">
<img class="sector mx-2" [src]="'assets/sectors/'+sector.sectorIcon" pTooltip="{{sector.name}}">
</div>
</div>
<div class="flex flex-wrap">
<div class="inline col-3 my-0" [ngStyle]="{color:'var(--surface-500)'}">Regions</div>
<div class="inline col-3 my-0" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{regions}">Regions</div>
<div *ngFor="let region of resource.regions" class="inline my-0">
<p class=" my-0 py-2 mx-2" >{{region.name}}</p>
</div>
</div>
<div class="flex">
<div class="inline col-3" [ngStyle]="{color:'var(--surface-500)'}">Relevant pest(s)</div>
<div class="inline col-3" [ngStyle]="{color:'var(--surface-500)'}"i18n="@@{relevant_pests}">Relevant pest(s)</div>
<div class="col-9">
<div *ngFor="let pest of resource.pests" class="inline-flex pr-2 pb-2">
<p-badge severity="danger" value={{pest.commonName}}></p-badge>
......@@ -44,7 +52,7 @@
</div>
</div>
<div class="flex">
<div class="inline col-3" [ngStyle]="{color:'var(--surface-500)'}"> Relevant crop(s)</div>
<div class="inline col-3" [ngStyle]="{color:'var(--surface-500)'}" i18n="@@{relevant_crops}"> Relevant crop(s)</div>
<div class="col-9">
<div class="inline-flex pr-2 pb-2" *ngFor="let crop of resource.crops">
<p-badge severity="success" value={{crop.commonName}}></p-badge>
......@@ -54,10 +62,10 @@
</div>
</p-panel>
<p-panel class="col-12 p-d-block" header="Find out more" *ngIf="(resource.fileNames != undefined) || (resource.links != undefined)">
<div *ngFor="let file of resource.fileNames" >
<p-panel class="col-12 p-d-block" i18n-header="@@{find_more}" header="Find out more" *ngIf="(resource.files != undefined) || (resource.links != undefined)">
<div *ngFor="let file of resource.files" >
<i class="pi pi-file p-mr-2" style="font-size: 2rem"></i>
<button pButton type="button" label="{{file}}" class="p-button-link button-link" (click)="downloadFile(file)"></button>
<button pButton type="button" label="{{file.description}}" class="p-button-link button-link" (click)="downloadFile(file.description)"></button>
</div>
<div class="mt-2" *ngFor="let link of resource.links" >
<i class="pi pi-link p-mr-2" style="font-size: 2rem"></i>
......@@ -67,18 +75,19 @@
</div>
<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>
<p-button i18n-label="@@{back_to_search}" label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button>
<p-button i18n-label="@@{share}" label="Share" icon="pi pi-share-alt" class="ml-3"(click)=linkCopied(getPermLink(resource.idResource)) [loading]="false"></p-button>
<p-button i18n-label="@@{download}" label="Download" icon="pi pi-share-alt" class="ml-3"(click)=download(resource) [loading]="false"></p-button>
</div>
<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 i18n-label="@@{approve}" label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button>
</div>
<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 i18n-label="@@{edit}" label="Edit" icon="pi pi-pencil" routerLink="/resource/edit/{{resourceId}}" [loading]="false"></p-button>
</div>
<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 i18n-label="@@{delete]" label="Delete" icon="pi pi-trash" (onClick)="delete($event)" [loading]="false"></p-button>
</div>
</div>
</div>
......@@ -86,7 +95,7 @@
<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>
<label i18n="@@{link}">Link</label>
<input id="link" type="text" [(ngModel)]="copiedLink" pInputText/>
</div>
......
File mode changed from 100644 to 100755
......@@ -8,6 +8,7 @@ import {Observable} from "rxjs";
import {User} from "../../model/user";
import {UserState} from "../../states/user.state";
import {Store} from "@ngxs/store";
import {HttpResponse} from "@angular/common/http";
@Component({
selector: 'app-resource',
......@@ -20,6 +21,7 @@ export class ResourceComponent implements OnInit {
filePath = environment.baseUrl+"/resource/file";
url:any;
resourceId = null;
lang = null;
displayModal=false;
copiedLink="";
// @ts-ignore
......@@ -32,7 +34,10 @@ export class ResourceComponent implements OnInit {
// @ts-ignore
this.resourceId = this.route.snapshot.paramMap.get('id');
// @ts-ignore
this.resourceService.getResource(this.resourceId).subscribe(data =>{
this.lang = this.route.snapshot.paramMap.get('lang');
// @ts-ignore
this.resourceService.getResource(this.resourceId,this.lang).subscribe(data =>{
this.resource =data;
});
......@@ -77,7 +82,7 @@ export class ResourceComponent implements OnInit {
this.resourceService.deleteResource(this.resourceId).subscribe(r =>{
this.messageService.add({severity:'success', detail:'Resource has been deleted.'});
this.router.navigate(['/home'])
},error =>{
},(error: { status: any; }) =>{
this.messageService.add({severity:'error', detail:'Some error occurred!'});
}
);
......@@ -99,4 +104,31 @@ export class ResourceComponent implements OnInit {
this.copiedLink=link;
this.displayModal=true;
}
download(resource:Resource) {
this.resourceService.download(resource).subscribe({
next: (data) => {
// @ts-ignore
if (resource.resourceName ==undefined){
resource.resourceName = "unknown"
}
this.downloadPDF(data as unknown as HttpResponse<any>, resource.resourceName)
},
error: () => {
this.messageService.add({severity:'error', detail:'Some error occurred!'});
}
});
}
private downloadPDF(resp: HttpResponse<any>,fileName:string) {
const content = resp.headers.get('Content-Type');
const blob = new Blob([resp.body], { type: resp.body.type });
const anchor = document.createElement('a');
anchor.href = window.URL.createObjectURL(blob);
anchor.download = fileName +'.pdf';
anchor.target = '_blank';
anchor.dataset.downloadurl = ['text/plain', anchor.download, anchor.href].join(':');
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
}
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -4,15 +4,13 @@ export interface Resource {
description?: string;
descriptionNative?:string;
links?:string[];
fileNames?:string[];
files?:any[];
resourceOrigin?: string;
resourceType?: ResourceType;
sectors?: Sector[];
regions?: Region[];
crops?:Crop[];
pests?:Pest[];
//keywordsTemp?:string[];
//keywords?: Keyword[];
language?: Language;
project?: Project;
projectWeb?: string;
......@@ -20,7 +18,6 @@ export interface Resource {
contactInstitution?: string;
contactEmail?: string;
contactPhone?: string;
contactAddress?:string;
canEdit?:boolean;
citation?:string;
creationDate?:Date;
......@@ -47,13 +44,16 @@ export class ResourceType{
export class Sector{
public idSector!: string;
public name!: string;
public name_sr!: string;
public sectorIcon!:string;
}
export class Region{
public idRegion!: string;
public name!: string;
public code!:string;
}
export class Language{
public idLanguage!: string;
......
File mode changed from 100644 to 100755
......@@ -9,4 +9,5 @@ export class SearchModel {
pest?: Pest[];
crop?: Crop[];
language?: Language[];
title?:string;
}
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -34,8 +34,8 @@ export class ResourceService {
public getResourcesForApproval() {
return this._httpClient.get<Resource []>(`${AppConfig.ApiPaths.getResourcesForApproval}`);
}
public getResource(id:string) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.getResource}`+"/"+id);
public getResource(id:string, lang:string) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.getResource}`+"/"+id+"/"+lang);
}
public hasImage(id:string,type:string) {
return this._httpClient.get<boolean>(`${AppConfig.ApiPaths.hasImage}`+"/"+type+"/"+id);
......@@ -49,6 +49,7 @@ export class ResourceService {
public deleteFile(id:string) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.deleteFile}`+"/"+id);
}
public downloadFile(name: string) {
const httpOptions = {
responseType: 'blob' as 'json',
......@@ -130,6 +131,8 @@ export class ResourceService {
public getAllHelpFilesDesc() {
return this._httpClient.get<FileDesc[]>(`${AppConfig.ApiPaths.getAllHelpFilesDesc}`);
}
public download(resource:Resource){
return this._httpClient.post(`${AppConfig.ApiPaths.download}`,resource,{responseType: 'blob' as 'blob', observe: 'response'})
}
}
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -12,12 +12,18 @@ export class AppConfig {
approveResource: `${AppConfig.Origin}/admin/approve`,
deleteResource: `${AppConfig.Origin}/admin/delete`,
deleteFile: `${AppConfig.Origin}/file/delete`,
getFile: `${AppConfig.Origin}/resource/file`,
getFileById: `${AppConfig.Origin}/file/get`,
saveResource: `${AppConfig.Origin}/resource/saveResource`,
searchResource: `${AppConfig.Origin}/resource/search`,
addFile: `${AppConfig.Origin}/resource/add`,
searchResource: `${AppConfig.Origin}/resource/search`,
addFile: `${AppConfig.Origin}/resource/add`,
addHelpFile: `${AppConfig.Origin}/file/add`,
download: `${AppConfig.Origin}/resource/download`,
getAllLanguages: `${AppConfig.Origin}/codebooks/getAllLanguages`,
......@@ -28,12 +34,14 @@ export class AppConfig {
getAllPests: `${AppConfig.Origin}/codebooks/getAllPests`,
getAllCrops: `${AppConfig.Origin}/codebooks/getAllCrops`,
getAllKeywords: `${AppConfig.Origin}/codebooks/getAllKeywords`,
getAllHelpFilesDesc: `${AppConfig.Origin}/file/help/list`,
login:`${AppConfig.Origin}/auth/authenticate`,
startChangingPassword:`${AppConfig.Origin}/auth/startChangingPassword`,
getUserName:`${AppConfig.Origin}/auth/validateToken`,
changePassword:`${AppConfig.Origin}/auth/changePassword`
};
}
......
......@@ -5,7 +5,10 @@
<title>IPMworks toolbox</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="assets/logo.png"></head>
<link rel="icon" href="assets/logo.png">
<script defer data-domain="ipmworks.net/toolbox" src=https://plausible.io/js/script.js></script>
<script defer data-domain="ipmworks.net" src=https://plausible.io/js/script.js></script>
</head>
<body>
<app-root></app-root>
</body>
......
/***************************************************************************************************
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
*/
import '@angular/localize/init';
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
......
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