Compare commits

..

1 Commits

Author SHA1 Message Date
22935f7007 SP-1271-rework 2025-03-27 14:52:26 +03:00
10 changed files with 172 additions and 320 deletions

View File

@ -2,17 +2,14 @@ import 'package:flutter/foundation.dart';
class FactoryResetModel { class FactoryResetModel {
final List<String> devicesUuid; final List<String> devicesUuid;
final String operationType;
FactoryResetModel({ FactoryResetModel({
required this.devicesUuid, required this.devicesUuid,
this.operationType = "RESET",
}); });
factory FactoryResetModel.fromJson(Map<String, dynamic> json) { factory FactoryResetModel.fromJson(Map<String, dynamic> json) {
return FactoryResetModel( return FactoryResetModel(
devicesUuid: List<String>.from(json['devicesUuid']), devicesUuid: List<String>.from(json['devicesUuid']),
operationType: "RESET",
); );
} }

View File

@ -14,34 +14,12 @@ class DeviceSearchFilters extends StatefulWidget {
class _DeviceSearchFiltersState extends State<DeviceSearchFilters> class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
with HelperResponsiveLayout { with HelperResponsiveLayout {
late final TextEditingController _unitNameController; final _unitNameController = TextEditingController();
late final TextEditingController _productNameController; final _productNameController = TextEditingController();
@override
void initState() {
_unitNameController = TextEditingController();
_productNameController = TextEditingController();
super.initState();
}
@override
void dispose() {
_unitNameController.dispose();
_productNameController.dispose();
super.dispose();
}
List<Widget> get _widgets => [ List<Widget> get _widgets => [
_buildSearchField( _buildSearchField("Space Name", _unitNameController, 200),
"Space Name", _buildSearchField("Device Name / Product Name", _productNameController, 300),
_unitNameController,
200,
),
_buildSearchField(
"Device Name / Product Name",
_productNameController,
300,
),
_buildSearchResetButtons(), _buildSearchResetButtons(),
]; ];
@ -49,14 +27,9 @@ class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isExtraLargeScreenSize(context)) { if (isExtraLargeScreenSize(context)) {
return Row( return Row(
children: _widgets.map( children: _widgets
(e) { .map((e) => Padding(padding: const EdgeInsets.all(10), child: e))
return Padding( .toList(),
padding: const EdgeInsets.symmetric(vertical: 10),
child: e,
);
},
).toList(),
); );
} }

View File

@ -1,16 +1,16 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart'; import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart'; import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/style.dart';
class CommunityDropdown extends StatelessWidget { class CommunityDropdown extends StatelessWidget {
final String? selectedValue; final String? selectedValue;
final Function(String?) onChanged; final Function(String?) onChanged;
final TextEditingController _searchController = TextEditingController();
CommunityDropdown({ const CommunityDropdown({
Key? key, Key? key,
required this.selectedValue, required this.selectedValue,
required this.onChanged, required this.onChanged,
@ -34,125 +34,59 @@ class CommunityDropdown extends StatelessWidget {
const SizedBox(height: 8), const SizedBox(height: 8),
BlocBuilder<SpaceTreeBloc, SpaceTreeState>( BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
builder: (context, state) { builder: (context, state) {
List<CommunityModel> communities = state.isSearching
? state.filteredCommunity
: state.communityList;
return SizedBox( return SizedBox(
child: Container( child: DropdownButtonFormField<String>(
decoration: BoxDecoration( dropdownColor: ColorsManager.whiteColors,
borderRadius: BorderRadius.circular(10),
),
child: DropdownButton2<String>(
underline: SizedBox(),
value: selectedValue, value: selectedValue,
items: state.communityList.map((community) { items: communities.map((community) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: community.uuid, value: community.uuid,
child: Text( child: Text(' ${community.name}'),
' ${community.name}',
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
); );
}).toList(), }).toList(),
onChanged: onChanged, onChanged: onChanged,
style: TextStyle(color: Colors.black), icon: const SizedBox.shrink(),
borderRadius: const BorderRadius.all(Radius.circular(10)),
hint: Padding( hint: Padding(
padding: EdgeInsets.only(left: 10), padding: EdgeInsets.only(left: 10),
child: Text( child: Text(
" Please Select", "Please Select",
style: Theme.of(context).textTheme.bodySmall!.copyWith( style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.textGray, color: ColorsManager.textGray,
), ),
), ),
), ),
customButton: Container( decoration: inputTextFormDeco().copyWith(
contentPadding: EdgeInsets.zero,
suffixIcon: Container(
padding: EdgeInsets.zero,
width: 70,
height: 45, height: 45,
decoration: BoxDecoration(
border:
Border.all(color: ColorsManager.textGray, width: 1.0),
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 5,
child: Text(
selectedValue != null
? " ${state.communityList.firstWhere((element) => element.uuid == selectedValue).name}"
: ' Please Select',
style:
Theme.of(context).textTheme.bodySmall!.copyWith(
color: selectedValue != null
? Colors.black
: ColorsManager.textGray,
),
overflow: TextOverflow.ellipsis,
),
),
Expanded(
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[100], color: Colors.grey[100],
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10), bottomRight: Radius.circular(10),
topRight: Radius.circular(10),
),
border: Border.all(
color: ColorsManager.textGray,
width: 1.0,
), ),
), ),
height: 45, child: const Center(
child: const Icon( child: Icon(
Icons.keyboard_arrow_down, Icons.keyboard_arrow_down,
color: ColorsManager.textGray, color: ColorsManager.textGray,
), ),
), ),
), ),
],
), ),
), ),
dropdownStyleData: DropdownStyleData( );
maxHeight: MediaQuery.of(context).size.height * 0.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
),
dropdownSearchData: DropdownSearchData(
searchController: _searchController,
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
child: TextFormField(
style: const TextStyle(color: Colors.black),
controller: _searchController,
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 12,
),
hintText: 'Search for community...',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
final communityName =
(item.child as Text).data?.toLowerCase() ?? '';
return communityName
.contains(searchValue.toLowerCase().trim());
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
_searchController.clear();
}
},
menuItemStyleData: const MenuItemStyleData(
height: 40,
),
),
));
}, },
), ),
], ],

