[Monitor Dashboard | Trunk]: Fix bug with number indicators and with subcategory content while is recreated

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@58985 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2020-06-24 10:13:29 +00:00
parent 5a13ef0a57
commit 03879e7eeb
6 changed files with 89 additions and 62 deletions

View File

@ -76,7 +76,7 @@
"production": {
"browserTarget": "ng-universal-demo:build:production"
},
"production": {
"beta": {
"browserTarget": "ng-universal-demo:build:beta"
}
}

View File

@ -72,22 +72,22 @@
<div class="md-btn-group">
<button [disabled]="editing" class="md-btn md-btn-mini" (click)="createSection(i, 'number')"
title="Create a new section"><i
class="material-icons">add</i></button>
class="material-icons">add</i></button>
<!--<button class="md-btn md-btn-mini"><i class="material-icons rotate-90">drag_indicator</i></button>-->
<button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"
[title]="(number.defaultId?'Default sections cannot be deleted':'Delete section')"
(click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">clear</i>
<button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"
[title]="(number.defaultId?'Default sections cannot be deleted':'Delete section')"
(click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">clear</i>
</button>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(number, i, 'number', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
</div>
</div>
<div *ngIf="grid && numberSections.at(i)"
@ -142,10 +142,10 @@
<hr *ngIf="isAdministrator && !indicator.defaultId" class="uk-nav-divider">
<li *ngIf="isAdministrator && !indicator.defaultId && !editing"><a
(click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete</a>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(number, indicator._id, 'number', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
<!-- </ng-container>-->
</li>
</ul>
</div>
@ -222,22 +222,23 @@
<div class="md-btn-group">
<button [disabled]="editing" class="md-btn md-btn-mini" (click)="createSection(i)"
title="Create a new section"><i
class="material-icons">add</i></button>
class="material-icons">add</i></button>
<!--<button class="md-btn md-btn-mini"><i class="material-icons rotate-90">drag_indicator</i></button>-->
<button [disabled]="editing || chart.defaultId "
[title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section')"
class="md-btn md-btn-mini" (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">clear</i>
class="md-btn md-btn-mini" (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i
class="material-icons">clear</i>
</button>
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">highlight_off</i>-->
<!-- </button>-->
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'disconnect')"><i class="material-icons">link_off</i>-->
<!-- </button>-->
<!-- </ng-container>-->
</div>
</div>
<div *ngIf="grid && chartSections.at(i)"
@ -294,7 +295,8 @@
<div #element uk-dropdown="mode: click; pos: bottom-right; delay-hide: 0; flip: false"
class="uk-padding-remove-horizontal">
<ul class="uk-nav uk-dropdown-nav">
<li *ngIf="!editing"><a (click)="editChartIndicatorOpen(chart, indicator._id);hide(element)">Edit</a></li>
<li *ngIf="!editing"><a (click)="editChartIndicatorOpen(chart, indicator._id);hide(element)">Edit</a>
</li>
<li *ngIf="!editing"><a (click)="toggleIndicatorStatus(chart._id, indicator);hide(element)">
{{indicator.isActive ? 'Inactive' : 'Active'}}</a>
</li>
@ -302,10 +304,11 @@
{{indicator.isPublic ? 'Private' : 'Public'}}</a>
</li>
<hr *ngIf="!indicator.defaultId " class="uk-nav-divider">
<li *ngIf="!editing && !indicator.defaultId "><a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">
<li *ngIf="!editing && !indicator.defaultId "><a
(click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">
Delete</a>
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'delete');hide(element)">Delete from all profiles</a>-->
<!-- <a (click)="deleteIndicatorOpen(chart, indicator._id, 'chart', 'disconnect');hide(element)">Delete and disconnect from all profiles</a>-->
</li>
</ul>
</div>
@ -348,7 +351,7 @@
[src]="safeUrls.get(indicatorUtils.getFullUrl(stakeholder, indicator.indicatorPaths[0]))"
class="uk-width-1-1 uk-height-medium"></iframe>
<div *ngIf="indicator.indicatorPaths[0] && indicator.indicatorPaths[0].source === 'image'">
<img class="uk-width-1-1 uk-height-medium" [src]="indicator.indicatorPaths[i].url">
<img class="uk-width-1-1 uk-height-medium" [src]="indicator.indicatorPaths[0].url">
</div>
</div>
</div>
@ -568,9 +571,9 @@
<div *ngIf="indicatorChildrenActionOnDelete == 'delete'" class="uk-text-bold">
Indicators of all profiles based on this default indicator, will be deleted as well.
</div>
<!-- <span *ngIf="indicatorChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.-->
<!-- </span>-->
<!-- <span *ngIf="indicatorChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
</modal-alert>
<!--<modal-alert #deleteAllModal (alertOutput)="deleteIndicator('delete')">-->
@ -590,9 +593,9 @@
<div *ngIf="sectionChildrenActionOnDelete == 'delete'" class="uk-text-bold">
Sections of all profiles based on this default section and their contents, will be deleted as well.
</div>
<!-- <span *ngIf="sectionChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Sections of all profiles based on this default section and their contents, will not be marked as copied from default anymore.-->
<!-- </span>-->
<!-- <span *ngIf="sectionChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
<!-- Sections of all profiles based on this default section and their contents, will not be marked as copied from default anymore.-->
<!-- </span>-->
Are you sure you want to proceed?
</modal-alert>
<!--<modal-alert #deleteNumberSectionModal (alertOutput)="deleteSection('number')">-->

View File

@ -41,7 +41,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
public categoryIndex: number = 0;
@Input()
public subcategoryIndex: number = 0;
@Input()
public stakeholder: Stakeholder = null;
public user = null;
public preview: string;
@ -106,8 +105,15 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
});
this.buildFilters();
this.buildSections();
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
this.stakeholder = stakeholder;
if(this.stakeholder) {
this.buildFilters();
this.buildSections();
this.filterCharts();
this.filterNumbers();
}
});
}
ngOnDestroy(): void {
@ -133,11 +139,17 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.filterCharts();
this.filterNumbers();
}
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias;
if(this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]) {
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias;
if(this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]) {
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].alias;
this.setPreview();
}
setPreview() {
if(this.stakeholder && this.stakeholder.topics[this.topicIndex]) {
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias;
if (this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]) {
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias;
if (this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]) {
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].alias;
}
}
}
}
@ -264,7 +276,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.filterByKeyword(HelperFunctions.copy(this.numbers), this.filters.value.keyword),
this.filters.value.status),
this.filters.value.privacy);
console.log(this.numbers);
this.buildSections();
}
@ -519,7 +530,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.indicator = HelperFunctions.copy(this.section.indicators[this.index]);
this.numberIndicatorFb = this.fb.group({
_id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name),
name: this.fb.control(this.indicator.name, Validators.required),
description: this.fb.control(this.indicator.description),
isPublic: this.fb.control(this.indicator.isPublic),
isActive: this.fb.control(this.indicator.isActive),
@ -535,7 +546,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.indicator = new Indicator('', '', 'number', 'small', true, true, []);
this.numberIndicatorFb = this.fb.group({
_id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name),
name: this.fb.control(this.indicator.name, Validators.required),
description: this.fb.control(this.indicator.description),
isPublic: this.fb.control(this.indicator.isPublic),
isActive: this.fb.control(this.indicator.isActive),
@ -619,6 +630,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.section = this.charts.find(section => section._id === this.section._id);
} else {
this.indicator = this.numberIndicatorFb.value;
this.section = this.numbers.find(section => section._id === this.section._id);
}
let path = [
this.stakeholder._id,
@ -633,8 +645,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} else {
this.section.indicators.push(indicator);
}
this.filterCharts();
this.chartIndicatorFb = null;
if(this.indicator.type === "chart") {
this.filterCharts();
this.chartIndicatorFb = null;
} else {
this.filterNumbers();
this.numberIndicatorFb = null;
}
UIkit.notification('Indicator has been successfully saved', {
status: 'success',
timeout: 3000,

View File

@ -143,7 +143,6 @@
</div>
</aside>
<indicators *ngIf="stakeholder" [properties]="properties"
[stakeholder]="stakeholder"
[topicIndex]="topicIndex"
[categoryIndex]="categoryIndex"
[subcategoryIndex]="subCategoryIndex"></indicators>

View File

@ -459,6 +459,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
private save(message: string, path: string[], saveElement: any, callback: Function, redirect = false) {
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, saveElement, path).subscribe(saveElement => {
callback(saveElement);
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, {
status: 'success',
timeout: 3000,
@ -481,6 +482,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
private delete(message: string, path: string[], callback: Function, redirect = false) {
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.elementChildrenActionOnDelete).subscribe(() => {
callback();
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, {
status: 'success',
timeout: 3000,
@ -501,6 +503,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
private toggleStatus(element: Topic | Category | SubCategory, path: string[]) {
this.stakeholderService.toggleStatus(this.properties.monitorServiceAPIURL, path).subscribe(isActive => {
element.isActive = isActive;
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + (isActive ? 'active' : 'inactive'), {
status: 'success',
timeout: 3000,
@ -518,6 +521,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
private toggleAccess(element: Topic | Category | SubCategory, path: string[]) {
this.stakeholderService.toggleAccess(this.properties.monitorServiceAPIURL, path).subscribe(isPublic => {
element.isPublic = isPublic;
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + (isPublic ? 'public' : 'private'), {
status: 'success',
timeout: 3000,

View File

@ -436,20 +436,24 @@ body.dashboard {
.dashboard .section:hover .tools .md-btn-group::before {
content: "";
border-bottom: 23px solid var(--secondary-color);
border-bottom: 24px solid var(--secondary-color);
border-left:solid 12px transparent;
width: 0;
margin-left: -1px;
padding-bottom: 2px;
position: absolute;
top: 0;
bottom: 0;
left: -12px;
}
.dashboard .section:hover .tools .md-btn-group::after {
content: "";
border-bottom: 23px solid var(--secondary-color);
border-bottom: 24px solid var(--secondary-color);
border-right: solid 12px transparent;
width: 0;
margin-left: -1px;
padding-bottom: 2px;
position: absolute;
top: 0;
bottom: 0;
right: -11px;
}
/* New section*/