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