diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.html b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.html index 4f78c5a..a440ffc 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.html +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.html @@ -343,8 +343,20 @@
Base Drilldown Filters
Configure filters for the base drilldown level
+ +
+
+
+ + +
+
+
+ - @@ -353,14 +365,16 @@ style="margin-bottom: 10px; padding: 8px; border: 1px solid #eee; border-radius: 4px; background-color: #f9f9f9;">
Filter {{i + 1}} -
- @@ -368,11 +382,13 @@
+ class="clr-input" placeholder="Filter Value" + [disabled]="gadgetsEditdata.commonFilterEnabledDrilldown"/>
-
@@ -472,8 +488,20 @@
Layer {{i + 1}} Filters
Configure filters for this drilldown layer
+ +
+
+
+ + +
+
+
+ - @@ -482,14 +510,16 @@ style="margin-bottom: 10px; padding: 8px; border: 1px solid #eee; border-radius: 4px; background-color: #f9f9f9;">
Filter {{j + 1}} -
- @@ -497,11 +527,13 @@
+ class="clr-input" placeholder="Filter Value" + [disabled]="layer.commonFilterEnabled"/>
-
diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts index eda384b..dd020a6 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts @@ -159,8 +159,9 @@ export class EditnewdashComponent implements OnInit { drilldownFilters: [] as any[], // Add separate drilldown filters // Multi-layer drilldown configurations drilldownLayers: [] as any[], - // Common filter property - commonFilterEnabled: false + // Common filter properties + commonFilterEnabled: false, + commonFilterEnabledDrilldown: false }; // Add sureconnect data property @@ -537,6 +538,10 @@ export class EditnewdashComponent implements OnInit { if (item['commonFilterEnabled'] === undefined) { this.gadgetsEditdata['commonFilterEnabled'] = false; } + // Initialize drilldown common filter property if not present + if (item['commonFilterEnabledDrilldown'] === undefined) { + this.gadgetsEditdata['commonFilterEnabledDrilldown'] = false; + } this.getStores(); // Set default connection if none is set and we have connections @@ -579,7 +584,7 @@ export class EditnewdashComponent implements OnInit { this.gadgetsEditdata['drilldownLayers'] = []; } else { // Ensure each layer has proper structure (removed parameterKey, added parameter) - this.gadgetsEditdata['drilldownLayers'].forEach(layer => { + this.gadgetsEditdata['drilldownLayers'].forEach((layer, index) => { // Initialize parameter if not present if (layer['parameter'] === undefined) { layer['parameter'] = ''; @@ -588,6 +593,10 @@ export class EditnewdashComponent implements OnInit { if (layer['filters'] === undefined) { layer['filters'] = []; } + // Initialize common filter property for layer if not present + if (layer['commonFilterEnabled'] === undefined) { + layer['commonFilterEnabled'] = false; + } }); } @@ -824,6 +833,7 @@ export class EditnewdashComponent implements OnInit { updatedItem.drilldownFilters = this.gadgetsEditdata.drilldownFilters; // Add drilldown filters updatedItem.drilldownLayers = this.gadgetsEditdata.drilldownLayers; updatedItem.commonFilterEnabled = this.gadgetsEditdata.commonFilterEnabled; // Add common filter property + updatedItem.commonFilterEnabledDrilldown = this.gadgetsEditdata.commonFilterEnabledDrilldown; // Add drilldown common filter property console.log('Updated item:', updatedItem); return updatedItem; @@ -1158,13 +1168,21 @@ export class EditnewdashComponent implements OnInit { // Update the dashboardArray to reflect changes this.dashboardArray = this.dashboardArray.map(item => { if (item.commonFilterEnabled) { + // Preserve the component reference + const componentRef = item.component; + // Update the chart with common filter data - return { + const updatedItem = { ...item, table: this.commonFilterData.apiUrl, connection: this.commonFilterData.connection, baseFilters: [...this.commonFilterData.filters] }; + + // Restore the component reference + updatedItem.component = componentRef; + + return updatedItem; } return item; }); @@ -1172,13 +1190,21 @@ export class EditnewdashComponent implements OnInit { // Also update the dashboardCollection to persist changes this.dashboardCollection.dashboard = this.dashboardCollection.dashboard.map(item => { if (item.commonFilterEnabled) { + // Preserve the component reference + const componentRef = item.component; + // Update the chart with common filter data - return { + const updatedItem = { ...item, table: this.commonFilterData.apiUrl, connection: this.commonFilterData.connection, baseFilters: [...this.commonFilterData.filters] } as DashboardContentModel; + + // Restore the component reference + updatedItem.component = componentRef; + + return updatedItem; } return item; }); @@ -1196,4 +1222,29 @@ export class EditnewdashComponent implements OnInit { } // When disabling, the user can edit the filters normally } + + // Add method to handle common filter toggle for base drilldown + onCommonFilterToggleDrilldown() { + console.log('Common filter drilldown toggled:', this.gadgetsEditdata.commonFilterEnabledDrilldown); + + if (this.gadgetsEditdata.commonFilterEnabledDrilldown) { + // When enabling common filter, save current values and apply common filter data + this.gadgetsEditdata.drilldownFilters = [...this.commonFilterData.filters]; + } + // When disabling, the user can edit the filters normally + } + + // Add method to handle common filter toggle for drilldown layers + onCommonFilterToggleLayer(layerIndex: number) { + const layer = this.gadgetsEditdata.drilldownLayers[layerIndex]; + if (layer) { + console.log(`Common filter layer ${layerIndex} toggled:`, layer.commonFilterEnabled); + + if (layer.commonFilterEnabled) { + // When enabling common filter, save current values and apply common filter data + layer.filters = [...this.commonFilterData.filters]; + } + // When disabling, the user can edit the filters normally + } + } }