mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-10-26 17:27:56 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e634dc7a2 | ||
|
|
08e2ed4b4c | ||
|
|
59e04708cd | ||
|
|
b6664ec1ba | ||
|
|
21f8b2962c | ||
|
|
645a07287e | ||
|
|
e55e793081 | ||
|
|
dcf1df9b4a |
+13
-10
@@ -2,11 +2,12 @@ import 'package:bloc/bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_event.dart';
|
import 'package:syncrow_web/pages/access_management/booking_system/presentation/bloc/date_selection/date_selection_event.dart';
|
||||||
import 'date_selection_state.dart';
|
import 'date_selection_state.dart';
|
||||||
|
|
||||||
|
|
||||||
class DateSelectionBloc extends Bloc<DateSelectionEvent, DateSelectionState> {
|
class DateSelectionBloc extends Bloc<DateSelectionEvent, DateSelectionState> {
|
||||||
DateSelectionBloc() : super(DateSelectionState.initial()) {
|
DateSelectionBloc() : super(DateSelectionState.initial()) {
|
||||||
on<SelectDate>((event, emit) {
|
on<SelectDate>((event, emit) {
|
||||||
final newWeekStart = _getStartOfWeek(event.selectedDate);
|
final newWeekStart = _getStartOfWeek(event.selectedDate);
|
||||||
emit(DateSelectionState(
|
emit(state.copyWith(
|
||||||
selectedDate: event.selectedDate,
|
selectedDate: event.selectedDate,
|
||||||
weekStart: newWeekStart,
|
weekStart: newWeekStart,
|
||||||
));
|
));
|
||||||
@@ -14,19 +15,21 @@ class DateSelectionBloc extends Bloc<DateSelectionEvent, DateSelectionState> {
|
|||||||
|
|
||||||
on<NextWeek>((event, emit) {
|
on<NextWeek>((event, emit) {
|
||||||
final newWeekStart = state.weekStart.add(const Duration(days: 7));
|
final newWeekStart = state.weekStart.add(const Duration(days: 7));
|
||||||
final inNewWeek = state.selectedDate
|
emit(state.copyWith(
|
||||||
.isAfter(newWeekStart.subtract(const Duration(days: 1))) &&
|
|
||||||
state.selectedDate
|
|
||||||
.isBefore(newWeekStart.add(const Duration(days: 7)));
|
|
||||||
emit(DateSelectionState(
|
|
||||||
selectedDate: state.selectedDate,
|
|
||||||
weekStart: newWeekStart,
|
weekStart: newWeekStart,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
on<PreviousWeek>((event, emit) {
|
on<PreviousWeek>((event, emit) {
|
||||||
emit(DateSelectionState(
|
final newWeekStart = state.weekStart.subtract(const Duration(days: 7));
|
||||||
selectedDate: state.selectedDate!.subtract(const Duration(days: 7)),
|
emit(state.copyWith(
|
||||||
weekStart: state.weekStart.subtract(const Duration(days: 7)),
|
weekStart: newWeekStart,
|
||||||
|
));
|
||||||
|
});
|
||||||
|
|
||||||
|
on<SelectDateFromSidebarCalendar>((event, emit) {
|
||||||
|
emit(state.copyWith(
|
||||||
|
selectedDateFromSideBarCalender: event.selectedDate,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -10,4 +10,9 @@ class SelectDate extends DateSelectionEvent {
|
|||||||
|
|
||||||
class NextWeek extends DateSelectionEvent {}
|
class NextWeek extends DateSelectionEvent {}
|
||||||
|
|
||||||
class PreviousWeek extends DateSelectionEvent {}
|
class PreviousWeek extends DateSelectionEvent {}
|
||||||
|
|
||||||
|
class SelectDateFromSidebarCalendar extends DateSelectionEvent {
|
||||||
|
final DateTime selectedDate;
|
||||||
|
SelectDateFromSidebarCalendar(this.selectedDate);
|
||||||
|
}
|
||||||
+17
-4
@@ -1,21 +1,34 @@
|
|||||||
|
|
||||||
class DateSelectionState {
|
class DateSelectionState {
|
||||||
final DateTime selectedDate;
|
final DateTime selectedDate;
|
||||||
final DateTime weekStart;
|
final DateTime weekStart;
|
||||||
|
final DateTime? selectedDateFromSideBarCalender;
|
||||||
|
|
||||||
const DateSelectionState({
|
DateSelectionState({
|
||||||
required this.selectedDate,
|
required this.selectedDate,
|
||||||
required this.weekStart,
|
required this.weekStart,
|
||||||
|
this.selectedDateFromSideBarCalender,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory DateSelectionState.initial() {
|
factory DateSelectionState.initial() {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
|
final weekStart = now.subtract(Duration(days: now.weekday - 1));
|
||||||
return DateSelectionState(
|
return DateSelectionState(
|
||||||
selectedDate: now,
|
selectedDate: now,
|
||||||
weekStart: _getStartOfWeek(now),
|
weekStart: weekStart,
|
||||||
|
selectedDateFromSideBarCalender: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DateTime _getStartOfWeek(DateTime date) {
|
DateSelectionState copyWith({
|
||||||
return date.subtract(Duration(days: date.weekday - 1));
|
DateTime? selectedDate,
|
||||||
|
DateTime? weekStart,
|
||||||
|
DateTime? selectedDateFromSideBarCalender,
|
||||||
|
}) {
|
||||||
|
return DateSelectionState(
|
||||||
|
selectedDate: selectedDate ?? this.selectedDate,
|
||||||
|
weekStart: weekStart ?? this.weekStart,
|
||||||
|
selectedDateFromSideBarCalender: selectedDateFromSideBarCalender ?? this.selectedDateFromSideBarCalender,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
context
|
context
|
||||||
.read<DateSelectionBloc>()
|
.read<DateSelectionBloc>()
|
||||||
.add(SelectDate(newDate));
|
.add(SelectDate(newDate));
|
||||||
|
context
|
||||||
|
.read<DateSelectionBloc>()
|
||||||
|
.add(SelectDateFromSidebarCalendar(newDate));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -227,6 +230,10 @@ class _BookingPageState extends State<BookingPage> {
|
|||||||
weekStart: dateState.weekStart,
|
weekStart: dateState.weekStart,
|
||||||
selectedDate: dateState.selectedDate,
|
selectedDate: dateState.selectedDate,
|
||||||
eventController: _eventController,
|
eventController: _eventController,
|
||||||
|
selectedDateFromSideBarCalender: context
|
||||||
|
.watch<DateSelectionBloc>()
|
||||||
|
.state
|
||||||
|
.selectedDateFromSideBarCalender,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
+48
-16
@@ -9,6 +9,7 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
final EventController eventController;
|
final EventController eventController;
|
||||||
final String? startTime;
|
final String? startTime;
|
||||||
final String? endTime;
|
final String? endTime;
|
||||||
|
final DateTime? selectedDateFromSideBarCalender;
|
||||||
|
|
||||||
const WeeklyCalendarPage({
|
const WeeklyCalendarPage({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -17,32 +18,55 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
required this.eventController,
|
required this.eventController,
|
||||||
this.startTime,
|
this.startTime,
|
||||||
this.endTime,
|
this.endTime,
|
||||||
|
this.selectedDateFromSideBarCalender,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final startHour = _parseHour(startTime, defaultValue: 0);
|
final startHour = _parseHour(startTime, defaultValue: 0);
|
||||||
final endHour = _parseHour(endTime, defaultValue: 24);
|
final endHour = _parseHour(endTime, defaultValue: 24);
|
||||||
|
|
||||||
if (endTime == null || endTime!.isEmpty) {
|
if (endTime == null || endTime!.isEmpty) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: Text(
|
child: Column(
|
||||||
'Please select a bookable space to view the calendar.',
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.calendar_today,
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
size: 80,
|
||||||
|
),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
'Please select a bookable space to view the calendar.',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: ColorsManager.lightGrayColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final weekDays = _getWeekDays(weekStart);
|
final weekDays = _getWeekDays(weekStart);
|
||||||
|
|
||||||
|
final selectedDayIndex =
|
||||||
|
weekDays.indexWhere((d) => isSameDay(d, selectedDate));
|
||||||
|
final selectedSidebarIndex = selectedDateFromSideBarCalender == null
|
||||||
|
? -1
|
||||||
|
: weekDays
|
||||||
|
.indexWhere((d) => isSameDay(d, selectedDateFromSideBarCalender!));
|
||||||
|
|
||||||
|
const double timeLineWidth = 80;
|
||||||
|
const int totalDays = 7;
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final double calendarWidth = constraints.maxWidth;
|
final double calendarWidth = constraints.maxWidth;
|
||||||
const double timeLineWidth = 80;
|
|
||||||
const int totalDays = 7;
|
|
||||||
final double dayColumnWidth =
|
final double dayColumnWidth =
|
||||||
(calendarWidth - timeLineWidth) / totalDays - 0.1;
|
(calendarWidth - timeLineWidth) / totalDays - 0.1;
|
||||||
final selectedDayIndex =
|
|
||||||
weekDays.indexWhere((d) => isSameDay(d, selectedDate));
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 25),
|
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 25),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
@@ -64,13 +88,8 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
height: 0,
|
height: 0,
|
||||||
),
|
),
|
||||||
weekDayBuilder: (date) {
|
weekDayBuilder: (date) {
|
||||||
final weekDays = _getWeekDays(weekStart);
|
|
||||||
final selectedDayIndex =
|
|
||||||
weekDays.indexWhere((d) => isSameDay(d, selectedDate));
|
|
||||||
final index = weekDays.indexWhere((d) => isSameDay(d, date));
|
final index = weekDays.indexWhere((d) => isSameDay(d, date));
|
||||||
final isSelectedDay = index == selectedDayIndex;
|
final isSelectedDay = index == selectedDayIndex;
|
||||||
final isToday = isSameDay(date, DateTime.now());
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
@@ -138,10 +157,7 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
weekPageHeaderBuilder: (start, end) => Container(),
|
weekPageHeaderBuilder: (start, end) => Container(),
|
||||||
weekTitleHeight: 60,
|
weekTitleHeight: 60,
|
||||||
weekNumberBuilder: (firstDayOfWeek) => Padding(
|
weekNumberBuilder: (firstDayOfWeek) => Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(right: 15, bottom: 10),
|
||||||
right: 15,
|
|
||||||
bottom: 10,
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@@ -219,6 +235,22 @@ class WeeklyCalendarPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (selectedSidebarIndex >= 0 &&
|
||||||
|
selectedSidebarIndex != selectedDayIndex)
|
||||||
|
Positioned(
|
||||||
|
left: (timeLineWidth + 3) +
|
||||||
|
(dayColumnWidth - 8) * (selectedSidebarIndex - 0.01),
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
width: dayColumnWidth,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(
|
||||||
|
vertical: 0, horizontal: 4),
|
||||||
|
color: Colors.orange.withOpacity(0.14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
top: 50,
|
top: 50,
|
||||||
|
|||||||
+15
-11
@@ -46,15 +46,16 @@ class DeviceManagementBloc
|
|||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
|
||||||
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
||||||
devices = await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
devices = await DevicesManagementApi().fetchDevices(
|
||||||
|
projectUuid,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
for (final community in spaceBloc.state.selectedCommunities) {
|
for (var community in spaceBloc.state.selectedCommunities) {
|
||||||
final spacesList =
|
final spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
||||||
for (final space in spacesList) {
|
devices.addAll(await DevicesManagementApi().fetchDevices(projectUuid,
|
||||||
devices.addAll(await DevicesManagementApi()
|
spacesId: spacesList,
|
||||||
.fetchDevices(community, space, projectUuid));
|
communities: spaceBloc.state.selectedCommunities));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +159,8 @@ class DeviceManagementBloc
|
|||||||
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
|
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSelectDevice(SelectDevice event, Emitter<DeviceManagementState> emit) {
|
void _onSelectDevice(
|
||||||
|
SelectDevice event, Emitter<DeviceManagementState> emit) {
|
||||||
final selectedUuid = event.selectedDevice.uuid;
|
final selectedUuid = event.selectedDevice.uuid;
|
||||||
|
|
||||||
if (_selectedDevices.any((device) => device.uuid == selectedUuid)) {
|
if (_selectedDevices.any((device) => device.uuid == selectedUuid)) {
|
||||||
@@ -254,7 +256,8 @@ class DeviceManagementBloc
|
|||||||
_onlineCount = _devices.where((device) => device.online == true).length;
|
_onlineCount = _devices.where((device) => device.online == true).length;
|
||||||
_offlineCount = _devices.where((device) => device.online == false).length;
|
_offlineCount = _devices.where((device) => device.online == false).length;
|
||||||
_lowBatteryCount = _devices
|
_lowBatteryCount = _devices
|
||||||
.where((device) => device.batteryLevel != null && device.batteryLevel! < 20)
|
.where((device) =>
|
||||||
|
device.batteryLevel != null && device.batteryLevel! < 20)
|
||||||
.length;
|
.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +274,8 @@ class DeviceManagementBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSearchDevices(SearchDevices event, Emitter<DeviceManagementState> emit) {
|
void _onSearchDevices(
|
||||||
|
SearchDevices event, Emitter<DeviceManagementState> emit) {
|
||||||
if ((event.community == null || event.community!.isEmpty) &&
|
if ((event.community == null || event.community!.isEmpty) &&
|
||||||
(event.unitName == null || event.unitName!.isEmpty) &&
|
(event.unitName == null || event.unitName!.isEmpty) &&
|
||||||
(event.deviceNameOrProductName == null ||
|
(event.deviceNameOrProductName == null ||
|
||||||
@@ -435,8 +439,8 @@ class DeviceManagementBloc
|
|||||||
final selectedDevices = loaded.selectedDevice?.map((device) {
|
final selectedDevices = loaded.selectedDevice?.map((device) {
|
||||||
if (device.uuid == event.deviceId) {
|
if (device.uuid == event.deviceId) {
|
||||||
return device.copyWith(
|
return device.copyWith(
|
||||||
subspace:
|
subspace: device.subspace
|
||||||
device.subspace?.copyWith(subspaceName: event.newSubSpaceName));
|
?.copyWith(subspaceName: event.newSubSpaceName));
|
||||||
}
|
}
|
||||||
return device;
|
return device;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|||||||
@@ -170,45 +170,45 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadScenes(
|
Future<void> _onLoadScenes(
|
||||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
List<ScenesModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
try {
|
try {
|
||||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||||
createRoutineBloc.selectedCommunityId == '') {
|
createRoutineBloc.selectedCommunityId == '') {
|
||||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||||
List<String> spacesList =
|
List<String> spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||||
for (var spaceId in spacesList) {
|
for (var spaceId in spacesList) {
|
||||||
scenes.addAll(
|
scenes.addAll(
|
||||||
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
scenes.addAll(await SceneApi.getScenes(
|
||||||
|
createRoutineBloc.selectedSpaceId,
|
||||||
|
createRoutineBloc.selectedCommunityId,
|
||||||
|
projectUuid));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
scenes.addAll(await SceneApi.getScenes(
|
|
||||||
createRoutineBloc.selectedSpaceId,
|
|
||||||
createRoutineBloc.selectedCommunityId,
|
|
||||||
projectUuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
scenes: scenes,
|
scenes: scenes,
|
||||||
isLoading: false,
|
|
||||||
));
|
|
||||||
} catch (e) {
|
|
||||||
emit(state.copyWith(
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
loadScenesErrorMessage: 'Failed to load scenes',
|
));
|
||||||
errorMessage: '',
|
} catch (e) {
|
||||||
loadAutomationErrorMessage: '',
|
emit(state.copyWith(
|
||||||
scenes: scenes));
|
isLoading: false,
|
||||||
|
loadScenesErrorMessage: 'Failed to load scenes',
|
||||||
|
errorMessage: '',
|
||||||
|
loadAutomationErrorMessage: '',
|
||||||
|
scenes: scenes));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onLoadAutomation(
|
Future<void> _onLoadAutomation(
|
||||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||||
@@ -936,16 +936,19 @@ Future<void> _onLoadScenes(
|
|||||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||||
List<String> spacesList =
|
List<String> spacesList =
|
||||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||||
for (var spaceId in spacesList) {
|
|
||||||
devices.addAll(await DevicesManagementApi()
|
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||||
.fetchDevices(communityId, spaceId, projectUuid));
|
projectUuid,
|
||||||
}
|
spacesId: spacesList,
|
||||||
|
communities: spaceBloc.state.selectedCommunities,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
devices.addAll(await DevicesManagementApi().fetchDevices(
|
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||||
createRoutineBloc.selectedCommunityId,
|
projectUuid,
|
||||||
createRoutineBloc.selectedSpaceId,
|
spacesId: [createRoutineBloc.selectedSpaceId],
|
||||||
projectUuid));
|
communities: spaceBloc.state.selectedCommunities,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(state.copyWith(isLoading: false, devices: devices));
|
emit(state.copyWith(isLoading: false, devices: devices));
|
||||||
|
|||||||
+1
-3
@@ -96,9 +96,7 @@ class _WallPresenceSensorState extends State<FlushPresenceSensor> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
DialogHeader(widget.dialogType == 'THEN'
|
const DialogHeader('Presence Sensor'),
|
||||||
? 'Presence Sensor Functions'
|
|
||||||
: 'Presence Sensor Condition'),
|
|
||||||
Expanded(child: _buildMainContent(context, state)),
|
Expanded(child: _buildMainContent(context, state)),
|
||||||
_buildDialogFooter(context, state),
|
_buildDialogFooter(context, state),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -12,20 +12,20 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||||
|
|
||||||
class DevicesManagementApi {
|
class DevicesManagementApi {
|
||||||
Future<List<AllDevicesModel>> fetchDevices(
|
Future<List<AllDevicesModel>> fetchDevices(String projectId,
|
||||||
String communityId, String spaceId, String projectId) async {
|
{List<String>? spacesId, List<String>? communities}) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().get(
|
final response = await HTTPService().get(
|
||||||
path: communityId.isNotEmpty && spaceId.isNotEmpty
|
path: ApiEndpoints.getSpaceDevices.replaceAll('{projectId}', projectId),
|
||||||
? ApiEndpoints.getSpaceDevices
|
queryParameters: {
|
||||||
.replaceAll('{spaceUuid}', spaceId)
|
if (spacesId != null && spacesId.isNotEmpty) 'spaces': spacesId,
|
||||||
.replaceAll('{communityUuid}', communityId)
|
if (communities != null && communities.isNotEmpty)
|
||||||
.replaceAll('{projectId}', projectId)
|
'communities': communities,
|
||||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<dynamic> jsonData = json['data'];
|
final List<dynamic> jsonData = json['data'] as List<dynamic>;
|
||||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
final List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||||
return AllDevicesModel.fromJson(jsonItem);
|
return AllDevicesModel.fromJson(jsonItem);
|
||||||
}).toList();
|
}).toList();
|
||||||
return devicesList;
|
return devicesList;
|
||||||
@@ -416,5 +416,4 @@ class DevicesManagementApi {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ abstract class ApiEndpoints {
|
|||||||
////// Devices Management ////////////////
|
////// Devices Management ////////////////
|
||||||
|
|
||||||
static const String getAllDevices = '/projects/{projectId}/devices';
|
static const String getAllDevices = '/projects/{projectId}/devices';
|
||||||
static const String getSpaceDevices =
|
static const String getSpaceDevices = '/projects/{projectId}/devices';
|
||||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
|
||||||
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
||||||
static const String getBatchStatus = '/devices/batch';
|
static const String getBatchStatus = '/devices/batch';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user