{{dashboards/video-stats/header isOverview=false ownerLogin=owner.id video=video}}

<div class="flex flex--spaceBetween flex--verticalCenter brick brick--theme-grey brick--pd-lg">
  <div class="flex__item">
    {{dashboards/video-stats/date-range-picker
      today=today
      startDate=report.startDate
      endDate=report.endDate
      minimumDate=minimumDate
      setStartDate=(action 'setStartDate')
      setEndDate=(action 'setEndDate')}}
  </div>
  {{!-- <div class="flex__item">
    <button type="button" class="button button--icon">
      <figure class="icon">{{svg-icon path='svg/download'}}</figure>
      <span>{{i18n 'Export to CSV'}}</span>
    </button>
  </div> --}}
</div>
<div class="brick brick--theme-white brick--pd-lg">
  <div class="flex">
    <div class="flex__item mg-r-1">
      <select class="vod-upload__selectbox js-metric-selector" onchange={{action 'setMetric' value='target.value'}}>
        {{#each report.metricOptions as |metric|}}
          <option value={{metric.value}} selected={{eq metric.value report.selectedMetric}}>
            {{metric.display}}
          </option>
        {{/each}}
      </select>
    </div>
    <div class="flex__item">
      <select class="vod-upload__selectbox js-filter-selector" onchange={{action 'setFilter' value='target.value'}}>
        <option value=''>{{i18n 'Add Filter'}}</option>
        {{#each report.filterOptions as |filter|}}
          <option value={{filter.value}} selected={{eq filter.value report.selectedFilter}}>
            {{filter.display}}
          </option>
        {{/each}}
      </select>
    </div>
  </div>
  <div class="pd-t-2">
    {{ember-chart
      type='line'
      data=formattedChartData
      options=videoDetailsGraphOptions
      height=370}}
  </div>
</div>

{{#if (and report.selectedFilter (not-eq report.selectedMetric 'averageviewduration'))}}
  <div class="brick brick--theme-white brick--pd-lg js-video-stats__filter-table">
    <div class="video-stats__table">
      <h3 class="video-stats__table-title js-summary-table__title">
        {{styled-i18n "%{filter} Totals" (hash filter=report.selectedFilterDisplay)}}
      </h3>
      <table class="table table--fixed-cells">
        <thead>
          <tr class="table__header">
            <th class="table__cell table__cell--header">{{i18n "Label"}}</th>
            <th class="table__cell table__cell--header">{{i18n "Total"}}</th>
          </tr>
        </thead>

        {{#each report.timeSeriesQuery as |row|}}
          <tr class="table__row">
            <td class="table__cell">{{row.key}}</td>
            <td class="table__cell">{{commatized row.sum}}</td>
          </tr>
        {{/each}}
      </table>
    </div>
  </div>
{{/if}}
