<commit_before>package ch.fhnw.ima.saav.component

import ch.fhnw.ima.saav.model.app.AppModel
import diode.react.ModelProxy
import japgolly.scalajs.react.ReactComponentB
import japgolly.scalajs.react.vdom.prefix_<^._

import scalacss.ScalaCssReact._

object IndicatorComponent {

  case class Props(proxy: ModelProxy[AppModel])

  private val component = ReactComponentB[Props](IndicatorComponent.getClass.getSimpleName)
    .render_P { p =>

      val model = p.proxy.value

      val indicators = for {
        pinnedEntity <- model.entitySelectionModel.pinned.toSeq
        hoveredSubCriteria <- model.subCriteriaSelectionModel.hovered.toSeq
        focusSubCriteria <- model.qualityModel.criteria.flatMap(_.subCriteria).find(_.id == hoveredSubCriteria).toSeq
        indicator <- focusSubCriteria.indicators
      } yield {
        val value = indicator.groupedValues(pinnedEntity)
        <.div(
          <.div(css.colXs10, indicator.name),
          <.div(css.colXs2, value)
        )
      }

      <.div(
        <.h2("Indicators"),
        <.div(css.row, indicators.toSeq)
      )

    }
    .build

  def apply(proxy: ModelProxy[AppModel]) = component(Props(proxy))

}<commit_msg>#27: Display help while no indicators can be shown<commit_after>package ch.fhnw.ima.saav.component

import ch.fhnw.ima.saav.model.app.AppModel
import diode.react.ModelProxy
import japgolly.scalajs.react.ReactComponentB
import japgolly.scalajs.react.vdom.prefix_<^._

import scalacss.ScalaCssReact._

object IndicatorComponent {

  case class Props(proxy: ModelProxy[AppModel])

  private val component = ReactComponentB[Props](IndicatorComponent.getClass.getSimpleName)
    .render_P { p =>

      val model = p.proxy.value

      val indicators = for {
        pinnedEntity <- model.entitySelectionModel.pinned.toSeq
        hoveredSubCriteria <- model.subCriteriaSelectionModel.hovered.toSeq
        focusSubCriteria <- model.qualityModel.criteria.flatMap(_.subCriteria).find(_.id == hoveredSubCriteria).toSeq
        indicator <- focusSubCriteria.indicators
      } yield {
        val value = indicator.groupedValues(pinnedEntity)
        <.div(
          <.div(css.colXs10, indicator.name),
          <.div(css.colXs2, value)
        )
      }

      <.div(
        <.h2("Indicators"),
        if (indicators.isEmpty) {
          <.i("Pin a row and move your mouse over an axis to see something here")
        } else {
          <.div(css.row, indicators.toSeq)
        }
      )

    }
    .build

  def apply(proxy: ModelProxy[AppModel]) = component(Props(proxy))

}
{'fraction_non_alphanumeric': 0.10959438377535101, 'fraction_numerical': 0.0039001560062402497, 'mean_word_length': 2.934049079754601, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 5, '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': '4264440', 'n_tokens_mistral': 833, 'n_tokens_neox': 813, 'n_words': 139}