mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
fix bugs
This commit is contained in:
@ -38,8 +38,9 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
emit(FailedState(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void updateTabsCount() {
|
||||
int toBeEffectiveCount = data.where((item) => item.passwordStatus.value== 'To Be Effective').length;
|
||||
int toBeEffectiveCount = data.where((item) => item.passwordStatus.value== 'To be effective').length;
|
||||
int effectiveCount = data.where((item) => item.passwordStatus.value == 'Effective').length;
|
||||
int expiredCount = data.where((item) => item.passwordStatus.value == 'Expired').length;
|
||||
tabs[1] = 'To Be Effective ($toBeEffectiveCount)';
|
||||
@ -48,7 +49,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
int selectedIndex = 0;
|
||||
final List<String> tabs = [
|
||||
'All',
|
||||
@ -73,7 +73,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
|
||||
Future<void> selectTime(SelectTime event, Emitter<AccessState> emit) async {
|
||||
emit(AccessLoaded());
|
||||
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: event.context,
|
||||
initialDate: DateTime.now(),
|
||||
@ -81,7 +80,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (picked != null) {
|
||||
|
||||
final selectedDateTime = DateTime(
|
||||
picked.year,
|
||||
picked.month,
|
||||
@ -110,7 +108,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
expirationTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
emit(ChangeTimeState());
|
||||
}
|
||||
@ -165,7 +162,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
}
|
||||
|
||||
// Filter by selected tab index
|
||||
if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') {
|
||||
if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To be effective') {
|
||||
matchesCriteria = false;
|
||||
} else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') {
|
||||
matchesCriteria = false;
|
||||
@ -183,110 +180,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
}
|
||||
|
||||
|
||||
// Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
||||
// emit(AccessLoaded());
|
||||
// try {
|
||||
// filteredData = data.where((item) {
|
||||
// bool matchesCriteria = true;
|
||||
//
|
||||
// // Filter by password name
|
||||
// if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
||||
// final bool matchesName = item.passwordName != null &&
|
||||
// item.passwordName.contains(event.passwordName);
|
||||
// if (!matchesName) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Filter by start time only
|
||||
// if (event.startTime != null && event.endTime == null) {
|
||||
// final int? effectiveTime = int.tryParse(item.effectiveTime.toString());
|
||||
// if (effectiveTime == null || effectiveTime < event.startTime!) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Filter by end time only
|
||||
// if (event.endTime != null && event.startTime == null) {
|
||||
// final int? invalidTime = int.tryParse(item.invalidTime.toString());
|
||||
// if (invalidTime == null || invalidTime > event.endTime!) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Filter by both start time and end time
|
||||
// if (event.startTime != null && event.endTime != null) {
|
||||
// final int? effectiveTime = int.tryParse(item.effectiveTime.toString());
|
||||
// final int? invalidTime = int.tryParse(item.invalidTime.toString());
|
||||
// if (effectiveTime == null || invalidTime == null) {
|
||||
// matchesCriteria = false;
|
||||
// } else {
|
||||
// final bool matchesStartTime = effectiveTime >= event.startTime!;
|
||||
// final bool matchesEndTime = invalidTime <= event.endTime!;
|
||||
// if (!matchesStartTime || !matchesEndTime) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Filter by selected tab index
|
||||
// if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') {
|
||||
// matchesCriteria = false;
|
||||
// } else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') {
|
||||
// matchesCriteria = false;
|
||||
// } else if (event.selectedTabIndex == 3 && item.passwordStatus.value != 'Expired') {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
//
|
||||
// return matchesCriteria;
|
||||
// }).toList();
|
||||
//
|
||||
// emit(TableLoaded(filteredData));
|
||||
// } catch (e) {
|
||||
// emit(FailedState(e.toString()));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
||||
// emit(AccessLoaded());
|
||||
// try {
|
||||
// filteredData = data.where((item) {
|
||||
// bool matchesCriteria = true;
|
||||
// if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
||||
// final bool matchesName = item.passwordName != null &&
|
||||
// item.passwordName.contains(event.passwordName);
|
||||
// if (!matchesName) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
// if (event.startTime != null || event.endTime != null) {
|
||||
// final int? effectiveTime = int.tryParse(item.effectiveTime.toString());
|
||||
// final int? invalidTime = int.tryParse(item.invalidTime.toString());
|
||||
// if (effectiveTime == null || invalidTime == null) {
|
||||
// matchesCriteria = false;
|
||||
// } else {
|
||||
// final bool matchesStartTime = effectiveTime >= event.startTime!;
|
||||
// final bool matchesEndTime = invalidTime <= event.endTime!;
|
||||
// if (!matchesStartTime || !matchesEndTime) {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (event.selectedTabIndex == 1 && item.passwordStatus.value != 'To Be Effective') {
|
||||
// matchesCriteria = false;
|
||||
// } else if (event.selectedTabIndex == 2 && item.passwordStatus.value != 'Effective') {
|
||||
// matchesCriteria = false;
|
||||
// } else if (event.selectedTabIndex == 3 && item.passwordStatus.value != 'Expired') {
|
||||
// matchesCriteria = false;
|
||||
// }
|
||||
// return matchesCriteria;
|
||||
// }).toList();
|
||||
// emit(TableLoaded(filteredData));
|
||||
// } catch (e) {
|
||||
// emit(FailedState(e.toString()));
|
||||
// }
|
||||
// }
|
||||
|
||||
resetSearch(ResetSearch event, Emitter<AccessState> emit) async{
|
||||
emit(AccessLoaded());
|
||||
|
@ -133,7 +133,6 @@ class AccessManagementPage extends StatelessWidget {
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height:45,
|
||||
|
||||
width: size.width * 0.06,
|
||||
child:Container(
|
||||
@ -153,7 +152,6 @@ class AccessManagementPage extends StatelessWidget {
|
||||
width: 10,
|
||||
),
|
||||
SizedBox(
|
||||
height:45,
|
||||
width: size.width * 0.06,
|
||||
child: Container(
|
||||
decoration: containerDecoration,
|
||||
@ -237,6 +235,7 @@ class AccessManagementPage extends StatelessWidget {
|
||||
'Access Status'
|
||||
],
|
||||
data: filteredData.map((item) {
|
||||
|
||||
return [
|
||||
item.passwordName.toString(),
|
||||
item.passwordType.value,
|
||||
@ -244,7 +243,7 @@ class AccessManagementPage extends StatelessWidget {
|
||||
item.deviceUuid.toString(),
|
||||
'',
|
||||
'',
|
||||
item.passwordStatus.value
|
||||
item.passwordStatus.value,
|
||||
];
|
||||
}).toList(),
|
||||
)
|
||||
|
@ -14,7 +14,6 @@ class DynamicTable extends StatefulWidget {
|
||||
final void Function(bool?)? selectAll;
|
||||
final void Function(int, bool?)? onRowCheckboxChanged;
|
||||
final List<String>? initialSelectedIds;
|
||||
|
||||
const DynamicTable({
|
||||
super.key,
|
||||
required this.headers,
|
||||
@ -199,6 +198,20 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
}
|
||||
|
||||
Widget _buildTableCell(String content,size) {
|
||||
Color? statusColor;
|
||||
switch (content) {
|
||||
case 'Effective':
|
||||
statusColor = ColorsManager.textGreen;
|
||||
break;
|
||||
case 'Expired':
|
||||
statusColor = ColorsManager.red;
|
||||
break;
|
||||
case 'To be effective':
|
||||
statusColor = ColorsManager.yaGreen;
|
||||
break;
|
||||
default:
|
||||
statusColor = Colors.black; // Default color
|
||||
}
|
||||
return Expanded(
|
||||
child: Container(
|
||||
height:size ,
|
||||
@ -213,7 +226,11 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
content,
|
||||
style: const TextStyle(color: Colors.black, fontSize: 10,fontWeight: FontWeight.w400),
|
||||
style: TextStyle(
|
||||
color:statusColor, // Use the passed color or default to black
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w400
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -73,7 +73,7 @@ class CustomWebTextField extends StatelessWidget {
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(
|
||||
errorStyle: const TextStyle(height: 0), // Hide the error text space
|
||||
hintStyle: TextStyle(color: ColorsManager.grayColor),
|
||||
hintStyle: const TextStyle(color: ColorsManager.grayColor),
|
||||
hintText: 'Please enter'),
|
||||
),
|
||||
),
|
||||
|
@ -461,7 +461,7 @@ class VisitorPasswordBloc
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> stateDialog({
|
||||
Future stateDialog({
|
||||
BuildContext? context,
|
||||
String? message,
|
||||
String? title,
|
||||
@ -469,6 +469,7 @@ class VisitorPasswordBloc
|
||||
Widget? widgeta,
|
||||
}) {
|
||||
return showCustomDialog(
|
||||
barrierDismissible: false,
|
||||
context: context!,
|
||||
message: message!,
|
||||
iconPath: Assets.deviceNoteIcon,
|
||||
@ -479,7 +480,7 @@ class VisitorPasswordBloc
|
||||
<Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
child: const Text('OK'),
|
||||
),
|
||||
@ -487,30 +488,5 @@ class VisitorPasswordBloc
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Future<void> stateAndDeviseDialog({
|
||||
// BuildContext? context,
|
||||
// String? message,
|
||||
// String? title,
|
||||
// dynamic actions,
|
||||
// }) {
|
||||
// return showCustomDialog(
|
||||
// context: context!,
|
||||
// message: message!,
|
||||
// iconPath: Assets.deviceNoteIcon,
|
||||
// title: title,
|
||||
// dialogHeight: 150,
|
||||
// actions: actions ??
|
||||
// <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: const Text('OK'),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
).then((v){
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else if (state is FailedState) {
|
||||
visitorBloc.stateDialog(
|
||||
context: context,
|
||||
@ -423,7 +425,6 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
@ -485,8 +486,14 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
onPressed: () {
|
||||
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||
if(visitorBloc.selectedDevices.isNotEmpty){
|
||||
|
||||
if(visitorBloc.usageFrequencySelected == 'One-Time' && visitorBloc.accessTypeSelected == 'Offline Password'){
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
}
|
||||
else if(visitorBloc.accessTypeSelected == 'Dynamic Password'){
|
||||
print('objectobjectobjectobject');
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
|
||||
}else{
|
||||
if(visitorBloc.effectiveTimeTimeStamp!=null&&visitorBloc.expirationTimeTimeStamp!=null) {
|
||||
if(isRepeat==true){
|
||||
@ -668,37 +675,45 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
borderRadius: 8,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
} else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
if(visitorBloc.accessTypeSelected == 'Dynamic Password'){
|
||||
|
||||
}else{
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password') {
|
||||
visitorBloc.add(OnlineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineOneTimePasswordEvent(
|
||||
context: context,
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
));
|
||||
}
|
||||
else if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
visitorBloc.add(OfflineMultipleTimePasswordEvent(
|
||||
passwordName: visitorBloc.userNameController.text,
|
||||
email: visitorBloc.emailController.text,
|
||||
effectiveTime: visitorBloc.effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: visitorBloc.expirationTimeTimeStamp.toString(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
child: Text(
|
||||
'Ok',
|
||||
|
@ -36,5 +36,7 @@ abstract class ColorsManager {
|
||||
static const Color blue2 = Color(0xFF0026A2);
|
||||
static const Color blue3 = Color(0xFF00165E);
|
||||
static const Color blue4 = Color(0xFF001E7E);
|
||||
static const Color textGreen = Color(0xFF008905);
|
||||
static const Color yaGreen = Color(0xFFFFBF44);
|
||||
}
|
||||
//0036E6
|
Reference in New Issue
Block a user