2024-03-15 19:19:31 +01:00
import { Component , SimpleChanges } from '@angular/core' ;
2024-02-28 12:07:31 +01:00
import { PluginBaseComponent , PluginBaseInfo } from "../../utils/base-plugin.component" ;
2024-02-22 10:09:20 +01:00
import { FetchResearchResults } from "../../../../utils/fetchEntitiesClasses/fetchResearchResults.class" ;
import { SearchResearchResultsService } from "../../../../services/searchResearchResults.service" ;
2024-03-15 19:19:31 +01:00
import { properties } from "../../../../../../environments/environment" ;
import { ResultPreview } from "../../../../utils/result-preview/result-preview" ;
2024-02-22 10:09:20 +01:00
2024-02-28 12:07:31 +01:00
export class PluginFeaturedDatasets extends PluginBaseInfo {
2024-02-22 10:09:20 +01:00
title : string = "Featured datasets" ;
textLine1 : string = "Here are listed some of the most important energy datasets as selected by energy experts." ;
textLine2 : string = "Check them if you want to easily explore and visualize the European energy landscape, using only well-known datasets which you can trust." ;
}
2024-01-31 10:05:46 +01:00
@Component ( {
selector : 'plugin-featured-datasets' ,
templateUrl : 'plugin-featured-datasets.component.html'
} )
2024-02-22 10:09:20 +01:00
export class PluginFeaturedDatasetsComponent extends PluginBaseComponent < PluginFeaturedDatasets > {
default = new PluginFeaturedDatasets ( ) ;
2024-03-15 19:19:31 +01:00
// public fetchFeaturedDatasets: FetchResearchResults;
2024-02-22 10:09:20 +01:00
page = 1 ;
size = 3 ;
2024-03-06 14:26:14 +01:00
slides = 1 ;
slideItems = 3 ;
2024-03-15 19:19:31 +01:00
totalNum = null ;
results : ResultPreview [ ] = null ;
2024-02-22 10:09:20 +01:00
constructor ( private _searchResearchResultsService : SearchResearchResultsService ) {
2024-01-31 10:05:46 +01:00
super ( )
2024-03-15 19:19:31 +01:00
// this.fetchFeaturedDatasets = new FetchResearchResults(this._searchResearchResultsService);
// this.fetchFeaturedDatasets.searchUtils.size = this.size;
// this.fetchFeaturedDatasets.getAllResultsForCommunity("dataset", "enermaps", 1, 50, this.properties, "enermaps::selection");
this . subscriptions . push ( this . _searchResearchResultsService . advancedSearchResults ( "dataset" , null , 1 , 50 , null , properties , "&type=results&fq=communityid=enermaps&fq=categoryid=" + encodeURIComponent ( "enermaps::selection" ) ) . subscribe (
data = > {
console . log ( data ) ;
this . totalNum = data [ 0 ] ;
this . results = data [ 1 ] . map ( res = > {
let resultPreview = ResultPreview . searchResultConvert ( res , 'dataset' )
resultPreview . hostedBy_collectedFrom = null ;
resultPreview . measure = null ;
return resultPreview
} ) ;
console . log ( this . totalNum = data [ 0 ] , this . results ) ;
if ( this . results && this . results . length > 0 ) {
this . calculatePages ( ) ;
}
} ,
err = > {
2024-02-22 10:09:20 +01:00
2024-03-15 19:19:31 +01:00
}
) ) ;
}
/ * n g O n C h a n g e s ( c h a n g e s : S i m p l e C h a n g e s ) {
if ( this . results ) {
this . calculatePages ( ) ;
}
} * /
calculatePages ( ) {
this . slides = 1 ;
if ( this . results . length > this . slideItems ) {
this . slides = parseInt ( '' + ( this . results . length / this . slideItems ) ) ;
if ( this . slides < ( this . results . length / this . slideItems ) ) {
this . slides ++ ;
}
}
}
2024-03-06 14:26:14 +01:00
2024-01-31 10:05:46 +01:00
}