[angular-16-irish-monitor]: Fix name of export file of indicators. Fix manageStakeholders if an error is occurred.

This commit is contained in:
Konstantinos Triantafyllou 2024-01-10 14:21:12 +02:00
parent ae4b3b7b95
commit c5759235e4
4 changed files with 158 additions and 139 deletions

View File

@ -1,156 +1,173 @@
<div page-content> <div page-content>
<div header> <div header>
<sidebar-mobile-toggle class="uk-margin-top uk-hidden@m uk-display-block"></sidebar-mobile-toggle> <sidebar-mobile-toggle class="uk-margin-top uk-hidden@m uk-display-block"></sidebar-mobile-toggle>
<div *ngIf="isCurator()" class="uk-margin-remove-bottom uk-margin-medium-top"> <div *ngIf="isCurator()" class="uk-margin-remove-bottom uk-margin-medium-top">
<slider-tabs [type]="'dynamic'" (activeEmitter)="tab = $event"> <slider-tabs [type]="'dynamic'" (activeEmitter)="tab = $event">
<slider-tab tabTitle="All" [tabId]="'all'" [active]="tab === 'all'"></slider-tab> <slider-tab tabTitle="All" [tabId]="'all'" [active]="tab === 'all'"></slider-tab>
<slider-tab tabTitle="Profile templates" [tabId]="'templates'" [active]="tab === 'templates'"></slider-tab> <slider-tab tabTitle="Profile templates" [tabId]="'templates'"
<slider-tab tabTitle="Profiles" [tabId]="'profiles'" [active]="tab === 'profiles'"></slider-tab> [active]="tab === 'templates'"></slider-tab>
</slider-tabs> <slider-tab tabTitle="Profiles" [tabId]="'profiles'" [active]="tab === 'profiles'"></slider-tab>
</div> </slider-tabs>
</div>
<div actions>
<div class="uk-section-xsmall">
<div class="uk-flex uk-flex-center uk-flex-wrap uk-flex-middle" [ngClass]="properties.dashboard == 'irish' ? 'uk-flex-between@m' : 'uk-flex-right@m'">
<div *ngIf="properties.dashboard == 'irish'" class="uk-width-medium uk-margin-small-bottom">
<div input type="select" placeholder="Type"
[options]="typeOptions" [formInput]="filters.get('type')">
</div>
</div> </div>
<div search-input [searchControl]="filters.get('keyword')" [expandable]="true" placeholder="Search Profiles" searchInputClass="outer"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1 uk-flex uk-flex-right"></div>
</div>
</div> </div>
</div> <div actions>
<div inner> <div class="uk-section-xsmall">
<div *ngIf="loading" class="uk-margin-medium-top uk-padding-large"> <div class="uk-flex uk-flex-center uk-flex-wrap uk-flex-middle"
<loading></loading> [ngClass]="properties.dashboard == 'irish' ? 'uk-flex-between@m' : 'uk-flex-right@m'">
<div *ngIf="properties.dashboard == 'irish'" class="uk-width-medium uk-margin-small-bottom">
<div input type="select" placeholder="Type"
[options]="typeOptions" [formInput]="filters.get('type')">
</div>
</div>
<div search-input [searchControl]="filters.get('keyword')" [expandable]="true"
placeholder="Search Profiles" searchInputClass="outer"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1 uk-flex uk-flex-right"></div>
</div>
</div>
</div> </div>
<div *ngIf="!loading" uk-height-match="target: .titleContainer; row: false"> <div inner>
<div uk-height-match="target: .logoContainer; row: false"> <div *ngIf="loading" class="uk-margin-medium-top uk-padding-large">
<div *ngIf="tab != 'profiles' && isCurator()" class="uk-section"> <loading></loading>
<div class="uk-flex uk-flex-middle uk-flex-between uk-margin-small-bottom"> </div>
<h4 class="uk-margin-remove">Profile Templates</h4> <div *ngIf="!loading" uk-height-match="target: .titleContainer; row: false">
<paging-no-load *ngIf="displayDefaultStakeholders.length > pageSize" <div uk-height-match="target: .logoContainer; row: false">
(pageChange)="updateCurrentTemplatesPage($event)" <div *ngIf="tab != 'profiles' && isCurator()" class="uk-section">
[currentPage]="currentTemplatesPage" [size]="pageSize" <div class="uk-flex uk-flex-middle uk-flex-between uk-margin-small-bottom">
[totalResults]="displayDefaultStakeholders.length"> <h4 class="uk-margin-remove">Profile Templates</h4>
</paging-no-load> <paging-no-load *ngIf="displayDefaultStakeholders?.length > pageSize"
</div> (pageChange)="updateCurrentTemplatesPage($event)"
<div class="uk-grid uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1 uk-grid-match" uk-grid> [currentPage]="currentTemplatesPage" [size]="pageSize"
<ng-template ngFor [ngForOf]="displayDefaultStakeholders.slice((currentTemplatesPage-1)*pageSize, currentTemplatesPage*pageSize)" let-stakeholder> [totalResults]="displayDefaultStakeholders.length">
<ng-container *ngTemplateOutlet="stakeholderBox; context: {stakeholder:stakeholder}"></ng-container> </paging-no-load>
</ng-template> </div>
<div *ngIf="!loading && isCurator()"> <div class="uk-grid uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1 uk-grid-match"
<ng-container *ngTemplateOutlet="newBox; context: {text:'Create a new default profile.', isDefault:true}"></ng-container> uk-grid>
</div> <ng-template ngFor
</div> [ngForOf]="displayDefaultStakeholders.slice((currentTemplatesPage-1)*pageSize, currentTemplatesPage*pageSize)"
</div> let-stakeholder>
<div *ngIf="!isManager()" class="message"> <ng-container
<h4 class="uk-text-center"> *ngTemplateOutlet="stakeholderBox; context: {stakeholder:stakeholder}"></ng-container>
No profiles to manage yet </ng-template>
</h4> <div *ngIf="!loading && isCurator()">
</div> <ng-container
<div *ngIf="tab != 'templates' && isManager()" class="uk-section"> *ngTemplateOutlet="newBox; context: {text:'Create a new default profile.', isDefault:true}"></ng-container>
<div class="uk-flex uk-flex-middle uk-flex-between uk-margin-small-bottom"> </div>
<h4 class="uk-margin-remove">Profiles</h4> </div>
<paging-no-load *ngIf="displayStakeholders.length > pageSize" </div>
(pageChange)="updateCurrentPage($event)" <div *ngIf="!isManager()" class="message">
[currentPage]="currentPage" [size]="pageSize" <h4 class="uk-text-center">
[totalResults]="displayStakeholders.length"> No profiles to manage yet
</paging-no-load> </h4>
</div> </div>
<div class="uk-grid uk-grid-match uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1" uk-grid> <div *ngIf="tab != 'templates' && isManager()" class="uk-section">
<ng-template ngFor [ngForOf]="displayStakeholders.slice((currentPage-1)*pageSize, currentPage*pageSize)" let-stakeholder> <div class="uk-flex uk-flex-middle uk-flex-between uk-margin-small-bottom">
<ng-container *ngTemplateOutlet="stakeholderBox; context: {stakeholder:stakeholder}"></ng-container> <h4 class="uk-margin-remove">Profiles</h4>
</ng-template> <paging-no-load *ngIf="displayStakeholders?.length > pageSize"
<div *ngIf="!loading && isCurator()"> (pageChange)="updateCurrentPage($event)"
<ng-container *ngTemplateOutlet="newBox; context: {text:'Create a new profile by selecting the type ('+typesAsString+') and ' + [currentPage]="currentPage" [size]="pageSize"
[totalResults]="displayStakeholders.length">
</paging-no-load>
</div>
<div class="uk-grid uk-grid-match uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1"
uk-grid>
<ng-template ngFor
[ngForOf]="displayStakeholders.slice((currentPage-1)*pageSize, currentPage*pageSize)"
let-stakeholder>
<ng-container
*ngTemplateOutlet="stakeholderBox; context: {stakeholder:stakeholder}"></ng-container>
</ng-template>
<div *ngIf="!loading && isCurator()">
<ng-container *ngTemplateOutlet="newBox; context: {text:'Create a new profile by selecting the type ('+typesAsString+') and ' +
'select indicators based on a default or a blank profile.', isDefault:false}"></ng-container> 'select indicators based on a default or a blank profile.', isDefault:false}"></ng-container>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div>
</div> </div>
<ng-template #stakeholderBox let-stakeholder="stakeholder"> <ng-template #stakeholderBox let-stakeholder="stakeholder">
<div *ngIf="stakeholder"> <div *ngIf="stakeholder">
<div class="uk-card uk-card-default uk-card-body uk-position-relative" [ngClass]="stakeholder.type"> <div class="uk-card uk-card-default uk-card-body uk-position-relative" [ngClass]="stakeholder.type">
<div class="uk-position-top-right uk-margin-small-right uk-margin-small-top"> <div class="uk-position-top-right uk-margin-small-right uk-margin-small-top">
<a class="uk-link-reset uk-flex uk-flex-middle"> <a class="uk-link-reset uk-flex uk-flex-middle">
<icon *ngIf="showVisibility" [flex]="true" [name]="stakeholderUtils.visibilityIcon.get(stakeholder.visibility)" ratio="0.6"></icon> <icon *ngIf="showVisibility" [flex]="true"
<icon [flex]="true" name="more_vert"></icon> [name]="stakeholderUtils.visibilityIcon.get(stakeholder.visibility)" ratio="0.6"></icon>
</a> <icon [flex]="true" name="more_vert"></icon>
<div #element class="uk-dropdown" uk-dropdown="mode: click; pos: bottom-left; offset: 5; delay-hide: 0;">
<ul class="uk-nav uk-dropdown-nav">
<li>
<a (click)="editStakeholder(stakeholder, !stakeholder.defaultId); hide(element)">Edit</a>
</li>
<li *ngIf="isCurator && stakeholderUtils.isCachingIndicators">
<a (click)="createReport(stakeholder);hide(element)">Cache Indicators</a>
</li>
<li *ngIf="showVisibility" class="uk-nav-divider"></li>
<ng-template *ngIf="showVisibility" ngFor [ngForOf]="stakeholderUtils.visibilities" let-v>
<li [class.uk-active]="stakeholder.visibility === v.value">
<a (click)="changeStakeholderStatus(stakeholder, v.value);hide(element)">
<div class="uk-flex uk-flex-middle">
<icon [flex]="true" [name]="v.icon" ratio="0.6"></icon>
<span class="uk-margin-small-left uk-width-expand">{{v.label}}</span>
<icon *ngIf="stakeholder.visibility === v.value" [flex]="true" name="done" class="uk-text-secondary" ratio="0.8"></icon>
</div>
</a> </a>
</li> <div #element class="uk-dropdown"
</ng-template> uk-dropdown="mode: click; pos: bottom-left; offset: 5; delay-hide: 0;">
<hr *ngIf="isProfileManager(stakeholder)" class="uk-nav-divider"> <ul class="uk-nav uk-dropdown-nav">
<li *ngIf="isProfileManager(stakeholder)"><a <li>
(click)="deleteStakeholderOpen(stakeholder);hide(element)">Delete</a> <a (click)="editStakeholder(stakeholder, !stakeholder.defaultId); hide(element)">Edit</a>
</li> </li>
</ul> <li *ngIf="isCurator && stakeholderUtils.isCachingIndicators">
<a (click)="createReport(stakeholder);hide(element)">Cache Indicators</a>
</li>
<li *ngIf="showVisibility" class="uk-nav-divider"></li>
<ng-template *ngIf="showVisibility" ngFor [ngForOf]="stakeholderUtils.visibilities" let-v>
<li [class.uk-active]="stakeholder.visibility === v.value">
<a (click)="changeStakeholderStatus(stakeholder, v.value);hide(element)">
<div class="uk-flex uk-flex-middle">
<icon [flex]="true" [name]="v.icon" ratio="0.6"></icon>
<span class="uk-margin-small-left uk-width-expand">{{v.label}}</span>
<icon *ngIf="stakeholder.visibility === v.value" [flex]="true" name="done"
class="uk-text-secondary" ratio="0.8"></icon>
</div>
</a>
</li>
</ng-template>
<hr *ngIf="isProfileManager(stakeholder)" class="uk-nav-divider">
<li *ngIf="isProfileManager(stakeholder)"><a
(click)="deleteStakeholderOpen(stakeholder);hide(element)">Delete</a>
</li>
</ul>
</div>
</div>
<a class="uk-display-block uk-text-center uk-link-reset" [routerLink]="'/admin/' + stakeholder.alias">
<div class="titleContainer uk-h6 uk-margin-remove-bottom uk-margin-top multi-line-ellipsis lines-2">
<p *ngIf="stakeholder.name" class="uk-margin-remove">
{{stakeholder.name}}
</p>
</div>
<div class="logoContainer uk-margin-top uk-flex uk-flex-column uk-flex-center uk-flex-middle">
<img [src]="stakeholder | logoUrl" class="uk-blend-multiply" style="max-height: 80px;">
</div>
</a>
</div> </div>
</div>
<a class="uk-display-block uk-text-center uk-link-reset" [routerLink]="'/admin/' + stakeholder.alias">
<div class="titleContainer uk-h6 uk-margin-remove-bottom uk-margin-top multi-line-ellipsis lines-2">
<p *ngIf="stakeholder.name" class="uk-margin-remove">
{{stakeholder.name}}
</p>
</div>
<div class="logoContainer uk-margin-top uk-flex uk-flex-column uk-flex-center uk-flex-middle">
<img [src]="stakeholder | logoUrl" class="uk-blend-multiply" style="max-height: 80px;">
</div>
</a>
</div> </div>
</div>
</ng-template> </ng-template>
<ng-template #newBox let-text="text" let-isDefault="isDefault"> <ng-template #newBox let-text="text" let-isDefault="isDefault">
<ng-container *ngIf="!loading"> <ng-container *ngIf="!loading">
<div class="uk-card uk-card-default uk-text-center uk-card-body clickable" (click)="editStakeholder(null, isDefault)"> <div class="uk-card uk-card-default uk-text-center uk-card-body clickable"
<div class="uk-text-small uk-text-muted"> (click)="editStakeholder(null, isDefault)">
{{text}} <div class="uk-text-small uk-text-muted">
</div> {{text}}
<div class="uk-margin-medium-top uk-margin-small-bottom"> </div>
<div class="uk-margin-medium-top uk-margin-small-bottom">
<span class="uk-text-secondary"> <span class="uk-text-secondary">
<icon name="add" [ratio]="3"></icon> <icon name="add" [ratio]="3"></icon>
</span> </span>
</div> </div>
</div> </div>
</ng-container> </ng-container>
</ng-template> </ng-template>
<modal-alert #editStakeholderModal [large]="true" classTitle="uk-background-primary uk-light" <modal-alert #editStakeholderModal [large]="true" classTitle="uk-background-primary uk-light"
(alertOutput)="editStakeholderComponent.save(callback)" (cancelOutput)="editStakeholderComponent.removePhoto()" (alertOutput)="editStakeholderComponent.save(callback)"
[okDisabled]="editStakeholderComponent.disabled"> (cancelOutput)="editStakeholderComponent.removePhoto()"
<div class="uk-height-large uk-position-relative" *ngIf="editStakeholderComponent.loading"> [okDisabled]="editStakeholderComponent.disabled">
<loading class="uk-position-center"></loading> <div class="uk-height-large uk-position-relative" *ngIf="editStakeholderComponent.loading">
</div> <loading class="uk-position-center"></loading>
<div class="uk-padding" [class.uk-hidden]="editStakeholderComponent.loading"> </div>
<edit-stakeholder #editStakeholderComponent></edit-stakeholder> <div class="uk-padding" [class.uk-hidden]="editStakeholderComponent.loading">
</div> <edit-stakeholder #editStakeholderComponent></edit-stakeholder>
</div>
</modal-alert> </modal-alert>
<modal-alert #deleteStakeholderModal [overflowBody]="false" (alertOutput)="deleteStakeholder()"> <modal-alert #deleteStakeholderModal [overflowBody]="false" (alertOutput)="deleteStakeholder()">
<div class="uk-height-medium uk-position-relative" *ngIf="deleteLoading"> <div class="uk-height-medium uk-position-relative" *ngIf="deleteLoading">
<loading class="uk-position-center"></loading> <loading class="uk-position-center"></loading>
</div> </div>
<div *ngIf="!deleteLoading"> <div *ngIf="!deleteLoading">
This stakeholder will permanently be deleted. Are you sure you want to proceed? This stakeholder will permanently be deleted. Are you sure you want to proceed?
</div> </div>
</modal-alert> </modal-alert>