View File

@ -62,9 +62,7 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Divider(), const Divider(),
Padding( CommunityDropdown(
padding: const EdgeInsets.only(left: 15, right: 15),
child: CommunityDropdown(
selectedValue: _selectedCommunity, selectedValue: _selectedCommunity,
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
@ -76,11 +74,8 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
} }
}, },
), ),
), const SizedBox(height: 16),
const SizedBox(height: 5), SpaceDropdown(
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: SpaceDropdown(
hintMessage: spaceHint, hintMessage: spaceHint,
spaces: spaces, spaces: spaces,
selectedValue: _selectedSpace, selectedValue: _selectedSpace,
@ -90,7 +85,6 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
}); });
}, },
), ),
),
const Divider(), const Divider(),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -102,6 +96,7 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
), ),
child: TextButton( child: TextButton(
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text( child: Text(
@ -144,7 +139,6 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
), ),
], ],
), ),
SizedBox(height: 10),
], ],
), ),
); );

View File

@ -1,8 +1,7 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart'; import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/style.dart';
class SpaceDropdown extends StatelessWidget { class SpaceDropdown extends StatelessWidget {
final List<SpaceModel> spaces; final List<SpaceModel> spaces;
@ -34,13 +33,7 @@ class SpaceDropdown extends StatelessWidget {
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
SizedBox( DropdownButtonFormField<String>(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
child: DropdownButton2<String>(
underline: const SizedBox(),
value: selectedValue, value: selectedValue,
items: spaces.map((space) { items: spaces.map((space) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
@ -51,25 +44,23 @@ class SpaceDropdown extends StatelessWidget {
children: [ children: [
Text( Text(
' ${space.name}', ' ${space.name}',
style: style: Theme.of(context).textTheme.bodyMedium!.copyWith(
Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 12, fontSize: 12,
color: ColorsManager.blackColor, color: ColorsManager.blackColor,
), ),
), ),
Text( Text(
' ${space.lastThreeParents}', ' ${space.lastThreeParents}',
style: style: Theme.of(context).textTheme.bodyMedium!.copyWith(
Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 12, fontSize: 12,
), ),
), ),
], ],
), ));
);
}).toList(), }).toList(),
onChanged: onChanged, onChanged: onChanged,
style: TextStyle(color: Colors.black), icon: const SizedBox.shrink(),
borderRadius: const BorderRadius.all(Radius.circular(10)),
hint: Padding( hint: Padding(
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: Text( child: Text(
@ -79,66 +70,28 @@ class SpaceDropdown extends StatelessWidget {
), ),
), ),
), ),
customButton: Container( decoration: inputTextFormDeco().copyWith(
contentPadding: EdgeInsets.zero,
suffixIcon: Container(
width: 70,
height: 45, height: 45,
decoration: BoxDecoration(
border:
Border.all(color: ColorsManager.textGray, width: 1.0),
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 5,
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
selectedValue != null
? spaces
.firstWhere((e) => e.uuid == selectedValue)
.name
: hintMessage,
style:
Theme.of(context).textTheme.bodySmall!.copyWith(
color: selectedValue != null
? Colors.black
: ColorsManager.textGray,
),
overflow: TextOverflow.ellipsis,
),
),
),
Expanded(
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[200], color: Colors.grey[200],
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10), bottomRight: Radius.circular(10),
topRight: Radius.circular(10),
),
border: Border.all(
color: ColorsManager.textGray,
width: 1.0,
), ),
), ),
height: 45,
child: const Icon( child: const Icon(
Icons.keyboard_arrow_down, Icons.keyboard_arrow_down,
color: ColorsManager.textGray, color: ColorsManager.textGray,
), ),
), ),
), ),
],
),
),
dropdownStyleData: DropdownStyleData(
maxHeight: MediaQuery.of(context).size.height * 0.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 60,
),
),
),
), ),
], ],
), ),

