fix: Récupérer l'opération active depuis la table operations

- Corrige l'erreur SQL 'Unknown column fk_operation in users'
- L'opération active est récupérée depuis operations.chk_active = 1
- Jointure avec users pour filtrer par entité de l'admin créateur
- Query: SELECT o.id FROM operations o INNER JOIN users u ON u.fk_entite = o.fk_entite WHERE u.id = ? AND o.chk_active = 1
This commit is contained in:
2026-01-26 16:57:08 +01:00
parent c24a3afe6a
commit 0687900564
3040 changed files with 77204 additions and 1578 deletions

View File

@@ -0,0 +1,56 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart';
export 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart'
show BatteryState;
export 'src/battery_plus_linux.dart';
/// API for accessing information about the battery of the device the Flutter app is running on.
class Battery {
/// Constructs a singleton instance of [Battery].
///
/// [Battery] is designed to work as a singleton.
// When a second instance is created, the first instance will not be able to listen to the
// EventChannel because it is overridden. Forcing the class to be a singleton class can prevent
// misuse of creating a second instance from a programmer.
factory Battery() {
_singleton ??= Battery._();
return _singleton!;
}
Battery._();
static Battery? _singleton;
static BatteryPlatform get _platform {
return BatteryPlatform.instance;
}
/// get battery level
Future<int> get batteryLevel {
return _platform.batteryLevel;
}
/// check if device is on battery save mode
///
/// Currently only implemented on Android, iOS and Windows.
Future<bool> get isInBatterySaveMode {
return _platform.isInBatterySaveMode;
}
/// Get battery state
Future<BatteryState> get batteryState {
return _platform.batteryState;
}
/// Fires whenever the battery state changes.
Stream<BatteryState> get onBatteryStateChanged {
return _platform.onBatteryStateChanged;
}
}

View File

@@ -0,0 +1,98 @@
import 'dart:async';
import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart';
import 'package:meta/meta.dart';
import 'package:upower/upower.dart';
extension _ToBatteryState on UPowerDeviceState {
BatteryState toBatteryState() {
switch (this) {
case UPowerDeviceState.charging:
return BatteryState.charging;
case UPowerDeviceState.discharging:
case UPowerDeviceState.pendingDischarge:
return BatteryState.discharging;
case UPowerDeviceState.fullyCharged:
return BatteryState.full;
case UPowerDeviceState.pendingCharge:
return BatteryState.connectedNotCharging;
default:
return BatteryState.unknown;
}
}
}
///
@visibleForTesting
typedef UPowerClientFactory = UPowerClient Function();
/// The Linux implementation of BatteryPlatform.
class BatteryPlusLinuxPlugin extends BatteryPlatform {
/// Register this dart class as the platform implementation for linux
static void registerWith() {
BatteryPlatform.instance = BatteryPlusLinuxPlugin();
}
/// Returns the current battery level in percent.
@override
Future<int> get batteryLevel {
final client = createClient();
return client
.connect()
.then((_) => client.displayDevice.percentage.round())
.whenComplete(() => client.close());
}
/// Returns the current battery state.
@override
Future<BatteryState> get batteryState {
final client = createClient();
return client
.connect()
.then((_) => client.displayDevice.state.toBatteryState())
.whenComplete(() => client.close);
}
/// Fires whenever the battery state changes.
@override
Stream<BatteryState> get onBatteryStateChanged {
_stateController ??= StreamController<BatteryState>.broadcast(
onListen: _startListenState,
onCancel: _stopListenState,
);
return _stateController!.stream.asBroadcastStream();
}
UPowerClient? _stateClient;
StreamController<BatteryState>? _stateController;
@visibleForTesting
// ignore: public_member_api_docs, prefer_function_declarations_over_variables
UPowerClientFactory createClient = () => UPowerClient();
void _addState(UPowerDeviceState value) {
_stateController!.add(value.toBatteryState());
}
Future<void> _startListenState() async {
_stateClient ??= createClient();
await _stateClient!
.connect()
.then((_) => _addState(_stateClient!.displayDevice.state));
_stateClient!.displayDevice.propertiesChanged.listen((properties) {
if (properties.contains('State')) {
_addState(_stateClient!.displayDevice.state);
}
});
}
void _stopListenState() {
_stateController?.close();
_stateClient?.close();
_stateClient = null;
}
}

View File

@@ -0,0 +1,107 @@
import 'dart:async';
import 'dart:js_interop';
import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:web/web.dart';
/// The web implementation of the BatteryPlatform of the Battery plugin.
///
/// The Battery Status API is not supported by Firefox and Safari.
/// Therefore, when using this plugin, recommend that test not only in Chrome but also in Firefox and Safari.
/// In some environments, accessing this plugin from Firefox or Safari will cause unexpected exception.
/// If an unexpected Exception occurs, try-catch at the point where the method is being called.
class BatteryPlusWebPlugin extends BatteryPlatform {
/// Constructs a BatteryPlusPlugin.
BatteryPlusWebPlugin();
/// Return [BatteryManager] if the BatteryManager API is supported by the User Agent.
Future<BatteryManager?> _getBatteryManager() async {
try {
return await window.navigator.getBattery().toDart;
} on NoSuchMethodError catch (_) {
// BatteryManager API is not supported this User Agent.
return null;
} on Object catch (_) {
// Unexpected exception occurred.
return null;
}
}
/// Factory method that initializes the Battery plugin platform with an instance
/// of the plugin for the web.
static void registerWith(Registrar registrar) {
BatteryPlatform.instance = BatteryPlusWebPlugin();
}
/// Returns the current battery level in percent.
@override
Future<int> get batteryLevel async {
final batteryManager = await _getBatteryManager();
if (batteryManager == null) {
return 0;
}
// level is a number representing the system's battery charge level scaled to a value between 0.0 and 1.0
final level = batteryManager.level;
return (level * 100).toInt();
}
/// Returns the current battery state.
@override
Future<BatteryState> get batteryState async {
final batteryManager = await _getBatteryManager();
if (batteryManager == null) {
return BatteryState.unknown;
}
return _checkBatteryChargingState(batteryManager.charging);
}
StreamController<BatteryState>? _batteryChangeStreamController;
Stream<BatteryState>? _batteryChange;
/// Returns a Stream of BatteryState changes.
@override
Stream<BatteryState> get onBatteryStateChanged async* {
final batteryManager = await _getBatteryManager();
if (batteryManager == null) {
yield BatteryState.unknown;
return;
}
if (_batteryChange != null) {
yield* _batteryChange!;
return;
}
_batteryChangeStreamController = StreamController<BatteryState>();
_batteryChangeStreamController?.add(
_checkBatteryChargingState(batteryManager.charging),
);
batteryManager.onchargingchange = (Event _) {
_batteryChangeStreamController?.add(
_checkBatteryChargingState(batteryManager.charging),
);
}.toJS;
_batteryChangeStreamController?.onCancel = () {
_batteryChangeStreamController?.close();
_batteryChangeStreamController = null;
_batteryChange = null;
};
_batteryChange = _batteryChangeStreamController!.stream.asBroadcastStream();
yield* _batteryChange!;
}
BatteryState _checkBatteryChargingState(bool charging) {
if (charging) {
return BatteryState.charging;
} else {
return BatteryState.discharging;
}
}
}