From 24fd2b385662a16b9edacc95ee1f84132dfdb4f9 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Fri, 17 Dec 2021 15:36:30 +0200 Subject: [PATCH 1/2] Progress on dynamic menu - dev only --- dashboard/menu/menu.component.html | 23 +++++++++++------ dashboard/menu/menu.component.ts | 40 ++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/dashboard/menu/menu.component.html b/dashboard/menu/menu.component.html index 28005498..3587fd8d 100644 --- a/dashboard/menu/menu.component.html +++ b/dashboard/menu/menu.component.html @@ -13,11 +13,11 @@
@@ -25,7 +25,7 @@ -
  • +
  • @@ -74,7 +74,7 @@
  • Delete
  • + (click)="confirmDeleteSelectedMenuItems()"> Delete
    @@ -120,11 +120,18 @@ - +
    -
    +
    -
    -
    + +
    + +
    +
    Select one of the pages
    +
    +
    + +
    \ No newline at end of file diff --git a/dashboard/menu/menu.component.ts b/dashboard/menu/menu.component.ts index 5b0455b4..6be41581 100644 --- a/dashboard/menu/menu.component.ts +++ b/dashboard/menu/menu.component.ts @@ -13,6 +13,7 @@ import {Title} from "@angular/platform-browser"; import {AlertModal} from '../../utils/modal/alert'; import {CheckMenuItem, MenuItem} from '../../sharedComponents/menu'; import {SearchInputComponent} from '../../sharedComponents/search-input/search-input.component'; +import {Option} from '../../sharedComponents/input/input.component'; @Component({ @@ -32,6 +33,7 @@ export class MenuComponent implements OnInit { // public rootMenuForm: FormGroup; public menuItemForm: FormGroup; + public allPages = []; public keyword = ''; @@ -85,15 +87,33 @@ export class MenuComponent implements OnInit { }); } - // public newRootMenu() { - // this.rootMenuForm = this._fb.group({ - // id: this._fb.control(null), - // title: this._fb.control("",Validators.required), - // route: this._fb.control(""), - // isEnabled: this._fb.control("",Validators.required), - // }); - // this.menuItemsModalOpen('Create Root Menu', 'Save Changes'); - // } + public newRootMenu() { + this.menuItemForm = this._fb.group({ + id: this._fb.control(""), + title: this._fb.control("",Validators.required), + type: this._fb.control("",Validators.required), + route: this._fb.control(""), + url: this._fb.control(""), + isEnabled: this._fb.control("",Validators.required), + }); + this.menuItemsModalOpen('Create Root Menu', 'Save Changes'); + } + + public editRootMenu() { + this.menuItemForm = this._fb.group({ + id: this._fb.control("id"), + title: this._fb.control("Resources",Validators.required), + type: this._fb.control("",Validators.required), + route: this._fb.control("noNeed"), + url: this._fb.control("noNeed"), + isEnabled: this._fb.control("enabled",Validators.required), + }); + this.menuItemsModalOpen('Edit Root Menu', 'Save Changes'); + } + + public deleteRootMenu() { + console.log('Delete root menu'); + } public getSelectedMenuItems(): string[] { return this.checkboxes.filter(menuItem => menuItem.checked == true).map(checkedMenuItem => checkedMenuItem.menuItem).map(res => res.id); @@ -155,7 +175,7 @@ export class MenuComponent implements OnInit { } public onSearchClose() { - this.selectedKeyword = this.filterForm.value; + this.selectedKeyword = this.filterForm.get('keyword').value; } public reset() { From f911dec31e26e97ff40e159297d6aeea07d989a4 Mon Sep 17 00:00:00 2001 From: argirok Date: Fri, 17 Dec 2021 15:39:32 +0200 Subject: [PATCH 2/2] landing pages: keep the loaded url as canonical if there is a timeout error - show the correct message --- .../dataProvider/dataProvider.component.ts | 8 +- .../organization/organization.component.ts | 126 +++++++++--------- landingPages/project/project.component.ts | 15 ++- .../result/resultLanding.component.ts | 21 +-- 4 files changed, 94 insertions(+), 76 deletions(-) diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index d02caed0..13c42d22 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -145,6 +145,7 @@ export class DataProviderComponent { //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(data => { this.updateTitle("Content provider"); this.updateDescription(""); @@ -259,10 +260,13 @@ export class DataProviderComponent { "page_type": "dataprovider" } }); + }else if(err.name == "TimeoutError"){ + this.errorMessage = 'An error occurred please try again later'; + }else { + this.errorMessage = 'No dataProvider found'; + this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders); } - this.errorMessage = 'No dataProvider found'; this.showLoading = false; - this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToDataProviders); } )); } diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index 41f5be78..6af678a2 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -32,20 +32,20 @@ import {properties} from "../../../../environments/environment"; export class OrganizationComponent { @Input() piwikSiteId = null; @Input() communityId = null; - + public organizationInfo: OrganizationInfo; public organizationId: string; - + // Message variables public warningMessage = ""; public errorMessage = ""; public showLoading: boolean = true; - + // CSV variables public downloadURLAPI: string; public csvProjectParamsHead: string; public csvParamsTail: string; - + // Variables for publications, research data, projects, dataproviders tabs public fetchProjects: FetchProjects; public fetchPublications: FetchResearchResults; @@ -67,18 +67,18 @@ export class OrganizationComponent { @ViewChild('downloadReportModal') downloadReportModal; @ViewChild('downloadFunderReportModal') downloadFunderReportModal; - + @ViewChild(ModalLoading) loading: ModalLoading; // Alert box when CSV: Project Publications for a funder is requested @ViewChild('AlertModalApplyAll') alertApplyAll; // Alert box when something is wrong with CSV requests @ViewChild('AlertModalCsvError') alertCsvError; - + public routerHelper: RouterHelper = new RouterHelper(); public errorCodes: ErrorCodes = new ErrorCodes(); public pageContents = null; public divContents = null; - + // Helper variables to specify funder in downloadPublicationsFile function public contentTypes: [string, string][] = [ ['results', 'all research outcomes'], @@ -97,11 +97,11 @@ export class OrganizationComponent { public indexUpdateDate: Date; public showFeedback: boolean = false; public feedbackFields: string [] = ['Name', 'Country', 'Other']; - + @ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference; @ViewChild('projectsModal') projectsModal; public deleteByInferenceOpened: boolean = false; - + constructor(private element: ElementRef, private _organizationService: OrganizationService, @@ -125,7 +125,7 @@ export class OrganizationComponent { this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService); this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService); } - + ngOnInit() { this.properties = properties; @@ -139,14 +139,15 @@ export class OrganizationComponent { //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.organizationInfo = null; this.updateTitle("Organization"); this.updateDescription(""); - + this.organizationId = params['organizationId']; - + if (this.organizationId && StringUtils.isOpenAIREID(this.organizationId)) { this.getOrganizationInfo(); } else { @@ -160,13 +161,13 @@ export class OrganizationComponent { } this.csvParamsTail = '" and relorganizationid exact "' + this.organizationId + '" ))'; })); - + this.downloadURLAPI = this.properties.csvAPIURL; //this.csvAffiliatedPublications = this.downloadURLAPI + "?format=csv&type=publications&fq=(((oaftype exact result) and (resulttypeid exact publication)) and (relorganizationid exact \"" + this.organizationId + "\"))"; this.csvProjectParamsHead = 'format=csv&type=projects&fq=((funder exact "'; //this.csvPublicationParamsHead = 'format=csv-special&type=publications&page=0&query=((((oaftype exact result) and (resulttypeid exact publication)) and (funderid exact '; } - + private getPageContents() { if(this.communityId) { this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { @@ -174,7 +175,7 @@ export class OrganizationComponent { })); } } - + private getDivContents() { if(this.communityId) { this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { @@ -209,11 +210,11 @@ export class OrganizationComponent { this.fetchSoftware.getNumForEntity('software', 'organization', this.organizationId, this.properties); this.fetchOrps.getNumForEntity('other', 'organization', this.organizationId, this.properties); } - + private getTotalDataproviders() { this.fetchDataproviders.getNumForEntity('organization', this.organizationId, this.properties); } - + // private searchContentProviders() { // this.fetchDataproviders.getResultsForEntity("organization", this.organizationId, 1, this.searchNumber, this.properties); // } @@ -227,7 +228,7 @@ export class OrganizationComponent { } this.reloadDataproviders = false; } - + // private searchPublications() { // this.fetchPublications.getResultsForEntity("publication", "organization", this.organizationId, 1, size, this.properties); // } @@ -241,7 +242,7 @@ export class OrganizationComponent { } this.reloadPublications = false; } - + // private searchDatasets() { // this.fetchDatasets.getResultsForEntity("dataset", "organization", this.organizationId, 1, this.searchNumber, this.properties); // } @@ -283,13 +284,13 @@ export class OrganizationComponent { } this.reloadOrps = false; } - + private getOrganizationInfo() { - + this.warningMessage = ''; this.errorMessage = "" this.showLoading = true; - + this.organizationInfo = null; this.subscriptions.push(this._organizationService.getOrganizationInfo(this.organizationId, this.properties).subscribe( @@ -337,14 +338,17 @@ export class OrganizationComponent { "page_type": "organization" } }); + }else if(err.name == "TimeoutError"){ + this.errorMessage = 'An error occurred please try again later'; + }else { + this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToOrganizations); + this.errorMessage = 'No organization found'; } - this.seoService.createLinkForCanonicalURL(this.properties.domain+ this.properties.baseLink + this.properties.searchLinkToOrganizations); - this.errorMessage = 'No organization found'; this.showLoading = false; } )); } - + public downloadFile(url: string, filename: string) { this.openLoading(); this.setMessageLoading("Downloading CSV file"); @@ -352,7 +356,7 @@ export class OrganizationComponent { this.subscriptions.push(this._reportsService.downloadCSVFile(url).subscribe( data => { this.closeLoading(); - + var url = window.URL.createObjectURL(data); var a = window.document.createElement('a'); window.document.body.appendChild(a); @@ -362,7 +366,7 @@ export class OrganizationComponent { a.click(); window.URL.revokeObjectURL(url); a.remove(); // remove the element - + //window.open(window.URL.createObjectURL(data)); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.subscriptions.push(this._piwikService.trackDownload(this.properties, "DownloadCSV" + filename, this.piwikSiteId).subscribe()); @@ -371,26 +375,26 @@ export class OrganizationComponent { err => { //console.log("Error downloading the file."); this.handleError("Error downloading file: " + filename + ".csv", err); - + this.closeLoading(); this.confirmOpenCsvError(); }/*, () => console.log('Completed file download.')*/ )); } - + private downloadFileByFunder() { - + this.openLoading(); this.setMessageLoading("Downloading CSV file"); - + let response: string[] = []; let totalResponse: string = ""; let projects = []; let counter: number = this.funderCount; let title: boolean = false; let title_index: number = 0; - + let filename: string = 'funder-project-' + this.funderContentType + '-report'; this.subscriptions.push(this._searchProjectsService.getProjectsForOrganizations(this.organizationId, ' and (funder exact "' + this.encodeURI(this.funderId) + '" ) ', 1, this.funderCount, [], this.properties).subscribe( @@ -404,7 +408,7 @@ export class OrganizationComponent { counter--; response[index] = ""; //console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]); - + if (counter == 0) { //for(let i=count-1; i>=0; i--) { for (let i = 0; i < projects.length; i++) { @@ -417,7 +421,7 @@ export class OrganizationComponent { } } this.closeLoading(); - + var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'})); var a = window.document.createElement('a'); window.document.body.appendChild(a); @@ -447,7 +451,7 @@ export class OrganizationComponent { counter--; response[index] = data; //console.info("index: "+index, "counter: "+counter, "id:"+projects[index].id, response[index]); - + if (counter == 0) { //for(let i=count-1; i>=0; i--) { for (let i = 0; i < projects.length; i++) { @@ -460,7 +464,7 @@ export class OrganizationComponent { } } this.closeLoading(); - + var csvurl = window.URL.createObjectURL(new Blob([totalResponse], {type: 'text/csv'})); var a = window.document.createElement('a'); window.document.body.appendChild(a); @@ -477,7 +481,7 @@ export class OrganizationComponent { }, err => { this.handleError("Error downloading file: " + filename, err); - + this.closeLoading(); this.confirmOpenCsvError(); this.innerReportSubscriptions.forEach(subscription => subscription.unsubscribe()); @@ -496,18 +500,18 @@ export class OrganizationComponent { }, err => { this.handleError("Error getting projects for organization with id: " + this.organizationId, err); - + this.closeLoading(); this.confirmOpenCsvError(); } )); } - + private updateDescription(description: string) { this._meta.updateTag({content: description.substring(0, 160)}, "name='description'"); this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'"); } - + private updateTitle(title: string) { var _prefix = ""; // if(!this.communityId) { @@ -517,11 +521,11 @@ export class OrganizationComponent { 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 openLoading() { this.closeDownloadReportModal(); this.closeDownloadFunderReportModal(); @@ -530,19 +534,19 @@ export class OrganizationComponent { this.loading.open(); } } - + private closeLoading() { if (this.loading) { this.loading.close(); } } - + private setMessageLoading(message: string) { if (this.loading) { this.loading.message = message; } } - + public confirmOpenApplyAll(contentType: string) { this.alertApplyAll.cancelButton = true; this.alertApplyAll.okButton = true; @@ -555,11 +559,11 @@ export class OrganizationComponent { this.funderCount = this.funder.number; this.funderContentType = contentType; } - + public confirmCloseApplyAll() { this.downloadFileByFunder(); } - + public confirmOpenCsvError() { this.alertCsvError.cancelButton = false; this.alertCsvError.okButton = true; @@ -568,15 +572,15 @@ export class OrganizationComponent { this.alertCsvError.okButtonText = "OK"; this.alertCsvError.open(); } - + encodeURI(input: string): string { return StringUtils.URIEncode(input); } - + private handleError(message: string, error) { console.error("Organizaton Landing Page: " + message, error); } - + openDeletedByInference() { this.deleteByInferenceOpened = true; this.alertModalDeletedByInference.cancelButton = false; @@ -584,26 +588,26 @@ export class OrganizationComponent { this.alertModalDeletedByInference.alertTitle = "Other versions of"; this.alertModalDeletedByInference.open(); } - + public getTypeParam(type: string): string { if (type == 'results') { type = 'publications&type=datasets&type=software&type=other'; } return 'type=' + type; } - + getCSVAffiliated(contentType: string): string { return this.downloadURLAPI + '?format=csv&' + this.getTypeParam(contentType) + '&fq=(relorganizationid exact "' + this.organizationId + '")'; } - + getFunderProjects(): string { return this.downloadURLAPI + '?' + this.csvProjectParamsHead + encodeURI(this.funder.id) + this.csvParamsTail; } - + open(value: any) { console.log(value); } - + openDownloadReportModal() { this.downloadReportModal.cancelButton = false; this.downloadReportModal.okButton = false; @@ -614,7 +618,7 @@ export class OrganizationComponent { closeDownloadReportModal() { this.downloadReportModal.cancel(); } - + openDownloadFunderReportModal() { this.funder = this.fetchProjects.funders[0]; this.downloadFunderReportModal.cancelButton = false; @@ -634,7 +638,7 @@ export class OrganizationComponent { return this.routerHelper.createQueryParams(['f0', 'fv0'], ['relorganizationid', this.organizationId]); } } - + public onSelectActiveTab(activeTabId) { if (this.activeTab != activeTabId) { // tab really changed if (activeTabId == 'projects') { @@ -657,7 +661,7 @@ export class OrganizationComponent { } } } - + public get total(): number { let total = this.fetchPublications.searchUtils.totalResults; total += this.fetchDatasets.searchUtils.totalResults; @@ -665,7 +669,7 @@ export class OrganizationComponent { total += this.fetchOrps.searchUtils.totalResults; return total; } - + // public get numberOfTabs(): number { // if (this.tabsAreInitialized) { // return this._numberOfTabs; @@ -724,7 +728,7 @@ export class OrganizationComponent { // this.tabsAreInitialized = true; // return this._numberOfTabs; // } - + private getEntityName(entityType: string, plural: boolean, full: boolean): string { if (entityType == "publication") { return "publication" + (plural ? "s" : ""); @@ -740,7 +744,7 @@ export class OrganizationComponent { return entityType + (plural ? "s" : ""); } } - + public scroll() { HelperFunctions.scroll(); } diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 54610e24..0c34b5bc 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -152,6 +152,7 @@ export class ProjectComponent { //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 => { @@ -351,9 +352,12 @@ export class ProjectComponent { this.handleError("Error getting project for id: " + this.projectId, err); if(err.status == 404) { this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); + }else if(err.name == "TimeoutError"){ + this.errorMessage = 'An error occurred please try again later'; + }else { + this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToProjects); + this.errorMessage = 'No project found'; } - this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToProjects); - this.errorMessage = 'No project found'; this.showLoading = false; } )); @@ -380,9 +384,12 @@ export class ProjectComponent { this.handleError("Error getting project for grant id: " + grantId + " and funder: " + funder, err); if(err.status == 404) { this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": "project"}}); + }else if(err.name == "TimeoutError"){ + this.errorMessage = 'An error occurred please try again later'; + }else { + this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToProjects); + this.errorMessage = 'No project found'; } - this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.properties.searchLinkToProjects); - this.errorMessage = 'No project found'; this.showLoading = false; } )); diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 7b295a5e..c06eae1d 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -143,6 +143,7 @@ export class ResultLandingComponent { //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(data => { if (data['articleId']) { this.id = data['articleId']; @@ -422,17 +423,19 @@ export class ResultLandingComponent { this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err); if (err.status == 404) { this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}}); - } - - if (this.type == "publication" || this.type == "software") { - this.errorMessage = 'No ' + this.type + ' found'; - } else if (this.type == "dataset") { - this.errorMessage += "No research data found"; - } else if (this.type == "orp") { - this.errorMessage += "No research product found"; + }else if(err.name == "TimeoutError"){ + this.errorMessage = 'An error occurred please try again later'; + }else{ + if (this.type == "publication" || this.type == "software") { + this.errorMessage = 'No ' + this.type + ' found'; + } else if (this.type == "dataset") { + this.errorMessage += "No research data found"; + } else if (this.type == "orp") { + this.errorMessage += "No research product found"; + } + this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage); } this.showLoading = false; - this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage); } )); }