Skip to content

Commit

Permalink
adding loading + empty panel support to the records summary widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Oct 14, 2023
1 parent 8e999e6 commit c25b164
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,42 +166,49 @@ export class RecordsSummaryWidgetComponent extends DashboardWidgetComponent impl

} as DashboardWidgetConfig
super.ngOnInit();
this.loading = true
this.isEmpty = true
this.chartProcessQueryResults(null)
}

this.fastenApi.getSummary().subscribe((summary: Summary) => {
this.summary = summary
chartProcessQueryResults(queryResults: any[]) {

for(let resourceTypeCount of summary.resource_type_counts){
let foundGroup = false
for(let groupKey in this.groupLookup){
let group = this.groupLookup[groupKey]
if(group.resourceTypes.indexOf(resourceTypeCount.resource_type) > -1){
foundGroup = true
this.groupLookup[groupKey].count += resourceTypeCount.count
this.groupLookup[groupKey].includedResourceTypes.push(resourceTypeCount.resource_type)
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) {
let group = this.groupLookup[groupKey]
if (group.resourceTypes.indexOf(resourceTypeCount.resource_type) > -1) {
foundGroup = true
this.groupLookup[groupKey].count += resourceTypeCount.count
this.groupLookup[groupKey].includedResourceTypes.push(resourceTypeCount.resource_type)
}
}
}

if(!foundGroup){
console.log('no group found for ' + resourceTypeCount.resource_type)
this.groupLookup[resourceTypeCount.resource_type] = {
displayName: resourceTypeCount.resource_type,
if (!foundGroup) {
this.groupLookup[resourceTypeCount.resource_type] = {
displayName: resourceTypeCount.resource_type,

resourceTypes: [resourceTypeCount.resource_type],
count: resourceTypeCount.count
resourceTypes: [resourceTypeCount.resource_type],
count: resourceTypeCount.count
}
}
}
}

//filter any groups with 0 counts
this.groupLookup = this.groupLookup.filter((group) => {
return group.count > 0
})
//filter any groups with 0 counts
this.groupLookup = this.groupLookup.filter((group) => {
return group.count > 0
})

})
//call Summary endpoint
this.loading = false
this.isEmpty = false
if(this.summary.resource_type_counts.length > 0){
this.isEmpty = false
}
this.loading = false
},
(error) => {
this.loading = false
},
() => {
console.log('completed getting summary')
})
}
}

0 comments on commit c25b164

Please # to comment.