mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Merge pull request #41 from mtlynch/show-error
Show repeater login error in login dialog
This commit is contained in:
commit
988806dccd
28 changed files with 120 additions and 8 deletions
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Входът не беше успешен. Или паролата е грешна, или повторителят е недостъпен.",
|
||||
|
||||
"common_reload": "Презареди",
|
||||
"common_clear": "Изчисти",
|
||||
"path_currentPath": "Текущ път: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Anmeldung fehlgeschlagen. Entweder ist das Passwort falsch oder der Repeater ist nicht erreichbar.",
|
||||
|
||||
"common_reload": "Neu laden",
|
||||
"common_clear": "Löschen",
|
||||
"path_currentPath": "Aktiger Pfad: {path}",
|
||||
|
|
|
|||
|
|
@ -723,6 +723,8 @@
|
|||
"error": {"type": "String"}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Login failed. Either the password is incorrect or the repeater is unreachable.",
|
||||
|
||||
|
||||
"common_reload": "Reload",
|
||||
"common_clear": "Clear",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Inicio fallido. La contraseña es incorrecta o el repetidor no está disponible.",
|
||||
|
||||
"common_reload": "Recargar",
|
||||
"common_clear": "Borrar",
|
||||
"path_currentPath": "Ruta actual: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Connexion échouée. Soit le mot de passe est incorrect, soit le relais est injoignable.",
|
||||
|
||||
"common_reload": "Recharger",
|
||||
"common_clear": "Effacer",
|
||||
"path_currentPath": "Chemin actuel : {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Accesso fallito. La password non è corretta oppure il ripetitore non è raggiungibile.",
|
||||
|
||||
"common_reload": "Ricaricare",
|
||||
"common_clear": "Cancella",
|
||||
"path_currentPath": "Percorso corrente: {path}",
|
||||
|
|
|
|||
|
|
@ -2759,6 +2759,12 @@ abstract class AppLocalizations {
|
|||
/// **'Login failed: {error}'**
|
||||
String login_failed(String error);
|
||||
|
||||
/// No description provided for @login_failedMessage.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Login failed. Either the password is incorrect or the repeater is unreachable.'**
|
||||
String get login_failedMessage;
|
||||
|
||||
/// No description provided for @common_reload.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
|
|
|||
|
|
@ -1514,6 +1514,10 @@ class AppLocalizationsBg extends AppLocalizations {
|
|||
return 'Входът не беше успешен: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Входът не беше успешен. Или паролата е грешна, или повторителят е недостъпен.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Презареди';
|
||||
|
||||
|
|
|
|||
|
|
@ -1516,6 +1516,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||
return 'Anmeldung fehlgeschlagen: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Anmeldung fehlgeschlagen. Entweder ist das Passwort falsch oder der Repeater ist nicht erreichbar.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Neu laden';
|
||||
|
||||
|
|
|
|||
|
|
@ -1490,6 +1490,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
return 'Login failed: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Login failed. Either the password is incorrect or the repeater is unreachable.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Reload';
|
||||
|
||||
|
|
|
|||
|
|
@ -1512,6 +1512,10 @@ class AppLocalizationsEs extends AppLocalizations {
|
|||
return 'Inicio fallido: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Inicio fallido. La contraseña es incorrecta o el repetidor no está disponible.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Recargar';
|
||||
|
||||
|
|
|
|||
|
|
@ -1518,6 +1518,10 @@ class AppLocalizationsFr extends AppLocalizations {
|
|||
return 'Connexion échouée : $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Connexion échouée. Soit le mot de passe est incorrect, soit le relais est injoignable.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Recharger';
|
||||
|
||||
|
|
|
|||
|
|
@ -1510,6 +1510,10 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||
return 'Accesso fallito: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Accesso fallito. La password non è corretta oppure il ripetitore non è raggiungibile.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Ricaricare';
|
||||
|
||||
|
|
|
|||
|
|
@ -1506,6 +1506,10 @@ class AppLocalizationsNl extends AppLocalizations {
|
|||
return 'Inloggen mislukt: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Inloggen mislukt. Het wachtwoord is onjuist of de repeater is niet bereikbaar.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Opnieuw laden';
|
||||
|
||||
|
|
|
|||
|
|
@ -1514,6 +1514,10 @@ class AppLocalizationsPl extends AppLocalizations {
|
|||
return 'Zalogowanie się nie powiodło: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Logowanie nie powiodło się. Hasło jest nieprawidłowe albo repeater jest nieosiągalny.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Ponownie załadować';
|
||||
|
||||
|
|
|
|||
|
|
@ -1512,6 +1512,10 @@ class AppLocalizationsPt extends AppLocalizations {
|
|||
return 'Login falhou: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Falha no login. A senha está incorreta ou o repetidor está inacessível.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Recarregar';
|
||||
|
||||
|
|
|
|||
|
|
@ -1507,6 +1507,10 @@ class AppLocalizationsSk extends AppLocalizations {
|
|||
return 'Prihlásenie zlyhalo: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Prihlásenie zlyhalo. Heslo je nesprávne alebo je opakovač nedostupný.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Načítať';
|
||||
|
||||
|
|
|
|||
|
|
@ -1508,6 +1508,10 @@ class AppLocalizationsSl extends AppLocalizations {
|
|||
return 'Prijava je bila neuspešna: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Prijava je bila neuspešna. Geslo je napačno ali pa je repetitor nedosegljiv.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Ponovno naloži';
|
||||
|
||||
|
|
|
|||
|
|
@ -1497,6 +1497,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||
return 'Inloggning misslyckades: $error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage =>
|
||||
'Inloggning misslyckades. Antingen är lösenordet fel eller så går det inte att nå repeatern.';
|
||||
|
||||
@override
|
||||
String get common_reload => 'Ladda om';
|
||||
|
||||
|
|
|
|||
|
|
@ -1447,6 +1447,9 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||
return '登录失败:$error';
|
||||
}
|
||||
|
||||
@override
|
||||
String get login_failedMessage => '登录失败。密码不正确或中继器不可达。';
|
||||
|
||||
@override
|
||||
String get common_reload => '重新加载';
|
||||
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Inloggen mislukt. Het wachtwoord is onjuist of de repeater is niet bereikbaar.",
|
||||
|
||||
"common_reload": "Opnieuw laden",
|
||||
"common_clear": "Schoonmaken",
|
||||
"path_currentPath": "Huidige pad: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Logowanie nie powiodło się. Hasło jest nieprawidłowe albo repeater jest nieosiągalny.",
|
||||
|
||||
"common_reload": "Ponownie załadować",
|
||||
"common_clear": "Wyczyść",
|
||||
"path_currentPath": "Aktualny ścieżka: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Falha no login. A senha está incorreta ou o repetidor está inacessível.",
|
||||
|
||||
"common_reload": "Recarregar",
|
||||
"common_clear": "Limpar",
|
||||
"path_currentPath": "Caminho atual: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Prihlásenie zlyhalo. Heslo je nesprávne alebo je opakovač nedostupný.",
|
||||
|
||||
"common_reload": "Načítať",
|
||||
"common_clear": "Zmazať",
|
||||
"path_currentPath": "Aktívna cesta: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Prijava je bila neuspešna. Geslo je napačno ali pa je repetitor nedosegljiv.",
|
||||
|
||||
"common_reload": "Ponovno naloži",
|
||||
"common_clear": "Ponoviti",
|
||||
"path_currentPath": "Trenutna pot: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "Inloggning misslyckades. Antingen är lösenordet fel eller så går det inte att nå repeatern.",
|
||||
|
||||
"common_reload": "Ladda om",
|
||||
"common_clear": "Rensa",
|
||||
"path_currentPath": "Nuvarande sökväg: {path}",
|
||||
|
|
|
|||
|
|
@ -821,6 +821,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"login_failedMessage": "登录失败。密码不正确或中继器不可达。",
|
||||
|
||||
"common_reload": "重新加载",
|
||||
"common_clear": "清除",
|
||||
"path_currentPath": "当前路径:{path}",
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
bool _savePassword = false;
|
||||
bool _isLoading = true;
|
||||
bool _obscurePassword = true;
|
||||
String? _loginError;
|
||||
late MeshCoreConnector _connector;
|
||||
int _currentAttempt = 0;
|
||||
static const int _maxAttempts = 5;
|
||||
|
|
@ -79,6 +80,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
setState(() {
|
||||
_isLoggingIn = true;
|
||||
_currentAttempt = 0;
|
||||
_loginError = null;
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
@ -134,7 +136,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
'Login failed for ${repeater.name}',
|
||||
tag: 'RepeaterLogin',
|
||||
);
|
||||
throw Exception('Wrong password or node is unreachable');
|
||||
break;
|
||||
}
|
||||
appLogger.warn(
|
||||
'Login attempt ${attempt + 1} timed out after ${timeoutSeconds}s',
|
||||
|
|
@ -156,7 +158,13 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
}
|
||||
|
||||
if (loginResult != true) {
|
||||
throw Exception('Wrong password or node is unreachable');
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoggingIn = false;
|
||||
_loginError = context.l10n.login_failedMessage;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If we got a response, login succeeded
|
||||
|
|
@ -182,13 +190,8 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoggingIn = false;
|
||||
_loginError = context.l10n.login_failedMessage;
|
||||
});
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(context.l10n.login_failed(e.toString())),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -271,6 +274,25 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (_loginError != null) ...[
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.error, size: 18, color: Theme.of(context).colorScheme.error),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_loginError!,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
TextField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
|
|
@ -292,6 +314,13 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||
},
|
||||
),
|
||||
),
|
||||
onChanged: (_) {
|
||||
if (_loginError != null && mounted) {
|
||||
setState(() {
|
||||
_loginError = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
onSubmitted: (_) => _handleLogin(),
|
||||
autofocus: _passwordController.text.isEmpty,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue