mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:44:54 +00:00
Fixed bugs in automation
This commit is contained in:
@ -95,7 +95,7 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
event.automationId, event.automationStatusUpdate);
|
event.automationId, event.automationStatusUpdate);
|
||||||
if (success) {
|
if (success) {
|
||||||
automationList = await SceneApi.getAutomationByUnitId(
|
automationList = await SceneApi.getAutomationByUnitId(
|
||||||
event.automationStatusUpdate.unitUuid);
|
event.automationStatusUpdate.spaceUuid);
|
||||||
newLoadingStates[event.automationId] = false;
|
newLoadingStates[event.automationId] = false;
|
||||||
emit(SceneLoaded(
|
emit(SceneLoaded(
|
||||||
currentState.scenes,
|
currentState.scenes,
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class SceneDetailsModel {
|
|||||||
|
|
||||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
|
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
|
||||||
SceneDetailsModel(
|
SceneDetailsModel(
|
||||||
id: json["uuid"],
|
id: json["uuid"] ?? json["id"],
|
||||||
name: json["name"],
|
name: json["name"],
|
||||||
status: json["status"],
|
status: json["status"],
|
||||||
type: json["type"],
|
type: json["type"],
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class AutomationStatusUpdate {
|
class AutomationStatusUpdate {
|
||||||
final String unitUuid;
|
final String spaceUuid;
|
||||||
final bool isEnable;
|
final bool isEnable;
|
||||||
|
|
||||||
AutomationStatusUpdate({
|
AutomationStatusUpdate({
|
||||||
required this.unitUuid,
|
required this.spaceUuid,
|
||||||
required this.isEnable,
|
required this.isEnable,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -16,23 +16,23 @@ class AutomationStatusUpdate {
|
|||||||
|
|
||||||
factory AutomationStatusUpdate.fromJson(Map<String, dynamic> json) =>
|
factory AutomationStatusUpdate.fromJson(Map<String, dynamic> json) =>
|
||||||
AutomationStatusUpdate(
|
AutomationStatusUpdate(
|
||||||
unitUuid: json["unitUuid"],
|
spaceUuid: json["spaceUuid"],
|
||||||
isEnable: json["isEnable"],
|
isEnable: json["isEnable"],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"unitUuid": unitUuid,
|
"spaceUuid": spaceUuid,
|
||||||
"isEnable": isEnable,
|
"isEnable": isEnable,
|
||||||
};
|
};
|
||||||
|
|
||||||
factory AutomationStatusUpdate.fromMap(Map<String, dynamic> map) =>
|
factory AutomationStatusUpdate.fromMap(Map<String, dynamic> map) =>
|
||||||
AutomationStatusUpdate(
|
AutomationStatusUpdate(
|
||||||
unitUuid: map["unitUuid"],
|
spaceUuid: map["spaceUuid"],
|
||||||
isEnable: map["isEnable"],
|
isEnable: map["isEnable"],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() => {
|
||||||
"unitUuid": unitUuid,
|
"spaceUuid": spaceUuid,
|
||||||
"isEnable": isEnable,
|
"isEnable": isEnable,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class SceneItem extends StatelessWidget {
|
|||||||
context.read<SceneBloc>().add(UpdateAutomationStatus(
|
context.read<SceneBloc>().add(UpdateAutomationStatus(
|
||||||
automationStatusUpdate: AutomationStatusUpdate(
|
automationStatusUpdate: AutomationStatusUpdate(
|
||||||
isEnable: value,
|
isEnable: value,
|
||||||
unitUuid: HomeCubit.getInstance().selectedSpace!.id!),
|
spaceUuid: HomeCubit.getInstance().selectedSpace!.id!),
|
||||||
automationId: scene.id));
|
automationId: scene.id));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -163,7 +163,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String deleteAutomation =
|
static const String deleteAutomation =
|
||||||
'/automation/{unitUuid}/{automationId}';
|
'/automation/{automationId}';
|
||||||
|
|
||||||
//////////////////////Door Lock //////////////////////
|
//////////////////////Door Lock //////////////////////
|
||||||
//online
|
//online
|
||||||
|
|||||||
@ -233,8 +233,7 @@ class SceneApi {
|
|||||||
try {
|
try {
|
||||||
final response = await _httpService.delete(
|
final response = await _httpService.delete(
|
||||||
path: ApiEndpoints.deleteAutomation
|
path: ApiEndpoints.deleteAutomation
|
||||||
.replaceAll('{automationId}', automationId)
|
.replaceAll('{automationId}', automationId),
|
||||||
.replaceAll('{unitUuid}', unitUuid),
|
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => json['statusCode'] == 200,
|
expectedResponseModel: (json) => json['statusCode'] == 200,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user