<commit_before><template>
  <div>
    <b-field class="column">
      <b-input icon="search" v-model="filter" type="search" placeholder="Filter modules..." expanded></b-input>
      <b-select v-model="paginator">
        <option value="0">Don't paginate</option>
        <option value="50">50 per page</option>
        <option value="100">100 per page</option>
        <option value="200">200 per page</option>
      </b-select>
    </b-field>

    <b-table class="column fixed" :data="filtered" narrowed :loading="loading" :paginated="paginator > 0" :per-page="paginator" default-sort="name" detailed @details-open="openDetail">
      <template scope="props">
        <b-table-column field="name" label="Name" sortable width="320">
          {{ props.row.name }}
        </b-table-column>

        <b-table-column field="baseAddress" label="Base" class="monospace" sortable width="120">
          0x{{ props.row.baseAddress.value.toString(16) }}
        </b-table-column>

        <b-table-column field="size" label="Size" class="monospace" sortable width="120">
          {{ props.row.size }}
        </b-table-column>

        <b-table-column field="path" label="Path" class="break-all">
          {{ props.row.path }}
        </b-table-column>
      </template>

      <template slot="detail" scope="props">
        <loading-tab v-if="props.row.loading"></loading-tab>

        <div class="content" v-if="props.index == 0">
          <h4 class="title">Imports</h4>
          <functions :list="imports" :loading="loading" :module="props.row.name"></functions>
        </div>

        <div class="content" v-if="props.row.exports.length">
          <h4 class="title">Exports</h4>
          <functions :list="props.row.exports" :loading="props.row.loading" :module="props.row.name"></functions>
        </div>
        <b-message v-else>This module has no exported symbol</b-message>

      </template>

      <div slot="empty" class="has-text-centered">
        <div v-if="!loading">No matching module found</div>
      </div>
    </b-table>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { GET_SOCKET } from '~/vuex/types'
import { AsyncSearch, debounce } from '~/lib/utils'
import LoadingTab from '~/components/LoadingTab.vue'
import Functions from '~/components/Functions.vue'

export default {
  components: { LoadingTab, Functions },
  methods: {
    load() {
      this.loading = true
      this.socket.call('imports').then(list => {
        this.imports = list.filter(imp => imp.type === 'function')
        this.socket.call('modules').then(modules => {
          this.modules = modules.map((mod, index) =>
            Object.assign({
              loading: false,
              exports: [],
            }, mod))
          this.loading = false
        })
      })
    },
    openDetail(mod, index) {
      if (mod.detailed)
        return

      mod.loading = true
      mod.detailed = true
      this.socket.call('exports', { module: mod.name }).then(list => {
        mod.loading = false
        mod.exports = list.filter(exp => exp.type === 'function')
      })<commit_msg>bugfix: imports list always shows up<commit_after><template>
  <div>
    <b-field class="column">
      <b-input icon="search" v-model="filter" type="search" placeholder="Filter modules..." expanded></b-input>
      <b-select v-model="paginator">
        <option value="0">Don't paginate</option>
        <option value="50">50 per page</option>
        <option value="100">100 per page</option>
        <option value="200">200 per page</option>
      </b-select>
    </b-field>

    <b-table class="column fixed" :data="filtered" narrowed :loading="loading" :paginated="paginator > 0" :per-page="paginator" default-sort="name" detailed @details-open="openDetail">
      <template scope="props">
        <b-table-column field="name" label="Name" sortable width="320">
          {{ props.row.name }}
        </b-table-column>

        <b-table-column field="baseAddress" label="Base" class="monospace" sortable width="120">
          0x{{ props.row.baseAddress.value.toString(16) }}
        </b-table-column>

        <b-table-column field="size" label="Size" class="monospace" sortable width="120">
          {{ props.row.size }}
        </b-table-column>

        <b-table-column field="path" label="Path" class="break-all">
          {{ props.row.path }}
        </b-table-column>
      </template>

      <template slot="detail" scope="props">
        <loading-tab v-if="props.row.loading"></loading-tab>

        <div class="content" v-if="props.row.imports">
          <h4 class="title">Imports</h4>
          <functions :list="props.row.imports" :loading="loading" :module="props.row.name"></functions>
        </div>

        <div class="content" v-if="props.row.exports.length">
          <h4 class="title">Exports</h4>
          <functions :list="props.row.exports" :loading="props.row.loading" :module="props.row.name"></functions>
        </div>
        <b-message v-else>This module has no exported symbol</b-message>

      </template>

      <div slot="empty" class="has-text-centered">
        <div v-if="!loading">No matching module found</div>
      </div>
    </b-table>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { GET_SOCKET } from '~/vuex/types'
import { AsyncSearch, debounce } from '~/lib/utils'
import LoadingTab from '~/components/LoadingTab.vue'
import Functions from '~/components/Functions.vue'

export default {
  components: { LoadingTab, Functions },
  methods: {
    async load() {
      this.loading = true
      let modules = await this.socket.call('modules')
      this.modules = modules.map((mod, index) =>
        Object.assign({
          loading: false,
          exports: [],
        }, mod))

      let imports = await this.socket.call('imports')
      this.imports = imports.filter(imp => imp.type === 'function')
      this.modules[0].imports = this.imports
      this.loading = false
    },
    openDetail(mod, index) {
      if (mod.detailed)
        return

      mod.loading = true
      mod.detailed = true
      this.socket.call('exports', { module: mod.name }).then(list => {
        mod.loading = false
        mod.exports = list.filter(exp => exp.type === 'function')
      })
{'fraction_non_alphanumeric': 0.17172039578678583, 'fraction_numerical': 0.011171401212894989, 'mean_word_length': 2.6670567583382097, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 121, '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': '4487488', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1894, 'n_words': 387}