<commit_before>package drt.client.components

import drt.client.SPAMain
import drt.client.modules.GoogleEventTracker
import drt.client.services.SPACircuit
import drt.shared.{PaxTypes, Queues}
import japgolly.scalajs.react.component.Scala.Component
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.{Callback, CtorType, ScalaComponent}


object SimulateArrivalsPage {

  case class Props()

  val component: Component[Props, Unit, Unit, CtorType.Props] = ScalaComponent.builder[Props]("ArrivalSimulations")
    .render_P { _ =>

      <.div(<.h2("Arrival Simulations"))
      val airportConfigRCP = SPACircuit.connect(_.airportConfig)

      airportConfigRCP(airportConfigMP => {
        val airportConfig = airportConfigMP()
        <.div(
          airportConfig.renderReady(airportConfig => {
            <.form(
              ^.action := SPAMain.absoluteUrl("desk-rec-simulation"),
              ^.method := "post",
              ^.encType := "multipart/form-data",
              <.div(^.className := "form-group row col-sm-10",
                <.label(^.htmlFor := "arrivals-file", "Arrivals File", ^.className := "col-sm-3"),
                <.input(^.tpe := "file", ^.name := "arrivals-file", ^.id := "arrivals-file", ^.required := true)
              ),
              <.div(^.className := "form-group row  col-sm-10",
                <.label(^.className := "col-sm-3", ^.htmlFor := "passenger-weighting", "Passenger weighting"),
                <.input(^.tpe := "number", ^.step := "0.01", ^.name := "passenger-weighting", ^.id := "passenger-weighting")
              ),
              <.div(^.className := "form-group row col-sm-10",
                <.legend(^.className := "pt-0", "Processing times"),
                <.div(^.className := "",
                  airportConfig.terminalProcessingTimes.head._2.map {
                    case (ptq, time) =>
                      <.div(^.className := "form-check",
                        <.label(
                          ^.className := "col-sm-3",
                          s"${PaxTypes.displayName(ptq.passengerType)} to ${Queues.queueDisplayNames(ptq.queueType)}"
                        ),
                        <.input(^.tpe := "number", ^.name := s"${ptq.key}", ^.defaultValue := (time * 60).toInt)
                      )

                  }.toTagMod
                )),
              <.div(^.className := "form-group row col-sm-10",
                <.button(^.tpe := "Submit", ^.className := "btn btn-primary", "Submit"))
            )
          }
          ))

      })


    }.componentDidMount(_ => Callback {
    GoogleEventTracker.sendPageView(s"Arrival Simulations Page")
  }).build

  def apply(): VdomElement = component(Props())

}
<commit_msg>DRTII-473 Deploy simulator to staging<commit_after>package drt.client.components

import drt.client.SPAMain
import drt.client.modules.GoogleEventTracker
import drt.client.services.SPACircuit
import drt.shared.{PaxTypes, Queues}
import japgolly.scalajs.react.component.Scala.Component
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.{Callback, CtorType, ScalaComponent, _}


object SimulateArrivalsPage {

  case class State(terminalString: Option[String])

  case class Props()

  val component: Component[Props, Unit, Unit, CtorType.Props] = ScalaComponent.builder[Props]("ArrivalSimulations")
    .initialState(State(None))
    .renderS { (scope, state) =>

      <.div(<.h2("Arrival Simulations"))
      val airportConfigRCP = SPACircuit.connect(_.airportConfig)

      airportConfigRCP(airportConfigMP => {
        val airportConfig = airportConfigMP()
        <.div(
          airportConfig.renderReady(airportConfig => {
            <.form(
              ^.action := SPAMain.absoluteUrl("desk-rec-simulation"),
              ^.method := "post",
              ^.encType := "multipart/form-data",
              <.div(
                ^.className := "form-group row col-sm-10",
                <.label(^.htmlFor := "arrivals-file", "Arrivals File", ^.className := "col-sm-3"),
                <.input(^.tpe := "file", ^.name := "arrivals-file", ^.id := "arrivals-file", ^.required := true)
              ),
              <.div(
                ^.className := "form-group row  col-sm-10",
                <.label(^.className := "col-sm-3", ^.htmlFor := "terminal", "Terminal"),
                <.select(
                  ^.name := "terminal",
                  ^.value := state.terminalString.getOrElse(""),
                  <.option(),
                  airportConfig.terminals.map(t => <.option(^.value := t.toString, t.toString)).toTagMod,
                  ^.onChange ==> ((e: ReactEventFromInput) => {

                    val newState = if (e.target.value != "")
                      State(Option(e.target.value))
                    else
                      State(None)

                    scope.setState(newState)
                  })
                )
              ),
              <.div(
                ^.className := "form-group row  col-sm-10",
                <.label(^.className := "col-sm-3", ^.htmlFor := "passenger-weighting", "Passenger weighting"),
                <.input(^.tpe := "number", ^.step := "0.01", ^.name := "passenger-weighting", ^.id := "passenger-weighting")
              ),
              <.div(
                ^.className := "form-group row col-sm-10",
                <.legend(^.className := "pt-0", "Processing times"),
                <.div(^.className := "",
                  airportConfig.terminalProcessingTimes.head._2.map {
                    case (ptq, time) =>
                      <.div(^.className := "form-check",
                        <.label(
                          ^.className := "col-sm-3",
                          s"${PaxTypes.displayName(ptq.passengerType)} to ${Queues.queueDisplayNames(ptq.queueType)}"
                        ),
                        <.input(^.tpe := "number", ^.name := s"${ptq.key}", ^.defaultValue := (time * 60).toInt)
                      )

                  }.toTagMod
                )),
              <.div(^.className := "form-group row col-sm-10",
                <.button(^.tpe := "Submit", ^.className := "btn btn-primary", "Submit"))
            )
          }
          ))

      })


    }.componentDidMount(_ => Callback {
    GoogleEventTracker.sendPageView(s"Arrival Simulations Page")
  }).build

  def apply(): VdomElement = component(Props())

}

{'fraction_non_alphanumeric': 0.16109989125368962, 'fraction_numerical': 0.006835482367562529, 'mean_word_length': 1.802786242925555, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 16, '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': '7591092', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1873, 'n_words': 315}