diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 10d1fb1..e32d736 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -249,7 +249,7 @@ export class AppComponent implements OnInit, OnDestroy {
}
if(this.isPublicOrIsMember(this.stakeholder.visibility)) {
- this.specialSideBarMenuItem = new MenuItem("search", "Search research outcomes", "", this.properties.searchLinkToResults, false, [], null, {})
+ this.specialSideBarMenuItem = new MenuItem("search", "Search research outcomes", "", this.properties.searchLinkToResults, false, [], null, this.createSearchParameters());
this.specialSideBarMenuItem.icon = '';
}else{
this.specialSideBarMenuItem =null;
diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts
index 84f0dcb..f5d2b31 100644
--- a/src/app/monitor/monitor.component.ts
+++ b/src/app/monitor/monitor.component.ts
@@ -155,7 +155,6 @@ export class MonitorComponent implements OnInit, OnDestroy {
});
this.subscriptions.push(subscription);
} else {
- console.debug(" stakeholder is already available")
this.initializeFilters();
this.setView(params);
}
diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html
index bdf60e1..c85ea3c 100644
--- a/src/app/topic/indicators.component.html
+++ b/src/app/topic/indicators.component.html
@@ -2,11 +2,11 @@
Number Indicators
-
Chart Indicators
@@ -243,7 +241,7 @@
[formInput]="numberIndicatorFb.get('description')"
label="Description" type="textarea">
-
@@ -267,7 +265,8 @@
+ type="select"
+ [options]="isAdministrator?indicatorUtils.allSourceTypes:indicatorUtils.sourceTypes">
@@ -345,7 +344,7 @@
[formInput]="chartIndicatorFb.get('description')"
label="Description" type="textarea">
-
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts
index b2bd247..5393e0b 100644
--- a/src/app/topic/indicators.component.ts
+++ b/src/app/topic/indicators.component.ts
@@ -488,7 +488,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
return this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath));
}
- public addNumberIndicatorPath(url: string = '', parameters: FormArray = new FormArray([]), source: string = 'search', jsonPath: FormArray = new FormArray([])) {
+ public addNumberIndicatorPath(url: string = '', parameters: FormArray = new FormArray([]), source: string = 'stats-tool', jsonPath: FormArray = new FormArray([])) {
if (jsonPath.length === 0) {
jsonPath.push(this.fb.control('', Validators.required));
}
@@ -508,7 +508,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
this.numberIndicatorPaths.at(index).get('result').setValue(null);
if (this.numberIndicatorPaths.at(index).get('url').valid) {
- let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(value), value, this.stakeholder, this.numberIndicatorPaths.at(index).get('jsonPath').value);
+ let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(value), value, this.stakeholder, this.numberIndicatorPaths.at(index).get('jsonPath').value, this.statisticsService.numberSources.get(this.statisticsService.getNumberSource(value)));
if ((indicatorPath.chartObject && Object.keys(indicatorPath.parameters).indexOf("index_id") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_name") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_shortName") == -1)
|| (!indicatorPath.chartObject && indicatorPath.url.indexOf("index_id") == -1 && indicatorPath.url.indexOf("index_name") == -1 && (indicatorPath.url).indexOf("index_shortName") == -1)) {
// default profile
@@ -528,6 +528,15 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if (indicatorPath.source) {
this.numberIndicatorPaths.at(index).get('source').setValue(indicatorPath.source);
}
+ if(indicatorPath.jsonPath.length > 1 && this.getJsonPath(index).length ==1 ) {
+ let paths = indicatorPath.jsonPath;
+ for (let i = 0; i < paths.length; i++) {
+ if (i == this.getJsonPath(index).length) {
+ this.getJsonPath(index).push(this.fb.control('', Validators.required));
+ }
+ }
+ this.getJsonPath(index).setValue(paths)
+ }
} else {
this.urlParameterizedMessage = null;
}
@@ -830,9 +839,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
public get isAdministrator(): boolean {
- return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user);
+ return Session.isPortalAdministrator(this.user);
+ }
+ public get isCurator(): boolean {
+ return this.isAdministrator || Session.isMonitorCurator(this.user);
}
-
refreshIndicator() {
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.chartIndicatorFb.value, this.indicator.indicatorPaths, 'chart', true);
this.indicator.indicatorPaths.forEach(indicatorPath => {
diff --git a/src/app/utils/indicator-utils.ts b/src/app/utils/indicator-utils.ts
index b0be113..b76b271 100644
--- a/src/app/utils/indicator-utils.ts
+++ b/src/app/utils/indicator-utils.ts
@@ -176,13 +176,15 @@ export class IndicatorUtils {
{value: 'large', label: 'Large'}
];
- sourceTypes: Option[] = [
+ allSourceTypes: Option[] = [
{value: 'search', label: 'Search'},
{value: 'statistics', label: 'Statistics'},
{value: 'metrics', label: 'Metrics'},
{value: 'stats-tool', label: 'Statistics tool'}
];
-
+ sourceTypes: Option[] = [
+ {value: 'stats-tool', label: 'Statistics tool'}
+ ];
isPublic: Option[] = [
{icon: 'public', value: true, label: 'Public'},
{icon: 'lock', value: false, label: 'Private'},
@@ -296,15 +298,15 @@ export class IndicatorUtils {
}
}
- //For numbers
+ //For numbers (e.g from stats-api , search service, etc)
if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) !=- 1){
- indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
+ replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
}
if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_name' + ChartHelper.suffix) !=- 1){
- indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_name' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_name))
+ replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_name' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_name))
}
if(indicatorPath.url.indexOf(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix) !=- 1){
- indicatorPath.url = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
+ replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
}
return (indicatorPath.chartObject?indicatorPath.url + encodeURIComponent(replacedUrl):replacedUrl);
}
@@ -427,7 +429,6 @@ export class IndicatorUtils {
// console.debug("Field Params length:" + paramFields.length)
// console.debug(paramFields)
// console.debug("Parameters length:" + queries["query"]["parameters"].length)
- console.debug("Parameters length:" + queries["query"]["parameters"].length)
if((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length*2 + 4) == queries["query"]["parameters"].length){
filterApplied = true;
@@ -531,7 +532,7 @@ export class IndicatorUtils {
});
return indicator;
}
- generateIndicatorByNumberUrl(source: SourceType, url: string, stakeholder:Stakeholder, jsonPath = []): IndicatorPath {
+ generateIndicatorByNumberUrl(source: SourceType, url: string, stakeholder:Stakeholder, jsonPath = [], sourceServices:string[] =[] ): IndicatorPath {
let indicatorPath = new IndicatorPath(null, source, url, null, jsonPath);
if (source === 'stats-tool') {
indicatorPath.url = url.split("json=")[0] + "json=";
@@ -541,8 +542,14 @@ export class IndicatorUtils {
this.parameterizeDefaultQuery(chart, indicatorPath, stakeholder);
this.extractStakeHolders(chart, indicatorPath, stakeholder);
indicatorPath.chartObject = JSON.stringify(chart);
+ indicatorPath.jsonPath = ["data","0","0","0"];
// this.addResultFilters(chart, indicatorPath);
}else {
+ for( let service of sourceServices){
+ if(url.indexOf(service)!=-1){
+ url = url.split(service)[1] ;
+ }
+ }
try {
if (url.indexOf(encodeURIComponent(stakeholder.index_id)) !== -1) {
url = url.split(encodeURIComponent(stakeholder.index_id)).join(ChartHelper.prefix + "index_id" + ChartHelper.suffix);