Skip to content

Commit

Permalink
add breadcrumbs to agent component
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Aug 6, 2024
1 parent ff44cf5 commit 3303438
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<ng-container *ngIf="data$ | async as data">
<lc-breadcrumb [breadcrumbs]="getBreadcrumbs(data)"></lc-breadcrumb>

<ng-container *ngIf="data.agentDescription as agentDescription">
<h1 class="mb-4">
<lc-icon [icon]="dataIcons.person" />
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/app/data-entry/agent-form/agent-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Breadcrumb } from '@shared/breadcrumb/breadcrumb.component';
import { dataIcons } from '@shared/icons';
import { DataEntryAgentGQL, DataEntryAgentQuery } from 'generated/graphql';
import { map, Observable, switchMap } from 'rxjs';
Expand All @@ -24,4 +25,27 @@ export class AgentFormComponent {
map(result => result.data),
);
}

getBreadcrumbs(data: DataEntryAgentQuery): Breadcrumb[] {
if (data.agentDescription) {
return [
{ link: '/', label: 'Lettercraft' },
{ link: '/data-entry', label: 'Data entry' },
{
link: `/data-entry/sources/${data.agentDescription.source.id}`,
label: data.agentDescription.source.name
},
{
link: `/data-entry/agents/${data.agentDescription.id}`,
label: data.agentDescription.name
},
];
} else {
return [
{ link: '/', label: 'Lettercraft' },
{ link: '/data-entry', label: 'Data entry' },
{ link: '', label: 'Agent not found' }
]
}
}
}

0 comments on commit 3303438

Please sign in to comment.