File

libs/video-stat-dashboard/src/views-breakdown/views-breakdown.component.ts

Metadata

selector views-breakdown
templateUrl ./views-breakdown.component.html

Index

Properties
Methods

Constructor

constructor(viewsFilterService: ViewsFilterService, dashboardService: DashboardService, viewsBreakdownService: ViewsBreakdownService)
Parameters :
Name Type Optional
viewsFilterService ViewsFilterService no
dashboardService DashboardService no
viewsBreakdownService ViewsBreakdownService no

Methods

addNewGraph
addNewGraph()
Returns : void
removeGroup
removeGroup(group: number)
Parameters :
Name Type Optional
group number no
Returns : void

Properties

currentVideo
currentVideo: Observable<Video>
Type : Observable<Video>
graphData
graphData: Observable<[]>
Type : Observable<[]>
newGraph
newGraph: FormControl
Type : FormControl
Default value : new FormControl('age')
viewsBreakdown
viewsBreakdown: Observable<string[]>
Type : Observable<string[]>
viewsFilterState
viewsFilterState: Observable<ViewsFilterState>
Type : Observable<ViewsFilterState>
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { FormControl } from '@angular/forms';

import { ViewsFilterService } from '../services/views-filter.service';
import { Video, ViewsFilterState } from '../+state/video-stats.interfaces';
import { DashboardService } from '../services/dashboard.service';
import { ViewsBreakdownService, GraphData } from '../services/views-breakdown.service';

@Component({
  selector: 'views-breakdown',
  templateUrl: './views-breakdown.component.html'
})
export class ViewsBreakdownComponent {
  viewsFilterState: Observable<ViewsFilterState>;
  currentVideo: Observable<Video>;
  viewsBreakdown: Observable<string[]>;
  graphData: Observable<GraphData[]>;

  // Could be used as ngModel example if desired.
  newGraph: FormControl = new FormControl('age');

  constructor(
    viewsFilterService: ViewsFilterService,
    dashboardService: DashboardService,
    private viewsBreakdownService: ViewsBreakdownService) {
    this.viewsFilterState = viewsFilterService.filterState;
    this.currentVideo = dashboardService.currentVideo;
    this.viewsBreakdown = viewsBreakdownService.getBreakdowns();
    this.graphData = viewsBreakdownService.getGraphData();
  }

  addNewGraph() {
    this.viewsBreakdownService.addNewGraphAxis(this.newGraph.value);
  }

  removeGroup(group: number) {
    this.viewsBreakdownService.removeGroup(group);
  }
}
<div class="card">
  <div class="card-content">
    <div class="card-title">Views Breakdown</div>

    <filter-state-display
      [viewsFilterState]="viewsFilterState | async"
      (removeGroup)="removeGroup($event)"
    ></filter-state-display>

    <views-breakdown-display
      [currentVideo]="currentVideo | async"
      [viewsBreakdown]="viewsBreakdown | async"
      [graphData]="graphData | async"
    >
    </views-breakdown-display>

    <div class="card">
      <div class="card-content">
        <div class="card-title">Add New Graph</div>
        <p>Select an x-axis and click Render</p>
        <div>
          <label for="newGraph">Axis:</label>
          <select name="newGraph" id="axis" [formControl]="newGraph" class="browser-default">
            <option value="age">Age</option>
            <option value="date">Day</option>
            <option value="region">Region</option>
          </select>
          <button (click)="addNewGraph()" class="btn waves-effect waves-light">Render</button>
        </div>
      </div>
    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""