Toyota Connected: Toyota, Lexus and Subaru as three plugins
One connector, registered once per brand with the brand fixed, so the
panel, the Web App and the Phone App each list Toyota, Lexus and Subaru
separately: own card, own account, own enable switch, own
/api/integrations/{brand} routes and vehicle provider. The brand picker
is gone.
Settings saved before the split under pluginSettings.toyota with brand
L or S move onto their brand's key on read, and are written back on the
next save. Cars linked as provider "toyota" read through their make's
brand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d8636ee73
commit
914aeeee23
21 files changed
+837
-471
No files matched your search
@@ -631,6 +631,10 @@
|
||||
"title": "Integrationer",
|
||||
"subtitle": "Forbind eksterne tjenester til din konto.",
|
||||
"toyotaDesc": "Log ind med din MyToyota-konto for at hente køretøjsdata fra Toyota Connected Europe. Kun Europa.",
|
||||
"lexus": "Lexus (Lexus Link+)",
|
||||
"lexusDesc": "Log ind med din Lexus Link+-konto for at hente køretøjsdata fra Toyota Connected Europe. Kun Europa.",
|
||||
"subaru": "Subaru (MySubaru)",
|
||||
"subaruDesc": "Log ind med din MySubaru-konto for at hente Solterra-data fra Toyota Connected Europe. Kun Europa.",
|
||||
"enable": "Aktivér for min konto",
|
||||
"enableOrg": "Aktivér for organisationen",
|
||||
"unavailable": "Denne integration er slået fra af administratoren.",
|
||||
@@ -639,9 +643,8 @@
|
||||
"scopeOrg": "Organisation",
|
||||
"scopeHint": "Organisationens indstillinger gælder for alle i din organisation, der lader et felt stå tomt.",
|
||||
"readOnly": "Denne integrations fælles indstillinger administreres i API-serverens panel; her er de skrivebeskyttede.",
|
||||
"email": "MyToyota-e-mail",
|
||||
"password": "MyToyota-adgangskode",
|
||||
"brand": "Mærke",
|
||||
"email": "{app}-e-mail",
|
||||
"password": "{app}-adgangskode",
|
||||
"inherited": "Sat på et højere niveau",
|
||||
"inheritedFrom": "Nedarvet fra {source}",
|
||||
"sourceGlobal": "administratoren",
|
||||
@@ -733,9 +736,6 @@
|
||||
"greencellCommandTopic": "Emne for QUERY-kommandoen",
|
||||
"greencellCommandTopicHint": "Valgfrit. Greencell beskriver en QUERY-kommando, der får laderen til at publicere med det samme, men ikke det emne, den lytter på. Finder du dit, så skriv det her, og læsninger behøver ikke vente på laderens egen kadence. Brug {sn} for serienummeret.",
|
||||
"toyota": "Toyota Connected (MyToyota)",
|
||||
"brandToyota": "Toyota",
|
||||
"brandLexus": "Lexus",
|
||||
"brandSubaru": "Subaru",
|
||||
"ankerSolix": "Anker Solix (V1 Smart EV Charger)",
|
||||
"categories": {
|
||||
"vehicles": "Bilproducenter",
|
||||
|
||||
@@ -498,6 +498,10 @@
|
||||
"subtitle": "Connect external services to your account.",
|
||||
"toyota": "Toyota Connected (MyToyota)",
|
||||
"toyotaDesc": "Sign in with your MyToyota account to pull vehicle data from Toyota Connected Europe. Europe only.",
|
||||
"lexus": "Lexus (Lexus Link+)",
|
||||
"lexusDesc": "Sign in with your Lexus Link+ account to pull vehicle data from Toyota Connected Europe. Europe only.",
|
||||
"subaru": "Subaru (MySubaru)",
|
||||
"subaruDesc": "Sign in with your MySubaru account to pull Solterra vehicle data from Toyota Connected Europe. Europe only.",
|
||||
"enable": "Enable for my account",
|
||||
"enableOrg": "Enable for the organization",
|
||||
"unavailable": "This integration is turned off by the administrator.",
|
||||
@@ -506,12 +510,8 @@
|
||||
"scopeOrg": "Organization",
|
||||
"scopeHint": "Organization settings apply to everyone in your organization who leaves a field blank.",
|
||||
"readOnly": "You manage this integration's shared settings in the API Server panel; here it is read-only.",
|
||||
"email": "MyToyota email",
|
||||
"password": "MyToyota password",
|
||||
"brand": "Brand",
|
||||
"brandToyota": "Toyota",
|
||||
"brandLexus": "Lexus",
|
||||
"brandSubaru": "Subaru",
|
||||
"email": "{app} email",
|
||||
"password": "{app} password",
|
||||
"inherited": "Set above your level",
|
||||
"inheritedFrom": "Inherited from {source}",
|
||||
"sourceGlobal": "the administrator",
|
||||
|
||||
@@ -639,6 +639,10 @@
|
||||
"title": "Integracje",
|
||||
"subtitle": "Połącz zewnętrzne usługi ze swoim kontem.",
|
||||
"toyotaDesc": "Zaloguj się kontem MyToyota, aby pobierać dane pojazdu z Toyota Connected Europe. Tylko Europa.",
|
||||
"lexus": "Lexus (Lexus Link+)",
|
||||
"lexusDesc": "Zaloguj się kontem Lexus Link+, aby pobierać dane pojazdu z Toyota Connected Europe. Tylko Europa.",
|
||||
"subaru": "Subaru (MySubaru)",
|
||||
"subaruDesc": "Zaloguj się kontem MySubaru, aby pobierać dane Solterry z Toyota Connected Europe. Tylko Europa.",
|
||||
"enable": "Włącz dla mojego konta",
|
||||
"enableOrg": "Włącz dla organizacji",
|
||||
"unavailable": "Ta integracja została wyłączona przez administratora.",
|
||||
@@ -647,9 +651,8 @@
|
||||
"scopeOrg": "Organizacja",
|
||||
"scopeHint": "Ustawienia organizacji obowiązują każdego w Twojej organizacji, kto pozostawi pole puste.",
|
||||
"readOnly": "Wspólnymi ustawieniami tej integracji zarządzasz w panelu API Servera; tutaj są tylko do odczytu.",
|
||||
"email": "E-mail MyToyota",
|
||||
"password": "Hasło MyToyota",
|
||||
"brand": "Marka",
|
||||
"email": "E-mail {app}",
|
||||
"password": "Hasło {app}",
|
||||
"inherited": "Ustawione na wyższym poziomie",
|
||||
"inheritedFrom": "Odziedziczone od: {source}",
|
||||
"sourceGlobal": "administratora",
|
||||
@@ -741,9 +744,6 @@
|
||||
"greencellCommandTopic": "Temat polecenia QUERY",
|
||||
"greencellCommandTopicHint": "Opcjonalne. Greencell opisuje polecenie QUERY, które każe ładowarce natychmiast opublikować dane, ale nie podaje tematu, na którym ona nasłuchuje. Jeśli poznasz swój, wpisz go tutaj, a odczyty przestaną czekać na własny rytm ładowarki. Użyj {sn} zamiast numeru seryjnego.",
|
||||
"toyota": "Toyota Connected (MyToyota)",
|
||||
"brandToyota": "Toyota",
|
||||
"brandLexus": "Lexus",
|
||||
"brandSubaru": "Subaru",
|
||||
"ankerSolix": "Anker Solix (V1 Smart EV Charger)",
|
||||
"categories": {
|
||||
"vehicles": "Producenci samochodów",
|
||||
|
||||
@@ -600,18 +600,21 @@ class ApiClient {
|
||||
// (effective/own/locked per field, secrets and inherited values masked); save…
|
||||
// writes the caller's editable layer (scope "user" by default, "org" for org
|
||||
// admins); test… runs a live probe under the resolved config.
|
||||
Future<IntegrationView> getToyota() async {
|
||||
final data = await _send("GET", "/integrations/toyota");
|
||||
//
|
||||
// brand is "toyota", "lexus" or "subaru": one connector on the server, but
|
||||
// three integrations with their own accounts.
|
||||
Future<IntegrationView> getToyota([String brand = "toyota"]) async {
|
||||
final data = await _send("GET", "/integrations/$brand");
|
||||
return IntegrationView.fromJson(Map<String, dynamic>.from(data));
|
||||
}
|
||||
|
||||
Future<IntegrationView> saveToyota(Map<String, dynamic> body) async {
|
||||
final data = await _send("PUT", "/integrations/toyota", body: body);
|
||||
Future<IntegrationView> saveToyota(Map<String, dynamic> body, [String brand = "toyota"]) async {
|
||||
final data = await _send("PUT", "/integrations/$brand", body: body);
|
||||
return IntegrationView.fromJson(Map<String, dynamic>.from(data));
|
||||
}
|
||||
|
||||
Future<IntegrationHealth> testToyota() async {
|
||||
final data = await _send("POST", "/integrations/toyota/health");
|
||||
Future<IntegrationHealth> testToyota([String brand = "toyota"]) async {
|
||||
final data = await _send("POST", "/integrations/$brand/health");
|
||||
final h = (data is Map ? data["health"] : null) ?? {};
|
||||
return IntegrationHealth.fromJson(Map<String, dynamic>.from(h));
|
||||
}
|
||||
|
||||
@@ -1540,7 +1540,7 @@ class _DangerSectionState extends State<_DangerSection> {
|
||||
|
||||
// --- Integrations tab ------------------------------------------------------
|
||||
//
|
||||
// Three foldable connector cards (Toyota, Anker Solix, Greencell) over a
|
||||
// Foldable connector cards (Toyota, Lexus, Subaru, Anker Solix, Greencell) over a
|
||||
// superadmin → org admin → user cascade. Each card resolves, per field, the effective value
|
||||
// (secrets/inherited values masked), the caller's own-layer value, its source
|
||||
// layer, and whether it's locked (set above the caller). Org admins get a
|
||||
@@ -1609,6 +1609,9 @@ class _IntegrationConfig {
|
||||
final Future<IntegrationView> Function(Map<String, dynamic>) save;
|
||||
final Future<IntegrationHealth> Function() test;
|
||||
|
||||
/// Filled into every field label — the app name in "{app} email".
|
||||
final Map<String, Object?> labelParams;
|
||||
|
||||
const _IntegrationConfig({
|
||||
required this.nameKey,
|
||||
required this.descKey,
|
||||
@@ -1617,6 +1620,7 @@ class _IntegrationConfig {
|
||||
required this.load,
|
||||
required this.save,
|
||||
required this.test,
|
||||
this.labelParams = const {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1634,29 +1638,26 @@ class _IntegrationsTabState extends State<_IntegrationsTab> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final toyota = _IntegrationConfig(
|
||||
nameKey: "settings.integrations.toyota",
|
||||
descKey: "settings.integrations.toyotaDesc",
|
||||
anker: false,
|
||||
load: apiClient.getToyota,
|
||||
save: apiClient.saveToyota,
|
||||
test: apiClient.testToyota,
|
||||
fields: const [
|
||||
_FieldSpec(key: "username", labelKey: "settings.integrations.email"),
|
||||
_FieldSpec(key: "password", labelKey: "settings.integrations.password", type: _FieldType.password),
|
||||
_FieldSpec(
|
||||
key: "brand",
|
||||
labelKey: "settings.integrations.brand",
|
||||
type: _FieldType.select,
|
||||
options: [
|
||||
("", "common.empty"),
|
||||
("T", "settings.integrations.brandToyota"),
|
||||
("L", "settings.integrations.brandLexus"),
|
||||
("S", "settings.integrations.brandSubaru"),
|
||||
// Toyota, Lexus and Subaru are one connector on the server, but each is an
|
||||
// integration of its own here: its own account, switch and card.
|
||||
_IntegrationConfig toyotaBrand(String brand, String app) => _IntegrationConfig(
|
||||
nameKey: "settings.integrations.$brand",
|
||||
descKey: "settings.integrations.${brand}Desc",
|
||||
anker: false,
|
||||
load: () => apiClient.getToyota(brand),
|
||||
save: (body) => apiClient.saveToyota(body, brand),
|
||||
test: () => apiClient.testToyota(brand),
|
||||
labelParams: {"app": app},
|
||||
fields: const [
|
||||
_FieldSpec(key: "username", labelKey: "settings.integrations.email"),
|
||||
_FieldSpec(key: "password", labelKey: "settings.integrations.password", type: _FieldType.password),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
);
|
||||
final toyotaBrands = [
|
||||
toyotaBrand("toyota", "MyToyota"),
|
||||
toyotaBrand("lexus", "Lexus Link+"),
|
||||
toyotaBrand("subaru", "MySubaru"),
|
||||
];
|
||||
|
||||
final anker = _IntegrationConfig(
|
||||
nameKey: "settings.integrations.ankerSolix",
|
||||
@@ -1786,7 +1787,7 @@ class _IntegrationsTabState extends State<_IntegrationsTab> {
|
||||
// exactly these cards a line below it, so saying how many would be saying it
|
||||
// twice.
|
||||
final groups = [
|
||||
[toyota],
|
||||
toyotaBrands,
|
||||
[anker, greencell],
|
||||
];
|
||||
final index = _group.clamp(0, groups.length - 1);
|
||||
@@ -1814,7 +1815,9 @@ class _IntegrationsTabState extends State<_IntegrationsTab> {
|
||||
for (final config in groups[index])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _IntegrationCard(config: config),
|
||||
// Keyed, so switching category never hands one card's state
|
||||
// (its loaded view, its typed password) to another.
|
||||
child: _IntegrationCard(key: ValueKey(config.nameKey), config: config),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -1826,7 +1829,7 @@ class _IntegrationsTabState extends State<_IntegrationsTab> {
|
||||
|
||||
class _IntegrationCard extends StatefulWidget {
|
||||
final _IntegrationConfig config;
|
||||
const _IntegrationCard({required this.config});
|
||||
const _IntegrationCard({super.key, required this.config});
|
||||
@override
|
||||
State<_IntegrationCard> createState() => _IntegrationCardState();
|
||||
}
|
||||
@@ -2333,7 +2336,7 @@ class _IntegrationCardState extends State<_IntegrationCard> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(t(f.labelKey), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||
Text(t(f.labelKey, params: _c.labelParams), style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||
const SizedBox(height: 4),
|
||||
input,
|
||||
if (hint != null)
|
||||
|
||||
Reference in new issue
Block a user