added hierarchy parent component
This commit is contained in:
@@ -1 +1,50 @@
|
||||
<p>hierarchy works!</p>
|
||||
<div class="content">
|
||||
<h6>Organizationsstruktur</h6>
|
||||
<mat-accordion multi>
|
||||
<mat-expansion-panel
|
||||
[expanded]="hierarchyExpanded()"
|
||||
(expandedChange)="onHierarchyExpandedChange($event)"
|
||||
class="mat-elevation-z1">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Hierarchie</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<app-hierarchy-chart
|
||||
[hierarchyData]="hierarchyData()"
|
||||
(analyzeOrgEvent)="analyzeOrg($event)" />
|
||||
</mat-expansion-panel>
|
||||
@if (classifiedBuckets() && orgminerContent() && orgminerContent()?.uri) {
|
||||
<mat-expansion-panel
|
||||
[expanded]="organizationExpanded()"
|
||||
(expandedChange)="onOrganizationExpandedChange($event)"
|
||||
class="mat-elevation-z1">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>{{ orgName() }}</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
|
||||
@if (orgminerContent()) {
|
||||
<app-orgminer-content
|
||||
[orgName]="orgName()"
|
||||
[data]="orgminerContent()"></app-orgminer-content>
|
||||
} @else {
|
||||
<div class="ucs-info">
|
||||
<mat-icon>info</mat-icon>
|
||||
<span>Keine Organisation ausgewählt.</span>
|
||||
</div>
|
||||
}
|
||||
</mat-expansion-panel>
|
||||
<mat-expansion-panel
|
||||
[expanded]="classifiedPagesExpanded()"
|
||||
(expandedChange)="onClassifiedPagesExpandedChange($event)"
|
||||
class="mat-elevation-z1">
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>
|
||||
Klassifizierte Seiten: {{ totalPagesClassified() }} URLs
|
||||
</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<app-classified-pages
|
||||
[orgUrl]="orgminerContent()?.uri ?? ''"
|
||||
[buckets]="classifiedBuckets() ?? []"></app-classified-pages>
|
||||
</mat-expansion-panel>
|
||||
}
|
||||
</mat-accordion>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
mat-expansion-panel {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-none);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
mat-expansion-panel-header {
|
||||
padding: 0 16px;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
mat-panel-title {
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
mat-panel-description {
|
||||
font-size: 14px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
app-hierarchy-chart {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,161 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
DestroyRef,
|
||||
inject,
|
||||
input,
|
||||
OnInit,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { HierarchyChartComponent } from './hierarchy-chart/hierarchy-chart.component';
|
||||
import { OrgminerService } from '../../api/api/orgminer.service';
|
||||
import { OrgminerContentComponent } from './orgminer-content/orgminer-content.component';
|
||||
import { OrgminerContent } from '../../api/model/orgminerContent';
|
||||
import { ClassifiedPagesComponent } from './classified-pages/classified-pages.component';
|
||||
import { CategoryBucket } from '../../api/model/categoryBucket';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
const ORGANIZATION_URL_PARAM = 'orgUrl';
|
||||
const ORGANIZATION_NAME_PARAM = 'orgName';
|
||||
const ORGMINER_EXPANDED_PARAM = 'orgExpanded';
|
||||
const ORGMINER_SELECTION_CATEGORY_PARAM = 'orgSelectionCategory';
|
||||
const ORGMINER_SELECTION_INDEX_PARAM = 'orgSelectionIndex';
|
||||
const CLASSIFIED_CATEGORY_PARAM = 'classifiedCategory';
|
||||
const CLASSIFIED_PAGE_PARAM = 'classifiedPage';
|
||||
const HIERARCHY_PANEL_PARAM = 'hierarchyExpanded';
|
||||
const ORGANIZATION_PANEL_PARAM = 'organizationExpanded';
|
||||
const CLASSIFIED_PAGES_PANEL_PARAM = 'classifiedPagesExpanded';
|
||||
|
||||
@Component({
|
||||
selector: 'app-hierarchy',
|
||||
imports: [],
|
||||
imports: [
|
||||
HierarchyChartComponent,
|
||||
OrgminerContentComponent,
|
||||
ClassifiedPagesComponent,
|
||||
MatExpansionModule,
|
||||
MatIconModule,
|
||||
],
|
||||
templateUrl: './hierarchy.component.html',
|
||||
styleUrl: './hierarchy.component.scss',
|
||||
})
|
||||
export class HierarchyComponent {
|
||||
export class HierarchyComponent implements OnInit {
|
||||
hierarchyData = input.required();
|
||||
hierarchyExpanded = signal(true);
|
||||
organizationExpanded = signal(true);
|
||||
classifiedPagesExpanded = signal(false);
|
||||
orgminerContent = signal<OrgminerContent | null>(null);
|
||||
orgName = signal<string | null>(null);
|
||||
classifiedBuckets = signal<CategoryBucket[] | null>(null);
|
||||
orgminerService = inject(OrgminerService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private isOwnNavigation = false;
|
||||
totalPagesClassified = computed(
|
||||
() => this.classifiedBuckets()?.reduce((sum, b) => sum + b.count, 0) ?? 0,
|
||||
);
|
||||
ngOnInit(): void {
|
||||
this.route.queryParamMap
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((params) => {
|
||||
if (this.isOwnNavigation) {
|
||||
this.isOwnNavigation = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const organizationUrl = params.get(ORGANIZATION_URL_PARAM);
|
||||
this.hierarchyExpanded.set(
|
||||
this.readBooleanParam(params.get(HIERARCHY_PANEL_PARAM), true),
|
||||
);
|
||||
this.organizationExpanded.set(
|
||||
this.readBooleanParam(params.get(ORGANIZATION_PANEL_PARAM), true),
|
||||
);
|
||||
this.classifiedPagesExpanded.set(
|
||||
this.readBooleanParam(
|
||||
params.get(CLASSIFIED_PAGES_PANEL_PARAM),
|
||||
false,
|
||||
),
|
||||
);
|
||||
if (organizationUrl) {
|
||||
this.loadOrganization({
|
||||
name: params.get(ORGANIZATION_NAME_PARAM) ?? 'Organisation',
|
||||
url: organizationUrl,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onHierarchyExpandedChange(expanded: boolean): void {
|
||||
this.hierarchyExpanded.set(expanded);
|
||||
this.syncPanelState({ [HIERARCHY_PANEL_PARAM]: expanded });
|
||||
}
|
||||
|
||||
onOrganizationExpandedChange(expanded: boolean): void {
|
||||
this.organizationExpanded.set(expanded);
|
||||
this.syncPanelState({ [ORGANIZATION_PANEL_PARAM]: expanded });
|
||||
}
|
||||
|
||||
onClassifiedPagesExpandedChange(expanded: boolean): void {
|
||||
this.classifiedPagesExpanded.set(expanded);
|
||||
this.syncPanelState({ [CLASSIFIED_PAGES_PANEL_PARAM]: expanded });
|
||||
}
|
||||
|
||||
analyzeOrg(org: { name: string; url: string }) {
|
||||
this.hierarchyExpanded.set(false);
|
||||
this.organizationExpanded.set(true);
|
||||
this.isOwnNavigation = true;
|
||||
this.router
|
||||
.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
[ORGANIZATION_URL_PARAM]: org.url,
|
||||
[ORGANIZATION_NAME_PARAM]: org.name,
|
||||
[ORGMINER_EXPANDED_PARAM]: null,
|
||||
[ORGMINER_SELECTION_CATEGORY_PARAM]: null,
|
||||
[ORGMINER_SELECTION_INDEX_PARAM]: null,
|
||||
[CLASSIFIED_CATEGORY_PARAM]: null,
|
||||
[CLASSIFIED_PAGE_PARAM]: null,
|
||||
[HIERARCHY_PANEL_PARAM]: false,
|
||||
[ORGANIZATION_PANEL_PARAM]: true,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
})
|
||||
.then((navigated) => {
|
||||
if (!navigated) this.isOwnNavigation = false;
|
||||
});
|
||||
this.loadOrganization(org);
|
||||
}
|
||||
|
||||
private syncPanelState(queryParams: Record<string, boolean>): void {
|
||||
this.isOwnNavigation = true;
|
||||
this.router
|
||||
.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams,
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
})
|
||||
.then((navigated) => {
|
||||
if (!navigated) this.isOwnNavigation = false;
|
||||
});
|
||||
}
|
||||
|
||||
private readBooleanParam(value: string | null, fallback: boolean): boolean {
|
||||
return value === null ? fallback : value === 'true';
|
||||
}
|
||||
|
||||
private loadOrganization(org: { name: string; url: string }) {
|
||||
console.log('Analyze organization event triggered', org.url);
|
||||
this.orgName.set(org.name);
|
||||
this.orgminerService.getOrgminerContent(org.url).subscribe((data) => {
|
||||
console.log('Orgminer content:', data);
|
||||
this.orgminerContent.set(data);
|
||||
});
|
||||
this.orgminerService.getClassifiedPagesAggs(org.url).subscribe((data) => {
|
||||
this.classifiedBuckets.set(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user