Skip to content

Commit 62091e4

Browse files
committed
fix(webui): fix table width if long URLs are present
1 parent ebf9788 commit 62091e4

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

webui/src/components/dashboard/http/Requests.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { usePrettyHttp } from '@/composables/http'
66
import { Modal, Tooltip } from 'bootstrap'
77
import RegexInput from '@/components/RegexInput.vue'
88
import { getRouteName, useDashboard } from '@/composables/dashboard';
9+
import { usePrettyText } from '@/composables/usePrettyText'
910
1011
const props = defineProps({
1112
serviceName: { type: String, required: false},
@@ -29,12 +30,15 @@ const { dashboard } = useDashboard()
2930
const { events: data, close } = dashboard.value.getEvents('http', ...labels.value)
3031
const { format, duration } = usePrettyDates()
3132
const { formatStatusCode } = usePrettyHttp()
33+
const { adaptiveTruncate } = usePrettyText()
3234
const { services, close: closeServices } = dashboard.value.getServices('http', true);
3335
const dialogRef = useTemplateRef('dialogRef')
3436
let dialog: Modal | undefined;
3537
const urlValue = useTemplateRef<ComponentPublicInstance<typeof RegexInput>>('urlValue');
3638
const requestHeaderValueRefs = ref<any[]>([])
3739
const responseHeaderValueRefs = ref<any[]>([])
40+
const urlCell = useTemplateRef<HTMLElement>('urlCell');
41+
const dynamicLimit = ref(80);
3842
type CheckboxFilter = 'Not' | 'Single' | 'Multi'
3943
interface Filter {
4044
service: MultiFilterItem
@@ -81,6 +85,14 @@ const filter = reactive<Filter>({
8185
}
8286
)
8387
88+
const updateLimit = () => {
89+
if (urlCell.value) {
90+
const width = urlCell.value.offsetWidth;
91+
dynamicLimit.value = Math.floor(width / 9);
92+
}
93+
};
94+
95+
const observer = new ResizeObserver(updateLimit);
8496
onMounted(() => {
8597
dialog = Modal.getOrCreateInstance(dialogRef.value!);
8698
const s = localStorage.getItem(`http-requests-${getFilterCacheKey()}`)
@@ -92,6 +104,9 @@ onMounted(() => {
92104
tooltipTriggerList.forEach(el => new Tooltip(el, {
93105
trigger: 'hover'
94106
}))
107+
if (urlCell.value) {
108+
observer.observe(urlCell.value);
109+
}
95110
})
96111
97112
function goToRequest(event: ServiceEvent, openInNewTab = false){
@@ -323,6 +338,7 @@ const method = computed({
323338
onUnmounted(() => {
324339
close()
325340
closeServices()
341+
observer.disconnect()
326342
})
327343
function showDialog() {
328344
dialog?.show()
@@ -590,7 +606,7 @@ function mergeDeep<T>(target: T, source: Partial<T>): T {
590606
<tr>
591607
<th v-if="hasDeprecatedRequests" scope="col" class="text-center" style="width: 5px;"></th>
592608
<th scope="col" class="text-left col-1">Method</th>
593-
<th scope="col" class="text-left col">URL</th>
609+
<th scope="col" class="text-left col" ref="urlCell">URL</th>
594610
<th scope="col" class="text-center col-1">Status Code</th>
595611
<th scope="col" class="text-center col-2">Time</th>
596612
<th scope="col" class="text-center col-1">Duration</th>
@@ -608,7 +624,7 @@ function mergeDeep<T>(target: T, source: Partial<T>): T {
608624
</td>
609625
<td>
610626
<router-link @click.stop class="row-link" :to="{ name: getRouteName('httpRequest').value, params: {id: event.id} }">
611-
{{ eventData(event).request.url }}
627+
{{ adaptiveTruncate(eventData(event).request.url, dynamicLimit) }}
612628
</router-link>
613629
</td>
614630
<td class="text-center">{{ formatStatusCode(eventData(event).response.statusCode.toString()) }}</td>

0 commit comments

Comments
 (0)