import {Component, OnInit, AfterViewInit, Directive, ElementRef, Renderer2} from '@angular/core';
+import {OrgService} from '@eg/core/org.service';
+import {AuthService} from '@eg/core/auth.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {Router} from '@angular/router';
constructor(
private renderer: Renderer2,
private pcrud: PcrudService,
+ private auth: AuthService,
+ private org: OrgService,
private router: Router
) {}
ngOnInit() {
const tmpPortalEntries: any[][] = [];
- this.pcrud.search('cusppe', {owner: 1}).subscribe(
+ const wsAncestors = this.org.ancestors(this.auth.user().ws_ou(), true);
+ this.pcrud.search('cusppe', {owner: wsAncestors}).subscribe(
item => {
const page_col = item.page_col();
if (tmpPortalEntries[page_col] === undefined) {
},
err => {},
() => {
+ // find the first set of entries belonging to the
+ // workstation OU or one of its ancestors
+ var filteredPortalEntries: any[][] = [];
+ var foundMatch = false;
+ for (let ou of wsAncestors) {
+ tmpPortalEntries.forEach((col) => {
+ if (col !== undefined) {
+ const filtered = col.filter(x => x !== undefined)
+ .filter(x => ou === x.owner());
+ if (filtered.length) {
+ foundMatch = true;
+ filteredPortalEntries.push(filtered);
+ }
+ }
+ });
+ if (foundMatch) {
+ break;
+ } else {
+ filteredPortalEntries = [];
+ }
+ }
+
// munge the results so that we don't need to
// care if there are gaps in the page_col or col_pos
// sequences
- tmpPortalEntries.forEach((col) => {
+ filteredPortalEntries.forEach((col) => {
if (col !== undefined) {
const filtered = col.filter(x => x !== undefined);
this.portalEntries.push(filtered);