adding loading + empty panel support to the records summary widget.

This commit is contained in:
Jason Kulatunga 2023-10-13 21:37:22 -07:00
parent 8e999e6b79
commit c25b164035
No known key found for this signature in database
2 changed files with 38 additions and 31 deletions

View File

@ -1,8 +1,8 @@
{
"id": "updated",
"id": "secondary",
"schema_version": "1.0",
"title": "Updated Dashboard",
"description": "An example dashboard to show-off the power of Fasten widgets",
"title": "Secondary Dashboard",
"description": "An second dashboard to show-off the flexibility of the dashboard system.",
"widgets": [
{
"title_text": "Records Summary",

View File

@ -166,12 +166,13 @@ export class RecordsSummaryWidgetComponent extends DashboardWidgetComponent impl
} as DashboardWidgetConfig
super.ngOnInit();
this.loading = true
this.isEmpty = true
this.chartProcessQueryResults(null)
}
chartProcessQueryResults(queryResults: any[]) {
this.fastenApi.getSummary().subscribe((summary: Summary) => {
this.summary = summary
for (let resourceTypeCount of summary.resource_type_counts) {
let foundGroup = false
for (let groupKey in this.groupLookup) {
@ -184,7 +185,6 @@ export class RecordsSummaryWidgetComponent extends DashboardWidgetComponent impl
}
if (!foundGroup) {
console.log('no group found for ' + resourceTypeCount.resource_type)
this.groupLookup[resourceTypeCount.resource_type] = {
displayName: resourceTypeCount.resource_type,
@ -199,9 +199,16 @@ export class RecordsSummaryWidgetComponent extends DashboardWidgetComponent impl
return group.count > 0
})
})
//call Summary endpoint
this.loading = false
if(this.summary.resource_type_counts.length > 0){
this.isEmpty = false
}
this.loading = false
},
(error) => {
this.loading = false
},
() => {
console.log('completed getting summary')
})
}
}