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,8 @@
|
||||
#if TARGET_OS_IOS
|
||||
#import <Flutter/Flutter.h>
|
||||
#elif TARGET_OS_OSX
|
||||
#import <FlutterMacOS/FlutterMacOS.h>
|
||||
#endif
|
||||
|
||||
@interface ConnectivityPlusPlugin : NSObject <FlutterPlugin>
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
#import "ConnectivityPlusPlugin.h"
|
||||
#if __has_include(<connectivity_plus/connectivity_plus-Swift.h>)
|
||||
#import <connectivity_plus/connectivity_plus-Swift.h>
|
||||
#else
|
||||
// Support project import fallback if the generated compatibility header
|
||||
// is not copied when this plugin is created as a library.
|
||||
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
|
||||
#import "connectivity_plus-Swift.h"
|
||||
#endif
|
||||
|
||||
@implementation ConnectivityPlusPlugin
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
[SwiftConnectivityPlusPlugin registerWithRegistrar:registrar];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
import Foundation
|
||||
|
||||
public enum ConnectivityType {
|
||||
case none
|
||||
case wiredEthernet
|
||||
case wifi
|
||||
case cellular
|
||||
case other
|
||||
}
|
||||
|
||||
public protocol ConnectivityProvider: NSObjectProtocol {
|
||||
typealias ConnectivityUpdateHandler = ([ConnectivityType]) -> Void
|
||||
|
||||
var currentConnectivityTypes: [ConnectivityType] { get }
|
||||
|
||||
var connectivityUpdateHandler: ConnectivityUpdateHandler? { get set }
|
||||
|
||||
func start()
|
||||
|
||||
func stop()
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import Foundation
|
||||
import Network
|
||||
|
||||
public class PathMonitorConnectivityProvider: NSObject, ConnectivityProvider {
|
||||
|
||||
// Use .utility, as it is intended for tasks that the user does not track actively.
|
||||
// See: https://developer.apple.com/documentation/dispatch/dispatchqos
|
||||
private let queue = DispatchQueue.global(qos: .utility)
|
||||
|
||||
private var pathMonitor: NWPathMonitor?
|
||||
|
||||
private func connectivityFrom(path: NWPath) -> [ConnectivityType] {
|
||||
var types: [ConnectivityType] = []
|
||||
|
||||
// Check for connectivity and append to types array as necessary
|
||||
if path.status == .satisfied {
|
||||
if path.usesInterfaceType(.wifi) {
|
||||
types.append(.wifi)
|
||||
}
|
||||
if path.usesInterfaceType(.cellular) {
|
||||
types.append(.cellular)
|
||||
}
|
||||
if path.usesInterfaceType(.wiredEthernet) {
|
||||
types.append(.wiredEthernet)
|
||||
}
|
||||
if path.usesInterfaceType(.other) {
|
||||
types.append(.other)
|
||||
}
|
||||
}
|
||||
|
||||
return types.isEmpty ? [.none] : types
|
||||
}
|
||||
|
||||
public var currentConnectivityTypes: [ConnectivityType] {
|
||||
let path = ensurePathMonitor().currentPath
|
||||
return connectivityFrom(path: path)
|
||||
}
|
||||
|
||||
public var connectivityUpdateHandler: ConnectivityUpdateHandler?
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
_ = ensurePathMonitor()
|
||||
}
|
||||
|
||||
public func start() {
|
||||
_ = ensurePathMonitor()
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
pathMonitor?.cancel()
|
||||
pathMonitor = nil
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
private func ensurePathMonitor() -> NWPathMonitor {
|
||||
if (pathMonitor == nil) {
|
||||
let pathMonitor = NWPathMonitor()
|
||||
pathMonitor.start(queue: queue)
|
||||
pathMonitor.pathUpdateHandler = pathUpdateHandler
|
||||
self.pathMonitor = pathMonitor
|
||||
}
|
||||
return self.pathMonitor!
|
||||
}
|
||||
|
||||
private func pathUpdateHandler(path: NWPath) {
|
||||
connectivityUpdateHandler?(connectivityFrom(path: path))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
||||
// Use of this source is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#if os(iOS)
|
||||
import Flutter
|
||||
#elseif os(macOS)
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
#endif
|
||||
|
||||
public class SwiftConnectivityPlusPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
private let connectivityProvider: ConnectivityProvider
|
||||
private var eventSink: FlutterEventSink?
|
||||
|
||||
init(connectivityProvider: ConnectivityProvider) {
|
||||
self.connectivityProvider = connectivityProvider
|
||||
super.init()
|
||||
self.connectivityProvider.connectivityUpdateHandler = connectivityUpdateHandler
|
||||
}
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
#if os(iOS)
|
||||
let binaryMessenger = registrar.messenger()
|
||||
#elseif os(macOS)
|
||||
let binaryMessenger = registrar.messenger
|
||||
#endif
|
||||
|
||||
let channel = FlutterMethodChannel(
|
||||
name: "dev.fluttercommunity.plus/connectivity",
|
||||
binaryMessenger: binaryMessenger)
|
||||
|
||||
let streamChannel = FlutterEventChannel(
|
||||
name: "dev.fluttercommunity.plus/connectivity_status",
|
||||
binaryMessenger: binaryMessenger)
|
||||
|
||||
let connectivityProvider = PathMonitorConnectivityProvider()
|
||||
let instance = SwiftConnectivityPlusPlugin(connectivityProvider: connectivityProvider)
|
||||
streamChannel.setStreamHandler(instance)
|
||||
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
}
|
||||
|
||||
public func detachFromEngine(for registrar: FlutterPluginRegistrar) {
|
||||
eventSink = nil
|
||||
connectivityProvider.stop()
|
||||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "check":
|
||||
result(statusFrom(connectivityTypes: connectivityProvider.currentConnectivityTypes))
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
|
||||
private func statusFrom(connectivityType: ConnectivityType) -> String {
|
||||
switch connectivityType {
|
||||
case .wifi:
|
||||
return "wifi"
|
||||
case .cellular:
|
||||
return "mobile"
|
||||
case .wiredEthernet:
|
||||
return "ethernet"
|
||||
case .other:
|
||||
return "other"
|
||||
case .none:
|
||||
return "none"
|
||||
}
|
||||
}
|
||||
|
||||
private func statusFrom(connectivityTypes: [ConnectivityType]) -> [String] {
|
||||
return connectivityTypes.map {
|
||||
self.statusFrom(connectivityType: $0)
|
||||
}
|
||||
}
|
||||
|
||||
public func onListen(
|
||||
withArguments _: Any?,
|
||||
eventSink events: @escaping FlutterEventSink
|
||||
) -> FlutterError? {
|
||||
eventSink = events
|
||||
connectivityProvider.start()
|
||||
// Update this to handle a list
|
||||
connectivityUpdateHandler(connectivityTypes: connectivityProvider.currentConnectivityTypes)
|
||||
return nil
|
||||
}
|
||||
|
||||
private func connectivityUpdateHandler(connectivityTypes: [ConnectivityType]) {
|
||||
DispatchQueue.main.async {
|
||||
self.eventSink?(self.statusFrom(connectivityTypes: connectivityTypes))
|
||||
}
|
||||
}
|
||||
|
||||
public func onCancel(withArguments _: Any?) -> FlutterError? {
|
||||
connectivityProvider.stop()
|
||||
eventSink = nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'connectivity_plus'
|
||||
s.version = '0.0.1'
|
||||
s.summary = 'Flutter Connectivity'
|
||||
s.description = <<-DESC
|
||||
This plugin allows Flutter apps to discover network connectivity and configure themselves accordingly.
|
||||
Downloaded by pub (not CocoaPods).
|
||||
DESC
|
||||
s.homepage = 'https://plus.fluttercommunity.dev/'
|
||||
s.license = { :type => 'BSD', :file => '../LICENSE' }
|
||||
s.author = { 'Flutter Community Team' => 'authors@fluttercommunity.dev' }
|
||||
s.source = { :http => 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/connectivity_plus' }
|
||||
s.documentation_url = 'https://pub.dev/packages/connectivity_plus'
|
||||
s.source_files = [
|
||||
'Classes/**/*'
|
||||
]
|
||||
s.public_header_files = [
|
||||
'Classes/**/*.h'
|
||||
]
|
||||
s.ios.dependency 'Flutter'
|
||||
s.osx.dependency 'FlutterMacOS'
|
||||
s.ios.deployment_target = '12.0'
|
||||
s.osx.deployment_target = '10.14'
|
||||
s.swift_version = '5.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
s.ios.resource_bundles = {'connectivity_plus_privacy' => ['PrivacyInfo.xcprivacy']}
|
||||
end
|
||||
Reference in New Issue
Block a user