adguard-home-manager/lib/providers/logs_provider.dart

133 lines
2.5 KiB
Dart
Raw Normal View History

2023-02-04 14:56:57 +01:00
import 'package:adguard_home_manager/models/clients.dart';
2022-10-02 03:58:02 +02:00
import 'package:flutter/material.dart';
2022-10-09 18:47:34 +02:00
import 'package:adguard_home_manager/models/applied_filters.dart';
import 'package:adguard_home_manager/models/logs.dart';
2022-10-02 03:58:02 +02:00
class LogsProvider with ChangeNotifier {
int _loadStatus = 0;
LogsData? _logsData;
2023-02-04 14:56:57 +01:00
List<AutoClient>? _clients;
int _clientsLoadStatus = 0;
2022-10-02 03:58:02 +02:00
DateTime? _logsOlderThan;
2022-10-02 05:32:24 +02:00
String _selectedResultStatus = 'all';
2023-02-18 14:52:10 +01:00
String? _searchText;
2023-02-04 14:56:57 +01:00
List<String>? _selectedClients;
2022-10-02 03:58:02 +02:00
int _logsQuantity = 100;
int _offset = 0;
2022-10-09 18:47:34 +02:00
AppliedFiters _appliedFilters = AppliedFiters(
selectedResultStatus: 'all',
2023-02-18 14:52:10 +01:00
searchText: null,
2023-02-04 14:56:57 +01:00
clients: null
2022-10-09 18:47:34 +02:00
);
2022-10-02 03:58:02 +02:00
int get loadStatus {
return _loadStatus;
}
LogsData? get logsData {
return _logsData;
}
2023-02-04 14:56:57 +01:00
List<AutoClient>? get clients {
return _clients;
}
2022-10-02 03:58:02 +02:00
DateTime? get logsOlderThan {
return _logsOlderThan;
}
2022-10-02 05:32:24 +02:00
String get selectedResultStatus {
return _selectedResultStatus;
}
2022-10-02 13:55:41 +02:00
2023-02-18 14:52:10 +01:00
String? get searchText {
return _searchText;
2022-10-02 13:55:41 +02:00
}
2022-10-02 03:58:02 +02:00
int get logsQuantity {
return _logsQuantity;
}
int get offset {
return _offset;
}
2023-02-04 14:56:57 +01:00
List<String>? get selectedClients {
return _selectedClients;
}
int get clientsLoadStatus {
return _clientsLoadStatus;
}
2022-10-09 18:47:34 +02:00
AppliedFiters get appliedFilters {
return _appliedFilters;
}
2022-10-02 05:32:24 +02:00
2022-10-02 03:58:02 +02:00
void setLoadStatus(int value) {
_loadStatus = value;
notifyListeners();
}
void setLogsData(LogsData data) {
_logsData = data;
notifyListeners();
}
2023-02-04 14:56:57 +01:00
void setClients(List<AutoClient> clients) {
_clients = clients;
notifyListeners();
}
void setClientsLoadStatus(int status) {
_clientsLoadStatus = status;
notifyListeners();
}
2022-10-02 03:58:02 +02:00
void setLogsOlderThan(DateTime? value) {
_logsOlderThan = value;
notifyListeners();
}
void resetFilters() {
_logsOlderThan = null;
_offset = 0;
2022-10-02 05:32:24 +02:00
_selectedResultStatus = 'all';
2023-02-18 14:52:10 +01:00
_searchText = null;
2022-10-02 03:58:02 +02:00
notifyListeners();
}
void setLogsQuantity(int value) {
_logsQuantity = value;
notifyListeners();
}
void setOffset(int value) {
_offset = value;
}
2022-10-02 05:32:24 +02:00
void setSelectedResultStatus(String value) {
_selectedResultStatus = value;
notifyListeners();
}
2022-10-09 18:47:34 +02:00
2023-02-18 14:52:10 +01:00
void setSearchText(String? value) {
_searchText = value;
2022-10-02 13:55:41 +02:00
notifyListeners();
}
2022-10-09 18:47:34 +02:00
2023-02-04 14:56:57 +01:00
void setSelectedClients(List<String>? clients) {
_selectedClients = clients;
notifyListeners();
}
2022-10-09 18:47:34 +02:00
void setAppliedFilters(AppliedFiters value) {
_appliedFilters = value;
notifyListeners();
}
2022-10-02 03:58:02 +02:00
}