This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
FoodLoop-Web/src/app/dashboard/category-month.component.ts

68 lines
1.8 KiB
TypeScript
Raw Normal View History

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';
@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[] = [];
categoryLimitFirst: number = 10;
2018-01-22 17:23:56 +00:00
myWeek1: any;
myWeek2: any;
myWeek3: any;
myWeek4: any;
constructor(
private api: ApiService,
) {
2018-01-22 17:23:56 +00:00
this.setDate();
this.api.categoryTransactionList().subscribe(
result => {
console.log(result);
2018-01-22 17:23:56 +00:00
this.setData(result);
},
error => {
console.log('Retrieval Error');
console.log( error._body );
}
);
}
2018-01-22 17:23:56 +00:00
private loadMore () {
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]);
}
ngOnInit(): void {
}
}