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