mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
visitor password
This commit is contained in:
@ -5,9 +5,9 @@ import 'package:syncrow_web/pages/access_management/bloc/access_bloc.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
||||
import 'package:syncrow_web/pages/common/default_button.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/view/visitor_password_dialog.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||
|
||||
@ -35,16 +35,15 @@ class AccessManagementPage extends StatelessWidget {
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
],
|
||||
scaffoldBody: BlocProvider(
|
||||
create: (BuildContext context) => AccessBloc()..add(FetchTableData() ),
|
||||
child: BlocConsumer<AccessBloc, AccessState>(
|
||||
listener: (context, state) {
|
||||
scaffoldBody: BlocProvider(create: (BuildContext context) => AccessBloc()..add(FetchTableData()),
|
||||
child: BlocConsumer<AccessBloc, AccessState>(listener: (context, state) {
|
||||
if (state is FailedState) {
|
||||
// CustomSnackBar.displaySnackBar(
|
||||
// state.errorMessage
|
||||
// );
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
final accessBloc = BlocProvider.of<AccessBloc>(context);
|
||||
return Container(
|
||||
padding: EdgeInsets.all(30),
|
||||
height: size.height,
|
||||
@ -53,233 +52,294 @@ class AccessManagementPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: size.width * 0.3,
|
||||
height: size.height * 0.05,
|
||||
width:size.width * 0.26 ,
|
||||
decoration: containerDecoration,
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('All'),
|
||||
Text('To Be Effective (0)'),
|
||||
Text('Effective (0)'),
|
||||
Text('Expired'),
|
||||
],
|
||||
child: Center(
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: BlocProvider.of<AccessBloc>(context).tabs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isSelected = index ==
|
||||
BlocProvider.of<AccessBloc>(context).selectedIndex;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
BlocProvider.of<AccessBloc>(context).add(TabChangedEvent(index));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
border: Border.all(
|
||||
color: isSelected ? Colors.blue : Colors.transparent,
|
||||
width: 2.0,),
|
||||
borderRadius: index == 0
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10))
|
||||
: index == 3
|
||||
? const BorderRadius.only(
|
||||
topRight: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10))
|
||||
: null),
|
||||
padding: const EdgeInsets.only(left: 10,right: 10),
|
||||
child: Center(
|
||||
child: Text(
|
||||
BlocProvider.of<AccessBloc>(context).tabs[index],
|
||||
style: TextStyle(
|
||||
color: isSelected
|
||||
? Colors.blue
|
||||
: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Wrap(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text('User Name'),
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Email Address'),
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Access Time'),
|
||||
Container(
|
||||
width: size.width*0.18,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: containerDecoration,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(child: Text(BlocProvider.of<AccessBloc>(context).startTime)),
|
||||
const Icon(Icons.arrow_right_alt),
|
||||
InkWell(child: Text(BlocProvider.of<AccessBloc>(context).endTime)),
|
||||
SvgPicture.asset(
|
||||
Assets.calendarIcon,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Authorization Source'),
|
||||
Container(
|
||||
width: size.width*0.18,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
SizedBox(
|
||||
width: size.width*0.06,
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(''),
|
||||
const Text('Password Name'),
|
||||
Container(
|
||||
width: size.width * 0.15,
|
||||
decoration: containerDecoration,
|
||||
|
||||
child: DefaultButton(child: Text('Search'),borderRadius: 9)),
|
||||
child: TextFormField(
|
||||
controller: accessBloc.passwordName,
|
||||
style: TextStyle(color: Colors.black),
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10,),
|
||||
SizedBox(
|
||||
width: size.width*0.06,
|
||||
child: Column(
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(''),
|
||||
const Text('Access Time'),
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
backgroundColor: ColorsManager.whiteColors,borderRadius: 9,
|
||||
child: Text('Reset'
|
||||
,style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black),)
|
||||
,),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Wrap(children: [
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: const DefaultButton(
|
||||
borderRadius: 8,
|
||||
child: Text('+ Create Visitor Password ')),
|
||||
),
|
||||
const SizedBox(width: 10,),
|
||||
Container(
|
||||
width: size.width*0.12,
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
borderRadius: 8,
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
child: Text('Admin Password'
|
||||
,style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black),)
|
||||
))
|
||||
],),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child:state is TableLoaded?
|
||||
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 ,
|
||||
width: size.width * 0.25,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: containerDecoration,
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Container(
|
||||
color: ColorsManager.boxColor,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTableHeaderCell('Access User'),
|
||||
_buildTableHeaderCell('Access Type'),
|
||||
_buildTableHeaderCell('Access Period'),
|
||||
_buildTableHeaderCell('Accessible Device'),
|
||||
_buildTableHeaderCell('Authorization Source'),
|
||||
_buildTableHeaderCell('Authorizer'),
|
||||
_buildTableHeaderCell('Authorization Time'),
|
||||
_buildTableHeaderCell('Access Status'),
|
||||
_buildTableHeaderCell('Actions'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
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.accessUser),
|
||||
_buildTableCell(item.accessType),
|
||||
_buildTableCell(item.accessPeriod),
|
||||
_buildTableCell(item.accessibleDevice),
|
||||
_buildTableCell(item.authorizationSource),
|
||||
_buildTableCell(item.authorizer),
|
||||
_buildTableCell(item.authorizationTime),
|
||||
_buildTableCell(item.accessStatus),
|
||||
_buildTableCell(item.actions),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
accessBloc.add(SelectTime(context: context, isStart: true));
|
||||
},
|
||||
child: Text(BlocProvider.of<AccessBloc>(context).startTime)
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_right_alt),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
accessBloc.add(SelectTime(context: context, isStart: false));
|
||||
},
|
||||
child: Text(BlocProvider.of<AccessBloc>(context).endTime)),
|
||||
SvgPicture.asset(
|
||||
Assets.calendarIcon,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: size.width * 0.06,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(''),
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
onPressed: () {
|
||||
accessBloc.add(FilterDataEvent(
|
||||
passwordName: accessBloc.passwordName.text,
|
||||
startTime: accessBloc.effectiveTimeTimeStamp,
|
||||
endTime: accessBloc.expirationTimeTimeStamp
|
||||
));
|
||||
}, borderRadius: 9,
|
||||
child: const Text('Search'))),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
SizedBox(
|
||||
width: size.width * 0.06,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(''),
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
onPressed: () {
|
||||
accessBloc.add(ResetSearch());
|
||||
},
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
borderRadius: 9,
|
||||
child: Text(
|
||||
'Reset',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.black),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
):const Center(child: CircularProgressIndicator())
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Wrap(
|
||||
children: [
|
||||
Container(
|
||||
width: size.width * 0.15,
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return const VisitorPasswordDialog();
|
||||
},
|
||||
);
|
||||
},
|
||||
borderRadius: 8,
|
||||
child: Text('+ Create Visitor Password ')),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Container(
|
||||
width: size.width * 0.12,
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
borderRadius: 8,
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
child: Text(
|
||||
'Admin Password',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: Colors.black),
|
||||
)))
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: state is TableLoaded
|
||||
? TableWidget(size, state,accessBloc)
|
||||
: 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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTableHeaderCell(String title) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border.symmetric(vertical: BorderSide(color: ColorsManager.boxDivider))
|
||||
),
|
||||
border: Border.symmetric(
|
||||
vertical: BorderSide(color: ColorsManager.boxDivider))),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -292,12 +352,21 @@ Widget _buildTableHeaderCell(String title) {
|
||||
Widget _buildTableCell(String content) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
height: 80,
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border.symmetric(horizontal: BorderSide(color: ColorsManager.boxDivider))
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide( // <--- right side
|
||||
color: ColorsManager.boxDivider,
|
||||
width: 1.0,
|
||||
),
|
||||
)
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(content,style: TextStyle(color: Colors.black,fontSize: 12),),
|
||||
child: Text(
|
||||
content,
|
||||
style: TextStyle(color: Colors.black, fontSize: 12),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user