-
Notifications
You must be signed in to change notification settings - Fork 64
/
NMEAInjector.vue
163 lines (153 loc) · 4.1 KB
/
NMEAInjector.vue
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
<template>
<v-card
width="500"
elevation="0"
class="mx-auto my-6 injectors-list"
>
<v-card
class="mx-auto my-6"
width="500"
elevation="1"
>
<v-card-text>
<div class="text--primary">
The NMEA Injector receives NMEA via UDP or TCP and transforms it
into MAVLink data that is forwarded to the autopilot.
It currently supports the sentences
<!-- suppressing vue-no-html rule, as we create this html ourselves -->
<!-- eslint-disable -->
<span
target="_blank"
v-html="createLink('GPGGA')"
/>,
<span
target="_blank"
v-html="createLink('GPRMC')"
/>,
<span
target="_blank"
v-html="createLink('GPGLL')"
/>, and
<!-- eslint-enable -->
<a
target="_blank"
href="https://receiverhelp.trimble.com/alloy-gnss/en-us/NMEA-0183messages_GNS.html"
>
GPGNSS
</a>
</div>
</v-card-text>
</v-card>
<v-list
v-if="are_nmea_sockets_available && !updating_nmea_sockets"
style="background-color: transparent"
dense
>
<template v-for="(nmea_socket, index) in available_nmea_sockets">
<v-divider
v-if="index !== 0"
:key="index"
/>
<v-list-item
:key="index"
class="pa-0"
>
<nmea-socket-card :nmea-socket="nmea_socket" />
</v-list-item>
</template>
</v-list>
<v-container v-else-if="updating_nmea_sockets">
<spinning-logo
size="30%"
subtitle="Fetching available NMEA sockets..."
/>
</v-container>
<v-container
v-else
class="text-center"
>
<p class="text-h6">
No NMEA sockets available. You can add a connection by clicking the + symbol in the corner.
</p>
</v-container>
<v-fab-transition>
<v-btn
:key="'create_button'"
color="primary"
fab
large
dark
fixed
bottom
right
class="v-btn--example"
@click="openCreationDialog"
>
<v-icon>mdi-plus</v-icon>
</v-btn>
</v-fab-transition>
<creation-dialog
v-model="show_creation_dialog"
/>
</v-card>
</template>
<script lang="ts">
import Vue from 'vue'
import { OneMoreTime } from '@/one-more-time'
import nmea_injector from '@/store/nmea-injector'
import { NMEASocket } from '@/types/nmea-injector'
import SpinningLogo from '../common/SpinningLogo.vue'
import NMEASocketCard from './NMEASocketCard.vue'
import CreationDialog from './NMEASocketCreationDialog.vue'
export default Vue.extend({
name: 'NMEAInjector',
components: {
SpinningLogo,
CreationDialog,
'nmea-socket-card': NMEASocketCard,
},
data() {
return {
show_creation_dialog: false,
updating_nmea_sockets_debounced: false,
fetch_nmea_sockets_task: new OneMoreTime({ delay: 5000, disposeWith: this }),
}
},
computed: {
updating_nmea_sockets(): boolean {
return nmea_injector.updating_nmea_sockets && this.updating_nmea_sockets_debounced
},
available_nmea_sockets(): NMEASocket[] {
return nmea_injector.available_nmea_sockets
},
are_nmea_sockets_available(): boolean {
return !this.available_nmea_sockets.isEmpty()
},
},
mounted() {
this.fetch_nmea_sockets_task.setAction(() => this.fetchAvailableNMEASockets())
},
methods: {
async fetchAvailableNMEASockets(): Promise<void> {
this.updating_nmea_sockets_debounced = false
await nmea_injector.fetchAvailableNMEASockets()
setTimeout(() => {
this.updating_nmea_sockets_debounced = true
}, 300)
},
openCreationDialog(): void {
this.show_creation_dialog = true
},
createLink(sentence: string): string {
return `<a href="http://aprs.gids.nl/nmea/#${sentence.toLowerCase().substring(2)}">${sentence}</a>`
},
},
})
</script>
<style scoped>
.injectors-list {
background-color: transparent;
max-width: 70%;
margin: auto;
}
</style>