<commit_before>import { computed, observable, toJS } from "mobx";
import moment from "moment";
import color from "tinycolor2";
import LoaderTsne from "./Loaders/Tsne";
import LoaderJson from "./Loaders/Json";
import LoaderLdaJson from "./Loaders/LdaJson";
import LoaderLombardi from "./Loaders/Lombardi";
import LoaderJsonFeed from "./Loaders/JsonFeed";
import LoaderWeb3 from "./Loaders/Web3";

import FileSaver from "file-saver";

const LOADERS = {
  dd_tsne: LoaderTsne,
  json: LoaderJson,
  lombardi: LoaderLombardi,
  jsonfeed: LoaderJsonFeed,
  ldajson: LoaderLdaJson,
  web3: LoaderWeb3
};

class AppState {
  @observable networks = [];
  @observable currentLoader = null;
  @observable selectedNetworkIndex = 0;
  @observable refreshNetwork = Math.random();

  @observable
  graph = {
    selectedNodes: [],
    isFiltered: false,
    filterMode: "singlenode",
    minNodeSize: 0,
    maxNodeSize: Infinity,
    minEdgeWeight: 0,
    maxEdgeWeight: Infinity,
    refresh: Math.random(),
    subnetworkLevels: 2
  };

  @observable
  ui = {
    drawers: [
      {
        id: "left",
        open: true,
        openSecondary: false,
        components: [
          { name: "AppBar" },
          { name: "NetworkInput" },
          { name: "NetworkUrlSuffixInput" },
          { name: "NetworkList" },
          { name: "Divider" },
          { name: "ForceLinkSettings" },
          { name: "Divider" },
          { name: "Legend" },
          { name: "TopicSelector" }
        ]
      },
      {
        id: "right",
        open: true,
        openSecondary: true,
        components: [
          { name: "SearchInput" },
          { name: "NodeSize" },
          { name: "EdgeWeight" },
          { name: "HideOrphan" },
          { name: "Divider" },
          { name: "ShowSelected" },
          { name: "SelectedNode" },
          //{ name: "SelectedNodes" },
          { name: "Divider" },
          { name: "NeighborNodes" }
        ]
      }
    ],
    renderer: "canvas",
    filters: {
      edgeLabelSize: "proportional",
      enableEdgeHovering: true,
      //minNodeSize: 0,
      //maxNodeSize: 8,
      minEdgeWeight: 0,
      maxEdgeWeight: Infinity,
      minArrowSize: 4,
      onlyShowSelected: false,
      hideOrphans: false,
      categories: [],
      attributes: [],
      nodes: [],
      topics: []
    },
    muiTheme: "dark",
    mode: "fullscreen",
    labels: {
      //labelThreshold: 10,
      labelSize: "ratio",
      labelSizeRatio: 2,
      fontStyle: "500",
      font: "Roboto",
      labelColor: "node"
      //labelColor: '#000',
    },
    edges: {
      shape: "curve"
    }
  };

  @observable
  layout = {
    running: false,
    shouldStart: false,
    shouldStop: false,
    params: {
      //startingIterations: 1,
      barnesHutOptimize: true,
      barnesHutTheta: 0.5,
      adjustSizes: false,
      iterationsPerRender: 1,
      linLogMode: true,
      outboundAttractionDistribution: false,
      edgeWeightInfluence: 0,
      scalingRatio: 1,
      strongGravityMode: false,
      gravity: 1,
      alignNodeSiblings: false,
      nodeSiblingsScale: 1,
      nodeSiblingsAngleMin: 0,
      worker: true,
      background: true,
      easing: "cubicInOut",
      randomize: "locally",
      slowDown: 1,
      timeout: 1000
    }
  };

  @observable
  network_loader = {
    path: "",
    methods: []
  };

  initSettings(settings) {
    if (settings.ui) {
      this.ui = Object.assign(this.ui, settings.ui);
    }

    if (settings.graph) {
      this.graph = Object.assign(this.graph, settings.graph);
    }

    if (settings.networks) {
      const self = this;
      settings.networks.forEach((network, index) => {
        if (index == settings.networks.length - 1) {
          // select first imported network when done
          this.initNetwork(network, () => {
            self.selectNetwork(0);
            self.refreshNetwork = Math.random();
          });
        } else {
          this.initNetwork(network, () => {
            self.refreshNetwork = Math.random();
          });
        }
      });
    }

    // if (settings.layout) {
    //   this.layout = Object.assign(this.layout, settings.layout);
    // }

    if (settings.network_loader) {
      this.network_loader = Object.assign(
        this.network_loader,
        settings.network_loader
      );
    }
  }

  /*
  * Network
  */

