Skip to content

Commit 35dfa7c

Browse files
committed
add dialog to LDAP search response result to show attributes
1 parent a01dd5d commit 35dfa7c

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

webui/src/components/dashboard/kafka/KafkaGroups.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { usePrettyDates } from '@/composables/usePrettyDate'
33
import { onMounted, ref } from 'vue'
44
import { Modal, Popover, Tab } from 'bootstrap'
55
import { useMetrics } from '@/composables/metrics'
6-
import type { GroupMember } from 'kafkajs';
76
87
const props = defineProps<{
98
service: KafkaService,

webui/src/components/dashboard/ldap/Search.vue

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue'
2+
import { computed, onMounted, ref, useTemplateRef } from 'vue'
33
import Actions from '../Actions.vue'
4+
import { Modal } from 'bootstrap';
45
56
const props = defineProps<{
67
event: ServiceEvent
@@ -35,6 +36,28 @@ function compareResult(r1: LdapSearchResult, r2: LdapSearchResult) {
3536
const hasActions = computed(() => {
3637
return data.value.data.actions?.length > 0
3738
})
39+
40+
const selected = ref<{dn: string, keys: string[], attributes: { [name: string]: string[] }} | undefined>()
41+
const dialogRef = useTemplateRef('dialogRef')
42+
let dialog: Modal;
43+
44+
function showResult(result: LdapSearchResult) {
45+
if (getSelection()?.toString()) {
46+
return
47+
}
48+
selected.value = {
49+
dn: result.dn,
50+
keys: Object.keys(result.attributes).sort((x: string, y: string) => x.localeCompare(y)),
51+
attributes: result.attributes
52+
}
53+
dialog.show()
54+
}
55+
56+
onMounted(() => {
57+
if (dialogRef.value) {
58+
dialog = new Modal(dialogRef.value)
59+
}
60+
})
3861
</script>
3962

4063
<template>
@@ -83,21 +106,51 @@ const hasActions = computed(() => {
83106
<section class="card" aria-labelledby="response">
84107
<div class="card-body">
85108
<h2 id="response" class="card-title text-center">Response</h2>
86-
<table class="table dataTable" aria-labelledby="response">
109+
<table class="table dataTable selectable" aria-labelledby="response">
87110
<thead>
88111
<tr>
89-
<th scope="col" class="text-left" style="width: 20%">DN</th>
112+
<th scope="col" class="text-left col">DN</th>
113+
<th scope="col" class="text-center col-2">Attributes</th>
90114
</tr>
91115
</thead>
92116
<tbody>
93-
<tr v-for="item of searchResults" :key="item.dn">
117+
<tr v-for="item of searchResults" :key="item.dn" @click="showResult(item)">
94118
<td>{{ item.dn }}</td>
119+
<td class="text-center">{{ Object.keys(item.attributes).length }}</td>
95120
</tr>
96121
</tbody>
97122
</table>
98123
</div>
99124
</section>
100125
</div>
126+
<div class="modal fade" id="modal-response" tabindex="-1" aria-hidden="true" aria-labelledby="modal-response-title" ref="dialogRef">
127+
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
128+
<div class="modal-content" v-if="selected">
129+
<div class="modal-header">
130+
<h6 id="modal-response-title" class="modal-title">DN: {{ selected.dn }}</h6>
131+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
132+
</div>
133+
<div class="modal-body">
134+
<div class="row p-2">
135+
<table class="table dataTable" aria-labelledby="modal-response-title">
136+
<thead>
137+
<tr>
138+
<th scope="col" class="text-left col-4">Type</th>
139+
<th scope="col" class="text-left col">Value</th>
140+
</tr>
141+
</thead>
142+
<tbody>
143+
<tr v-for="name in selected.keys" :key="name">
144+
<td>{{ name }}</td>
145+
<td v-html="selected.attributes[name]?.join('<br />')"></td>
146+
</tr>
147+
</tbody>
148+
</table>
149+
</div>
150+
</div>
151+
</div>
152+
</div>
153+
</div>
101154
</template>
102155

103156
<style scoped>

webui/src/types/ldap.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ declare interface LdapSearchResponse {
4040

4141
declare interface LdapSearchResult {
4242
dn: string
43-
attributes: { [name: string]: string }
43+
attributes: { [name: string]: string[] }
4444
}
4545

4646
declare interface LdapModifyRequest {

0 commit comments

Comments
 (0)