Welcome to ethernet
This commit is contained in:
@ -11,14 +11,22 @@ import router from '../router'
|
||||
|
||||
export default {
|
||||
name: 'home',
|
||||
props: { saved_ssid: String, list_ssids: Array, internet: Boolean },
|
||||
props: { saved_ssid: String, iface_out: String, list_ssids: Array, internet: Boolean },
|
||||
methods: {
|
||||
next: function() {
|
||||
var saved_ssid = this.saved_ssid
|
||||
var list_ssids = this.list_ssids
|
||||
var internet = this.internet
|
||||
router.push({ name: 'wifi-select', params: { saved_ssid: saved_ssid, list_ssids: list_ssids, internet:internet } });
|
||||
}
|
||||
console.log(this.iface_out)
|
||||
if (this.iface_out.charAt(0) == "e"){
|
||||
router.push({ name: 'generate-ap' });
|
||||
} else {
|
||||
router.push({ name: 'wifi-select',
|
||||
params: { saved_ssid: saved_ssid,
|
||||
list_ssids: list_ssids,
|
||||
internet:internet } });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -15,35 +15,58 @@
|
||||
data() {
|
||||
return {
|
||||
list_ssids: [],
|
||||
internet: false
|
||||
internet: false,
|
||||
iface_out:""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// Check if the device is already connected to internet.
|
||||
// Check if the device is connected to internet.
|
||||
internet_check: function() {
|
||||
axios.get(`/api/network/status`, { timeout: 10000 })
|
||||
.then(response => {
|
||||
if (response.data.internet) this.internet = true
|
||||
this.get_wifi_networks()
|
||||
if (response.data.internet){
|
||||
this.internet = true
|
||||
this.load_config()
|
||||
}
|
||||
})
|
||||
.catch(err => (console.log(err)))
|
||||
},
|
||||
// Get the WiFi networks around the box.
|
||||
get_wifi_networks: function() {
|
||||
axios.get(`/api/network/wifi/list`, { timeout: 10000 })
|
||||
.then(response => (this.append_ssids(response.data.networks)))
|
||||
.then(response => {
|
||||
this.list_ssids = response.data.networks
|
||||
this.goto_home();
|
||||
})
|
||||
.catch(err => (console.log(err)))
|
||||
},
|
||||
// Handle the get_wifi_networks answer and call goto_home.
|
||||
append_ssids: function(networks) {
|
||||
this.list_ssids = networks
|
||||
this.goto_home()
|
||||
},
|
||||
// Pass the list of ssids and the internet status as a prop to the home view.
|
||||
// Forward the view to home, with some props
|
||||
// such as (SSIDs, internet & interface)
|
||||
goto_home: function() {
|
||||
var list_ssids = this.list_ssids
|
||||
var internet = this.internet
|
||||
router.replace({ name: 'home', params: { list_ssids: list_ssids, internet: internet } });
|
||||
var internet = this.internet
|
||||
var iface_out = this.iface_out
|
||||
router.replace({ name: 'home', params: { list_ssids: list_ssids, internet: internet, iface_out : iface_out } });
|
||||
},
|
||||
// Get the network_out from the config
|
||||
// to determine the next steps.
|
||||
load_config: function() {
|
||||
axios.get(`/api/misc/config`, { timeout: 60000 })
|
||||
.then(response => {
|
||||
if(response.data.iface_out){
|
||||
this.iface_out = response.data.iface_out
|
||||
// If ethernet, just goto the homepage.
|
||||
// Else, get wifi networks and then go to home.
|
||||
if(this.iface_out.charAt(0) == "e"){
|
||||
setTimeout(function () { this.goto_home(); }.bind(this), 1000);
|
||||
} else {
|
||||
this.get_wifi_networks();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
});
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
|
Reference in New Issue
Block a user