-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathchart-edit.component.html
More file actions
165 lines (148 loc) · 7.67 KB
/
Copy pathchart-edit.component.html
File metadata and controls
165 lines (148 loc) · 7.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<app-alert></app-alert>
<div class="chart-edit-page">
<div class="chart-edit-header">
<button mat-icon-button (click)="cancel()" matTooltip="Back to list">
<mat-icon>arrow_back</mat-icon>
</button>
<h1 class="mat-h1">{{ isEditMode() ? 'Edit Saved Query' : 'Create Saved Query' }}</h1>
</div>
<div *ngIf="loading()" class="loading-container">
<mat-spinner diameter="40"></mat-spinner>
</div>
<div *ngIf="!loading()" class="chart-edit-content">
<div class="query-details">
<mat-form-field appearance="outline" class="name-field">
<mat-label>Query Name</mat-label>
<input matInput
[ngModel]="queryName()"
(ngModelChange)="queryName.set($event)"
placeholder="Enter a name for this query"
data-testid="query-name-input"
required>
</mat-form-field>
<mat-form-field appearance="outline" class="description-field">
<mat-label>Description (optional)</mat-label>
<input matInput
[ngModel]="queryDescription()"
(ngModelChange)="queryDescription.set($event)"
placeholder="Add a description"
data-testid="query-description-input">
</mat-form-field>
</div>
<div class="editor-preview-container">
<div class="editor-section">
<div class="section-header">
<h3>SQL Query</h3>
<button mat-stroked-button
(click)="testQuery()"
[disabled]="!canTest()"
data-testid="test-query-button">
<mat-icon *ngIf="!testing()">play_arrow</mat-icon>
<mat-spinner *ngIf="testing()" diameter="18"></mat-spinner>
{{ testing() ? 'Testing...' : 'Test Query' }}
</button>
</div>
<div class="code-editor-box" data-hj-suppress>
<ngs-code-editor
[theme]="codeEditorTheme"
[codeModel]="codeModel()"
[options]="codeEditorOptions"
(valueChanged)="onCodeChange($event)">
</ngs-code-editor>
</div>
</div>
<div class="right-panel" *ngIf="showResults()">
<div class="config-section">
<div class="section-header">
<h3>Chart Configuration</h3>
<span class="execution-time" *ngIf="executionTime() !== null">
Executed in {{ executionTime() }}ms
</span>
</div>
<div class="chart-config">
<mat-form-field appearance="outline" class="chart-config-field">
<mat-label>Chart Type</mat-label>
<mat-select [ngModel]="chartType()" (ngModelChange)="chartType.set($event)" data-testid="chart-type-select">
<mat-option *ngFor="let type of chartTypes" [value]="type.value">
{{ type.label }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline" class="chart-config-field">
<mat-label>Label Column</mat-label>
<mat-select [ngModel]="labelColumn()" (ngModelChange)="labelColumn.set($event)" data-testid="label-column-select">
<mat-option *ngFor="let col of resultColumns()" [value]="col">
{{ col }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline" class="chart-config-field" *ngIf="showLabelTypeOption()">
<mat-label>Label Type</mat-label>
<mat-select [ngModel]="labelType()" (ngModelChange)="labelType.set($event)" data-testid="label-type-select">
<mat-option *ngFor="let type of labelTypes" [value]="type.value">
{{ type.label }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline" class="chart-config-field">
<mat-label>Value Column</mat-label>
<mat-select [ngModel]="valueColumn()" (ngModelChange)="valueColumn.set($event)" data-testid="value-column-select">
<mat-option *ngFor="let col of resultColumns()" [value]="col">
{{ col }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<div class="preview-section">
<div class="section-header">
<h3>Chart Preview</h3>
</div>
<div class="chart-container" *ngIf="hasChartData()">
<app-chart-preview
[chartType]="chartType()"
[data]="testResults()"
[labelColumn]="labelColumn()"
[valueColumn]="valueColumn()"
[labelType]="labelType()">
</app-chart-preview>
</div>
<div class="no-chart-data" *ngIf="!hasChartData() && testResults().length > 0">
<p>Select label and value columns to display the chart</p>
</div>
</div>
</div>
</div>
<div class="results-section" *ngIf="showResults() && testResults().length > 0">
<div class="section-header">
<h3>Query Results ({{ testResults().length }} rows)</h3>
</div>
<div class="results-table-container">
<table mat-table [dataSource]="testResults()" class="results-table mat-elevation-z1">
<ng-container *ngFor="let column of resultColumns()" [matColumnDef]="column">
<th mat-header-cell *matHeaderCellDef>{{ column }}</th>
<td mat-cell *matCellDef="let row">{{ row[column] }}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="resultColumns()"></tr>
<tr mat-row *matRowDef="let row; columns: resultColumns();"></tr>
</table>
</div>
</div>
<div class="no-results" *ngIf="showResults() && testResults().length === 0">
<mat-icon>info</mat-icon>
<p>Query executed successfully but returned no results.</p>
</div>
<div class="actions">
<button mat-button (click)="cancel()" data-testid="cancel-button">
Cancel
</button>
<button mat-flat-button color="primary"
(click)="saveQuery()"
[disabled]="!canSave()"
data-testid="save-query-button">
<mat-spinner *ngIf="saving()" diameter="18"></mat-spinner>
{{ saving() ? 'Saving...' : (isEditMode() ? 'Update Query' : 'Save Query') }}
</button>
</div>
</div>
</div>