mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
added device spaces model
This commit is contained in:
@ -0,0 +1,18 @@
|
|||||||
|
class DeviceSpaceModel {
|
||||||
|
String? uuid;
|
||||||
|
String? spaceName;
|
||||||
|
|
||||||
|
DeviceSpaceModel({this.uuid, this.spaceName});
|
||||||
|
|
||||||
|
DeviceSpaceModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
uuid = json['uuid']?.toString();
|
||||||
|
spaceName = json['spaceName']?.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final data = <String, dynamic>{};
|
||||||
|
data['uuid'] = uuid;
|
||||||
|
data['spaceName'] = spaceName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -64,6 +65,7 @@ class AllDevicesModel {
|
|||||||
String? uuid;
|
String? uuid;
|
||||||
int? batteryLevel;
|
int? batteryLevel;
|
||||||
String? productName;
|
String? productName;
|
||||||
|
List<DeviceSpaceModel>? spaces;
|
||||||
|
|
||||||
AllDevicesModel({
|
AllDevicesModel({
|
||||||
this.room,
|
this.room,
|
||||||
@ -92,6 +94,7 @@ class AllDevicesModel {
|
|||||||
this.uuid,
|
this.uuid,
|
||||||
this.batteryLevel,
|
this.batteryLevel,
|
||||||
this.productName,
|
this.productName,
|
||||||
|
this.spaces,
|
||||||
});
|
});
|
||||||
AllDevicesModel.fromJson(Map<String, dynamic> json) {
|
AllDevicesModel.fromJson(Map<String, dynamic> json) {
|
||||||
room = (json['room'] != null && (json['room'] is Map))
|
room = (json['room'] != null && (json['room'] is Map))
|
||||||
@ -124,6 +127,11 @@ class AllDevicesModel {
|
|||||||
uuid = json['uuid']?.toString();
|
uuid = json['uuid']?.toString();
|
||||||
batteryLevel = int.tryParse(json['battery']?.toString() ?? '');
|
batteryLevel = int.tryParse(json['battery']?.toString() ?? '');
|
||||||
productName = json['productName']?.toString();
|
productName = json['productName']?.toString();
|
||||||
|
if (json['spaces'] != null && json['spaces'] is List) {
|
||||||
|
spaces = (json['spaces'] as List)
|
||||||
|
.map((space) => DeviceSpaceModel.fromJson(space))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getDefaultIcon(String? productType) {
|
String _getDefaultIcon(String? productType) {
|
||||||
@ -186,6 +194,9 @@ class AllDevicesModel {
|
|||||||
data['uuid'] = uuid;
|
data['uuid'] = uuid;
|
||||||
data['battery'] = batteryLevel;
|
data['battery'] = batteryLevel;
|
||||||
data['productName'] = productName;
|
data['productName'] = productName;
|
||||||
|
if (spaces != null) {
|
||||||
|
data['spaces'] = spaces!.map((space) => space.toJson()).toList();
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
'Device Name',
|
'Device Name',
|
||||||
'Product Name',
|
'Product Name',
|
||||||
'Device ID',
|
'Device ID',
|
||||||
'Unit Name',
|
'Space Name',
|
||||||
'Room',
|
'location',
|
||||||
'Battery Level',
|
'Battery Level',
|
||||||
'Installation Date and Time',
|
'Installation Date and Time',
|
||||||
'Status',
|
'Status',
|
||||||
|
@ -68,7 +68,8 @@ 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 {
|
try {
|
||||||
final body = {
|
final body = {
|
||||||
'devicesUuid': uuids,
|
'devicesUuid': uuids,
|
||||||
@ -92,7 +93,8 @@ class DevicesManagementApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||||
|
String gatewayId) async {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
@ -126,7 +128,9 @@ class DevicesManagementApi {
|
|||||||
String code,
|
String code,
|
||||||
) async {
|
) async {
|
||||||
final response = await HTTPService().get(
|
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,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return DeviceReport.fromJson(json);
|
return DeviceReport.fromJson(json);
|
||||||
@ -135,7 +139,8 @@ class DevicesManagementApi {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<DeviceReport> getDeviceReportsByDate(String uuid, String code, [String? from, String? to]) async {
|
static Future<DeviceReport> getDeviceReportsByDate(String uuid, String code,
|
||||||
|
[String? from, String? to]) async {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.getDeviceLogsByDate
|
path: ApiEndpoints.getDeviceLogsByDate
|
||||||
.replaceAll('{uuid}', uuid)
|
.replaceAll('{uuid}', uuid)
|
||||||
@ -174,7 +179,8 @@ class DevicesManagementApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> addScheduleRecord(ScheduleEntry sendSchedule, String uuid) async {
|
Future<bool> addScheduleRecord(
|
||||||
|
ScheduleEntry sendSchedule, String uuid) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||||
@ -191,10 +197,13 @@ class DevicesManagementApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ScheduleModel>> getDeviceSchedules(String uuid, String category) async {
|
Future<List<ScheduleModel>> getDeviceSchedules(
|
||||||
|
String uuid, String category) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: ApiEndpoints.getScheduleByDeviceId.replaceAll('{deviceUuid}', uuid).replaceAll('{category}', category),
|
path: ApiEndpoints.getScheduleByDeviceId
|
||||||
|
.replaceAll('{deviceUuid}', uuid)
|
||||||
|
.replaceAll('{category}', category),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<ScheduleModel> schedules = [];
|
List<ScheduleModel> schedules = [];
|
||||||
@ -211,7 +220,10 @@ class DevicesManagementApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> updateScheduleRecord({required bool enable, required String uuid, required String scheduleId}) async {
|
Future<bool> updateScheduleRecord(
|
||||||
|
{required bool enable,
|
||||||
|
required String uuid,
|
||||||
|
required String scheduleId}) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().put(
|
final response = await HTTPService().put(
|
||||||
path: ApiEndpoints.updateScheduleByDeviceId
|
path: ApiEndpoints.updateScheduleByDeviceId
|
||||||
@ -232,7 +244,8 @@ class DevicesManagementApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> editScheduleRecord(String uuid, ScheduleEntry newSchedule) async {
|
Future<bool> editScheduleRecord(
|
||||||
|
String uuid, ScheduleEntry newSchedule) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().put(
|
final response = await HTTPService().put(
|
||||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||||
|
Reference in New Issue
Block a user