diff --git a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts index 99420a2..72a1392 100644 --- a/src/app/general/edit-stakeholder/edit-stakeholder.component.ts +++ b/src/app/general/edit-stakeholder/edit-stakeholder.component.ts @@ -10,6 +10,7 @@ import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeho import {UtilitiesService} from "../../openaireLibrary/services/utilities.service"; import {Session, User} from "../../openaireLibrary/login/utils/helper.class"; import {UserManagementService} from "../../openaireLibrary/services/user-management.service"; +import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; declare var UIkit; @@ -73,6 +74,15 @@ declare var UIkit; +
+
+
+ Note: Prefer urls like "https://example.com/my-secure-image.png" instead + of "http://example.com/my-image.png". + Browsers may not load non secure content. +
+
+
{{uploadError}}
alias !== this.stakeholder.alias) + this.alias.filter(alias => alias !== this.stakeholder.alias) )] ), isDefault: this.fb.control((this.isDefault)), @@ -163,7 +173,7 @@ export class EditStakeholderComponent implements OnDestroy { type: this.fb.control(this.stakeholder.type, Validators.required), topics: this.fb.control(this.stakeholder.topics), isUpload: this.fb.control(this.stakeholder.isUpload), - logoUrl: this.fb.control(this.stakeholder.logoUrl), + logoUrl: this.fb.control(this.stakeholder.logoUrl, StringUtils.urlValidator()), }); this.initPhoto(); if (!isDefault) { diff --git a/src/app/monitor/monitor.component.html b/src/app/monitor/monitor.component.html index 16bf9a1..09c5384 100644 --- a/src/app/monitor/monitor.component.html +++ b/src/app/monitor/monitor.component.html @@ -137,8 +137,9 @@ out of {{countSelectedFilters()}}
{{indicator.name}}
-

- {{numberResults.get(i + '-' + j) | number}} +

+ {{numberResults.get(i + '-' + j) | number}} + --

diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts index 0c71936..24bcc45 100644 --- a/src/app/monitor/monitor.component.ts +++ b/src/app/monitor/monitor.component.ts @@ -435,6 +435,14 @@ export class MonitorComponent implements OnInit, OnDestroy { result = result[jsonPath]; } }); + if (typeof result === 'string' || typeof result === 'number') { + result = Number(result); + if (result === Number.NaN) { + result = 0; + } + } else { + result = 0; + } this.numberResults.set(i + '-' + j, result); }); })); diff --git a/src/app/topic/indicators.component.html b/src/app/topic/indicators.component.html index d1eea25..f015c5f 100644 --- a/src/app/topic/indicators.component.html +++ b/src/app/topic/indicators.component.html @@ -76,8 +76,9 @@
{{indicator.name ? indicator.name : 'No title available'}}
-

- {{numberResults.get(i + '-' + j) | number}} +

+ {{numberResults.get(i + '-' + j) | number}} + --

