[Trunk | Library]:

1. error.module & errorPage.component: Set canonical url to '/error'.
2. dataProvider.component & organization.component & project.component & resultLanding.component: Use 'location.path(true)' for page parameter in error navigation.
3. organization.service: [Bug fix]: Initialize 'objIdentifier' field only when an organization was found.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57536 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-11-07 09:51:09 +00:00
parent 3c044f5b79
commit 90f748f8e6
7 changed files with 41 additions and 29 deletions

View File

@ -4,10 +4,11 @@ import {FormsModule} from '@angular/forms';
import {ErrorPageComponent} from './errorPage.component';
import {RouterModule} from "@angular/router";
import { SEOServiceModule } from '../sharedComponents/SEO/SEOService.module';
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule
CommonModule, FormsModule, RouterModule, SEOServiceModule
],
providers: [],
declarations: [

View File

@ -4,6 +4,7 @@ import {ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {RESPONSE} from "@nguniversal/express-engine/tokens";
import {EnvProperties} from "../utils/properties/env-properties";
import {SEOService} from "../sharedComponents/SEO/SEO.service";
@Component({
selector: 'error',
@ -43,7 +44,8 @@ export class ErrorPageComponent {
constructor (private _location: Location, private _meta: Meta,
private _title: Title, private route: ActivatedRoute,
@Optional() @Inject(RESPONSE) private response: any) {
@Optional() @Inject(RESPONSE) private response: any,
private seoService: SEOService) {
var title = "OpenAIRE | Error page";
@ -58,16 +60,19 @@ export class ErrorPageComponent {
this.response.statusCode = 404;
this.response.statusMessage = '404 - Page not found';
}
this.route.queryParams.subscribe(data => {
this.page = data['page'];
if (!this.page) {
this.page = this._location.path(true);
}
this.page_type = data['page_type'];
if(this.page_type) {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
let properties = data.envSpecific;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
let properties = data.envSpecific;
this.seoService.createLinkForCanonicalURL(properties.baseLink + "/error");
this.route.queryParams.subscribe(data => {
this.page = data['page'];
if (!this.page) {
this.page = this._location.path(true);
}
this.page_type = data['page_type'];
if(this.page_type) {
if (this.page_type == "publication") {
this.searchPage = properties.searchLinkToPublications;
this.page_type_name = "publication";
@ -90,8 +95,8 @@ export class ErrorPageComponent {
this.searchPage = properties.searchLinkToDataProviders;
this.page_type_name = "content provider";
}
});
}
}
});
});
}
}

View File

@ -20,6 +20,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service';
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common";
@Component({
@ -105,7 +106,8 @@ export class DataProviderComponent {
private _searchProjectsService: SearchProjectsService,
private _searchDataprovidersService: SearchDataprovidersService,
private seoService: SEOService,
private helper: HelperService) {
private helper: HelperService,
private _location: Location) {
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
@ -132,7 +134,7 @@ export class DataProviderComponent {
this.getDataProviderInfo(this.datasourceId);
} else {
this.showLoading = false;
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "dataprovider"}});
}
HelperFunctions.scroll();
@ -204,7 +206,7 @@ export class DataProviderComponent {
//console.log(err);
this.handleError("Error getting content provider for id: " + this.datasourceId, err);
if(err.status == 404) {
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToDataProvider + this.datasourceId, "page_type": "dataprovider"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "dataprovider"}});
}
//this.errorMessage = 'No dataProvider found';
this.showLoading = false;

View File

@ -24,6 +24,7 @@ import {EnvProperties} from '../../utils/properties/env-properties';
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common";
@Component({
selector: 'organization',
@ -118,7 +119,8 @@ export class OrganizationComponent {
private _title: Title,
private _router: Router,
private helper: HelperService,
private seoService: SEOService) {
private seoService: SEOService,
private _location: Location) {
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
// this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
@ -146,7 +148,7 @@ export class OrganizationComponent {
this.getOrganizationInfo();
} else {
this.showLoading = false;
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "organization"}});
//this.warningMessage = "No valid organization id";
}
@ -219,6 +221,7 @@ export class OrganizationComponent {
data => {
if (data == null) {
this.showLoading = false;
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "organization"}});
this.errorMessage = 'No organization found';
} else {
this.organizationInfo = data;
@ -256,7 +259,7 @@ export class OrganizationComponent {
//console.log(err)
this.handleError("Error getting organization for id: " + this.organizationId, err);
if(err.status == 404) {
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToOrganization + this.organizationId, "page_type": "organization"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "organization"}});
}
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganizations);
//this.errorMessage = 'No organization found';

View File

@ -19,6 +19,7 @@ import {EnvProperties} from '../../utils/properties/env-properties';
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common";
@Component({
selector: 'project',
@ -110,7 +111,8 @@ export class ProjectComponent {
private _title: Title,
private _router: Router,
private helper: HelperService,
private seoService: SEOService) {
private seoService: SEOService,
private _location: Location) {
}
ngOnInit() {
@ -148,7 +150,7 @@ export class ProjectComponent {
} else {
this.showLoading = false;
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}});
//this.warningMessage = "No valid project id";
}
@ -331,7 +333,7 @@ export class ProjectComponent {
//console.log(err);
this.handleError("Error getting project for id: " + this.projectId, err);
if(err.status == 404) {
this._router.navigate(['/error'], {queryParams: {"page": this.properties.searchLinkToProject + this.projectId, "page_type": "project"}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}});
}
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects);
//this.errorMessage = 'No project found';

View File

@ -11,7 +11,7 @@ import {ResultLandingService} from './resultLanding.service';
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from '../../utils/HelperFunctions.class';
import {HelperService} from '../../utils/helper/helper.service';
import {isPlatformBrowser} from "@angular/common";
import {Location} from "@angular/common";
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
@ -97,8 +97,7 @@ export class ResultLandingComponent {
private _router: Router,
private helper: HelperService,
private seoService: SEOService,
@Inject(PLATFORM_ID) private platformId: string) {
this.testBrowser = isPlatformBrowser(platformId);
private _location: Location) {
}
ngOnInit() {
@ -146,7 +145,7 @@ export class ResultLandingComponent {
} else {
this.showLoading = false;
this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
/*
this.warningMessage = "No valid ";
if(this.type == "publication" || this.type == "software") {
@ -292,7 +291,7 @@ export class ResultLandingComponent {
this.handleError("Error getting "+this.type+" for id: " + this.id, err);
if(err.status == 404) {
this._router.navigate(['/error'], {queryParams: {"page": this.linkToSearchPage + this.id, "page_type": this.type}});
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
}
if(this.type == "publication" || this.type == "software") {

View File

@ -50,9 +50,9 @@ export class OrganizationService {
let organization;
let relations;
this.organizationInfo.objIdentifier = data["result"]["header"]["dri:objIdentifier"];
if(data != null) {
organization = data['result']['metadata']['oaf:entity']['oaf:organization'];
this.organizationInfo.objIdentifier = data["result"]["header"]["dri:objIdentifier"];
relations = data['result']['metadata']['oaf:entity']['oaf:organization']['rels']['rel'];
} else {
return null;