commit
ef66009baa
25 changed files with 523 additions and 148 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -2,6 +2,16 @@
|
|||
|
||||
# Next Release
|
||||
|
||||
# v0.1.0
|
||||
|
||||
* Changed Story Trail choosing to modals
|
||||
* Revamped snippets and graph widgets on customer dashboard
|
||||
* Added local purchase pie chart for customer dashboard
|
||||
* Added week by week purchase list for customer dashboard
|
||||
* Added sector purchase amount list for customer dashboard
|
||||
* Added sector U to available ones
|
||||
* Fixed snippet layout
|
||||
|
||||
# v0.0.7
|
||||
|
||||
* Added ESTA to Story Trail
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "localloop-web",
|
||||
"version": "0.0.7",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "localloop-web",
|
||||
"version": "0.0.7",
|
||||
"version": "0.1.0",
|
||||
"description": "LocalLoop Web - Web interface for LocalLoop app",
|
||||
"author": "",
|
||||
"url": "http://www.peartrade.org",
|
||||
|
|
|
@ -21,7 +21,10 @@ import { CustomerGuard } from './_guards/customer.guard';
|
|||
import { ApiService } from './providers/api-service';
|
||||
|
||||
import { OrgGraphsService } from './providers/org-graphs.service';
|
||||
import { CustGraphsService } from './providers/cust-graphs.service';
|
||||
import { OrgSnippetsService } from './providers/org-snippets.service';
|
||||
import { CustSnippetsService } from './providers/cust-snippets.service';
|
||||
import { CustPiesService } from './providers/cust-pies.service';
|
||||
|
||||
// Layouts
|
||||
import { FullLayoutComponent } from './layouts/full-layout.component';
|
||||
|
@ -65,6 +68,9 @@ import { DashboardModule } from './dashboard/dashboard.module';
|
|||
ApiService,
|
||||
OrgGraphsService,
|
||||
OrgSnippetsService,
|
||||
CustGraphsService,
|
||||
CustSnippetsService,
|
||||
CustPiesService,
|
||||
{
|
||||
provide: LocationStrategy,
|
||||
useClass: HashLocationStrategy
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
<option value='R'>Arts, Entertainment & Recreation</option>
|
||||
<option value='S'>Other Service Activities</option>
|
||||
<option value='T'>Household Domestic Business</option>
|
||||
<option value='U'>Extraterritorial Organisations and Bodies</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
<option value='R'>Arts, Entertainment & Recreation</option>
|
||||
<option value='S'>Other Service Activities</option>
|
||||
<option value='T'>Household Domestic Business</option>
|
||||
<option value='U'>Extraterritorial Organisations and Bodies</option>
|
||||
</select>
|
||||
<span class="help-block">Alter this if your business sector has changed.</span>
|
||||
</div>
|
||||
|
|
|
@ -1,129 +1,104 @@
|
|||
<div class="animated fadeIn">
|
||||
<div class="card">
|
||||
<div class="card-footer">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="text-muted">My Points</div>
|
||||
<strong>{{ basicStats.user_sum / 10 | number:'1.0-0' }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<div class="text-muted">My Rank</div>
|
||||
<div *ngIf="basicStats.user_position == 0" class="statuscontent">
|
||||
<strong>Unranked</strong>
|
||||
</div>
|
||||
<div *ngIf="basicStats.user_position != 0" class="statuscontent">
|
||||
<strong>{{ basicStats.user_position }}</strong>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<ul>
|
||||
<li>
|
||||
<div class="text-muted">My Total Spend</div>
|
||||
<strong>{{ basicStats.user_sum | currency:'GBP':'symbol':'1.2-2' }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<div class="text-muted">Value to Local Economy</div>
|
||||
<strong>{{ basicStats.user_sum * 2.3 | currency:'GBP':'symbol':'1.2-2' }}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<snippet-bar-cust></snippet-bar-cust>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div *ngFor="let widget of widgetList" class="col-sm-6 col-lg-3">
|
||||
<widget-graph *ngIf="widget.type == 'graph'"
|
||||
[graphName]="widget.name"
|
||||
[graphTitle]="widget.title"
|
||||
[graphIcon]="widget.icon"
|
||||
[dataType]="widget.dataType">
|
||||
</widget-graph>
|
||||
</div><!--/.col-->
|
||||
</div><!--/.row-->
|
||||
<div class=row>
|
||||
<div class="col-xl-4 col-md-6">
|
||||
<panel-pie></panel-pie>
|
||||
</div><!--/.col-->
|
||||
<div class="col-xl-4 col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.today_sum | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Total Today</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="card-title float-left mb-0">Purchases by Week</h4>
|
||||
</div><!--/.col-->
|
||||
</div><!--/.row-->
|
||||
<div class="chart-wrapper">
|
||||
<ul class="horizontal-bars type-2">
|
||||
<li>
|
||||
<span class="title">This Week</span>
|
||||
<span class="value">{{ (weekPurchaseList.first || 0 ) }} <span class="text-muted small">
|
||||
({{ (weekPurchaseList.first || 0 ) / weekPurchaseList.max | percent:'1.0-0' }})</span></span>
|
||||
<div class="bars">
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
[style.width]="(weekPurchaseList.first || 0 ) / weekPurchaseList.max | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Last Week</span>
|
||||
<span class="value">{{ weekPurchaseList.second || 0 }} <span class="text-muted small">
|
||||
({{ (weekPurchaseList.second || 0 ) / weekPurchaseList.max | percent:'1.0-0' }})</span></span>
|
||||
<div class="bars">
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
[style.width]="(weekPurchaseList.second || 0 ) / weekPurchaseList.max | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Week Maximum</span>
|
||||
<span class="value">{{ weekPurchaseList.max || 0 }} <span class="text-muted small">
|
||||
(100%)</span></span>
|
||||
<div class="bars">
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style="width: 100%" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">Weekly Average</span>
|
||||
<span class="value">{{ (weekPurchaseList.sum / weekPurchaseList.count) || 0 | number:'1.0-0'}} <span class="text-muted small">
|
||||
({{ ((weekPurchaseList.sum / weekPurchaseList.count) || 0) / weekPurchaseList.max | percent:'1.0-0' }})</span></span>
|
||||
<div class="bars">
|
||||
<div class="progress" style="height: 6px;">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
[style.width]="((weekPurchaseList.sum / weekPurchaseList.count) || 0) / weekPurchaseList.max | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="col-xl-4">
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.today_sum / (basicStats.today_count ? basicStats.today_count : 1) | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Avg. Spend Today</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="card-title float-left mb-0">Sector Purchase Amounts</h4>
|
||||
</div><!--/.col-->
|
||||
</div><!--/.row-->
|
||||
<div class="chart-wrapper">
|
||||
<ul class="icons-list">
|
||||
<!-- New loop -->
|
||||
<li *ngFor="let sector of sectorLetters | slice:0:sectorLimit; let i=index">
|
||||
<i [ngClass]="[sectorIcons [sector] || 'icon-question', sectorClasses [sector] || 'bg-info']"></i>
|
||||
<div class="desc">
|
||||
<div class="title">{{ sectorNames [sector] || 'N/A' }}</div>
|
||||
</div>
|
||||
<div class="value">
|
||||
<div class="small text-muted">Bought</div>
|
||||
<strong>{{ sectorPurchases[i] || 'N/A' }}</strong>
|
||||
</div>
|
||||
</li>
|
||||
<li *ngIf="sectorLetters.length > 10 && disableSectorButton == false" class="divider text-center">
|
||||
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore()"><i class="icon-options"></i></button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.week_sum | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Last Week Total</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.week_sum / (basicStats.week_count ? basicStats.week_count : 1) | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Last Week Avg. Spend</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.month_sum | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Last Month Total</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.month_sum / (basicStats.month_count ? basicStats.month_count : 1) | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>Last Month Avg. Spend</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.user_sum | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>User Total</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card card-inverse card-primary">
|
||||
<div class="card-block">
|
||||
<div class="h4 mb-0">{{ basicStats.user_sum / (basicStats.user_count ? basicStats.user_count : 1) | currency:'GBP':'symbol':'1.2-2' }}</div>
|
||||
<div>User Avg. Spend</div>
|
||||
<!-- <div class="progress progress-white progress-xs mt-3">
|
||||
<div class="progress-bar" role="progressbar" style="width: 100%" attr.aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<small class="text-muted">Lorem ipsum dolor sit amet enim.</small> -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
|
|
|
@ -2,15 +2,14 @@ import { Directive, Component, OnInit } from '@angular/core';
|
|||
import { ApiService } from '../providers/api-service';
|
||||
import { Router } from '@angular/router';
|
||||
import { GraphWidget } from '../widgets/graph-widget.component';
|
||||
import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component';
|
||||
import { PiePanel } from '../panels/pie-panel.component';
|
||||
import { DataType } from '../shared/data-types.enum';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'dashboard-customer.component.html'
|
||||
})
|
||||
export class DashboardCustomerComponent implements OnInit {
|
||||
customersThisMonth: any;
|
||||
moneySpentThisMonth: any;
|
||||
pointsTotal: any;
|
||||
averageTransactionToday: any;
|
||||
|
||||
/* Setting up dashboard's main variables*/
|
||||
name: any;
|
||||
|
@ -19,27 +18,133 @@ export class DashboardCustomerComponent implements OnInit {
|
|||
trends: any;
|
||||
myRank: any;
|
||||
username: any;
|
||||
maxPurchase: number = 0;
|
||||
|
||||
basicStats = {
|
||||
today_sum: 0,
|
||||
today_count: 0,
|
||||
week_sum: 0,
|
||||
week_count: 0,
|
||||
month_sum: 0,
|
||||
month_count: 0,
|
||||
user_sum: 0,
|
||||
user_count: 0,
|
||||
global_sum: 0,
|
||||
global_count: 0,
|
||||
user_position: 0,
|
||||
disableSectorButton: boolean = false;
|
||||
|
||||
weekPurchaseList = {
|
||||
first: 0,
|
||||
second: 0,
|
||||
max: 0,
|
||||
sum: 0,
|
||||
count: 0,
|
||||
};
|
||||
|
||||
sectorNames = {
|
||||
A: 'Agriculture, Forestry & Fishing',
|
||||
B: 'Mining & Quarrying',
|
||||
C: 'Manufacturing',
|
||||
D: 'Electricity, Gas, Steam & Air Conditioning',
|
||||
E: 'Water & Waste Management',
|
||||
F: 'Construction',
|
||||
G: 'Wholesale & Retail Trade',
|
||||
H: 'Transportation & Storage',
|
||||
I: 'Accomodation & Food Services',
|
||||
J: 'Information & Communication',
|
||||
K: 'Financial & Insurance Activities',
|
||||
L: 'Real Estate',
|
||||
M: 'Professional, Scientfic & Technical',
|
||||
N: 'Administrative & Support Services',
|
||||
O: 'Public Administration, Defence & Social Security',
|
||||
P: 'Education',
|
||||
Q: 'Human Health & Social Work',
|
||||
R: 'Arts, Entertainment & Recreation',
|
||||
S: 'Other Service Activities',
|
||||
T: 'Household Domestic Business',
|
||||
U: 'Extraterritorial Organisations and Bodies'
|
||||
}
|
||||
|
||||
sectorIcons = {
|
||||
A: 'icon-drop',
|
||||
B: 'icon-diamond',
|
||||
C: 'icon-settings',
|
||||
D: 'icon-energy',
|
||||
E: 'icon-trash',
|
||||
F: 'icon-wrench',
|
||||
G: 'icon-tag',
|
||||
H: 'icon-speedometer',
|
||||
I: 'icon-cup',
|
||||
J: 'icon-feed',
|
||||
K: 'icon-credit-card',
|
||||
L: 'icon-graph',
|
||||
M: 'icon-chemistry',
|
||||
N: 'icon-drawer',
|
||||
O: 'icon-pie-chart',
|
||||
P: 'icon-graduation',
|
||||
Q: 'icon-support',
|
||||
R: 'icon-film',
|
||||
S: 'icon-calendar',
|
||||
T: 'icon-home',
|
||||
U: 'icon-globe',
|
||||
}
|
||||
|
||||
sectorClasses = {
|
||||
A: 'bg-primary',
|
||||
B: 'bg-success',
|
||||
C: 'bg-danger',
|
||||
D: 'bg-warning',
|
||||
E: 'bg-info',
|
||||
F: 'bg-primary',
|
||||
G: 'bg-success',
|
||||
H: 'bg-danger',
|
||||
I: 'bg-warning',
|
||||
J: 'bg-info',
|
||||
K: 'bg-primary',
|
||||
L: 'bg-success',
|
||||
M: 'bg-danger',
|
||||
N: 'bg-warning',
|
||||
O: 'bg-info',
|
||||
P: 'bg-primary',
|
||||
Q: 'bg-success',
|
||||
R: 'bg-danger',
|
||||
S: 'bg-warning',
|
||||
T: 'bg-info',
|
||||
U: 'bg-primary',
|
||||
}
|
||||
|
||||
sectorLetters: string[] = [];
|
||||
sectorPurchases: number[] = [];
|
||||
sectorLimit: number = 10;
|
||||
|
||||
sectorList: any;
|
||||
|
||||
// Graph widgets
|
||||
public widgetList = [
|
||||
{
|
||||
type: 'graph',
|
||||
name: 'total_last_week',
|
||||
icon: 'icon-diamond',
|
||||
title: 'Last Week Total',
|
||||
dataType: DataType.currency,
|
||||
},
|
||||
{
|
||||
type: 'graph',
|
||||
name: 'avg_spend_last_week',
|
||||
icon: 'icon-diamond',
|
||||
title: 'Last Week Avg. Spend',
|
||||
dataType: DataType.currency,
|
||||
},
|
||||
{
|
||||
type: 'graph',
|
||||
name: 'total_last_month',
|
||||
title: 'Last Month Total',
|
||||
dataType: DataType.currency,
|
||||
},
|
||||
{
|
||||
type: 'graph',
|
||||
name: 'avg_spend_last_month',
|
||||
title: 'Last Month Avg. Spend',
|
||||
dataType: DataType.currency,
|
||||
},
|
||||
];
|
||||
|
||||
constructor(
|
||||
private api: ApiService,
|
||||
) {
|
||||
this.api.basicStats().subscribe(
|
||||
this.api.customerStats().subscribe(
|
||||
result => {
|
||||
this.basicStats = result;
|
||||
this.setWeekPurchaseList(result.weeks);
|
||||
this.setSectorList(result.sectors);
|
||||
},
|
||||
error => {
|
||||
console.log('Retrieval Error');
|
||||
|
@ -48,6 +153,26 @@ export class DashboardCustomerComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
public setWeekPurchaseList (data: any) {
|
||||
this.weekPurchaseList = {
|
||||
first: data.first,
|
||||
second: data.second,
|
||||
max: data.max,
|
||||
sum: data.sum,
|
||||
count: data.count,
|
||||
};
|
||||
}
|
||||
|
||||
public setSectorList (data: any) {
|
||||
this.sectorLetters = Object.keys(data.sectors).map(key => data.sectors[key]);
|
||||
this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]);
|
||||
}
|
||||
|
||||
public loadMore () {
|
||||
this.disableSectorButton = true;
|
||||
this.sectorLimit = 22;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
[graphName]="widget.name"
|
||||
[graphTitle]="widget.title"
|
||||
[graphIcon]="widget.icon"
|
||||
[dataType]="widget.dataType"></widget-graph>
|
||||
[dataType]="widget.dataType">
|
||||
</widget-graph>
|
||||
</div><!--/.col-->
|
||||
</div><!--/.row-->
|
||||
<panel-graph></panel-graph>
|
||||
|
|
|
@ -23,7 +23,9 @@ import { TrailMapComponent } from './trail-map.component';
|
|||
|
||||
import { GraphWidget } from '../widgets/graph-widget.component';
|
||||
import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component';
|
||||
import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component';
|
||||
import { GraphPanel } from '../panels/graph-panel.component';
|
||||
import { PiePanel } from '../panels/pie-panel.component';
|
||||
|
||||
import { DashboardRoutingModule } from './dashboard.routing';
|
||||
import { OrgResultComponent } from '../shared/org-result.component';
|
||||
|
@ -69,7 +71,9 @@ import { environment } from '../../environments/environment';
|
|||
FeedbackComponent,
|
||||
GraphWidget,
|
||||
OrgBarSnippetComponent,
|
||||
CustBarSnippetComponent,
|
||||
GraphPanel,
|
||||
PiePanel,
|
||||
],
|
||||
providers: [
|
||||
CurrencyPipe,
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Position</th>
|
||||
<th>Value</th>
|
||||
<th>Purchase Time</th>
|
||||
<th>Name</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -4,11 +4,39 @@
|
|||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>Story Trail</strong>
|
||||
<small>Click a marker to get location details.</small>
|
||||
<select type="text" [(ngModel)]="assocMap" (ngModelChange)="viewBoundsChanged()">
|
||||
<option value="lis" selected>Lancaster Independent Story</option>
|
||||
<option value="esta">ESTA</option>
|
||||
</select>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12 col-sm-6 mb-3">
|
||||
<small>Select a Story Trail to see all the businesses in that story on the map.<br>
|
||||
Click an icon on the map to get more information.</small>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 order-12">
|
||||
<button type="button" class="btn btn-outline-info btn-lg float-right" (click)="openModalAssoc(templateAssoc)">Select Story Trail</button>
|
||||
</div>
|
||||
</div>
|
||||
<ng-template #templateAssoc>
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title pull-left">Select View</h4>
|
||||
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef2.hide()">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-6 text-center">
|
||||
<img src="assets/img/association/lis-logo.png" class="w-50" alt="lis logo"><br>
|
||||
<button type="button" class="btn btn-success mt-3" (click)="modalRef2.hide(); assocMap = 'lis'">Lancaster Independent Story</button>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 text-center">
|
||||
<img src="assets/img/association/esta-logo.png" class="w-50" alt="lis logo"><br>
|
||||
<button type="button" class="btn btn-success mt-3" (click)="modalRef2.hide(); assocMap = 'esta'">ESTA Association</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" (click)="modalRef2.hide()">Close</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</div>
|
||||
<div class="modal fade" bsModal #statusModal="bs-modal" [config]="{backdrop: false, animated: false}"
|
||||
tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
|
|
|
@ -14,6 +14,7 @@ export class TrailMapComponent implements OnInit, AfterViewInit {
|
|||
lng: number = -2.8007;
|
||||
zoom: number = 12;
|
||||
public modalRef: BsModalRef;
|
||||
public modalRef2: BsModalRef;
|
||||
clickedMarker: any;
|
||||
assocMap = 'lis';
|
||||
assocLogo: string;
|
||||
|
@ -45,6 +46,10 @@ export class TrailMapComponent implements OnInit, AfterViewInit {
|
|||
this.modalRef = this.modalService.show(template);
|
||||
}
|
||||
|
||||
openModalAssoc(templateAssoc: TemplateRef<any>) {
|
||||
this.modalRef2 = this.modalService.show(templateAssoc);
|
||||
}
|
||||
|
||||
public onMarkerClick(clickedMarker, template: TemplateRef<any>) {
|
||||
console.log(clickedMarker);
|
||||
this.clickedMarker = clickedMarker;
|
||||
|
|
27
src/app/panels/pie-panel.component.html
Normal file
27
src/app/panels/pie-panel.component.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<div class="card">
|
||||
<div class="card-block">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h4 class="card-title mb-0">Local Purchases</h4>
|
||||
</div><!--/.col-->
|
||||
<div class="col-sm-4 hidden-sm-down">
|
||||
<div class="btn-toolbar float-right" role="toolbar" aria-label="Toolbar with button groups">
|
||||
<div class="btn-group mr-3" data-toggle="buttons" aria-label="First group">
|
||||
<label class="btn btn-outline-secondary active">
|
||||
<input type="radio" name="options" id="option2" checked> Week
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--/.col-->
|
||||
</div><!--/.row-->
|
||||
<div class="chart-wrapper">
|
||||
<canvas baseChart class="chart"
|
||||
[data]="doughnutChartData"
|
||||
[labels]="doughnutChartLabels"
|
||||
[legend]="chartLegend"
|
||||
[chartType]="chartType"
|
||||
(chartHover)="chartHovered($event)"
|
||||
(chartClick)="chartClicked($event)"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
57
src/app/panels/pie-panel.component.ts
Normal file
57
src/app/panels/pie-panel.component.ts
Normal file
|
@ -0,0 +1,57 @@
|
|||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { CustPiesService } from '../providers/cust-pies.service';
|
||||
import { DataType } from '../shared/data-types.enum';
|
||||
import { ChartData } from '../_interfaces/chart-data';
|
||||
|
||||
@Component({
|
||||
selector: 'panel-pie',
|
||||
templateUrl: 'pie-panel.component.html',
|
||||
})
|
||||
export class PiePanel implements OnInit {
|
||||
|
||||
public chartType = 'doughnut';
|
||||
public chartLegend = true;
|
||||
public doughnutChartLabels: string[] = [];
|
||||
public doughnutChartData: number[] = [];
|
||||
|
||||
|
||||
//Old
|
||||
|
||||
// public mainChartElements = 7;
|
||||
|
||||
constructor(
|
||||
private pieService: CustPiesService,
|
||||
) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.pieService.getPie()
|
||||
.subscribe( result => this.setData(result.pie) );
|
||||
}
|
||||
|
||||
private setData(data: any) {
|
||||
this.doughnutChartData = Object.keys(data).map(key => data[key]);
|
||||
// setTimeout is currently a workaround for ng2-charts labels
|
||||
setTimeout(() => this.doughnutChartLabels = Object.keys(data), 0);
|
||||
}
|
||||
|
||||
// convert Hex to RGBA
|
||||
public convertHex(hex: string, opacity: number) {
|
||||
hex = hex.replace('#', '');
|
||||
const r = parseInt(hex.substring(0, 2), 16);
|
||||
const g = parseInt(hex.substring(2, 4), 16);
|
||||
const b = parseInt(hex.substring(4, 6), 16);
|
||||
|
||||
const rgba = 'rgba(' + r + ', ' + g + ', ' + b + ', ' + opacity / 100 + ')';
|
||||
return rgba;
|
||||
}
|
||||
|
||||
// events
|
||||
public chartClicked(e: any): void {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
public chartHovered(e: any): void {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
}
|
|
@ -286,10 +286,10 @@ export class ApiService {
|
|||
}
|
||||
|
||||
// Basic Customer User stats API
|
||||
public basicStats() {
|
||||
public customerStats() {
|
||||
const key = this.sessionKey;
|
||||
return this.http.post<any>(
|
||||
this.apiUrl + '/stats',
|
||||
this.apiUrl + '/stats/customer',
|
||||
{
|
||||
session_key : key,
|
||||
}
|
||||
|
|
14
src/app/providers/cust-graphs.service.ts
Normal file
14
src/app/providers/cust-graphs.service.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ApiService } from './api-service';
|
||||
|
||||
@Injectable()
|
||||
export class CustGraphsService {
|
||||
private custGraphUrl = '/v1/customer/graphs';
|
||||
|
||||
constructor(private api: ApiService) { }
|
||||
|
||||
public getGraph(name: string, data: any = {}) {
|
||||
data.graph = name;
|
||||
return this.api.post(this.custGraphUrl, data);
|
||||
}
|
||||
}
|
14
src/app/providers/cust-pies.service.ts
Normal file
14
src/app/providers/cust-pies.service.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ApiService } from './api-service';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
@Injectable()
|
||||
export class CustPiesService {
|
||||
private custPieUrl = '/v1/customer/pies';
|
||||
|
||||
constructor(private api: ApiService) { }
|
||||
|
||||
public getPie(): Observable<any> {
|
||||
return this.api.post(this.custPieUrl);
|
||||
}
|
||||
}
|
15
src/app/providers/cust-snippets.service.ts
Normal file
15
src/app/providers/cust-snippets.service.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ApiService } from './api-service';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
@Injectable()
|
||||
export class CustSnippetsService {
|
||||
private custSnippetsUrl = '/v1/customer/snippets';
|
||||
|
||||
constructor(private api: ApiService) { }
|
||||
|
||||
// This endpoint should mimic basicStats
|
||||
public getData(): Observable<any> {
|
||||
return this.api.post(this.custSnippetsUrl);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ import { ApiService } from './api-service';
|
|||
|
||||
@Injectable()
|
||||
export class OrgGraphsService {
|
||||
private orgGraphUrl = '/v1/organisation/graphs';
|
||||
private orgGraphUrl = '/v1/customer/graphs';
|
||||
|
||||
constructor(private api: ApiService) { }
|
||||
|
||||
|
|
37
src/app/snippets/cust-snippet-bar.component.html
Normal file
37
src/app/snippets/cust-snippet-bar.component.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<div class="card text-center">
|
||||
<div class="card-block">
|
||||
<ul style="list-style: none; padding-left: 0;">
|
||||
<div class="row no-gutters">
|
||||
<div class="col-12 col-sm-6 col-md-3 mx-auto">
|
||||
<li class="hidden-sm-down">
|
||||
<div>My Points</div>
|
||||
<div class="number-circle mx-auto"><strong>{{ userSum / 10 | number:'1.0-0' }}</strong></div>
|
||||
</li>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 col-md-3 mx-auto">
|
||||
<li class="hidden-sm-down">
|
||||
<div class="">My Rank</div>
|
||||
<div *ngIf="userPosition == 0" class="statuscontent">
|
||||
<div class="number-circle mx-auto"><strong>Unranked</strong></div>
|
||||
</div>
|
||||
<div *ngIf="userPosition != 0" class="statuscontent">
|
||||
<div class="number-circle mx-auto"><strong>{{ userPosition }}</strong></div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 col-md-3 mx-auto">
|
||||
<li class="hidden-sm-down">
|
||||
<div class="">My Total Spend</div>
|
||||
<div class="number-circle mx-auto"><strong>{{ userSum | currency:'GBP':'symbol':'1.2-2' }}</strong></div>
|
||||
</li>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 col-md-3 mx-auto">
|
||||
<li class="hidden-sm-down">
|
||||
<div class="">Value to Local Economy</div>
|
||||
<div class="number-circle mx-auto"><strong>{{ userSum * 2.3 | currency:'GBP':'symbol':'1.2-2' }}</strong></div>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
26
src/app/snippets/cust-snippet-bar.component.ts
Normal file
26
src/app/snippets/cust-snippet-bar.component.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { CustSnippetsService } from '../providers/cust-snippets.service';
|
||||
|
||||
@Component({
|
||||
selector: 'snippet-bar-cust',
|
||||
templateUrl: 'cust-snippet-bar.component.html',
|
||||
})
|
||||
export class CustBarSnippetComponent implements OnInit {
|
||||
|
||||
public userSum = 0;
|
||||
public userPosition = 0;
|
||||
|
||||
constructor(
|
||||
private snippetsService: CustSnippetsService,
|
||||
) { }
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.snippetsService.getData()
|
||||
.subscribe(
|
||||
result => {
|
||||
this.userSum = result.snippets.user_sum;
|
||||
this.userPosition = result.snippets.user_position;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -35,12 +35,21 @@ export class GraphWidget implements OnInit {
|
|||
maintainAspectRatio: false,
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
time: {
|
||||
unit: 'day',
|
||||
displayFormats: {
|
||||
day: 'MMM D',
|
||||
},
|
||||
tooltipFormat: 'MMM D',
|
||||
},
|
||||
gridLines: {
|
||||
color: 'transparent',
|
||||
zeroLineColor: 'transparent'
|
||||
},
|
||||
ticks: {
|
||||
fontSize: 2,
|
||||
source: 'data',
|
||||
fontColor: 'transparent',
|
||||
}
|
||||
|
||||
|
@ -106,6 +115,12 @@ export class GraphWidget implements OnInit {
|
|||
private setData(data: any) {
|
||||
this.setChartData(data.data);
|
||||
this.setChartLabels(data.labels);
|
||||
this.setChartBounds(data.bounds);
|
||||
}
|
||||
|
||||
private setChartBounds(data) {
|
||||
this.lineChartOptions.scales.xAxes[0].time.max = data.max;
|
||||
this.lineChartOptions.scales.xAxes[0].time.min = data.min;
|
||||
}
|
||||
|
||||
private setChartData(data: Array<number>) {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 19 KiB |
|
@ -24,6 +24,20 @@ agm-map {
|
|||
width: 15%;
|
||||
}
|
||||
|
||||
// circle for text
|
||||
// TODO: Make these resize based on inside content
|
||||
.number-circle {
|
||||
height: 10rem;
|
||||
border-radius:50%;
|
||||
text-align:center;
|
||||
width: 10rem;
|
||||
padding: 5rem 5%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
background: #20a8d8;
|
||||
color: white;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
// white title font variant on type-2 as defined in _widgets.css
|
||||
.horizontal-bars {
|
||||
padding: 0;
|
||||
|
|
Reference in a new issue