[Monitor Dashboard | Trunk]: 1. Fix bug with topics. 2. Change number edit to be same as charts

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59891 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2020-11-16 16:48:07 +00:00
parent d0687323bd
commit f54486f752
3 changed files with 105 additions and 86 deletions

View File

@ -55,7 +55,7 @@
<i uk-icon="more-vertical" (click)="$event.stopPropagation();$event.preventDefault()"></i>
<div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false">
<ul class="uk-nav uk-dropdown-nav">
<li *ngIf="isAdministrator && !indicator.defaultId && !editing"><a
<li *ngIf="!editing"><a
(click)="editNumberIndicatorOpen(number, indicator._id)">Edit</a></li>
<ng-template ngFor [ngForOf]="stakeholderUtils.visibility" let-v>
<li *ngIf="indicator.visibility != v.value"><a (click)="changeIndicatorStatus(number._id,
@ -92,7 +92,7 @@
</div>
</div>
</ng-template>
<div *ngIf="isAdministrator" class="disable-sortable uk-sortable-nodrag uk-width-1-1">
<div class="disable-sortable uk-sortable-nodrag uk-width-1-1">
<div class="uk-width-1-3@l uk-width-1-2@m uk-width-1-1 uk-card uk-card-default uk-card-body clickable"
(click)="editNumberIndicatorOpen(number)">
<div>
@ -301,7 +301,7 @@
</div>
</div>
</div>
<div class="uk-flex uk-flex-middle">
<div *ngIf="indicator.defaultId === null" class="uk-flex uk-flex-middle">
<button class="uk-icon-button uk-button-secondary uk-margin-medium-top"
(click)="addJsonPath(i)">
<icon name="add"></icon>

View File

@ -262,6 +262,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.numberSections.push(this.fb.group({
_id: this.fb.control(section._id),
title: this.fb.control(section.title),
creationDate: this.fb.control(section.creationDate),
stakeholderAlias: this.fb.control(section.stakeholderAlias),
defaultId: this.fb.control(section.defaultId),
type: this.fb.control(section.type),
@ -273,6 +274,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.chartSections.push(this.fb.group({
_id: this.fb.control(section._id),
title: this.fb.control(section.title),
creationDate: this.fb.control(section.creationDate),
stakeholderAlias: this.fb.control(section.stakeholderAlias),
defaultId: this.fb.control(section.defaultId),
type: this.fb.control(section.type),
@ -430,7 +432,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
public validateJsonPath(index: number) {
let indicatorPath: FormGroup = <FormGroup>this.numberIndicatorPaths.at(index);
if(this.indicator.defaultId === null) {
this.getJsonPath(index).disable();
}
indicatorPath.get('result').setErrors({validating: true});
this.subscriptions.push(this.statisticsService.getNumbers(null, indicatorPath.get('url').value).subscribe(response => {
let result = JSON.parse(JSON.stringify(response));
@ -440,8 +444,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
});
setTimeout(() => {
if(this.indicator.defaultId === null) {
this.getJsonPath(index).enable();
}
indicatorPath.get('result').setErrors(null);
console.debug(result);
if(typeof result === 'string' || typeof result === 'number') {
result = Number(result);
if (result !== Number.NaN) {
@ -497,6 +504,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if(this.numberIndicatorPaths.at(index).get('url').valid) {
this.validateJsonPath(index);
}
if(this.indicator.defaultId === null) {
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) {
@ -539,6 +547,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
})
);
} else {
this.numberIndicatorPaths.at(index).get('url').disable();
this.numberIndicatorPaths.at(index).get('jsonPath').disable();
this.numberIndicatorPaths.at(index).get('source').disable();
}
}
}
@ -632,6 +645,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
_id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name, Validators.required),
description: this.fb.control(this.indicator.description),
creationDate: this.fb.control(this.indicator.creationDate),
additionalDescription: this.fb.control(this.indicator.additionalDescription),
visibility: this.fb.control(this.indicator.visibility),
indicatorPaths: this.fb.array([], Validators.required),
@ -689,6 +703,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.chartIndicatorFb = this.fb.group({
_id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name),
creationDate: this.fb.control(this.indicator.creationDate),
description: this.fb.control(this.indicator.description),
additionalDescription: this.fb.control(this.indicator.additionalDescription),
visibility: this.fb.control(this.indicator.visibility),

View File

@ -28,7 +28,8 @@ declare var UIkit;
templateUrl: './topic.component.html',
})
export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
public subscriptions: any[] = [];
private subscriptions: any[] = [];
private paramsSub: any;
public properties: EnvProperties;
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public loading: boolean = true;
@ -79,7 +80,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
public ngOnInit() {
this.properties = properties;
let subscription: Subscription;
this.subscriptions.push(this.route.params.subscribe(params => {
this.paramsSub = this.route.params.subscribe(params => {
if (subscription) {
subscription.unsubscribe();
}
@ -107,8 +108,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
}
});
this.subscriptions.push(subscription);
}));
});
}
public ngOnDestroy() {
@ -117,6 +117,9 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
value.unsubscribe();
}
});
if(this.paramsSub instanceof Subscriber) {
this.paramsSub.unsubscribe();
}
}
canExit(): boolean {
@ -163,6 +166,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
_id: this.fb.control(topic._id),
name: this.fb.control(topic.name, Validators.required),
description: this.fb.control(topic.description),
creationDate: this.fb.control(topic.creationDate),
alias: this.fb.control(topic.alias, [
Validators.required,
this.stakeholderUtils.aliasValidator(topics)
@ -256,6 +260,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
_id: this.fb.control(category._id),
name: this.fb.control(category.name, Validators.required),
description: this.fb.control(category.description),
creationDate: this.fb.control(category.creationDate),
alias: this.fb.control(category.alias, [
Validators.required,
this.stakeholderUtils.aliasValidator(categories)
@ -342,6 +347,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
_id: this.fb.control(subCategory._id),
name: this.fb.control(subCategory.name, Validators.required),
description: this.fb.control(subCategory.description),
creationDate: this.fb.control(subCategory.creationDate),
alias: this.fb.control(subCategory.alias, [
Validators.required,
this.stakeholderUtils.aliasValidator(subCategories)
@ -409,7 +415,6 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
}
public deleteSubcategoryOpen(index, childrenAction: string = null) {
this.type = 'subcategory';
this.index = index;
@ -467,7 +472,6 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
private save(message: string, path: string[], saveElement: any, callback: Function, redirect = false) {
this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, saveElement, path).subscribe(saveElement => {
callback(saveElement);
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, {
status: 'success',
timeout: 3000,
@ -513,8 +517,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
this.changeSubcategoryStatus(index, visibility);
} else if (type == "cat") {
this.changeCategoryStatus(index, visibility);
}
else if(type == "topic") {
} else if (type == "topic") {
this.changeTopicStatus(index, visibility);
}
}
@ -563,6 +566,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
public get isSmallScreen() {
return this.layoutService.isSmallScreen;
}
public get open() {
return this.layoutService.open;
}