mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 10:17:54 +00:00
fetchDevices by projectUuid
This commit is contained in:
@@ -51,7 +51,8 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
|
||||
spaceUuid: event.unit.id,
|
||||
roomId: event.roomId,
|
||||
projectId: project?.uuid ?? TempConst.projectIdDev);
|
||||
allDevices = await HomeManagementAPI.fetchDevicesByUserId();
|
||||
allDevices = await HomeManagementAPI.fetchDevices(
|
||||
project?.uuid ?? TempConst.projectIdDev);
|
||||
|
||||
List<String> allDevicesIds = [];
|
||||
|
||||
|
||||
@@ -28,8 +28,7 @@ class AssignDeviceView extends StatelessWidget {
|
||||
listener: (context, state) {
|
||||
if (state is FetchDeviceByRoomIdState) {
|
||||
if (state.allDevices.isEmpty) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'You do not have the permission to assign devices');
|
||||
CustomSnackBar.displaySnackBar('You do not have the devices');
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ abstract class ApiEndpoints {
|
||||
//SPACE Module
|
||||
//GET
|
||||
static const String userSpaces = '/user/{userUuid}/spaces';
|
||||
static const String devices = '/projects/{projectUuid}/devices';
|
||||
|
||||
static const String spaceDevices =
|
||||
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
||||
|
||||
|
||||
@@ -27,7 +27,23 @@ class HomeManagementAPI {
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> fetchDevicesByUnitId(String projectUuid) async {
|
||||
static Future<List<DeviceModel>> fetchDevices(projectUuid) async {
|
||||
List<DeviceModel> list = [];
|
||||
|
||||
await _httpService.get(
|
||||
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
json.forEach((value) {
|
||||
list.add(DeviceModel.fromJson(value));
|
||||
});
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> fetchDevicesByUnitId(
|
||||
String projectUuid) async {
|
||||
List<DeviceModel> list = [];
|
||||
|
||||
try {
|
||||
@@ -62,8 +78,12 @@ class HomeManagementAPI {
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> assignDeviceToRoom(String communityId,
|
||||
String spaceId, String subSpaceId, String deviceId, String projectId) async {
|
||||
static Future<Map<String, dynamic>> assignDeviceToRoom(
|
||||
String communityId,
|
||||
String spaceId,
|
||||
String subSpaceId,
|
||||
String deviceId,
|
||||
String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.assignDeviceToRoom
|
||||
@@ -82,8 +102,12 @@ class HomeManagementAPI {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> unAssignDeviceToRoom(String communityId,
|
||||
String spaceId, String subSpaceId, String deviceId, String projectId) async {
|
||||
static Future<Map<String, dynamic>> unAssignDeviceToRoom(
|
||||
String communityId,
|
||||
String spaceId,
|
||||
String subSpaceId,
|
||||
String deviceId,
|
||||
String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.assignDeviceToRoom
|
||||
|
||||
Reference in New Issue
Block a user