Skip to content

Commit

Permalink
dct: add title
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Nov 6, 2023
1 parent 8a74e67 commit 6ef54fa
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/app/dct/dct.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const LS = {

interface ICertDagNode extends Node {
mark: boolean;
template?: string;
};
interface ICertDagEdge extends Edge {
mark: boolean;
Expand Down Expand Up @@ -81,6 +82,7 @@ export class DCTComponent implements OnInit, AfterViewInit {
const options = {
interaction: {
hover: true,
tooltipDelay: 0,
},
manipulation: {
enabled: false,
Expand Down Expand Up @@ -147,7 +149,8 @@ export class DCTComponent implements OnInit, AfterViewInit {

// Patterns in schemaCompile output
const REGEX = {
CHAIN: /chain \w+:(.*)/i
CHAIN: /chain \w+:(.*)/i,
TEMPLATE: /cert (\w+):(.*)/i,
}

// Mark all nodes and edges as unvisited
Expand All @@ -157,7 +160,7 @@ export class DCTComponent implements OnInit, AfterViewInit {
// Parse compiler output
for (const line of lines) {
// Signing chain
const match = line.match(REGEX.CHAIN);
let match = line.match(REGEX.CHAIN);
if (match) {
const chain = match[1].trim()
.split('<=')
Expand Down Expand Up @@ -200,11 +203,33 @@ export class DCTComponent implements OnInit, AfterViewInit {
}
continue;
}

// Certificate template
match = line.match(REGEX.TEMPLATE);
if (match) {
const certName = match[1].trim();
const template = match[2].trim();
const node = this.certDag.nodes.get(certName);
if (node) {
node.template = template;
}
continue;
}
}

// Clean up unvisited nodes and edges
for (const node of this.certDag.nodes.get())
if (!node.mark) this.certDag.nodes.remove(node.id);
for (const node of this.certDag.nodes.get()) {
if (!node.mark) {
this.certDag.nodes.remove(node.id);
continue;
}

// Set extra info
if (node.template) {
node.title = node.template;
this.certDag.nodes.update(node);
}
}
for (const edge of this.certDag.edges.get())
if (!edge.mark) this.certDag.edges.remove(edge.id);

Expand Down

0 comments on commit 6ef54fa

Please sign in to comment.