commit branches simulator windows web differences implementation
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../models/response_output.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
import '../models/response_output.dart';
|
||||
import '../helper/constants.dart';
|
||||
|
||||
enum MainView { dashboard, traun, sarleinsbach, lannach, settings }
|
||||
@@ -94,6 +96,18 @@ class HomeController extends GetxController {
|
||||
},
|
||||
};
|
||||
|
||||
//Device Info data
|
||||
Future<bool> isAndroidSimulator() async {
|
||||
// Prüfen, ob es überhaupt Android ist
|
||||
if (!Platform.isAndroid) return false;
|
||||
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final androidInfo = await deviceInfo.androidInfo;
|
||||
|
||||
// Wenn es KEIN physisches Gerät ist, ist es ein Simulator/Emulator
|
||||
return !androidInfo.isPhysicalDevice;
|
||||
}
|
||||
|
||||
void fetchData() async {
|
||||
final inputFromIso = dateFromToIsoController.value.text;
|
||||
final inputToIso = dateToIsoController.value.text;
|
||||
@@ -104,7 +118,7 @@ class HomeController extends GetxController {
|
||||
return;
|
||||
}
|
||||
|
||||
final baseUrl = _getBaseUrl();
|
||||
final baseUrl = getBaseUrl;
|
||||
if (baseUrl.isEmpty) {
|
||||
kDisplaySnackBarRed('Bitte zuerst die Server-URL eintragen.');
|
||||
return;
|
||||
@@ -123,12 +137,24 @@ class HomeController extends GetxController {
|
||||
|
||||
try {
|
||||
// Fetch PV Daten
|
||||
await _fetchAndStore(baseUri, inputFromIso, inputToIso,
|
||||
config['pvSuffix'], config['pv'], basicAuth);
|
||||
await _fetchAndStore(
|
||||
baseUri,
|
||||
inputFromIso,
|
||||
inputToIso,
|
||||
config['pvSuffix'],
|
||||
config['pv'],
|
||||
basicAuth,
|
||||
);
|
||||
|
||||
// Fetch Import Daten
|
||||
await _fetchAndStore(baseUri, inputFromIso, inputToIso,
|
||||
config['importSuffix'], config['import'], basicAuth);
|
||||
await _fetchAndStore(
|
||||
baseUri,
|
||||
inputFromIso,
|
||||
inputToIso,
|
||||
config['importSuffix'],
|
||||
config['import'],
|
||||
basicAuth,
|
||||
);
|
||||
} catch (e) {
|
||||
print('Error: $e');
|
||||
kDisplaySnackBarRed('Netzwerkfehler: $e');
|
||||
@@ -163,7 +189,9 @@ class HomeController extends GetxController {
|
||||
|
||||
if (statusGroup == 2) {
|
||||
print('✓ $switchBranch erfolgreich geladen');
|
||||
responseObservable.value = ResponseOutput.fromJson(jsonDecode(response.body));
|
||||
responseObservable.value = ResponseOutput.fromJson(
|
||||
jsonDecode(response.body),
|
||||
);
|
||||
} else if (statusGroup == 4) {
|
||||
kDisplaySnackBarRed('Fehler 4xx: ${response.statusCode}');
|
||||
} else if (statusGroup == 5) {
|
||||
@@ -177,20 +205,37 @@ class HomeController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wählt die richtige Base-URL:
|
||||
/// Web: localhost:3000 (Reverse Proxy)
|
||||
/// Desktop: Direkt von Settings
|
||||
String _getBaseUrl() {
|
||||
final settingsUrl = powerUrlController.value.text.trim();
|
||||
final isEmulator = false.obs;
|
||||
|
||||
// Auf Web: verwende Reverse Proxy auf localhost:3000
|
||||
// Synchroner Getter
|
||||
String get getBaseUrl {
|
||||
if (kIsWeb) {
|
||||
return 'http://localhost:3000/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
}
|
||||
|
||||
// Auf Desktop (Windows, Linux, macOS): direkt von Settings
|
||||
return settingsUrl;
|
||||
if (isEmulator.value) {
|
||||
return 'http://10.12.101.27:5556/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
}
|
||||
return powerUrlController.value.text.trim();
|
||||
}
|
||||
|
||||
|
||||
/// Wählt die richtige Base-URL:
|
||||
/// Web: localhost:3000 (Reverse Proxy)
|
||||
/// Desktop: Direkt von Settings
|
||||
// Future<String> _getBaseUrl() async {
|
||||
// final settingsUrl = powerUrlController.value.text.trim();
|
||||
|
||||
// // Auf Web: verwende Reverse Proxy auf localhost:3000
|
||||
// if (kIsWeb) {
|
||||
// return 'http://localhost:3000/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
// }
|
||||
// if (await isAndroidSimulator()) {
|
||||
// return 'http://10.12.101.27:5556/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
// }
|
||||
|
||||
// // Auf Desktop (Windows, Linux, macOS): direkt von Settings
|
||||
// return settingsUrl;
|
||||
// }
|
||||
|
||||
void changeView(MainView view) {
|
||||
currentView.value = view;
|
||||
@@ -225,8 +270,13 @@ class HomeController extends GetxController {
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
if (!kIsWeb && Platform.isAndroid) {
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final androidInfo = await deviceInfo.androidInfo;
|
||||
isEmulator(!androidInfo.isPhysicalDevice);
|
||||
}
|
||||
_readStorageData();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Values {
|
||||
|
||||
Values.fromJson(Map<String, dynamic> json) {
|
||||
datetime = json['datetime'];
|
||||
value = json['value'];
|
||||
value = (json['value'] as num?)?.toDouble();
|
||||
tariff = json['tariff'];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import device_info_plus
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
}
|
||||
|
||||
@@ -73,6 +73,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.9"
|
||||
device_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: device_info_plus
|
||||
sha256: a7fd703482b391a87d60b6061d04dfdeab07826b96f9abd8f5ed98068acc0074
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.1.2"
|
||||
device_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: device_info_plus_platform_interface
|
||||
sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.3"
|
||||
equatable:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -97,6 +113,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
fl_chart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -123,6 +147,11 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
get:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -440,6 +469,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.15.0"
|
||||
win32_registry:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32_registry
|
||||
sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.5"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -17,6 +17,7 @@ dependencies:
|
||||
get_storage: ^2.1.1
|
||||
http: ^1.6.0
|
||||
intl: ^0.20.3
|
||||
device_info_plus: ^10.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_lints: ^6.0.0
|
||||
|
||||
@@ -26,7 +26,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
Win32Window::Size size(1280, 986);
|
||||
if (!window.Create(L"flutter_test_services", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user