some minor changes

parent df535bda
#Sun May 30 15:06:06 CEST 2021 #Fri Feb 17 18:28:47 CET 2023
gradle.version=6.7 gradle.version=7.6
...@@ -7,6 +7,47 @@ ...@@ -7,6 +7,47 @@
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"ipmworks-web": { "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", "projectType": "application",
"schematics": { "schematics": {
"@schematics/angular:application": { "@schematics/angular:application": {
...@@ -20,6 +61,8 @@ ...@@ -20,6 +61,8 @@
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"localize": true,
"aot": true,
"outputPath": "dist/ipmworks-web", "outputPath": "dist/ipmworks-web",
"index": "src/index.html", "index": "src/index.html",
"baseHref": "/toolbox/", "baseHref": "/toolbox/",
...@@ -35,7 +78,9 @@ ...@@ -35,7 +78,9 @@
"./node_modules/primeicons/primeicons.css", "./node_modules/primeicons/primeicons.css",
"./node_modules/primeng/resources/themes/mdc-light-indigo/theme.css", "./node_modules/primeng/resources/themes/mdc-light-indigo/theme.css",
"./node_modules/primeng/resources/primeng.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": [] "scripts": []
}, },
...@@ -47,12 +92,12 @@ ...@@ -47,12 +92,12 @@
{ {
"type": "initial", "type": "initial",
"maximumWarning": "10mb", "maximumWarning": "10mb",
"maximumError": "5mb" "maximumError": "10mb"
}, },
{ {
"type": "anyComponentStyle", "type": "anyComponentStyle",
"maximumWarning": "5mb", "maximumWarning": "10mb",
"maximumError": "4kb" "maximumError": "10mb"
} }
], ],
"fileReplacements": [ "fileReplacements": [
......
...@@ -10,8 +10,8 @@ repositories { ...@@ -10,8 +10,8 @@ repositories {
} }
node { node {
version = '14.15.5' version = '18.13.0'
npmVersion = '6.14.11' npmVersion = '9.4.0'
download = true download = true
} }
......
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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 @@ ...@@ -22,19 +22,21 @@
"@ngxs/store": "^3.5.0", "@ngxs/store": "^3.5.0",
"lazysizes": "^5.3.2", "lazysizes": "^5.3.2",
"ng-lazyload-image": "^9.1.2", "ng-lazyload-image": "^9.1.2",
"ngx-clipboard": "~15.1.0",
"primeflex": "~3.1.3", "primeflex": "~3.1.3",
"primeicons": "~5.0.0", "primeicons": "~5.0.0",
"primeng": "~13.2.1", "primeng": "~13.2.1",
"quill": "^1.3.7",
"rxjs": "~6.6.0", "rxjs": "~6.6.0",
"tslib": "^2.1.0", "tslib": "^2.1.0",
"zone.js": "~0.11.4", "zone.js": "~0.11.4"
"ngx-clipboard": "~15.1.0"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^13.2.6", "@angular-devkit/build-angular": "^13.2.6",
"@angular/cdk": "~13.2.6", "@angular/cdk": "~13.2.6",
"@angular/cli": "~13.2.6", "@angular/cli": "~13.2.6",
"@angular/compiler-cli": "~13.2.6", "@angular/compiler-cli": "~13.2.6",
"@angular/localize": "~13.2.6",
"@types/jasmine": "~3.10.3", "@types/jasmine": "~3.10.3",
"@types/node": "^14.0.0", "@types/node": "^14.0.0",
"jasmine-core": "~4.0.1", "jasmine-core": "~4.0.1",
...@@ -43,6 +45,7 @@ ...@@ -43,6 +45,7 @@
"karma-coverage": "~2.0.3", "karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0", "karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0", "karma-jasmine-html-reporter": "^1.5.0",
"lite-server": "^2.6.1",
"typescript": "~4.4.2" "typescript": "~4.4.2"
} }
} }
import { NgModule } from '@angular/core'; import {NgModule, OnInit} from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import {ActivatedRoute, Router, RouterModule, Routes} from '@angular/router';
import {HomeComponent} from './component/home/home.component'; import {HomeComponent} from './component/home/home.component';
import {ResourceComponent} from "./component/resource/resource.component"; import {ResourceComponent} from "./component/resource/resource.component";
import {AddResourceComponent} from "./component/add-resource/add-resource.component"; import {AddResourceComponent} from "./component/add-resource/add-resource.component";
...@@ -7,15 +7,20 @@ import {ApproveResourceComponent} from "./component/approve-resource/approve-res ...@@ -7,15 +7,20 @@ import {ApproveResourceComponent} from "./component/approve-resource/approve-res
import {LoginComponent} from "./component/login/login.component"; import {LoginComponent} from "./component/login/login.component";
import {AuthGuard} from "./guard/auth.guard"; import {AuthGuard} from "./guard/auth.guard";
import {ChangePasswordComponent} from "./component/change-password/change-password.component"; import {ChangePasswordComponent} from "./component/change-password/change-password.component";
import {HelpComponent} from "./component/help/help.component";
import {AppComponent} from "./app.component";
const routes: Routes = [ const routes: Routes = [
{path: '', component: HomeComponent, pathMatch: 'full'}, {path: '', component: HomeComponent, pathMatch: 'full'},
{path: 'export', component: HomeComponent, pathMatch: 'full',data:{header:"none"}},
{path: 'home', component: HomeComponent, pathMatch: 'full'}, {path: 'home', component: HomeComponent, pathMatch: 'full'},
{path:'resource/approve', component:ApproveResourceComponent, pathMatch:'full',canActivate:[AuthGuard]}, {path:'resource/approve', component:ApproveResourceComponent, pathMatch:'full',canActivate:[AuthGuard]},
{path:'resource/add', component:AddResourceComponent, pathMatch:'full'}, {path:'resource/add', component:AddResourceComponent, pathMatch:'full'},
{path:'resource/edit/:id',component:AddResourceComponent,pathMatch:'full',canActivate:[AuthGuard]}, {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:'resource/:id', component:ResourceComponent, pathMatch:'full'},
{path:'login', component:LoginComponent, pathMatch:'full'}, {path:'login', component:LoginComponent, pathMatch:'full'},
{path:'help', component:HelpComponent, pathMatch:'full'},
{path:'changePassword/:token', component:ChangePasswordComponent, pathMatch:'full'} {path:'changePassword/:token', component:ChangePasswordComponent, pathMatch:'full'}
...@@ -23,7 +28,9 @@ const routes: Routes = [ ...@@ -23,7 +28,9 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes,{ onSameUrlNavigation: 'reload' })], imports: [RouterModule.forRoot(routes,{onSameUrlNavigation: 'reload', scrollPositionRestoration: 'enabled'})],
exports: [RouterModule] 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"> <div class="container-fluid py-4">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
......
import {Component, OnDestroy, OnInit} from "@angular/core"; import {Component, OnDestroy, OnInit} from "@angular/core";
import {LogoutAction, UserState} from "./states/user.state"; import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
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";
@Component({ @Component({
...@@ -14,9 +8,17 @@ import {User} from "./model/user"; ...@@ -14,9 +8,17 @@ import {User} from "./model/user";
styleUrls: ['./app.component.css'] styleUrls: ['./app.component.css']
}) })
export class AppComponent{ export class AppComponent implements OnInit{
title = 'ipmworks-web'; 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 { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
...@@ -13,7 +13,6 @@ import {CheckboxModule} from 'primeng/checkbox'; ...@@ -13,7 +13,6 @@ import {CheckboxModule} from 'primeng/checkbox';
import {FormsModule, ReactiveFormsModule} from "@angular/forms"; import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {DataViewModule} from "primeng/dataview"; import {DataViewModule} from "primeng/dataview";
import {RatingModule} from "primeng/rating"; import {RatingModule} from "primeng/rating";
import {RouterModule} from "@angular/router";
import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http"; import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http";
import {MultiSelectModule} from 'primeng/multiselect'; import {MultiSelectModule} from 'primeng/multiselect';
import {DropdownModule} from "primeng/dropdown"; import {DropdownModule} from "primeng/dropdown";
...@@ -21,8 +20,8 @@ import {InputTextModule} from "primeng/inputtext"; ...@@ -21,8 +20,8 @@ import {InputTextModule} from "primeng/inputtext";
import {TooltipModule} from "primeng/tooltip"; import {TooltipModule} from "primeng/tooltip";
import {CardModule} from "primeng/card"; import {CardModule} from "primeng/card";
import {TagModule} from "primeng/tag"; import {TagModule} from "primeng/tag";
import { ResourceComponent } from './component/resource/resource.component'; import {ResourceComponent } from './component/resource/resource.component';
import { AddResourceComponent } from './component/add-resource/add-resource.component'; import {AddResourceComponent } from './component/add-resource/add-resource.component';
import {InputTextareaModule} from "primeng/inputtextarea"; import {InputTextareaModule} from "primeng/inputtextarea";
import {RadioButtonModule} from "primeng/radiobutton"; import {RadioButtonModule} from "primeng/radiobutton";
import {FileUploadModule} from "primeng/fileupload"; import {FileUploadModule} from "primeng/fileupload";
...@@ -47,10 +46,19 @@ import {ImageModule} from "primeng/image"; ...@@ -47,10 +46,19 @@ import {ImageModule} from "primeng/image";
import {ConfirmPopupModule} from 'primeng/confirmpopup'; import {ConfirmPopupModule} from 'primeng/confirmpopup';
import {ConfirmationService} from 'primeng/api'; import {ConfirmationService} from 'primeng/api';
import {ConfirmDialogModule} from "primeng/confirmdialog"; import {ConfirmDialogModule} from "primeng/confirmdialog";
import {LAZYLOAD_IMAGE_HOOKS, LazyLoadImageModule, ScrollHooks} from 'ng-lazyload-image'; import {LazyLoadImageModule} from 'ng-lazyload-image';
import { FooterComponent } from './component/footer/footer.component'; import {FooterComponent } from './component/footer/footer.component';
import { ChangePasswordComponent } from './component/change-password/change-password.component'; import {ChangePasswordComponent } from './component/change-password/change-password.component';
import { CheckPasswordDirective } from './validator/check-password.directive'; 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({ @NgModule({
declarations: [ declarations: [
...@@ -63,60 +71,67 @@ import { CheckPasswordDirective } from './validator/check-password.directive'; ...@@ -63,60 +71,67 @@ import { CheckPasswordDirective } from './validator/check-password.directive';
HeaderMenuComponent, HeaderMenuComponent,
FooterComponent, FooterComponent,
ChangePasswordComponent, ChangePasswordComponent,
CheckPasswordDirective CheckPasswordDirective,
], HelpComponent
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
], ],
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, providers: [MessageService,ConfirmationService,
{provide: LocationStrategy, useClass: HashLocationStrategy},
{ {
provide: LocationStrategy, useClass: HashLocationStrategy, provide: HTTP_INTERCEPTORS,
},{ useClass: AuthInterceptor,
provide: HTTP_INTERCEPTORS, multi: true
useClass: AuthInterceptor, }
multi: true ],
}],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }
File mode changed from 100644 to 100755
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 {ResourceType, Language, Region, Sector, Project, Resource, Pest, Crop} from "../../model/resource";
import {ResourceService} from "../../service/resource.service"; import {ResourceService} from "../../service/resource.service";
import {MessageService} from 'primeng/api'; import {ConfirmationService, MessageService} from 'primeng/api';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {FormControl} from "@angular/forms"; import {FormControl} from "@angular/forms";
import {environment} from "../../../environments/environment"; import {environment} from "../../../environments/environment";
...@@ -36,8 +36,10 @@ export class AddResourceComponent implements OnInit { ...@@ -36,8 +36,10 @@ export class AddResourceComponent implements OnInit {
logo: any; logo: any;
showOldLogo = true; showOldLogo = true;
logoExist:boolean = false; 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 { ngOnInit(): void {
this.resourceService.getAllSectors().subscribe((sectors: Sector[]) => { this.resourceService.getAllSectors().subscribe((sectors: Sector[]) => {
...@@ -75,11 +77,9 @@ export class AddResourceComponent implements OnInit { ...@@ -75,11 +77,9 @@ export class AddResourceComponent implements OnInit {
} }
saveResource(){ saveResource(){
this.resource.canEdit=true;
this.resourceService.saveResource(this.resource,this.edit).subscribe((data: Resource) => { this.resourceService.saveResource(this.resource,this.edit).subscribe((data: Resource) => {
this.resource = data; 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 => { this.resourceService.addFiles(this.image, this.logo, this.resourceContent, this.resource.idResource).subscribe(data => {
if(!this.edit){ if(!this.edit){
this.messageService.add({severity: 'success', detail: 'Resource is saved, but need to be approved by administrator!'}); 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 { ...@@ -156,4 +156,37 @@ export class AddResourceComponent implements OnInit {
this.logo=undefined; this.logo=undefined;
this.showOldLogo = true; 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"> <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" > <p-table [value]="resources" [paginator]="true" [rows]="10" >
<ng-template pTemplate="header"> <ng-template pTemplate="header">
<tr> <tr>
<th>Resource name</th> <th i18n>Resource name</th>
<th>Resource type</th> <th i18n>Resource type</th>
<th>Creation date</th> <th i18n>Creation date</th>
<th i18n>How resource added</th>
<th></th> <th></th>
</tr> </tr>
</ng-template> </ng-template>
...@@ -14,6 +15,7 @@ ...@@ -14,6 +15,7 @@
<td>{{resource.resourceName}}</td> <td>{{resource.resourceName}}</td>
<td>{{resource.resourceType?.name}}</td> <td>{{resource.resourceType?.name}}</td>
<td>{{resource.creationDate| date:"d.M.yyyy, h:mm a"}}</td> <td>{{resource.creationDate| date:"d.M.yyyy, h:mm a"}}</td>
<td i18n>Manually</td>
<td> <td>
<button pButton type="button" routerLink="/resource/{{resource.idResource}}" icon="pi pi-pencil"></button> <button pButton type="button" routerLink="/resource/{{resource.idResource}}" icon="pi pi-pencil"></button>
</td> </td>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -5,22 +5,22 @@ ...@@ -5,22 +5,22 @@
<div class="field"> <div class="field">
<span class="p-float-label"> <span class="p-float-label">
<input type="password" id="password" pInputText formControlName="password"> <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> </span>
</div> </div>
<div class="field"> <div class="field">
<span class="p-float-label"> <span class="p-float-label">
<input type="password" id="confirmedPassword" pInputText formControlName="confirmedPassword"> <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> </span>
</div> </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! Passwords does not match!
</div> </div>
</div> </div>
<div class="field flex justify-content-center pt-4"> <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> </div>
</form> </form>
</div> </div>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<img src="assets/EUFlag.png"/> <img src="assets/EUFlag.png"/>
</div> </div>
<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. This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No. 101000339.
</p> </p>
</div> </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"> <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> </ng-template>
</p-menubar> </p-menubar>
<p-toast></p-toast> <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 {MenuItem, MessageService, PrimeNGConfig} from "primeng/api";
import {Observable, Subject} from "rxjs"; import {Observable, Subject} from "rxjs";
import {User} from "../../model/user"; import {User} from "../../model/user";
import {LogoutAction, UserState} from "../../states/user.state"; import {LogoutAction, UserState} from "../../states/user.state";
import {Select, Store} from "@ngxs/store"; 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 {filter, takeUntil} from "rxjs/operators";
import { LOCALE_ID, Inject } from '@angular/core';
export class LanguageTrans{
public name?: string;
public code?:string;
}
@Component({ @Component({
selector: 'app-header-menu', selector: 'app-header-menu',
templateUrl: './header-menu.component.html', templateUrl: './header-menu.component.html',
...@@ -19,49 +24,53 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{ ...@@ -19,49 +24,53 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
// @ts-ignore // @ts-ignore
public loggeduser: Observable<User> = this.store.select(UserState.userDetails); public loggeduser: Observable<User> = this.store.select(UserState.userDetails);
logged?:boolean 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() { initialise() {
this.logged = this.isLogged(); this.logged = this.isLogged();
// @ts-ignore // @ts-ignore
this.items = [ this.items = [
{ {
label: 'Home', label: $localize `Home`,
routerLink:'/home', routerLink:'/home',
styleClass:"pr-2 ", styleClass:"pr-2 ",
}, },
{ {
label: 'Add resource', label: $localize `Add resource`,
url:'#/resource/add', url:'#/resource/add',
styleClass:"pr-2", styleClass:"pr-2",
target:"_blank" target:"_blank"
}, },
{ {
label: 'Approve', label: $localize `Approve`,
routerLink:'/resource/approve', routerLink:'/resource/approve',
styleClass:"pr-2", styleClass:"pr-2",
visible:this.isUserAdmin() visible:this.isUserAdmin()
}, },
{ {
label: 'IPMWORKS Project', label:$localize `IPMWORKS Project`,
url:'http://ipmworks.net', url:'http://ipmworks.net',
styleClass:"pr-2", styleClass:"pr-2",
target:"_blank" target:"_blank"
}, },
{ {
label: 'Help and Support', label: $localize`Help and Support`,
routerLink:'/help', routerLink:'/help',
styleClass:"pr-2", styleClass:"pr-2",
target:"_blank" target:"_blank"
}, },
{ {
label: 'Logout', label: $localize `Logout`,
command:(event) => {this.logout()}, command:(event) => {this.logout()},
styleClass:"pr-2", styleClass:"pr-2",
visible:this.logged visible:this.logged
}, },
{ {
label: 'Login', label: $localize `Login`,
routerLink:'/login', routerLink:'/login',
styleClass:"pr-2", styleClass:"pr-2",
visible:!this.logged visible:!this.logged
...@@ -69,12 +78,38 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{ ...@@ -69,12 +78,38 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
] ]
} }
ngOnInit(): void { 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), this.router.events.pipe(filter((event) => event instanceof NavigationEnd),
takeUntil(this.destroyed) takeUntil(this.destroyed)
).subscribe(() => { ).subscribe(() => {
this.router.routeReuseStrategy.shouldReuseRoute = function() { return false; }; this.router.routeReuseStrategy.shouldReuseRoute = function() { return false; };
this.initialise(); 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() { public isUserAdmin() {
var admin = false; var admin = false;
...@@ -110,6 +145,11 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{ ...@@ -110,6 +145,11 @@ export class HeaderMenuComponent implements OnInit,OnDestroy{
this.router.navigate(['/home']); this.router.navigate(['/home']);
this.messageService.add({severity:"success", detail:"Goodbye!"}) 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 @@ ...@@ -34,3 +34,8 @@
padding:5px; padding:5px;
display: inline-block; display: inline-block;
} }
.hoverResource:hover{
background: rgba(63, 81, 181, 0.04);
cursor: pointer;
}
import {Component, OnDestroy, OnInit} from '@angular/core'; import {Component, Inject, LOCALE_ID, OnDestroy, OnInit} from '@angular/core';
import { import {
Crop, Crop,
Keyword, Keyword,
...@@ -16,6 +16,7 @@ import {Message, MessageService} from "primeng/api"; ...@@ -16,6 +16,7 @@ import {Message, MessageService} from "primeng/api";
import {environment} from "../../../environments/environment"; import {environment} from "../../../environments/environment";
import {SearchModel} from "../../model/search-model"; import {SearchModel} from "../../model/search-model";
import {NavigationEnd, Router} from "@angular/router"; import {NavigationEnd, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.component.html', templateUrl: './home.component.html',
...@@ -48,13 +49,14 @@ export class HomeComponent implements OnInit{ ...@@ -48,13 +49,14 @@ export class HomeComponent implements OnInit{
selectedPestType: string | undefined; selectedPestType: string | undefined;
serachRunning= false; serachRunning= false;
searchTerm: string = ""; searchTerm: string = "";
more= false; more= true;
close = false; close = false;
imagePath = environment.baseUrl+"/resource/image"; imagePath = environment.baseUrl+"/resource/image";
imagePathRaw = environment.baseUrl+"/resource/image/raw"; imagePathRaw = environment.baseUrl+"/resource/image/raw";
searchModel:SearchModel = {}; searchModel:SearchModel = {};
loading:boolean = true;
constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService) { counter:number = 0;
constructor(private resourceService:ResourceService, private router:Router,private messageService: MessageService, @Inject(LOCALE_ID) public locale: string) {
this.pageableResponse = {totalElements:0} this.pageableResponse = {totalElements:0}
} }
...@@ -121,7 +123,9 @@ export class HomeComponent implements OnInit{ ...@@ -121,7 +123,9 @@ export class HomeComponent implements OnInit{
this.totalElements = this.pageableResponse.totalElements; this.totalElements = this.pageableResponse.totalElements;
} }
public resetSearch(){ public resetSearch(){
this.serachRunning=true; this.router.navigate(['home']);
/*this.serachRunning=true;
this.resourceService.getAllResources().subscribe((resources: PageableResource) => { this.resourceService.getAllResources().subscribe((resources: PageableResource) => {
// @ts-ignore // @ts-ignore
this.resources = resources.content; this.resources = resources.content;
...@@ -129,12 +133,46 @@ export class HomeComponent implements OnInit{ ...@@ -129,12 +133,46 @@ export class HomeComponent implements OnInit{
this.totalElements = resources.totalElements; this.totalElements = resources.totalElements;
this.searchModel = {}; this.searchModel = {};
this.search = false; this.search = false;
this.serachRunning=false; this.serachRunning=false;*/
}); //});
} }
isEmptySearch(){ isEmptySearch(){
return JSON.stringify(this.searchModel) === '{}'; 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 @@ ...@@ -4,27 +4,27 @@
<div class="field"> <div class="field">
<span class="p-float-label"> <span class="p-float-label">
<input type="email" id="username" pInputText formControlName="username"> <input type="email" id="username" pInputText formControlName="username">
<label for="username">Username</label> <label for="username" i18n="@@{username}">Username</label>
</span> </span>
</div> </div>
<div class="field"> <div class="field">
<span class="p-float-label"> <span class="p-float-label">
<input type="password" id="password" pInputText formControlName="password"> <input type="password" id="password" pInputText formControlName="password">
<label for="username">Password</label> <label for="username" i18n="@@{password}">Password</label>
</span> </span>
</div> </div>
<div class="field flex justify-content-center pt-4"> <div class="field flex justify-content-center pt-4">
<p-button class="pr-4" type="submit" (click)="signIn()">Login</p-button> <p-button class="pr-4" type="submit" (click)="signIn()" i18n="@@{login}">Login</p-button>
<p-button label="Forgot password?" (click)="displayDialog()" styleClass="p-button-link"></p-button> <p-button i18n-label="@@{forgot_password}" label="Forgot password?" (click)="displayDialog()" styleClass="p-button-link"></p-button>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
<p-dialog [(visible)]="display" [breakpoints]="{'960px': '75vw', '640px': '100vw'}" [style]="{width: '50vw'} "> <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"> <input type="text" pInputText [(ngModel)]="email">
<div class="pt-4" > <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> </div>
</p-dialog> </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 @@ ...@@ -27,3 +27,6 @@
white-space: -o-pre-wrap; /* Opera 7 */ white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */ 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"> <div class="flex col-12 justify-content-center">
<p class="text-3xl">{{resource.resourceName}} <p class="text-3xl">{{resource.resourceName}}
</p> </p>
</div> </div>
<div class="col-6 flex flex-column"> <div class="md:col-6 flex flex-column">
<div class="col-12 text-center"> <div class="col-12 text-center">
<img [src]="imagePath+'/'+resourceId" class="imageSize" > <img [src]="imagePath+'/'+resourceId" class="imageSize" >
</div> </div>
<div class="col-12"> <div class="col-12">
<p-panel class="col-12 inline"> <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)'}" 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)'}">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="@@{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)'}">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="@@{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)'}">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="@@{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)'}">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="@@{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)'}">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="@@{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)'}">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)'}" 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)'}">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="@@{citation}">Citation (DOI)</div><div class="overflow-text my-0">{{resource.citation}}</div></div>
</p-panel> </p-panel>
</div> </div>
</div> </div>
<div class="col-6 flex flex-column"> <div class="md:col-6 flex flex-column">
<p-panel header="Short summary" class="col-12 p-d-block"> <p-panel i18n-header="@@{short_summary}" header="Short summary" class="col-12 p-d-block">
<div class="flex"> {{resource.description}}</div> <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="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"> <div class="inline my-0" *ngFor="let sector of resource.sectors">
<img class="sector mx-2" [src]="'assets/sectors/'+sector.sectorIcon" pTooltip="{{sector.name}}"> <img class="sector mx-2" [src]="'assets/sectors/'+sector.sectorIcon" pTooltip="{{sector.name}}">
</div> </div>
</div> </div>
<div class="flex flex-wrap"> <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"> <div *ngFor="let region of resource.regions" class="inline my-0">
<p class=" my-0 py-2 mx-2" >{{region.name}}</p> <p class=" my-0 py-2 mx-2" >{{region.name}}</p>
</div> </div>
</div> </div>
<div class="flex"> <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 class="col-9">
<div *ngFor="let pest of resource.pests" class="inline-flex pr-2 pb-2"> <div *ngFor="let pest of resource.pests" class="inline-flex pr-2 pb-2">
<p-badge severity="danger" value={{pest.commonName}}></p-badge> <p-badge severity="danger" value={{pest.commonName}}></p-badge>
...@@ -44,7 +52,7 @@ ...@@ -44,7 +52,7 @@
</div> </div>
</div> </div>
<div class="flex"> <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="col-9">
<div class="inline-flex pr-2 pb-2" *ngFor="let crop of resource.crops"> <div class="inline-flex pr-2 pb-2" *ngFor="let crop of resource.crops">
<p-badge severity="success" value={{crop.commonName}}></p-badge> <p-badge severity="success" value={{crop.commonName}}></p-badge>
...@@ -54,10 +62,10 @@ ...@@ -54,10 +62,10 @@
</div> </div>
</p-panel> </p-panel>
<p-panel class="col-12 p-d-block" header="Find out more" *ngIf="(resource.fileNames != undefined) || (resource.links != undefined)"> <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.fileNames" > <div *ngFor="let file of resource.files" >
<i class="pi pi-file p-mr-2" style="font-size: 2rem"></i> <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>
<div class="mt-2" *ngFor="let link of resource.links" > <div class="mt-2" *ngFor="let link of resource.links" >
<i class="pi pi-link p-mr-2" style="font-size: 2rem"></i> <i class="pi pi-link p-mr-2" style="font-size: 2rem"></i>
...@@ -67,18 +75,19 @@ ...@@ -67,18 +75,19 @@
</div> </div>
<div class="col-12 pt-3 flex justify-content-center"> <div class="col-12 pt-3 flex justify-content-center">
<div class="pr-2"> <div class="pr-2">
<p-button label="Back to search" icon="pi pi-search" routerLink="/home" [loading]="false"></p-button> <p-button i18n-label="@@{back_to_search}" 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="@@{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>
<div class="pr-2" *ngIf="!resource.approved && resource.canEdit && (loggeduser| async)?.roles?.includes('ADMIN')"> <div class="pr-2" *ngIf="!resource.approved && resource.canEdit && (loggeduser| async)?.roles?.includes('ADMIN')">
<p-button label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button> <p-button i18n-label="@@{approve}" label="Approve" icon="pi pi-check" (onClick)="approve($event)" [loading]="false"></p-button>
</div> </div>
<div class="pr-2" *ngIf="(loggeduser| async)?.roles?.includes('ADMIN') && resource.canEdit"> <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>
<div *ngIf="(loggeduser| async)?.roles?.includes('ADMIN') && resource.canEdit"> <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> </div>
</div> </div>
...@@ -86,7 +95,7 @@ ...@@ -86,7 +95,7 @@
<p-confirmDialog></p-confirmDialog> <p-confirmDialog></p-confirmDialog>
<p-dialog id="shareModal" name="shareModal" header="Copy link to share" [(visible)]="displayModal" [style]="{width: '40vw'}"> <p-dialog id="shareModal" name="shareModal" header="Copy link to share" [(visible)]="displayModal" [style]="{width: '40vw'}">
<div class="field"> <div class="field">
<label>Link</label> <label i18n="@@{link}">Link</label>
<input id="link" type="text" [(ngModel)]="copiedLink" pInputText/> <input id="link" type="text" [(ngModel)]="copiedLink" pInputText/>
</div> </div>
......
File mode changed from 100644 to 100755
...@@ -8,6 +8,7 @@ import {Observable} from "rxjs"; ...@@ -8,6 +8,7 @@ import {Observable} from "rxjs";
import {User} from "../../model/user"; import {User} from "../../model/user";
import {UserState} from "../../states/user.state"; import {UserState} from "../../states/user.state";
import {Store} from "@ngxs/store"; import {Store} from "@ngxs/store";
import {HttpResponse} from "@angular/common/http";
@Component({ @Component({
selector: 'app-resource', selector: 'app-resource',
...@@ -20,6 +21,7 @@ export class ResourceComponent implements OnInit { ...@@ -20,6 +21,7 @@ export class ResourceComponent implements OnInit {
filePath = environment.baseUrl+"/resource/file"; filePath = environment.baseUrl+"/resource/file";
url:any; url:any;
resourceId = null; resourceId = null;
lang = null;
displayModal=false; displayModal=false;
copiedLink=""; copiedLink="";
// @ts-ignore // @ts-ignore
...@@ -32,7 +34,10 @@ export class ResourceComponent implements OnInit { ...@@ -32,7 +34,10 @@ export class ResourceComponent implements OnInit {
// @ts-ignore // @ts-ignore
this.resourceId = this.route.snapshot.paramMap.get('id'); this.resourceId = this.route.snapshot.paramMap.get('id');
// @ts-ignore // @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; this.resource =data;
}); });
...@@ -77,7 +82,7 @@ export class ResourceComponent implements OnInit { ...@@ -77,7 +82,7 @@ export class ResourceComponent implements OnInit {
this.resourceService.deleteResource(this.resourceId).subscribe(r =>{ this.resourceService.deleteResource(this.resourceId).subscribe(r =>{
this.messageService.add({severity:'success', detail:'Resource has been deleted.'}); this.messageService.add({severity:'success', detail:'Resource has been deleted.'});
this.router.navigate(['/home']) this.router.navigate(['/home'])
},error =>{ },(error: { status: any; }) =>{
this.messageService.add({severity:'error', detail:'Some error occurred!'}); this.messageService.add({severity:'error', detail:'Some error occurred!'});
} }
); );
...@@ -99,4 +104,31 @@ export class ResourceComponent implements OnInit { ...@@ -99,4 +104,31 @@ export class ResourceComponent implements OnInit {
this.copiedLink=link; this.copiedLink=link;
this.displayModal=true; 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 { ...@@ -4,15 +4,13 @@ export interface Resource {
description?: string; description?: string;
descriptionNative?:string; descriptionNative?:string;
links?:string[]; links?:string[];
fileNames?:string[]; files?:any[];
resourceOrigin?: string; resourceOrigin?: string;
resourceType?: ResourceType; resourceType?: ResourceType;
sectors?: Sector[]; sectors?: Sector[];
regions?: Region[]; regions?: Region[];
crops?:Crop[]; crops?:Crop[];
pests?:Pest[]; pests?:Pest[];
//keywordsTemp?:string[];
//keywords?: Keyword[];
language?: Language; language?: Language;
project?: Project; project?: Project;
projectWeb?: string; projectWeb?: string;
...@@ -20,7 +18,6 @@ export interface Resource { ...@@ -20,7 +18,6 @@ export interface Resource {
contactInstitution?: string; contactInstitution?: string;
contactEmail?: string; contactEmail?: string;
contactPhone?: string; contactPhone?: string;
contactAddress?:string;
canEdit?:boolean; canEdit?:boolean;
citation?:string; citation?:string;
creationDate?:Date; creationDate?:Date;
...@@ -47,13 +44,16 @@ export class ResourceType{ ...@@ -47,13 +44,16 @@ export class ResourceType{
export class Sector{ export class Sector{
public idSector!: string; public idSector!: string;
public name!: string; public name!: string;
public name_sr!: string;
public sectorIcon!:string; public sectorIcon!:string;
} }
export class Region{ export class Region{
public idRegion!: string; public idRegion!: string;
public name!: string; public name!: string;
public code!:string; public code!:string;
} }
export class Language{ export class Language{
public idLanguage!: string; public idLanguage!: string;
......
File mode changed from 100644 to 100755
...@@ -9,4 +9,5 @@ export class SearchModel { ...@@ -9,4 +9,5 @@ export class SearchModel {
pest?: Pest[]; pest?: Pest[];
crop?: Crop[]; crop?: Crop[];
language?: Language[]; 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 { ...@@ -34,8 +34,8 @@ export class ResourceService {
public getResourcesForApproval() { public getResourcesForApproval() {
return this._httpClient.get<Resource []>(`${AppConfig.ApiPaths.getResourcesForApproval}`); return this._httpClient.get<Resource []>(`${AppConfig.ApiPaths.getResourcesForApproval}`);
} }
public getResource(id:string) { public getResource(id:string, lang:string) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.getResource}`+"/"+id); return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.getResource}`+"/"+id+"/"+lang);
} }
public hasImage(id:string,type:string) { public hasImage(id:string,type:string) {
return this._httpClient.get<boolean>(`${AppConfig.ApiPaths.hasImage}`+"/"+type+"/"+id); return this._httpClient.get<boolean>(`${AppConfig.ApiPaths.hasImage}`+"/"+type+"/"+id);
...@@ -49,6 +49,7 @@ export class ResourceService { ...@@ -49,6 +49,7 @@ export class ResourceService {
public deleteFile(id:string) { public deleteFile(id:string) {
return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.deleteFile}`+"/"+id); return this._httpClient.get<Resource>(`${AppConfig.ApiPaths.deleteFile}`+"/"+id);
} }
public downloadFile(name: string) { public downloadFile(name: string) {
const httpOptions = { const httpOptions = {
responseType: 'blob' as 'json', responseType: 'blob' as 'json',
...@@ -130,6 +131,8 @@ export class ResourceService { ...@@ -130,6 +131,8 @@ export class ResourceService {
public getAllHelpFilesDesc() { public getAllHelpFilesDesc() {
return this._httpClient.get<FileDesc[]>(`${AppConfig.ApiPaths.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
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