[Trunk|Library]

Server Side errors: Add missing checks before using document, fix SEO rel canonical issue 


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54829 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-02-15 15:03:48 +00:00
parent 8c25f2bd27
commit 01a945b226
7 changed files with 11 additions and 11 deletions

View File

@ -274,11 +274,11 @@ private errorsInClaimsInsertion(){
var text =""
//console.log("Errors: this.errorInRecords.length: "+this.errorInRecords.length+" - this.errorInClaims.length: "+this.errorInClaims.length);
if(this.errorInRecords.length>0){
text+="<div>The following records couldn't automatically inserted to the Openaire Info space: <ul>";
text+="<div>The following results couldn't automatically inserted to the Openaire Info space: <ul>";
for(var i=0; i< this.errorInRecords.length ; i++){
for(var k=0; k< this.results.length ; k++){
if(this.results[k].id == this.errorInRecords[i]){
text+="<li>"+this.results[i].title+" from "+this.results[i].source+"</li>";
text+="<li>Title: \""+this.results[i].title+"\" ("+this.results[i].source+")</li>";
}
}
}
@ -290,7 +290,7 @@ private errorsInClaimsInsertion(){
for(var i=0; i< this.errorInClaims.length ; i++){
// var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)};
text+="<li>"+this.errorInClaims[i].sourceType+": "+this.errorInClaims[i].sourceId +"(from "+this.errorInClaims[i].sourceCollectedFrom+") link to "+this.errorInClaims[i].targetType+": "+this.errorInClaims[i].targetId +"(from "+this.errorInClaims[i].targetCollectedFrom+") </li>";
text+="<li>"+this.errorInClaims[i].sourceType+": "+this.errorInClaims[i].sourceId +" ("+this.errorInClaims[i].sourceCollectedFrom+") link to "+this.errorInClaims[i].targetType+": "+this.errorInClaims[i].targetId +" ("+this.errorInClaims[i].targetCollectedFrom+") </li>";
}
text+="</ul></div>";

View File

@ -33,7 +33,7 @@ export class ApprovedByCommunityComponent {
communityId => {
this.communityId = communityId['communityId'];
if(!this.communityId){
if(!this.communityId && (typeof document !== 'undefined')){
this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}

View File

@ -19,7 +19,7 @@ export class ConnectSubscriberGuard implements CanActivate {
var errorCode = LoginErrorCodes.NOT_SUBSCRIBER;
let community = (route.queryParams["communityId"]);
if(!community){
if(!community && (typeof document !== 'undefined')){
community = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
if(!Session.isLoggedIn()){

View File

@ -54,7 +54,7 @@ export class MailPrefsComponent {
this.sub = this.route.queryParams.subscribe(params => {
this.communityId = params['communityId'];
if(!this.communityId){
if(!this.communityId && (typeof document !== 'undefined')){
this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}

View File

@ -100,7 +100,7 @@ export class SearchDownloadComponent {
this.closeLoading();
//window.open(window.URL.createObjectURL(data),filename+".csv");
//console.info("Fill window with data for csv");
if(typeof document !== 'undefined'){
var url = window.URL.createObjectURL(data);
var a = window.document.createElement('a');
window.document.body.appendChild(a);
@ -110,7 +110,7 @@ export class SearchDownloadComponent {
a.click();
window.URL.revokeObjectURL(url);
a.remove(); // remove the element
}
//newWindow.location.assign(window.URL.createObjectURL(data));
//window.location.href = window.URL.createObjectURL(data);

View File

@ -47,7 +47,7 @@ export class SEOService {
throw new Error('<head> not found within DOCUMENT.');
}
renderer.setAttribute(link, "rel", "canonical");
renderer.setAttribute(link, "href", (addParameters)?url:this.doc.URL.split("?")[0]);
renderer.setAttribute(link, "href", (addParameters)?url:url.split("?")[0]);
renderer.setAttribute(link, "id", "relcan");
// [TODO]: get them to update the existing one (if it exists) ?
renderer.appendChild(head, link);

View File

@ -41,13 +41,13 @@ export class HelperComponent {
this.route.queryParams.subscribe(
params => {
this.communityId = params['communityId'];
if(!this.communityId){
if(!this.communityId && (typeof document !== 'undefined')){
this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
if(!this.communityId){
this.communityId = this.properties.adminToolsCommunity;
}
if(this.properties.enableHelper && location){
if(this.properties.enableHelper && typeof document != 'undefined'){
//this.sub = this._service.getHelper(location.pathname, this.properties).subscribe(
this.sub = this._service.getHelper(location.pathname, this.position, this.before, this.div, this.properties, this.communityId).subscribe(
data => {