Skip to content

Commit

Permalink
Route Templates in Topology
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed Nov 26, 2024
1 parent c45930d commit 87d8f1d
Show file tree
Hide file tree
Showing 30 changed files with 17,729 additions and 368 deletions.
9,557 changes: 9,557 additions & 0 deletions karavan-app/src/main/webui/package-lock.json

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions karavan-core/src/core/api/TopologyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
PatchDefinition,
PostDefinition,
PutDefinition,
RestDefinition, RouteConfigurationDefinition, RouteDefinition, SagaDefinition,
RestDefinition, RouteConfigurationDefinition, RouteDefinition, RouteTemplateDefinition, SagaDefinition,
} from '../model/CamelDefinition';
import {
CamelElement,
Expand Down Expand Up @@ -174,6 +174,17 @@ export class TopologyUtils {
return new TopologyIncomingNode(id, type, connectorType, r.id, title, filename, r.from, uniqueUri);
}) || [];
result.push(...routeElements);
const templates = i.spec.flows?.filter(flow => flow.dslName === 'RouteTemplateDefinition');
const templateElements = templates?.map(t => {
const r = t.route;
const id = 'incoming-' + r.id;
const title = CamelDisplayUtil.getStepDescription(r.from);
const type = TopologyUtils.isElementInternalComponent(r.from) ? 'internal' : 'external';
const connectorType = TopologyUtils.getConnectorType(r.from);
const uniqueUri = TopologyUtils.getUniqueUri(r.from);
return new TopologyIncomingNode(id, type, connectorType, r.id, title, filename, r.from, uniqueUri);
}) || [];
result.push(...templateElements);
} catch (e) {
console.error(e);
}
Expand All @@ -193,6 +204,14 @@ export class TopologyUtils {
return new TopologyRouteNode(id, r.id, title, filename, r.from, r);
}) || [];
result.push(...routeElements);
const templates = i.spec.flows?.filter(flow => flow.dslName === 'RouteTemplateDefinition');
const templateElements = templates?.map(t => {
const r = t.route;
const id = 'route-' + r.id;
const title = '' + (r.description ? r.description : r.id);
return new TopologyRouteNode(id, r.id, title, filename, r.from, r, t.id, t.description);
}) || [];
result.push(...templateElements);
} catch (e) {
console.error(e);
}
Expand Down Expand Up @@ -224,8 +243,9 @@ export class TopologyUtils {
integrations.forEach(i => {
try {
const filename = i.metadata.name;
const routes = i.spec.flows?.filter(flow => flow.dslName === 'RouteDefinition');
routes?.forEach(route => {
const routes = i.spec.flows?.filter(flow => flow.dslName === 'RouteDefinition') || [];
const routeFromTemplates = i.spec.flows?.filter(flow => flow.dslName === 'RouteTemplateDefinition').map(rt => rt.route) || [];
routes.concat(routeFromTemplates).forEach(route => {
const from: FromDefinition = route.from;
const elements = TopologyUtils.findOutgoingInStep(from, []);
elements.forEach((e: any) => {
Expand Down
6 changes: 5 additions & 1 deletion karavan-core/src/core/model/TopologyDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ export class TopologyRouteNode {
fileName: string;
from: FromDefinition;
route: RouteDefinition
templateId?: string
templateTitle?: string

constructor(id: string, routeId: string, title: string, fileName: string, from: FromDefinition, route: RouteDefinition) {
constructor(id: string, routeId: string, title: string, fileName: string, from: FromDefinition, route: RouteDefinition, templateId?: string, templateTitle?: string) {
this.id = id;
this.routeId = routeId;
this.title = title;
this.fileName = fileName;
this.from = from;
this.route = route;
this.templateId = templateId;
this.templateTitle = templateTitle;
}
}

Expand Down
Loading

0 comments on commit 87d8f1d

Please sign in to comment.