EVLogViewer.vue 1.69 KB
Newer Older
Janis Streib's avatar
Janis Streib committed
1
<template>
Janis Streib's avatar
Janis Streib committed
2 3
  <b-modal size="xl" ok-title="Schließen" :title="'Eventlog: ' + title" :ok-only="true" :id="modal_id"
           @show="fetchData()">
Janis Streib's avatar
Janis Streib committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    <Loading :data="[records]">
      <b-table :responsive="true" striped :items="records" :fields="table_fields">
        <template v-slot:cell(type)="data">
          {{ record_types[data.item.type].action }}
        </template>
      </b-table>
    </Loading>
  </b-modal>
</template>

<script>
import EVLogService from '@/api-services/evlog.service'
import Loading from '@/components/Loading'
import apiutil from '@/util/apiutil'

export default {
  name: 'EVLogViewer',
  components: {Loading},
  data() {
    return {
      records: null,
      record_types: {},
      table_fields: [
        {
          key: 'data',
          label: 'Beschreibung'
        },
        {
          key: 'type',
          label: 'Aktionstyp'
        },
        {
          key: 'ta_timestamp',
          label: 'Zeit',
          sortable: true
        },
        {
          key: 'mgr_login_name',
          label: 'Account',
          sortable: true
        }
      ]
    }
  },
  props: {
    title: {
      required: true
    },
    modal_id: {
      required: true
Janis Streib's avatar
Janis Streib committed
54 55 56 57 58 59 60 61 62
    },
    ref_obj_fq: {
      required: true
    },
    refobj_id_field: {
      required: true
    },
    refobj_id_value: {
      required: true
Janis Streib's avatar
Janis Streib committed
63 64 65 66 67
    }
  },
  methods: {
    async fetchData() {
      this.records = null
Janis Streib's avatar
Janis Streib committed
68 69 70
      const res = await EVLogService.getByFK(this.$store.state.netdb_axios_config, this.ref_obj_fq, this.refobj_id_field, this.refobj_id_value)
      this.records = res.data[1]
      this.record_types = apiutil.dict_by_value_of_array(res.data[2], 'short_name')
Janis Streib's avatar
Janis Streib committed
71 72 73 74 75 76 77 78
    }
  }
}
</script>

<style scoped>

</style>