mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
create visitor password
This commit is contained in:
@ -171,11 +171,10 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DateTime timestampToDateTime(dynamic timestamp) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
|
||||
String timestampToDate(dynamic timestamp) {
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
|
||||
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'package:syncrow_web/utils/constants/const.dart';
|
||||
|
||||
class PasswordModel {
|
||||
final dynamic passwordId;
|
||||
final dynamic invalidTime;
|
||||
@ -6,7 +8,7 @@ class PasswordModel {
|
||||
final dynamic createdTime;
|
||||
final dynamic passwodName; // New field
|
||||
final dynamic passwordStatus;
|
||||
final dynamic passwordType;
|
||||
final AccessType passwordType;
|
||||
final dynamic deviceUuid;
|
||||
|
||||
PasswordModel({
|
||||
@ -17,7 +19,7 @@ class PasswordModel {
|
||||
this.createdTime,
|
||||
this.passwodName, // New field
|
||||
this.passwordStatus,
|
||||
this.passwordType,
|
||||
required this.passwordType,
|
||||
this.deviceUuid,
|
||||
});
|
||||
|
||||
@ -30,7 +32,7 @@ class PasswordModel {
|
||||
createdTime: json['createdTime'],
|
||||
passwodName: json['passwodName']??'No name', // New field
|
||||
passwordStatus: json['passwordStatus'],
|
||||
passwordType: json['passwordType'],
|
||||
passwordType:AccessTypeExtension.fromString(json['passwordType']) ,
|
||||
deviceUuid: json['deviceUuid'],
|
||||
);
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
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/custom_table.dart';
|
||||
import 'package:syncrow_web/pages/common/date_time_widget.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/const.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||
|
||||
@ -51,68 +53,69 @@ class AccessManagementPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
height: size.height * 0.05,
|
||||
width:size.width * 0.26 ,
|
||||
decoration: containerDecoration,
|
||||
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,
|
||||
height: size.height * 0.05,
|
||||
child: Flexible(
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: BlocProvider.of<AccessBloc>(context).tabs.length,
|
||||
shrinkWrap: true,
|
||||
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,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Password Name'),
|
||||
const Text('Name'),
|
||||
Container(
|
||||
width: size.width * 0.15,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
controller: accessBloc.passwordName,
|
||||
style: TextStyle(color: Colors.black),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
@ -206,7 +209,7 @@ class AccessManagementPage extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
borderRadius: 8,
|
||||
child: Text('+ Create Visitor Password ')),
|
||||
child: const Text('+ Create Visitor Password ')),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
@ -230,120 +233,110 @@ class AccessManagementPage extends StatelessWidget {
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: state is TableLoaded
|
||||
? TableWidget(size, state,accessBloc)
|
||||
: const Center(child: CircularProgressIndicator()))
|
||||
child: state is TableLoaded
|
||||
? DynamicTable(
|
||||
size: size,
|
||||
cellDecoration: containerDecoration,
|
||||
headers: const [
|
||||
'Name',
|
||||
'Access Type',
|
||||
'Access Period',
|
||||
'Device Id',
|
||||
'Authorizer',
|
||||
'Authorization Date & Time',
|
||||
'Access Status'
|
||||
],
|
||||
data: state.data.map((item) {
|
||||
return [
|
||||
item.passwodName.toString(),
|
||||
item.passwordType.value,
|
||||
('${accessBloc.timestampToDate(item.effectiveTime)} - ${accessBloc.timestampToDate(item.invalidTime)}'),
|
||||
item.deviceUuid.toString(),
|
||||
'',
|
||||
'',
|
||||
''
|
||||
];
|
||||
}).toList(),
|
||||
)
|
||||
: 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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// 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))),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(title, style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTableCell(String content) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
height: 80,
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user