Commit 1a7c08a5 by Ooh-Ao

dashboard

parent 3ab688d0
......@@ -55,7 +55,7 @@
(click)="addWidgetToDashboard(widget)"
class="widget-item p-3 rounded-lg hover:bg-gray-100 cursor-pointer transition-colors duration-200"
>
<p class="font-semibold text-gray-700">{{ widget.name }}</p>
<p class="font-semibold text-gray-700">{{ widget.thName }}</p>
<p class="text-xs text-gray-500">
Size: {{ widget.cols }}x{{ widget.rows }}
</p>
......
......@@ -157,12 +157,12 @@ export class DashboardViewerComponent implements OnInit {
const widgetConfig = widget.config || {};
return {
id: widget.id,
id: widget.widgetId,
row: widget.y,
col: widget.x,
sizeX: widget.cols,
sizeY: widget.rows,
header: widget.name,
header: widget.thName,
componentName: widget.component, // Add componentName
componentType: this.widgetComponentMap[widget.component], // Attach the component Type
componentInputs: { config: widgetConfig } // Pass the config object as 'config' input
......
......@@ -21,38 +21,45 @@ export class DatasetModel implements IDataset {
}
export interface IWidget {
id: string;
name: string;
widgetId: string;
thName: string;
engName: string;
component: string;
cols: number;
rows: number;
x: number;
y: number;
data: any; // Legacy, to be phased out
config: any; // New: For data-driven configuration
data: any;
config: any;
perspective: any;
}
export class WidgetModel implements IWidget {
id: string;
name: string;
widgetId: string;
thName: string;
engName: string;
component: string;
cols: number;
rows: number;
x: number;
y: number;
data: any; // Legacy, to be phased out
config: any; // New: For data-driven configuration
data: any;
config: any;
perspective: any;
constructor(data: Partial<IWidget>) {
this.id = data.id ?? '';
this.name = data.name ?? '';
this.widgetId = data.widgetId ?? '';
this.thName = data.thName ?? '';
this.engName = data.engName ?? '';
this.component = data.component ?? '';
this.cols = data.cols ?? 1;
this.rows = data.rows ?? 1;
this.x = data.x ?? 0;
this.y = data.y ?? 0;
this.data = data.data ?? {}; // Keep for now for compatibility
this.config = data.config ?? {}; // Initialize new config object
this.data = data.data ?? {};
this.config = data.config ?? {};
this.perspective = data.perspective ?? {};
}
}
......
......@@ -15,28 +15,24 @@ export class WidgetService {
createStatus: boolean = true
constructor(private http: HttpClient) { }
getListWidgets(status?: string): Observable<WidgetModel[]> {
if (status) {
return this.http.get<WidgetModel[]>(this.url + "widget/lists?status=" + status)
} else {
return this.http.get<WidgetModel[]>(this.url + "widget/lists")
}
return this.http.get<WidgetModel[]>(this.url + "widget-registry/lists/search")
}
getListExcelContent(status?: string): Observable<DocumentContentModel[]> {
return this.http.get<DocumentContentModel[]>(this.url + "document-center/content/lists")
}
getWidgetById(widgetId: string): Observable<WidgetModel> {
return this.http.get<WidgetModel>(this.url + "widget/" + widgetId)
return this.http.get<WidgetModel>(this.url + "widget-registry/" + widgetId)
}
downloadFile(logId:string):Observable<any>{
return this.http.get(this.url + "widget/files/download/"+logId, { responseType: 'blob' })
downloadFile(logId: string): Observable<any> {
return this.http.get(this.url + "widget-registry/files/download/" + logId, { responseType: 'blob' })
}
createWidget(model: WidgetModel): Observable<any> {
let body : any = model
return this.http.post(this.url + 'widget', body)
let body: any = model
return this.http.post(this.url + 'widget-registry', body)
}
deleteWidget(model: WidgetModel): Observable<any> {
let body = {
widgetId: model.id
widgetId: model.widgetId
}
let option = {
headers: new HttpHeaders({
......@@ -44,7 +40,7 @@ export class WidgetService {
}),
body: body
}
return this.http.delete<any>(this.url + 'widget', option)
return this.http.delete<any>(this.url + 'widget-registry', option)
}
deleteExcelContent(model: DocumentContentModel): Observable<any> {
let body = {
......@@ -61,7 +57,7 @@ export class WidgetService {
getCount(status?: string): Observable<number> {
return this.http.get<number>(this.url + "widget/count")
return this.http.get<number>(this.url + "widget-registry/count")
}
getCountContent(status?: string): Observable<number> {
return this.http.get<number>(this.url + "document-center/content/count")
......
......@@ -20,7 +20,7 @@
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr *ngFor="let widget of widgets$ | async">
<td class="px-6 py-4 whitespace-nowrap">{{ widget.name }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ widget.thName }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ widget.component }}</td>
<td class="px-6 py-4 whitespace-nowrap">{{ widget.cols }} x {{ widget.rows }}</td>
<td class="px-6 py-4">
......@@ -29,7 +29,7 @@
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right">
<button (click)="editWidget(widget.id)" class="text-indigo-600 hover:text-indigo-900">Edit</button>
<button (click)="editWidget(widget.widgetId)" class="text-indigo-600 hover:text-indigo-900">Edit</button>
</td>
</tr>
<!-- Show a message if there are no widgets -->
......
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