﻿<template>
  <div class="node-page">
    <div class="card-content">
      <div class="app-card elevation-1">
        <div>主机地址 <br> {{ ipAddress }}</div>
      </div>
      <div class="app-sep"></div>
      <div class="app-card elevation-1">
        <div>在线用户 <br> </div>
      </div>
    </div>

    <div class="table-content elevation-1">
      <div class="panel-header">
        <h3>{{ $t('node.tableHeader') }}</h3>
        <div class="search-input">
          <v-text-field
            :placeholder="$t('node.searchHolder')"
            :value="filter"
            @input="inputFilter"
            append-icon="search" />
        </div>
      </div>

      <template>
        <v-data-table
          :headers="headers"
          :items="itemList"
          :total-items="100"
          :rows-per-page-items="pageEntity"
          :loading="fetching"
          class="panel-content elevation-1"
        >
          <template slot="headerCell" slot-scope="props">
            <span>{{ $t(props.header.text) }}</span>
          </template>
          <template slot="items" slot-scope="props">
            <td>{{ props.item.height }}</td>
            <td>{{ props.item.timestamp }}</td>
            <td>{{ props.item.type }}</td>
            <td>{{ props.item.hash }}</td>
          </template>
          <template slot="no-results">
            {{ $t('node.tableNone') }}
          </template>
        </v-data-table>
      </template>
    </div>

  </div>
</template>

<script>
import {
  createNamespacedHelpers,
} from 'vuex'

const { mapState, mapGetters, mapActions, mapMutations } = createNamespacedHelpers('node')

export default {
  name: 'Node',

  computed: {
    ...mapState([
      'headers',
      'itemList',
      'pageEntity',
      'fetching',
      'filter',
      'modal',
      'ipAddress',
    ]),
    ...mapGetters([]),
  },

  methods: {
    ...mapActions([
      'updateNodeInfo',
    ]),
    ...mapMutations([
      'inputFilter',
      'setIpAddress',
    ]),
  },

  mounted() {
    this.updateNodeInfo()
  },

}
</script>

<style scoped lang="scss">
.node-page {

  .card-content {
    display: flex;
    padding: 20px;

    .app-card {
      flex: 1;
      height: 100px;
      background-color: white;
    }

    .app-sep {
      width: 20px;
    }

  }

  .table-content {
    flex: 1;
    margin: 0 20px 20px;
    background-color: white;
    display: flex;
    flex-direction: column;

    .panel-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 0 20px;

      .search-input {
        width: 80%;
      }
    }

    .panel-content {
      margin: 0 20px 20px;
    }
  }

}
</style>
