Compare commits
4
Commits
c8a3cc9812
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ed1da54f | ||
|
|
9e356f8581 | ||
|
|
f0808047e3 | ||
|
|
423fa0efaa |
@@ -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,45 @@ class HomeController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
final isEmulator = false.obs;
|
||||
|
||||
// Synchroner Getter
|
||||
String get getBaseUrl {
|
||||
if (kIsWeb) {
|
||||
if (kDebugMode) {
|
||||
// Lokale Entwicklung mit lokalem Proxy
|
||||
return 'http://localhost:3000/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
} else {
|
||||
// Produktion: Direkt an den Server oder über den Produktions-Proxy
|
||||
return 'http://localhost:3000/invoke/IFN_ASKI_Service.flows/getAskiData?';
|
||||
// ODER bei Nginx-Proxy: '/api/IFN_ASKI_Service.flows/getAskiData?'
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
String _getBaseUrl() {
|
||||
final settingsUrl = powerUrlController.value.text.trim();
|
||||
// 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?';
|
||||
}
|
||||
// // 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;
|
||||
}
|
||||
// // Auf Desktop (Windows, Linux, macOS): direkt von Settings
|
||||
// return settingsUrl;
|
||||
// }
|
||||
|
||||
void changeView(MainView view) {
|
||||
currentView.value = view;
|
||||
@@ -225,8 +278,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'];
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,12 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 26.0,
|
||||
right: 35.0,
|
||||
top: 16.0,
|
||||
bottom: 16.0,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -92,6 +97,52 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
height: 500,
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
barTouchData: BarTouchData(
|
||||
enabled: true,
|
||||
touchTooltipData: BarTouchTooltipData(
|
||||
// Optional: Hintergrundfarbe und Styling des Tooltips anpassen
|
||||
getTooltipItem: (group, groupIndex, rod, rodIndex) {
|
||||
// 1. Datum/Uhrzeit anhand des groupIndex abrufen
|
||||
final rawDateTime = displayDatetimes[groupIndex];
|
||||
|
||||
// 2. Formatieren zu "20.07.26 12:00"
|
||||
String formattedDateTime = rawDateTime;
|
||||
try {
|
||||
final parsedDate = DateTime.parse(rawDateTime);
|
||||
final day = parsedDate.day.toString().padLeft(2, '0');
|
||||
final month = parsedDate.month.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
final year = parsedDate.year.toString().substring(2);
|
||||
final hour = parsedDate.hour.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
final minute = parsedDate.minute.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
formattedDateTime = '$day.$month.$year $hour:$minute';
|
||||
} catch (_) {}
|
||||
|
||||
// 3. Typ bestimmen (z.B. PV oder Import je nach Rod-Index)
|
||||
final label = rodIndex == 0 ? 'PV' : 'Import';
|
||||
final unit = 'kW';
|
||||
|
||||
// 4. Nur beim ersten Ballekn der Gruppe das Datum als Header einfügen
|
||||
// (sonst würde es bei jedem Einzelbalken doppelt stehen)
|
||||
return BarTooltipItem(
|
||||
'$formattedDateTime\n$label: ${rod.toY.round()} $unit',
|
||||
const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
alignment: BarChartAlignment.spaceAround,
|
||||
maxY: maxValue * 1.02,
|
||||
minY: 0,
|
||||
@@ -112,7 +163,7 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
// PV Maximum - oranger Pin
|
||||
if (index == maxPvIndex) {
|
||||
return Transform.translate(
|
||||
offset: const Offset(-5, 0),
|
||||
offset: const Offset(0, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -122,7 +173,9 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
color: Colors.grey.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
@@ -153,7 +206,7 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
// Import Maximum - roter Pin
|
||||
if (index == maxImportIndex) {
|
||||
return Transform.translate(
|
||||
offset: const Offset(5, 0),
|
||||
offset: const Offset(3, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -163,7 +216,9 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withValues(alpha: 0.3),
|
||||
color: Colors.grey.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
@@ -213,24 +268,71 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 60,
|
||||
reservedSize: 40, // Platz für die normale Textzeile
|
||||
getTitlesWidget: (value, meta) {
|
||||
final index = value.toInt();
|
||||
if (index < 0 || index >= displayDatetimes.length) {
|
||||
return const SizedBox();
|
||||
}
|
||||
final datetime = displayDatetimes[index];
|
||||
// Extrahiere nur Uhrzeit (HH:mm)
|
||||
final timePart = datetime.contains('T')
|
||||
? datetime.split('T').last.substring(0, 5)
|
||||
: datetime.substring(0, 5);
|
||||
|
||||
// 1. Indizes für Start, Mitte und Ende bestimmen
|
||||
final firstIndex = 0;
|
||||
final lastIndex = displayDatetimes.length - 1;
|
||||
final middleIndex = displayDatetimes.length ~/ 2;
|
||||
|
||||
// 2. Nur anzeigen, wenn es Start, Mitte oder Ende ist
|
||||
final isFirst = index == firstIndex;
|
||||
final isMiddle =
|
||||
index == middleIndex &&
|
||||
displayDatetimes.length > 2;
|
||||
final isLast =
|
||||
index == lastIndex && displayDatetimes.length > 1;
|
||||
|
||||
if (!isFirst && !isMiddle && !isLast) {
|
||||
return const SizedBox(); // Für alle anderen Balken ausblenden
|
||||
}
|
||||
|
||||
final datetimeRaw = displayDatetimes[index];
|
||||
|
||||
// 3. Formatiere den String zu "DD.MM.YY HH:mm"
|
||||
String formattedDateTime = datetimeRaw;
|
||||
try {
|
||||
final parsedDate = DateTime.parse(datetimeRaw);
|
||||
final day = parsedDate.day.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
final month = parsedDate.month.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
final year = parsedDate.year.toString().substring(
|
||||
2,
|
||||
); // Die letzten 2 Stellen
|
||||
final hour = parsedDate.hour.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
final minute = parsedDate.minute.toString().padLeft(
|
||||
2,
|
||||
'0',
|
||||
);
|
||||
|
||||
formattedDateTime =
|
||||
'$day.$month.$year $hour:$minute';
|
||||
} catch (_) {
|
||||
// Fallback, falls String kein echtes ISO-Format ist
|
||||
formattedDateTime = datetimeRaw;
|
||||
}
|
||||
|
||||
// 4. Liegend (horizontal) ausgeben
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: RotatedBox(
|
||||
quarterTurns: 1,
|
||||
child: Text(
|
||||
timePart,
|
||||
style: const TextStyle(fontSize: 10),
|
||||
child: Text(
|
||||
formattedDateTime,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -296,15 +398,17 @@ class ComparisonBarChart extends StatelessWidget {
|
||||
BarChartRodData(
|
||||
toY: pvValue,
|
||||
color: Colors.orange,
|
||||
width: 8,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(4)),
|
||||
width: 5, // <-- ERHEBLICH SCHMALER (z.B. 2 oder 3 statt 6/8)
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(1)),
|
||||
),
|
||||
// Roter Bar für Import
|
||||
BarChartRodData(
|
||||
toY: importValue,
|
||||
color: Colors.red,
|
||||
width: 8,
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(4)),
|
||||
width: 5, // <-- ERHEBLICH SCHMALER
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(2.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -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,8 +26,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.Create(L"flutter_test_services", origin, size)) {
|
||||
Win32Window::Size size(1280, 986);
|
||||
if (!window.Create(L"IFN ASKI Inside", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
window.SetQuitOnClose(true);
|
||||
|
||||
Reference in New Issue
Block a user