|
1 | 1 | <script setup lang="ts"> |
2 | | -import { computed } from 'vue' |
| 2 | +import { computed, onMounted, ref, useTemplateRef } from 'vue' |
3 | 3 | import Actions from '../Actions.vue' |
| 4 | +import { Modal } from 'bootstrap'; |
4 | 5 |
|
5 | 6 | const props = defineProps<{ |
6 | 7 | event: ServiceEvent |
@@ -35,6 +36,28 @@ function compareResult(r1: LdapSearchResult, r2: LdapSearchResult) { |
35 | 36 | const hasActions = computed(() => { |
36 | 37 | return data.value.data.actions?.length > 0 |
37 | 38 | }) |
| 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 | +}) |
38 | 61 | </script> |
39 | 62 |
|
40 | 63 | <template> |
@@ -83,21 +106,51 @@ const hasActions = computed(() => { |
83 | 106 | <section class="card" aria-labelledby="response"> |
84 | 107 | <div class="card-body"> |
85 | 108 | <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"> |
87 | 110 | <thead> |
88 | 111 | <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> |
90 | 114 | </tr> |
91 | 115 | </thead> |
92 | 116 | <tbody> |
93 | | - <tr v-for="item of searchResults" :key="item.dn"> |
| 117 | + <tr v-for="item of searchResults" :key="item.dn" @click="showResult(item)"> |
94 | 118 | <td>{{ item.dn }}</td> |
| 119 | + <td class="text-center">{{ Object.keys(item.attributes).length }}</td> |
95 | 120 | </tr> |
96 | 121 | </tbody> |
97 | 122 | </table> |
98 | 123 | </div> |
99 | 124 | </section> |
100 | 125 | </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> |
101 | 154 | </template> |
102 | 155 |
|
103 | 156 | <style scoped> |
|
0 commit comments