ceb51b98fe32a0aaf9379b207902c4be5f60d4d763452d178a3434e27614e198.json 7.3 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./statistic.component.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./statistic.component.scss?ngResource\";\nimport { StatisticService } from './../../../services/statistic.service';\nimport { Component } from '@angular/core';\nlet StatisticComponent = class StatisticComponent {\n constructor(StatisticService) {\n this.StatisticService = StatisticService;\n this.statisticArray = [];\n this.barChartData = [];\n this.isFoo = true;\n //chart\n this.barChartOptions = {\n responsive: true\n };\n this.barChartLabels = ['Une entrée ou un dessert au choix', 'Un burger au choix', 'Un menu du jour', 'Un menu au choix', '70% de réduction'];\n this.barChartBar = 'bar';\n this.barChartHorizontal = 'horizontalBar';\n this.barChartLegend = true;\n this.barChartPlugins = [];\n this.displayedColumns = ['gain', 'used', 'served', 'total'];\n }\n ngOnInit() {\n this.subscribeToStatistic();\n }\n //sbscribe statistic\n subscribeToStatistic() {\n this.StatisticService.getStatistic().subscribe(res => {\n this.statisticArray = res.data;\n this.barChartData = [{\n data: this.statisticArray.map(res => res.total),\n label: 'totalité'\n }, {\n data: this.statisticArray.map(res => res.used),\n label: 'utiliser'\n }, {\n data: this.statisticArray.map(res => res.served),\n label: 'server'\n }];\n });\n }\n getTotal() {\n return this.statisticArray.map(t => t.total).reduce((acc, value) => acc + value, 0);\n }\n getUsed() {\n return this.statisticArray.map(t => t.used).reduce((acc, value) => acc + value, 0);\n }\n getServed() {\n return this.statisticArray.map(t => t.served).reduce((acc, value) => acc + value, 0);\n }\n //texte button \n getBtnText() {\n if (this.isFoo) {\n return 'diagramme à bandes horizontales';\n } else return 'diagramme à bandes verticales';\n }\n static #_ = this.ctorParameters = () => [{\n type: StatisticService\n }];\n};\nStatisticComponent = __decorate([Component({\n selector: 'app-statistic',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], StatisticComponent);\nexport { StatisticComponent };","map":{"version":3,"names":["StatisticService","Component","StatisticComponent","constructor","statisticArray","barChartData","isFoo","barChartOptions","responsive","barChartLabels","barChartBar","barChartHorizontal","barChartLegend","barChartPlugins","displayedColumns","ngOnInit","subscribeToStatistic","getStatistic","subscribe","res","data","map","total","label","used","served","getTotal","t","reduce","acc","value","getUsed","getServed","getBtnText","_","__decorate","selector","template","__NG_CLI_RESOURCE__0"],"sources":["C:\\FatboarProject\\angular-client\\src\\app\\components\\admin\\statistic\\statistic.component.ts"],"sourcesContent":["import { StatisticService } from './../../../services/statistic.service';\r\nimport { Component, OnInit } from '@angular/core';\r\nimport { ChartOptions, ChartType, ChartDataSets } from 'chart.js';\r\nimport { Label } from 'ng2-charts';\r\nimport { Statistic } from 'src/app/models/statisticResponse';\r\n\r\n\r\n@Component({\r\n selector: 'app-statistic',\r\n templateUrl: './statistic.component.html',\r\n styleUrls: ['./statistic.component.scss']\r\n})\r\nexport class StatisticComponent implements OnInit {\r\n\r\n\r\n statisticArray: Statistic[]=[];\r\n barChartData: ChartDataSets[] = [];\r\n isFoo : boolean = true;\r\n\r\n\r\n constructor(private StatisticService: StatisticService) { }\r\n\r\n ngOnInit(): void {\r\n\r\n this.subscribeToStatistic();\r\n\r\n }\r\n\r\n\r\n\r\n //sbscribe statistic\r\n subscribeToStatistic() {\r\n\r\n this.StatisticService.getStatistic().subscribe((res) => {\r\n \r\n this.statisticArray = res.data;\r\n \r\n\r\n this.barChartData = [\r\n { data: this.statisticArray.map(res => res.total), label: 'totalité' },\r\n { data: this.statisticArray.map(res => res.used), label: 'utiliser' },\r\n { data: this.statisticArray.map(res => res.served), label: 'server' }\r\n ];\r\n \r\n \r\n})\r\n \r\n \r\n\r\n }\r\n\r\n\r\n//chart\r\n public barChartOptions: ChartOptions = {\r\n responsive: true,\r\n };\r\n public barChartLabels: Label[] =\r\n ['Une entrée ou un dessert au choix',\r\n 'Un burger au choix',\r\n 'Un menu du jour',\r\n 'Un menu au choix',\r\n '70% de réduction'];\r\n public barChartBar : ChartType = 'bar'\r\n public barChartHorizontal : ChartType = 'horizontalBar';\r\n public barChartLegend = true;\r\n public barChartPlugins = [];\r\n\r\n \r\n \r\n \r\n \r\n\r\n displayedColumns: string[] = ['gain', 'used', 'served','total'];\r\n \r\n\r\n\r\n getTotal() {\r\n return this.statisticArray.map(t => t.total).reduce((acc, value) => acc + value, 0);\r\n \r\n }\r\n getUsed() {\r\n return this.statisticArray.map(t => t.used).reduce((acc, value) => acc + value, 0);\r\n }\r\n getServed() {\r\n return this.statisticArray.map(t => t.served).reduce((acc, value) => acc + value, 0);\r\n }\r\n\r\n//texte button \r\ngetBtnText(){\r\n if(this.isFoo){\r\n return 'diagramme à bandes horizontales'\r\n }else\r\n return 'diagramme à bandes verticales'\r\n}\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n"],"mappings":";;;AAAA,SAASA,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,SAAS,QAAgB,eAAe;AAW1C,IAAMC,kBAAkB,GAAxB,MAAMA,kBAAkB;EAQ7BC,YAAoBH,gBAAkC;IAAlC,KAAAA,gBAAgB,GAAhBA,gBAAgB;IALpC,KAAAI,cAAc,GAAc,EAAE;IAC9B,KAAAC,YAAY,GAAoB,EAAE;IAClC,KAAAC,KAAK,GAAa,IAAI;IAmCxB;IACS,KAAAC,eAAe,GAAiB;MACrCC,UAAU,EAAE;KACb;IACM,KAAAC,cAAc,GACnB,CAAC,mCAAmC,EAClC,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CAAC;IAChB,KAAAC,WAAW,GAAgB,KAAK;IAChC,KAAAC,kBAAkB,GAAe,eAAe;IAChD,KAAAC,cAAc,GAAG,IAAI;IACrB,KAAAC,eAAe,GAAG,EAAE;IAO3B,KAAAC,gBAAgB,GAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAC,OAAO,CAAC;EApDL;EAE1DC,QAAQA,CAAA;IAEN,IAAI,CAACC,oBAAoB,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