mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
alert after connecting to new wifi
This commit is contained in:
committed by
Aiden McClelland
parent
7b0f99881b
commit
7a3811235e
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { ToastController } from '@ionic/angular'
|
||||
import { AlertController, ToastController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
import { pauseFor } from 'src/app/util/misc.util'
|
||||
import { ServerModel } from 'src/app/models/server-model'
|
||||
@@ -12,6 +12,7 @@ export class WifiService {
|
||||
constructor (
|
||||
private readonly apiService: ApiService,
|
||||
private readonly toastCtrl: ToastController,
|
||||
private readonly alertCtrl: AlertController,
|
||||
private readonly serverModel: ServerModel,
|
||||
) { }
|
||||
|
||||
@@ -30,10 +31,13 @@ export class WifiService {
|
||||
const maxAttempts = 5
|
||||
let attempts = 0
|
||||
|
||||
let old: string | null
|
||||
|
||||
while (attempts < maxAttempts) {
|
||||
try {
|
||||
const start = new Date().valueOf()
|
||||
const { current, ssids } = (await this.apiService.getServer(timeout)).wifi
|
||||
old = current
|
||||
const end = new Date().valueOf()
|
||||
if (current === ssid) {
|
||||
this.serverModel.update({ wifi: { current, ssids } })
|
||||
@@ -53,7 +57,13 @@ export class WifiService {
|
||||
}
|
||||
|
||||
if (this.serverModel.peek().wifi.current === ssid) {
|
||||
return true
|
||||
let message = 'Note. It may take a few minutes for your Embassy to reconnect over Tor. If it does not reconnect after 5 minutes, please unplug the device and plug it back in. You may also need to hard refresh your browser cache.'
|
||||
const alert = await this.alertCtrl.create({
|
||||
header: `Connected to "${ssid}"`,
|
||||
message: old ? message : 'You may now unplug your Embassy from Ethernet.<br /></br />' + message,
|
||||
buttons: ['OK'],
|
||||
})
|
||||
await alert.present()
|
||||
} else {
|
||||
const toast = await this.toastCtrl.create({
|
||||
header: 'Failed to connect:',
|
||||
|
||||
@@ -11,7 +11,10 @@ export interface ApiServer {
|
||||
versionInstalled: string
|
||||
alternativeRegistryUrl: string | null
|
||||
specs: ServerSpecs
|
||||
wifi: { ssids: string[]; current: string; }
|
||||
wifi: {
|
||||
ssids: string[]
|
||||
current: string | null
|
||||
}
|
||||
ssh: SSHFingerprint[]
|
||||
serverId: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user