-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathModulePanel.vue
More file actions
181 lines (162 loc) · 3.87 KB
/
ModulePanel.vue
File metadata and controls
181 lines (162 loc) · 3.87 KB
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
175
176
177
178
179
180
181
<template>
<div class="fill-height d-flex flex-column">
<div id="module-switcher">
<v-tabs
id="module-switcher-tabs"
v-model="selectedModuleIndex"
icons-and-text
show-arrows
>
<v-tab
v-for="item in modules"
:key="item.name"
:data-testid="`module-tab-${item.name}`"
:disabled="item.disabled"
>
<div class="tab-content">
<span class="mb-0 mt-1 module-text">{{ item.name }}</span>
<v-icon>mdi-{{ item.icon }}</v-icon>
</div>
</v-tab>
</v-tabs>
</div>
<div id="module-container">
<v-window v-model="selectedModuleIndex" touchless class="fill-height">
<v-window-item
v-for="mod in modules"
:key="mod.name"
class="fill-height"
>
<component
:key="mod.name"
v-show="modules[selectedModuleIndex] === mod"
:is="mod.component"
/>
</v-window-item>
</v-window>
</div>
<ProbeView />
</div>
</template>
<script lang="ts">
import { Component, computed, defineComponent, ref, watch } from 'vue';
import { ConnectionState, useServerStore } from '@/src/store/server';
import DataBrowser from './DataBrowser.vue';
import RenderingModule from './RenderingModule.vue';
import AnnotationsModule from './AnnotationsModule.vue';
import ServerModule from './ServerModule.vue';
import ProbeView from './ProbeView.vue';
import { useToolStore } from '../store/tools';
import { Tools } from '../store/tools/types';
interface Module {
name: string;
icon: string;
component: Component;
disabled?: boolean;
}
const Modules: Module[] = [
{
name: 'Data',
icon: 'database',
component: DataBrowser,
},
{
name: 'Annotations',
icon: 'pencil',
component: AnnotationsModule,
},
{
name: 'Rendering',
icon: 'cube',
component: RenderingModule,
},
{
name: 'Remote',
icon: 'server-network',
component: ServerModule,
},
];
const autoSwitchToAnnotationsTools = [
Tools.Rectangle,
Tools.Ruler,
Tools.Polygon,
Tools.Paint,
];
export default defineComponent({
name: 'ModulePanel',
components: { ProbeView },
setup() {
const selectedModuleIndex = ref(0);
const toolStore = useToolStore();
watch(
() => toolStore.currentTool,
(newTool) => {
if (autoSwitchToAnnotationsTools.includes(newTool))
selectedModuleIndex.value = 1;
}
);
const serverStore = useServerStore();
const modules = computed(() => {
if (!serverStore.url) {
return Modules.filter((m) => m.name !== 'Remote');
}
if (serverStore.connState === ConnectionState.Connected) {
return Modules;
}
return Modules.map((m) => {
if (m.name === 'Remote') {
return { ...m, disabled: true };
}
return m;
});
});
return {
selectedModuleIndex,
modules,
};
},
});
</script>
<style scoped>
#module-switcher {
display: relative;
flex: 0 2;
/* roughly match vuetify's dark/light transition */
transition: border-bottom 0.3s;
border-bottom: 2px solid rgb(var(--v-theme-on-surface-variant));
}
#close-btn {
position: absolute;
top: 1.5em;
left: 0.5em;
z-index: 10;
}
#module-container {
position: relative;
flex: 2;
overflow: auto;
scrollbar-gutter: stable;
}
.module-text {
font-size: 0.6rem;
white-space: pre;
}
.tab-content {
display: flex;
justify-content: flex-end;
flex-direction: column-reverse;
height: 100%;
align-items: center;
}
#module-switcher-tabs :deep(.v-slide-group__content) {
justify-content: center;
}
#module-switcher-tabs
:deep(.v-slide-group__prev.v-slide-group__prev--disabled) {
visibility: hidden;
}
#module-switcher-tabs
:deep(.v-slide-group__next.v-slide-group__next--disabled) {
visibility: hidden;
}
</style>