Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82425d5377 | ||
|
|
2995328ec1 | ||
|
|
afc2c1f8a1 | ||
|
|
418b02acd7 | ||
|
|
cdd752469c |
@@ -79,12 +79,16 @@
|
|||||||
|
|
||||||
<!-- Multi-Select Filter -->
|
<!-- Multi-Select Filter -->
|
||||||
<div class="filter-control" *ngIf="filterType === 'multiselect'">
|
<div class="filter-control" *ngIf="filterType === 'multiselect'">
|
||||||
<select [(ngModel)]="filterValue"
|
<div class="compact-multiselect-checkboxes" style="max-height: 200px; overflow-y: auto; border: 1px solid #ddd; padding: 10px;">
|
||||||
(ngModelChange)="onFilterValueChange($event)"
|
<div *ngFor="let option of filterOptions" class="clr-checkbox-wrapper" style="margin-bottom: 5px;">
|
||||||
multiple
|
<input type="checkbox"
|
||||||
class="clr-select compact-multiselect">
|
[id]="'multiselect-' + option"
|
||||||
<option *ngFor="let option of filterOptions" [value]="option">{{ option }}</option>
|
[value]="option"
|
||||||
</select>
|
[checked]="isOptionSelected(option)"
|
||||||
|
(change)="onMultiselectOptionChange($event, option)">
|
||||||
|
<label [for]="'multiselect-' + option" class="clr-control-label">{{ option }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Date Range Filter -->
|
<!-- Date Range Filter -->
|
||||||
|
|||||||
@@ -331,4 +331,48 @@ export class CompactFilterComponent implements OnInit, OnChanges {
|
|||||||
this.loadAvailableValues(this.configFilterKey);
|
this.loadAvailableValues(this.configFilterKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add method to check if an option is selected for checkboxes
|
||||||
|
isOptionSelected(option: string): boolean {
|
||||||
|
if (!this.filterValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure filterValue is an array for multiselect
|
||||||
|
if (!Array.isArray(this.filterValue)) {
|
||||||
|
this.filterValue = [];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.filterValue.includes(option);
|
||||||
|
}
|
||||||
|
// need to check this
|
||||||
|
// Add method to handle multiselect option change
|
||||||
|
onMultiselectOptionChange(event: any, option: string): void {
|
||||||
|
// Initialize filterValue array if it doesn't exist
|
||||||
|
if (!this.filterValue) {
|
||||||
|
this.filterValue = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure filterValue is an array
|
||||||
|
if (!Array.isArray(this.filterValue)) {
|
||||||
|
this.filterValue = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.target.checked) {
|
||||||
|
// Add option if not already in array
|
||||||
|
if (!this.filterValue.includes(option)) {
|
||||||
|
this.filterValue.push(option);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Remove option from array
|
||||||
|
const index = this.filterValue.indexOf(option);
|
||||||
|
if (index > -1) {
|
||||||
|
this.filterValue.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit the change event
|
||||||
|
this.onFilterValueChange(this.filterValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,12 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
public entryForm: FormGroup;
|
public entryForm: FormGroup;
|
||||||
public commonFilterForm: FormGroup; // Add common filter form
|
public commonFilterForm: FormGroup; // Add common filter form
|
||||||
|
|
||||||
|
// Add filterOptionsString property for compact filter
|
||||||
|
filterOptionsString: string = '';
|
||||||
|
|
||||||
|
// Add availableKeys property for compact filter
|
||||||
|
availableKeys: string[] = [];
|
||||||
|
|
||||||
WidgetsMock: WidgetModel[] = [
|
WidgetsMock: WidgetModel[] = [
|
||||||
{
|
{
|
||||||
name: 'Common Filter',
|
name: 'Common Filter',
|
||||||
@@ -360,6 +366,16 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
dashboard.component = component.componentInstance;
|
dashboard.component = component.componentInstance;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure compact filter configuration properties are properly initialized
|
||||||
|
if (dashboard.component === 'Compact Filter' || dashboard.name === 'Compact Filter') {
|
||||||
|
// Make sure all compact filter properties exist
|
||||||
|
if (dashboard.filterKey === undefined) dashboard.filterKey = '';
|
||||||
|
if (dashboard.filterType === undefined) dashboard.filterType = 'text';
|
||||||
|
if (dashboard.filterLabel === undefined) dashboard.filterLabel = '';
|
||||||
|
if (dashboard.filterOptions === undefined) dashboard.filterOptions = [];
|
||||||
|
// table and connection properties should already exist for all components
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,6 +390,16 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
dashboard.component = component.name;
|
dashboard.component = component.name;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure compact filter configuration properties are preserved
|
||||||
|
if (dashboard.name === 'Compact Filter') {
|
||||||
|
// Make sure all compact filter properties exist
|
||||||
|
if (dashboard.filterKey === undefined) dashboard.filterKey = '';
|
||||||
|
if (dashboard.filterType === undefined) dashboard.filterType = 'text';
|
||||||
|
if (dashboard.filterLabel === undefined) dashboard.filterLabel = '';
|
||||||
|
if (dashboard.filterOptions === undefined) dashboard.filterOptions = [];
|
||||||
|
// table and connection properties should already exist for all components
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Add method to get available fields for a filter dropdown (excluding already selected fields)
|
// Add method to get available fields for a filter dropdown (excluding already selected fields)
|
||||||
@@ -601,6 +627,18 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
if (item['filterOptions'] === undefined) {
|
if (item['filterOptions'] === undefined) {
|
||||||
this.gadgetsEditdata['filterOptions'] = [];
|
this.gadgetsEditdata['filterOptions'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize filterOptionsString for compact filter
|
||||||
|
if (item.name === 'Compact Filter') {
|
||||||
|
this.filterOptionsString = this.gadgetsEditdata['filterOptions'].join(', ');
|
||||||
|
// Load available keys when editing a compact filter
|
||||||
|
if (this.gadgetsEditdata['table']) {
|
||||||
|
this.loadAvailableKeys(this.gadgetsEditdata['table'], this.gadgetsEditdata['connection']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.filterOptionsString = '';
|
||||||
|
}
|
||||||
|
|
||||||
this.getStores();
|
this.getStores();
|
||||||
|
|
||||||
// Set default connection if none is set and we have connections
|
// Set default connection if none is set and we have connections
|
||||||
@@ -699,6 +737,9 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
|
|
||||||
//https://www.w3schools.com/js/tryit.asp?filename=tryjson_stringify_function_tostring
|
//https://www.w3schools.com/js/tryit.asp?filename=tryjson_stringify_function_tostring
|
||||||
|
|
||||||
|
// First serialize the dashboard collection to ensure component names are properly set
|
||||||
|
this.serialize(this.dashboardCollection.dashboard);
|
||||||
|
|
||||||
let cmp = this.dashboardCollection.dashboard.forEach(dashboard => {
|
let cmp = this.dashboardCollection.dashboard.forEach(dashboard => {
|
||||||
this.componentCollection.forEach(component => {
|
this.componentCollection.forEach(component => {
|
||||||
if (dashboard.name === component.name) {
|
if (dashboard.name === component.name) {
|
||||||
@@ -719,8 +760,6 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
//console.log(merged);
|
//console.log(merged);
|
||||||
console.log("temp data", typeof tmp);
|
console.log("temp data", typeof tmp);
|
||||||
console.log(tmp);
|
console.log(tmp);
|
||||||
let parsed = JSON.parse(tmp);
|
|
||||||
this.serialize(parsed.dashboard);
|
|
||||||
this.dashbord1_Line.model = tmp;
|
this.dashbord1_Line.model = tmp;
|
||||||
|
|
||||||
// let obj = this.dashboardCollection;
|
// let obj = this.dashboardCollection;
|
||||||
@@ -777,11 +816,16 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
xyz.commonFilterEnabled = this.gadgetsEditdata.commonFilterEnabled; // Add common filter property
|
xyz.commonFilterEnabled = this.gadgetsEditdata.commonFilterEnabled; // Add common filter property
|
||||||
|
|
||||||
// For compact filter, preserve filter configuration properties
|
// For compact filter, preserve filter configuration properties
|
||||||
if (item.component && item.component.name === 'CompactFilterComponent') {
|
if (item.name === 'Compact Filter') {
|
||||||
xyz.filterKey = this.gadgetsEditdata.filterKey || '';
|
xyz.filterKey = this.gadgetsEditdata.filterKey || '';
|
||||||
xyz.filterType = this.gadgetsEditdata.filterType || 'text';
|
xyz.filterType = this.gadgetsEditdata.filterType || 'text';
|
||||||
xyz.filterLabel = this.gadgetsEditdata.filterLabel || '';
|
xyz.filterLabel = this.gadgetsEditdata.filterLabel || '';
|
||||||
xyz.filterOptions = this.gadgetsEditdata.filterOptions || [];
|
// Convert filterOptionsString to array
|
||||||
|
if (this.gadgetsEditdata.fieldName === 'Compact Filter') {
|
||||||
|
xyz.filterOptions = this.filterOptionsString.split(',').map(opt => opt.trim()).filter(opt => opt);
|
||||||
|
} else {
|
||||||
|
xyz.filterOptions = this.gadgetsEditdata.filterOptions || [];
|
||||||
|
}
|
||||||
xyz.table = this.gadgetsEditdata.table || '';
|
xyz.table = this.gadgetsEditdata.table || '';
|
||||||
xyz.connection = this.gadgetsEditdata.connection || undefined;
|
xyz.connection = this.gadgetsEditdata.connection || undefined;
|
||||||
}
|
}
|
||||||
@@ -821,7 +865,7 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
getChartInputs(item: any): any {
|
getChartInputs(item: any): any {
|
||||||
// For CompactFilterComponent, pass only filter configuration properties
|
// For CompactFilterComponent, pass only filter configuration properties
|
||||||
if (item.component && item.component.name === 'CompactFilterComponent') {
|
if (item.name === 'Compact Filter') {
|
||||||
const filterInputs = {
|
const filterInputs = {
|
||||||
filterKey: item['filterKey'] || '',
|
filterKey: item['filterKey'] || '',
|
||||||
filterType: item['filterType'] || 'text',
|
filterType: item['filterType'] || 'text',
|
||||||
@@ -995,11 +1039,16 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
updatedItem.commonFilterEnabledDrilldown = this.gadgetsEditdata.commonFilterEnabledDrilldown; // Add drilldown common filter property
|
updatedItem.commonFilterEnabledDrilldown = this.gadgetsEditdata.commonFilterEnabledDrilldown; // Add drilldown common filter property
|
||||||
|
|
||||||
// For compact filter, preserve filter configuration properties
|
// For compact filter, preserve filter configuration properties
|
||||||
if (item.component && item.component.name === 'CompactFilterComponent') {
|
if (item.name === 'Compact Filter') {
|
||||||
updatedItem.filterKey = this.gadgetsEditdata.filterKey || '';
|
updatedItem.filterKey = this.gadgetsEditdata.filterKey || '';
|
||||||
updatedItem.filterType = this.gadgetsEditdata.filterType || 'text';
|
updatedItem.filterType = this.gadgetsEditdata.filterType || 'text';
|
||||||
updatedItem.filterLabel = this.gadgetsEditdata.filterLabel || '';
|
updatedItem.filterLabel = this.gadgetsEditdata.filterLabel || '';
|
||||||
updatedItem.filterOptions = this.gadgetsEditdata.filterOptions || [];
|
// Convert filterOptionsString to array
|
||||||
|
if (this.gadgetsEditdata.fieldName === 'Compact Filter') {
|
||||||
|
updatedItem.filterOptions = this.filterOptionsString.split(',').map(opt => opt.trim()).filter(opt => opt);
|
||||||
|
} else {
|
||||||
|
updatedItem.filterOptions = this.gadgetsEditdata.filterOptions || [];
|
||||||
|
}
|
||||||
updatedItem.table = this.gadgetsEditdata.table || ''; // API URL
|
updatedItem.table = this.gadgetsEditdata.table || ''; // API URL
|
||||||
updatedItem.connection = this.gadgetsEditdata.connection || undefined; // Connection ID
|
updatedItem.connection = this.gadgetsEditdata.connection || undefined; // Connection ID
|
||||||
|
|
||||||
@@ -1435,4 +1484,80 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
// This would require the chart component to have a public resize method
|
// This would require the chart component to have a public resize method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add method to load available keys for compact filter
|
||||||
|
loadAvailableKeys(apiUrl: string, connectionId: string | undefined) {
|
||||||
|
if (apiUrl) {
|
||||||
|
const connectionIdNum = connectionId ? parseInt(connectionId, 10) : undefined;
|
||||||
|
this.alertService.getColumnfromurl(apiUrl, connectionIdNum).subscribe(
|
||||||
|
(keys: string[]) => {
|
||||||
|
this.availableKeys = keys;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Error loading available keys:', error);
|
||||||
|
this.availableKeys = [];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to load available values for a specific key
|
||||||
|
loadAvailableValues(key: string) {
|
||||||
|
if (key && this.gadgetsEditdata['table']) {
|
||||||
|
const connectionIdNum = this.gadgetsEditdata['connection'] ?
|
||||||
|
parseInt(this.gadgetsEditdata['connection'], 10) : undefined;
|
||||||
|
this.alertService.getValuesFromUrl(this.gadgetsEditdata['table'], connectionIdNum, key).subscribe(
|
||||||
|
(values: string[]) => {
|
||||||
|
// Update filter options string for dropdown/multiselect
|
||||||
|
if (this.gadgetsEditdata['filterType'] === 'dropdown' ||
|
||||||
|
this.gadgetsEditdata['filterType'] === 'multiselect') {
|
||||||
|
this.filterOptionsString = values.join(', ');
|
||||||
|
// Also update the gadgetsEditdata filterOptions array
|
||||||
|
this.gadgetsEditdata['filterOptions'] = values;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
console.error('Error loading available values:', error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to handle filter key change
|
||||||
|
onFilterKeyChange(key: string) {
|
||||||
|
this.gadgetsEditdata['filterKey'] = key;
|
||||||
|
// Load available values when filter key changes
|
||||||
|
if (key && (this.gadgetsEditdata['filterType'] === 'dropdown' ||
|
||||||
|
this.gadgetsEditdata['filterType'] === 'multiselect')) {
|
||||||
|
this.loadAvailableValues(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to handle filter type change
|
||||||
|
onFilterTypeChange(type: string) {
|
||||||
|
this.gadgetsEditdata['filterType'] = type;
|
||||||
|
// Load available values when filter type changes to dropdown or multiselect
|
||||||
|
if ((type === 'dropdown' || type === 'multiselect') && this.gadgetsEditdata['filterKey']) {
|
||||||
|
this.loadAvailableValues(this.gadgetsEditdata['filterKey']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to handle API URL change for compact filter
|
||||||
|
onCompactFilterApiUrlChange(url: string) {
|
||||||
|
this.gadgetsEditdata['table'] = url;
|
||||||
|
// Load available keys when API URL changes
|
||||||
|
if (url) {
|
||||||
|
this.loadAvailableKeys(url, this.gadgetsEditdata['connection']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add method to handle connection change for compact filter
|
||||||
|
onCompactFilterConnectionChange(connectionId: string) {
|
||||||
|
this.gadgetsEditdata['connection'] = connectionId;
|
||||||
|
// Reload available keys when connection changes
|
||||||
|
if (this.gadgetsEditdata['table']) {
|
||||||
|
this.loadAvailableKeys(this.gadgetsEditdata['table'], connectionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,73 @@
|
|||||||
<!-- Display Mode - No configuration UI in runner -->
|
|
||||||
<div class="compact-filter">
|
<div class="compact-filter">
|
||||||
<div class="filter-header">
|
<div class="filter-header" (click)="toggleFilter()">
|
||||||
<span class="filter-label" *ngIf="filterLabel">{{ filterLabel }}</span>
|
<span class="filter-label" *ngIf="filterLabel">{{ filterLabel }}</span>
|
||||||
<span class="filter-key" *ngIf="!filterLabel && filterKey">{{ filterKey }}</span>
|
<span class="filter-key" *ngIf="!filterLabel && filterKey">{{ filterKey }}</span>
|
||||||
<span class="filter-type">({{ filterType }})</span>
|
<span class="filter-type">({{ filterType }})</span>
|
||||||
|
<clr-icon shape="caret down" class="expand-icon" *ngIf="!isExpanded"></clr-icon>
|
||||||
|
<clr-icon shape="caret up" class="expand-icon" *ngIf="isExpanded"></clr-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Text Filter -->
|
<div class="filter-content" *ngIf="isExpanded">
|
||||||
<div class="filter-control" *ngIf="filterType === 'text'">
|
<!-- Text Filter -->
|
||||||
<input type="text"
|
<div class="filter-control" *ngIf="filterType === 'text'">
|
||||||
[(ngModel)]="filterValue"
|
<input type="text"
|
||||||
(ngModelChange)="onFilterValueChange($event)"
|
[(ngModel)]="filterValue"
|
||||||
[placeholder]="filterLabel || filterKey"
|
(ngModelChange)="onFilterValueChange($event)"
|
||||||
class="clr-input compact-input">
|
[placeholder]="filterLabel || filterKey"
|
||||||
</div>
|
class="clr-input compact-input">
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Dropdown Filter -->
|
<!-- Dropdown Filter -->
|
||||||
<div class="filter-control" *ngIf="filterType === 'dropdown'">
|
<div class="filter-control" *ngIf="filterType === 'dropdown'">
|
||||||
<select [(ngModel)]="filterValue"
|
<select [(ngModel)]="filterValue"
|
||||||
(ngModelChange)="onFilterValueChange($event)"
|
(ngModelChange)="onFilterValueChange($event)"
|
||||||
class="clr-select compact-select">
|
class="clr-select compact-select">
|
||||||
<option value="">{{ filterLabel || filterKey }}</option>
|
<option value="">{{ filterLabel || filterKey }}</option>
|
||||||
<option *ngFor="let option of filterOptions" [value]="option">{{ option }}</option>
|
<option *ngFor="let option of filterOptions; let i = index" [value]="option">{{ option }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Multi-Select Filter -->
|
<!-- Multi-Select Filter -->
|
||||||
<div class="filter-control" *ngIf="filterType === 'multiselect'">
|
<div class="filter-control" *ngIf="filterType === 'multiselect'">
|
||||||
<div class="checkbox-group">
|
<div class="multiselect-container">
|
||||||
<div *ngFor="let option of filterOptions" class="checkbox-item">
|
<div class="checkbox-group">
|
||||||
<input type="checkbox"
|
<div *ngFor="let option of filterOptions; let i = index" class="checkbox-item">
|
||||||
[checked]="filterValue && filterValue.includes(option)"
|
<input type="checkbox"
|
||||||
(change)="onMultiSelectChange(option, $event)"
|
[checked]="isOptionSelected(option)"
|
||||||
[id]="'checkbox-' + option">
|
(change)="onMultiSelectChange(option, $event)"
|
||||||
<label [for]="'checkbox-' + option">{{ option }}</label>
|
[id]="'checkbox-' + filterKey + '-' + i"
|
||||||
|
class="clr-checkbox">
|
||||||
|
<label [for]="'checkbox-' + filterKey + '-' + i" class="checkbox-label">{{ option }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Date Range Filter -->
|
<!-- Date Range Filter -->
|
||||||
<div class="filter-control date-range" *ngIf="filterType === 'date-range'">
|
<div class="filter-control date-range" *ngIf="filterType === 'date-range'">
|
||||||
<input type="date"
|
<div class="date-input-group">
|
||||||
[(ngModel)]="filterValue.start"
|
<input type="date"
|
||||||
(ngModelChange)="onDateRangeChange({ start: $event, end: filterValue.end })"
|
[(ngModel)]="filterValue.start"
|
||||||
placeholder="Start Date"
|
(ngModelChange)="onDateRangeChange({ start: $event, end: filterValue.end })"
|
||||||
class="clr-input compact-date">
|
placeholder="Start Date"
|
||||||
<input type="date"
|
class="clr-input compact-date">
|
||||||
[(ngModel)]="filterValue.end"
|
<span class="date-separator">to</span>
|
||||||
(ngModelChange)="onDateRangeChange({ start: filterValue.start, end: $event })"
|
<input type="date"
|
||||||
placeholder="End Date"
|
[(ngModel)]="filterValue.end"
|
||||||
class="clr-input compact-date">
|
(ngModelChange)="onDateRangeChange({ start: filterValue.start, end: $event })"
|
||||||
</div>
|
placeholder="End Date"
|
||||||
|
class="clr-input compact-date">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Toggle Filter -->
|
<!-- Toggle Filter -->
|
||||||
<div class="filter-control toggle" *ngIf="filterType === 'toggle'">
|
<div class="filter-control toggle" *ngIf="filterType === 'toggle'">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
[(ngModel)]="filterValue"
|
[(ngModel)]="filterValue"
|
||||||
(ngModelChange)="onToggleChange($event)"
|
(ngModelChange)="onToggleChange($event)"
|
||||||
clrToggle
|
clrToggle
|
||||||
class="clr-toggle">
|
class="clr-toggle">
|
||||||
<label class="toggle-label">{{ filterLabel || filterKey }}</label>
|
<label class="toggle-label">{{ filterLabel || filterKey }}</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,74 +1,149 @@
|
|||||||
.compact-filter {
|
.compact-filter {
|
||||||
padding: 10px;
|
display: block;
|
||||||
border: 1px solid #ddd;
|
min-width: 200px;
|
||||||
|
max-width: 300px;
|
||||||
|
margin: 8px;
|
||||||
|
padding: 0;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 1px solid #d7d7d7;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
margin-bottom: 10px;
|
font-size: 14px;
|
||||||
background-color: #f8f8f8;
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
|
|
||||||
.filter-header {
|
.filter-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 10px;
|
padding: 12px 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
background: #f8f8f8;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
border-radius: 4px 4px 0 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
.filter-label, .filter-key {
|
.filter-label, .filter-key {
|
||||||
font-weight: bold;
|
font-weight: 500;
|
||||||
|
color: #333333;
|
||||||
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-type {
|
.filter-type {
|
||||||
font-size: 0.8em;
|
font-size: 12px;
|
||||||
color: #666;
|
color: #666666;
|
||||||
|
margin: 0 8px;
|
||||||
|
background: #eaeaea;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
color: #666666;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-control {
|
.filter-content {
|
||||||
margin-bottom: 10px;
|
padding: 15px;
|
||||||
|
|
||||||
.compact-input, .compact-select, .compact-date {
|
.filter-control {
|
||||||
width: 100%;
|
margin-bottom: 12px;
|
||||||
padding: 5px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.compact-multiselect {
|
&:last-child {
|
||||||
width: 100%;
|
margin-bottom: 0;
|
||||||
height: 100px;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-group {
|
&.date-range {
|
||||||
display: flex;
|
.date-input-group {
|
||||||
flex-direction: column;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
.checkbox-item {
|
.date-separator {
|
||||||
margin: 5px 0;
|
font-size: 14px;
|
||||||
|
color: #666666;
|
||||||
input[type="checkbox"] {
|
}
|
||||||
margin-right: 5px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&.date-range {
|
&.toggle {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
.compact-date {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.toggle {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.clr-toggle {
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-label {
|
|
||||||
margin: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.compact-input,
|
||||||
|
.compact-select,
|
||||||
|
.compact-date {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
border: 1px solid #d7d7d7;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #ffffff;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #0072ce;
|
||||||
|
box-shadow: 0 0 0 1px #0072ce;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-select {
|
||||||
|
height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.multiselect-container {
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
border: 1px solid #d7d7d7;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 10px;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
.clr-checkbox {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-label {
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-label {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clr-toggle {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Host styling
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -20,20 +20,24 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
availableFilters: Filter[] = [];
|
availableFilters: Filter[] = [];
|
||||||
availableKeys: string[] = [];
|
availableKeys: string[] = [];
|
||||||
availableValues: string[] = [];
|
availableValues: string[] = [];
|
||||||
|
isExpanded: boolean = false; // Add expansion state
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private filterService: FilterService
|
private filterService: FilterService
|
||||||
) { }
|
) {
|
||||||
|
console.log('=== COMPACT FILTER RUNNER CONSTRUCTOR CALLED ===');
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
console.log('CompactFilterRunnerComponent initialized with inputs:', {
|
console.log('=== COMPACT FILTER RUNNER DEBUG INFO ===');
|
||||||
filterKey: this.filterKey,
|
console.log('Component initialized with inputs:');
|
||||||
filterType: this.filterType,
|
console.log('- filterKey:', this.filterKey);
|
||||||
filterOptions: this.filterOptions,
|
console.log('- filterType:', this.filterType);
|
||||||
filterLabel: this.filterLabel,
|
console.log('- filterOptions:', this.filterOptions);
|
||||||
apiUrl: this.apiUrl,
|
console.log('- filterLabel:', this.filterLabel);
|
||||||
connection: this.connection
|
console.log('- apiUrl:', this.apiUrl);
|
||||||
});
|
console.log('- connection:', this.connection);
|
||||||
|
console.log('========================================');
|
||||||
|
|
||||||
// Register this filter with the filter service
|
// Register this filter with the filter service
|
||||||
this.registerFilter();
|
this.registerFilter();
|
||||||
@@ -41,24 +45,35 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
// Subscribe to filter definitions to get available filters
|
// Subscribe to filter definitions to get available filters
|
||||||
this.filterService.filters$.subscribe(filters => {
|
this.filterService.filters$.subscribe(filters => {
|
||||||
this.availableFilters = filters;
|
this.availableFilters = filters;
|
||||||
|
console.log('Available filters updated:', filters);
|
||||||
this.updateSelectedFilter();
|
this.updateSelectedFilter();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subscribe to filter state changes
|
// Subscribe to filter state changes
|
||||||
this.filterService.filterState$.subscribe(state => {
|
this.filterService.filterState$.subscribe(state => {
|
||||||
|
console.log('Filter state updated:', state);
|
||||||
if (this.selectedFilter && state.hasOwnProperty(this.selectedFilter.id)) {
|
if (this.selectedFilter && state.hasOwnProperty(this.selectedFilter.id)) {
|
||||||
this.filterValue = state[this.selectedFilter.id];
|
this.filterValue = state[this.selectedFilter.id];
|
||||||
|
console.log('Filter value updated for', this.selectedFilter.id, ':', this.filterValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
console.log('CompactFilterRunnerComponent inputs changed:', changes);
|
console.log('=== COMPACT FILTER RUNNER CHANGES DEBUG ===');
|
||||||
|
console.log('Component inputs changed:', changes);
|
||||||
|
|
||||||
// If filterKey or filterType changes, re-register the filter
|
// If filterKey or filterType changes, re-register the filter
|
||||||
if (changes.filterKey || changes.filterType || changes.filterOptions) {
|
if (changes.filterKey || changes.filterType || changes.filterOptions) {
|
||||||
|
console.log('Re-registering filter due to input changes');
|
||||||
this.registerFilter();
|
this.registerFilter();
|
||||||
}
|
}
|
||||||
|
console.log('==========================================');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle filter expansion
|
||||||
|
toggleFilter(): void {
|
||||||
|
this.isExpanded = !this.isExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register this filter with the filter service
|
// Register this filter with the filter service
|
||||||
@@ -68,6 +83,7 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
if (this.filterKey) {
|
if (this.filterKey) {
|
||||||
// Get current filter values from the service
|
// Get current filter values from the service
|
||||||
const currentFilterValues = this.filterService.getFilterValues();
|
const currentFilterValues = this.filterService.getFilterValues();
|
||||||
|
console.log('Current filter values from service:', currentFilterValues);
|
||||||
|
|
||||||
// Create a filter definition for this compact filter
|
// Create a filter definition for this compact filter
|
||||||
const filterDef: Filter = {
|
const filterDef: Filter = {
|
||||||
@@ -83,9 +99,11 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
// Get current filters
|
// Get current filters
|
||||||
const currentFilters = this.filterService.getFilters();
|
const currentFilters = this.filterService.getFilters();
|
||||||
|
console.log('Current filters from service:', currentFilters);
|
||||||
|
|
||||||
// Check if this filter is already registered
|
// Check if this filter is already registered
|
||||||
const existingFilterIndex = currentFilters.findIndex(f => f.id === filterDef.id);
|
const existingFilterIndex = currentFilters.findIndex(f => f.id === filterDef.id);
|
||||||
|
console.log('Existing filter index:', existingFilterIndex);
|
||||||
|
|
||||||
if (existingFilterIndex >= 0) {
|
if (existingFilterIndex >= 0) {
|
||||||
// Preserve the existing filter configuration
|
// Preserve the existing filter configuration
|
||||||
@@ -130,15 +148,20 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
// Update the selected filter reference
|
// Update the selected filter reference
|
||||||
this.selectedFilter = filterDef;
|
this.selectedFilter = filterDef;
|
||||||
console.log('Selected filter set to:', this.selectedFilter);
|
console.log('Selected filter set to:', this.selectedFilter);
|
||||||
|
} else {
|
||||||
|
console.log('No filterKey provided, skipping filter registration');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelectedFilter(): void {
|
updateSelectedFilter(): void {
|
||||||
|
console.log('Updating selected filter. Filter key:', this.filterKey, 'Available filters:', this.availableFilters);
|
||||||
if (this.filterKey && this.availableFilters.length > 0) {
|
if (this.filterKey && this.availableFilters.length > 0) {
|
||||||
this.selectedFilter = this.availableFilters.find(f => f.field === this.filterKey) || null;
|
this.selectedFilter = this.availableFilters.find(f => f.field === this.filterKey) || null;
|
||||||
|
console.log('Found selected filter:', this.selectedFilter);
|
||||||
if (this.selectedFilter) {
|
if (this.selectedFilter) {
|
||||||
// Get current value for this filter from the service
|
// Get current value for this filter from the service
|
||||||
const currentState = this.filterService.getFilterValues();
|
const currentState = this.filterService.getFilterValues();
|
||||||
|
console.log('Current state from service:', currentState);
|
||||||
const filterValue = currentState[this.selectedFilter.id];
|
const filterValue = currentState[this.selectedFilter.id];
|
||||||
if (filterValue !== undefined) {
|
if (filterValue !== undefined) {
|
||||||
this.filterValue = filterValue;
|
this.filterValue = filterValue;
|
||||||
@@ -203,4 +226,20 @@ export class CompactFilterRunnerComponent implements OnInit, OnChanges {
|
|||||||
// Emit the change
|
// Emit the change
|
||||||
this.onFilterValueChange(this.filterValue);
|
this.onFilterValueChange(this.filterValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add method to check if an option is selected for checkboxes (needed for proper UI rendering)
|
||||||
|
isOptionSelected(option: string): boolean {
|
||||||
|
console.log('Checking if option is selected:', option, 'Current filter value:', this.filterValue);
|
||||||
|
if (!this.filterValue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure filterValue is an array for multiselect
|
||||||
|
if (!Array.isArray(this.filterValue)) {
|
||||||
|
this.filterValue = [];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.filterValue.includes(option);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,9 @@
|
|||||||
<!-- <span><button class="btn btn-primary" (click)="Export(item.name)">Export</button></span> -->
|
<!-- <span><button class="btn btn-primary" (click)="Export(item.name)">Export</button></span> -->
|
||||||
<!-- <span><app-line-runner (buttonClicked)="generatePDFFile()"></app-line-runner></span> -->
|
<!-- <span><app-line-runner (buttonClicked)="generatePDFFile()"></app-line-runner></span> -->
|
||||||
<!-- <h4 style="margin-top: 10px; margin-left: 10px;">{{ item.charttitle }}</h4> -->
|
<!-- <h4 style="margin-top: 10px; margin-left: 10px;">{{ item.charttitle }}</h4> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ndc-dynamic class="no-drag"
|
<ndc-dynamic class="no-drag"
|
||||||
[ndcDynamicComponent]="item.component"
|
[ndcDynamicComponent]="item.component"
|
||||||
[ndcDynamicInputs]="getComponentInputs(item)"
|
[ndcDynamicInputs]="getComponentInputs(item)"
|
||||||
|
|||||||
@@ -311,12 +311,18 @@ dashboard_name = "Dashtest";
|
|||||||
|
|
||||||
// Compact Filter specific inputs
|
// Compact Filter specific inputs
|
||||||
if (item.name === 'Compact Filter') {
|
if (item.name === 'Compact Filter') {
|
||||||
|
console.log('=== COMPACT FILTER INPUTS DEBUG ===');
|
||||||
|
console.log('Item data for compact filter:', item);
|
||||||
|
|
||||||
if (item.filterKey !== undefined) inputs.filterKey = item.filterKey;
|
if (item.filterKey !== undefined) inputs.filterKey = item.filterKey;
|
||||||
if (item.filterType !== undefined) inputs.filterType = item.filterType;
|
if (item.filterType !== undefined) inputs.filterType = item.filterType;
|
||||||
if (item.filterLabel !== undefined) inputs.filterLabel = item.filterLabel;
|
if (item.filterLabel !== undefined) inputs.filterLabel = item.filterLabel;
|
||||||
if (item.filterOptions !== undefined) inputs.filterOptions = item.filterOptions;
|
if (item.filterOptions !== undefined) inputs.filterOptions = item.filterOptions;
|
||||||
if (item.table !== undefined) inputs.apiUrl = item.table; // Use table as API URL for compact filter
|
if (item.table !== undefined) inputs.apiUrl = item.table; // Use table as API URL for compact filter
|
||||||
if (item.connection !== undefined) inputs.connection = item.connection ? parseInt(item.connection, 10) : undefined;
|
if (item.connection !== undefined) inputs.connection = item.connection ? parseInt(item.connection, 10) : undefined;
|
||||||
|
|
||||||
|
console.log('Final inputs for compact filter:', inputs);
|
||||||
|
console.log('==============================');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grid View specific inputs
|
// Grid View specific inputs
|
||||||
|
|||||||
Reference in New Issue
Block a user