Refactored snippet bar into seperate component

This commit is contained in:
Tom Bloor 2017-09-07 15:12:49 +01:00
parent 1774f2f0d5
commit cfb131b800
8 changed files with 80 additions and 56 deletions

View file

@ -1,26 +1,5 @@
<div class="animated fadeIn">
<div class="card">
<div class="card-footer">
<ul>
<li class="hidden-sm-down">
<div class="text-muted">Customers This Month</div>
<strong>{{customersThisMonth}}</strong>
</li>
<li class="hidden-sm-down">
<div class="text-muted">Money Spent This Month</div>
<strong>{{moneySpentThisMonth | currency:'GBP':true:'1.2-2'}}</strong>
</li>
<li class="hidden-sm-down">
<div class="text-muted">Points Total</div>
<strong>{{pointsTotal}}</strong>
</li>
<li class="hidden-sm-down">
<div class="text-muted">Average Transaction Today</div>
<strong>{{averageTransactionToday | currency:'GBP':true:'1.2-2'}}</strong>
</li>
</ul>
</div>
</div>
<snippet-bar-org></snippet-bar-org>
<div class="row">
<div *ngFor="let widget of widgetList" class="col-sm-6 col-lg-3">
<widget-graph *ngIf="widget.type == 'graph'"

View file

@ -1,8 +1,7 @@
import { Directive, Component, OnInit } from '@angular/core';
import { Http, Response } from '@angular/http';
import { ApiService } from '../providers/api-service';
import { Router } from '@angular/router';
import { GraphWidget } from '../widgets/graph-widget.component';
import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component';
import { DataType } from '../shared/data-types.enum';
@Component({
@ -10,12 +9,6 @@ import { DataType } from '../shared/data-types.enum';
})
export class DashboardComponent implements OnInit {
// Snippet data
public customersThisMonth: number;
public moneySpentThisMonth: number;
public pointsTotal: number;
public averageTransactionToday: number;
shuffledArray: any;
public widgetList = [
@ -60,20 +53,8 @@ export class DashboardComponent implements OnInit {
];
constructor(
private http: Http,
private api: ApiService,
) {
this.shuffle = this.shuffledArray;
this.api.breadcrumb_data(undefined)
.subscribe(
result => {
console.log(result);
this.customersThisMonth = result.customersthismonth;
this.moneySpentThisMonth = result.moneyspentthismonth;
this.pointsTotal = result.pointstotal;
this.averageTransactionToday = result.averagetransactiontoday;
}
);
this.shuffle = this.shuffledArray;
}
// Fisher-Yates shuffle function

View file

@ -15,6 +15,7 @@ import { FeedbackComponent } from './feedback.component';
import { TransactionLogComponent } from './transaction-log.component';
import { GraphWidget } from '../widgets/graph-widget.component';
import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component';
import { DashboardRoutingModule } from './dashboard.routing';
import { OrgResultComponent } from '../shared/org-result.component';
@ -43,6 +44,7 @@ import { TransactionResultComponent } from '../shared/transaction-result.compone
TransactionResultComponent,
FeedbackComponent,
GraphWidget,
OrgBarSnippetComponent,
],
providers: [
CurrencyPipe