Commit 1a7c08a5 by Ooh-Ao

dashboard

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