Skip to content

Commit da9c2e8

Browse files
committed
feat: add additional sources
1 parent ab20c54 commit da9c2e8

13 files changed

Lines changed: 1842 additions & 64 deletions

frontend/src/components/inspect-file/file-topic-table.vue

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@
6868
loadingState[props.row.name] || false
6969
"
7070
:error="topicErrors[props.row.name] || null"
71+
:topic-size="props.row.size"
72+
:protocol="props.row.protocol"
7173
@load-required="() => loadSmart(props.row)"
72-
@load-more="() => loadData(props.row.name, 20)"
74+
@load-more="() => loadMore(props.row.name)"
7375
/>
7476
</div>
7577
</q-td>
@@ -144,15 +146,49 @@ const columns: QTableColumn[] = [
144146
},
145147
];
146148
147-
// Directly load specific count
149+
// Directly load specific count (Base function)
148150
const loadData = (topic: string, count: number): void => {
149151
emit('load-preview', topic, count);
150152
};
151153
152-
// Smart load based on message type
154+
// In file-topic-table.vue > script > loadSmart
155+
153156
const loadSmart = (row: any): void => {
154157
const type = detectPreviewType(row.type);
155-
const limit = type === PreviewType.IMAGE ? row.nrMessages : 5;
156-
emit('load-preview', row.name, limit);
158+
159+
// 1. Full Load (Visual Plots / Images)
160+
if (
161+
type === PreviewType.IMAGE ||
162+
type === PreviewType.TWIST ||
163+
type === PreviewType.TEMPERATURE
164+
) {
165+
loadData(row.name, row.nrMessages);
166+
return;
167+
}
168+
169+
// 2. Medium Load (Logs)
170+
if (
171+
type === PreviewType.ROS_LOG ||
172+
type === PreviewType.TIME_REFERENCE ||
173+
type === PreviewType.STRING
174+
) {
175+
loadData(row.name, 100);
176+
return;
177+
}
178+
179+
// 3. Strict Load (Heavy Binary)
180+
if (type === PreviewType.POINT_CLOUD) {
181+
loadData(row.name, 1);
182+
return;
183+
}
184+
185+
// 4. Default
186+
loadData(row.name, 5);
187+
};
188+
189+
// Incremental Load (Load More button)
190+
const loadMore = (topicName: string): void => {
191+
const currentCount = properties.previews[topicName]?.length || 0;
192+
loadData(topicName, currentCount + 20);
157193
};
158194
</script>

frontend/src/components/inspect-file/message-viewer.vue

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
<div class="text-subtitle2 text-grey-8 flex items-center">
55
{{ topicName }}
66
<q-badge color="grey-4" text-color="black" class="q-ml-sm">{{
7-
messageType
8-
}}</q-badge>
7+
messageType
8+
}}</q-badge>
99
</div>
10-
<q-btn
11-
v-if="hasData && !isImage"
12-
label="Load More"
13-
size="sm"
14-
flat
15-
color="primary"
16-
@click="$emit('load-more')"
17-
/>
10+
11+
<q-badge
12+
color="orange-7"
13+
text-color="white"
14+
label="BETA"
15+
class="text-weight-bold cursor-help"
16+
style="font-size: 10px; padding: 2px 6px"
17+
>
18+
<q-tooltip>
19+
Preview functionality is currently in beta.
20+
</q-tooltip>
21+
</q-badge>
1822
</div>
1923

2024
<div
@@ -39,6 +43,7 @@
3943
:topic-name="topicName"
4044
:total-count="totalCount"
4145
@load-required="$emit('load-required')"
46+
@load-more="$emit('load-more')"
4247
/>
4348

4449
<div
@@ -62,7 +67,6 @@ import { computed } from 'vue';
6267
import {
6368
detectPreviewType,
6469
getViewerComponent,
65-
PreviewType,
6670
} from '../../services/message-factory';
6771
6872
const properties = defineProps<{
@@ -72,6 +76,8 @@ const properties = defineProps<{
7276
totalCount: number;
7377
isLoading: boolean;
7478
error: string | null;
79+
protocol?: string;
80+
topicSize?: number;
7581
}>();
7682
7783
defineEmits(['load-more', 'load-required']);
@@ -80,17 +86,23 @@ const hasData = computed(
8086
() => properties.messages && properties.messages.length > 0,
8187
);
8288
83-
// Determine the type based on the message string + sample data
89+
// --- Type Detection ---
8490
const currentPreviewType = computed(() => {
8591
const sample = properties.messages?.[0]?.data;
8692
return detectPreviewType(properties.messageType, sample);
8793
});
8894
89-
// Helper to check if it is an image
90-
const isImage = computed(() => currentPreviewType.value === PreviewType.IMAGE);
91-
92-
// Get the correct component
9395
const activeComponent = computed(() => {
9496
return getViewerComponent(currentPreviewType.value);
9597
});
96-
</script>
98+
99+
// --- Utilities ---
100+
function formatBytes(bytes: number, decimals = 1): string {
101+
if (!+bytes) return '0 B';
102+
const k = 1024;
103+
const dm = decimals < 0 ? 0 : decimals;
104+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
105+
const i = Math.floor(Math.log(bytes) / Math.log(k));
106+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
107+
}
108+
</script>

0 commit comments

Comments
 (0)