[develop | DONE | DELETED]: Deleted legacy unused files mailPrefs.component.html, mailPrefs.component.ts, mailPrefs.module.ts, htmlProjectReport.component.ts, htmlProjectReport.module.ts.
This commit is contained in:
parent
5a23f6437d
commit
6b5b7df8be
|
@ -1,55 +0,0 @@
|
|||
|
||||
<div *ngIf="!hidden" class="">
|
||||
<div *ngIf="showSaveResetButtons" class="uk-article-title custom-article-title">
|
||||
User Email Preferences for Claims Notifications
|
||||
</div>
|
||||
|
||||
<div *ngIf="userValidMessage.length > 0" class = "uk-alert uk-alert-danger uk-animation-fade" role="alert">
|
||||
{{userValidMessage}}
|
||||
</div>
|
||||
<div *ngIf="savedMessage.length > 0" class="uk-alert uk-alert-success uk-animation-fade" role="alert">
|
||||
{{savedMessage}}
|
||||
</div>
|
||||
<errorMessages [status]="[status]" [type]="'notification preferences'"></errorMessages>
|
||||
|
||||
|
||||
<div *ngFor="let notification of notifications; let i=index" >
|
||||
<!-- <div class="uk-accordion-title">Email preferences for {{preferencesFor}}: <strong>{{notification.openaireName}}</strong></div>-->
|
||||
<!-- <div class="uk-accordion-content">-->
|
||||
<form class="uk-form-horizontal"><!-- [formGroup]="myForm"-->
|
||||
<!--[ngClass]="{'has-error':!myForm.controls.notify.valid && myForm.controls.notify.dirty}"-->
|
||||
<div class="uk-margin uk-grid">
|
||||
<div class=" inherit-color uk-width-medium"
|
||||
title="Get e-mail notification when there are new user links related your community">Notify
|
||||
for new user links:</div>
|
||||
|
||||
<mat-slide-toggle [checked]="notification.notify"
|
||||
(change)="($event.source.checked = notification.notify);changeNotify(notification, !notification.notify, i)"></mat-slide-toggle>
|
||||
</div>
|
||||
|
||||
<div *ngIf="notification.notify" [class]="notification.notify ? 'uk-margin' :
|
||||
'uk-margin cursor-not-allowed'">
|
||||
<div class="uk-form-label inherit-color">Frequency:</div>
|
||||
<div class="uk-form-controls">
|
||||
<select [class]="notification.notify ? 'uk-select' : 'uk-select uk-disabled'" id="form-horizontal-select"
|
||||
[(ngModel)]="notification.frequency" (ngModelChange)="changeFrequency(i)" name="select_frequency">
|
||||
<option [ngValue]="24" >Daily</option>
|
||||
<option [ngValue]="48" >Every two days</option>
|
||||
<option [ngValue]="168">Weekly</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="showSaveResetButtons" class="uk-float-right">
|
||||
<button type="submit" class="uk-button uk-button-primary" (click)="saveNotification(i)">Save Changes</button>
|
||||
<button type="submit" class="uk-button" (click)="restoreNotification(i)">Reset</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!-- </div>-->
|
||||
<!-- </ul>-->
|
||||
|
||||
</div>
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Session} from '../../login/utils/helper.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {MailPrefsService} from './mailPrefs.service';
|
||||
import {ConnectHelper} from '../connectHelper';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {Subscriber} from "rxjs";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'mailPrefs',
|
||||
templateUrl: 'mailPrefs.component.html',
|
||||
providers:[MailPrefsService]
|
||||
|
||||
})
|
||||
export class MailPrefsComponent {
|
||||
properties:EnvProperties;
|
||||
subscriptions = [];
|
||||
@Input() communityId: string;
|
||||
public preferencesFor: string = "community";
|
||||
public status: number;
|
||||
|
||||
public notifications = [];
|
||||
public initialNotifications = [];
|
||||
public prefsChanged = {};
|
||||
public hidden: boolean = true;
|
||||
|
||||
//public showForbiddenMessage:boolean = false;
|
||||
public userValidMessage:string = "";
|
||||
public savedMessage: string = "";
|
||||
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
|
||||
@Input() showSaveResetButtons: boolean = true;
|
||||
|
||||
constructor (private _mailPrefsService: MailPrefsService, private route: ActivatedRoute, private _router:Router, private location: Location) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.properties = properties;
|
||||
this.subscriptions.push(this.route.params.subscribe(params => {
|
||||
this.hidden = true;
|
||||
console.debug(this.communityId);
|
||||
if(!this.communityId){
|
||||
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||
}
|
||||
if(!this.communityId) {
|
||||
this.communityId = params['community'];
|
||||
}
|
||||
console.debug(this.communityId, params)
|
||||
this.getEmailPreferences();
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
getEmailPreferences() {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.status = this.errorCodes.LOADING;
|
||||
this.savedMessage = "";
|
||||
|
||||
if(this.communityId && this.communityId != "openaire") {
|
||||
this.preferencesFor = "community";
|
||||
this.subscriptions.push(this._mailPrefsService.getUserEmailPreferencesForCommunity(this.communityId, this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
if(data.code == "204") {
|
||||
this.status = this.errorCodes.NONE;
|
||||
this.initialNotifications = [{notify: true, frequency:24, openaireId: this.communityId}];
|
||||
} else {
|
||||
this.initialNotifications = data.data;
|
||||
}
|
||||
this.notifications = JSON.parse(JSON.stringify( this.initialNotifications ));
|
||||
|
||||
this.status = this.errorCodes.DONE;
|
||||
this.hidden = false;
|
||||
|
||||
},
|
||||
err => {
|
||||
this.hidden = false;
|
||||
this.handleErrors(err);
|
||||
this.handleError("Error getting user email preferences for community with id: "+this.communityId, err);
|
||||
}
|
||||
));
|
||||
} else {
|
||||
this.preferencesFor = "project";
|
||||
this.subscriptions.push(this._mailPrefsService.getUserEmailPreferencesForOpenaire(this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
|
||||
if(data.code == "204") {
|
||||
this.status = this.errorCodes.NONE;
|
||||
} else {
|
||||
|
||||
this.initialNotifications = data.data;
|
||||
this.notifications = JSON.parse(JSON.stringify( this.initialNotifications ));
|
||||
//this.notifications = this.initialNotifications.map(x => Object.assign({}, x));
|
||||
//this.notifications = this.initialNotifications;
|
||||
|
||||
this.status = this.errorCodes.DONE;
|
||||
}
|
||||
},
|
||||
err => {
|
||||
//console.info(err);
|
||||
this.handleErrors(err);
|
||||
this.handleError("Error getting user email preferences for openaire", err);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeNotify(notification: any, checked: boolean, index: number) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.savedMessage = "";
|
||||
this.status = this.errorCodes.DONE;
|
||||
notification.notify = checked;
|
||||
this.prefsChanged[index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
changeFrequency(index: number) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.savedMessage = "";
|
||||
this.status = this.errorCodes.DONE;
|
||||
if(this.initialNotifications[index].frequency != this.notifications[index].frequency) {
|
||||
this.prefsChanged[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
saveNotification(index: number) {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
|
||||
|
||||
this.status = this.errorCodes.LOADING;
|
||||
this.savedMessage = "";
|
||||
|
||||
this.subscriptions.push(this._mailPrefsService.saveUserEmailPreferences(this.notifications[index], this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
this.initialNotifications[index] = JSON.parse(JSON.stringify( this.notifications[index] ));
|
||||
|
||||
this.status = this.errorCodes.DONE;
|
||||
|
||||
/*UIkit.notification({
|
||||
message : '<strong>Your email preferences for '+this.notifications[index].openaireName+' have been successfully changed<strong>',
|
||||
status : 'success',
|
||||
timeout : 3000,
|
||||
pos : 'top-center'
|
||||
});*/
|
||||
this.savedMessage = "Notification settings for claims saved!";
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error saving user email preferences: "+JSON.stringify(this.notifications[index]), err);
|
||||
this.status = this.errorCodes.NOT_SAVED;
|
||||
}
|
||||
));
|
||||
}
|
||||
else {
|
||||
/*UIkit.notification({
|
||||
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>',
|
||||
status : 'primary',
|
||||
timeout : 3000,
|
||||
pos : 'top-center'
|
||||
});*/
|
||||
this.savedMessage = "Notification settings for claims saved!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
restoreNotification(index: number) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
this.status = this.errorCodes.LOADING;
|
||||
this.savedMessage = "";
|
||||
this.notifications[index] = JSON.parse(JSON.stringify( this.initialNotifications[index] ));
|
||||
this.status = this.errorCodes.DONE;
|
||||
this.prefsChanged[index] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
prefsChanged(index: number) : boolean {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
handleErrors(err){
|
||||
//this.showErrorMessage = true;
|
||||
//try{
|
||||
var code = "";
|
||||
if(!err.status) {
|
||||
var error = err.json();
|
||||
code = error.code;
|
||||
} else {
|
||||
code = err.status;
|
||||
}
|
||||
this.status = this.errorMessages.getErrorCode(code);
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("User mail notification preferences Page (for claims): "+message, error);
|
||||
}
|
||||
|
||||
|
||||
//}catch (e) {
|
||||
//console.log("Couldn't parse answer as json")
|
||||
//this.showErrorMessage = true;
|
||||
//}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
import { MailPrefsComponent } from './mailPrefs.component';
|
||||
import { MailPrefsService } from './mailPrefs.service';
|
||||
import {ErrorMessagesModule} from '../../utils/errorMessages.module';
|
||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, RouterModule, FormsModule, ReactiveFormsModule, ErrorMessagesModule, MatSlideToggleModule
|
||||
],
|
||||
declarations: [
|
||||
MailPrefsComponent
|
||||
],
|
||||
providers:[MailPrefsService],
|
||||
exports: [
|
||||
MailPrefsComponent
|
||||
]
|
||||
})
|
||||
export class MailPrefsModule { }
|
|
@ -1,302 +0,0 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
|
||||
import {HtmlProjectReportService} from './htmlProjectReport.service';
|
||||
import {ProjectService} from '../project/project.service';
|
||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
||||
import {HelperService} from "../../utils/helper/helper.service";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
@Component({
|
||||
selector: 'htmlProjectReport',
|
||||
template: `
|
||||
<div id="tm-main" class=" uk-section uk-padding-remove-top tm-middle">
|
||||
<div uk-grid>
|
||||
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
|
||||
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
|
||||
[texts]="pageContents['top']" styleName="uk-width-1-1"></helper>
|
||||
<div class="uk-container uk-margin-top uk-width-1-1">
|
||||
<div *ngIf="warningMessage" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
<div [style.display]="showLoading ? 'inline' : 'none'"
|
||||
class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><span
|
||||
class="loading-gif uk-align-center"></span></div>
|
||||
|
||||
<div *ngIf="!showLoading && !warningMessage">
|
||||
<div *ngIf="header1" class="uk-h4 uk-text-bold ">{{header1}}</div>
|
||||
<div *ngIf="header1 || htmlResult" class=" ">{{header2}}</div>
|
||||
|
||||
<div class="uk-clearfix uk-margin-bottom">
|
||||
<button *ngIf="htmlResult" class="uk-icon-clipboard uk-button uk-button-primary clipBtn uk-float-right"
|
||||
(click)="copied()">
|
||||
Copy to clipboard
|
||||
</button>
|
||||
</div>
|
||||
<!--div class="uk-panel-scrollable custom-html-table-height" *ngIf="htmlResult" id="clipboard" [innerHTML]="htmlResult"></div-->
|
||||
<div class="uk-overflow-auto custom-html-table-height" *ngIf="htmlResult" id="clipboard"
|
||||
[innerHTML]="htmlResult"></div>
|
||||
|
||||
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0"
|
||||
[texts]="pageContents['bottom']" styleName="uk-width-1-1"></helper>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`
|
||||
})
|
||||
export class HtmlProjectReportComponent {
|
||||
@Input() communityId = null;
|
||||
private projectId: string;
|
||||
private totalResults: number = 10;
|
||||
private resultsType: string = "publication";
|
||||
|
||||
public header1: string = "";
|
||||
public header2: string = "";
|
||||
public htmlResult: string = "";
|
||||
|
||||
subscriptions = [];
|
||||
|
||||
public warningMessage: string = "";
|
||||
public errorMessage: string = "";
|
||||
public showLoading: boolean = true;
|
||||
properties: EnvProperties;
|
||||
public pageContents = null;
|
||||
public divContents = null;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private htmlService: HtmlProjectReportService,
|
||||
private _piwikService: PiwikService,
|
||||
private _projectService: ProjectService,
|
||||
private _meta: Meta,
|
||||
private _title: Title,
|
||||
private _router: Router,
|
||||
private helper: HelperService,
|
||||
private seoService: SEOService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.properties = properties;
|
||||
//this.getDivContents();
|
||||
this.getPageContents();
|
||||
this.updateUrl(this.properties.domain + this.properties.baseLink + this._router.url);
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this._router.url);
|
||||
|
||||
|
||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||
this.projectId = params['projectId'];
|
||||
|
||||
if (params['size'] == parseInt(params['size'], 10)) {
|
||||
this.totalResults = params['size'];
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this.warningMessage = "Requested size is not an integer";
|
||||
}
|
||||
|
||||
if (params['type'] && (params['type'] == "publication" || params['type'] == "dataset" || params['type'] == "software" || params['type'] == "other")) {
|
||||
if (params['type'] == "publication") {
|
||||
this.resultsType = 'publication';
|
||||
} else if (params['type'] == "dataset") {
|
||||
this.resultsType = 'research data';
|
||||
} else if (params['type'] == "software") {
|
||||
this.resultsType = 'software';
|
||||
} else if (params['type'] == "other") {
|
||||
this.resultsType = "other research product";
|
||||
}
|
||||
|
||||
var title = "Project's " + this.resultsType + " report";
|
||||
var description = "project, project " + this.resultsType + " report, funding, open access, publications, research data, software, other research products";
|
||||
this.updateTitle(title);
|
||||
this.updateDescription(description);
|
||||
|
||||
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this.warningMessage = "Requested type should be publication or research data or software or other research product";
|
||||
}
|
||||
|
||||
//showLoading is true if no warnings
|
||||
if (this.showLoading) {
|
||||
if (this.projectId) {
|
||||
this.createHeaders();
|
||||
} else {
|
||||
this.showLoading = false;
|
||||
this.warningMessage = "No valid project id";
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private getPageContents() {
|
||||
if(this.communityId) {
|
||||
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
||||
this.pageContents = contents;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private getDivContents() {
|
||||
if(this.communityId) {
|
||||
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
||||
this.divContents = contents;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private createHeaders() {
|
||||
this.subscriptions.push(this._projectService.getHTMLInfo(this.projectId, this.properties).subscribe(
|
||||
data => {
|
||||
this.createHeader1(data);
|
||||
if (data.acronym) {
|
||||
this.updateTitle(data.acronym + " " + this.resultsType + " report");
|
||||
} else if (data.title) {
|
||||
this.updateTitle(data.title + " " + this.resultsType + " report");
|
||||
}
|
||||
this.subscriptions.push(this._piwikService.trackView(this.properties, ((data.acronym) ? data.acronym : data.title) + " " + this.resultsType + " report").subscribe());
|
||||
},
|
||||
err => {
|
||||
this.handleError("Error getting html information for project id: " + this.projectId, err);
|
||||
//console.log(err);
|
||||
this.createClipboard();
|
||||
}
|
||||
));
|
||||
|
||||
if (this.resultsType == "publication") {
|
||||
this.header2 += this.totalResults.toLocaleString('en-US') + " publications";
|
||||
} else if (this.resultsType == "research data") {
|
||||
this.header2 += this.totalResults.toLocaleString('en-US') + " research data";
|
||||
} else if (this.resultsType == "software") {
|
||||
this.header2 += this.totalResults.toLocaleString('en-US') + " software";
|
||||
} else if (this.resultsType == "other research product") {
|
||||
this.header2 += this.totalResults.toLocaleString('en-US') + " other";
|
||||
}
|
||||
}
|
||||
|
||||
private createClipboard() {
|
||||
let intro: string = '<!doctype html>';
|
||||
intro += '<html lang="en-gb" dir="ltr" vocab="http://schema.org/">';
|
||||
intro += '<head>';
|
||||
intro += '<title>' + this.header1 + '</title>'
|
||||
intro += '</head>';
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
this.subscriptions.push(this.htmlService.getHTML(this.projectId, this.resultsType, this.properties.csvAPIURL).subscribe(
|
||||
data => {
|
||||
//let body: string = intro+'<body><h1>'+this.header1+'</h1><h2>'+this.header2+'</h2>'+data+'</body></html>';
|
||||
let body: string = intro + '<body><h1>' + this.header1 + '</h1><h2>' + this.header2 + '</h2>';
|
||||
body += "<table><thead><tr> <th>Title</th><th>Authors</th><th>Publication Year</th><th>DOI</th><th>Permanent Identifier</th><th>Publication type</th><th>Journal</th><th>Project Name (GA Number)</th><th>Access Mode</th></tr></thead><tbody>" + data + "</tbody></table>";
|
||||
body += '</body></html>';
|
||||
|
||||
//this.htmlResult = data;
|
||||
this.htmlResult = "<table><thead><tr> <th>Title</th><th>Authors</th><th>Publication Year</th><th>DOI</th><th>Permanent Identifier</th><th>Publication type</th><th>Journal</th><th>Project Name (GA Number)</th><th>Access Mode</th></tr></thead><tbody>" + data + "</tbody></table>";
|
||||
|
||||
let clipboard;
|
||||
let Clipboard;
|
||||
Clipboard = require('clipboard');
|
||||
clipboard = new Clipboard('.clipBtn', {
|
||||
/*target: function(trigger) {
|
||||
return document.getElementById("clipboard");
|
||||
}*/
|
||||
text: function (trigger) {
|
||||
return body;//document.getElementById("clipboard").getAttribute('innerHTML');//"aaaa"+tmp+"oo";
|
||||
}
|
||||
});
|
||||
|
||||
this.showLoading = false;
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this.handleError("Error getting html for id: " + this.projectId, err);
|
||||
|
||||
this.errorMessage = 'Service not available';
|
||||
this.showLoading = false;
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
createHeader1(data: { "title": string, "acronym": string, "callIdentifier": string }) {
|
||||
if (this.resultsType == "publication") {
|
||||
this.header1 += "Publications";
|
||||
} else if (this.resultsType == "research data") {
|
||||
this.header1 += "Research Data";
|
||||
} else if (this.resultsType == "software") {
|
||||
this.header1 += "Software";
|
||||
} else if (this.resultsType == "other research product") {
|
||||
this.header1 += "Other Research Products";
|
||||
}
|
||||
|
||||
if (data != undefined) {
|
||||
if (data.title != undefined && data.title != "") {
|
||||
this.header1 += data.title;
|
||||
}
|
||||
if ((data.title != undefined && data.title != "") &&
|
||||
((data.acronym != undefined && data.acronym != "") ||
|
||||
(data.callIdentifier != undefined && data.callIdentifier != ""))) {
|
||||
this.header1 += "(";
|
||||
}
|
||||
if (data.acronym != undefined && data.acronym != "") {
|
||||
this.header1 += data.acronym + " - ";
|
||||
}
|
||||
if (data.callIdentifier != undefined && data.callIdentifier != "") {
|
||||
this.header1 += data.callIdentifier;
|
||||
}
|
||||
if ((data.title != undefined && data.title != "") &&
|
||||
((data.acronym != undefined && data.acronym != "") ||
|
||||
(data.callIdentifier != undefined && data.callIdentifier != ""))) {
|
||||
this.header1 += ")";
|
||||
}
|
||||
}
|
||||
|
||||
this.createClipboard();
|
||||
}
|
||||
|
||||
public copied() {
|
||||
UIkit.notification({
|
||||
message: '<strong>Raw html is copied. Please paste it on an html file.<strong>',
|
||||
status: 'success',
|
||||
timeout: 3000,
|
||||
pos: 'top-center'
|
||||
});
|
||||
}
|
||||
|
||||
private updateDescription(description: string) {
|
||||
this._meta.updateTag({content: description}, "name='description'");
|
||||
this._meta.updateTag({content: description}, "property='og:description'");
|
||||
}
|
||||
|
||||
private updateTitle(title: string) {
|
||||
var _prefix = "";
|
||||
if(!this.communityId) {
|
||||
_prefix = "OpenAIRE | ";
|
||||
}
|
||||
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
||||
this._title.setTitle(_title);
|
||||
this._meta.updateTag({content: _title}, "property='og:title'");
|
||||
}
|
||||
|
||||
private updateUrl(url: string) {
|
||||
this._meta.updateTag({content: url}, "property='og:url'");
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error("Html Project Report Page: " + message, error);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
//import {MaterialModule} from '@angular/material';
|
||||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { ProjectServiceModule} from '../project/projectService.module';
|
||||
|
||||
|
||||
import {HtmlProjectReportService} from './htmlProjectReport.service';
|
||||
import {HtmlProjectReportComponent} from './htmlProjectReport.component';
|
||||
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
||||
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
|
||||
import {HelperModule} from "../../utils/helper/helper.module";
|
||||
import {RouterModule} from '@angular/router';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, ProjectServiceModule, PiwikServiceModule, SEOServiceModule, HelperModule,
|
||||
RouterModule
|
||||
],
|
||||
declarations: [
|
||||
HtmlProjectReportComponent
|
||||
],
|
||||
providers:[
|
||||
HtmlProjectReportService
|
||||
],
|
||||
exports: [
|
||||
HtmlProjectReportComponent
|
||||
]
|
||||
})
|
||||
export class HtmlProjectReportModule { }
|
Loading…
Reference in New Issue