Update snippets to use new snippets api and dataset

This commit is contained in:
Tom Bloor 2017-09-07 16:02:29 +01:00
parent a0e077852d
commit f0ed1e9369
2 changed files with 31 additions and 13 deletions

View file

@ -3,19 +3,19 @@
<ul> <ul>
<li class="hidden-sm-down"> <li class="hidden-sm-down">
<div class="text-muted">Customers This Month</div> <div class="text-muted">Customers This Month</div>
<strong>{{customersThisMonth}}</strong> <strong>{{ thisMonthSalesCount }}</strong>
</li> </li>
<li class="hidden-sm-down"> <li class="hidden-sm-down">
<div class="text-muted">Money Spent This Month</div> <div class="text-muted">Money Spent This Month</div>
<strong>{{moneySpentThisMonth | currency:'GBP':true:'1.2-2'}}</strong> <strong>{{ thisMonthPurchasesTotal | currency:'GBP':true:'1.2-2'}}</strong>
</li> </li>
<li class="hidden-sm-down"> <li class="hidden-sm-down">
<div class="text-muted">Points Total</div> <div class="text-muted">Customers Today</div>
<strong>{{pointsTotal}}</strong> <strong>{{ todaySalesCount }}</strong>
</li> </li>
<li class="hidden-sm-down"> <li class="hidden-sm-down">
<div class="text-muted">Average Transaction Today</div> <div class="text-muted">Average Transaction Today</div>
<strong>{{averageTransactionToday | currency:'GBP':true:'1.2-2'}}</strong> <strong>{{ ( todaySalesTotal / todaySalesCount ) || 0 | currency:'GBP':true:'1.2-2'}}</strong>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -7,10 +7,19 @@ import { OrgSnippetsService } from '../providers/org-snippets.service';
}) })
export class OrgBarSnippetComponent implements OnInit { export class OrgBarSnippetComponent implements OnInit {
public customersThisMonth = 0; public thisMonthSalesCount = 0;
public moneySpentThisMonth = 0; public thisMonthSalesTotal = 0;
public pointsTotal = 0; public thisWeekSalesCount = 0;
public averageTransactionToday = 0; public thisWeekSalesTotal = 0;
public todaySalesCount = 0;
public todaySalesTotal = 0;
public thisMonthPurchasesCount = 0;
public thisMonthPurchasesTotal = 0;
public thisWeekPurchasesCount = 0;
public thisWeekPurchasesTotal = 0;
public todayPurchasesCount = 0;
public todayPurchasesTotal = 0;
constructor( constructor(
private snippetsService: OrgSnippetsService, private snippetsService: OrgSnippetsService,
@ -20,10 +29,19 @@ export class OrgBarSnippetComponent implements OnInit {
this.snippetsService.getData() this.snippetsService.getData()
.subscribe( .subscribe(
result => { result => {
this.customersThisMonth = result.snippets.this_month_customer_count; this.thisMonthSalesCount = result.snippets.this_month_sales_count;
this.moneySpentThisMonth = result.snippets.this_month_customer_spend; this.thisMonthSalesTotal = result.snippets.this_month_sales_total;
this.pointsTotal = result.snippets.pear_points_total; this.thisWeekSalesCount = result.snippets.this_week_sales_count;
this.averageTransactionToday = result.snippets.today_sales_average; this.thisWeekSalesTotal = result.snippets.this_week_sales_total;
this.todaySalesCount = result.snippets.today_sales_count;
this.todaySalesTotal = result.snippets.today_sales_total;
this.thisMonthPurchasesCount = result.snippets.this_week_purchases_count;
this.thisMonthPurchasesTotal = result.snippets.this_week_purchases_total;
this.thisWeekPurchasesCount = result.snippets.this_month_purchases_count;
this.thisWeekPurchasesTotal = result.snippets.this_month_purchases_total;
this.todayPurchasesCount = result.snippets.today_purchases_count;
this.todayPurchasesTotal = result.snippets.today_purchases_total;
} }
); );
} }