From a40f1431ed8535252f133a05031bb145ac2ab359 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 24 Jan 2024 20:13:05 +0200 Subject: [PATCH] [angular-16-irish-monitor]: Fix overlay in indicators. Fix admin calls for managers/ivnitations. --- .../users/role-users/role-users.component.ts | 5 ++-- .../subscribers/subscribers.component.ts | 2 +- monitor/entities/stakeholder.ts | 3 ++- ...or-indicator-stakeholder-base.component.ts | 24 ++++--------------- services/user-registry.service.ts | 8 +++---- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts index df92f83b..cb53ed14 100644 --- a/dashboard/users/role-users/role-users.component.ts +++ b/dashboard/users/role-users/role-users.component.ts @@ -140,9 +140,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { updateLists() { this.loadActive = true; this.loadPending = true; - this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role).subscribe(users => { + this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role, true).subscribe(users => { this.active = users; - // users.forEach(user => this.active.push(user)); this.filterActiveBySearch(this.filterForm.value.active); this.loadActive = false; this.exists = true; @@ -154,7 +153,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { } this.loadActive = false; })); - this.subs.push(this.userRegistryService.getPending(this.type, this.id, this.role).subscribe(users => { + this.subs.push(this.userRegistryService.getPending(this.type, this.id, this.role, true).subscribe(users => { this.pending = users; this.filterPendingBySearch(this.filterForm.value.pending); this.loadPending = false; diff --git a/dashboard/users/subscribers/subscribers.component.ts b/dashboard/users/subscribers/subscribers.component.ts index 0d0cd490..5b7976e7 100644 --- a/dashboard/users/subscribers/subscribers.component.ts +++ b/dashboard/users/subscribers/subscribers.component.ts @@ -105,7 +105,7 @@ export class SubscribersComponent implements OnInit, OnDestroy, OnChanges { updateList() { this.loading = true; - this.subs.push( this.userRegistryService.getActive(this.type, this.id, 'member').subscribe(users => { + this.subs.push( this.userRegistryService.getActive(this.type, this.id, 'member', true).subscribe(users => { this.subscribers = users; this.filterBySearch(this.filterForm.value.keyword); this.loading = false; diff --git a/monitor/entities/stakeholder.ts b/monitor/entities/stakeholder.ts index 8cbec466..e82b968d 100644 --- a/monitor/entities/stakeholder.ts +++ b/monitor/entities/stakeholder.ts @@ -14,6 +14,7 @@ export type IndicatorPathType = 'table' | 'bar' | 'column' | 'pie' | 'line' | 'o export type SourceType = 'statistics' | 'search' |'stats-tool' | 'old' | 'image'; export type Format = 'NUMBER' | 'PERCENTAGE'; export type Visibility = 'PUBLIC' | 'PRIVATE' | 'RESTRICTED'; +export type Overlay = 'embed' | 'description' | false; export class Stakeholder { _id: string; @@ -171,7 +172,7 @@ export class Indicator { visibility: Visibility; defaultId: string; indicatorPaths: IndicatorPath[]; - overlay: boolean = false; + overlay: Overlay = false; constructor(name: string, description: string, additionalDescription:string, type: IndicatorType, width: IndicatorSize,height: IndicatorSize, visibility: Visibility, indicatorPaths: IndicatorPath[], defaultId: string = null) { this._id = null; diff --git a/monitor/monitor-indicator-stakeholder-base.component.ts b/monitor/monitor-indicator-stakeholder-base.component.ts index db496ed1..9a7a3648 100644 --- a/monitor/monitor-indicator-stakeholder-base.component.ts +++ b/monitor/monitor-indicator-stakeholder-base.component.ts @@ -4,7 +4,7 @@ import {DomSanitizer} from "@angular/platform-browser"; import { Category, Indicator, IndicatorPath, - IndicatorSize, + IndicatorSize, Overlay, Section, Stakeholder, SubCategory, @@ -55,8 +55,6 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator public chartsActiveType: Map = new Map(); public currentYear = new Date().getFullYear(); public clipboard; - public embedOverlay: boolean = false; - public descriptionOverlay: boolean = false; /** Services */ protected sanitizer: DomSanitizer; @@ -394,7 +392,7 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator } } - public getChartClassBySize(size: IndicatorSize) { + public getChartClassBySize(size: IndicatorSize): string { if (size === 'small') { return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1'; } else if (size === 'medium') { @@ -408,26 +406,14 @@ export abstract class MonitorIndicatorStakeholderBaseComponent extends Indicator window.print(); } - toggleOverlay(event, indicator: Indicator, overlayType: string) { + changeOverlay(event, indicator: Indicator, overlay: Overlay) { event.stopPropagation(); - indicator.overlay = !indicator.overlay; - if (overlayType == 'embed') { - this.embedOverlay = !this.embedOverlay; - } - if (overlayType == 'desc') { - this.descriptionOverlay = !this.descriptionOverlay; - } + indicator.overlay = overlay; } - closeOverlay(event: ClickEvent, indicator: Indicator, overlayType: string) { + closeOverlay(event: ClickEvent, indicator: Indicator) { if(event.clicked && indicator.overlay) { indicator.overlay = false; - if (overlayType == 'embed') { - this.embedOverlay = false; - } - if (overlayType == 'desc') { - this.descriptionOverlay = false; - } } } diff --git a/services/user-registry.service.ts b/services/user-registry.service.ts index e81cf626..6dc38d75 100644 --- a/services/user-registry.service.ts +++ b/services/user-registry.service.ts @@ -58,9 +58,9 @@ export class UserRegistryService { return this.http.delete(properties.registryUrl + 'verification/' + id, CustomOptions.registryOptions()); } - public getActive(type: string, id: string, role: "member" | "manager" = "manager"): Observable { + public getActive(type: string, id: string, role: "member" | "manager" = "manager", admin = false): Observable { let url = properties.registryUrl + Role.GROUP + type + '/' + id + "/" + role + 's'; - return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url, + return this.http.get((properties.useCache && !admin) ? (properties.cacheUrl + encodeURIComponent(url)) : url, CustomOptions.registryOptions()).pipe(map((response:any) => response.response), map(users => { if(users.length > 0 && !users[0].email) { return []; @@ -70,9 +70,9 @@ export class UserRegistryService { })); } - public getPending(type: string, id: string, role: "member" | "manager" = "manager"): Observable { + public getPending(type: string, id: string, role: "member" | "manager" = "manager", admin = false): Observable { let url = properties.registryUrl + 'invite/' + Role.GROUP + type + '/' +id + "/" + role + 's/'; - return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url, + return this.http.get((properties.useCache && !admin) ? (properties.cacheUrl + encodeURIComponent(url)) : url, CustomOptions.registryOptions()).pipe(map((response: any) => response.response)); }