[Monitor Dashboard | Trunk]: Add alias error. Fix number indicator form validation
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59775 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
5f6c0884b5
commit
f6319eac64
|
@ -20,7 +20,7 @@ declare var UIkit;
|
||||||
[class.uk-padding-small]="!paddingLarge" [class.uk-padding-large]="paddingLarge"
|
[class.uk-padding-small]="!paddingLarge" [class.uk-padding-large]="paddingLarge"
|
||||||
class="uk-overflow-auto"
|
class="uk-overflow-auto"
|
||||||
[formGroup]="stakeholderFb">
|
[formGroup]="stakeholderFb">
|
||||||
<div class="uk-flex uk-flex-bottom" uk-grid>
|
<div class="uk-grid" uk-grid uk-height-match=".uk-form-hint">
|
||||||
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('name')" label="Name"
|
<div dashboard-input class="uk-width-1-2@m" [formInput]="stakeholderFb.get('name')" label="Name"
|
||||||
placeholder="Write a name..."
|
placeholder="Write a name..."
|
||||||
hint="Set a name for your profile."></div>
|
hint="Set a name for your profile."></div>
|
||||||
|
|
|
@ -295,13 +295,22 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="uk-flex uk-flex-middle">
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-secondary uk-button-small uk-flex uk-flex-middle uk-margin-medium-top"
|
class="uk-icon-button uk-button-secondary uk-margin-medium-top"
|
||||||
(click)="addJsonPath(i)">
|
(click)="addJsonPath(i)">
|
||||||
<icon name="add" [flex]="true"></icon>
|
<icon name="add"></icon>
|
||||||
<span class="space">Add level</span>
|
|
||||||
</button>
|
</button>
|
||||||
|
<!--<span *ngIf="getJsonPath(i).invalid" class="uk-margin-small-left uk-margin-medium-top">
|
||||||
|
<button *ngIf="getJsonPath(i).errors.invalid" class="uk-icon-button uk-button-primary"
|
||||||
|
(click)="validateJsonPath(i)">
|
||||||
|
<icon name="done"></icon>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<span *ngIf="getJsonPath(i).disabled" class="uk-text-primary uk-margin-small-left uk-margin-medium-top">Validating...</span>
|
||||||
|
<span *ngIf="getJsonPath(i).valid" class="uk-text-success uk-margin-small-left uk-margin-medium-top">
|
||||||
|
<icon name="done"></icon>
|
||||||
|
</span>-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -96,6 +96,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
public indicatorChildrenActionOnDelete: string;
|
public indicatorChildrenActionOnDelete: string;
|
||||||
|
|
||||||
urlParameterizedMessage = "";
|
urlParameterizedMessage = "";
|
||||||
|
|
||||||
constructor(private layoutService: LayoutService,
|
constructor(private layoutService: LayoutService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private statisticsService: StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
|
@ -330,7 +331,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private filterStatus(sections: Section[], value): Section[] {
|
private filterStatus(sections: Section[], value): Section[] {
|
||||||
if (value !== 'all') {
|
if (value !== 'all') {
|
||||||
sections.forEach(section =>
|
sections.forEach(section =>
|
||||||
|
@ -420,13 +420,41 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
|
|
||||||
public removeJsonPath(i: number, j: number) {
|
public removeJsonPath(i: number, j: number) {
|
||||||
this.getJsonPath(i).removeAt(j);
|
this.getJsonPath(i).removeAt(j);
|
||||||
|
if (this.getJsonPath(i).length !== this.getCurrentJsonPath(i).length) {
|
||||||
this.getJsonPath(i).markAsDirty();
|
this.getJsonPath(i).markAsDirty();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public validateJsonPath(index: number) {
|
||||||
|
let indicatorPath: FormGroup = <FormGroup>this.numberIndicatorPaths.at(index);
|
||||||
|
this.getJsonPath(index).disable();
|
||||||
|
this.statisticsService.getNumbers(null, indicatorPath.get('url').value).subscribe(response => {
|
||||||
|
let result = JSON.parse(JSON.stringify(response));
|
||||||
|
this.getJsonPath(index).controls.forEach(jsonPath => {
|
||||||
|
if (result) {
|
||||||
|
result = result[jsonPath.value];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTimeout( () => {
|
||||||
|
if (typeof result == 'string') {
|
||||||
|
this.getJsonPath(index).enable();
|
||||||
|
this.getJsonPath(index).setErrors(null);
|
||||||
|
} else {
|
||||||
|
this.getJsonPath(index).enable();
|
||||||
|
this.getJsonPath(index).setErrors({invalid: true});
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public getJsonPath(index: number): FormArray {
|
public getJsonPath(index: number): FormArray {
|
||||||
return this.numberIndicatorPaths.at(index).get('jsonPath') as FormArray;
|
return this.numberIndicatorPaths.at(index).get('jsonPath') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getCurrentJsonPath(index: number): string[] {
|
||||||
|
return this.section.indicators[this.index].indicatorPaths[index].jsonPath;
|
||||||
|
}
|
||||||
|
|
||||||
public getParameters(index: number): FormArray {
|
public getParameters(index: number): FormArray {
|
||||||
return this.chartIndicatorPaths.at(index).get('parameters') as FormArray;
|
return this.chartIndicatorPaths.at(index).get('parameters') as FormArray;
|
||||||
}
|
}
|
||||||
|
@ -474,31 +502,19 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
/* if(value != indicatorPath.url) {
|
/* if(value != indicatorPath.url) {
|
||||||
(this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url);
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url);
|
||||||
}*/
|
}*/
|
||||||
if (!this.indicator.indicatorPaths[index]) {
|
|
||||||
this.indicator.indicatorPaths[index] = indicatorPath;
|
this.indicator.indicatorPaths[index] = indicatorPath;
|
||||||
} else {
|
|
||||||
this.indicator.indicatorPaths[index] = indicatorPath;
|
|
||||||
}
|
|
||||||
(this.numberIndicatorPaths.at(index) as FormGroup).get('source').setValue(indicatorPath.source);
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('source').setValue(indicatorPath.source);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('jsonPath').valueChanges.subscribe(value => {
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('jsonPath').valueChanges.subscribe(value => {
|
||||||
if (!this.indicator.indicatorPaths[index]) {
|
|
||||||
this.indicator.indicatorPaths[index].jsonPath = value;
|
this.indicator.indicatorPaths[index].jsonPath = value;
|
||||||
} else {
|
//this.getJsonPath(index).setErrors({invalid: true});
|
||||||
this.indicator.indicatorPaths[index].jsonPath = value;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('source').valueChanges.subscribe(value => {
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('source').valueChanges.subscribe(value => {
|
||||||
if (!this.indicator.indicatorPaths[index]) {
|
|
||||||
this.indicator.indicatorPaths[index].source = value;
|
this.indicator.indicatorPaths[index].source = value;
|
||||||
} else {
|
|
||||||
this.indicator.indicatorPaths[index].source = value;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -692,8 +708,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.numberIndicatorFb.value, this.indicator.indicatorPaths, this.indicator.type, false);
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.numberIndicatorFb.value, this.indicator.indicatorPaths, this.indicator.type, false);
|
||||||
this.section = this.numbers.find(section => section._id === this.section._id);
|
this.section = this.numbers.find(section => section._id === this.section._id);
|
||||||
}
|
}
|
||||||
console.debug("Indicator to svae");
|
|
||||||
console.debug(this.indicator);
|
|
||||||
let path = [
|
let path = [
|
||||||
this.stakeholder._id,
|
this.stakeholder._id,
|
||||||
this.stakeholder.topics[this.topicIndex]._id,
|
this.stakeholder.topics[this.topicIndex]._id,
|
||||||
|
|
|
@ -24,15 +24,16 @@ import {
|
||||||
group,
|
group,
|
||||||
refresh,
|
refresh,
|
||||||
close,
|
close,
|
||||||
arrow_right
|
arrow_right, done
|
||||||
} from "../openaireLibrary/utils/icons/icons";
|
} from "../openaireLibrary/utils/icons/icons";
|
||||||
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
|
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
|
||||||
import {PageContentModule} from "../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
|
import {PageContentModule} from "../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
|
||||||
|
import {LoadingModule} from "../openaireLibrary/utils/loading/loading.module";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, TopicRoutingModule, ClickModule, RouterModule, FormsModule, AlertModalModule,
|
CommonModule, TopicRoutingModule, ClickModule, RouterModule, FormsModule, AlertModalModule,
|
||||||
ReactiveFormsModule, InputModule, IconsModule, PageContentModule
|
ReactiveFormsModule, InputModule, IconsModule, PageContentModule, LoadingModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
TopicComponent, IndicatorsComponent
|
TopicComponent, IndicatorsComponent
|
||||||
|
@ -47,6 +48,6 @@ import {PageContentModule} from "../openaireLibrary/dashboard/sharedComponents/p
|
||||||
})
|
})
|
||||||
export class TopicModule {
|
export class TopicModule {
|
||||||
constructor(private iconsService: IconsService) {
|
constructor(private iconsService: IconsService) {
|
||||||
this.iconsService.registerIcons([preview, bullet, add, earth, lock, group, refresh, close, arrow_right]);
|
this.iconsService.registerIcons([preview, bullet, add, earth, lock, group, refresh, close, arrow_right, done]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,11 @@ export class StakeholderUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasValidator(elements: any[]): ValidatorFn {
|
aliasValidator(elements: any[]): ValidatorFn {
|
||||||
return (control: AbstractControl): { [key: string]: boolean } | null => {
|
return (control: AbstractControl): { [key: string]: string } | null => {
|
||||||
if (control.value && elements.find(element =>
|
if (control.value && elements.find(element =>
|
||||||
element.alias === control.value
|
element.alias === control.value
|
||||||
)) {
|
)) {
|
||||||
return {'alias': true};
|
return {'error': 'Alias already in use'};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {HttpClient} from "@angular/common/http";
|
||||||
import {EnvironmentSpecificService} from "../../openaireLibrary/utils/properties/environment-specific.service";
|
import {EnvironmentSpecificService} from "../../openaireLibrary/utils/properties/environment-specific.service";
|
||||||
import {Observable} from "rxjs";
|
import {Observable} from "rxjs";
|
||||||
import {SourceType} from "../../openaireLibrary/monitor/entities/stakeholder";
|
import {SourceType} from "../../openaireLibrary/monitor/entities/stakeholder";
|
||||||
|
import {el} from "@angular/platform-browser/testing/src/browser_util";
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
|
@ -35,8 +36,13 @@ export class StatisticsService {
|
||||||
});
|
});
|
||||||
return sourceType;
|
return sourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
getNumbers(source: SourceType, url: string): Observable<any> {
|
getNumbers(source: SourceType, url: string): Observable<any> {
|
||||||
|
if(source !== null) {
|
||||||
return this.http.get<any>(this.numberSources.get(source)[0] + url);
|
return this.http.get<any>(this.numberSources.get(source)[0] + url);
|
||||||
|
} else {
|
||||||
|
return this.http.get<any>(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getChartUrl(source: SourceType, url: string): string {
|
getChartUrl(source: SourceType, url: string): string {
|
||||||
|
|
Loading…
Reference in New Issue