mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
tap filter
This commit is contained in:
23
assets/images/empty_table.svg
Normal file
23
assets/images/empty_table.svg
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<svg width="100" height="88" viewBox="0 0 100 88" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g opacity="0.7">
|
||||||
|
<path d="M99.9982 31V87.5508H23.9567C22.6831 87.5508 21.6528 86.5186 21.6528 85.2469V23.2094C21.6528 21.9358 22.6831 20.9055 23.9567 20.9055H51.8961C52.5057 20.9055 53.0912 21.1469 53.5238 21.5795L59.9664 28.0221C60.399 28.4547 60.9845 28.6961 61.596 28.6961H97.6943C98.966 28.6963 99.9982 29.7285 99.9982 31Z" fill="#756F6F"/>
|
||||||
|
<path d="M63.2924 39.9286C66.3941 39.9286 68.9086 37.4142 68.9086 34.3124C68.9086 31.2107 66.3941 28.6963 63.2924 28.6963C60.1907 28.6963 57.6763 31.2107 57.6763 34.3124C57.6763 37.4142 60.1907 39.9286 63.2924 39.9286Z" fill="#5B5555"/>
|
||||||
|
<path d="M42.6767 47.5693C43.6907 48.5814 42.9745 50.3158 41.54 50.3158H23.8057C23.0794 50.3158 22.361 50.2795 21.6528 50.2111V23.2094C21.6528 21.9358 22.6831 20.9055 23.9567 20.9055H43.9786C44.9122 23.3219 45.4253 25.9498 45.4253 28.6963C45.4253 34.6661 43.0048 40.0704 39.0933 43.9838L42.6767 47.5693Z" fill="#5B5555"/>
|
||||||
|
<path d="M99.9997 31.0001V87.551H92.3498V31.0001C92.3498 29.7284 91.3195 28.6962 90.0459 28.6962H97.6956C98.9675 28.6964 99.9997 29.7286 99.9997 31.0001Z" fill="#5B5555"/>
|
||||||
|
<path d="M76.5031 58.662L99.9992 87.5516H22.7485C22.0552 87.5516 21.3989 87.2393 20.9614 86.7014L0.520807 61.5688C-0.7034 60.0636 0.367684 57.8118 2.3079 57.8118H74.7158C75.4094 57.8118 76.0658 58.1241 76.5031 58.662Z" fill="#64B9FC"/>
|
||||||
|
<path d="M99.9988 87.5508H90.0915L66.5968 58.6618C66.1581 58.1245 65.5022 57.8107 64.8101 57.8107H74.7154C75.4096 57.8107 76.0654 58.1245 76.5021 58.6618L99.9988 87.5508Z" fill="#31A7FB"/>
|
||||||
|
<path d="M82.504 80.7751H62.1786C61.5502 80.7751 60.9581 80.4815 60.5774 79.9815L55.3685 73.1373C54.8644 72.475 55.3368 71.522 56.169 71.522H76.4944C77.1228 71.522 77.7149 71.8156 78.0956 72.3156L83.3045 79.1599C83.8086 79.822 83.3364 80.7751 82.504 80.7751Z" fill="#F8F3F1"/>
|
||||||
|
<path d="M82.5047 80.7746H75.9655C76.7985 80.7746 77.2713 79.8229 76.7663 79.159L71.5571 72.3161C71.1768 71.8151 70.5852 71.5214 69.9575 71.5214H76.4948C77.1244 71.5214 77.716 71.8151 78.0963 72.3161L83.3054 79.159C83.8084 79.823 83.3377 80.7746 82.5047 80.7746Z" fill="#EFE2DD"/>
|
||||||
|
<path d="M49.999 82.2837H40.7663C39.9329 82.2837 39.2573 81.6081 39.2573 80.7748C39.2573 79.9414 39.9329 79.2658 40.7663 79.2658H49.999C50.8324 79.2658 51.508 79.9414 51.508 80.7748C51.508 81.6081 50.8324 82.2837 49.999 82.2837Z" fill="#F8F3F1"/>
|
||||||
|
<path d="M46.6315 77.2784H42.7126C41.8792 77.2784 41.2036 76.6029 41.2036 75.7695C41.2036 74.9361 41.8792 74.2605 42.7126 74.2605H46.6315C47.4649 74.2605 48.1405 74.9361 48.1405 75.7695C48.1407 76.6029 47.4651 77.2784 46.6315 77.2784Z" fill="#F8F3F1"/>
|
||||||
|
<path d="M45.4271 21.6202C45.4271 9.68008 35.7477 0.000671387 23.8077 0.000671387C11.8787 0.000671387 2.18799 9.69141 2.18799 21.6204C2.18818 33.5605 11.8674 43.2397 23.8075 43.2397H41.5417C42.9755 43.2397 43.6937 41.5062 42.6798 40.4923L39.0949 36.9074C43.0074 32.9953 45.4271 27.5903 45.4271 21.6202Z" fill="#31A7FB"/>
|
||||||
|
<path d="M42.6806 40.4929C43.6946 41.507 42.9784 43.2394 41.5438 43.2394H34.2521C35.6847 43.2394 36.4031 41.507 35.3888 40.4929L33.1658 38.2687C32.4264 37.5289 32.3795 36.348 33.0537 35.5482C36.2251 31.7865 38.1372 26.9256 38.1372 21.6198C38.1372 10.9238 30.3688 2.04051 20.1655 0.308107C21.1528 0.138772 22.1626 0.0379915 23.1901 0.00889019C35.2808 -0.331732 45.2247 9.15764 45.4258 21.2515C45.5276 27.3669 43.0886 32.9154 39.097 36.9072L42.6806 40.4929Z" fill="#1C96F9"/>
|
||||||
|
<path d="M28.074 21.6202L32.0957 17.5986C33.2744 16.4199 33.2744 14.509 32.0957 13.3304C30.9172 12.1517 29.0061 12.1517 27.8276 13.3304L23.8059 17.3521L19.7845 13.3303C18.606 12.1516 16.6949 12.1516 15.5163 13.3303C14.3376 14.5088 14.3376 16.4197 15.5163 17.5984L19.538 21.62L15.5163 25.6417C14.3376 26.8204 14.3376 28.7313 15.5163 29.9098C16.1056 30.4992 16.8781 30.7938 17.6505 30.7938C18.423 30.7938 19.1952 30.4991 19.7847 29.9098L23.8063 25.8882L27.828 29.9098C28.4174 30.4992 29.1895 30.7938 29.9621 30.7938C30.7344 30.7938 31.5068 30.4991 32.0963 29.9098C33.275 28.7313 33.275 26.8204 32.0963 25.6417L28.074 21.6202Z" fill="#F8F3F1"/>
|
||||||
|
<path d="M63.2939 35.1746C66.3956 35.1746 68.9101 32.6601 68.9101 29.5584C68.9101 26.4567 66.3956 23.9423 63.2939 23.9423C60.1922 23.9423 57.6777 26.4567 57.6777 29.5584C57.6777 32.6601 60.1922 35.1746 63.2939 35.1746Z" fill="#BCEA73"/>
|
||||||
|
<path d="M68.9087 29.5576C68.9087 32.6605 66.3935 35.1758 63.2931 35.1758C62.2537 35.1758 61.2785 34.8933 60.4443 34.398C62.649 33.8898 64.2916 31.9162 64.2916 29.5576C64.2916 27.2016 62.6515 25.2255 60.4469 24.7173C61.281 24.2245 62.2537 23.9423 63.2931 23.9423C66.3937 23.9421 68.9087 26.4573 68.9087 29.5576Z" fill="#99D53B"/>
|
||||||
|
<path d="M82.9628 22.8247C85.4105 22.8247 87.3947 20.8404 87.3947 18.3927C87.3947 15.945 85.4105 13.9607 82.9628 13.9607C80.515 13.9607 78.5308 15.945 78.5308 18.3927C78.5308 20.8404 80.515 22.8247 82.9628 22.8247Z" fill="#BCEA73"/>
|
||||||
|
<path d="M87.3925 18.3923C87.3925 20.8409 85.4078 22.8257 82.9611 22.8257C82.1408 22.8257 81.3713 22.6028 80.7129 22.212C82.4527 21.811 83.7488 20.2534 83.7488 18.3923C83.7488 16.5329 82.4547 14.9736 80.7148 14.5724C81.373 14.1835 82.1406 13.9607 82.9609 13.9607C85.4078 13.9607 87.3925 15.9456 87.3925 18.3923Z" fill="#99D53B"/>
|
||||||
|
<path d="M72.8344 10.292L73.6508 9.4756C74.2403 8.88615 74.2403 7.93089 73.6508 7.34144C73.0616 6.75219 72.1061 6.75219 71.5167 7.34144L70.7003 8.15784L69.8839 7.34144C69.2946 6.75199 68.3392 6.75199 67.7497 7.34144C67.1603 7.93069 67.1603 8.88615 67.7497 9.4756L68.5661 10.292L67.7497 11.1084C67.1603 11.6978 67.1603 12.6531 67.7497 13.2426C68.0444 13.5373 68.4306 13.6845 68.8167 13.6845C69.2028 13.6845 69.5891 13.5371 69.8837 13.2426L70.7001 12.4262L71.5165 13.2426C71.8112 13.5373 72.1973 13.6845 72.5835 13.6845C72.9696 13.6845 73.3559 13.5371 73.6504 13.2426C74.2399 12.6533 74.2399 11.6978 73.6504 11.1084L72.8344 10.292Z" fill="#64B9FC"/>
|
||||||
|
<path d="M11.2994 44.5503C10.7102 43.961 9.75473 43.961 9.16528 44.5503L7.74381 45.9718L6.32234 44.5503C5.73309 43.961 4.77763 43.961 4.18818 44.5503C3.59873 45.1395 3.59873 46.095 4.18818 46.6844L5.60965 48.1059L4.18818 49.5274C3.59873 50.1166 3.59873 51.0721 4.18818 51.6615C4.4829 51.9563 4.86903 52.1035 5.25516 52.1035C5.64129 52.1035 6.02762 51.9561 6.32214 51.6615L7.74362 50.2401L9.16509 51.6615C9.45981 51.9563 9.84594 52.1035 10.2321 52.1035C10.6182 52.1035 11.0045 51.9561 11.2991 51.6615C11.8885 51.0723 11.8885 50.1168 11.2991 49.5274L9.87758 48.1059L11.2991 46.6844C11.8887 46.095 11.8887 45.1395 11.2994 44.5503Z" fill="#A8E7EF"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 6.4 KiB |
@ -5,23 +5,25 @@ import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
|||||||
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
||||||
import 'package:syncrow_web/services/access_mang_api.dart';
|
import 'package:syncrow_web/services/access_mang_api.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/const.dart';
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
|
||||||
class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||||
AccessBloc() : super((AccessInitial())) {
|
AccessBloc() : super((AccessInitial())) {
|
||||||
on<FetchTableData>(_onFetchTableData);
|
on<FetchTableData>(_onFetchTableData);
|
||||||
on<TabChangedEvent>(selectFilterTap);
|
// on<TabChangedEvent>(selectFilterTap);
|
||||||
on<SelectTime>(selectTime);
|
on<SelectTime>(selectTime);
|
||||||
on<FilterDataEvent>(_filterData);
|
on<FilterDataEvent>(_filterData);
|
||||||
on<ResetSearch>(resetSearch);
|
on<ResetSearch>(resetSearch);
|
||||||
|
on<TabChangedEvent>(onTabChanged);
|
||||||
}
|
}
|
||||||
String startTime = 'Start Time';
|
String startTime = 'Start Date';
|
||||||
String endTime = 'End Time';
|
String endTime = 'End Date';
|
||||||
|
|
||||||
int? effectiveTimeTimeStamp;
|
int? effectiveTimeTimeStamp;
|
||||||
int? expirationTimeTimeStamp;
|
int? expirationTimeTimeStamp;
|
||||||
TextEditingController passwordName= TextEditingController();
|
TextEditingController passwordName= TextEditingController();
|
||||||
List<PasswordModel> filteredData = []; // To store filtered data
|
List<PasswordModel> filteredData = [];
|
||||||
List<PasswordModel> data=[];
|
List<PasswordModel> data=[];
|
||||||
|
|
||||||
Future<void> _onFetchTableData(
|
Future<void> _onFetchTableData(
|
||||||
@ -29,11 +31,26 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
try {
|
try {
|
||||||
emit(AccessLoaded());
|
emit(AccessLoaded());
|
||||||
data = await AccessMangApi().fetchVisitorPassword();
|
data = await AccessMangApi().fetchVisitorPassword();
|
||||||
|
filteredData= data;
|
||||||
|
updateTabsCount();
|
||||||
emit(TableLoaded(data));
|
emit(TableLoaded(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void updateTabsCount() {
|
||||||
|
// Count occurrences based on the type field
|
||||||
|
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;
|
||||||
|
|
||||||
|
// Update tab labels with counts
|
||||||
|
tabs[1] = 'To Be Effective ($toBeEffectiveCount)';
|
||||||
|
tabs[2] = 'Effective ($effectiveCount)';
|
||||||
|
tabs[3] = 'Expired ($expiredCount)';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
|
|
||||||
@ -51,7 +68,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
selectedIndex= event.selectedIndex;
|
selectedIndex= event.selectedIndex;
|
||||||
emit(AccessInitial());
|
emit(AccessInitial());
|
||||||
emit(TableLoaded(data));
|
emit(TableLoaded(data));
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState( e.toString()));
|
emit(FailedState( e.toString()));
|
||||||
return;
|
return;
|
||||||
@ -60,6 +76,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
|
|
||||||
|
|
||||||
Future<void> selectTime(SelectTime event, Emitter<AccessState> emit) async {
|
Future<void> selectTime(SelectTime event, Emitter<AccessState> emit) async {
|
||||||
|
|
||||||
final DateTime? picked = await showDatePicker(
|
final DateTime? picked = await showDatePicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
initialDate: DateTime.now(),
|
initialDate: DateTime.now(),
|
||||||
@ -120,27 +137,27 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit(AccessInitial());
|
emit(ChangeTimeState());
|
||||||
emit(TableLoaded(data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
|
||||||
emit(AccessLoaded());
|
emit(AccessLoaded());
|
||||||
try {
|
try {
|
||||||
// Filter the data based on the provided criteria
|
|
||||||
filteredData = data.where((item) {
|
filteredData = data.where((item) {
|
||||||
bool matchesCriteria = true;
|
bool matchesCriteria = true;
|
||||||
// Check if the password name should be used for filtering
|
|
||||||
|
// Filter by password name if provided
|
||||||
if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
if (event.passwordName != null && event.passwordName!.isNotEmpty) {
|
||||||
final bool matchesName = item.passwodName != null &&
|
final bool matchesName = item.passwordName != null &&
|
||||||
item.passwodName.contains(event.passwordName);
|
item.passwordName.contains(event.passwordName);
|
||||||
if (!matchesName) {
|
if (!matchesName) {
|
||||||
matchesCriteria = false;
|
matchesCriteria = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if the time range should be used for filtering
|
|
||||||
|
// Filter by date range if provided
|
||||||
if (event.startTime != null && event.endTime != null) {
|
if (event.startTime != null && event.endTime != null) {
|
||||||
// Ensure effectiveTime and invalidTime are treated as integers
|
|
||||||
final int? effectiveTime = int.tryParse(item.effectiveTime.toString());
|
final int? effectiveTime = int.tryParse(item.effectiveTime.toString());
|
||||||
final int? invalidTime = int.tryParse(item.invalidTime.toString());
|
final int? invalidTime = int.tryParse(item.invalidTime.toString());
|
||||||
if (effectiveTime == null || invalidTime == null) {
|
if (effectiveTime == null || invalidTime == null) {
|
||||||
@ -153,22 +170,31 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter by tab selection
|
||||||
|
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;
|
return matchesCriteria;
|
||||||
}).toList();
|
}).toList();
|
||||||
print('Filtered data: $filteredData');
|
|
||||||
emit(TableLoaded(filteredData));
|
emit(TableLoaded(filteredData));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error occurred during filtering: $e');
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ResetSearch
|
|
||||||
resetSearch(ResetSearch event, Emitter<AccessState> emit) async{
|
resetSearch(ResetSearch event, Emitter<AccessState> emit) async{
|
||||||
emit(AccessLoaded());
|
emit(AccessLoaded());
|
||||||
startTime = 'Start Time';
|
startTime = 'Start Time';
|
||||||
endTime = 'End Time';
|
endTime = 'End Time';
|
||||||
passwordName.clear();
|
passwordName.clear();
|
||||||
|
selectedIndex=0;
|
||||||
add(FetchTableData());
|
add(FetchTableData());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String timestampToDate(dynamic timestamp) {
|
String timestampToDate(dynamic timestamp) {
|
||||||
@ -176,5 +202,38 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
|||||||
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')}";
|
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onTabChanged(TabChangedEvent event, Emitter<AccessState> emit) async {
|
||||||
|
try {
|
||||||
|
emit(AccessLoaded());
|
||||||
|
selectedIndex = event.selectedIndex;
|
||||||
|
// Apply filtering based on selected tab
|
||||||
|
switch (selectedIndex) {
|
||||||
|
case 0: // All
|
||||||
|
filteredData = data;
|
||||||
|
break;
|
||||||
|
case 1: // To Be Effective
|
||||||
|
filteredData = data.where((item) => item.passwordStatus.value == "To Be Effective").toList();
|
||||||
|
break;
|
||||||
|
case 2: // Effective
|
||||||
|
filteredData = data.where((item) => item.passwordStatus.value == "Effective").toList();
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 3: // Expired
|
||||||
|
filteredData = data.where((item) => item.passwordStatus.value == "Expired").toList();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filteredData = data;
|
||||||
|
}
|
||||||
|
add(FilterDataEvent(
|
||||||
|
selectedTabIndex: selectedIndex, // Pass the selected tab index
|
||||||
|
passwordName: passwordName.text.toLowerCase(),
|
||||||
|
startTime: effectiveTimeTimeStamp,
|
||||||
|
endTime: expirationTimeTimeStamp
|
||||||
|
));
|
||||||
|
emit(TableLoaded(filteredData));
|
||||||
|
} catch (e) {
|
||||||
|
emit(FailedState(e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,16 @@ class FilterDataEvent extends AccessEvent {
|
|||||||
final String? passwordName;
|
final String? passwordName;
|
||||||
final int? startTime;
|
final int? startTime;
|
||||||
final int? endTime;
|
final int? endTime;
|
||||||
|
final int selectedTabIndex; // Add this field
|
||||||
|
|
||||||
const FilterDataEvent({
|
const FilterDataEvent({
|
||||||
this.passwordName,
|
this.passwordName,
|
||||||
this.startTime,
|
this.startTime,
|
||||||
this.endTime,
|
this.endTime,
|
||||||
|
required this.selectedTabIndex, // Initialize this field
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ class PasswordModel {
|
|||||||
final dynamic effectiveTime;
|
final dynamic effectiveTime;
|
||||||
final dynamic passwordCreated;
|
final dynamic passwordCreated;
|
||||||
final dynamic createdTime;
|
final dynamic createdTime;
|
||||||
final dynamic passwodName; // New field
|
final dynamic passwordName; // New field
|
||||||
final dynamic passwordStatus;
|
final AccessStatus passwordStatus;
|
||||||
final AccessType passwordType;
|
final AccessType passwordType;
|
||||||
final dynamic deviceUuid;
|
final dynamic deviceUuid;
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ class PasswordModel {
|
|||||||
this.effectiveTime,
|
this.effectiveTime,
|
||||||
this.passwordCreated,
|
this.passwordCreated,
|
||||||
this.createdTime,
|
this.createdTime,
|
||||||
this.passwodName, // New field
|
this.passwordName, // New field
|
||||||
this.passwordStatus,
|
required this.passwordStatus,
|
||||||
required this.passwordType,
|
required this.passwordType,
|
||||||
this.deviceUuid,
|
this.deviceUuid,
|
||||||
});
|
});
|
||||||
@ -30,8 +30,8 @@ class PasswordModel {
|
|||||||
effectiveTime: json['effectiveTime'],
|
effectiveTime: json['effectiveTime'],
|
||||||
passwordCreated: json['passwordCreated'],
|
passwordCreated: json['passwordCreated'],
|
||||||
createdTime: json['createdTime'],
|
createdTime: json['createdTime'],
|
||||||
passwodName: json['passwodName']??'No name', // New field
|
passwordName: json['passwordName']??'No name', // New field
|
||||||
passwordStatus: json['passwordStatus'],
|
passwordStatus:AccessStatusExtension.fromString(json['passwordStatus']),
|
||||||
passwordType:AccessTypeExtension.fromString(json['passwordType']),
|
passwordType:AccessTypeExtension.fromString(json['passwordType']),
|
||||||
deviceUuid: json['deviceUuid'],
|
deviceUuid: json['deviceUuid'],
|
||||||
);
|
);
|
||||||
@ -44,13 +44,11 @@ class PasswordModel {
|
|||||||
'effectiveTime': effectiveTime,
|
'effectiveTime': effectiveTime,
|
||||||
'passwordCreated': passwordCreated,
|
'passwordCreated': passwordCreated,
|
||||||
'createdTime': createdTime,
|
'createdTime': createdTime,
|
||||||
'passwodName': passwodName, // New field
|
'passwodName': passwordName, // New field
|
||||||
'passwordStatus': passwordStatus,
|
'passwordStatus': passwordStatus,
|
||||||
'passwordType': passwordType,
|
'passwordType': passwordType,
|
||||||
'deviceUuid': deviceUuid,
|
'deviceUuid': deviceUuid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
List<PasswordModel> parsePasswordList(List<dynamic> jsonList) {
|
|
||||||
return jsonList.map((json) => PasswordModel.fromJson(json)).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,13 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
scaffoldBody: BlocProvider(create: (BuildContext context) => AccessBloc()..add(FetchTableData()),
|
scaffoldBody: BlocProvider(create: (BuildContext context) => AccessBloc()..add(FetchTableData()),
|
||||||
child: BlocConsumer<AccessBloc, AccessState>(listener: (context, state) {
|
child: BlocConsumer<AccessBloc, AccessState>(listener: (context, state) {
|
||||||
if (state is FailedState) {
|
|
||||||
// CustomSnackBar.displaySnackBar(
|
|
||||||
// state.errorMessage
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
final accessBloc = BlocProvider.of<AccessBloc>(context);
|
final accessBloc = BlocProvider.of<AccessBloc>(context);
|
||||||
return Container(
|
final filteredData = accessBloc.filteredData;
|
||||||
|
return state is AccessLoaded?
|
||||||
|
const Center(child: CircularProgressIndicator()):
|
||||||
|
Container(
|
||||||
padding: EdgeInsets.all(30),
|
padding: EdgeInsets.all(30),
|
||||||
height: size.height,
|
height: size.height,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
@ -61,8 +60,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
itemCount: BlocProvider.of<AccessBloc>(context).tabs.length,
|
itemCount: BlocProvider.of<AccessBloc>(context).tabs.length,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final isSelected = index ==
|
final isSelected = index == BlocProvider.of<AccessBloc>(context).selectedIndex;
|
||||||
BlocProvider.of<AccessBloc>(context).selectedIndex;
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
BlocProvider.of<AccessBloc>(context).add(TabChangedEvent(index));
|
BlocProvider.of<AccessBloc>(context).add(TabChangedEvent(index));
|
||||||
@ -72,7 +70,8 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
color: ColorsManager.boxColor,
|
color: ColorsManager.boxColor,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isSelected ? Colors.blue : Colors.transparent,
|
color: isSelected ? Colors.blue : Colors.transparent,
|
||||||
width: 2.0,),
|
width: 2.0,
|
||||||
|
),
|
||||||
borderRadius: index == 0
|
borderRadius: index == 0
|
||||||
? const BorderRadius.only(
|
? const BorderRadius.only(
|
||||||
topLeft: Radius.circular(10),
|
topLeft: Radius.circular(10),
|
||||||
@ -81,15 +80,14 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
? const BorderRadius.only(
|
? const BorderRadius.only(
|
||||||
topRight: Radius.circular(10),
|
topRight: Radius.circular(10),
|
||||||
bottomRight: Radius.circular(10))
|
bottomRight: Radius.circular(10))
|
||||||
: null),
|
: null,
|
||||||
|
),
|
||||||
padding: const EdgeInsets.only(left: 10, right: 10),
|
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
BlocProvider.of<AccessBloc>(context).tabs[index],
|
BlocProvider.of<AccessBloc>(context).tabs[index],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isSelected
|
color: isSelected ? Colors.blue : Colors.black,
|
||||||
? Colors.blue
|
|
||||||
: Colors.black,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -105,12 +103,15 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text('Name'),
|
Text('Name',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
|
const SizedBox(height: 5,),
|
||||||
Container(
|
Container(
|
||||||
|
height:size.height * 0.053,
|
||||||
width: size.width * 0.15,
|
width: size.width * 0.15,
|
||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
@ -118,7 +119,8 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
decoration: textBoxDecoration()!
|
decoration: textBoxDecoration()!
|
||||||
.copyWith(hintText: 'Please enter'),
|
.copyWith(hintText: 'Please enter'),
|
||||||
)),
|
)
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@ -152,6 +154,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
accessBloc.add(FilterDataEvent(
|
accessBloc.add(FilterDataEvent(
|
||||||
|
selectedTabIndex: BlocProvider.of<AccessBloc>(context).selectedIndex, // Pass the selected tab index
|
||||||
passwordName: accessBloc.passwordName.text.toLowerCase(),
|
passwordName: accessBloc.passwordName.text.toLowerCase(),
|
||||||
startTime: accessBloc.effectiveTimeTimeStamp,
|
startTime: accessBloc.effectiveTimeTimeStamp,
|
||||||
endTime: accessBloc.expirationTimeTimeStamp
|
endTime: accessBloc.expirationTimeTimeStamp
|
||||||
@ -234,8 +237,8 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: state is TableLoaded
|
child: DynamicTable(
|
||||||
? DynamicTable(
|
isEmpty: filteredData.isEmpty ,
|
||||||
withCheckBox: false,
|
withCheckBox: false,
|
||||||
size: size,
|
size: size,
|
||||||
cellDecoration: containerDecoration,
|
cellDecoration: containerDecoration,
|
||||||
@ -243,102 +246,30 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
'Name',
|
'Name',
|
||||||
'Access Type',
|
'Access Type',
|
||||||
'Access Period',
|
'Access Period',
|
||||||
'Device Id',
|
'Accessible Device',
|
||||||
'Authorizer',
|
'Authorizer',
|
||||||
'Authorization Date & Time',
|
'Authorization Date & Time',
|
||||||
'Access Status'
|
'Access Status'
|
||||||
],
|
],
|
||||||
data: state.data.map((item) {
|
data: filteredData.map((item) {
|
||||||
return [
|
return [
|
||||||
item.passwodName.toString(),
|
item.passwordName.toString(),
|
||||||
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(),
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
''
|
item.passwordStatus.value
|
||||||
];
|
];
|
||||||
}).toList(),
|
}).toList(),
|
||||||
)
|
)
|
||||||
: const Center(child: CircularProgressIndicator()),
|
// : const Center(child: CircularProgressIndicator()),
|
||||||
)
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Container TableWidget(Size size, TableLoaded state,AccessBloc accessBloc) {
|
|
||||||
// return Container(
|
|
||||||
// decoration: containerDecoration,
|
|
||||||
// width: size.width,
|
|
||||||
// child: Padding(
|
|
||||||
// padding: const EdgeInsets.all(10.0),
|
|
||||||
// child: ListView(
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// children: [
|
|
||||||
// Container(
|
|
||||||
// width: size.width,
|
|
||||||
// height: size.height,
|
|
||||||
// child: Column(
|
|
||||||
// children: [
|
|
||||||
// Container(
|
|
||||||
// color: ColorsManager.boxColor,
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// _buildTableHeaderCell('Password name'),
|
|
||||||
// _buildTableHeaderCell(' Password Type'),
|
|
||||||
// _buildTableHeaderCell('Start Time'),
|
|
||||||
// _buildTableHeaderCell('End Time'),
|
|
||||||
// _buildTableHeaderCell('Device Id'),
|
|
||||||
// // _buildTableHeaderCell('Authorization Source'),
|
|
||||||
// // _buildTableHeaderCell('Authorizer'),
|
|
||||||
// _buildTableHeaderCell('Password Created'),
|
|
||||||
// // _buildTableHeaderCell('Access Status'),
|
|
||||||
// _buildTableHeaderCell('Password Status'),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// Expanded(
|
|
||||||
// child: Container(
|
|
||||||
// width: size.width,
|
|
||||||
// color: ColorsManager.whiteColors,
|
|
||||||
// child: ListView(
|
|
||||||
// shrinkWrap: true,
|
|
||||||
// children: [
|
|
||||||
// Column(
|
|
||||||
// children: state.data.map((item) {
|
|
||||||
// return Row(
|
|
||||||
// children: [
|
|
||||||
// _buildTableCell(item.passwodName),
|
|
||||||
// _buildTableCell(item.passwordType),
|
|
||||||
//
|
|
||||||
// _buildTableCell(accessBloc.timestampToDateTime(item.effectiveTime).toString()),
|
|
||||||
// _buildTableCell(accessBloc.timestampToDateTime(item.invalidTime).toString()),
|
|
||||||
// _buildTableCell(item.deviceUuid.toString()),
|
|
||||||
// // _buildTableCell(item.authorizationSource),
|
|
||||||
// // _buildTableCell(item.authorizer),
|
|
||||||
// _buildTableCell(item.passwordCreated!=null?accessBloc.timestampToDateTime(item.passwordCreated).toString():'no data'),
|
|
||||||
// // _buildTableCell(item.accessStatus),
|
|
||||||
// _buildTableCell(item.passwordStatus.toString()),
|
|
||||||
// ],
|
|
||||||
// );
|
|
||||||
// }).toList(),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +159,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
loginPasswordController.clear();
|
loginPasswordController.clear();
|
||||||
emit(LoginSuccess());
|
emit(LoginSuccess());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
emit(const LoginFailure(error: 'Something went wrong'));
|
emit(const LoginFailure(error: 'Something went wrong'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -166,8 +166,7 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
|||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: region.id,
|
value: region.id,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: size.width*0.06,
|
width: size.width*0.08,
|
||||||
|
|
||||||
child: Text(region.name)),
|
child: Text(region.name)),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class DynamicTable extends StatefulWidget {
|
class DynamicTable extends StatefulWidget {
|
||||||
final List<String> headers;
|
final List<String> headers;
|
||||||
@ -8,6 +10,7 @@ class DynamicTable extends StatefulWidget {
|
|||||||
final BoxDecoration? cellDecoration;
|
final BoxDecoration? cellDecoration;
|
||||||
final Size size;
|
final Size size;
|
||||||
final bool withCheckBox;
|
final bool withCheckBox;
|
||||||
|
final bool isEmpty;
|
||||||
final void Function(bool?)? selectAll;
|
final void Function(bool?)? selectAll;
|
||||||
final void Function(int, bool?)? onRowCheckboxChanged;
|
final void Function(int, bool?)? onRowCheckboxChanged;
|
||||||
|
|
||||||
@ -16,6 +19,7 @@ class DynamicTable extends StatefulWidget {
|
|||||||
required this.headers,
|
required this.headers,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.size,
|
required this.size,
|
||||||
|
required this.isEmpty,
|
||||||
required this.withCheckBox,
|
required this.withCheckBox,
|
||||||
this.headerDecoration,
|
this.headerDecoration,
|
||||||
this.cellDecoration,
|
this.cellDecoration,
|
||||||
@ -63,7 +67,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
decoration: widget.cellDecoration,
|
decoration: widget.cellDecoration,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: ListView(
|
child:
|
||||||
|
ListView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -83,6 +88,29 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
widget.isEmpty?
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.emptyTable
|
||||||
|
),
|
||||||
|
SizedBox(height: 15,),
|
||||||
|
Text('No Passwords',style: Theme.of(context).textTheme.bodySmall!.copyWith(color:ColorsManager.grayColor ),)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
):
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -164,7 +192,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
child: Text(
|
||||||
content,
|
content,
|
||||||
style: const TextStyle(color: Colors.black, fontSize: 12),
|
style: const TextStyle(color: Colors.black, fontSize: 10,fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -42,11 +42,12 @@ class DateTimeWebWidget extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
Text(title??'' , style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
Text(title??'' ,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color: Colors.black,fontSize: 13),),
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 8,),
|
const SizedBox(height: 8,),
|
||||||
Container(
|
Container(
|
||||||
width: size.width * 0.25,
|
width: size.width * 0.25,
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
|
@ -67,7 +67,7 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
color: null,
|
color: null,
|
||||||
),
|
),
|
||||||
HomeItemModel(
|
HomeItemModel(
|
||||||
title: 'Space\nManagement',
|
title: 'Space Management',
|
||||||
icon: Assets.spaseManagementIcon,
|
icon: Assets.spaseManagementIcon,
|
||||||
active: true,
|
active: true,
|
||||||
onPress: (context) {
|
onPress: (context) {
|
||||||
|
@ -37,7 +37,8 @@ class HomeCard extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
FittedBox(
|
Flexible(
|
||||||
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: Text(
|
child: Text(
|
||||||
name,
|
name,
|
||||||
@ -48,6 +49,7 @@ class HomeCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -11,9 +11,7 @@ import 'package:syncrow_web/services/access_mang_api.dart';
|
|||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
|
||||||
List<String> selectedDevices = [];
|
|
||||||
|
|
||||||
// Define the BLoC
|
|
||||||
class VisitorPasswordBloc
|
class VisitorPasswordBloc
|
||||||
extends Bloc<VisitorPasswordEvent, VisitorPasswordState> {
|
extends Bloc<VisitorPasswordEvent, VisitorPasswordState> {
|
||||||
VisitorPasswordBloc() : super(VisitorPasswordInitial()) {
|
VisitorPasswordBloc() : super(VisitorPasswordInitial()) {
|
||||||
@ -42,12 +40,12 @@ class VisitorPasswordBloc
|
|||||||
final TextEditingController unitNameController = TextEditingController();
|
final TextEditingController unitNameController = TextEditingController();
|
||||||
final TextEditingController virtualAddressController =
|
final TextEditingController virtualAddressController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
|
List<String> selectedDevices = [];
|
||||||
|
|
||||||
List<DeviceModel> data = [];
|
List<DeviceModel> data = [];
|
||||||
List<String> selectedDeviceIds = [];
|
List<String> selectedDeviceIds = [];
|
||||||
String effectiveTime = 'Select Time';
|
String effectiveTime = 'Start Time';
|
||||||
|
String expirationTime = 'End Time';
|
||||||
String expirationTime = 'Select Time';
|
|
||||||
|
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
@ -69,8 +67,6 @@ class VisitorPasswordBloc
|
|||||||
String startTimeAccess = 'Start Time';
|
String startTimeAccess = 'Start Time';
|
||||||
String endTimeAccess = 'End Time';
|
String endTimeAccess = 'End Time';
|
||||||
|
|
||||||
// DateTime? repeatStartTime=DateTime.now();
|
|
||||||
// DateTime? repeatEndTime;
|
|
||||||
|
|
||||||
selectAccessType(
|
selectAccessType(
|
||||||
SelectPasswordType event, Emitter<VisitorPasswordState> emit) {
|
SelectPasswordType event, Emitter<VisitorPasswordState> emit) {
|
||||||
@ -210,9 +206,6 @@ class VisitorPasswordBloc
|
|||||||
Emitter<VisitorPasswordState> emit) async {
|
Emitter<VisitorPasswordState> emit) async {
|
||||||
try {
|
try {
|
||||||
generate7DigitNumber();
|
generate7DigitNumber();
|
||||||
|
|
||||||
print('selectedDevices$selectedDevices');
|
|
||||||
// emit(DeviceLoaded());
|
|
||||||
bool res = await AccessMangApi().postOnlineOneTime(
|
bool res = await AccessMangApi().postOnlineOneTime(
|
||||||
email: event.email,
|
email: event.email,
|
||||||
password: passwordController,
|
password: passwordController,
|
||||||
@ -225,6 +218,7 @@ class VisitorPasswordBloc
|
|||||||
}
|
}
|
||||||
emit(TableLoaded(data));
|
emit(TableLoaded(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,9 +345,9 @@ class VisitorPasswordBloc
|
|||||||
emit(TableLoaded(event.filteredData));
|
emit(TableLoaded(event.filteredData));
|
||||||
}
|
}
|
||||||
|
|
||||||
addDeviceToList() {
|
addDeviceToList(context) {
|
||||||
selectedDevices = selectedDeviceIds;
|
selectedDevices = selectedDeviceIds;
|
||||||
print(selectedDevices);
|
Navigator.of(context).pop(selectedDevices); // Close the dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> selectTimeOfLinePassword(SelectTimeEvent event, Emitter<VisitorPasswordState> emit) async {
|
Future<void> selectTimeOfLinePassword(SelectTimeEvent event, Emitter<VisitorPasswordState> emit) async {
|
||||||
|
@ -161,6 +161,7 @@ class AddDeviceDialog extends StatelessWidget {
|
|||||||
child: state is TableLoaded
|
child: state is TableLoaded
|
||||||
? DynamicTable(
|
? DynamicTable(
|
||||||
cellDecoration: containerDecoration,
|
cellDecoration: containerDecoration,
|
||||||
|
isEmpty:visitorBloc.data.isEmpty,
|
||||||
selectAll: (p0) {
|
selectAll: (p0) {
|
||||||
visitorBloc.selectedDeviceIds.clear();
|
visitorBloc.selectedDeviceIds.clear();
|
||||||
for (var item in state.data) {
|
for (var item in state.data) {
|
||||||
@ -211,8 +212,7 @@ class AddDeviceDialog extends StatelessWidget {
|
|||||||
width: size.width * 0.2,
|
width: size.width * 0.2,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
visitorBloc.addDeviceToList();
|
visitorBloc.addDeviceToList(context);
|
||||||
Navigator.of(context).pop(); // Close the dialog
|
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
child: Text('Ok'),
|
child: Text('Ok'),
|
||||||
|
@ -128,10 +128,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
: visitorBloc.accessTypeSelected,
|
: visitorBloc.accessTypeSelected,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
print(value);
|
context.read<VisitorPasswordBloc>()
|
||||||
|
|
||||||
context
|
|
||||||
.read<VisitorPasswordBloc>()
|
|
||||||
.add(SelectPasswordType(value));
|
.add(SelectPasswordType(value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -192,22 +189,18 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 200,
|
width: 200,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: Text('One-Time',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
title: Text('One-Time',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color: Colors.black,fontSize: 13),),
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'One-Time',
|
value: 'One-Time',
|
||||||
groupValue:
|
groupValue:
|
||||||
(state is UsageFrequencySelected)
|
(state is UsageFrequencySelected)
|
||||||
? state.selectedFrequency
|
? state.selectedFrequency
|
||||||
: visitorBloc
|
: visitorBloc.usageFrequencySelected,
|
||||||
.usageFrequencySelected,
|
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
print(value);
|
context.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectUsageFrequency(value));
|
||||||
context
|
|
||||||
.read<VisitorPasswordBloc>()
|
|
||||||
.add(SelectUsageFrequency(
|
|
||||||
value));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -219,17 +212,14 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color: Colors.black,fontSize: 13),),
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'Periodic',
|
value: 'Periodic',
|
||||||
groupValue:
|
groupValue: (state is UsageFrequencySelected)
|
||||||
(state is UsageFrequencySelected)
|
|
||||||
? state.selectedFrequency
|
? state.selectedFrequency
|
||||||
: visitorBloc
|
: visitorBloc.usageFrequencySelected,
|
||||||
.usageFrequencySelected,
|
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
context
|
context
|
||||||
.read<VisitorPasswordBloc>()
|
.read<VisitorPasswordBloc>()
|
||||||
.add(SelectUsageFrequency(
|
.add(SelectUsageFrequency(value));
|
||||||
value));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -238,7 +228,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Text('Within the validity period, each device can be unlocked only once.',
|
Text('Within the validity period, each device can be unlocked only once.',
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color: ColorsManager.grayColor,fontSize: 9),)
|
color: ColorsManager.grayColor,fontSize: 9),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@ -332,7 +323,14 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return const AddDeviceDialog();
|
return const AddDeviceDialog();
|
||||||
},
|
},
|
||||||
);
|
).then((listDevice) {
|
||||||
|
if(listDevice!=null){
|
||||||
|
print('selectedDevices==$listDevice');
|
||||||
|
visitorBloc.selectedDevices = listDevice;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
child: Text('+ Add Device',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
child: Text('+ Add Device',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
@ -371,9 +369,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
width: size.width * 0.2,
|
width: size.width * 0.2,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print(selectedDevices);
|
|
||||||
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||||
if (selectedDevices.toString() != '[]') {
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@ -390,8 +386,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context)
|
Navigator.of(context).pop();
|
||||||
.pop(); // Close the dialog
|
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -449,57 +444,6 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
content: SizedBox(
|
|
||||||
height: size!.height * 0.15,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.deviceNoteIcon,
|
|
||||||
height: 35,
|
|
||||||
width: 35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Please select devices to continue',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.headlineLarge!
|
|
||||||
.copyWith(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Colors.black),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actionsAlignment: MainAxisAlignment.center,
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: Text('OK',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: ColorsManager.whiteColors,fontSize: 16),),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
@ -26,4 +26,5 @@ class Assets {
|
|||||||
static const String calendarIcon = "assets/images/calendar_icon.svg";
|
static const String calendarIcon = "assets/images/calendar_icon.svg";
|
||||||
static const String deviceNoteIcon = "assets/images/device_note.svg";
|
static const String deviceNoteIcon = "assets/images/device_note.svg";
|
||||||
static const String timeIcon = "assets/images/time_icon.svg";
|
static const String timeIcon = "assets/images/time_icon.svg";
|
||||||
|
static const String emptyTable = "assets/images/empty_table.svg";
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum AccessType {
|
enum AccessType {
|
||||||
onlineOnetime,
|
onlineOnetime,
|
||||||
onlineMultiple,
|
onlineMultiple,
|
||||||
@ -43,8 +41,6 @@ extension AccessTypeExtension on AccessType {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum DeviseStatus {
|
enum DeviseStatus {
|
||||||
online,
|
online,
|
||||||
offline,
|
offline,
|
||||||
@ -74,6 +70,40 @@ extension OnlineTypeExtension on DeviseStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum AccessStatus {
|
||||||
|
expired ,
|
||||||
|
effective ,
|
||||||
|
toBeEffective,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AccessStatusExtension on AccessStatus {
|
||||||
|
String get value {
|
||||||
|
switch (this) {
|
||||||
|
case AccessStatus.expired:
|
||||||
|
return "Expired";
|
||||||
|
case AccessStatus.effective:
|
||||||
|
return "Effective" ;
|
||||||
|
case AccessStatus.toBeEffective:
|
||||||
|
return "To be effective";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static AccessStatus fromString(String value) {
|
||||||
|
switch (value) {
|
||||||
|
case "EXPIRED" :
|
||||||
|
return AccessStatus.expired;
|
||||||
|
case "EFFECTIVE" :
|
||||||
|
return AccessStatus.effective;
|
||||||
|
case "TO_BE_EFFECTIVE":
|
||||||
|
return AccessStatus.toBeEffective;
|
||||||
|
default:
|
||||||
|
throw ArgumentError("Invalid access type: $value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user