mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fix pugs
This commit is contained in:
@ -107,26 +107,28 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
||||
emit(AccessLoaded());
|
||||
try {
|
||||
// Convert search text to lower case for case-insensitive search
|
||||
final searchText = event.passwordName?.toLowerCase() ?? '';
|
||||
|
||||
filteredData = data.where((item) {
|
||||
bool matchesCriteria = true;
|
||||
|
||||
// Convert timestamp to DateTime and extract date component
|
||||
DateTime effectiveDate =
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.effectiveTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.effectiveTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime invalidDate =
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.invalidTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(int.parse(item.invalidTime.toString()) * 1000)
|
||||
.toUtc()
|
||||
.toLocal();
|
||||
DateTime effectiveDateOnly =
|
||||
DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day);
|
||||
DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day);
|
||||
DateTime invalidDateOnly = DateTime(invalidDate.year, invalidDate.month, invalidDate.day);
|
||||
|
||||
// Filter by password name
|
||||
if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
||||
final bool matchesName =
|
||||
item.passwordName != null && item.passwordName.contains(event.passwordName);
|
||||
// Filter by password name, making the search case-insensitive
|
||||
if (searchText.isNotEmpty) {
|
||||
final bool matchesName = item.passwordName.toString().toLowerCase().contains(searchText);
|
||||
if (!matchesName) {
|
||||
matchesCriteria = false;
|
||||
}
|
||||
@ -135,7 +137,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by start date only
|
||||
if (event.startTime != null && event.endTime == null) {
|
||||
DateTime startDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
|
||||
if (effectiveDateOnly.isBefore(startDateOnly)) {
|
||||
matchesCriteria = false;
|
||||
@ -145,7 +147,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by end date only
|
||||
if (event.endTime != null && event.startTime == null) {
|
||||
DateTime endDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
|
||||
if (invalidDateOnly.isAfter(endDateOnly)) {
|
||||
matchesCriteria = false;
|
||||
@ -155,9 +157,9 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
// Filter by both start date and end date
|
||||
if (event.startTime != null && event.endTime != null) {
|
||||
DateTime startDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
|
||||
DateTime endDateOnly =
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
|
||||
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
|
||||
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
|
||||
if (effectiveDateOnly.isBefore(startDateOnly) || invalidDateOnly.isAfter(endDateOnly)) {
|
||||
@ -183,6 +185,8 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resetSearch(ResetSearch event, Emitter<AccessState> emit) async {
|
||||
emit(AccessLoaded());
|
||||
startTime = 'Start Time';
|
||||
|
@ -30,7 +30,7 @@ class PasswordModel {
|
||||
effectiveTime: json['effectiveTime'],
|
||||
passwordCreated: json['passwordCreated'],
|
||||
createdTime: json['createdTime'],
|
||||
passwordName: json['passwordName'] ?? 'No name', // New field
|
||||
passwordName: json['passwordName']??'No Name',
|
||||
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
|
||||
passwordType: AccessTypeExtension.fromString(json['passwordType']),
|
||||
deviceUuid: json['deviceUuid'],
|
||||
|
@ -92,6 +92,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
const SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: DynamicTable(
|
||||
tableName:'AccessManagement',
|
||||
withSelectAll: false,
|
||||
isEmpty: filteredData.isEmpty,
|
||||
withCheckBox: false,
|
||||
@ -108,7 +109,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
],
|
||||
data: filteredData.map((item) {
|
||||
return [
|
||||
item.passwordName.toString(),
|
||||
item.passwordName,
|
||||
item.passwordType.value,
|
||||
('${accessBloc.timestampToDate(item.effectiveTime)} - ${accessBloc.timestampToDate(item.invalidTime)}'),
|
||||
item.deviceUuid.toString(),
|
||||
|
@ -49,9 +49,13 @@ class UpdateTimerEvent extends AuthEvent {
|
||||
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
|
||||
}
|
||||
|
||||
class ChangePasswordEvent extends AuthEvent {}
|
||||
class ChangePasswordEvent extends AuthEvent {
|
||||
|
||||
class SendOtpEvent extends AuthEvent {}
|
||||
}
|
||||
|
||||
class SendOtpEvent extends AuthEvent {
|
||||
|
||||
}
|
||||
|
||||
class PasswordVisibleEvent extends AuthEvent {
|
||||
final bool? newValue;
|
||||
|
@ -5,6 +5,7 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class DynamicTable extends StatefulWidget {
|
||||
final List<String> headers;
|
||||
final String? tableName;
|
||||
final List<List<dynamic>> data;
|
||||
final BoxDecoration? headerDecoration;
|
||||
final BoxDecoration? cellDecoration;
|
||||
@ -20,6 +21,7 @@ class DynamicTable extends StatefulWidget {
|
||||
required this.headers,
|
||||
required this.data,
|
||||
required this.size,
|
||||
this.tableName,
|
||||
required this.isEmpty,
|
||||
required this.withCheckBox,
|
||||
required this.withSelectAll,
|
||||
@ -106,7 +108,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
height: 15,
|
||||
),
|
||||
Text(
|
||||
'No Devices',
|
||||
// no password
|
||||
widget.tableName=='AccessManagement'? 'No Password ' : 'No Devices',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
|
@ -219,8 +219,8 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
||||
scheduleList: [
|
||||
if (repeat)
|
||||
Schedule(
|
||||
effectiveTime: getTimeFromDateTimeString(expirationTime),
|
||||
invalidTime: getTimeFromDateTimeString(effectiveTime).toString(),
|
||||
effectiveTime: getTimeFromDateTimeString(effectiveTime),
|
||||
invalidTime: getTimeFromDateTimeString(expirationTime).toString(),
|
||||
workingDay: selectedDays,
|
||||
),
|
||||
],
|
||||
@ -448,6 +448,7 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
||||
<Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
child: const Text('OK'),
|
||||
|
@ -87,7 +87,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
],
|
||||
))
|
||||
.then((v) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(true);
|
||||
|
||||
});
|
||||
} else if (state is FailedState) {
|
||||
visitorBloc.stateDialog(
|
||||
@ -379,11 +380,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
endTime: () {
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(
|
||||
SelectTimeEvent(context: context, isEffective: false));
|
||||
visitorBloc.add(SelectTimeEvent(context: context, isEffective: false));
|
||||
} else {
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context, isStart: false, isRepeat: false));
|
||||
visitorBloc.add(SelectTimeVisitorPassword(context: context, isStart: false, isRepeat: false));
|
||||
}
|
||||
},
|
||||
startTime: () {
|
||||
@ -397,13 +396,11 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
firstString: (visitorBloc.usageFrequencySelected ==
|
||||
'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
'Periodic' && visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
? visitorBloc.effectiveTime
|
||||
: visitorBloc.startTimeAccess.toString(),
|
||||
secondString: (visitorBloc.usageFrequencySelected ==
|
||||
'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
'Periodic' && visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
? visitorBloc.expirationTime
|
||||
: visitorBloc.endTimeAccess.toString(),
|
||||
icon: Assets.calendarIcon),
|
||||
@ -529,7 +526,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
} else if (visitorBloc.accessTypeSelected == 'Dynamic Password') {
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
} else {
|
||||
} else if(visitorBloc.endTimeAccess.toString()!='End Time'&&visitorBloc.startTimeAccess.toString()!='Start Time') {
|
||||
if (visitorBloc.effectiveTimeTimeStamp != null &&
|
||||
visitorBloc.expirationTimeTimeStamp != null) {
|
||||
if (isRepeat == true) {
|
||||
@ -553,6 +550,11 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
message: 'Please select Access Period to continue',
|
||||
title: 'Access Period');
|
||||
}
|
||||
}else{
|
||||
visitorBloc.stateDialog(
|
||||
context: context,
|
||||
message: 'Please select Access Period to continue',
|
||||
title: 'Access Period');
|
||||
}
|
||||
} else {
|
||||
visitorBloc.stateDialog(
|
||||
|
Reference in New Issue
Block a user