diff options
Diffstat (limited to 'ufund-ui/src/app')
| -rw-r--r-- | ufund-ui/src/app/components/dashboard/dashboard.component.html | 3 | ||||
| -rw-r--r-- | ufund-ui/src/app/components/dashboard/dashboard.component.ts | 12 | 
2 files changed, 6 insertions, 9 deletions
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.html b/ufund-ui/src/app/components/dashboard/dashboard.component.html index 69ae66e..2af467c 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.html +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.html @@ -5,9 +5,8 @@  <!--<app-mini-need-list [needList]="inBasket" jtitle="In your basket" url="/basket"/>-->  <span>_ Registered users</span>  <span *ngIf="count"> {{count | async}} </span> -<span>_ Needs with overflow</span>  <span>_ Fulfilled needs</span> -<span *ngIf="fulfilledNeeds"> {{fulfilledNeeds | async}} </span> +<app-mini-need-list [needList]="fulfilledNeeds.getValue()" jtitle="Fulfilled needs"> </app-mini-need-list>  <span>_ Most fulfilled needs</span>  <app-mini-need-list [needList]="mostFulfilledNeeds.getValue()" jtitle="Most fulfilled"> </app-mini-need-list>  <span>_ Total monetary contributions</span> diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 8c397ff..9bf7627 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -16,7 +16,8 @@ export class DashboardComponent implements OnInit{      protected count = new BehaviorSubject<number | undefined>(undefined)      protected totalDonations = new BehaviorSubject<number | undefined>(undefined) -    protected fulfilledNeeds = new BehaviorSubject<number | undefined>(undefined) +    protected totalNeeds = new BehaviorSubject<number | undefined>(undefined) +    protected fulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)      protected mostFulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)      constructor( @@ -35,22 +36,19 @@ export class DashboardComponent implements OnInit{          this.userService.getCount().subscribe(count => this.count.next(count))          this.cupboardService.getNeeds().subscribe(needs => { -            let fulfilledNeeds = 0              let totalValue = 0              for (let need of needs) { -                let needPercent = need.current / need.maxGoal -                if (needPercent >= 1) { -                    fulfilledNeeds++ -                    this.fulfilledNeeds.next(fulfilledNeeds) -                }                  if (need.type === GoalType.MONETARY) {                      totalValue += need.current                      this.totalDonations.next(totalValue)                  }              } +            this.fulfilledNeeds.next(needs.filter(a => ((a.current / a.maxGoal)) >= 1))              needs.sort((a, b) => b.current/b.maxGoal - a.current/a.maxGoal) +              needs = needs.filter(a => a.current != 0) +            this.totalNeeds.next(needs.length)              this.mostFulfilledNeeds.next(needs.slice(0, 5))          })  | 
