mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +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(),
|
||||
)
|
||||
|
Reference in New Issue
Block a user