2018-01-17 17:36:28 +00:00
|
|
|
import { Directive, Component, OnInit } from '@angular/core';
|
|
|
|
import { ApiService } from '../providers/api-service';
|
|
|
|
import { DataType } from '../shared/data-types.enum';
|
2018-01-22 17:23:56 +00:00
|
|
|
import * as moment from 'moment';
|
|
|
|
import 'rxjs/add/operator/map';
|
2018-01-17 17:36:28 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: 'category-month.component.html'
|
|
|
|
})
|
|
|
|
export class CategoryMonthComponent implements OnInit {
|
|
|
|
|
|
|
|
disableCategoryButtonFirst: boolean = false;
|
|
|
|
|
|
|
|
weekPurchaseList = {
|
|
|
|
first: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
categoryList: number[] = [];
|
2018-01-22 17:23:56 +00:00
|
|
|
dayList: any[] = [];
|
|
|
|
valueList: number[] = [];
|
2018-01-17 17:36:28 +00:00
|
|
|
categoryLimitFirst: number = 10;
|
2018-01-22 17:23:56 +00:00
|
|
|
myWeek1: any;
|
|
|
|
myWeek2: any;
|
|
|
|
myWeek3: any;
|
|
|
|
myWeek4: any;
|
2018-01-17 17:36:28 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private api: ApiService,
|
|
|
|
) {
|
2018-01-22 17:23:56 +00:00
|
|
|
this.setDate();
|
2018-01-17 17:36:28 +00:00
|
|
|
this.api.categoryTransactionList().subscribe(
|
|
|
|
result => {
|
|
|
|
console.log(result);
|
2018-01-22 17:23:56 +00:00
|
|
|
this.setData(result);
|
2018-01-17 17:36:28 +00:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.log('Retrieval Error');
|
|
|
|
console.log( error._body );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-01-22 17:23:56 +00:00
|
|
|
private loadMore () {
|
2018-01-17 17:36:28 +00:00
|
|
|
this.disableCategoryButtonFirst = true;
|
|
|
|
this.categoryLimitFirst = 100;
|
|
|
|
}
|
|
|
|
|
2018-01-22 17:23:56 +00:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:36:28 +00:00
|
|
|
ngOnInit(): void {
|
|
|
|
}
|
|
|
|
}
|