mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 17:47:53 +00:00
Compare commits
8 Commits
fix_routin
...
SP-1200
Author | SHA1 | Date | |
---|---|---|---|
76793a3c0b | |||
c330f11206 | |||
9cb62795a6 | |||
a034202d76 | |||
869799f08e | |||
de5030d9f0 | |||
8c15fffd42 | |||
3750fa8329 |
@ -2,14 +2,17 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class FactoryResetModel {
|
||||
final List<String> devicesUuid;
|
||||
final String operationType;
|
||||
|
||||
FactoryResetModel({
|
||||
required this.devicesUuid,
|
||||
this.operationType = "RESET",
|
||||
});
|
||||
|
||||
factory FactoryResetModel.fromJson(Map<String, dynamic> json) {
|
||||
return FactoryResetModel(
|
||||
devicesUuid: List<String>.from(json['devicesUuid']),
|
||||
operationType: "RESET",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -301,11 +301,18 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
SpaceTemplateModel? spaceModel, List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Set the first space in the center or use passed position
|
||||
Offset centerPosition = position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
Offset newPosition;
|
||||
if (parentIndex != null) {
|
||||
newPosition =
|
||||
getBalancedChildPosition(spaces[parentIndex]); // Ensure balanced position
|
||||
} else {
|
||||
newPosition = position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
}
|
||||
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
position: centerPosition,
|
||||
position: newPosition,
|
||||
isPrivate: false,
|
||||
children: [],
|
||||
status: SpaceStatus.newSpace,
|
||||
@ -425,7 +432,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
Connection(
|
||||
startSpace: parent,
|
||||
endSpace: child,
|
||||
direction: child.incomingConnection?.direction ?? "down",
|
||||
direction: "down",
|
||||
),
|
||||
);
|
||||
|
||||
@ -522,6 +529,38 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
);
|
||||
}
|
||||
|
||||
Offset getBalancedChildPosition(SpaceModel parent) {
|
||||
int totalSiblings = parent.children.length + 1;
|
||||
double totalWidth = (totalSiblings - 1) * 250; // Horizontal spacing
|
||||
double startX = parent.position.dx - (totalWidth / 2);
|
||||
|
||||
Offset position = Offset(startX + (parent.children.length * 250), parent.position.dy + 180);
|
||||
|
||||
// Check for overlaps & adjust
|
||||
while (spaces.any((s) => (s.position - position).distance < 250)) {
|
||||
position = Offset(position.dx + 250, position.dy);
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void realignTree() {
|
||||
void updatePositions(SpaceModel node, double x, double y) {
|
||||
node.position = Offset(x, y);
|
||||
|
||||
int numChildren = node.children.length;
|
||||
double childStartX = x - ((numChildren - 1) * 250) / 2;
|
||||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
updatePositions(node.children[i], childStartX + (i * 250), y + 180);
|
||||
}
|
||||
}
|
||||
|
||||
if (spaces.isNotEmpty) {
|
||||
updatePositions(spaces.first, spaces.first.position.dx, spaces.first.position.dy);
|
||||
}
|
||||
}
|
||||
|
||||
void _onDuplicate(BuildContext parentContext) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
@ -604,29 +643,57 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
void _duplicateSpace(SpaceModel space) {
|
||||
final Map<SpaceModel, SpaceModel> originalToDuplicate = {};
|
||||
const double horizontalGap = 200.0;
|
||||
const double verticalGap = 100.0;
|
||||
double horizontalGap = 250.0; // Increased spacing
|
||||
double verticalGap = 180.0; // Adjusted for better visualization
|
||||
|
||||
SpaceModel duplicateRecursive(
|
||||
SpaceModel original, Offset parentPosition, SpaceModel? duplicatedParent) {
|
||||
Offset newPosition = Offset(parentPosition.dx + horizontalGap, original.position.dy);
|
||||
print("🟢 Duplicating: ${space.name}");
|
||||
|
||||
while (spaces.any((s) =>
|
||||
(s.position - newPosition).distance < horizontalGap && s.status != SpaceStatus.deleted)) {
|
||||
newPosition += Offset(horizontalGap, 0);
|
||||
/// **Find a new position ensuring no overlap**
|
||||
Offset getBalancedChildPosition(SpaceModel parent) {
|
||||
int totalSiblings = parent.children.length + 1;
|
||||
double totalWidth = (totalSiblings - 1) * horizontalGap;
|
||||
double startX = parent.position.dx - (totalWidth / 2);
|
||||
Offset position = Offset(
|
||||
startX + (parent.children.length * horizontalGap), parent.position.dy + verticalGap);
|
||||
|
||||
// **Check for overlaps & adjust**
|
||||
while (spaces.any((s) => (s.position - position).distance < horizontalGap)) {
|
||||
position = Offset(position.dx + horizontalGap, position.dy);
|
||||
}
|
||||
|
||||
print("🔹 New position for ${parent.name}: (${position.dx}, ${position.dy})");
|
||||
return position;
|
||||
}
|
||||
|
||||
/// **Realign the entire tree after duplication**
|
||||
void realignTree() {
|
||||
void updatePositions(SpaceModel node, double x, double y) {
|
||||
node.position = Offset(x, y);
|
||||
print("✅ Adjusted ${node.name} to (${x}, ${y})");
|
||||
|
||||
int numChildren = node.children.length;
|
||||
double childStartX = x - ((numChildren - 1) * horizontalGap) / 2;
|
||||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
updatePositions(node.children[i], childStartX + (i * horizontalGap), y + verticalGap);
|
||||
}
|
||||
}
|
||||
|
||||
if (spaces.isNotEmpty) {
|
||||
print("🔄 Realigning tree...");
|
||||
updatePositions(spaces.first, spaces.first.position.dx, spaces.first.position.dy);
|
||||
}
|
||||
}
|
||||
|
||||
/// **Recursive duplication logic**
|
||||
SpaceModel duplicateRecursive(SpaceModel original, SpaceModel? duplicatedParent) {
|
||||
Offset newPosition = duplicatedParent == null
|
||||
? Offset(original.position.dx + horizontalGap, original.position.dy)
|
||||
: getBalancedChildPosition(duplicatedParent);
|
||||
|
||||
final duplicatedName = SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||
|
||||
final List<SubspaceModel>? duplicatedSubspaces;
|
||||
final List<Tag>? duplicatedTags;
|
||||
if (original.spaceModel != null) {
|
||||
duplicatedTags = [];
|
||||
duplicatedSubspaces = [];
|
||||
} else {
|
||||
duplicatedTags = original.tags;
|
||||
duplicatedSubspaces = original.subspaces;
|
||||
}
|
||||
print(
|
||||
"🟡 Duplicating ${original.name} → ${duplicatedName} at (${newPosition.dx}, ${newPosition.dy})");
|
||||
|
||||
final duplicated = SpaceModel(
|
||||
name: duplicatedName,
|
||||
@ -637,12 +704,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
status: SpaceStatus.newSpace,
|
||||
parent: duplicatedParent,
|
||||
spaceModel: original.spaceModel,
|
||||
subspaces: duplicatedSubspaces,
|
||||
tags: duplicatedTags,
|
||||
subspaces: original.subspaces,
|
||||
tags: original.tags,
|
||||
);
|
||||
|
||||
originalToDuplicate[original] = duplicated;
|
||||
|
||||
setState(() {
|
||||
spaces.add(duplicated);
|
||||
_updateNodePosition(duplicated, duplicated.position);
|
||||
@ -651,60 +716,42 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
final newConnection = Connection(
|
||||
startSpace: duplicatedParent,
|
||||
endSpace: duplicated,
|
||||
direction: original.incomingConnection?.direction ?? 'down',
|
||||
direction: "down",
|
||||
);
|
||||
connections.add(newConnection);
|
||||
duplicated.incomingConnection = newConnection;
|
||||
duplicatedParent.addOutgoingConnection(newConnection);
|
||||
duplicatedParent.children.add(duplicated);
|
||||
print("🔗 Created connection: ${duplicatedParent.name} → ${duplicated.name}");
|
||||
}
|
||||
|
||||
if (original.parent != null && duplicatedParent == null) {
|
||||
final originalParent = original.parent!;
|
||||
final duplicatedParent = originalToDuplicate[originalParent] ?? originalParent;
|
||||
|
||||
final parentConnection = Connection(
|
||||
startSpace: duplicatedParent,
|
||||
endSpace: duplicated,
|
||||
direction: original.incomingConnection?.direction ?? "down",
|
||||
);
|
||||
|
||||
connections.add(parentConnection);
|
||||
duplicated.incomingConnection = parentConnection;
|
||||
duplicatedParent.addOutgoingConnection(parentConnection);
|
||||
}
|
||||
// **Recalculate the whole tree to avoid overlaps**
|
||||
realignTree();
|
||||
});
|
||||
|
||||
final childrenWithDownDirection = original.children
|
||||
.where((child) =>
|
||||
child.incomingConnection?.direction == "down" && child.status != SpaceStatus.deleted)
|
||||
.toList();
|
||||
|
||||
Offset childStartPosition = childrenWithDownDirection.length == 1
|
||||
? duplicated.position
|
||||
: newPosition + Offset(0, verticalGap);
|
||||
|
||||
for (final child in original.children) {
|
||||
final isDownDirection = child.incomingConnection?.direction == "down" ?? false;
|
||||
|
||||
if (isDownDirection && childrenWithDownDirection.length == 1) {
|
||||
childStartPosition = duplicated.position + Offset(0, verticalGap);
|
||||
} else if (!isDownDirection) {
|
||||
childStartPosition = duplicated.position + Offset(horizontalGap, 0);
|
||||
}
|
||||
|
||||
final duplicatedChild = duplicateRecursive(child, childStartPosition, duplicated);
|
||||
duplicated.children.add(duplicatedChild);
|
||||
childStartPosition += Offset(0, verticalGap);
|
||||
// Recursively duplicate children
|
||||
for (var child in original.children) {
|
||||
duplicateRecursive(child, duplicated);
|
||||
}
|
||||
|
||||
return duplicated;
|
||||
}
|
||||
|
||||
/// **Handle root duplication**
|
||||
if (space.parent == null) {
|
||||
duplicateRecursive(space, space.position, null);
|
||||
print("🟠 Duplicating root node: ${space.name}");
|
||||
SpaceModel duplicatedRoot = duplicateRecursive(space, null);
|
||||
|
||||
setState(() {
|
||||
spaces.add(duplicatedRoot);
|
||||
realignTree();
|
||||
});
|
||||
|
||||
print("✅ Root duplication successful: ${duplicatedRoot.name}");
|
||||
} else {
|
||||
final duplicatedParent = originalToDuplicate[space.parent!] ?? space.parent!;
|
||||
duplicateRecursive(space, space.position, duplicatedParent);
|
||||
duplicateRecursive(space, space.parent);
|
||||
}
|
||||
|
||||
print("🟢 Finished duplication process for: ${space.name}");
|
||||
}
|
||||
}
|
||||
|
@ -47,18 +47,6 @@ class SpaceCardWidget extends StatelessWidget {
|
||||
children: [
|
||||
buildSpaceContainer(index), // Build the space container
|
||||
if (isHovered) ...[
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'left',
|
||||
offset: const Offset(-21, 20),
|
||||
onButtonTap: onButtonTap,
|
||||
),
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'right',
|
||||
offset: const Offset(140, 20),
|
||||
onButtonTap: onButtonTap,
|
||||
),
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'down',
|
||||
|
@ -2,8 +2,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_m
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
class SpaceHelper {
|
||||
static SpaceModel? findSpaceByUuid(
|
||||
String? uuid, List<CommunityModel> communities) {
|
||||
static SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
|
||||
for (var community in communities) {
|
||||
for (var space in community.spaces) {
|
||||
if (space.uuid == uuid) return space;
|
||||
@ -12,8 +11,7 @@ class SpaceHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static SpaceModel? findSpaceByInternalId(
|
||||
String? internalId, List<SpaceModel> spaces) {
|
||||
static SpaceModel? findSpaceByInternalId(String? internalId, List<SpaceModel> spaces) {
|
||||
if (internalId != null) {
|
||||
for (var space in spaces) {
|
||||
if (space.internalId == internalId) return space;
|
||||
@ -23,8 +21,7 @@ class SpaceHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static String generateUniqueSpaceName(
|
||||
String originalName, List<SpaceModel> spaces) {
|
||||
static String generateUniqueSpaceName(String originalName, List<SpaceModel> spaces) {
|
||||
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
|
||||
int maxNumber = 0;
|
||||
|
||||
@ -54,13 +51,10 @@ class SpaceHelper {
|
||||
|
||||
return space == selectedSpace ||
|
||||
selectedSpace.parent?.internalId == space.internalId ||
|
||||
selectedSpace.children
|
||||
?.any((child) => child.internalId == space.internalId) ==
|
||||
true;
|
||||
selectedSpace.children?.any((child) => child.internalId == space.internalId) == true;
|
||||
}
|
||||
|
||||
static bool isNameConflict(
|
||||
String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
|
||||
static bool isNameConflict(String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
|
||||
final siblings = parentSpace?.children
|
||||
.where((child) => child.internalId != editSpace?.internalId)
|
||||
.toList() ??
|
||||
@ -71,19 +65,17 @@ class SpaceHelper {
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
final editSiblingConflict =
|
||||
editSiblings.any((child) => child.name == value);
|
||||
final editSiblingConflict = editSiblings.any((child) => child.name == value);
|
||||
|
||||
final siblingConflict = siblings.any((child) => child.name == value);
|
||||
|
||||
final parentConflict = parentSpace?.name == value &&
|
||||
parentSpace?.internalId != editSpace?.internalId;
|
||||
final parentConflict =
|
||||
parentSpace?.name == value && parentSpace?.internalId != editSpace?.internalId;
|
||||
|
||||
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
|
||||
editSpace?.parent?.internalId != editSpace?.internalId;
|
||||
final parentOfEditSpaceConflict =
|
||||
editSpace?.parent?.name == value && editSpace?.parent?.internalId != editSpace?.internalId;
|
||||
|
||||
final childConflict =
|
||||
editSpace?.children.any((child) => child.name == value) ?? false;
|
||||
final childConflict = editSpace?.children.any((child) => child.name == value) ?? false;
|
||||
|
||||
return siblingConflict ||
|
||||
parentConflict ||
|
||||
|
@ -194,9 +194,10 @@ class VisitorPasswordBloc
|
||||
emit(DeviceLoaded());
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
data = await AccessMangApi().fetchDevices(projectUuid);
|
||||
data = await AccessMangApi().fetchDoorLockDeviceList(projectUuid);
|
||||
emit(TableLoaded(data));
|
||||
} catch (e) {
|
||||
print("error: $e");
|
||||
emit(FailedState(e.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,23 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
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 {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.visitorPassword.replaceAll('{projectId}', projectId),
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
List<PasswordModel> passwordList = jsonData.map((jsonItem) {
|
||||
return PasswordModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -25,17 +35,22 @@ class AccessMangApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future fetchDevices(String projectId) async {
|
||||
Future fetchDoorLockDeviceList(String projectId) async {
|
||||
try {
|
||||
// The endpoint structure is already validated during initialization.
|
||||
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDevices.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {
|
||||
'deviceType': 'DOOR_LOCK',
|
||||
},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
List<DeviceModel> passwordList = jsonData.map((jsonItem) {
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
List<DeviceModel> deviceList = jsonData.map((jsonItem) {
|
||||
return DeviceModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
return passwordList;
|
||||
return deviceList;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -52,14 +67,15 @@ class AccessMangApi {
|
||||
String? invalidTime,
|
||||
List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineOneTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"password": password,
|
||||
"devicesUuid": devicesUuid,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "ONLINE_ONE_TIME",
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
@ -84,13 +100,13 @@ class AccessMangApi {
|
||||
"password": password,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "ONLINE_MULTIPLE_TIME",
|
||||
};
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] =
|
||||
scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineMultipleTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode(body),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
@ -105,8 +121,9 @@ class AccessMangApi {
|
||||
Future postOffLineOneTime(
|
||||
{String? email, String? passwordName, List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineOneTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"operationType": "OFFLINE_ONE_TIME",
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"devicesUuid": devicesUuid
|
||||
@ -126,13 +143,14 @@ class AccessMangApi {
|
||||
String? invalidTime,
|
||||
List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineMultipleTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"email": email,
|
||||
"devicesUuid": devicesUuid,
|
||||
"passwordName": passwordName,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "OFFLINE_MULTIPLE_TIME",
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
|
@ -23,9 +23,8 @@ class DevicesManagementApi {
|
||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = communityId.isNotEmpty && spaceId.isNotEmpty
|
||||
? json['data']
|
||||
: json;
|
||||
List<dynamic> jsonData =
|
||||
communityId.isNotEmpty && spaceId.isNotEmpty ? json['data'] : json['data'];
|
||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
return AllDevicesModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -34,7 +33,7 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('fetchDevices Error fetching $e');
|
||||
debugPrint('Error fetching device $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -45,7 +44,7 @@ class DevicesManagementApi {
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json);
|
||||
return DeviceStatus.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -62,7 +61,7 @@ class DevicesManagementApi {
|
||||
Future getPowerClampInfo(String deviceId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', deviceId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -100,6 +99,7 @@ class DevicesManagementApi {
|
||||
'devicesUuid': uuids,
|
||||
'code': code,
|
||||
'value': value,
|
||||
'operationType': 'COMMAND',
|
||||
};
|
||||
|
||||
final response = await HTTPService().post(
|
||||
@ -107,7 +107,7 @@ class DevicesManagementApi {
|
||||
body: body,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return (json['successResults'] as List).isNotEmpty;
|
||||
return json['success'] ?? false;
|
||||
},
|
||||
);
|
||||
|
||||
@ -128,7 +128,7 @@ class DevicesManagementApi {
|
||||
if (json == null || json.isEmpty || json == []) {
|
||||
return devices;
|
||||
}
|
||||
for (var device in json['devices']) {
|
||||
for (var device in json['data']['devices']) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
return devices;
|
||||
@ -158,7 +158,7 @@ class DevicesManagementApi {
|
||||
.replaceAll('{code}', code),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
return DeviceReport.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -174,7 +174,7 @@ class DevicesManagementApi {
|
||||
.replaceAll('{endTime}', to ?? ''),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
return DeviceReport.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -190,7 +190,7 @@ class DevicesManagementApi {
|
||||
queryParameters: queryParameters,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json['status']);
|
||||
return DeviceStatus.fromJson(json['data']['status']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
|
@ -9,21 +9,8 @@ abstract class ApiEndpoints {
|
||||
static const String sendOtp = '/authentication/user/send-otp';
|
||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||
static const String getRegion = '/region';
|
||||
static const String visitorPassword =
|
||||
'/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 visitorPassword = '/visitor-passwords';
|
||||
static const String getDevices = '/projects/{projectId}/devices';
|
||||
|
||||
static const String getUser = '/user/{userUuid}';
|
||||
|
||||
@ -32,15 +19,15 @@ abstract class ApiEndpoints {
|
||||
static const String getAllDevices = '/projects/{projectId}/devices';
|
||||
static const String getSpaceDevices =
|
||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
||||
static const String getDeviceStatus = '/device/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/device/status/batch';
|
||||
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/devices/batch';
|
||||
|
||||
static const String deviceControl = '/device/{uuid}/control';
|
||||
static const String deviceBatchControl = '/device/control/batch';
|
||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
||||
static const String deviceControl = '/devices/{uuid}/command';
|
||||
static const String deviceBatchControl = '/devices/batch';
|
||||
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||
|
||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
||||
static const String getDeviceLogs = '/devices/{uuid}/report-logs?code={code}';
|
||||
|
||||
// Space Module
|
||||
static const String createSpace =
|
||||
@ -70,18 +57,13 @@ abstract class ApiEndpoints {
|
||||
static const String createUserCommunity =
|
||||
'/projects/{projectId}/communities/user';
|
||||
static const String getDeviceLogsByDate =
|
||||
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
'/devices/{uuid}/report-logs?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
|
||||
static const String scheduleByDeviceId = '/schedule/{deviceUuid}';
|
||||
static const String getScheduleByDeviceId =
|
||||
'/schedule/{deviceUuid}?category={category}';
|
||||
static const String deleteScheduleByDeviceId =
|
||||
'/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';
|
||||
static const String getScheduleByDeviceId = '/schedule/{deviceUuid}?category={category}';
|
||||
static const String deleteScheduleByDeviceId = '/schedule/{deviceUuid}/{scheduleUuid}';
|
||||
static const String updateScheduleByDeviceId = '/schedule/enable/{deviceUuid}';
|
||||
static const String factoryReset = '/devices/batch';
|
||||
|
||||
//product
|
||||
static const String listProducts = '/products';
|
||||
|
Reference in New Issue
Block a user