@@ -270,12 +271,10 @@
-
+
JSON Path
-
+
This JSON path is not valid or the result has not been calculated yet. Please press calculate on box below to see the result. @@ -286,11 +285,13 @@
@@ -310,15 +311,20 @@
- - {{numberIndicatorPaths.at(i).get('result').value | number}} + + + {{numberIndicatorPaths.at(i).get('result').value | number}} + + + -- +
+ [class.uk-disabled]="numberIndicatorPaths.at(i).get('url').invalid" + (click)="validateJsonPath(i, true)">
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts index 75e0ece..322dd87 100644 --- a/src/app/topic/indicators.component.ts +++ b/src/app/topic/indicators.component.ts @@ -30,6 +30,7 @@ import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sideb import {Router} from "@angular/router"; import {Session} from "../openaireLibrary/login/utils/helper.class"; import {UserManagementService} from "../openaireLibrary/services/user-management.service"; +import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; declare var UIkit; @@ -172,6 +173,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV result = result[jsonPath]; } }); + if (typeof result === 'string' || typeof result === 'number') { + result = Number(result); + if (result === Number.NaN) { + result = 0; + } + } else { + result = 0; + } this.numberResults.set(i + '-' + j, result); }); })); @@ -431,7 +440,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV public addJsonPath(index: number) { if (index == 0 && this.getJsonPath(index).getRawValue()[index].indexOf(",") != -1) { - //if in the first path there are more than one paaths comma separated, split them and autogenerate the forms + //if in the first path there are more than one paths comma separated, split them and autogenerate the forms let paths = this.getJsonPath(index).getRawValue()[index].split(","); for (let i = 0; i < paths.length; i++) { if (i != 0) { @@ -439,19 +448,18 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV } } this.getJsonPath(index).setValue(paths) - return; + } else { + this.getJsonPath(index).push(this.fb.control('', Validators.required)); } - this.getJsonPath(index).push(this.fb.control('', Validators.required)); } public removeJsonPath(i: number, j: number) { - this.getJsonPath(i).removeAt(j); - if (this.getJsonPath(i).length !== this.getCurrentJsonPath(i).length) { - this.getJsonPath(i).markAsDirty(); + if(this.getJsonPath(i).enabled) { + this.getJsonPath(i).removeAt(j); } } - public validateJsonPath(index: number) { + public validateJsonPath(index: number, dirty: boolean = false) { let indicatorPath: FormGroup = this.numberIndicatorPaths.at(index); if (this.indicator.defaultId === null) { this.getJsonPath(index).disable(); @@ -467,20 +475,33 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV setTimeout(() => { if (this.indicator.defaultId === null) { this.getJsonPath(index).enable(); + if(dirty) { + this.getJsonPath(index).markAsDirty(); + } } indicatorPath.get('result').setErrors(null); - console.debug(result); if (typeof result === 'string' || typeof result === 'number') { result = Number(result); if (result !== Number.NaN) { indicatorPath.get('result').setValue(result); } else { - indicatorPath.get('result').setValue(null); + indicatorPath.get('result').setValue(0); } } else { - indicatorPath.get('result').setValue(null); + indicatorPath.get('result').setValue(0); } }, 500); + }, error => { + setTimeout(() => { + if (this.indicator.defaultId === null) { + this.getJsonPath(index).enable(); + if (dirty) { + this.getJsonPath(index).markAsDirty(); + } + } + indicatorPath.get('result').setErrors(null); + indicatorPath.get('result').setValue(0); + }, 500); })); } @@ -514,7 +535,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV jsonPath.push(this.fb.control('', Validators.required)); } this.numberIndicatorPaths.push(this.fb.group({ - url: this.fb.control(url, Validators.required), + url: this.fb.control(url, [Validators.required, StringUtils.urlValidator()]), jsonPath: jsonPath, result: this.fb.control(0, Validators.required), // parameters: parameters, @@ -587,10 +608,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV public addChartIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), disableUrl: boolean = false, type: string = null) { this.chartIndicatorPaths.push(this.fb.group({ - url: this.fb.control(value, [Validators.required, - Validators.pattern('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,}')]), + url: this.fb.control(value, [Validators.required, StringUtils.urlValidator()]), parameters: parameters, type: this.fb.control(type) } diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html index e663e2d..30d166b 100644 --- a/src/app/topic/topic.component.html +++ b/src/app/topic/topic.component.html @@ -57,7 +57,7 @@ - Create new topic + Create new topic @@ -141,7 +141,7 @@ - Create new category + Create new category @@ -194,7 +194,7 @@ - Create new subcategory + Create new subcategory diff --git a/src/assets/dashboard-theme/input.css b/src/assets/dashboard-theme/input.css index 1f86274..0e94bbd 100644 --- a/src/assets/dashboard-theme/input.css +++ b/src/assets/dashboard-theme/input.css @@ -10,7 +10,7 @@ } .input-box { - background-color: #FAFAFA; + background-color: #FAFAFA !important; border: 1px solid transparent; padding: 16px; border-radius: 4px; diff --git a/src/assets/new.css b/src/assets/new.css index 8379d88..df04c13 100644 --- a/src/assets/new.css +++ b/src/assets/new.css @@ -10,7 +10,6 @@ --primary-color-rgb: var(--theme-secondary-color-rgb); --secondary-color-rgb: var(--theme-secondary-color-rgb); } - /*Stakeholder Specific*/ .publicationsSearchForm { background-image: none; @@ -145,9 +144,10 @@ max-width: 50px; background: var(--secondary-color); color: var(--contrast-color); - -webkit-clip-path: polygon(15% 5%, 100% 5%, 100% 100%, 0% 100%); + -webkit-clip-path: polygon(20% 5%, 80% 5%, 100% 100%, 0% 100%); clip-path: polygon(20% 5%, 80% 5%, 100% 100%, 0% 100%); display: none; + padding-left: 10px; } .dashboard .section {