View File

@ -40,8 +40,8 @@ export class ManageStakeholdersComponent extends StakeholderBaseComponent implem
/** /**
* Filtered Stakeholders * Filtered Stakeholders
*/ */
public displayDefaultStakeholders: Stakeholder[]; public displayDefaultStakeholders: Stakeholder[] = [];
public displayStakeholders: Stakeholder[]; public displayStakeholders: Stakeholder[] = [];
/** /**
* Top filters * Top filters
*/ */

View File

@ -1372,7 +1372,7 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
let topic = this.stakeholder ? this.stakeholder.topics[this.topicIndex] : null; let topic = this.stakeholder ? this.stakeholder.topics[this.topicIndex] : null;
let category = topic ? topic.categories[this.categoryIndex] : null; let category = topic ? topic.categories[this.categoryIndex] : null;
let subCategory = category ? category.subCategories[this.subcategoryIndex] : null; let subCategory = category ? category.subCategories[subcategoryIndex] : null;
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'})); var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'}));
var a = window.document.createElement('a'); var a = window.document.createElement('a');

View File

@ -8,7 +8,9 @@ import {StakeholderService} from "../../monitor/services/stakeholder.service";
import {Observable, zip} from "rxjs"; import {Observable, zip} from "rxjs";
@Injectable() @Injectable({
providedIn: 'root'
})
export class AdminDashboardGuard { export class AdminDashboardGuard {
constructor(private router: Router, constructor(private router: Router,