[Trunk | Library]:
1. configuration.service.ts: Use "useLongCache" property for communityFull | Add BehaviorSubject for communityFull | Add filtering methods to check if route is enabled from communityFull info. 2. isRouteEnabled.guard.ts: Get properties from environment (no service needed) | Foreach route do not query API but check if enabled by communityFull info (BehaviorSubject). 3. search.component.ts & searchAll.component.ts & entitiesSelection.component.ts & quick-selections.component.ts & navigationBar.component.ts & bottom.component.ts: Get communityFull info from state (call configurationService.communityInformationState) | Add subscriptions in array to unsubscribe in ngOnDestroy. quick-selections.component.ts: Add "uk-disabled" class when needed in <form> elements. 4. resultLanding.module.ts & navigationBar.module.ts & bottom.module.ts & entitiesSelection.module.ts & quick-selections.module.ts: Remove ConfigurationService from providers (singleton service, providedIn: 'root'). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59074 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
0e26d955bc
commit
5c9575ab7a
|
@ -1,7 +1,7 @@
|
|||
|
||||
import {of as observableOf, Observable} from 'rxjs';
|
||||
import {of as observableOf, Observable, Subject} from 'rxjs';
|
||||
|
||||
import {map, filter, mergeMap} from 'rxjs/operators';
|
||||
import {map, filter, mergeMap, tap} from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Router,
|
||||
|
@ -15,6 +15,10 @@ import {
|
|||
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
||||
import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service';
|
||||
import {ConnectHelper} from '../connect/connectHelper';
|
||||
import {properties} from "../../../environments/environment";
|
||||
import {LoginErrorCodes} from "../login/utils/guardHelper.class";
|
||||
import {of} from 'rxjs';
|
||||
import {Page} from "../utils/entities/adminTool/page";
|
||||
|
||||
@Injectable()
|
||||
export class IsRouteEnabled implements CanActivate {
|
||||
|
@ -23,29 +27,60 @@ export class IsRouteEnabled implements CanActivate {
|
|||
private config: ConfigurationService,
|
||||
private propertiesService: EnvironmentSpecificService) {}
|
||||
|
||||
// check(data: Data, community: string, path: string): Observable<boolean> | boolean {
|
||||
// const customRedirect = data['redirect'];
|
||||
//
|
||||
// const redirect = customRedirect ? customRedirect : '/error';
|
||||
// const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => {
|
||||
// let communityDomain = null;
|
||||
// //if (!community) {
|
||||
// communityDomain = ConnectHelper.getCommunityFromDomain(res.domain);
|
||||
// //}
|
||||
// if(communityDomain) {
|
||||
// community = communityDomain;
|
||||
// } else if (!community && data['community']) { // for openaire or connect
|
||||
// community = data['community'];
|
||||
// }
|
||||
// return res;
|
||||
// }),mergeMap(prop => {
|
||||
// if (!community) {
|
||||
// community = prop.adminToolsCommunity;
|
||||
// }
|
||||
// return this.config.isPageEnabled(prop, community, '/' + path);
|
||||
// }),);
|
||||
// console.log("check isRouteEnabled.guard : call isPageEnabled");
|
||||
//
|
||||
// obs.pipe(filter(enabled => !enabled))
|
||||
// .subscribe(() => this.router.navigate([redirect], {queryParams: {'page': path}}));
|
||||
// return obs;
|
||||
// }
|
||||
|
||||
check(data: Data, community: string, path: string): Observable<boolean> | boolean {
|
||||
const customRedirect = data['redirect'];
|
||||
|
||||
const redirect = customRedirect ? customRedirect : '/error';
|
||||
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => {
|
||||
let communityDomain = null;
|
||||
//if (!community) {
|
||||
communityDomain = ConnectHelper.getCommunityFromDomain(res.domain);
|
||||
//}
|
||||
let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain);
|
||||
|
||||
if(communityDomain) {
|
||||
community = communityDomain;
|
||||
} else if (!community && data['community']) { // for openaire or connect
|
||||
community = data['community'];
|
||||
}
|
||||
return res;
|
||||
}),mergeMap(prop => {
|
||||
|
||||
if (!community) {
|
||||
community = prop.adminToolsCommunity;
|
||||
community = properties.adminToolsCommunity;
|
||||
}
|
||||
return this.config.isPageEnabled(prop, community, '/' + path);
|
||||
}),);
|
||||
obs.pipe(filter(enabled => !enabled))
|
||||
.subscribe(() => this.router.navigate([redirect], {queryParams: {'page': path}}));
|
||||
|
||||
const obs =
|
||||
//this.config.isPageEnabled(properties, community, '/' + path);
|
||||
this.config.isPageEnabledByState(properties, community, '/'+path);
|
||||
obs
|
||||
.pipe(tap((enabled) => console.log("aaa: "+enabled)))
|
||||
.pipe(filter(enabled => !enabled))
|
||||
.subscribe(() => {
|
||||
this.router.navigate([redirect], {queryParams: {'page': path}});
|
||||
});
|
||||
|
||||
return obs;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import {CiteThisModule} from '../landing-utils/citeThis/citeThis.m
|
|||
import {IFrameModule} from '../../utils/iframe.module';
|
||||
import {AltMetricsModule} from '../../utils/altmetrics.module';
|
||||
import {PagingModule} from '../../utils/paging.module';
|
||||
import {ConfigurationServiceModule} from '../../utils/configuration/configurationService.module';
|
||||
|
||||
import {FreeGuard} from '../../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||
|
@ -36,7 +35,7 @@ import {LoadingModule} from "../../utils/loading/loading.module";
|
|||
imports: [
|
||||
CommonModule, FormsModule, LandingModule, SharedModule, RouterModule,
|
||||
CiteThisModule, PagingModule, IFrameModule,
|
||||
MetricsModule, AltMetricsModule, ConfigurationServiceModule, Schema2jsonldModule, SEOServiceModule,
|
||||
MetricsModule, AltMetricsModule, Schema2jsonldModule, SEOServiceModule,
|
||||
DeletedByInferenceModule, ShowAuthorsModule, HelperModule, ResultLandingUtilsModule, AlertModalModule, AnnotationModule, LandingHeaderModule, NoLoadPaging, ResultPreviewModule, FeedbackModule, TabsModule, LoadingModule
|
||||
],
|
||||
declarations: [
|
||||
|
|
|
@ -34,8 +34,8 @@ import {Observable, Subscription} from "rxjs";
|
|||
templateUrl: 'search.component.html'
|
||||
})
|
||||
export class SearchComponent {
|
||||
public sub: any;
|
||||
piwiksub: any;
|
||||
subs: Subscription[] = [];
|
||||
|
||||
public reloadPublications: boolean;
|
||||
public reloadDatasets: boolean;
|
||||
public reloadSoftware: boolean;
|
||||
|
@ -98,15 +98,6 @@ export class SearchComponent {
|
|||
@Input() piwikSiteId = null;
|
||||
@Input() formPlaceholderText = "Search for research outcomes, projects, content providers & organizations in OpenAIRE";
|
||||
|
||||
|
||||
public subPub;
|
||||
public subData;
|
||||
public subSoftware;
|
||||
public subOrps;
|
||||
public subProjects;
|
||||
public subOrg;
|
||||
public subDataPr;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private _searchResearchResultsService: SearchResearchResultsService,
|
||||
|
@ -131,7 +122,7 @@ export class SearchComponent {
|
|||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
this.subs.push(this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
|
||||
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
|
||||
|
@ -145,13 +136,15 @@ export class SearchComponent {
|
|||
this._meta.updateTag({content: url}, "property='og:url'");
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
|
||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
|
||||
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe());
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity) {
|
||||
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
//this.subs.push(this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
var showEntity = {};
|
||||
for (var i = 0; i < data['entities'].length; i++) {
|
||||
|
||||
|
@ -170,8 +163,8 @@ export class SearchComponent {
|
|||
this.showDataProviders = false;
|
||||
}
|
||||
this.loadAll();
|
||||
|
||||
});
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
if ((this.customFilter && this.customFilter.queryFieldName == "country")) {
|
||||
this.showPublications =true;
|
||||
|
@ -185,11 +178,11 @@ export class SearchComponent {
|
|||
}
|
||||
}
|
||||
this.loadAll();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
loadAll() {
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.subs.push(this.route.queryParams.subscribe(params => {
|
||||
|
||||
this.reloadTabs();
|
||||
this.keyword = (params['keyword']) ? params['keyword'] : "";
|
||||
|
@ -219,40 +212,13 @@ export class SearchComponent {
|
|||
}
|
||||
this.count();
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if (this.piwiksub) {
|
||||
this.piwiksub.unsubscribe();
|
||||
}
|
||||
if (this.keyword != null && this.keyword.length > 0) {
|
||||
if (this.subPub) {
|
||||
this.subPub.unsubscribe();
|
||||
}
|
||||
if (this.subData) {
|
||||
this.subData.unsubscribe();
|
||||
}
|
||||
if (this.subSoftware) {
|
||||
this.subSoftware.unsubscribe();
|
||||
}
|
||||
if (this.subOrps) {
|
||||
this.subOrps.unsubscribe();
|
||||
}
|
||||
if (this.subProjects) {
|
||||
this.subProjects.unsubscribe();
|
||||
}
|
||||
if (this.subOrg) {
|
||||
this.subOrg.unsubscribe();
|
||||
}
|
||||
if (this.subDataPr) {
|
||||
this.subDataPr.unsubscribe();
|
||||
}
|
||||
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,27 +356,27 @@ export class SearchComponent {
|
|||
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchPublications.results = [];
|
||||
|
||||
this.subPub = this.numOfSearchResults("publication", this.fetchPublications, refineParams);
|
||||
this.subs.push(this.numOfSearchResults("publication", this.fetchPublications, refineParams));
|
||||
}
|
||||
if (this.activeTab != "research data" && this.showDatasets) {
|
||||
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchDatasets.results = [];
|
||||
this.subData = this.numOfSearchResults("dataset", this.fetchDatasets, refineParams);
|
||||
this.subs.push(this.numOfSearchResults("dataset", this.fetchDatasets, refineParams));
|
||||
}
|
||||
if (this.activeTab != "software" && this.showSoftware) {
|
||||
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchSoftware.results = [];
|
||||
this.subSoftware = this.numOfSearchResults("software", this.fetchSoftware, refineParams);
|
||||
this.subs.push(this.numOfSearchResults("software", this.fetchSoftware, refineParams));
|
||||
}
|
||||
if (this.activeTab != "other research products" && this.showOrps) {
|
||||
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchOrps.results = [];
|
||||
this.subOrps = this.numOfSearchResults("other", this.fetchOrps, refineParams);
|
||||
this.subs.push(this.numOfSearchResults("other", this.fetchOrps, refineParams));
|
||||
}
|
||||
if (this.activeTab != "projects" && this.showProjects) {
|
||||
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchProjects.results = [];
|
||||
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword, this.properties, refineParams).subscribe(
|
||||
this.subs.push(this._searchProjectsService.numOfSearchProjects(this.keyword, this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
this.fetchProjects.searchUtils.totalResults = data;
|
||||
this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
|
||||
|
@ -423,7 +389,7 @@ export class SearchComponent {
|
|||
this.handleError("Error getting number of Projects", err);
|
||||
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
if (this.activeTab != "content providers" && this.showDataProviders) {
|
||||
this.fetchDataproviders.results = [];
|
||||
|
@ -432,7 +398,7 @@ export class SearchComponent {
|
|||
if (this.activeTab != "organizations" && this.showOrganizations) {
|
||||
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchOrganizations.results = [];
|
||||
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword, this.properties, refineParams).subscribe(
|
||||
this.subs.push(this._searchOrganizationsService.numOfSearchOrganizations(this.keyword, this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
this.fetchOrganizations.searchUtils.totalResults = data;
|
||||
this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
|
||||
|
@ -446,7 +412,7 @@ export class SearchComponent {
|
|||
this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR;
|
||||
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import {EnvProperties} from '../../utils/properties/env-properties';
|
|||
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
||||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
import {SearchCustomFilter} from "../searchUtils/searchUtils.class";
|
||||
import {Observable} from "rxjs";
|
||||
import {Observable, Subscription} from "rxjs";
|
||||
import {AdvancedField, Filter} from "../searchUtils/searchHelperClasses.class";
|
||||
import {SearchResearchResultsComponent} from "../searchResearchResults.component";
|
||||
import {SearchProjectsComponent} from "../searchProjects.component";
|
||||
|
@ -40,8 +40,6 @@ import {NewSearchPageComponent} from "../searchUtils/newSearchPage.component";
|
|||
templateUrl: 'searchAll.component.html'
|
||||
})
|
||||
export class SearchAllComponent {
|
||||
public sub: any;
|
||||
piwiksub: any;
|
||||
// public reloadResults: boolean;
|
||||
// public reloadPublications: boolean;
|
||||
// public reloadDatasets: boolean;
|
||||
|
@ -95,15 +93,7 @@ export class SearchAllComponent {
|
|||
@Input() piwikSiteId = null;
|
||||
@Input() formPlaceholderText = "Search for research outcomes, projects, content providers & organizations in OpenAIRE";
|
||||
|
||||
|
||||
public subPub;
|
||||
public subData;
|
||||
public subSoftware;
|
||||
public subOrps;
|
||||
public subProjects;
|
||||
public subOrg;
|
||||
public subDataPr;
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
||||
filter: null,
|
||||
|
@ -151,7 +141,7 @@ export class SearchAllComponent {
|
|||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.data
|
||||
this.subs.push(this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
|
||||
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
|
||||
|
@ -165,13 +155,15 @@ export class SearchAllComponent {
|
|||
this._meta.updateTag({content: url}, "property='og:url'");
|
||||
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
|
||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
|
||||
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe());
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity) {
|
||||
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
var showEntity = {};
|
||||
for (var i = 0; i < data['entities'].length; i++) {
|
||||
|
||||
|
@ -190,8 +182,8 @@ export class SearchAllComponent {
|
|||
this.showDataProviders = false;
|
||||
}
|
||||
this.loadAll();
|
||||
|
||||
});
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
if ((this.customFilter && this.customFilter.queryFieldName == "country")) {
|
||||
this.showPublications = true;
|
||||
|
@ -205,12 +197,12 @@ export class SearchAllComponent {
|
|||
}
|
||||
}
|
||||
this.loadAll();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
loadAll() {
|
||||
this.reloadTabs();
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.subs.push(this.route.queryParams.subscribe(params => {
|
||||
this.parameters = Object.assign({}, params);
|
||||
this.keyword = (params['keyword']) ? params['keyword'] : (params["q"] ? params["q"] : (params["f0"] && params["f0"] == "q" && params["fv0"]?params["fv0"]:""));
|
||||
this.selectedFields[0].value = StringUtils.URIDecode(this.keyword);
|
||||
|
@ -241,7 +233,7 @@ export class SearchAllComponent {
|
|||
this.searchOrganizations();
|
||||
}
|
||||
this.count();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
getDefaultEntityToShow(){
|
||||
|
@ -257,35 +249,8 @@ export class SearchAllComponent {
|
|||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
if (this.piwiksub) {
|
||||
this.piwiksub.unsubscribe();
|
||||
}
|
||||
if (this.keyword != null && this.keyword.length > 0) {
|
||||
if (this.subPub) {
|
||||
this.subPub.unsubscribe();
|
||||
}
|
||||
if (this.subData) {
|
||||
this.subData.unsubscribe();
|
||||
}
|
||||
if (this.subSoftware) {
|
||||
this.subSoftware.unsubscribe();
|
||||
}
|
||||
if (this.subOrps) {
|
||||
this.subOrps.unsubscribe();
|
||||
}
|
||||
if (this.subProjects) {
|
||||
this.subProjects.unsubscribe();
|
||||
}
|
||||
if (this.subOrg) {
|
||||
this.subOrg.unsubscribe();
|
||||
}
|
||||
if (this.subDataPr) {
|
||||
this.subDataPr.unsubscribe();
|
||||
}
|
||||
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,14 +355,14 @@ export class SearchAllComponent {
|
|||
this.reload["result"] = false;
|
||||
this.fetchPublications.results = [];
|
||||
//Add Open Access Filter
|
||||
this.subPub = this.numOfSearchResults(this.fetchPublications, (refineParams ? (refineParams + '&') : '') + "&fq=resultbestaccessright%20exact%20%22Open%20Access%22");
|
||||
this.subs.push(this.numOfSearchResults(this.fetchPublications, (refineParams ? (refineParams + '&') : '') + "&fq=resultbestaccessright%20exact%20%22Open%20Access%22"));
|
||||
}
|
||||
|
||||
if (this.activeEntity != "projects" && this.reload["projects"] && this.showProjects) {
|
||||
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchProjects.results = [];
|
||||
this.reload["projects"] = false;
|
||||
this.subProjects = this._searchProjectsService.numOfSearchProjects2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("project",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
this.subs.push(this._searchProjectsService.numOfSearchProjects2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("project",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
this.fetchProjects.searchUtils.totalResults = data;
|
||||
this.fetchProjects.searchUtils.status = this.errorCodes.DONE;
|
||||
|
@ -411,13 +376,13 @@ export class SearchAllComponent {
|
|||
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
|
||||
this.fetchProjects.searchUtils.totalResults = null;
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
if (this.activeEntity != "datasources" && this.reload["datasources"] && this.showDataProviders) {
|
||||
this.fetchDataproviders.results = [];
|
||||
this.reload["datasources"] = false;
|
||||
// this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams);
|
||||
this.subDataPr = this._searchDataprovidersService.numOfSearchDataproviders2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("datasources",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("datasources",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
this.fetchDataproviders.searchUtils.totalResults = data;
|
||||
this.fetchDataproviders.searchUtils.status = this.errorCodes.DONE;
|
||||
|
@ -431,13 +396,13 @@ export class SearchAllComponent {
|
|||
this.fetchDataproviders.searchUtils.status = this.errorCodes.ERROR;
|
||||
this.fetchDataproviders.searchUtils.totalResults = null;
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
if (this.activeEntity != "organizations" && this.reload["organizations"] && this.showOrganizations) {
|
||||
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.fetchOrganizations.results = [];
|
||||
this.reload["organizations"] = false;
|
||||
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("organizations",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
this.subs.push(this._searchOrganizationsService.numOfSearchOrganizations2(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("organizations",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
this.fetchOrganizations.searchUtils.totalResults = data;
|
||||
this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE;
|
||||
|
@ -452,13 +417,13 @@ export class SearchAllComponent {
|
|||
this.fetchOrganizations.searchUtils.totalResults = null;
|
||||
|
||||
}
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private numOfSearchResults(fetchClass: FetchResearchResults, refineParams): Observable<any> {
|
||||
private numOfSearchResults(fetchClass: FetchResearchResults, refineParams): Subscription {
|
||||
return this._searchResearchResultsService.numOfResearchOutcomes(this.keyword.length>0?NewSearchPageComponent.createKeywordQuery("result",this.keyword,"q","="):"", this.properties, refineParams).subscribe(
|
||||
data => {
|
||||
fetchClass.searchUtils.totalResults = data;
|
||||
|
|
|
@ -7,6 +7,7 @@ import {Router} from "@angular/router";
|
|||
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
|
||||
import {MatSelect} from "@angular/material";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'entities-selection',
|
||||
|
@ -93,6 +94,8 @@ export class EntitiesSelectionComponent {
|
|||
show = 0;
|
||||
@ViewChild(MatSelect) matSelect: MatSelect;
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {
|
||||
|
||||
|
||||
|
@ -103,7 +106,9 @@ export class EntitiesSelectionComponent {
|
|||
this.show = 0;
|
||||
if (this.properties) {
|
||||
if((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity !== "monitor") {
|
||||
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
let showEntity = {};
|
||||
let showPage = {};
|
||||
for (let i = 0; i < data['entities'].length; i++) {
|
||||
|
@ -143,7 +148,8 @@ export class EntitiesSelectionComponent {
|
|||
if (this.show == 1) {
|
||||
this.disableSelect = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
} else if((this.customFilter && this.customFilter.queryFieldName == "communityId") && this.properties.adminToolsCommunity === "monitor") {
|
||||
this.show = 1;
|
||||
this.disableSelect = true;
|
||||
|
@ -191,6 +197,11 @@ export class EntitiesSelectionComponent {
|
|||
});
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
entityChanged() {
|
||||
if (!this.simpleView || this.onChangeNavigate) {
|
||||
|
|
|
@ -3,13 +3,12 @@ import {CommonModule} from '@angular/common';
|
|||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {EntitiesSelectionComponent} from "./entitiesSelection.component";
|
||||
import {ConfigurationServiceModule} from "../../utils/configuration/configurationService.module";
|
||||
import {MatSelectModule} from "@angular/material";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ReactiveFormsModule, ConfigurationServiceModule, MatSelectModule
|
||||
RouterModule, ReactiveFormsModule, MatSelectModule
|
||||
],
|
||||
declarations: [
|
||||
EntitiesSelectionComponent,
|
||||
|
|
|
@ -9,7 +9,8 @@ import {debounceTime} from "rxjs/operators";
|
|||
@Component({
|
||||
selector: 'quick-selections',
|
||||
template: `
|
||||
<form *ngIf="!vertical && (resultTypes || quickFilter)" [formGroup]="control" class="uk-text-small uk-margin-small-bottom uk-grid uk-inline uk-flex uk-margin-small-left">
|
||||
<form *ngIf="!vertical && (resultTypes || quickFilter)" [formGroup]="control"
|
||||
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-text-small uk-margin-small-bottom uk-grid uk-inline uk-flex uk-margin-small-left'">
|
||||
<div *ngIf="quickFilter" class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
|
||||
<span class="uk-text-bold">{{quickFilter.value}}</span>
|
||||
<mat-slide-toggle
|
||||
|
@ -26,7 +27,8 @@ import {debounceTime} from "rxjs/operators";
|
|||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<form *ngIf="vertical && (resultTypes || quickFilter)" [formGroup]="control" class="uk-margin-small-bottom uk-list uk-list-divider">
|
||||
<form *ngIf="vertical && (resultTypes || quickFilter)" [formGroup]="control"
|
||||
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-margin-small-bottom uk-list uk-list-divider'">
|
||||
<!-- <li *ngIf="quickFilter" class="uk-margin-small-bottom ">
|
||||
<div class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
|
||||
<h5 class="">{{quickFilter.value}}</h5>
|
||||
|
@ -35,6 +37,7 @@ import {debounceTime} from "rxjs/operators";
|
|||
</mat-slide-toggle>
|
||||
</div>
|
||||
</li>-->
|
||||
<!-- {{showEntities}} - {{showPublications}} - {{showDatasets}} - {{showSoftware}} -- {{showOrp}}-->
|
||||
<li *ngIf="resultTypes && showEntities" class="uk-margin-small-bottom ng-star-inserted">
|
||||
<div class="uk-margin-small-top uk-margin-bottom uk-grid uk-flex uk-flex-bottom">
|
||||
<h5 class="uk-margin-bottom-remove" title="Community">Research Type ({{(this.showPublications + this.showDatasets + this.showSoftware + this.showOrp)}})</h5>
|
||||
|
@ -86,10 +89,12 @@ export class QuickSelectionsComponent implements OnChanges {
|
|||
showSoftware: boolean = false;
|
||||
showOrp: boolean = false;
|
||||
showEntities = false;
|
||||
resultTypesObs: Subscription ;
|
||||
selectedTypesNum = 0;
|
||||
@Input() delayTime = 0;
|
||||
private clicks = new Subject();
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
constructor(private _fb: FormBuilder, private config: ConfigurationService) {
|
||||
|
||||
this.control = this._fb.group({
|
||||
|
@ -156,7 +161,9 @@ export class QuickSelectionsComponent implements OnChanges {
|
|||
}
|
||||
if(this.properties) {
|
||||
if(this.properties.adminToolsCommunity !== "monitor") {
|
||||
this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity).subscribe(data => {
|
||||
//this.subs.push(this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
var showEntity = {};
|
||||
for (var i = 0; i < data['entities'].length; i++) {
|
||||
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
||||
|
@ -166,13 +173,14 @@ export class QuickSelectionsComponent implements OnChanges {
|
|||
this.showSoftware = showEntity["software"];
|
||||
this.showOrp = showEntity["orp"];
|
||||
this.showEntities = this.showPublications || this.showDatasets || this.showSoftware || this.showOrp;
|
||||
}
|
||||
}, error => {
|
||||
this.showPublications = true;
|
||||
this.showDatasets = true;
|
||||
this.showSoftware = true;
|
||||
this.showOrp = true;
|
||||
this.showEntities = true;
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
this.showPublications = true;
|
||||
this.showDatasets = true;
|
||||
|
@ -181,12 +189,18 @@ export class QuickSelectionsComponent implements OnChanges {
|
|||
this.showEntities = true;
|
||||
}
|
||||
}
|
||||
this.resultTypesObs = this.clicks.pipe(
|
||||
this.subs.push(this.clicks.pipe(
|
||||
debounceTime(this.delayTime)
|
||||
).subscribe(e =>{this.actuallyChanged()} );
|
||||
).subscribe(e =>{this.actuallyChanged()} ));
|
||||
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.isDisabled) {
|
||||
if (changes.isDisabled.currentValue == true) {
|
||||
|
|
|
@ -4,12 +4,11 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
|||
import {RouterModule} from '@angular/router';
|
||||
import {QuickSelectionsComponent} from "./quick-selections.component";
|
||||
import {MatCheckboxModule, MatSlideToggleModule} from "@angular/material";
|
||||
import {ConfigurationServiceModule} from "../../utils/configuration/configurationService.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, MatCheckboxModule, ReactiveFormsModule, MatSlideToggleModule, ConfigurationServiceModule
|
||||
RouterModule, MatCheckboxModule, ReactiveFormsModule, MatSlideToggleModule
|
||||
],
|
||||
declarations: [
|
||||
QuickSelectionsComponent,
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'rxjs';
|
|||
import{MenuItem} from './menu';
|
||||
import { ConfigurationService } from '../utils/configuration/configuration.service';
|
||||
import {EnvProperties} from "../utils/properties/env-properties";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'bottom',
|
||||
|
@ -29,6 +30,8 @@ grantConenctText = "OpenAIRE-Connect receives funding from the European Union's
|
|||
@Input() centered:boolean=false;
|
||||
sectionClass= "uk-section-primary";
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
constructor(private config: ConfigurationService, private route: ActivatedRoute,) {
|
||||
}
|
||||
|
||||
|
@ -36,21 +39,29 @@ constructor(private config: ConfigurationService, private route: ActivatedRoute
|
|||
if(!this.darkBackground){
|
||||
this.sectionClass= " footer-light-background";
|
||||
}
|
||||
this.route.queryParams.subscribe(params => {
|
||||
this.subs.push(this.route.queryParams.subscribe(params => {
|
||||
if(this.showMenuItems){
|
||||
if( this.properties.adminToolsAPIURL && this.communityId ){
|
||||
this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
|
||||
//this.subs.push(this.config.getCommunityInformation(this.properties, this.communityId ).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
for (var i = 0; i < data['pages'].length; i++) {
|
||||
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
|
||||
|
||||
}
|
||||
// console.log(this.showPage)
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
});
|
||||
public ngOnDestroy() {
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isEnabled(required, enabled){
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@ import { FormsModule } from '@angular/forms';
|
|||
import { RouterModule } from "@angular/router";
|
||||
|
||||
import {BottomComponent} from './bottom.component';
|
||||
import { ConfigurationServiceModule } from '../utils/configuration/configurationService.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, RouterModule, ConfigurationServiceModule
|
||||
CommonModule, FormsModule, RouterModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
|
|
|
@ -5,6 +5,7 @@ import {ConfigurationService} from '../utils/configuration/configuration.service
|
|||
import {MenuItem, RootMenuItem} from './menu';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {Stakeholder} from "../monitor/entities/stakeholder";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'navbar',
|
||||
|
@ -39,7 +40,8 @@ export class NavigationBarComponent {
|
|||
|
||||
|
||||
public isAuthorized: boolean = false;
|
||||
sub: any;
|
||||
subs: Subscription[] = [];
|
||||
|
||||
showEntity = {};
|
||||
showPage = {};
|
||||
specialAnnouncementContent: string = null;
|
||||
|
@ -60,8 +62,8 @@ export class NavigationBarComponent {
|
|||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if(this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
for (let sub of this.subs) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +71,9 @@ export class NavigationBarComponent {
|
|||
this.activeRouteEnabled = false;
|
||||
this.isAuthorized = Session.isClaimsCurator(this.user) || Session.isPortalAdministrator(this.user);
|
||||
if (this.properties.adminToolsAPIURL && this.communityId) {
|
||||
this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => {
|
||||
//this.config.getCommunityInformation(this.properties, this.communityId).subscribe(data => {
|
||||
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
||||
if(data) {
|
||||
for (var i = 0; i < data['entities'].length; i++) {
|
||||
|
||||
this.showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
||||
|
@ -78,11 +82,11 @@ export class NavigationBarComponent {
|
|||
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting community information (e.g. pages,entities) for community with id: " + this.communityId, error);
|
||||
});
|
||||
}));
|
||||
}
|
||||
if(!this.community){
|
||||
this.logosrc = this.logoPath + "logo-large-"+this.portal+".png";
|
||||
|
|
|
@ -7,13 +7,12 @@ import { RouterModule } from "@angular/router";
|
|||
import { NavigationBarComponent} from './navigationBar.component';
|
||||
|
||||
import { UserMiniModule} from '../login/userMiniModule.module';
|
||||
import { ConfigurationServiceModule } from '../utils/configuration/configurationService.module';
|
||||
import {SearchBarModule} from "./searchBar/searchBar.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
RouterModule, ConfigurationServiceModule,
|
||||
RouterModule,
|
||||
UserMiniModule, SearchBarModule
|
||||
],
|
||||
declarations: [
|
||||
|
|
|
@ -1,25 +1,59 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response, Headers} from '@angular/http';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Observable} from 'rxjs';
|
||||
import {BehaviorSubject, from, Observable, Subscription} from 'rxjs';
|
||||
|
||||
|
||||
// import 'rxjs/add/operator/do';
|
||||
// import 'rxjs/add/operator/share';
|
||||
import {map, mapTo} from 'rxjs/operators';
|
||||
import {EnvProperties} from "../properties/env-properties";
|
||||
import {Community} from "../entities/adminTool/community";
|
||||
import {Page} from "../entities/adminTool/page";
|
||||
|
||||
@Injectable()
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConfigurationService {
|
||||
|
||||
private communityInformation: BehaviorSubject<Community> = new BehaviorSubject(null);
|
||||
private sub: Subscription = null;
|
||||
private source: Observable<Community> = null;
|
||||
private promise: Promise<boolean> = null;
|
||||
|
||||
constructor(private http: HttpClient ) {}
|
||||
|
||||
ngOnDestroy() {
|
||||
if(this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
getCommunityInformation(properties:EnvProperties, community:string){
|
||||
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
//.map(res => res.json());
|
||||
}
|
||||
|
||||
public initCommunityInformation(properties:EnvProperties, community:string) {
|
||||
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
|
||||
this.promise = new Promise<any>((resolve => {
|
||||
this.source = this.http.get<Community>((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
||||
|
||||
this.sub = this.source
|
||||
.subscribe(
|
||||
(communityInformation: Community) => {
|
||||
this.communityInformation.next(communityInformation);
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
public get communityInformationState(): Observable<Community> {
|
||||
return this.communityInformation.asObservable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
@ -35,10 +69,14 @@ export class ConfigurationService {
|
|||
.pipe(map(res => true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
isPageEnabled(properties:EnvProperties, community:string,router: string){
|
||||
let page_route: string = router.split('?')[0].substring(1);
|
||||
|
||||
let url = properties.adminToolsAPIURL + "/community/" + community+"/pages?page_route="+page_route;
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => res.json())
|
||||
.pipe(map(res => {
|
||||
let result = false;
|
||||
|
@ -50,6 +88,37 @@ export class ConfigurationService {
|
|||
}));//.do(res => {console.log("Route "+page_route +" is "+res)});
|
||||
}
|
||||
|
||||
async isPageEnabledByStateAsync(properties: EnvProperties, community:string, page_route: string) {
|
||||
if(!this.promise) {
|
||||
this.initCommunityInformation(properties, community);
|
||||
}
|
||||
|
||||
await this.promise;
|
||||
return this.filtering(page_route);
|
||||
}
|
||||
|
||||
isPageEnabledByState(properties: EnvProperties, community:string, router: string): Observable<boolean> {
|
||||
let page_route: string = router.split('?')[0].substring(1);
|
||||
return from(this.isPageEnabledByStateAsync(properties, community, page_route));
|
||||
}
|
||||
|
||||
filtering(page_route: string) {
|
||||
let community: Community = this.communityInformation.getValue();
|
||||
|
||||
let pages: Page[] = <Page[]>community.pages;
|
||||
pages = pages.filter(function (page: Page) {
|
||||
return page.route == page_route;
|
||||
});
|
||||
|
||||
if (pages) {
|
||||
let result = false;
|
||||
if (pages['length'] > 0 && pages[0].route == page_route) {
|
||||
result = pages[0].isEnabled;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue