mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 15:47:44 +00:00
Compare commits
1 Commits
bugfix/SP-
...
feat/updat
Author | SHA1 | Date | |
---|---|---|---|
4896b6c593 |
@ -309,6 +309,8 @@ class SpaceManagementBloc
|
|||||||
await _api.deleteSpace(communityUuid, parent.uuid!);
|
await _api.deleteSpace(communityUuid, parent.uuid!);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print(
|
||||||
|
'Error deleting space ${parent.name} (UUID: ${parent.uuid}, Community UUID: $communityUuid): $e');
|
||||||
rethrow; // Decide whether to stop execution or continue
|
rethrow; // Decide whether to stop execution or continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,6 +342,7 @@ class SpaceManagementBloc
|
|||||||
space.uuid = response?.uuid;
|
space.uuid = response?.uuid;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print('Error creating space ${space.name}: $e');
|
||||||
rethrow; // Stop further execution on failure
|
rethrow; // Stop further execution on failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,13 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
isNameFieldInvalid = value.isEmpty;
|
isNameFieldInvalid = value.isEmpty;
|
||||||
|
|
||||||
if (!isNameFieldInvalid) {
|
if (!isNameFieldInvalid) {
|
||||||
if (_isNameConflict(value)) {
|
if ((widget.parentSpace?.children.any(
|
||||||
|
(child) => child.name == value) ??
|
||||||
|
false) ||
|
||||||
|
(widget.parentSpace?.name == value) ||
|
||||||
|
(widget.editSpace?.children.any(
|
||||||
|
(child) => child.name == value) ??
|
||||||
|
false)) {
|
||||||
isNameFieldExist = true;
|
isNameFieldExist = true;
|
||||||
isOkButtonEnabled = false;
|
isOkButtonEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
@ -381,14 +387,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isNameConflict(String value) {
|
|
||||||
return (widget.parentSpace?.children.any((child) => child.name == value) ??
|
|
||||||
false) ||
|
|
||||||
(widget.parentSpace?.name == value) ||
|
|
||||||
(widget.editSpace?.parent?.name == value) ||
|
|
||||||
(widget.editSpace?.children.any((child) => child.name == value) ??
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _mapIconToProduct(String uuid, List<ProductModel> products) {
|
String _mapIconToProduct(String uuid, List<ProductModel> products) {
|
||||||
// Find the product with the matching UUID
|
// Find the product with the matching UUID
|
||||||
|
@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/routiens/models/routine_details_model.dart';
|
|||||||
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.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/api_const.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||||
|
|
||||||
class SceneApi {
|
class SceneApi {
|
||||||
static final HTTPService _httpService = HTTPService();
|
static final HTTPService _httpService = HTTPService();
|
||||||
@ -76,7 +77,8 @@ class SceneApi {
|
|||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getUnitScenes
|
path: ApiEndpoints.getUnitScenes
|
||||||
.replaceAll('{spaceUuid}', unitId)
|
.replaceAll('{spaceUuid}', unitId)
|
||||||
.replaceAll('{communityUuid}', communityId),
|
.replaceAll('{communityUuid}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
queryParameters: {'showInHomePage': showInDevice},
|
queryParameters: {'showInHomePage': showInDevice},
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
|
@ -5,6 +5,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
|
||||||
import 'package:syncrow_web/services/api/http_service.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/api_const.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||||
|
|
||||||
class CommunitySpaceManagementApi {
|
class CommunitySpaceManagementApi {
|
||||||
// Community Management APIs
|
// Community Management APIs
|
||||||
@ -15,7 +16,8 @@ class CommunitySpaceManagementApi {
|
|||||||
|
|
||||||
while (hasNext) {
|
while (hasNext) {
|
||||||
await HTTPService().get(
|
await HTTPService().get(
|
||||||
path: ApiEndpoints.getCommunityList,
|
path: ApiEndpoints.getCommunityList
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
queryParameters: {'page': page},
|
queryParameters: {'page': page},
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<dynamic> jsonData = json['data'];
|
List<dynamic> jsonData = json['data'];
|
||||||
@ -59,7 +61,8 @@ class CommunitySpaceManagementApi {
|
|||||||
String name, String description) async {
|
String name, String description) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.createCommunity,
|
path: ApiEndpoints.createCommunity
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
body: {
|
body: {
|
||||||
'name': name,
|
'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
@ -79,7 +82,8 @@ class CommunitySpaceManagementApi {
|
|||||||
try {
|
try {
|
||||||
final response = await HTTPService().put(
|
final response = await HTTPService().put(
|
||||||
path: ApiEndpoints.updateCommunity
|
path: ApiEndpoints.updateCommunity
|
||||||
.replaceAll('{communityId}', communityId),
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
body: {
|
body: {
|
||||||
'name': name,
|
'name': name,
|
||||||
},
|
},
|
||||||
@ -98,7 +102,8 @@ class CommunitySpaceManagementApi {
|
|||||||
try {
|
try {
|
||||||
final response = await HTTPService().delete(
|
final response = await HTTPService().delete(
|
||||||
path: ApiEndpoints.deleteCommunity
|
path: ApiEndpoints.deleteCommunity
|
||||||
.replaceAll('{communityId}', communityId),
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json['success'] ?? false;
|
return json['success'] ?? false;
|
||||||
},
|
},
|
||||||
@ -113,7 +118,9 @@ class CommunitySpaceManagementApi {
|
|||||||
Future<SpacesResponse> fetchSpaces(String communityId) async {
|
Future<SpacesResponse> fetchSpaces(String communityId) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.listSpaces.replaceAll('{communityId}', communityId),
|
path: ApiEndpoints.listSpaces
|
||||||
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return SpacesResponse.fromJson(json);
|
return SpacesResponse.fromJson(json);
|
||||||
},
|
},
|
||||||
@ -139,7 +146,8 @@ class CommunitySpaceManagementApi {
|
|||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.getSpace
|
path: ApiEndpoints.getSpace
|
||||||
.replaceAll('{communityId}', communityId)
|
.replaceAll('{communityId}', communityId)
|
||||||
.replaceAll('{spaceId}', spaceId),
|
.replaceAll('{spaceId}', spaceId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return SpaceModel.fromJson(json);
|
return SpaceModel.fromJson(json);
|
||||||
},
|
},
|
||||||
@ -175,7 +183,9 @@ class CommunitySpaceManagementApi {
|
|||||||
body['parentUuid'] = parentId;
|
body['parentUuid'] = parentId;
|
||||||
}
|
}
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.createSpace.replaceAll('{communityId}', communityId),
|
path: ApiEndpoints.createSpace
|
||||||
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
body: body,
|
body: body,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return SpaceModel.fromJson(json['data']);
|
return SpaceModel.fromJson(json['data']);
|
||||||
@ -216,7 +226,8 @@ class CommunitySpaceManagementApi {
|
|||||||
final response = await HTTPService().put(
|
final response = await HTTPService().put(
|
||||||
path: ApiEndpoints.updateSpace
|
path: ApiEndpoints.updateSpace
|
||||||
.replaceAll('{communityId}', communityId)
|
.replaceAll('{communityId}', communityId)
|
||||||
.replaceAll('{spaceId}', spaceId),
|
.replaceAll('{spaceId}', spaceId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
body: body,
|
body: body,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return SpaceModel.fromJson(json['data']);
|
return SpaceModel.fromJson(json['data']);
|
||||||
@ -234,7 +245,8 @@ class CommunitySpaceManagementApi {
|
|||||||
final response = await HTTPService().delete(
|
final response = await HTTPService().delete(
|
||||||
path: ApiEndpoints.deleteSpace
|
path: ApiEndpoints.deleteSpace
|
||||||
.replaceAll('{communityId}', communityId)
|
.replaceAll('{communityId}', communityId)
|
||||||
.replaceAll('{spaceId}', spaceId),
|
.replaceAll('{spaceId}', spaceId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json['success'] ?? false;
|
return json['success'] ?? false;
|
||||||
},
|
},
|
||||||
@ -250,7 +262,8 @@ class CommunitySpaceManagementApi {
|
|||||||
try {
|
try {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.getSpaceHierarchy
|
path: ApiEndpoints.getSpaceHierarchy
|
||||||
.replaceAll('{communityId}', communityId),
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', TempConst.projectId),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final spaceModels = (json['data'] as List)
|
final spaceModels = (json['data'] as List)
|
||||||
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
|
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
|
||||||
|
@ -36,21 +36,21 @@ abstract class ApiEndpoints {
|
|||||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
||||||
|
|
||||||
// Space Module
|
// Space Module
|
||||||
static const String createSpace = '/communities/{communityId}/spaces';
|
static const String createSpace = '/projects/{projectId}/communities/{communityId}/spaces';
|
||||||
static const String listSpaces = '/communities/{communityId}/spaces';
|
static const String listSpaces = '/projects/{projectId}/communities/{communityId}/spaces';
|
||||||
static const String deleteSpace = '/communities/{communityId}/spaces/{spaceId}';
|
static const String deleteSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
|
||||||
static const String updateSpace = '/communities/{communityId}/spaces/{spaceId}';
|
static const String updateSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
|
||||||
static const String getSpace = '/communities/{communityId}/spaces/{spaceId}';
|
static const String getSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
|
||||||
static const String getSpaceHierarchy = '/communities/{communityId}/spaces';
|
static const String getSpaceHierarchy = '/projects/{projectId}/communities/{communityId}/spaces';
|
||||||
|
|
||||||
// Community Module
|
// Community Module
|
||||||
static const String createCommunity = '/communities';
|
static const String createCommunity = '/projects/{projectId}/communities';
|
||||||
static const String getCommunityList = '/communities';
|
static const String getCommunityList = '/projects/{projectId}/communities';
|
||||||
static const String getCommunityById = '/communities/{communityId}';
|
static const String getCommunityById = '/projects/{projectId}/communities/{communityId}';
|
||||||
static const String updateCommunity = '/communities/{communityId}';
|
static const String updateCommunity = '/projects/{projectId}/communities/{communityId}';
|
||||||
static const String deleteCommunity = '/communities/{communityId}';
|
static const String deleteCommunity = '/projects/{projectId}communities/{communityId}';
|
||||||
static const String getUserCommunities = '/communities/user/{userUuid}';
|
static const String getUserCommunities = '/projects/{projectId}/communities/user/{userUuid}';
|
||||||
static const String createUserCommunity = '/communities/user';
|
static const String createUserCommunity = '/projects/{projectId}/communities/user';
|
||||||
static const String getDeviceLogsByDate =
|
static const String getDeviceLogsByDate =
|
||||||
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String getIconScene = '/scene/icon';
|
static const String getIconScene = '/scene/icon';
|
||||||
static const String createScene = '/scene/tap-to-run';
|
static const String createScene = '/scene/tap-to-run';
|
||||||
static const String createAutomation = '/automation';
|
static const String createAutomation = '/automation';
|
||||||
static const String getUnitScenes = '/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
|
static const String getUnitScenes = '/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
|
||||||
static const String getAutomationDetails = '/automation/details/{automationId}';
|
static const String getAutomationDetails = '/automation/details/{automationId}';
|
||||||
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
3
lib/utils/constants/temp_const.dart
Normal file
3
lib/utils/constants/temp_const.dart
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class TempConst {
|
||||||
|
static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c';
|
||||||
|
}
|
Reference in New Issue
Block a user