View File

@ -33,6 +33,8 @@ class _RoutinesViewState extends State<RoutinesView> {
communityID: communityId, spaceID: spaceId)); communityID: communityId, spaceID: spaceId));
await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 1));
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true)); routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
await Future.delayed(const Duration(milliseconds:500));
_bloc.add(const ResetSelectedEvent());
} }
@override @override

View File

@ -194,10 +194,9 @@ class VisitorPasswordBloc
emit(DeviceLoaded()); emit(DeviceLoaded());
final projectUuid = await ProjectManager.getProjectUUID() ?? ''; final projectUuid = await ProjectManager.getProjectUUID() ?? '';
data = await AccessMangApi().fetchDoorLockDeviceList(projectUuid); data = await AccessMangApi().fetchDevices(projectUuid);
emit(TableLoaded(data)); emit(TableLoaded(data));
} catch (e) { } catch (e) {
print("error: $e");
emit(FailedState(e.toString())); emit(FailedState(e.toString()));
} }
} }

View File

@ -6,23 +6,13 @@ import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/constants/api_const.dart'; import 'package:syncrow_web/utils/constants/api_const.dart';
class AccessMangApi { class AccessMangApi {
AccessMangApi() {
_validateEndpoints();
}
void _validateEndpoints() {
if (!ApiEndpoints.getDevices.contains('{projectId}')) {
throw Exception("Endpoint 'getDevices' must contain '{projectId}' placeholder.");
}
}
Future<List<PasswordModel>> fetchVisitorPassword(String projectId) async { Future<List<PasswordModel>> fetchVisitorPassword(String projectId) async {
try { try {
final response = await HTTPService().get( final response = await HTTPService().get(
path: ApiEndpoints.visitorPassword, path: ApiEndpoints.visitorPassword.replaceAll('{projectId}', projectId),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
List<dynamic> jsonData = json['data'] ?? []; List<dynamic> jsonData = json;
List<PasswordModel> passwordList = jsonData.map((jsonItem) { List<PasswordModel> passwordList = jsonData.map((jsonItem) {
return PasswordModel.fromJson(jsonItem); return PasswordModel.fromJson(jsonItem);
}).toList(); }).toList();
@ -35,22 +25,17 @@ class AccessMangApi {
} }
} }
Future fetchDoorLockDeviceList(String projectId) async { Future fetchDevices(String projectId) async {
try { try {
// The endpoint structure is already validated during initialization.
final response = await HTTPService().get( final response = await HTTPService().get(
path: ApiEndpoints.getDevices.replaceAll('{projectId}', projectId), path: ApiEndpoints.getDevices.replaceAll('{projectId}', projectId),
queryParameters: {
'deviceType': 'DOOR_LOCK',
},
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
List<dynamic> jsonData = json['data'] ?? []; List<dynamic> jsonData = json;
List<DeviceModel> deviceList = jsonData.map((jsonItem) { List<DeviceModel> passwordList = jsonData.map((jsonItem) {
return DeviceModel.fromJson(jsonItem); return DeviceModel.fromJson(jsonItem);
}).toList(); }).toList();
return deviceList; return passwordList;
}, },
); );
return response; return response;
@ -67,15 +52,14 @@ class AccessMangApi {
String? invalidTime, String? invalidTime,
List<String>? devicesUuid}) async { List<String>? devicesUuid}) async {
final response = await HTTPService().post( final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword, path: ApiEndpoints.sendOnlineOneTime,
body: jsonEncode({ body: jsonEncode({
"email": email, "email": email,
"passwordName": passwordName, "passwordName": passwordName,
"password": password, "password": password,
"devicesUuid": devicesUuid, "devicesUuid": devicesUuid,
"effectiveTime": effectiveTime, "effectiveTime": effectiveTime,
"invalidTime": invalidTime, "invalidTime": invalidTime
"operationType": "ONLINE_ONE_TIME",
}), }),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
@ -100,13 +84,13 @@ class AccessMangApi {
"password": password, "password": password,
"effectiveTime": effectiveTime, "effectiveTime": effectiveTime,
"invalidTime": invalidTime, "invalidTime": invalidTime,
"operationType": "ONLINE_MULTIPLE_TIME",
}; };
if (scheduleList != null) { if (scheduleList != null) {
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList(); body["scheduleList"] =
scheduleList.map((schedule) => schedule.toJson()).toList();
} }
final response = await HTTPService().post( final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword, path: ApiEndpoints.sendOnlineMultipleTime,
body: jsonEncode(body), body: jsonEncode(body),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
@ -121,9 +105,8 @@ class AccessMangApi {
Future postOffLineOneTime( Future postOffLineOneTime(
{String? email, String? passwordName, List<String>? devicesUuid}) async { {String? email, String? passwordName, List<String>? devicesUuid}) async {
final response = await HTTPService().post( final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword, path: ApiEndpoints.sendOffLineOneTime,
body: jsonEncode({ body: jsonEncode({
"operationType": "OFFLINE_ONE_TIME",
"email": email, "email": email,
"passwordName": passwordName, "passwordName": passwordName,
"devicesUuid": devicesUuid "devicesUuid": devicesUuid
@ -143,14 +126,13 @@ class AccessMangApi {
String? invalidTime, String? invalidTime,
List<String>? devicesUuid}) async { List<String>? devicesUuid}) async {
final response = await HTTPService().post( final response = await HTTPService().post(
path: ApiEndpoints.visitorPassword, path: ApiEndpoints.sendOffLineMultipleTime,
body: jsonEncode({ body: jsonEncode({
"email": email, "email": email,
"devicesUuid": devicesUuid, "devicesUuid": devicesUuid,
"passwordName": passwordName, "passwordName": passwordName,
"effectiveTime": effectiveTime, "effectiveTime": effectiveTime,
"invalidTime": invalidTime, "invalidTime": invalidTime,
"operationType": "OFFLINE_MULTIPLE_TIME",
}), }),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {

View File

@ -23,8 +23,9 @@ class DevicesManagementApi {
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId), : ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
List<dynamic> jsonData = List<dynamic> jsonData = communityId.isNotEmpty && spaceId.isNotEmpty
communityId.isNotEmpty && spaceId.isNotEmpty ? json['data'] : json['data']; ? json['data']
: json;
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) { List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
return AllDevicesModel.fromJson(jsonItem); return AllDevicesModel.fromJson(jsonItem);
}).toList(); }).toList();
@ -33,7 +34,7 @@ class DevicesManagementApi {
); );
return response; return response;
} catch (e) { } catch (e) {
debugPrint('Error fetching device $e'); debugPrint('fetchDevices Error fetching $e');
return []; return [];
} }
} }
@ -44,7 +45,7 @@ class DevicesManagementApi {
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid), path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return DeviceStatus.fromJson(json['data']); return DeviceStatus.fromJson(json);
}, },
); );
return response; return response;
@ -61,7 +62,7 @@ class DevicesManagementApi {
Future getPowerClampInfo(String deviceId) async { Future getPowerClampInfo(String deviceId) async {
try { try {
final response = await HTTPService().get( final response = await HTTPService().get(
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', deviceId), path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json; return json;
@ -99,7 +100,6 @@ class DevicesManagementApi {
'devicesUuid': uuids, 'devicesUuid': uuids,
'code': code, 'code': code,
'value': value, 'value': value,
'operationType': 'COMMAND',
}; };
final response = await HTTPService().post( final response = await HTTPService().post(
@ -107,7 +107,7 @@ class DevicesManagementApi {
body: body, body: body,
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json['success'] ?? false; return (json['successResults'] as List).isNotEmpty;
}, },
); );
@ -128,7 +128,7 @@ class DevicesManagementApi {
if (json == null || json.isEmpty || json == []) { if (json == null || json.isEmpty || json == []) {
return devices; return devices;
} }
for (var device in json['data']['devices']) { for (var device in json['devices']) {
devices.add(DeviceModel.fromJson(device)); devices.add(DeviceModel.fromJson(device));
} }
return devices; return devices;
@ -158,7 +158,7 @@ class DevicesManagementApi {
.replaceAll('{code}', code), .replaceAll('{code}', code),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return DeviceReport.fromJson(json['data']); return DeviceReport.fromJson(json);
}, },
); );
return response; return response;
@ -174,7 +174,7 @@ class DevicesManagementApi {
.replaceAll('{endTime}', to ?? ''), .replaceAll('{endTime}', to ?? ''),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return DeviceReport.fromJson(json['data']); return DeviceReport.fromJson(json);
}, },
); );
return response; return response;
@ -190,7 +190,7 @@ class DevicesManagementApi {
queryParameters: queryParameters, queryParameters: queryParameters,
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return DeviceStatus.fromJson(json['data']['status']); return DeviceStatus.fromJson(json['status']);
}, },
); );
return response; return response;

View File

@ -9,8 +9,21 @@ abstract class ApiEndpoints {
static const String sendOtp = '/authentication/user/send-otp'; static const String sendOtp = '/authentication/user/send-otp';
static const String verifyOtp = '/authentication/user/verify-otp'; static const String verifyOtp = '/authentication/user/verify-otp';
static const String getRegion = '/region'; static const String getRegion = '/region';
static const String visitorPassword = '/visitor-passwords'; static const String visitorPassword =
static const String getDevices = '/projects/{projectId}/devices'; '/projects/{projectId}/visitor-password';
static const String getDevices =
'/projects/{projectId}/visitor-password/devices';
static const String sendOnlineOneTime =
'/visitor-password/temporary-password/online/one-time';
static const String sendOnlineMultipleTime =
'/visitor-password/temporary-password/online/multiple-time';
//offline Password
static const String sendOffLineOneTime =
'/visitor-password/temporary-password/offline/one-time';
static const String sendOffLineMultipleTime =
'/visitor-password/temporary-password/offline/multiple-time';
static const String getUser = '/user/{userUuid}'; static const String getUser = '/user/{userUuid}';
@ -19,15 +32,15 @@ abstract class ApiEndpoints {
static const String getAllDevices = '/projects/{projectId}/devices'; static const String getAllDevices = '/projects/{projectId}/devices';
static const String getSpaceDevices = static const String getSpaceDevices =
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices'; '/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
static const String getDeviceStatus = '/devices/{uuid}/functions/status'; static const String getDeviceStatus = '/device/{uuid}/functions/status';
static const String getBatchStatus = '/devices/batch'; static const String getBatchStatus = '/device/status/batch';
static const String deviceControl = '/devices/{uuid}/command'; static const String deviceControl = '/device/{uuid}/control';
static const String deviceBatchControl = '/devices/batch'; static const String deviceBatchControl = '/device/control/batch';
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices'; static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
static const String openDoorLock = '/door-lock/open/{doorLockUuid}'; static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
static const String getDeviceLogs = '/devices/{uuid}/report-logs?code={code}'; static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
// Space Module // Space Module
static const String createSpace = static const String createSpace =
@ -57,13 +70,18 @@ abstract class ApiEndpoints {
static const String createUserCommunity = static const String createUserCommunity =
'/projects/{projectId}/communities/user'; '/projects/{projectId}/communities/user';
static const String getDeviceLogsByDate = static const String getDeviceLogsByDate =
'/devices/{uuid}/report-logs?code={code}&startTime={startTime}&endTime={endTime}'; '/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
static const String scheduleByDeviceId = '/schedule/{deviceUuid}'; static const String scheduleByDeviceId = '/schedule/{deviceUuid}';
static const String getScheduleByDeviceId = '/schedule/{deviceUuid}?category={category}'; static const String getScheduleByDeviceId =
static const String deleteScheduleByDeviceId = '/schedule/{deviceUuid}/{scheduleUuid}'; '/schedule/{deviceUuid}?category={category}';
static const String updateScheduleByDeviceId = '/schedule/enable/{deviceUuid}'; static const String deleteScheduleByDeviceId =
static const String factoryReset = '/devices/batch'; '/schedule/{deviceUuid}/{scheduleUuid}';
static const String updateScheduleByDeviceId =
'/schedule/enable/{deviceUuid}';
static const String factoryReset = '/device/factory/reset/{deviceUuid}';
static const String powerClamp =
'/device/{powerClampUuid}/power-clamp/status';
//product //product
static const String listProducts = '/products'; static const String listProducts = '/products';