Implement time-range filter
Some checks failed
Build Docker and Deploy / Build Docker Container (push) Successful in 49s
Build Docker and Deploy / Run Unit-Tests (push) Failing after 11m28s
Build Docker and Deploy / Deploy to Server (push) Has been skipped

This commit is contained in:
Mike Schwörer 2025-05-11 16:32:55 +02:00
parent 255fc9337c
commit 84ac1e53b6
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
5 changed files with 31 additions and 52 deletions

View File

@ -299,8 +299,8 @@ class APIClient {
if (filter?.channelIDs != null) 'channel_id': filter!.channelIDs!,
if (filter?.senderNames != null) 'sender': filter!.senderNames!,
if (filter?.hasSenderName != null) 'has_sender': [filter!.hasSenderName!.toString()],
if (filter?.timeBefore != null) 'before': [filter!.timeBefore!.toIso8601String()],
if (filter?.timeAfter != null) 'after': [filter!.timeAfter!.toIso8601String()],
if (filter?.timeBefore != null) 'before': [filter!.timeBefore!.toUtc().toIso8601String()],
if (filter?.timeAfter != null) 'after': [filter!.timeAfter!.toUtc().toIso8601String()],
if (filter?.priority != null) 'priority': filter!.priority!.map((p) => p.toString()).toList(),
if (filter?.usedKeys != null) 'used_key': filter!.usedKeys!,
if (filter?.senderUserID != null) 'sender_user_id': filter!.senderUserID!,

View File

@ -1,12 +1,16 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_channel.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_keytoken.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_priority.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_searchplain.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_sendername.dart';
import 'package:simplecloudnotifier/components/modals/filter_modal_time.dart';
import 'package:simplecloudnotifier/pages/message_list/message_filter_chiplet.dart';
import 'package:simplecloudnotifier/state/app_bar_state.dart';
import 'package:simplecloudnotifier/state/app_events.dart';
import 'package:simplecloudnotifier/state/app_settings.dart';
import 'package:simplecloudnotifier/utils/navi.dart';
class AppBarFilterDialog extends StatefulWidget {
@ -116,7 +120,21 @@ class _AppBarFilterDialogState extends State<AppBarFilterDialog> {
}
void _showTimeModal(BuildContext context) {
showDialog<void>(context: context, builder: (BuildContext context) => FilterModalTime());
final dateFormat = AppSettings().dateFormat.dateOnlyFormat();
final now = DateTime.now();
showDateRangePicker(context: context, firstDate: DateTime(2000), lastDate: DateTime(now.year, now.month, now.day + 7)).then((value) {
if (value != null) {
List<MessageFilterChiplet> chiplets = [];
chiplets.add(MessageFilterChiplet(
label: dateFormat.format(value.start) + ' - ' + dateFormat.format(value.end),
value: value,
type: MessageFilterChipletType.timeRange,
));
AppEvents().notifyFilterListeners([MessageFilterChipletType.plainSearch], chiplets);
}
});
}
void _showPlainSearchModal(BuildContext context) {

View File

@ -1,44 +0,0 @@
import 'package:flutter/material.dart';
import 'package:simplecloudnotifier/utils/navi.dart';
class FilterModalTime extends StatefulWidget {
@override
_FilterModalTimeState createState() => _FilterModalTimeState();
}
class _FilterModalTimeState extends State<FilterModalTime> {
DateTime? _tsBefore = null;
DateTime? _tsAfter = null;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Timerange'),
content: Container(
width: 9000,
height: 9000,
child: Placeholder(),
),
actions: <Widget>[
TextButton(
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
child: const Text('Apply'),
onPressed: () {
onOkay();
},
),
],
);
}
void onOkay() {
Navi.popDialog(context);
//TODO
}
}

View File

@ -81,9 +81,9 @@ class _DebugRequestViewPageState extends State<DebugRequestViewPage> {
UI.buttonIconOnly(
iconSize: 14,
onPressed: () {
Clipboard.setData(new ClipboardData(text: title));
Clipboard.setData(new ClipboardData(text: value));
Toaster.info("Clipboard", 'Copied text to Clipboard');
print('================= [CLIPBOARD] =================\n${title}\n================= [/CLIPBOARD] =================');
print('================= [CLIPBOARD] =================\n${value}\n================= [/CLIPBOARD] =================');
},
icon: FontAwesomeIcons.copy,
),

View File

@ -340,9 +340,14 @@ class _MessageListPageState extends State<MessageListPage> with RouteAware {
var chipletsTimeRange = _filterChiplets.where((p) => p.type == MessageFilterChipletType.timeRange).toList();
if (chipletsTimeRange.isNotEmpty) {
//TODO
//filter.timeAfter = chipletsTimeRange[0].value1 as DateTime;
//filter.timeBefore = chipletsTimeRange[0].value2 as DateTime;
var t0 = (chipletsTimeRange[0].value as DateTimeRange).start.toLocal();
var t1 = (chipletsTimeRange[0].value as DateTimeRange).end.toLocal();
t0 = DateTime(t0.year, t0.month, t0.day, 0, 0, 0, 0);
t1 = DateTime(t1.year, t1.month, t1.day, 23, 59, 59, 999);
filter.timeAfter = t0;
filter.timeBefore = t1;
}
return filter;