Implemented side tree to devices and rountines screen

This commit is contained in:
Abdullah Alassaf
2025-01-04 17:45:15 +03:00
parent 0341844ea9
commit a98f7e77a3
88 changed files with 1551 additions and 1202 deletions

View File

@ -9,12 +9,18 @@ import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/constants/api_const.dart';
import 'package:syncrow_web/utils/constants/temp_const.dart';
class DevicesManagementApi {
Future<List<AllDevicesModel>> fetchDevices() async {
Future<List<AllDevicesModel>> fetchDevices(String communityId, String spaceId) async {
try {
final response = await HTTPService().get(
path: ApiEndpoints.getAllDevices,
path: communityId.isNotEmpty && spaceId.isNotEmpty
? ApiEndpoints.getSpaceDevices
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectId}', TempConst.projectId)
: ApiEndpoints.getAllDevices,
showServerMessage: true,
expectedResponseModel: (json) {
List<dynamic> jsonData = json;
@ -85,8 +91,7 @@ class DevicesManagementApi {
}
}
Future<bool> deviceBatchControl(
List<String> uuids, String code, dynamic value) async {
Future<bool> deviceBatchControl(List<String> uuids, String code, dynamic value) async {
try {
final body = {
'devicesUuid': uuids,
@ -110,8 +115,7 @@ class DevicesManagementApi {
}
}
static Future<List<DeviceModel>> getDevicesByGatewayId(
String gatewayId) async {
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
final response = await HTTPService().get(
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
showServerMessage: false,
@ -145,9 +149,7 @@ class DevicesManagementApi {
String code,
) async {
final response = await HTTPService().get(
path: ApiEndpoints.getDeviceLogs
.replaceAll('{uuid}', uuid)
.replaceAll('{code}', code),
path: ApiEndpoints.getDeviceLogs.replaceAll('{uuid}', uuid).replaceAll('{code}', code),
showServerMessage: false,
expectedResponseModel: (json) {
return DeviceReport.fromJson(json);
@ -220,8 +222,7 @@ class DevicesManagementApi {
}
}
Future<bool> addScheduleRecord(
ScheduleEntry sendSchedule, String uuid) async {
Future<bool> addScheduleRecord(ScheduleEntry sendSchedule, String uuid) async {
try {
final response = await HTTPService().post(
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
@ -238,8 +239,7 @@ class DevicesManagementApi {
}
}
Future<List<ScheduleModel>> getDeviceSchedules(
String uuid, String category) async {
Future<List<ScheduleModel>> getDeviceSchedules(String uuid, String category) async {
try {
final response = await HTTPService().get(
path: ApiEndpoints.getScheduleByDeviceId
@ -262,9 +262,7 @@ class DevicesManagementApi {
}
Future<bool> updateScheduleRecord(
{required bool enable,
required String uuid,
required String scheduleId}) async {
{required bool enable, required String uuid, required String scheduleId}) async {
try {
final response = await HTTPService().put(
path: ApiEndpoints.updateScheduleByDeviceId
@ -285,8 +283,7 @@ class DevicesManagementApi {
}
}
Future<bool> editScheduleRecord(
String uuid, ScheduleEntry newSchedule) async {
Future<bool> editScheduleRecord(String uuid, ScheduleEntry newSchedule) async {
try {
final response = await HTTPService().put(
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),