Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. /* Subcomponent */
  2.  
  3. import { Component, ElementRef, HostListener, Input } from '@angular/core';
  4.  
  5.  
  6. @Component({
  7. selector: 'charts-filter',
  8. templateUrl: './filter.component.html'
  9. })
  10. export class ChartFilterComponent {
  11. constructor(private el: ElementRef) {}
  12.  
  13. @Input() public dateRange: any;
  14.  
  15. @Input() public users: Array<any> = [];
  16. @Input() public userTyped: Function;
  17.  
  18. @Input() public clientTypes: Array<any> = [];
  19. @Input() public clientTypeTyped: Function;
  20.  
  21. @Input() public clients: Array<any> = [];
  22. @Input() public clientTyped: Function;
  23.  
  24. @Input() public selected: any = {};
  25.  
  26.  
  27. public userChanged(event) {
  28. this.selected['user'] = event;
  29. console.log(this.selected);
  30. }
  31. public userTyped_(event) {
  32. if(this.userTyped) {
  33. this.userTyped(event);
  34. }
  35. }
  36. public clientTypeChanged(event) {
  37. this.selected['clientType'] = event;
  38. console.log(this.selected);
  39. }
  40. public clientTypeTyped_(event) {
  41. if(this.clientTypeTyped) {
  42. this.clientTypeTyped(event);
  43. }
  44. }
  45. public clientChanged(event) {
  46. this.selected['client'] = event;
  47. console.log(this.selected);
  48. }
  49. public clientTyped_(event) {
  50. if(this.clientTyped) {
  51. this.clientTyped(event);
  52. }
  53. }
  54.  
  55. }
  56.  
  57.  
  58. /* Component */
  59.  
  60. import { Component, OnInit } from '@angular/core';
  61. import { Router, ActivatedRoute } from '@angular/router';
  62.  
  63. import { APIService } from '../api.service';
  64.  
  65. declare var $:any;
  66.  
  67. @Component({
  68. selector: 'app-charts',
  69. templateUrl: './charts.component.html',
  70. styleUrls: ['./charts.component.scss'],
  71. })
  72.  
  73.  
  74. export class ChartsComponent implements OnInit {
  75. public dateRange: any;
  76.  
  77. public users: any = [{text: 'Asdf', id: 1}, {text: 'Lol', id: 2}];
  78. public clientTypes: any = [];
  79. public clients: any = [];
  80.  
  81. public leftSelected: any = {};
  82. public rightSelected: any = {};
  83.  
  84. constructor (private api: APIService) { }
  85.  
  86. ngOnInit() { }
  87.  
  88. userTyped(event) {
  89. console.log(event);
  90. }
  91.  
  92. clientTypeTypes(even) {
  93. console.log(event);
  94. }
  95.  
  96. clientTypedd(event) {
  97. console.log(this);
  98. this.api.getCars(event).subscribe(res => {
  99. this.clients = [];
  100. for(const car in res) {
  101. this.clients.push({id: car['id'], text: `${car['license_plate']} | ${car['phone_number]}']}`});
  102. }
  103. });
  104. console.log(event);
  105. }
  106. }
  107.  
  108.  
  109. /* HTML */
  110.  
  111. <h1> Statistici </h1>
  112.  
  113. <div class="container-fluid">
  114.  
  115. <div class="row">
  116. <div class="col-md-6">
  117. <charts-filter
  118. [dateRange]="dateRange"
  119. [users]="users"
  120. [userTyped]="userTyped"
  121. [clientTypes]="clientTypes"
  122. [clients]="clients"
  123. [clientTyped]="clientTypedd"
  124. [selected]="leftSelected"></charts-filter>
  125.  
  126. </div>
  127.  
  128. <div class="col-md-6">
  129. <charts-filter></charts-filter>
  130. </div>
  131. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement