<commit_before>require('./style/index.less');

var React = require('react');

var __ = require('locale/client/dashboard.lang.json');
var unitConverter = require('client/utils/unit_converter');

class ResourceQuota extends React.Component {

  constructor(props) {
    super(props);

    this.state = {
      quota: []
    };
  }

  componentWillMount() {
    var quota = [{
      title: __.compute,
      items: [{
        title: __.instance,
        key: 'instances',
        link: 'instance'
      }, {
        title: __.keypair,
        key: 'key_pairs',
        link: 'keypair'
      }, {
        title: __.cpu,
        key: 'cores'
      }]
    }, {
      title: __.network,
      items: [{
        title: __.network,
        key: 'network',
        link: 'network'
      }, {
        title: __.subnet,
        key: 'subnet',
        link: 'subnet'
      }, {
        title: __['floating-ip'],
        key: 'floatingip',
        link: 'floating-ip'
      }, {
        title: __.port,
        key: 'port',
        link: 'port'
      }, {
        title: __.router,
        key: 'router',
        link: 'router'
      }, {
        title: __['security-group'],
        key: 'security_group',
        link: 'security-group'
      }]
    }, {
      title: __.storage,
      items: [{
        title: __.ssd + __.volume,
        key: 'volumes_ssd',
        link: 'volume'
      }, {
        title: __.sata + __.volume,
        key: 'volumes_sata',
        link: 'volume'
      }, {
        title: __.ssd + __.volume + __.gigabyte + __.unit_gb,
        key: 'gigabytes_ssd',
        link: 'volume'
      }, {
        title: __.sata + __.volume + __.gigabyte + __.unit_gb,
        key: 'gigabytes_sata',
        link: 'volume'
      }, {
        title: __.ssd + __.snapshot,
        key: 'snapshots_ssd',
        link: 'snapshot'
      }, {
        title: __.sata + __.snapshot,
        key: 'snapshots_sata',
        link: 'snapshot'
      }, {
        title: __.ram + __.unit_gb,
        key: 'ram'
      }]
    }];

    this.setState({
      quota: quota
    });
  }

  render() {
    var quota = this.state.quota,
      overview = this.props.overview;

    return (
      <div className="resource-quota">
        <div className="title">{__.resource + __.quota}</div>
        <div className="content">
          {quota.map((ele, index) =>
            <div key={index}>
              <h3>{ele.title}</h3>
              <ul className="quota-list">
                {ele.items.map((item, i) => {
                  var used, total, inUse, inUseClassName;

                  if (overview[item.key]) {
                    if (overview[item.key].total > -1) {
                      total = overview[item.key].total;
                    } else {
                      total = __.infinity;
                    }<commit_msg>dashboard overview fix ram show<commit_after>require('./style/index.less');

var React = require('react');

var __ = require('locale/client/dashboard.lang.json');
var unitConverter = require('client/utils/unit_converter');

class ResourceQuota extends React.Component {

  constructor(props) {
    super(props);

    this.state = {
      quota: []
    };
  }

  componentWillMount() {
    var quota = [{
      title: __.compute,
      items: [{
        title: __.instance,
        key: 'instances',
        link: 'instance'
      }, {
        title: __.keypair,
        key: 'key_pairs',
        link: 'keypair'
      }, {
        title: __.cpu,
        key: 'cores'
      }, {
        title: __.ram + __.unit_gb,
        key: 'ram'
      }]
    }, {
      title: __.network,
      items: [{
        title: __.network,
        key: 'network',
        link: 'network'
      }, {
        title: __.subnet,
        key: 'subnet',
        link: 'subnet'
      }, {
        title: __['floating-ip'],
        key: 'floatingip',
        link: 'floating-ip'
      }, {
        title: __.port,
        key: 'port',
        link: 'port'
      }, {
        title: __.router,
        key: 'router',
        link: 'router'
      }, {
        title: __['security-group'],
        key: 'security_group',
        link: 'security-group'
      }]
    }, {
      title: __.storage,
      items: [{
        title: __.ssd + __.volume,
        key: 'volumes_ssd',
        link: 'volume'
      }, {
        title: __.sata + __.volume,
        key: 'volumes_sata',
        link: 'volume'
      }, {
        title: __.ssd + __.volume + __.gigabyte + __.unit_gb,
        key: 'gigabytes_ssd',
        link: 'volume'
      }, {
        title: __.sata + __.volume + __.gigabyte + __.unit_gb,
        key: 'gigabytes_sata',
        link: 'volume'
      }, {
        title: __.ssd + __.snapshot,
        key: 'snapshots_ssd',
        link: 'snapshot'
      }, {
        title: __.sata + __.snapshot,
        key: 'snapshots_sata',
        link: 'snapshot'
      }]
    }];

    this.setState({
      quota: quota
    });
  }

  render() {
    var quota = this.state.quota,
      overview = this.props.overview;

    return (
      <div className="resource-quota">
        <div className="title">{__.resource + __.quota}</div>
        <div className="content">
          {quota.map((ele, index) =>
            <div key={index}>
              <h3>{ele.title}</h3>
              <ul className="quota-list">
                {ele.items.map((item, i) => {
                  var used, total, inUse, inUseClassName;

                  if (overview[item.key]) {
                    if (overview[item.key].total > -1) {
                      total = overview[item.key].total;
                    } else {
                      total = __.infinity;
                    }
{'fraction_non_alphanumeric': 0.15141843971631205, 'fraction_numerical': 0.0010638297872340426, 'mean_word_length': 1.4949137549756746, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '3713373', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1802, 'n_words': 350}