mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
changed endpoint for automation update
This commit is contained in:
@ -808,7 +808,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
|
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
|
||||||
} else {
|
} else {
|
||||||
await SceneApi.deleteAutomation(
|
await SceneApi.deleteAutomation(
|
||||||
unitUuid: spaceBloc.state.selectedSpaces[0], automationId: state.automationId ?? '',projectId: projectId);
|
unitUuid: spaceBloc.state.selectedSpaces[0],
|
||||||
|
automationId: state.automationId ?? '',
|
||||||
|
projectId: projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
add(const LoadScenes());
|
add(const LoadScenes());
|
||||||
@ -948,6 +950,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
|
|
||||||
FutureOr<void> _onUpdateAutomation(UpdateAutomation event, Emitter<RoutineState> emit) async {
|
FutureOr<void> _onUpdateAutomation(UpdateAutomation event, Emitter<RoutineState> emit) async {
|
||||||
try {
|
try {
|
||||||
|
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
errorMessage: 'Automation name is required',
|
errorMessage: 'Automation name is required',
|
||||||
@ -1057,8 +1061,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
actions: actions,
|
actions: actions,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result =
|
final result = await SceneApi.updateAutomation(
|
||||||
await SceneApi.updateAutomation(createAutomationModel, state.automationId ?? '');
|
createAutomationModel, state.automationId ?? '', projectId);
|
||||||
|
|
||||||
if (result['success']) {
|
if (result['success']) {
|
||||||
add(ResetRoutineState());
|
add(ResetRoutineState());
|
||||||
|
@ -166,10 +166,13 @@ class SceneApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update automation
|
//update automation
|
||||||
static updateAutomation(CreateAutomationModel createAutomationModel, String automationId) async {
|
static updateAutomation(
|
||||||
|
CreateAutomationModel createAutomationModel, String automationId, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.put(
|
||||||
path: ApiEndpoints.updateAutomation.replaceAll('{automationId}', automationId),
|
path: ApiEndpoints.updateAutomation
|
||||||
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
|
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
|
@ -69,7 +69,8 @@ abstract class ApiEndpoints {
|
|||||||
//product
|
//product
|
||||||
static const String listProducts = '/products';
|
static const String listProducts = '/products';
|
||||||
static const String getSpaceScenes = '/scene/tap-to-run/{spaceUuid}';
|
static const String getSpaceScenes = '/scene/tap-to-run/{spaceUuid}';
|
||||||
static const String getSpaceAutomation = '/projects/{projectId}/communities/{communityId}/spaces/{spaceUuid}/automations';
|
static const String getSpaceAutomation =
|
||||||
|
'/projects/{projectId}/communities/{communityId}/spaces/{spaceUuid}/automations';
|
||||||
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 = '/projects/{projectId}/automations';
|
static const String createAutomation = '/projects/{projectId}/automations';
|
||||||
@ -82,7 +83,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
|
||||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String updateAutomation = '/automation/{automationId}';
|
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
//space model
|
//space model
|
||||||
static const String listSpaceModels = '/projects/{projectId}/space-models';
|
static const String listSpaceModels = '/projects/{projectId}/space-models';
|
||||||
|
Reference in New Issue
Block a user