<commit_before>package blended.mgmt.ui.components

import blended.updater.config.ContainerInfo
import japgolly.scalajs.react.ReactComponentB
import japgolly.scalajs.react.ReactEventI
import japgolly.scalajs.react.vdom.prefix_<^._
import blended.mgmt.ui.util.I18n
import blended.mgmt.ui.util.Logger
import japgolly.scalajs.react.BackendScope
import blended.updater.config.OverlayState
import blended.updater.config.Profile
import blended.updater.config.OverlaySet
import japgolly.scalajs.react.CallbackTo
import blended.mgmt.ui.backend.ProfileUpdater
import blended.updater.config.ActivateProfile
import blended.updater.config.UpdateAction
import blended.updater.config.StageProfile
import blended.updater.config.Profile.SingleProfile
import blended.updater.config.RuntimeConfig
import blended.updater.config.OverlayConfig

/**
 * React component to render details of a [[ContainerInfo]].
 */
object OverlayConfigDetailComp {

  private[this] val log = Logger[OverlayConfigDetailComp.type]
  private[this] val i18n = I18n()

  case class Props(runtimeConfig: Option[OverlayConfig] = None)

  class Backend(scope: BackendScope[Props, Unit]) {

    def render(props: Props) = {
      props match {
        case Props(None) => <.span(i18n.tr("No OverlayConfig selected"))
        case Props(Some(oc)) =>

          val genConf = oc.generatedConfigs.map(c => <.div(c.configFile, <.pre(c.config)))

          <.div(
            ^.cls := "panel panel-default",
            <.div(
              ^.cls := "panel-heading",
              <.h3(i18n.tr("Overlay Config")),
              <.h4(oc.name + " " + i18n.tr("Version") + " " + oc.version)
            ),<commit_msg>Nicer formatting of generated Configs in Overlay page.<commit_after>package blended.mgmt.ui.components

import blended.mgmt.ui.util.{I18n, Logger}
import blended.updater.config.{ContainerInfo, OverlayConfig}
import japgolly.scalajs.react.{BackendScope, ReactComponentB}
import japgolly.scalajs.react.vdom.prefix_<^._

import scalajs.js.JSON

/**
 * React component to render details of a [[ContainerInfo]].
 */
object OverlayConfigDetailComp {

  private[this] val log = Logger[OverlayConfigDetailComp.type]
  private[this] val i18n = I18n()

  case class Props(runtimeConfig: Option[OverlayConfig] = None)

  class Backend(scope: BackendScope[Props, Unit]) {

    def render(props: Props) = {
      props match {
        case Props(None) => <.span(i18n.tr("No OverlayConfig selected"))
        case Props(Some(oc)) =>

          val replacer : scalajs.js.Array[scalajs.js.Any] = null

          val genConf = oc.generatedConfigs.map { c =>

            val obj : scalajs.js.Any = JSON.parse(c.config)
            val formatted = JSON.stringify(obj, replacer, 2)

            <.div(
              ^.cls := "panel panel-default",
              <.div(
                ^.cls := "panel-heading",
                <.h3(c.configFile)
              ),
              <.pre(formatted)
            )
          }

          <.div(
            ^.cls := "panel panel-default",
            <.div(
              ^.cls := "panel-heading",
              <.h3(i18n.tr("Overlay Config")),
              <.h4(oc.name + " " + i18n.tr("Version") + " " + oc.version)
            ),
{'fraction_non_alphanumeric': 0.1280696300901461, 'fraction_numerical': 0.009325458501709667, 'mean_word_length': 2.808284023668639, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 9, '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': '2501833', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1028, 'n_words': 193}