<commit_before>'use strict';

var _      = require('lodash');
var React  = require('react');
var moment = require('moment');

var Impact             = require('dashboard/management/Impact.jsx');
var Performance        = require('dashboard/management/Performance.jsx');
var Access             = require('dashboard/management/Access.jsx');
var SocialData         = require('dashboard/management/SocialData.jsx');
var BulletChartSection = require('./BulletChartSection.jsx');
var DonutChart   = require('component/DonutChart.jsx');

var ManagementDashboard = React.createClass({
  propTypes : {
    dashboard  : React.PropTypes.object.isRequired,
    indicators : React.PropTypes.object.isRequired,

    campaign   : React.PropTypes.object,
    data       : React.PropTypes.object,
    loading    : React.PropTypes.bool,
    location     : React.PropTypes.object,
  },

  getDefaultProps : function () {
    return {
      data    : [],
      loading : true
    };
  },

  render : function () {
    var campaign   = this.props.campaign;
    var printDate  = moment(campaign.start_date).format('MMM YYYY');
    var data       = this.props.data;
    var indicators = _.indexBy(this.props.indicators, 'id');
    var loading    = this.props.loading;
    var location     = _.get(this.props, 'location.name', '');

    var sections = _(this.props.dashboard.charts)
      .groupBy('section')
      .transform(function (result, charts, sectionName) {
        var section = {};
        _.each(charts, (c, i) => {
          section[_.camelCase(_.get(c, 'title', i))] = _.map(c.indicators, ind => indicators[ind]);
        });
        result[sectionName] = section;
      })
      .value();

    if (data.__none__.supply.length != 0) {
      _.filter(data.__none__.supply, d => {
        if (d.indicator.id == 194) {
          d.indicator.short_name = 'On-Time OPV Supply';
          d.value = 1 - d.value;
        }
      });
    }

    return (
      <div id='management-dashboard'>
        <div className='row print-only'>
          <div className='small-12 columns'>
            <h1>
              <span className='campaign'>{ printDate }</span>
              <span className='location'>{ location }</span>
            </h1>
            <h2>
              Polio<br />
              Performance<br />
              Dashboard
            </h2>
            <img src='/static/img/UNICEF.svg' className='logo'/>
          </div>
        </div>

        <div className='row'><commit_msg>[#451] the On-Time OPV Supply chart will show correct when no data<commit_after>'use strict';

var _      = require('lodash');
var React  = require('react');
var moment = require('moment');

var Impact             = require('dashboard/management/Impact.jsx');
var Performance        = require('dashboard/management/Performance.jsx');
var Access             = require('dashboard/management/Access.jsx');
var SocialData         = require('dashboard/management/SocialData.jsx');
var BulletChartSection = require('./BulletChartSection.jsx');
var DonutChart   = require('component/DonutChart.jsx');

var ManagementDashboard = React.createClass({
  propTypes : {
    dashboard  : React.PropTypes.object.isRequired,
    indicators : React.PropTypes.object.isRequired,

    campaign   : React.PropTypes.object,
    data       : React.PropTypes.object,
    loading    : React.PropTypes.bool,
    location     : React.PropTypes.object,
  },

  getDefaultProps : function () {
    return {
      data    : [],
      loading : true
    };
  },

  render : function () {
    var campaign   = this.props.campaign;
    var printDate  = moment(campaign.start_date).format('MMM YYYY');
    var data       = this.props.data;
    var indicators = _.indexBy(this.props.indicators, 'id');
    var loading    = this.props.loading;
    var location     = _.get(this.props, 'location.name', '');

    var sections = _(this.props.dashboard.charts)
      .groupBy('section')
      .transform(function (result, charts, sectionName) {
        var section = {};
        _.each(charts, (c, i) => {
          section[_.camelCase(_.get(c, 'title', i))] = _.map(c.indicators, ind => indicators[ind]);
        });
        result[sectionName] = section;
      })
      .value();

    if (data.__none__.supply.length != 0) {
      _.filter(data.__none__.supply, d => {
        if (_.isEqual(d.indicator.id, 194)) {
          d.indicator.short_name = 'On-Time OPV Supply';
          if (!_.isNull(d.value)) {
            d.value = 1 - d.value;
          }
        }
      });
    }

    return (
      <div id='management-dashboard'>
        <div className='row print-only'>
          <div className='small-12 columns'>
            <h1>
              <span className='campaign'>{ printDate }</span>
              <span className='location'>{ location }</span>
            </h1>
            <h2>
              Polio<br />
              Performance<br />
              Dashboard
            </h2>
            <img src='/static/img/UNICEF.svg' className='logo'/>
          </div>
        </div>

        <div className='row'>
{'fraction_non_alphanumeric': 0.14531435349940688, 'fraction_numerical': 0.0049426650850138395, 'mean_word_length': 2.1917981072555204, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2002617', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1498, 'n_words': 294}