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:
@@ -0,0 +1,66 @@
|
||||
// Copyright 2017 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:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
// Export enums from the platform_interface so plugin users can use them directly.
|
||||
export 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart'
|
||||
show ConnectivityResult;
|
||||
|
||||
export 'src/connectivity_plus_linux.dart'
|
||||
if (dart.library.js_interop) 'src/connectivity_plus_web.dart';
|
||||
|
||||
/// Discover network connectivity configurations: Distinguish between WI-FI and cellular, check WI-FI status and more.
|
||||
class Connectivity {
|
||||
/// Constructs a singleton instance of [Connectivity].
|
||||
///
|
||||
/// [Connectivity] 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 Connectivity() {
|
||||
_singleton ??= Connectivity._();
|
||||
return _singleton!;
|
||||
}
|
||||
|
||||
Connectivity._();
|
||||
|
||||
static Connectivity? _singleton;
|
||||
|
||||
static ConnectivityPlatform get _platform {
|
||||
return ConnectivityPlatform.instance;
|
||||
}
|
||||
|
||||
/// Exposes connectivity update events from the platform.
|
||||
///
|
||||
/// On iOS, the connectivity status might not update when WiFi
|
||||
/// status changes, this is a known issue that only affects simulators.
|
||||
/// For details see https://github.com/fluttercommunity/plus_plugins/issues/479.
|
||||
///
|
||||
/// The emitted list is never empty. In case of no connectivity, the list contains
|
||||
/// a single element of [ConnectivityResult.none]. Note also that this is the only
|
||||
/// case where [ConnectivityResult.none] is present.
|
||||
///
|
||||
/// This method applies [Stream.distinct] over the received events to ensure
|
||||
/// only emiting when connectivity changes.
|
||||
Stream<List<ConnectivityResult>> get onConnectivityChanged {
|
||||
return _platform.onConnectivityChanged.distinct((a, b) => a.equals(b));
|
||||
}
|
||||
|
||||
/// Checks the connection status of the device.
|
||||
///
|
||||
/// Do not use the result of this function to decide whether you can reliably
|
||||
/// make a network request, it only gives you the radio status. Instead, listen
|
||||
/// for connectivity changes via [onConnectivityChanged] stream.
|
||||
///
|
||||
/// The returned list is never empty. In case of no connectivity, the list contains
|
||||
/// a single element of [ConnectivityResult.none]. Note also that this is the only
|
||||
/// case where [ConnectivityResult.none] is present.
|
||||
Future<List<ConnectivityResult>> checkConnectivity() {
|
||||
return _platform.checkConnectivity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:nm/nm.dart';
|
||||
|
||||
// Used internally
|
||||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
@visibleForTesting
|
||||
typedef NetworkManagerClientFactory = NetworkManagerClient Function();
|
||||
|
||||
/// The Linux implementation of ConnectivityPlatform.
|
||||
class ConnectivityPlusLinuxPlugin extends ConnectivityPlatform {
|
||||
/// Register this dart class as the platform implementation for linux
|
||||
static void registerWith() {
|
||||
ConnectivityPlatform.instance = ConnectivityPlusLinuxPlugin();
|
||||
}
|
||||
|
||||
/// Checks the connection status of the device.
|
||||
@override
|
||||
Future<List<ConnectivityResult>> checkConnectivity() async {
|
||||
final client = createClient();
|
||||
await client.connect();
|
||||
final connectivity = _getConnectivity(client);
|
||||
await client.close();
|
||||
return connectivity;
|
||||
}
|
||||
|
||||
NetworkManagerClient? _client;
|
||||
StreamController<List<ConnectivityResult>>? _controller;
|
||||
|
||||
/// Returns a Stream of ConnectivityResults changes.
|
||||
@override
|
||||
Stream<List<ConnectivityResult>> get onConnectivityChanged {
|
||||
_controller ??= StreamController<List<ConnectivityResult>>.broadcast(
|
||||
onListen: _startListenConnectivity,
|
||||
onCancel: _stopListenConnectivity,
|
||||
);
|
||||
return _controller!.stream;
|
||||
}
|
||||
|
||||
List<ConnectivityResult> _getConnectivity(NetworkManagerClient client) {
|
||||
final List<ConnectivityResult> results = [];
|
||||
if (client.connectivity == NetworkManagerConnectivityState.none) {
|
||||
results.add(ConnectivityResult.none);
|
||||
} else {
|
||||
if (client.primaryConnectionType.contains('wireless')) {
|
||||
results.add(ConnectivityResult.wifi);
|
||||
}
|
||||
if (client.primaryConnectionType.contains('ethernet')) {
|
||||
results.add(ConnectivityResult.ethernet);
|
||||
}
|
||||
if (client.primaryConnectionType.contains('vpn')) {
|
||||
results.add(ConnectivityResult.vpn);
|
||||
}
|
||||
if (client.primaryConnectionType.contains('bluetooth')) {
|
||||
results.add(ConnectivityResult.bluetooth);
|
||||
}
|
||||
if (client.primaryConnectionType.contains('mobile')) {
|
||||
results.add(ConnectivityResult.mobile);
|
||||
}
|
||||
// Assuming 'other' is a catch-all for unspecified types
|
||||
if (results.isEmpty) {
|
||||
results.add(ConnectivityResult.other);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
Future<void> _startListenConnectivity() async {
|
||||
_client ??= createClient();
|
||||
await _client!.connect();
|
||||
_addConnectivity(_client!);
|
||||
_client!.propertiesChanged.listen((properties) {
|
||||
if (properties.contains('Connectivity')) {
|
||||
_addConnectivity(_client!);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _addConnectivity(NetworkManagerClient client) {
|
||||
_controller!.add(_getConnectivity(client));
|
||||
}
|
||||
|
||||
Future<void> _stopListenConnectivity() async {
|
||||
await _client?.close();
|
||||
_client = null;
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
// ignore: prefer_function_declarations_over_variables
|
||||
NetworkManagerClientFactory createClient = () => NetworkManagerClient();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
import 'web/dart_html_connectivity_plugin.dart';
|
||||
|
||||
/// The web implementation of the ConnectivityPlatform of the Connectivity plugin.
|
||||
class ConnectivityPlusWebPlugin extends ConnectivityPlatform {
|
||||
/// Factory method that initializes the connectivity plugin platform with an instance
|
||||
/// of the plugin for the web.
|
||||
static void registerWith(Registrar registrar) {
|
||||
ConnectivityPlatform.instance = DartHtmlConnectivityPlugin();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'dart:async';
|
||||
import 'package:web/web.dart';
|
||||
|
||||
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
|
||||
|
||||
import '../connectivity_plus_web.dart';
|
||||
|
||||
/// The web implementation of the ConnectivityPlatform of the Connectivity plugin.
|
||||
class DartHtmlConnectivityPlugin extends ConnectivityPlusWebPlugin {
|
||||
/// Checks the connection status of the device.
|
||||
@override
|
||||
Future<List<ConnectivityResult>> checkConnectivity() async {
|
||||
return (window.navigator.onLine)
|
||||
? [ConnectivityResult.wifi]
|
||||
: [ConnectivityResult.none];
|
||||
}
|
||||
|
||||
StreamController<List<ConnectivityResult>>? _connectivityResult;
|
||||
|
||||
/// Returns a Stream of ConnectivityResults changes.
|
||||
@override
|
||||
Stream<List<ConnectivityResult>> get onConnectivityChanged {
|
||||
if (_connectivityResult == null) {
|
||||
_connectivityResult =
|
||||
StreamController<List<ConnectivityResult>>.broadcast();
|
||||
const EventStreamProvider<Event>('online').forTarget(window).listen((_) {
|
||||
_connectivityResult!.add([ConnectivityResult.wifi]);
|
||||
});
|
||||
const EventStreamProvider<Event>('offline').forTarget(window).listen((_) {
|
||||
_connectivityResult!.add([ConnectivityResult.none]);
|
||||
});
|
||||
}
|
||||
return _connectivityResult!.stream;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'dart:html' as html show NetworkInformation;
|
||||
|
||||
import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart';
|
||||
|
||||
/// Converts an incoming NetworkInformation object into the correct ConnectivityResult.
|
||||
List<ConnectivityResult> networkInformationToConnectivityResult(
|
||||
html.NetworkInformation info,
|
||||
) {
|
||||
if (info.downlink == 0 && info.rtt == 0) {
|
||||
return [ConnectivityResult.none];
|
||||
}
|
||||
if (info.type != null) {
|
||||
return _typeToConnectivityResult(info.type!);
|
||||
}
|
||||
if (info.effectiveType != null) {
|
||||
return _effectiveTypeToConnectivityResult(info.effectiveType!);
|
||||
}
|
||||
return [ConnectivityResult.none];
|
||||
}
|
||||
|
||||
List<ConnectivityResult> _effectiveTypeToConnectivityResult(
|
||||
String effectiveType) {
|
||||
// Possible values:
|
||||
/*'2g'|'3g'|'4g'|'slow-2g'*/
|
||||
switch (effectiveType) {
|
||||
case 'slow-2g':
|
||||
case '2g':
|
||||
case '3g':
|
||||
case '4g':
|
||||
return [ConnectivityResult.mobile];
|
||||
default:
|
||||
return [ConnectivityResult.wifi];
|
||||
}
|
||||
}
|
||||
|
||||
List<ConnectivityResult> _typeToConnectivityResult(String type) {
|
||||
// Possible values: 'bluetooth', 'cellular', 'ethernet', 'mixed', 'none', 'other', 'unknown', 'wifi', 'wimax'
|
||||
switch (type) {
|
||||
case 'none':
|
||||
// Corrected to return a list
|
||||
return [ConnectivityResult.none];
|
||||
case 'bluetooth':
|
||||
return [ConnectivityResult.bluetooth];
|
||||
case 'cellular':
|
||||
case 'mixed':
|
||||
case 'other':
|
||||
case 'unknown':
|
||||
return [ConnectivityResult.mobile];
|
||||
case 'ethernet':
|
||||
return [ConnectivityResult.ethernet];
|
||||
case 'wifi':
|
||||
case 'wimax': // Assuming 'wimax' should be treated the same as 'wifi'
|
||||
return [ConnectivityResult.wifi];
|
||||
default:
|
||||
// Assuming default should be 'other' to cover all unspecified cases
|
||||
return [ConnectivityResult.other];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user