Implemented side tree to devices and rountines screen

This commit is contained in:
Abdullah Alassaf
2025-01-04 17:45:15 +03:00
parent 0341844ea9
commit a98f7e77a3
88 changed files with 1551 additions and 1202 deletions

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_scene_model.dart';
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
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/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
import 'package:syncrow_web/pages/routines/models/routine_details_model.dart';
import 'package:syncrow_web/pages/routines/models/routine_model.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/temp_const.dart';
@ -12,8 +12,7 @@ class SceneApi {
static final HTTPService _httpService = HTTPService();
// //create scene
static Future<Map<String, dynamic>> createScene(
CreateSceneModel createSceneModel) async {
static Future<Map<String, dynamic>> createScene(CreateSceneModel createSceneModel) async {
try {
debugPrint('create scene model: ${createSceneModel.toMap()}');
final response = await _httpService.post(
@ -70,13 +69,12 @@ class SceneApi {
//get scenes by community id and space id
static Future<List<ScenesModel>> getScenesByUnitId(
String unitId, String communityId,
static Future<List<ScenesModel>> getScenes(String spaceId, String communityId,
{showInDevice = false}) async {
try {
final response = await _httpService.get(
path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId)
path: ApiEndpoints.getScenes
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
queryParameters: {'showInHomePage': showInDevice},
@ -99,10 +97,10 @@ class SceneApi {
//getAutomation
static Future<List<ScenesModel>> getAutomationByUnitId(String unitId) async {
static Future<List<ScenesModel>> getAutomation(String spaceId) async {
try {
final response = await _httpService.get(
path: ApiEndpoints.getSpaceAutomation.replaceAll('{unitUuid}', unitId),
path: ApiEndpoints.getSpaceAutomation.replaceAll('{spaceUuid}', spaceId),
showServerMessage: false,
expectedResponseModel: (json) {
List<ScenesModel> scenes = [];
@ -132,12 +130,10 @@ class SceneApi {
// }
//automation details
static Future<RoutineDetailsModel> getAutomationDetails(
String automationId) async {
static Future<RoutineDetailsModel> getAutomationDetails(String automationId) async {
try {
final response = await _httpService.get(
path: ApiEndpoints.getAutomationDetails
.replaceAll('{automationId}', automationId),
path: ApiEndpoints.getAutomationDetails.replaceAll('{automationId}', automationId),
showServerMessage: false,
expectedResponseModel: (json) => RoutineDetailsModel.fromMap(json),
);
@ -152,8 +148,7 @@ class SceneApi {
try {
final response = await _httpService.put(
path: ApiEndpoints.updateScene.replaceAll('{sceneId}', sceneId),
body: createSceneModel
.toJson(sceneId.isNotEmpty == true ? sceneId : null),
body: createSceneModel.toJson(sceneId.isNotEmpty == true ? sceneId : null),
expectedResponseModel: (json) {
return json;
},
@ -165,14 +160,11 @@ class SceneApi {
}
//update automation
static updateAutomation(
CreateAutomationModel createAutomationModel, String automationId) async {
static updateAutomation(CreateAutomationModel createAutomationModel, String automationId) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.updateAutomation
.replaceAll('{automationId}', automationId),
body: createAutomationModel
.toJson(automationId.isNotEmpty == true ? automationId : null),
path: ApiEndpoints.updateAutomation.replaceAll('{automationId}', automationId),
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
expectedResponseModel: (json) {
return json;
},
@ -189,8 +181,7 @@ class SceneApi {
final response = await _httpService.get(
path: ApiEndpoints.getScene.replaceAll('{sceneId}', sceneId),
showServerMessage: false,
expectedResponseModel: (json) =>
RoutineDetailsModel.fromMap(json['data']),
expectedResponseModel: (json) => RoutineDetailsModel.fromMap(json['data']),
);
return response;
} catch (e) {
@ -199,8 +190,7 @@ class SceneApi {
}
//delete Scene
static Future<bool> deleteScene(
{required String unitUuid, required String sceneId}) async {
static Future<bool> deleteScene({required String unitUuid, required String sceneId}) async {
try {
final response = await _httpService.delete(
path: ApiEndpoints.deleteScene