Add stats profile entity class. Add stats profiles in admin tabs
This commit is contained in:
parent
f49149c99e
commit
6a2ac8cc4e
|
@ -11,9 +11,10 @@ import {ActivatedRoute} from "@angular/router";
|
||||||
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'portal'"><a routerLink="../portals">Portals</a></li>
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'portal'"><a routerLink="../portals">Portals</a></li>
|
||||||
<li [class.uk-active]="tab === 'page'"><a routerLink="../pages">Pages</a></li>
|
<li [class.uk-active]="tab === 'page'"><a routerLink="../pages">Pages</a></li>
|
||||||
<li [class.uk-active]="tab === 'entity'"><a routerLink="../entities">Entities</a></li>
|
<li [class.uk-active]="tab === 'entity'"><a routerLink="../entities">Entities</a></li>
|
||||||
<li *ngIf="portal && type === 'community'" [class.uk-active]="tab === 'menu'"><a routerLink="../menu">Menus</a></li>
|
<li *ngIf="portal && type === 'community'" [class.uk-active]="tab === 'menu'"><a routerLink="../menu">Menus</a></li>
|
||||||
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'class'"><a routerLink="../classes">Classes</a></li>
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'class'"><a routerLink="../classes">Classes</a></li>
|
||||||
<li *ngIf="isPortalAdmin && portal=='connect'" [class.uk-active]="tab === 'customization'"><a routerLink="../customization">Customization</a></li>
|
<li *ngIf="isPortalAdmin && portal=='connect'" [class.uk-active]="tab === 'customization'"><a routerLink="../customization">Customization</a></li>
|
||||||
|
<li *ngIf="portal === 'monitor'"[class.uk-active]="tab === 'stats-profiles'"><a routerLink="../stats-profiles">Stats Profiles</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
@ -25,7 +26,7 @@ export class AdminTabsComponent implements OnInit {
|
||||||
@Input()
|
@Input()
|
||||||
public user: User;
|
public user: User;
|
||||||
@Input()
|
@Input()
|
||||||
public tab: "portal" | "page" | "entity" | "menu" | "class" | "customization"= 'page';
|
public tab: "portal" | "page" | "entity" | "menu" | "class" | "customization" | "stats-profiles" = 'page';
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private userManagementService: UserManagementService) {
|
constructor(private route: ActivatedRoute, private userManagementService: UserManagementService) {
|
||||||
|
|
|
@ -213,8 +213,20 @@ export class IndicatorPath {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class StatsProfile {
|
||||||
|
_id: string;
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
constructor(name: string) {
|
||||||
|
this._id = null;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded";
|
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded";
|
||||||
export class IndicatorFilterUtils{
|
|
||||||
|
export class IndicatorFilterUtils {
|
||||||
|
|
||||||
static getFilter(fieldPath: string, filterType:FilterType) {
|
static getFilter(fieldPath: string, filterType:FilterType) {
|
||||||
if((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
if((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
||||||
|
|
|
@ -4,13 +4,10 @@ import {BehaviorSubject, from, Observable, Subscriber} from "rxjs";
|
||||||
import {Indicator, Section, Stakeholder, StakeholderInfo, Visibility} from "../entities/stakeholder";
|
import {Indicator, Section, Stakeholder, StakeholderInfo, Visibility} from "../entities/stakeholder";
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
import {map} from "rxjs/operators";
|
import {map} from "rxjs/operators";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
|
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
|
||||||
import {StringUtils} from "../../utils/string-utils.class";
|
import {StringUtils} from "../../utils/string-utils.class";
|
||||||
|
|
||||||
let maps: string[] = ['parameters', 'filters'];
|
|
||||||
|
|
||||||
export interface Reorder {
|
export interface Reorder {
|
||||||
action: 'moved' | 'added' | 'removed',
|
action: 'moved' | 'added' | 'removed',
|
||||||
target: string,
|
target: string,
|
||||||
|
@ -21,25 +18,25 @@ export interface Reorder {
|
||||||
providedIn: "root"
|
providedIn: "root"
|
||||||
})
|
})
|
||||||
export class StakeholderService {
|
export class StakeholderService {
|
||||||
|
|
||||||
private stakeholderSubject: BehaviorSubject<Stakeholder> = null;
|
private stakeholderSubject: BehaviorSubject<Stakeholder> = null;
|
||||||
private promise: Promise<void>;
|
private promise: Promise<void>;
|
||||||
private sub;
|
private sub;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.stakeholderSubject = new BehaviorSubject<Stakeholder>(null);
|
this.stakeholderSubject = new BehaviorSubject<Stakeholder>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.clearSubscriptions();
|
this.clearSubscriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSubscriptions() {
|
clearSubscriptions() {
|
||||||
if (this.sub instanceof Subscriber) {
|
if (this.sub instanceof Subscriber) {
|
||||||
this.sub.unsubscribe();
|
this.sub.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getStakeholder(alias: string, shouldUpdate: boolean = false): Observable<Stakeholder> {
|
getStakeholder(alias: string, shouldUpdate: boolean = false): Observable<Stakeholder> {
|
||||||
if (!this.stakeholderSubject.value || this.stakeholderSubject.value.alias !== alias || shouldUpdate) {
|
if (!this.stakeholderSubject.value || this.stakeholderSubject.value.alias !== alias || shouldUpdate) {
|
||||||
this.promise = new Promise<void>((resolve, reject) => {
|
this.promise = new Promise<void>((resolve, reject) => {
|
||||||
|
@ -56,78 +53,80 @@ export class StakeholderService {
|
||||||
}
|
}
|
||||||
return from(this.getStakeholderAsync());
|
return from(this.getStakeholderAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStakeholderAsync() {
|
async getStakeholderAsync() {
|
||||||
if(this.promise) {
|
if (this.promise) {
|
||||||
await this.promise;
|
await this.promise;
|
||||||
this.promise = null;
|
this.promise = null;
|
||||||
}
|
}
|
||||||
this.clearSubscriptions();
|
this.clearSubscriptions();
|
||||||
return this.stakeholderSubject.getValue();
|
return this.stakeholderSubject.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
getAlias(url: string): Observable<string[]> {
|
getAlias(url: string): Observable<string[]> {
|
||||||
return this.http.get<Stakeholder[]>(url + '/stakeholder/alias', CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
return this.http.get<Stakeholder[]>(url + '/stakeholder/alias', CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
||||||
return this.formalize(stakeholders);
|
return this.formalize(stakeholders);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getStakeholders(url: string, type: string = null, defaultId: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
|
getStakeholders(url: string, type: string = null, defaultId: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
|
||||||
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type) ? ('?type=' + type) : '') + ((!type && defaultId)? ('?defaultId=' + defaultId):''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
return this.http.get<Stakeholder[]>(url + '/stakeholder' + ((type) ? ('?type=' + type) : '') + ((!type && defaultId) ? ('?defaultId=' + defaultId) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
||||||
return this.formalize(this.checkIsUpload(stakeholders));
|
return this.formalize(this.checkIsUpload(stakeholders));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getMyStakeholders(url: string, type: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
|
getMyStakeholders(url: string, type: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
|
||||||
return this.http.get<Stakeholder[]>(url + '/my-stakeholder' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
return this.http.get<Stakeholder[]>(url + '/my-stakeholder' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
||||||
return this.formalize(this.checkIsUpload(stakeholders));
|
return this.formalize(this.checkIsUpload(stakeholders));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
|
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
|
||||||
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
|
||||||
return this.formalize(this.checkIsUpload(stakeholders));
|
return this.formalize(this.checkIsUpload(stakeholders));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
buildStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
|
buildStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
|
||||||
if(stakeholder.alias && stakeholder.alias.startsWith('/')) {
|
if (stakeholder.alias && stakeholder.alias.startsWith('/')) {
|
||||||
stakeholder.alias = stakeholder.alias.slice(1);
|
stakeholder.alias = stakeholder.alias.slice(1);
|
||||||
}
|
}
|
||||||
return this.http.post<Stakeholder>(url + '/build-stakeholder', stakeholder, CustomOptions.registryOptions()).pipe(map(stakeholder => {
|
return this.http.post<Stakeholder>(url + '/build-stakeholder', stakeholder, CustomOptions.registryOptions()).pipe(map(stakeholder => {
|
||||||
return this.formalize(this.checkIsUpload(stakeholder));
|
return this.formalize(this.checkIsUpload(stakeholder));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
changeVisibility(url: string, path: string[], visibility: Visibility, propagate: boolean = false): Observable<any> {
|
changeVisibility(url: string, path: string[], visibility: Visibility, propagate: boolean = false): Observable<any> {
|
||||||
return this.http.post<Visibility>(url + '/' + path.join('/') + '/change-visibility' + '?visibility=' + visibility + (propagate?'&propagate=true':''), null, CustomOptions.registryOptions());
|
return this.http.post<Visibility>(url + '/' + path.join('/') + '/change-visibility' + '?visibility=' + visibility + (propagate ? '&propagate=true' : ''), null, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
saveElement(url: string, element: any, path: string[] = []): Observable<any> {
|
saveElement(url: string, element: any, path: string[] = []): Observable<any> {
|
||||||
if(element.alias && element.alias.startsWith('/')) {
|
if (element.alias && element.alias.startsWith('/')) {
|
||||||
element.alias = element.alias.slice(1);
|
element.alias = element.alias.slice(1);
|
||||||
}
|
}
|
||||||
path = HelperFunctions.encodeArray(path);
|
path = HelperFunctions.encodeArray(path);
|
||||||
return this.http.post<any>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
return this.http.post<any>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
||||||
'/save', element, CustomOptions.registryOptions()).pipe(map(element => {
|
'/save', element, CustomOptions.registryOptions()).pipe(map(element => {
|
||||||
if(path.length === 0) {
|
if (path.length === 0) {
|
||||||
return this.formalize(this.checkIsUpload(element));
|
|
||||||
} else {
|
|
||||||
return this.formalize(element);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
saveBulkElements(url: string, indicators, path: string[] = []): Observable<any> {
|
|
||||||
path = HelperFunctions.encodeArray(path);
|
|
||||||
return this.http.post<any>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
|
||||||
'/save-bulk', indicators, CustomOptions.registryOptions()).pipe(map(element => {
|
|
||||||
if(path.length === 0) {
|
|
||||||
return this.formalize(this.checkIsUpload(element));
|
return this.formalize(this.checkIsUpload(element));
|
||||||
} else {
|
} else {
|
||||||
return this.formalize(element);
|
return this.formalize(element);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveBulkElements(url: string, indicators, path: string[] = []): Observable<any> {
|
||||||
|
path = HelperFunctions.encodeArray(path);
|
||||||
|
return this.http.post<any>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
||||||
|
'/save-bulk', indicators, CustomOptions.registryOptions()).pipe(map(element => {
|
||||||
|
if (path.length === 0) {
|
||||||
|
return this.formalize(this.checkIsUpload(element));
|
||||||
|
} else {
|
||||||
|
return this.formalize(element);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
saveSection(url: string, element: any, path: string[] = [], index: number = -1): Observable<Section> {
|
saveSection(url: string, element: any, path: string[] = [], index: number = -1): Observable<Section> {
|
||||||
path = HelperFunctions.encodeArray(path);
|
path = HelperFunctions.encodeArray(path);
|
||||||
return this.http.post<Section>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
return this.http.post<Section>(url + ((path.length > 0) ? '/' : '') + path.join('/') +
|
||||||
|
@ -135,7 +134,7 @@ export class StakeholderService {
|
||||||
return this.formalize(element);
|
return this.formalize(element);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteElement(url: string, path: string[], childrenAction: string = null): Observable<any> {
|
deleteElement(url: string, path: string[], childrenAction: string = null): Observable<any> {
|
||||||
path = HelperFunctions.encodeArray(path);
|
path = HelperFunctions.encodeArray(path);
|
||||||
let params: string = "";
|
let params: string = "";
|
||||||
|
@ -144,29 +143,29 @@ export class StakeholderService {
|
||||||
}
|
}
|
||||||
return this.http.delete<any>(url + '/' + path.join('/') + '/delete' + params, CustomOptions.registryOptions());
|
return this.http.delete<any>(url + '/' + path.join('/') + '/delete' + params, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
reorderElements(url: string, path: string[], ids: string[]): Observable<any> {
|
reorderElements(url: string, path: string[], ids: string[]): Observable<any> {
|
||||||
path = HelperFunctions.encodeArray(path);
|
path = HelperFunctions.encodeArray(path);
|
||||||
return this.http.post<any>(url + '/' + path.join('/') + '/reorder', ids, CustomOptions.registryOptions());
|
return this.http.post<any>(url + '/' + path.join('/') + '/reorder', ids, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
reorderIndicators(url: string, path: string[], reorder: Reorder, type: string = 'chart'): Observable<Indicator[]> {
|
reorderIndicators(url: string, path: string[], reorder: Reorder, type: string = 'chart'): Observable<Indicator[]> {
|
||||||
path = HelperFunctions.encodeArray(path);
|
path = HelperFunctions.encodeArray(path);
|
||||||
return this.http.post<Indicator[]>(url + '/' + path.join('/') + '/' + type + '/reorder', reorder, CustomOptions.registryOptions()).pipe(map(indicators => {
|
return this.http.post<Indicator[]>(url + '/' + path.join('/') + '/' + type + '/reorder', reorder, CustomOptions.registryOptions()).pipe(map(indicators => {
|
||||||
return this.formalize(indicators);
|
return this.formalize(indicators);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getStakeholderAsObservable(): Observable<Stakeholder> {
|
getStakeholderAsObservable(): Observable<Stakeholder> {
|
||||||
return this.stakeholderSubject.asObservable();
|
return this.stakeholderSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStakeholder(stakeholder: Stakeholder) {
|
setStakeholder(stakeholder: Stakeholder) {
|
||||||
this.stakeholderSubject.next(stakeholder);
|
this.stakeholderSubject.next(stakeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkIsUpload(response: Stakeholder | Stakeholder[]): any | any[] {
|
private checkIsUpload(response: Stakeholder | Stakeholder[]): any | any[] {
|
||||||
if(Array.isArray(response)) {
|
if (Array.isArray(response)) {
|
||||||
response.forEach(value => {
|
response.forEach(value => {
|
||||||
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
|
value.isUpload = value.logoUrl && !StringUtils.isValidUrl(value.logoUrl);
|
||||||
});
|
});
|
||||||
|
@ -175,7 +174,7 @@ export class StakeholderService {
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private formalize(element: any) {
|
private formalize(element: any) {
|
||||||
return HelperFunctions.copy(element);
|
return HelperFunctions.copy(element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue