Commit 03e89323 by Ooh-Ao

dataset

parent d7952bf7
......@@ -15,6 +15,7 @@ import { WidgetModel } from '../../models/widgets.model';
export interface WidgetConfigDialogData {
widget: WidgetModel;
availableColumns: string[];
currentConfig?: any; // Add optional currentConfig for editing
}
@Component({
......@@ -50,16 +51,20 @@ export class WidgetConfigComponent implements OnInit {
this.availableColumns = this.data.availableColumns;
this.widgetType = this.data.widget.component;
// Handle config whether it is a string or an object
try {
if (typeof this.data.widget.config === 'string') {
this.currentConfig = JSON.parse(this.data.widget.config);
} else {
this.currentConfig = JSON.parse(JSON.stringify(this.data.widget.config || {}));
// Prioritize the passed-in currentConfig for editing, otherwise use the widget's default config.
if (this.data.currentConfig && Object.keys(this.data.currentConfig).length > 0) {
this.currentConfig = JSON.parse(JSON.stringify(this.data.currentConfig)); // Deep copy to prevent modifying the original object
} else {
try {
if (typeof this.data.widget.config === 'string') {
this.currentConfig = JSON.parse(this.data.widget.config || '{}');
} else {
this.currentConfig = JSON.parse(JSON.stringify(this.data.widget.config || {}));
}
} catch (e) {
console.error('Error parsing widget config:', e);
this.currentConfig = {};
}
} catch (e) {
console.error('Error parsing widget config:', e);
this.currentConfig = {};
}
const gridLikeWidgets = ['SyncfusionDatagridWidgetComponent', 'NewDataTableWidget', 'MatrixWidgetComponent'];
......
......@@ -35,13 +35,13 @@
<ul *ngIf="linkedWidgets.length > 0" class="space-y-2">
<li *ngFor="let widget of linkedWidgets"
class="flex items-center justify-between p-2 rounded-md transition-colors cursor-pointer"
[class.bg-sky-100]="widget.itemId === widgetToPreview?.itemId"
[class.hover:bg-gray-100]="widget.itemId !== widgetToPreview?.itemId"
[class.bg-sky-100]="widget.widget.widgetId === widgetToPreview?.widget?.widgetId"
[class.hover:bg-gray-100]="widget.widget.widgetId !== widgetToPreview?.widget?.widgetId"
(click)="viewWidget(widget)">
<span class="font-medium">{{ widget.widget.thName }}</span>
<div class="flex items-center space-x-2">
<button (click)="removeWidget(widget, $event)" class="text-red-600 hover:text-red-800" title="Remove">
<i class="bi bi-trash-fill"></i>
<button (click)="removeWidget(widget, $event)" class="text-red hover:text-red-800" title="Remove">
<i class="bi bi-trash-fill text-red"></i>
</button>
</div>
</li>
......
......@@ -209,6 +209,10 @@ export class DatasetWidgetLinkerComponent implements OnInit {
// Persist the changes to the backend
this.mMenuitemsWidgetService.saveLinkedWidget(this.widgetToPreview!).subscribe(() => {
this.notificationService.success('Success', 'Configuration saved successfully!');
// Re-trigger the data fetch in the state service to get fresh data
this.dashboardStateService.selectDataset(this.selectedDatasetId!);
// Refresh the entire preview to reflect the changes
this.viewWidget(this.widgetToPreview!);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment