<commit_before>import React from "react";
import { Input, Container, Row, Col } from "reactstrap";
import ops from "./ops";
import FontAwesome from "react-fontawesome";
import Views, { Widgets } from "../../../../../components/views/index";
import ExtraMessageGroups from "./messageGroups";
import { titleCase } from "change-case";
const viewList = Object.keys(Views)
  .filter(v => {
    return v !== "Offline" && v !== "Login" && v !== "Viewscreen";
  })
  .sort();

const ConfigStation = props => {
  const {
    client,
    selectedStationSet,
    simulator,
    station,
    data: { loading, softwarePanels }
  } = props;
  const inSim = comp => {
    const stationSet = simulator.stationSets.find(
      s => s.id === selectedStationSet
    );
    const cards = stationSet.stations.reduce(
      (prev, next) => prev.concat(next.cards.map(c => c.component)),
      []
    );
    return cards.indexOf(comp) > -1;
  };
  const updateStationCard = (type, card, e) => {
    const variables = {
      stationSetId: selectedStationSet,
      stationName: station.name,
      cardName: card.name
    };
    variables[type] = e.target.value;
    client.mutate({
      mutation: ops.updateStationCard,
      variables
    });
  };
  const removeCard = card => {
    if (window.confirm("Are you sure you want to delete that card?")) {
      const variables = {
        id: selectedStationSet,
        stationName: station.name,
        cardName: card.name
      };
      client.mutate({
        mutation: ops.removeCard,
        variables
      });
    }
  };
  const addCard = e => {
    let name = prompt("What is the card name?", titleCase(e.target.value));
    if (name) {
      const variables = {
        id: selectedStationSet,
        name: station.name,
        cardName: name,
        cardComponent: e.target.value
      };
      client.mutate({
        mutation: ops.addCard,
        variables
      });
    }
  };
  const toggleStationMessageGroup = (evt, group) => {
    const variables = {
      stationSetId: selectedStationSet,
      station: station.name,
      group,
      state: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationMessageGroup,
      variables
    });
  };
  const toggleStationWidget = (evt, widget) => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      widget,
      state: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationWidget,
      variables
    });
  };
  const setStationLogin = evt => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      login: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationLogin,
      variables
    });
  };
  const setStationExecutive = evt => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      exec: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationExec,
      variables
    });
  };
  return (
    <Container fluid>
      <h5>Stations</h5>
      <div className="scroll">
        <div
          style={{
            marginBottom: "15px",
            border: "solid 1px rgba(0,0,0,0.5)"
          }}
        >
          <table className="table table-sm table-striped table-hover">
            <thead className="thead-default">
              <tr>
                <th colSpan="3">
                  <span>
                    {station.name} |{" "}
                    <label style={{ display: "inline" }}>
                      <input
                        checked={station.login}
                        onChange={setStationLogin}
                        type="checkbox"
                      />{" "}
                      Auto-Login
                    </label>{" "}
                    |{" "}<commit_msg>Minor fix to stations sets<commit_after>import React from "react";
import { Input, Container, Row, Col } from "reactstrap";
import ops from "./ops";
import FontAwesome from "react-fontawesome";
import Views, { Widgets } from "../../../../../components/views/index";
import ExtraMessageGroups from "./messageGroups";
import { titleCase } from "change-case";
const viewList = Object.keys(Views)
  .filter(v => {
    return v !== "Offline" && v !== "Login" && v !== "Viewscreen";
  })
  .sort();

const ConfigStation = props => {
  const {
    client,
    selectedStationSet,
    simulator,
    station,
    data: { loading, softwarePanels }
  } = props;
  const inSim = comp => {
    const stationSet = simulator.stationSets.find(
      s => s.id === selectedStationSet
    );
    const cards = stationSet.stations.reduce(
      (prev, next) => prev.concat(next.cards.map(c => c.component)),
      []
    );
    return cards.indexOf(comp) > -1;
  };
  const updateStationCard = (type, card, e) => {
    const variables = {
      stationSetId: selectedStationSet,
      stationName: station.name,
      cardName: card.name
    };
    variables[type] = e.target.value;
    client.mutate({
      mutation: ops.updateStationCard,
      variables
    });
  };
  const removeCard = card => {
    if (window.confirm("Are you sure you want to delete that card?")) {
      const variables = {
        id: selectedStationSet,
        stationName: station.name,
        cardName: card.name
      };
      client.mutate({
        mutation: ops.removeCard,
        variables
      });
    }
  };
  const addCard = e => {
    let name = prompt("What is the card name?", titleCase(e.target.value));
    if (name) {
      const variables = {
        id: selectedStationSet,
        name: station.name,
        cardName: name,
        cardComponent: e.target.value
      };
      client.mutate({
        mutation: ops.addCard,
        variables
      });
    }
  };
  const toggleStationMessageGroup = (evt, group) => {
    const variables = {
      stationSetId: selectedStationSet,
      station: station.name,
      group,
      state: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationMessageGroup,
      variables
    });
  };
  const toggleStationWidget = (evt, widget) => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      widget,
      state: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationWidget,
      variables
    });
  };
  const setStationLogin = evt => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      login: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationLogin,
      variables
    });
  };
  const setStationExecutive = evt => {
    const variables = {
      stationSetID: selectedStationSet,
      stationName: station.name,
      exec: evt.target.checked
    };
    client.mutate({
      mutation: ops.toggleStationExec,
      variables
    });
  };
  if (!station) return "Error - Station not found.";
  return (
    <Container fluid>
      <h5>Stations</h5>
      <div className="scroll">
        <div
          style={{
            marginBottom: "15px",
            border: "solid 1px rgba(0,0,0,0.5)"
          }}
        >
          <table className="table table-sm table-striped table-hover">
            <thead className="thead-default">
              <tr>
                <th colSpan="3">
                  <span>
                    {station.name} |{" "}
                    <label style={{ display: "inline" }}>
                      <input
                        checked={station.login}
                        onChange={setStationLogin}
                        type="checkbox"
                      />{" "}
                      Auto-Login
                    </label>{" "}
                    |{" "}
{'fraction_non_alphanumeric': 0.12799381921194952, 'fraction_numerical': 0.003090394025238218, 'mean_word_length': 1.93648393194707, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 57, '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': '3113907', 'n_tokens_mistral': 2234, 'n_tokens_neox': 2214, 'n_words': 503}