Skip to content

Commit 4c6b58a

Browse files
feat: Remote-access changes
Created a new component to connect to a new device when already connected. If you are already connected and trying to disconnect, you end up trying to connect way before the state has updated itselfs with a new ID and for that reason we had a blocking sequence.
1 parent c735f5b commit 4c6b58a

File tree

6 files changed

+117
-4
lines changed

6 files changed

+117
-4
lines changed

Diff for: src/components/AppFrame.vue

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export default {
224224
// ]
225225
// },
226226
{ icon: 'mdi-video-input-antenna', text: 'Connect', link: '/choose-edge-connection' },
227+
{ icon: 'mdi-video-input-antenna', text: 'Connect Remote', link: '/remote-edge-connection' },
227228
// { icon: 'settings', text: 'Settings', link: '/settings' },
228229
{ icon: 'chat_bubble', text: 'Send feedback', link: '/feedback' },
229230
{ icon: 'help', text: 'Help', link: '/help' },

Diff for: src/router/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ const routes = [
8888
// this generates a separate chunk (about.[hash].js) for this route
8989
// which is lazy-loaded when the route is visited.
9090
component: () => import(/* webpackChunkName: "choose-edge-connection" */ '../views/ChooseEdgeConnection.vue')
91+
},
92+
{
93+
path: '/remote-edge-connection',
94+
name: 'remote-edge-connection',
95+
// route level code-splitting
96+
// this generates a separate chunk (about.[hash].js) for this route
97+
// which is lazy-loaded when the route is visited.
98+
component: () => import(/* webpackChunkName: "remote-edge-connection" */ '../views/RemoteEdgeConnection.vue')
9199
}
92100
]
93101

Diff for: src/store/pnp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const state = {
7979
/**
8080
Edgeroom ID when connecting to remote network
8181
*/
82-
edgeRoom: String
82+
edgeRoom: undefined
8383
}
8484

8585
const mutations = {

Diff for: src/views/ChooseEdgeConnection.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<v-card-actions>
1717
<v-row justify="center">
1818
<v-btn
19-
:to="'edge-connect'"
2019
color="primary"
2120
:small="$vuetify.breakpoint.mdAndUp"
2221
>
@@ -67,7 +66,6 @@
6766
<v-card-actions>
6867
<v-btn
6968
:disabled="!correctEdgeAddress"
70-
:to="'edge-connect'"
7169
@click="sendEdgeAddress"
7270
color="primary"
7371
>
@@ -119,7 +117,9 @@ export default {
119117
}
120118
},
121119
sendEdgeAddress () {
120+
console.log(this.edgeAddress)
122121
this.$store.state.pnp.edgeRoom = this.edgeAddress
122+
console.log(this.$store.state.pnp.edgeRoom)
123123
this.$store.dispatch(REMOVE_REMOTE_PEER_ID)
124124
}
125125
},

Diff for: src/views/EdgeConnect.vue

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ export default {
240240
},
241241
methods: {
242242
disconnectEdge () {
243-
this.$store.state.pnp.remotePeerId = false
244243
this.$store.state.pnp.edgeRoom = undefined
245244
this.$store.dispatch(REMOVE_REMOTE_PEER_ID)
246245
}

Diff for: src/views/RemoteEdgeConnection.vue

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<template>
2+
<app-frame>
3+
<v-card
4+
max-width="500"
5+
class="text-center"
6+
>
7+
<v-card-text>
8+
<p class="text">
9+
Connect to remote network
10+
</p>
11+
<v-subheader>
12+
(must enter Peer ID to Ambianic network)
13+
</v-subheader>
14+
<v-text-field
15+
v-model="edgeAddress"
16+
type="text"
17+
label="Peer ID to Ambianic Network*"
18+
placeholder="Enter Peer ID"
19+
outlined
20+
dense
21+
class="mt-4"
22+
/>
23+
</v-card-text>
24+
25+
<v-card-actions>
26+
<v-btn
27+
:disabled="!correctEdgeAddress"
28+
@click="sendEdgeAddress"
29+
color="primary"
30+
>
31+
REMOTE NETWORK
32+
</v-btn>
33+
</v-card-actions>
34+
</v-card>
35+
</app-frame>
36+
</template>
37+
<script>
38+
import AppFrame from '@/components/AppFrame.vue'
39+
import {
40+
REMOVE_REMOTE_PEER_ID
41+
} from '../store/action-types.js'
42+
import { mapState } from 'vuex'
43+
import {
44+
PEER_CONNECTED
45+
} from '@/store/mutation-types'
46+
47+
export default {
48+
data: () => {
49+
return {
50+
edgeAddress: '',
51+
correctEdgeAddress: false
52+
// connectionStatus: '',
53+
// connectionTip: '',
54+
// testInProgress: false,
55+
// testDone: true,
56+
// statusColor: 'info',
57+
// resetEdgeDialog: false
58+
}
59+
},
60+
methods: {
61+
// Validate the user input so the ID has the correct format before showing the connect button
62+
validateIP (value) {
63+
if (/^([a-zA-Z0-9]{8})-([a-zA-Z0-9]{4})-([a-zA-Z0-9]{4})-([a-zA-Z0-9]{4})-([a-zA-Z0-9]{12})$/.test(value)) {
64+
this.correctEdgeAddress = true
65+
return this.correctEdgeAddress
66+
} else {
67+
// if value is not matching regex, remove button
68+
this.correctEdgeAddress = false
69+
return this.correctEdgeAddress
70+
}
71+
},
72+
sendEdgeAddress () {
73+
this.$store.state.pnp.edgeRoom = this.edgeAddress
74+
this.$store.dispatch(REMOVE_REMOTE_PEER_ID)
75+
}
76+
},
77+
computed: {
78+
...mapState({
79+
isEdgeConnected: state =>
80+
state.pnp.peerConnectionStatus === PEER_CONNECTED
81+
})
82+
},
83+
components: {
84+
AppFrame
85+
},
86+
watch: {
87+
edgeAddress (value) {
88+
this.edgeAddress = value
89+
this.validateIP(value)
90+
}
91+
}
92+
}
93+
</script>
94+
<style scoped>
95+
#ambianicEdgeAddress {
96+
border: 2px ridge lightgray;
97+
padding: 6px;
98+
border-radius: 5px;
99+
width: 81%;
100+
}
101+
102+
.text {
103+
font-size: 18px;
104+
}
105+
</style>

0 commit comments

Comments
 (0)