Merge branch 'develop' of code-repo.d4science.org:MaDgIK/openaire-library into develop
This commit is contained in:
commit
9025836af4
|
@ -32,6 +32,7 @@ export class SideBarComponent implements OnInit, AfterViewInit, OnDestroy, OnCha
|
|||
@ViewChild("sidebar_offcanvas") sidebar_offcanvas: ElementRef;
|
||||
public properties = properties;
|
||||
private subscriptions: any[] = [];
|
||||
private init: boolean = false;
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router,
|
||||
private sanitizer: DomSanitizer, private layoutService: LayoutService,
|
||||
|
@ -48,18 +49,15 @@ export class SideBarComponent implements OnInit, AfterViewInit, OnDestroy, OnCha
|
|||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if(this.nav && typeof UIkit !== "undefined") {
|
||||
setTimeout(() => {
|
||||
if(this.items[this.activeIndex]?.items?.length > 0) {
|
||||
UIkit.nav(this.nav.nativeElement).toggle(this.activeIndex, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.toggle(true);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if(changes.activeItem || changes.activeSubItem || changes.items) {
|
||||
this.setActiveMenuItem();
|
||||
if(this.init && changes.items) {
|
||||
this.toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +70,17 @@ export class SideBarComponent implements OnInit, AfterViewInit, OnDestroy, OnCha
|
|||
});
|
||||
}
|
||||
|
||||
toggle(init: boolean = false) {
|
||||
this.init = this.init || init;
|
||||
if(this.nav && typeof UIkit !== "undefined") {
|
||||
setTimeout(() => {
|
||||
if(this.items[this.activeIndex]?.items?.length > 0) {
|
||||
UIkit.nav(this.nav.nativeElement).toggle(this.activeIndex, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get isBrowser() {
|
||||
return this.platformId === 'browser';
|
||||
}
|
||||
|
@ -143,10 +152,6 @@ export class SideBarComponent implements OnInit, AfterViewInit, OnDestroy, OnCha
|
|||
}
|
||||
}
|
||||
|
||||
isTheActiveUrl(menuItemURL): boolean {
|
||||
return (menuItemURL == this.router.url.split('?')[0])
|
||||
}
|
||||
|
||||
public get open() {
|
||||
return this.layoutService.open;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|||
this.updateLists();
|
||||
this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
console.log(this.canDelete)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import {HttpClient} from "@angular/common/http";
|
||||
import {ChangeDetectorRef, Component, ElementRef, Input, ViewChild} from "@angular/core";
|
||||
import {FormBuilder, FormControl, UntypedFormArray} from "@angular/forms";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
|
@ -8,6 +7,7 @@ import {properties} from "../../../../environments/environment";
|
|||
import {StringUtils} from "../../utils/string-utils.class";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
declare var UIkit;
|
||||
|
@ -44,7 +44,7 @@ export class FosSelectionComponent {
|
|||
public sliderInit: boolean = false;
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private vocabulariesService: ISVocabulariesService,
|
||||
private fb: FormBuilder,
|
||||
private cdr: ChangeDetectorRef,
|
||||
private route: ActivatedRoute,
|
||||
|
@ -53,7 +53,7 @@ export class FosSelectionComponent {
|
|||
|
||||
ngOnInit() {
|
||||
this.loading = true;
|
||||
this.httpClient.get(this.properties.domain+'/assets/common-assets/vocabulary/fos.json').subscribe(data => {
|
||||
this.vocabulariesService.getFos(properties).subscribe(data => {
|
||||
this.fos = data['fos'];
|
||||
this.convertFosToOptions();
|
||||
if (typeof document !== 'undefined') {
|
||||
|
|
|
@ -14,6 +14,7 @@ import {SEOService} from "../sharedComponents/SEO/SEO.service";
|
|||
import {PiwikService} from "../utils/piwik/piwik.service";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
import {ISVocabulariesService} from "../utils/staticAutoComplete/ISVocabularies.service";
|
||||
|
||||
declare var UIkit;
|
||||
|
||||
|
@ -49,7 +50,7 @@ export class FosComponent implements OnInit, OnDestroy {
|
|||
public sliderInit: boolean = false;
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private vocabulariesService: ISVocabulariesService,
|
||||
private fb: FormBuilder,
|
||||
private location: Location,
|
||||
private route: ActivatedRoute,
|
||||
|
@ -70,7 +71,7 @@ export class FosComponent implements OnInit, OnDestroy {
|
|||
this.updateUrl(this.url);
|
||||
this.updateTitle(this.pageTitle);
|
||||
this.updateDescription(this.pageDescription);
|
||||
this.httpClient.get(properties.domain+'/assets/common-assets/vocabulary/fos.json').subscribe(data => {
|
||||
this.vocabulariesService.getFos(properties).subscribe(data => {
|
||||
this.fos = data['fos'];
|
||||
this.convertFosToOptions();
|
||||
if (typeof document !== 'undefined') {
|
||||
|
|
|
@ -4,6 +4,7 @@ import {UntypedFormArray, UntypedFormBuilder} from "@angular/forms";
|
|||
import {properties} from "../../../../environments/environment";
|
||||
import {EnvProperties} from "../../utils/properties/env-properties";
|
||||
import {StringUtils} from "../../utils/string-utils.class";
|
||||
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
|
||||
|
||||
@Component({
|
||||
selector: 'sdg-selection',
|
||||
|
@ -20,14 +21,14 @@ export class SdgSelectionComponent {
|
|||
public sdgs: UntypedFormArray;
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private vocabulariesService: ISVocabulariesService,
|
||||
private fb: UntypedFormBuilder
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.loading = true;
|
||||
this.sdgs = this.fb.array([]);
|
||||
this.httpClient.get(this.properties.domain+'/assets/common-assets/vocabulary/sdg.json').subscribe(data => {
|
||||
this.vocabulariesService.getSDGs(properties).subscribe(data => {
|
||||
data['sdg'].forEach(element => {
|
||||
// this.sdgs.push({code: element.code, id: element.id, label: element.label, html: element.html, checked: this.subjects?.includes(element.id)});
|
||||
this.sdgs.push(this.fb.group({
|
||||
|
|
|
@ -11,6 +11,7 @@ import {Router} from '@angular/router';
|
|||
import {Meta, Title} from "@angular/platform-browser";
|
||||
import {SEOService} from "../sharedComponents/SEO/SEO.service";
|
||||
import {PiwikService} from "../utils/piwik/piwik.service";
|
||||
import {ISVocabulariesService} from "../utils/staticAutoComplete/ISVocabularies.service";
|
||||
|
||||
@Component({
|
||||
selector: 'sdg',
|
||||
|
@ -36,7 +37,7 @@ export class SdgComponent implements OnInit, OnDestroy {
|
|||
subscriptions: Subscription[] = [];
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient, private refineFieldResultsService: RefineFieldResultsService,
|
||||
private vocabulariesService: ISVocabulariesService, private refineFieldResultsService: RefineFieldResultsService,
|
||||
private _router: Router,
|
||||
private _meta: Meta,
|
||||
private _title: Title,
|
||||
|
@ -54,7 +55,7 @@ export class SdgComponent implements OnInit, OnDestroy {
|
|||
this.updateUrl(this.url);
|
||||
this.updateTitle(this.pageTitle);
|
||||
this.updateDescription(this.pageDescription);
|
||||
this.httpClient.get(properties.domain+'/assets/common-assets/vocabulary/sdg.json').subscribe(data => {
|
||||
this.vocabulariesService.getSDGs(properties).subscribe(data => {
|
||||
this.sdgs = data['sdg'];
|
||||
});
|
||||
let refineParams = null;
|
||||
|
|
|
@ -107,22 +107,29 @@ export class ISVocabulariesService {
|
|||
|
||||
getLocalVocabularyFromService(vocabularyName: string, properties: EnvProperties): Observable<AutoCompleteValue[]> {
|
||||
if(vocabularyName == "sdg"){
|
||||
let url = properties.domain+"/assets/common-assets/vocabulary/sdg.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
return this.getSDGs(properties)
|
||||
.pipe(map(res => res['sdg']))
|
||||
.pipe(map(res => this.parseSDGs(res)))
|
||||
.pipe(catchError(this.handleError));
|
||||
}else if( vocabularyName == "fos"){
|
||||
let url = properties.domain+"/assets/common-assets/vocabulary/fos.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
return this.getFos(properties)
|
||||
.pipe(map(res => res['fos']))
|
||||
.pipe(map(res => this.parseFOS(res)))
|
||||
.pipe(catchError(this.handleError));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getFos(properties: EnvProperties): Observable<any> {
|
||||
let url = "/assets/common-assets/vocabulary/fos.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
}
|
||||
|
||||
getSDGs(properties: EnvProperties): Observable<any> {
|
||||
let url = "/assets/common-assets/vocabulary/sdg.json";
|
||||
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
}
|
||||
|
||||
parseSDGs(data: any): AutoCompleteValue[] {
|
||||
var array: AutoCompleteValue[] = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
|
@ -160,6 +167,7 @@ export class ISVocabulariesService {
|
|||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
parse(data: any, vocabularyName: string): AutoCompleteValue[] {
|
||||
var array: AutoCompleteValue[] = []
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
|
|
|
@ -261,9 +261,9 @@ export class Identifier {
|
|||
|
||||
export class StringUtils {
|
||||
|
||||
public static urlRegex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
|
||||
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' +
|
||||
'[a-zA-Z0-9]+\.[^\s]{2,}';
|
||||
public static urlRegex = 'https?:\\/\\/(?:www(2?)\\.|(?!www(2?)))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www(2?)\\.' +
|
||||
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?:\\/\\/(?:www(2?)\\.|(?!www(2?)))[a-zA-Z0-9]+\\.[^\\s]{2,}|www(2?)\\.' +
|
||||
'[a-zA-Z0-9]+\\.[^\\s]{2,}';
|
||||
|
||||
public static routeRegex = '^[a-zA-Z0-9\/][a-zA-Z0-9\/-]*$';
|
||||
|
||||
|
|
Loading…
Reference in New Issue