1
|
import {Component, Input, ViewChild} from '@angular/core';
|
2
|
import { ActivatedRoute} from '@angular/router';
|
3
|
import {Location} from '@angular/common';
|
4
|
|
5
|
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
|
6
|
|
7
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
8
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
9
|
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
10
|
import {SearchPageComponent } from '../searchUtils/searchPage.component';
|
11
|
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
|
12
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
13
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
14
|
|
15
|
@Component({
|
16
|
selector: 'browse-statistic',
|
17
|
templateUrl: 'browseStatistic.component.html'
|
18
|
|
19
|
})
|
20
|
export class BrowseStatisticComponent {
|
21
|
|
22
|
@Input() public baseUrl:string = "";
|
23
|
@Input() public filter:any = "";
|
24
|
private _maxCharacters = 30;
|
25
|
public viewAll = false;
|
26
|
public routerHelper:RouterHelper = new RouterHelper();
|
27
|
keyword = "";
|
28
|
sortBy = "num";
|
29
|
constructor () {
|
30
|
|
31
|
}
|
32
|
|
33
|
public ngOnInit() {
|
34
|
|
35
|
|
36
|
}
|
37
|
|
38
|
quote(str:string){
|
39
|
return '"'+str+'"';
|
40
|
}
|
41
|
|
42
|
public _formatName(value){
|
43
|
let maxLineLength = 29;
|
44
|
//3 space before number + parenthesis
|
45
|
if(value.name.length+value.number.toLocaleString().length +3> maxLineLength){
|
46
|
return value.name.substr(0, (maxLineLength - 3 -3 - value.number.toLocaleString().length))+'...';
|
47
|
}
|
48
|
|
49
|
return value.name;
|
50
|
}
|
51
|
filterKeywords(value){
|
52
|
if(this.keyword.length > 0){
|
53
|
if(value.toLowerCase().indexOf(this.keyword.toLowerCase()) ==-1){
|
54
|
return false;
|
55
|
}
|
56
|
}
|
57
|
return true;
|
58
|
}
|
59
|
|
60
|
getValues(filter, sortBy:string = "num"):any{
|
61
|
|
62
|
if(sortBy == "name"){
|
63
|
var array = filter.values.slice();
|
64
|
array.sort((n1,n2)=> {
|
65
|
if (n1.name > n2.name) {
|
66
|
return 1;
|
67
|
}
|
68
|
|
69
|
if (n1.name < n2.name) {
|
70
|
return -1;
|
71
|
}
|
72
|
|
73
|
return 0;
|
74
|
});
|
75
|
return array;
|
76
|
}else{
|
77
|
return filter.values;
|
78
|
}
|
79
|
|
80
|
|
81
|
}
|
82
|
}
|