Placeholder and date math

This commit is contained in:
piratefinn 2018-01-22 17:23:56 +00:00
parent 6cca97cc68
commit 5f2eee81ba
3 changed files with 117 additions and 3 deletions

View file

@ -1,6 +1,93 @@
<div class="animated fadeIn"> <div class="animated fadeIn">
<div class=row> <div class=row>
<div class="col-xl-4 col-md-6"> <div class="col-xl-3 col-md-6">
<div class="card">
<div class="card-block">
<div class="row">
<div class="col-12">
<h4 class="card-title float-left mb-0">Purchases this week</h4>
</div><!--/.col-->
</div><!--/.row-->
<div class="chart-wrapper">
<ul class="horizontal-bars type-2">
<li>
<span class="title">Placeholder Category</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.first | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</li>
<li *ngIf="categoryList.length > 10 && disableCategoryButtonFirst == 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>
</div>
</div>
</div><!--/.col-->
<div class="col-xl-3 col-md-6">
<div class="card">
<div class="card-block">
<div class="row">
<div class="col-12">
<h4 class="card-title float-left mb-0">Purchases this week</h4>
</div><!--/.col-->
</div><!--/.row-->
<div class="chart-wrapper">
<ul class="horizontal-bars type-2">
<li>
<span class="title">Placeholder Category</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.first | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</li>
<li *ngIf="categoryList.length > 10 && disableCategoryButtonFirst == 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>
</div>
</div>
</div><!--/.col-->
<div class="col-xl-3 col-md-6">
<div class="card">
<div class="card-block">
<div class="row">
<div class="col-12">
<h4 class="card-title float-left mb-0">Purchases this week</h4>
</div><!--/.col-->
</div><!--/.row-->
<div class="chart-wrapper">
<ul class="horizontal-bars type-2">
<li>
<span class="title">Placeholder Category</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.first | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</li>
<li *ngIf="categoryList.length > 10 && disableCategoryButtonFirst == 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>
</div>
</div>
</div><!--/.col-->
<div class="col-xl-3 col-md-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">

View file

@ -1,6 +1,8 @@
import { Directive, Component, OnInit } from '@angular/core'; import { Directive, Component, OnInit } from '@angular/core';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import { DataType } from '../shared/data-types.enum'; import { DataType } from '../shared/data-types.enum';
import * as moment from 'moment';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'category-month.component.html' templateUrl: 'category-month.component.html'
@ -14,14 +16,22 @@ export class CategoryMonthComponent implements OnInit {
}; };
categoryList: number[] = []; categoryList: number[] = [];
dayList: any[] = [];
valueList: number[] = [];
categoryLimitFirst: number = 10; categoryLimitFirst: number = 10;
myWeek1: any;
myWeek2: any;
myWeek3: any;
myWeek4: any;
constructor( constructor(
private api: ApiService, private api: ApiService,
) { ) {
this.setDate();
this.api.categoryTransactionList().subscribe( this.api.categoryTransactionList().subscribe(
result => { result => {
console.log(result); console.log(result);
this.setData(result);
}, },
error => { error => {
console.log('Retrieval Error'); console.log('Retrieval Error');
@ -30,11 +40,28 @@ export class CategoryMonthComponent implements OnInit {
); );
} }
public loadMore () { private loadMore () {
this.disableCategoryButtonFirst = true; this.disableCategoryButtonFirst = true;
this.categoryLimitFirst = 100; this.categoryLimitFirst = 100;
} }
private setDate () {
this.myWeek1 = moment().format('YYYY-MM-DD');
this.myWeek2 = moment(this.myWeek1).subtract(1, 'weeks').format('YYYY-MM-DD');
this.myWeek3 = moment(this.myWeek2).subtract(1, 'weeks').format('YYYY-MM-DD');
this.myWeek4 = moment(this.myWeek3).subtract(1, 'weeks').format('YYYY-MM-DD');
console.log(this.myWeek1);
console.log(this.myWeek2);
console.log(this.myWeek3);
console.log(this.myWeek4);
}
private setData (data: any) {
// this.categoryList = Object.keys(data.data.category).map(key => data.data.category[key]);
// this.dayList = Object.keys(data.data.days).map(key => data.data.days[key]);
// this.valueList = Object.keys(data.data.value).map(key => data.data.value[key]);
}
ngOnInit(): void { ngOnInit(): void {
} }
} }

View file

@ -168,7 +168,7 @@ export class DashboardCustomerComponent implements OnInit {
this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]); this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]);
} }
public loadMore () { private loadMore () {
this.disableSectorButton = true; this.disableSectorButton = true;
this.sectorLimit = 22; this.sectorLimit = 22;
} }