commit template changes
This commit is contained in:
@@ -17,6 +17,8 @@ export interface DocumentLayout {
|
||||
height: number;
|
||||
confidence: number;
|
||||
sequence_no: number;
|
||||
page_width: number;
|
||||
page_height: number;
|
||||
}
|
||||
|
||||
export interface TemplateField {
|
||||
@@ -66,7 +68,9 @@ export class TemplateService {
|
||||
width: tb.width,
|
||||
height: tb.height,
|
||||
confidence: tb.confidence || 0,
|
||||
sequence_no: tb.sequence || 0
|
||||
sequence_no: tb.sequence || 0,
|
||||
page_width: page.width || 1000,
|
||||
page_height: page.height || 1000
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,9 +25,18 @@
|
||||
<p>Upload a document to view its extracted layout structure.</p>
|
||||
</div>
|
||||
|
||||
<div *ngFor="let node of layoutNodes" cdkDrag class="layout-node" [ngClass]="node.block_type.toLowerCase()">
|
||||
<div class="node-type">{{ node.block_type }}</div>
|
||||
<div class="node-text">{{ node.text_value }}</div>
|
||||
<div class="document-canvas" [style.aspect-ratio]="pageWidth + ' / ' + pageHeight">
|
||||
<div *ngFor="let node of layoutNodes"
|
||||
cdkDrag
|
||||
class="layout-node"
|
||||
[ngClass]="node.block_type.toLowerCase()"
|
||||
[style.left.%]="(node.x_coordinate / node.page_width) * 100"
|
||||
[style.top.%]="(node.y_coordinate / node.page_height) * 100"
|
||||
[style.width.%]="(node.width / node.page_width) * 100"
|
||||
[style.height.%]="(node.height / node.page_height) * 100">
|
||||
<div class="node-type" *ngIf="node.height > 20">{{ node.block_type }}</div>
|
||||
<div class="node-text">{{ node.text_value }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -47,19 +47,33 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.document-canvas {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
background: white;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Draggable Nodes */
|
||||
.layout-node {
|
||||
padding: 0.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
background: white;
|
||||
position: absolute;
|
||||
padding: 0.1rem;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid var(--surface-border);
|
||||
border-left: 4px solid var(--primary-color);
|
||||
border-radius: 4px;
|
||||
border-radius: 2px;
|
||||
cursor: grab;
|
||||
transition: box-shadow 0.2s;
|
||||
transition: box-shadow 0.2s, border-color 0.2s;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
||||
z-index: 10;
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
&:active {
|
||||
@@ -67,25 +81,32 @@
|
||||
}
|
||||
|
||||
.node-type {
|
||||
font-size: 0.7rem;
|
||||
font-size: 0.5rem;
|
||||
color: var(--text-color-secondary);
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.25rem;
|
||||
margin-bottom: 0.1rem;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.node-text {
|
||||
font-size: 0.9rem;
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-color);
|
||||
word-break: break-word;
|
||||
line-height: 1.1;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* Color coding by block type */
|
||||
&.header { border-left-color: #3B82F6; }
|
||||
&.vendor { border-left-color: #8B5CF6; }
|
||||
&.table_header { border-left-color: #F59E0B; }
|
||||
&.total { border-left-color: #10B981; }
|
||||
&.tax { border-left-color: #EF4444; }
|
||||
/* Color coding by block type - use borders now instead of thick left border */
|
||||
&.header { border-color: #3B82F6; }
|
||||
&.vendor { border-color: #8B5CF6; }
|
||||
&.table_header { border-color: #F59E0B; }
|
||||
&.total { border-color: #10B981; }
|
||||
&.tax { border-color: #EF4444; }
|
||||
}
|
||||
|
||||
/* Template Mapping Side */
|
||||
|
||||
@@ -36,6 +36,8 @@ export class TemplatesComponent implements OnInit {
|
||||
// Document State
|
||||
documentId: string | null = null;
|
||||
layoutNodes: DocumentLayout[] = [];
|
||||
pageWidth: number = 800;
|
||||
pageHeight: number = 1100;
|
||||
|
||||
// Template State
|
||||
templateName: string = '';
|
||||
@@ -88,6 +90,10 @@ export class TemplatesComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
this.layoutNodes = layouts;
|
||||
if (layouts.length > 0) {
|
||||
this.pageWidth = layouts[0].page_width;
|
||||
this.pageHeight = layouts[0].page_height;
|
||||
}
|
||||
// Trigger auto-recognition
|
||||
this.autoRecognize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user