summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/LogModuleEntry.vue
blob: 2e9ce67d23b137291d63b9f78adc379281fd78cf (plain) (blame)
1
2
3
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<i18n>
{
  "en": {
    "id": "ID",
    "name": "Name",
    "description": "Description",
    "ip": "IP",
    "mac": "MAC",
    "uuid": "UUID",
    "username": "Username",
    "deleted": "Deleted"
  },
  "de": {
    "id": "ID",
    "name": "Name",
    "description": "Beschreibung",
    "ip": "IP",
    "mac": "MAC",
    "uuid": "UUID",
    "username": "Benutzername",
    "deleted": "Gelöscht"
  }
}
</i18n>

<template>
  <div style="display: flex; align-items: center;">
    <template v-if="item.client">
      <v-menu v-model="menus.client" :close-on-content-click="false" offset-y content-class="log-entry-menu-conent">
        <template #activator="{ on }">
          <v-btn v-on="on" outline small class="description-button" :class="{ 'error--text': item.client.deleted }">
            <v-icon small class="mr-1">computer</v-icon>{{ item.client.name }}
          </v-btn>
        </template>
        <template #default>
          <v-card style="user-select: text;"><v-card-text>
            <div v-if="item.client.deleted" class="error--text" style="text-align: center; font-weight: bold;">{{ $t('deleted') }}</div>
            <table>
              <tr><td class="snapshot-key">{{ $t('id') }}</td><td>{{ item.clientSnapshot.id }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('name') }}</td><td>{{ item.clientSnapshot.name }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('description') }}</td><td style="white-space: pre;">{{ item.clientSnapshot.description }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('ip') }}</td><td>{{ item.clientSnapshot.ip }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('mac') }}</td><td>{{ item.clientSnapshot.mac }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('uuid') }}</td><td>{{ item.clientSnapshot.uuid }}</td></tr>
            </table>
          </v-card-text></v-card>
        </template>
      </v-menu>
    </template>

    <template v-if="item.group">
      <v-menu v-model="menus.group" :close-on-content-click="false" offset-y content-class="log-entry-menu-conent">
        <template #activator="{ on }">
          <v-btn v-on="on" outline small class="description-button" :class="{ 'error--text': item.group.deleted }">
            <v-icon small class="mr-1">category</v-icon>{{ item.group.name }}
          </v-btn>
        </template>
        <template #default>
          <v-card style="user-select: text;"><v-card-text>
            <table>
              <tr><td class="snapshot-key">{{ $t('id') }}</td><td>{{ item.groupSnapshot.id }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('name') }}</td><td>{{ item.groupSnapshot.name }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('description') }}</td><td style="white-space: pre;">{{ item.groupSnapshot.description }}</td></tr>
            </table>
          </v-card-text></v-card>
        </template>
      </v-menu>
    </template>

    <template v-if="item.user">
      <v-menu v-model="menus.user" :close-on-content-click="false" offset-y content-class="log-entry-menu-conent">
        <template #activator="{ on }">
          <v-btn v-on="on" outline small class="description-button" :class="{ 'error--text': item.user.deleted }">
            <v-icon small class="mr-1">person</v-icon>{{ item.user.name }}
          </v-btn>
        </template>
        <template #default>
          <v-card style="user-select: text;"><v-card-text>
            <table>
              <tr><td class="snapshot-key">{{ $t('id') }}</td><td>{{ item.userSnapshot.id }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('username') }}</td><td>{{ item.userSnapshot.username }}</td></tr>
              <tr><td class="snapshot-key">{{ $t('name') }}</td><td>{{ item.userSnapshot.name }}</td></tr>
            </table>
          </v-card-text></v-card>
        </template>
      </v-menu>
    </template>

    <v-menu
      v-if="item.multilineDescription"
      v-model="menus.description"
      :close-on-content-click="false"
      nudge-top="12"
      nudge-left="16"
      content-class="log-entry-menu-conent"
    >
      <template #activator="{ on }">
        <v-btn v-if="item.multilineDescription" v-on="on" small icon style="margin: 0 2px 0 0; overflow: hidden;">
          <v-icon :style="menus.description ? 'transform: rotate(180deg)' : ''">arrow_drop_down</v-icon>
        </v-btn>
      </template>
      <template #default>
        <v-card style="display: flex; padding: 16px">
          <v-btn small icon style="margin: -4px 2px 0 0; overflow: hidden;" @click="menus.description = false">
            <v-icon :style="menus.description ? 'transform: rotate(180deg)' : ''">arrow_drop_down</v-icon>
          </v-btn>
          <div style="user-select: text; white-space: pre;">{{ item.multilineDescription }}</div>
        </v-card>
      </template>
    </v-menu>
    <div style="user-select: text;" @click="menus.description = true">{{ item.description }}</div>
  </div>
</template>

<script>

export default {
  name: 'LogModuleEntry',
  props: {
    item: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {
      menus: { description: false, client: false, group: false, user: false }
    }
  },
  watch: {
    item () {
      this.menus = { description: false, client: false, group: false, user: false }
    },
    menus: {
      deep: true,
      handler (menus) {
        if (menus.description || menus.client || menus.group || menus.user) this.$emit('menu-translate', this.$el.offsetParent.style.transform)
      }
    }
  },
  methods: {
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.description-button {
  min-width: 10px;
  margin: 0 10px 0 0;
}

.description-button >>> .v-btn__content {
  max-width: 180px;
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
  text-transform: none;
}

.snapshot-key {
  vertical-align: top;
  font-weight: bold;
  text-align: right;
  padding-right: 16px;
}
</style>

<style>
.log-entry-menu-conent {
  font-size: 13px;
  font-family: 'Roboto Mono';
}
</style>