[master | DONE]: Add My reasearcher page in user menu if orcid is available in user account and he has results in Irish.

This commit is contained in:
Konstantinos Triantafyllou 2023-12-08 15:35:51 +02:00
parent 127af64285
commit df51766786
7 changed files with 138 additions and 66 deletions

View File

@ -10,6 +10,11 @@ import {Session, User} from "./openaireLibrary/login/utils/helper.class";
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
import {StakeholderBaseComponent} from "./openaireLibrary/monitor-admin/utils/stakeholder-base.component";
import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {StakeholderUtils} from "./openaireLibrary/monitor-admin/utils/indicator-utils";
import {ResearcherBaseComponent} from "./shared/researcher-base.component";
import {SearchOrcidService} from "./openaireLibrary/claims/claim-utils/service/searchOrcid.service";
import {SearchResearchResultsService} from "./openaireLibrary/services/searchResearchResults.service";
import {properties} from "../environments/environment";
@Component({
selector: 'app-root',
@ -28,10 +33,10 @@ import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sideba
</div>
</div>
<cookie-law *ngIf="isClient" position="bottom" cookieName="cookieLawSeen-NOAMIreland">
National Open Access Monitor - Ireland, uses cookies in order to function properly.<br>
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible.
By using the National Open Access Monitor - Ireland portal you accept our use of cookies. <!--<a
National Open Access Monitor - Ireland, uses cookies in order to function properly.<br>
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible.
By using the National Open Access Monitor - Ireland portal you accept our use of cookies. <!--<a
href="https://www.openaire.eu/privacy-policy#cookies" target="_blank"> Read more <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
@ -40,7 +45,7 @@ import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sideba
</cookie-law>
`
})
export class AppComponent extends StakeholderBaseComponent implements OnInit {
export class AppComponent extends ResearcherBaseComponent implements OnInit {
loading: boolean = false;
hasHeader: boolean = true;
rootClass: string;
@ -52,20 +57,24 @@ export class AppComponent extends StakeholderBaseComponent implements OnInit {
position: 'left',
badge: true,
};
menuItems:MenuItem[] = [];
menuItems: MenuItem[] = [];
userMenuItems: MenuItem[] = [];
irish: Irish = new Irish();
user: User;
isClient:boolean = false;
isClient: boolean = false;
stakeholderUtils: StakeholderUtils = new StakeholderUtils();
constructor(protected _route: ActivatedRoute,
protected _router: Router,
protected cdr: ChangeDetectorRef,
protected _searchOrcidService: SearchOrcidService,
protected _searchResearchResultsService: SearchResearchResultsService,
private layoutService: LayoutService,
private smoothScroll: SmoothScroll,
private configurationService: ConfigurationService,
private customFilterService:CustomFilterService,
private userManagementService: UserManagementService) {
private customFilterService: CustomFilterService,
private userManagementService: UserManagementService,
) {
super();
this.configurationService.initStaticPortal(this.irish.portal);
}
@ -100,17 +109,35 @@ export class AppComponent extends StakeholderBaseComponent implements OnInit {
new MenuItem("researcher", "Researcher Monitors", "", "/researcher", false, [], null, {}, null, null, null, "/researcher"),
new MenuItem("repository", "Repository Monitors", "", "/repository", false, [], null, {}, null, null, null, "/repository"),
];
if (this.user) {
this.userMenuItems = [];
this.user.orcid = '0000-0003-4768-182X';
if(this.user.orcid) {
this.authorId = this.user.orcid;
this.results = {
success: (res: string | number) => {
if(+res > 0) {
this.userMenuItems.push(new MenuItem("my-researcher", "My Researcher Monitor", "", "/researcher/" + this.authorId, false, [], null, {}, null, null, null, null));
this.staticUserItems();
}
}
}
this.search();
} else {
this.staticUserItems();
}
}
}
if(this.user) {
this.userMenuItems = [
staticUserItems() {
this.userMenuItems.push(
new MenuItem("myorcidlinks", "My Orcid links", "", "/my-orcid-links", false, [], null, {}, null, null, null, null),
new MenuItem("myclaims", "My claims", "", "/participate/myclaims", false, [], null, {}, null, null, null, null),
new MenuItem("claims", "Link", "", "/participate/claim", false, [], null, {}, null, null, null, null),
new MenuItem("upload-dois", "Upload DOIs", "", "/upload-dois", false, [], null, {}, null, null, null, null)
];
if(this.isAdmin) {
this.userMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'}));
}
);
if (this.isAdmin) {
this.userMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'}));
}
}

View File

@ -14,6 +14,8 @@ import {SharedModule} from "./openaireLibrary/shared/shared.module";
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import {ErrorModule} from "./openaireLibrary/error/error.module";
import {CookieLawModule} from "./openaireLibrary/sharedComponents/cookie-law/cookie-law.module";
import {SearchResearchResultsServiceModule} from "./openaireLibrary/services/searchResearchResultsService.module";
import {SearchOrcidService} from "./openaireLibrary/claims/claim-utils/service/searchOrcid.service";
@NgModule({
declarations: [
@ -29,9 +31,11 @@ import {CookieLawModule} from "./openaireLibrary/sharedComponents/cookie-law/coo
NavigationBarModule,
BottomModule,
AppRoutingModule,
CookieLawModule
CookieLawModule,
SearchResearchResultsServiceModule
],
providers: [
SearchOrcidService,
{provide: APP_ID, useValue: 'irish-monitor'},
{
provide: HTTP_INTERCEPTORS,

@ -1 +1 @@
Subproject commit 2e336b93a8d564f5e88d842fd7b283ebc09be37c
Subproject commit 684c9ac4c07e0ab9d6ee7a06fbc53fc467544b9b

View File

@ -1,18 +1,17 @@
import {Component, OnInit} from "@angular/core";
import {BaseComponent} from "../openaireLibrary/sharedComponents/base/base.component";
import {ActivatedRoute, Router} from "@angular/router";
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
import {Meta, Title} from "@angular/platform-browser";
import {properties} from "../../environments/environment";
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {SearchOrcidService} from "../openaireLibrary/claims/claim-utils/service/searchOrcid.service";
import {CustomFilterService} from "../shared/customFilter.service";
import {LinksResolver} from "../search/links-resolver";
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {ResearcherBaseComponent} from "../shared/researcher-base.component";
import {LinksResolver} from "../search/links-resolver";
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {properties} from "../../environments/environment";
@Component({
selector: 'researcher',
@ -22,7 +21,7 @@ import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sideb
<div class="uk-banner uk-light">
<div class="uk-container uk-container-large">
<div class="uk-padding-small uk-padding-remove-vertical">
<div *ngIf="authorId && author" class="uk-width-1-1 uk-flex">
<div *ngIf="authorId && author" class="uk-grid uk-grid-large" uk-grid>
<div class="uk-width-expand">
<div class="uk-grid uk-grid-small uk-flex-middle" uk-grid>
<div>
@ -49,7 +48,7 @@ import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sideb
<div *ngIf="openResults && totalResults" class="uk-width-auto">
<div class="uk-progress-semicircle open-access" [attr.percentage]="getPercentage()" [style]="'--percentage:' + getPercentage()"></div>
<div class="uk-flex uk-flex-middle uk-margin-small-top">
<icon [name]="'open_access'" [flex]="true"></icon>
<icon customClass="open-access" [name]="'open_access'" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Open Access</span>
</div>
</div>
@ -64,24 +63,23 @@ import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sideb
</div>
`
})
export class ResearcherComponent extends BaseComponent implements OnInit {
author;
authorId;
totalResults;
openResults;
loading = false;
export class ResearcherComponent extends ResearcherBaseComponent implements OnInit {
totalResults: number;
openResults: number;
loading: boolean = false;
constructor(protected _router: Router,
protected _route: ActivatedRoute,
protected seoService: SEOService,
protected _piwikService: PiwikService,
protected _title: Title,
protected _meta: Meta,
private layoutService: LayoutService,
private _searchOrcidService: SearchOrcidService,
private _customFilterService:CustomFilterService, private _searchResearchResultsService: SearchResearchResultsService) {
protected _searchOrcidService: SearchOrcidService,
protected _searchResearchResultsService: SearchResearchResultsService,
private _customFilterService: CustomFilterService,
private layoutService: LayoutService) {
super();
super.initRouterParams(this._route);
}
@ -95,19 +93,32 @@ export class ResearcherComponent extends BaseComponent implements OnInit {
this.loading = true;
LinksResolver.resetProperties();
LinksResolver.setSearchAndResultLanding("researcher/" + this.authorId);
this.subscriptions.push(this._searchOrcidService.searchOrcidSingleAuthor(this.authorId, properties, true).subscribe(data => {
this.author = data;
this._customFilterService.setCustomFilter(
[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false),
new SearchCustomFilter("Orcid", "authorId", this.authorId, this.author.authorGivenName + " " + this.author.authorFamilyName)
]);
this.getResultsForAuthor();
}, err => {
this._router.navigate([properties.errorLink]);
}));
this.orcid = {
success: () => {
this._customFilterService.setCustomFilter(
[new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false),
new SearchCustomFilter("Orcid", "authorId", this.authorId, this.author.authorGivenName + " " + this.author.authorFamilyName)
]);
},
error: () => {
this._router.navigate([properties.errorLink]);
}
}
this.results = {
success: (res: string | number) => {
this.totalResults = +res;
if(this.totalResults ==0 ){
this._router.navigate([properties.errorLink]);
}else{
this.loading = false;
this.subscriptions.push(this._searchResearchResultsService.numOfResearchOutcomes(this.param + ' and (resultbestaccessright exact "Open Access")', properties, null).subscribe(res => {
this.openResults = +res;
}));
}
}
}
this.search();
}
});
}
@ -116,25 +127,8 @@ export class ResearcherComponent extends BaseComponent implements OnInit {
this.layoutService.setRootClass(null);
}
getResultsForAuthor(){
let param = '(authorid="' + StringUtils.URIEncode(this.author.id) + '")';
param += ' and (country exact "IE")';
this.subscriptions.push(this._searchResearchResultsService.numOfResearchOutcomes(param, properties, null).subscribe(res => {
this.totalResults = res;
if(this.totalResults ==0 ){
this._router.navigate([properties.errorLink]);
}else{
this.loading = false;
this.subscriptions.push(this._searchResearchResultsService.numOfResearchOutcomes(param + ' and (resultbestaccessright exact "Open Access")', properties, null).subscribe(res => {
this.openResults = res;
}));
}
}));
}
getPercentage(){
var num = new Number((this.openResults/this.totalResults)*100);
let num = (this.openResults/this.totalResults)*100;
return num == 100?100:num.toPrecision(2);
}
}

