mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
push fetch devices and connecting the filters
This commit is contained in:
@ -220,7 +220,6 @@ class VisitorPasswordBloc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> postOnlineMultipleTimePassword(
|
||||
OnlineMultipleTimePasswordEvent event,
|
||||
Emitter<VisitorPasswordState> emit) async {
|
||||
@ -246,11 +245,10 @@ class VisitorPasswordBloc
|
||||
passwordName: event.passwordName);
|
||||
if (res == true) {
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
} else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
@ -267,17 +265,16 @@ class VisitorPasswordBloc
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOffLineOneTime(
|
||||
bool res = await AccessMangApi().postOffLineOneTime(
|
||||
email: event.email,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName);
|
||||
if (res == true) {
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
} else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
@ -294,7 +291,7 @@ class VisitorPasswordBloc
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOffLineMultipleTime(
|
||||
bool res = await AccessMangApi().postOffLineMultipleTime(
|
||||
email: event.email,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName,
|
||||
@ -303,18 +300,18 @@ class VisitorPasswordBloc
|
||||
);
|
||||
if (res == true) {
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
} else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
stateDialog(
|
||||
context: event.context!,
|
||||
message: e.toString(),
|
||||
title: 'Something Wrong'); }
|
||||
title: 'Something Wrong');
|
||||
}
|
||||
}
|
||||
|
||||
void selectDevice(
|
||||
|
@ -26,33 +26,32 @@ class SelectUsageFrequency extends VisitorPasswordEvent {
|
||||
@override
|
||||
List<Object> get props => [usageType];
|
||||
}
|
||||
|
||||
class SelectTimeVisitorPassword extends VisitorPasswordEvent {
|
||||
final BuildContext context;
|
||||
final bool isStart;
|
||||
final bool isRepeat;
|
||||
|
||||
const SelectTimeVisitorPassword({ required this.context,required this.isStart,required this.isRepeat});
|
||||
const SelectTimeVisitorPassword(
|
||||
{required this.context, required this.isStart, required this.isRepeat});
|
||||
|
||||
@override
|
||||
List<Object> get props => [context,isStart,isRepeat];
|
||||
List<Object> get props => [context, isStart, isRepeat];
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ToggleDaySelectionEvent extends VisitorPasswordEvent {
|
||||
final String key;
|
||||
final String key;
|
||||
|
||||
const ToggleDaySelectionEvent({required this.key});
|
||||
@override
|
||||
List<Object> get props => [key];
|
||||
}
|
||||
|
||||
|
||||
class ToggleRepeatEvent extends VisitorPasswordEvent {}
|
||||
|
||||
class GeneratePasswordEvent extends VisitorPasswordEvent {}
|
||||
|
||||
class FetchDevice extends VisitorPasswordEvent {
|
||||
}
|
||||
class FetchDevice extends VisitorPasswordEvent {}
|
||||
|
||||
//online password
|
||||
class OnlineOneTimePasswordEvent extends VisitorPasswordEvent {
|
||||
@ -60,20 +59,31 @@ class OnlineOneTimePasswordEvent extends VisitorPasswordEvent {
|
||||
final String? passwordName;
|
||||
final BuildContext? context;
|
||||
|
||||
const OnlineOneTimePasswordEvent({this.email,this.passwordName,this.context});
|
||||
const OnlineOneTimePasswordEvent(
|
||||
{this.email, this.passwordName, this.context});
|
||||
|
||||
@override
|
||||
List<Object> get props => [email!,passwordName!,];
|
||||
List<Object> get props => [
|
||||
email!,
|
||||
passwordName!,
|
||||
];
|
||||
}
|
||||
|
||||
class OnlineMultipleTimePasswordEvent extends VisitorPasswordEvent {
|
||||
final String? email;
|
||||
final String? passwordName;
|
||||
final String? invalidTime;
|
||||
final String? effectiveTime;
|
||||
final BuildContext? context;
|
||||
const OnlineMultipleTimePasswordEvent({this.email,this.passwordName,this.invalidTime,this.effectiveTime,this.context});
|
||||
const OnlineMultipleTimePasswordEvent(
|
||||
{this.email,
|
||||
this.passwordName,
|
||||
this.invalidTime,
|
||||
this.effectiveTime,
|
||||
this.context});
|
||||
@override
|
||||
List<Object> get props => [email!,passwordName!,invalidTime!,effectiveTime!,context!];
|
||||
List<Object> get props =>
|
||||
[email!, passwordName!, invalidTime!, effectiveTime!, context!];
|
||||
}
|
||||
|
||||
//offline password
|
||||
@ -81,9 +91,14 @@ class OfflineOneTimePasswordEvent extends VisitorPasswordEvent {
|
||||
final BuildContext? context;
|
||||
final String? email;
|
||||
final String? passwordName;
|
||||
const OfflineOneTimePasswordEvent({this.email,this.passwordName,this.context});
|
||||
const OfflineOneTimePasswordEvent(
|
||||
{this.email, this.passwordName, this.context});
|
||||
@override
|
||||
List<Object> get props => [email!,passwordName!,context!,];
|
||||
List<Object> get props => [
|
||||
email!,
|
||||
passwordName!,
|
||||
context!,
|
||||
];
|
||||
}
|
||||
|
||||
class OfflineMultipleTimePasswordEvent extends VisitorPasswordEvent {
|
||||
@ -93,13 +108,18 @@ class OfflineMultipleTimePasswordEvent extends VisitorPasswordEvent {
|
||||
final String? effectiveTime;
|
||||
final BuildContext? context;
|
||||
|
||||
const OfflineMultipleTimePasswordEvent({this.context,this.email,this.passwordName,this.invalidTime,this.effectiveTime});
|
||||
const OfflineMultipleTimePasswordEvent(
|
||||
{this.context,
|
||||
this.email,
|
||||
this.passwordName,
|
||||
this.invalidTime,
|
||||
this.effectiveTime});
|
||||
|
||||
@override
|
||||
List<Object> get props => [email!,passwordName!,invalidTime!,effectiveTime!,context!];
|
||||
List<Object> get props =>
|
||||
[email!, passwordName!, invalidTime!, effectiveTime!, context!];
|
||||
}
|
||||
|
||||
|
||||
class SelectDeviceEvent extends VisitorPasswordEvent {
|
||||
final String deviceId;
|
||||
const SelectDeviceEvent(this.deviceId);
|
||||
@ -116,22 +136,26 @@ class FilterDataEvent extends VisitorPasswordEvent {
|
||||
this.endTime,
|
||||
});
|
||||
}
|
||||
|
||||
class UpdateFilteredDevicesEvent extends VisitorPasswordEvent {
|
||||
final List<DeviceModel> filteredData;
|
||||
|
||||
UpdateFilteredDevicesEvent(this.filteredData);
|
||||
}class SelectTimeEvent extends VisitorPasswordEvent {
|
||||
final BuildContext context;
|
||||
final bool isEffective;
|
||||
const SelectTimeEvent({required this.context,required this.isEffective});
|
||||
@override
|
||||
List<Object> get props => [context,isEffective];
|
||||
}
|
||||
|
||||
class SelectTimeEvent extends VisitorPasswordEvent {
|
||||
final BuildContext context;
|
||||
final bool isEffective;
|
||||
const SelectTimeEvent({required this.context, required this.isEffective});
|
||||
@override
|
||||
List<Object> get props => [context, isEffective];
|
||||
}
|
||||
|
||||
class ChangeTimeEvent extends VisitorPasswordEvent {
|
||||
final dynamic val;
|
||||
final bool isStartEndTime;
|
||||
|
||||
const ChangeTimeEvent({required this.val,required this.isStartEndTime});
|
||||
const ChangeTimeEvent({required this.val, required this.isStartEndTime});
|
||||
@override
|
||||
List<Object> get props => [val,isStartEndTime];
|
||||
}
|
||||
List<Object> get props => [val, isStartEndTime];
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
|
||||
|
||||
@ -12,8 +10,6 @@ abstract class VisitorPasswordState extends Equatable {
|
||||
|
||||
class VisitorPasswordInitial extends VisitorPasswordState {}
|
||||
|
||||
|
||||
|
||||
class PasswordTypeSelected extends VisitorPasswordState {
|
||||
final String selectedType;
|
||||
const PasswordTypeSelected(this.selectedType);
|
||||
@ -36,13 +32,16 @@ class IsRepeatState extends VisitorPasswordState {
|
||||
|
||||
@override
|
||||
List<Object> get props => [repeat];
|
||||
|
||||
}
|
||||
|
||||
class LoadingInitialState extends VisitorPasswordState {}
|
||||
|
||||
class ChangeTimeState extends VisitorPasswordState {}
|
||||
|
||||
class TimeSelectedState extends VisitorPasswordState {}
|
||||
|
||||
class DeviceLoaded extends VisitorPasswordState {}
|
||||
|
||||
class SuccessState extends VisitorPasswordState {}
|
||||
|
||||
class FailedState extends VisitorPasswordState {
|
||||
@ -62,4 +61,4 @@ class TableLoaded extends VisitorPasswordState {
|
||||
class DeviceSelectionUpdated extends VisitorPasswordState {
|
||||
final List<String> selectedDeviceIds;
|
||||
const DeviceSelectionUpdated(this.selectedDeviceIds);
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,26 @@
|
||||
|
||||
|
||||
import 'package:syncrow_web/utils/constants/const.dart';
|
||||
|
||||
class DeviceModel {
|
||||
dynamic productUuid;
|
||||
dynamic productType;
|
||||
dynamic activeTime;
|
||||
dynamic category;
|
||||
dynamic categoryName;
|
||||
dynamic createTime;
|
||||
dynamic gatewayId;
|
||||
dynamic icon;
|
||||
dynamic ip;
|
||||
dynamic lat;
|
||||
dynamic localKey;
|
||||
dynamic lon;
|
||||
dynamic model;
|
||||
dynamic name;
|
||||
DeviseStatus online;
|
||||
dynamic ownerId;
|
||||
dynamic sub;
|
||||
dynamic timeZone;
|
||||
dynamic updateTime;
|
||||
dynamic uuid;
|
||||
dynamic productUuid;
|
||||
dynamic productType;
|
||||
dynamic activeTime;
|
||||
dynamic category;
|
||||
dynamic categoryName;
|
||||
dynamic createTime;
|
||||
dynamic gatewayId;
|
||||
dynamic icon;
|
||||
dynamic ip;
|
||||
dynamic lat;
|
||||
dynamic localKey;
|
||||
dynamic lon;
|
||||
dynamic model;
|
||||
dynamic name;
|
||||
DeviseStatus online;
|
||||
dynamic ownerId;
|
||||
dynamic sub;
|
||||
dynamic timeZone;
|
||||
dynamic updateTime;
|
||||
dynamic uuid;
|
||||
|
||||
DeviceModel({
|
||||
required this.productUuid,
|
||||
@ -50,25 +48,25 @@ class DeviceModel {
|
||||
// Deserialize from JSON
|
||||
factory DeviceModel.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceModel(
|
||||
productUuid: json['productUuid'] ,
|
||||
productUuid: json['productUuid'],
|
||||
productType: json['productType'],
|
||||
activeTime: json['activeTime'],
|
||||
category: json['category'] ,
|
||||
categoryName: json['categoryName'] ,
|
||||
createTime: json['createTime'] ,
|
||||
category: json['category'],
|
||||
categoryName: json['categoryName'],
|
||||
createTime: json['createTime'],
|
||||
gatewayId: json['gatewayId'],
|
||||
icon: json['icon'],
|
||||
ip: json['ip'] ,
|
||||
lat: json['lat'] ,
|
||||
localKey: json['localKey'] ,
|
||||
lon: json['lon'] ,
|
||||
model: json['model'] ,
|
||||
ip: json['ip'],
|
||||
lat: json['lat'],
|
||||
localKey: json['localKey'],
|
||||
lon: json['lon'],
|
||||
model: json['model'],
|
||||
name: json['name'],
|
||||
online: OnlineTypeExtension.fromString(json['online']),
|
||||
ownerId: json['ownerId'] ,
|
||||
ownerId: json['ownerId'],
|
||||
sub: json['sub'],
|
||||
timeZone: json['timeZone'],
|
||||
updateTime: json['updateTime'] ,
|
||||
updateTime: json['updateTime'],
|
||||
uuid: json['uuid'],
|
||||
);
|
||||
}
|
||||
|
@ -24,4 +24,4 @@ class Schedule {
|
||||
'workingDay': workingDay,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,70 +17,72 @@ class RepeatWidget extends StatelessWidget {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return BlocBuilder<VisitorPasswordBloc, VisitorPasswordState>(
|
||||
builder: (context, state) {
|
||||
final visitorBloc = BlocProvider.of<VisitorPasswordBloc>(context);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// Wrap the Row in a SingleChildScrollView to handle overflow
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: visitorBloc.days.map((day) {
|
||||
return Container(
|
||||
width: 70, // Adjust width as needed
|
||||
margin: EdgeInsets.all(5),
|
||||
child: CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
day['day']!,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: visitorBloc.selectedDays.contains(day['key'])
|
||||
? Colors.black
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
value: visitorBloc.selectedDays.contains(day['key']),
|
||||
onChanged: (bool? value) {
|
||||
if (value != null) {
|
||||
visitorBloc.add(ToggleDaySelectionEvent(key: day['key']!));
|
||||
}
|
||||
},
|
||||
final visitorBloc = BlocProvider.of<VisitorPasswordBloc>(context);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// Wrap the Row in a SingleChildScrollView to handle overflow
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: visitorBloc.days.map((day) {
|
||||
return Container(
|
||||
width: 70, // Adjust width as needed
|
||||
margin: EdgeInsets.all(5),
|
||||
child: CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
day['day']!,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: visitorBloc.selectedDays.contains(day['key'])
|
||||
? Colors.black
|
||||
: ColorsManager.blackColor,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DateTimeWebWidget(
|
||||
icon: Assets.timeIcon,
|
||||
isRequired: false,
|
||||
title: '',
|
||||
size: size,
|
||||
endTime: () {
|
||||
visitorBloc.add(SelectTimeEvent(
|
||||
context: context,
|
||||
isEffective: false));
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
visitorBloc.add(ChangeTimeEvent(val: visitorBloc.endTime, isStartEndTime: true));
|
||||
});
|
||||
},
|
||||
startTime: () {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
visitorBloc.add(ChangeTimeEvent(val: visitorBloc.endTime, isStartEndTime: true));
|
||||
});
|
||||
visitorBloc.add(SelectTimeEvent(context: context, isEffective: true));
|
||||
},
|
||||
firstString: visitorBloc.effectiveTime,
|
||||
secondString: visitorBloc.expirationTime,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
),
|
||||
value: visitorBloc.selectedDays.contains(day['key']),
|
||||
onChanged: (bool? value) {
|
||||
if (value != null) {
|
||||
visitorBloc
|
||||
.add(ToggleDaySelectionEvent(key: day['key']!));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DateTimeWebWidget(
|
||||
icon: Assets.timeIcon,
|
||||
isRequired: false,
|
||||
title: '',
|
||||
size: size,
|
||||
endTime: () {
|
||||
visitorBloc
|
||||
.add(SelectTimeEvent(context: context, isEffective: false));
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
visitorBloc.add(ChangeTimeEvent(
|
||||
val: visitorBloc.endTime, isStartEndTime: true));
|
||||
});
|
||||
},
|
||||
startTime: () {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
visitorBloc.add(ChangeTimeEvent(
|
||||
val: visitorBloc.endTime, isStartEndTime: true));
|
||||
});
|
||||
visitorBloc
|
||||
.add(SelectTimeEvent(context: context, isEffective: true));
|
||||
},
|
||||
firstString: visitorBloc.effectiveTime,
|
||||
secondString: visitorBloc.expirationTime,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user