  @computed
  get selectedNetwork() {
    return this.networks[this.selectedNetworkIndex];
  }<commit_msg>add settings.layout in AppState init<commit_after>import { computed, observable, toJS } from "mobx";
import moment from "moment";
import color from "tinycolor2";
import LoaderTsne from "./Loaders/Tsne";
import LoaderJson from "./Loaders/Json";
import LoaderLdaJson from "./Loaders/LdaJson";
import LoaderLombardi from "./Loaders/Lombardi";
import LoaderJsonFeed from "./Loaders/JsonFeed";
import LoaderWeb3 from "./Loaders/Web3";

import FileSaver from "file-saver";

const LOADERS = {
  dd_tsne: LoaderTsne,
  json: LoaderJson,
  lombardi: LoaderLombardi,
  jsonfeed: LoaderJsonFeed,
  ldajson: LoaderLdaJson,
  web3: LoaderWeb3
};

class AppState {
  @observable networks = [];
  @observable currentLoader = null;
  @observable selectedNetworkIndex = 0;
  @observable refreshNetwork = Math.random();

  @observable
  graph = {
    selectedNodes: [],
    isFiltered: false,
    filterMode: "singlenode",
    minNodeSize: 0,
    maxNodeSize: Infinity,
    minEdgeWeight: 0,
    maxEdgeWeight: Infinity,
    refresh: Math.random(),
    subnetworkLevels: 2
  };

  @observable
  ui = {
    drawers: [
      {
        id: "left",
        open: true,
        openSecondary: false,
        components: [
          { name: "AppBar" },
          { name: "NetworkInput" },
          { name: "NetworkUrlSuffixInput" },
          { name: "NetworkList" },
          { name: "Divider" },
          { name: "ForceLinkSettings" },
          { name: "Divider" },
          { name: "Legend" },
          { name: "TopicSelector" }
        ]
      },
      {
        id: "right",
        open: true,
        openSecondary: true,
        components: [
          { name: "SearchInput" },
          { name: "NodeSize" },
          { name: "EdgeWeight" },
          { name: "HideOrphan" },
          { name: "Divider" },
          { name: "ShowSelected" },
          { name: "SelectedNode" },
          //{ name: "SelectedNodes" },
          { name: "Divider" },
          { name: "NeighborNodes" }
        ]
      }
    ],
    renderer: "canvas",
    filters: {
      edgeLabelSize: "proportional",
      enableEdgeHovering: true,
      //minNodeSize: 0,
      //maxNodeSize: 8,
      minEdgeWeight: 0,
      maxEdgeWeight: Infinity,
      minArrowSize: 4,
      onlyShowSelected: false,
      hideOrphans: false,
      categories: [],
      attributes: [],
      nodes: [],
      topics: []
    },
    muiTheme: "dark",
    mode: "fullscreen",
    labels: {
      //labelThreshold: 10,
      labelSize: "ratio",
      labelSizeRatio: 2,
      fontStyle: "500",
      font: "Roboto",
      labelColor: "node"
      //labelColor: '#000',
    },
    edges: {
      shape: "curve"
    }
  };

  @observable
  layout = {
    running: false,
    shouldStart: false,
    shouldStop: false,
    params: {
      //startingIterations: 1,
      barnesHutOptimize: true,
      barnesHutTheta: 0.5,
      adjustSizes: false,
      iterationsPerRender: 1,
      linLogMode: true,
      outboundAttractionDistribution: false,
      edgeWeightInfluence: 0,
      scalingRatio: 1,
      strongGravityMode: false,
      gravity: 1,
      alignNodeSiblings: false,
      nodeSiblingsScale: 1,
      nodeSiblingsAngleMin: 0,
      worker: true,
      background: true,
      easing: "cubicInOut",
      randomize: "locally",
      slowDown: 1,
      timeout: 1000
    }
  };

  @observable
  network_loader = {
    path: "",
    methods: []
  };

  initSettings(settings) {
    if (settings.ui) {
      this.ui = Object.assign(this.ui, settings.ui);
    }

    if (settings.graph) {
      this.graph = Object.assign(this.graph, settings.graph);
    }

    if (settings.networks) {
      const self = this;
      settings.networks.forEach((network, index) => {
        if (index == settings.networks.length - 1) {
          // select first imported network when done
          this.initNetwork(network, () => {
            self.selectNetwork(0);
            self.refreshNetwork = Math.random();
          });
        } else {
          this.initNetwork(network, () => {
            self.refreshNetwork = Math.random();
          });
        }
      });
    }

    if (settings.layout) {
      this.layout = Object.assign(this.layout, settings.layout);
    }

    if (settings.network_loader) {
      this.network_loader = Object.assign(
        this.network_loader,
        settings.network_loader
      );
    }
  }

  /*
  * Network
  */

  @computed
  get selectedNetwork() {
    return this.networks[this.selectedNetworkIndex];
  }
{'fraction_non_alphanumeric': 0.12959661243592602, 'fraction_numerical': 0.008468910184978827, 'mean_word_length': 2.1066112841813776, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1149875', 'n_tokens_mistral': 2920, 'n_tokens_neox': 2820, 'n_words': 596}