View File

@ -0,0 +1,47 @@
import {Directive} from "@angular/core";
import {BaseComponent} from "../openaireLibrary/sharedComponents/base/base.component";
import {SearchOrcidService} from "../openaireLibrary/claims/claim-utils/service/searchOrcid.service";
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
import {properties} from "../../environments/environment";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
interface Resolver {
success?: Function;
error?: Function;
}
@Directive()
export class ResearcherBaseComponent extends BaseComponent {
author: any;
authorId: string;
orcid: Resolver;
results: Resolver;
param: string;
protected _searchOrcidService: SearchOrcidService;
protected _searchResearchResultsService: SearchResearchResultsService;
search() {
this.subscriptions.push(this._searchOrcidService.searchOrcidSingleAuthor(this.authorId, properties, true).subscribe(data => {
this.author = data;
if(this.orcid?.success) {
this.orcid.success(data);
}
this.getResultsForAuthor();
}, () => {
if(this.orcid?.error) {
this.orcid.error();
}
}));
}
getResultsForAuthor(){
this.param = '(authorid="' + StringUtils.URIEncode(this.author.id) + '") and (country exact "IE")';
this.subscriptions.push(this._searchResearchResultsService.numOfResearchOutcomes(this.param, properties, null).subscribe(res => {
if(this.results?.success) {
this.results?.success(res);
}
}));
}
}

View File

@ -8,7 +8,7 @@
/* Shadows */
@global-default-shadow: 2px 2px 5px #00000014;
@inverse-global-large-box-shadow: 0px 3px 6px #0000001A;
/* Controls */
@global-control-small-height: 25px;

@ -1 +1 @@
Subproject commit c9e01c8a90b6caeb2bb060106c82caf68c511fa5
Subproject commit 2e308b336682f993c8cdef369d36c3e2f32271f1