2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, ViewChild} from '@angular/core';
|
|
|
|
import { ActivatedRoute} from '@angular/router';
|
|
|
|
import {Location} from '@angular/common';
|
|
|
|
|
|
|
|
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
|
|
|
|
|
|
|
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
2018-02-15 11:36:12 +01:00
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
|
|
|
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
|
|
|
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'browse-statistic',
|
|
|
|
templateUrl: 'browseStatistic.component.html'
|
|
|
|
|
|
|
|
})
|
|
|
|
export class BrowseStatisticComponent {
|
|
|
|
|
|
|
|
@Input() public baseUrl:string = "";
|
|
|
|
@Input() public filter:any = "";
|
|
|
|
private _maxCharacters = 30;
|
|
|
|
public viewAll = false;
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
2018-09-26 15:56:21 +02:00
|
|
|
keyword = "";
|
|
|
|
sortBy = "num";
|
2017-12-19 13:53:46 +01:00
|
|
|
constructor () {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnInit() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
quote(str:string){
|
|
|
|
return '"'+str+'"';
|
|
|
|
}
|
|
|
|
|
2019-07-22 16:15:23 +02:00
|
|
|
public _formatName(value){
|
|
|
|
let maxLineLength = 29;
|
|
|
|
//3 space before number + parenthesis
|
|
|
|
if(value.name.length+value.number.toLocaleString().length +3> maxLineLength){
|
|
|
|
return value.name.substr(0, (maxLineLength - 3 -3 - value.number.toLocaleString().length))+'...';
|
|
|
|
}
|
|
|
|
|
|
|
|
return value.name;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-09-26 15:56:21 +02:00
|
|
|
filterKeywords(value){
|
|
|
|
if(this.keyword.length > 0){
|
|
|
|
if(value.toLowerCase().indexOf(this.keyword.toLowerCase()) ==-1){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
getValues(filter, sortBy:string = "num"):any{
|
|
|
|
|
|
|
|
if(sortBy == "name"){
|
|
|
|
var array = filter.values.slice();
|
|
|
|
array.sort((n1,n2)=> {
|
|
|
|
if (n1.name > n2.name) {
|
|
|
|
return 1;
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-09-26 15:56:21 +02:00
|
|
|
if (n1.name < n2.name) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
return array;
|
|
|
|
}else{
|
|
|
|
return filter.values;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|