mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 09:45:25 +00:00
Compare commits
13 Commits
Build-Sche
...
dev
Author | SHA1 | Date | |
---|---|---|---|
75b9f4a4e6 | |||
fe4063ef8f | |||
029b5d32e0 | |||
428c81efff | |||
288c252f46 | |||
7399dee687 | |||
08e2ed4b4c | |||
59e04708cd | |||
338d4f5737 | |||
5532935a3a | |||
2681c837f5 | |||
b6664ec1ba | |||
dcf1df9b4a |
@ -132,6 +132,8 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
child: SingleChildScrollView(
|
||||
controller: _horizontalScrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics:
|
||||
widget.isEmpty ? const NeverScrollableScrollPhysics() : null,
|
||||
child: SizedBox(
|
||||
width: _totalTableWidth,
|
||||
child: Column(
|
||||
@ -164,7 +166,6 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: widget.isEmpty
|
||||
? _buildEmptyState()
|
||||
@ -265,7 +266,7 @@ class _DynamicTableState extends State<DynamicTable> {
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: widget.size.height * 0.5),
|
||||
SizedBox(height: widget.size.height * 0.2),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -46,15 +46,15 @@ class DeviceManagementBloc
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
||||
devices = await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
||||
devices = await DevicesManagementApi().fetchDevices(
|
||||
projectUuid,
|
||||
);
|
||||
} else {
|
||||
for (final community in spaceBloc.state.selectedCommunities) {
|
||||
for (var community in spaceBloc.state.selectedCommunities) {
|
||||
final spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[community] ?? [];
|
||||
for (final space in spacesList) {
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(community, space, projectUuid));
|
||||
}
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(projectUuid, spacesId: spacesList));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,12 @@ class DeviceManagementPage extends StatefulWidget with HelperResponsiveLayout {
|
||||
}
|
||||
|
||||
class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
||||
|
||||
@override
|
||||
@override
|
||||
void initState() {
|
||||
context.read<SpaceTreeBloc>().add(InitialEvent());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
@ -90,7 +90,7 @@ class _DeviceManagementPageState extends State<DeviceManagementPage> {
|
||||
const TriggerSwitchTabsEvent(isRoutineTab: true));
|
||||
},
|
||||
child: Text(
|
||||
'Routines',
|
||||
'Workflow Automation',
|
||||
style: context.textTheme.titleMedium?.copyWith(
|
||||
color: state.routineTab
|
||||
? ColorsManager.whiteColors
|
||||
|
@ -153,6 +153,7 @@ class EditUserModel {
|
||||
final String? jobTitle; // can be empty
|
||||
final String roleType; // e.g. "ADMIN"
|
||||
final List<UserSpaceModel> spaces;
|
||||
final String? companyName;
|
||||
|
||||
EditUserModel({
|
||||
required this.uuid,
|
||||
@ -167,6 +168,7 @@ class EditUserModel {
|
||||
required this.jobTitle,
|
||||
required this.roleType,
|
||||
required this.spaces,
|
||||
this.companyName,
|
||||
});
|
||||
|
||||
/// Create a [UserData] from JSON data
|
||||
@ -182,6 +184,7 @@ class EditUserModel {
|
||||
invitedBy: json['invitedBy'] as String,
|
||||
phoneNumber: json['phoneNumber'] ?? '',
|
||||
jobTitle: json['jobTitle'] ?? '',
|
||||
companyName: json['companyName'] as String?,
|
||||
roleType: json['roleType'] as String,
|
||||
spaces: (json['spaces'] as List<dynamic>)
|
||||
.map((e) => UserSpaceModel.fromJson(e as Map<String, dynamic>))
|
||||
|
@ -12,7 +12,7 @@ class RolesUserModel {
|
||||
final dynamic jobTitle;
|
||||
final dynamic createdDate;
|
||||
final dynamic createdTime;
|
||||
|
||||
final String? companyName;
|
||||
RolesUserModel({
|
||||
required this.uuid,
|
||||
required this.createdAt,
|
||||
@ -27,6 +27,7 @@ class RolesUserModel {
|
||||
this.jobTitle,
|
||||
required this.createdDate,
|
||||
required this.createdTime,
|
||||
this.companyName,
|
||||
});
|
||||
|
||||
factory RolesUserModel.fromJson(Map<String, dynamic> json) {
|
||||
@ -47,6 +48,7 @@ class RolesUserModel {
|
||||
: json['jobTitle'],
|
||||
createdDate: json['createdDate'],
|
||||
createdTime: json['createdTime'],
|
||||
companyName: json['companyName'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
final TextEditingController lastNameController = TextEditingController();
|
||||
final TextEditingController emailController = TextEditingController();
|
||||
final TextEditingController phoneController = TextEditingController();
|
||||
final TextEditingController jobTitleController = TextEditingController();
|
||||
final TextEditingController companyNameController = TextEditingController();
|
||||
final TextEditingController roleSearchController = TextEditingController();
|
||||
|
||||
bool? isCompleteBasics;
|
||||
@ -352,7 +352,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
bool res = await UserPermissionApi().sendInviteUser(
|
||||
email: emailController.text,
|
||||
firstName: firstNameController.text,
|
||||
jobTitle: jobTitleController.text,
|
||||
companyName: companyNameController.text,
|
||||
lastName: lastNameController.text,
|
||||
phoneNumber: phoneController.text,
|
||||
roleUuid: roleSelected,
|
||||
@ -405,7 +405,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
bool res = await UserPermissionApi().editInviteUser(
|
||||
userId: event.userId,
|
||||
firstName: firstNameController.text,
|
||||
jobTitle: jobTitleController.text,
|
||||
companyName: companyNameController.text,
|
||||
lastName: lastNameController.text,
|
||||
phoneNumber: phoneController.text,
|
||||
roleUuid: roleSelected,
|
||||
@ -455,7 +455,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
Future<void> checkEmail(
|
||||
CheckEmailEvent event, Emitter<UsersState> emit) async {
|
||||
emit(UsersLoadingState());
|
||||
String? res = await UserPermissionApi().checkEmail(
|
||||
String? res = await UserPermissionApi().checkEmail(
|
||||
emailController.text,
|
||||
);
|
||||
checkEmailValid = res!;
|
||||
@ -529,7 +529,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
lastNameController.text = res.lastName;
|
||||
emailController.text = res.email;
|
||||
phoneController.text = res.phoneNumber ?? '';
|
||||
jobTitleController.text = res.jobTitle ?? '';
|
||||
companyNameController.text = res.companyName ?? '';
|
||||
res.roleType;
|
||||
res.spaces.map((space) {
|
||||
selectedIds.add(space.uuid);
|
||||
@ -645,7 +645,7 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
|
||||
lastNameController.dispose();
|
||||
emailController.dispose();
|
||||
phoneController.dispose();
|
||||
jobTitleController.dispose();
|
||||
companyNameController.dispose();
|
||||
roleSearchController.dispose();
|
||||
return super.close();
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ class BasicsView extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Job Title',
|
||||
'Company Name',
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
@ -328,11 +328,11 @@ class BasicsView extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
controller: _blocRole.jobTitleController,
|
||||
controller: _blocRole.companyNameController,
|
||||
style:
|
||||
const TextStyle(color: ColorsManager.blackColor),
|
||||
decoration: inputTextFormDeco(
|
||||
hintText: "Job Title (Optional)")
|
||||
hintText: 'Company Name (Optional)')
|
||||
.copyWith(
|
||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
|
@ -411,7 +411,7 @@ class UsersPage extends StatelessWidget {
|
||||
titles: const [
|
||||
"Full Name",
|
||||
"Email Address",
|
||||
"Job Title",
|
||||
"Company Name",
|
||||
"Role",
|
||||
"Creation Date",
|
||||
"Creation Time",
|
||||
@ -424,7 +424,7 @@ class UsersPage extends StatelessWidget {
|
||||
return [
|
||||
Text('${user.firstName} ${user.lastName}'),
|
||||
Text(user.email),
|
||||
Text(user.jobTitle),
|
||||
Center(child: Text(user.companyName ?? '-')),
|
||||
Text(user.roleType ?? ''),
|
||||
Text(user.createdDate ?? ''),
|
||||
Text(user.createdTime ?? ''),
|
||||
|
@ -170,45 +170,45 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadScenes(
|
||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
List<ScenesModel> scenes = [];
|
||||
try {
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
scenes.addAll(
|
||||
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
||||
Future<void> _onLoadScenes(
|
||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
List<ScenesModel> scenes = [];
|
||||
try {
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
scenes.addAll(
|
||||
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(
|
||||
scenes: scenes,
|
||||
isLoading: false,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(state.copyWith(
|
||||
emit(state.copyWith(
|
||||
scenes: scenes,
|
||||
isLoading: false,
|
||||
loadScenesErrorMessage: 'Failed to load scenes',
|
||||
errorMessage: '',
|
||||
loadAutomationErrorMessage: '',
|
||||
scenes: scenes));
|
||||
));
|
||||
} catch (e) {
|
||||
emit(state.copyWith(
|
||||
isLoading: false,
|
||||
loadScenesErrorMessage: 'Failed to load scenes',
|
||||
errorMessage: '',
|
||||
loadAutomationErrorMessage: '',
|
||||
scenes: scenes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadAutomation(
|
||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||
@ -936,16 +936,15 @@ Future<void> _onLoadScenes(
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(communityId, spaceId, projectUuid));
|
||||
}
|
||||
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(projectUuid, spacesId: spacesList));
|
||||
}
|
||||
} else {
|
||||
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||
createRoutineBloc.selectedCommunityId,
|
||||
createRoutineBloc.selectedSpaceId,
|
||||
projectUuid));
|
||||
projectUuid,
|
||||
spacesId: [createRoutineBloc.selectedSpaceId],
|
||||
));
|
||||
}
|
||||
|
||||
emit(state.copyWith(isLoading: false, devices: devices));
|
||||
|
@ -96,9 +96,7 @@ class _WallPresenceSensorState extends State<FlushPresenceSensor> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DialogHeader(widget.dialogType == 'THEN'
|
||||
? 'Presence Sensor Functions'
|
||||
: 'Presence Sensor Condition'),
|
||||
const DialogHeader('Presence Sensor'),
|
||||
Expanded(child: _buildMainContent(context, state)),
|
||||
_buildDialogFooter(context, state),
|
||||
],
|
||||
|
@ -12,20 +12,16 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
class DevicesManagementApi {
|
||||
Future<List<AllDevicesModel>> fetchDevices(
|
||||
String communityId, String spaceId, String projectId) async {
|
||||
Future<List<AllDevicesModel>> fetchDevices(String projectId,
|
||||
{List<String>? spacesId}) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: communityId.isNotEmpty && spaceId.isNotEmpty
|
||||
? ApiEndpoints.getSpaceDevices
|
||||
.replaceAll('{spaceUuid}', spaceId)
|
||||
.replaceAll('{communityUuid}', communityId)
|
||||
.replaceAll('{projectId}', projectId)
|
||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
||||
path: ApiEndpoints.getSpaceDevices.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {if (spacesId != null) 'spaces': spacesId},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json['data'];
|
||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
final List<dynamic> jsonData = json['data'] as List<dynamic>;
|
||||
final List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
return AllDevicesModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
return devicesList;
|
||||
@ -416,5 +412,4 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,8 +34,9 @@ class UserPermissionApi {
|
||||
path: ApiEndpoints.roleTypes,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
final List<RoleTypeModel> fetchedRoles =
|
||||
(json['data'] as List).map((item) => RoleTypeModel.fromJson(item)).toList();
|
||||
final List<RoleTypeModel> fetchedRoles = (json['data'] as List)
|
||||
.map((item) => RoleTypeModel.fromJson(item))
|
||||
.toList();
|
||||
return fetchedRoles;
|
||||
},
|
||||
);
|
||||
@ -47,7 +48,9 @@ class UserPermissionApi {
|
||||
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return (json as List).map((data) => PermissionOption.fromJson(data)).toList();
|
||||
return (json as List)
|
||||
.map((data) => PermissionOption.fromJson(data))
|
||||
.toList();
|
||||
},
|
||||
);
|
||||
return response ?? [];
|
||||
@ -57,7 +60,7 @@ class UserPermissionApi {
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? email,
|
||||
String? jobTitle,
|
||||
String? companyName,
|
||||
String? phoneNumber,
|
||||
String? roleUuid,
|
||||
List<String>? spaceUuids,
|
||||
@ -68,7 +71,7 @@ class UserPermissionApi {
|
||||
"firstName": firstName,
|
||||
"lastName": lastName,
|
||||
"email": email,
|
||||
"jobTitle": jobTitle != '' ? jobTitle : null,
|
||||
"companyName": companyName != '' ? companyName : null,
|
||||
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
|
||||
"roleUuid": roleUuid,
|
||||
"projectUuid": projectUuid,
|
||||
@ -140,7 +143,7 @@ class UserPermissionApi {
|
||||
String? firstName,
|
||||
String? userId,
|
||||
String? lastName,
|
||||
String? jobTitle,
|
||||
String? companyName,
|
||||
String? phoneNumber,
|
||||
String? roleUuid,
|
||||
List<String>? spaceUuids,
|
||||
@ -150,8 +153,8 @@ class UserPermissionApi {
|
||||
final body = <String, dynamic>{
|
||||
"firstName": firstName,
|
||||
"lastName": lastName,
|
||||
"jobTitle": jobTitle != '' ? jobTitle : " ",
|
||||
"phoneNumber": phoneNumber != '' ? phoneNumber : " ",
|
||||
"companyName": companyName != '' ? companyName : ' ',
|
||||
"phoneNumber": phoneNumber != '' ? phoneNumber : ' ',
|
||||
"roleUuid": roleUuid,
|
||||
"projectUuid": projectUuid,
|
||||
"spaceUuids": spaceUuids,
|
||||
@ -190,12 +193,17 @@ class UserPermissionApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> changeUserStatusById(userUuid, status, String projectUuid) async {
|
||||
Future<bool> changeUserStatusById(
|
||||
userUuid, status, String projectUuid) async {
|
||||
try {
|
||||
Map<String, dynamic> bodya = {"disable": status, "projectUuid": projectUuid};
|
||||
Map<String, dynamic> bodya = {
|
||||
"disable": status,
|
||||
"projectUuid": projectUuid
|
||||
};
|
||||
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.changeUserStatus.replaceAll("{invitedUserUuid}", userUuid),
|
||||
path: ApiEndpoints.changeUserStatus
|
||||
.replaceAll("{invitedUserUuid}", userUuid),
|
||||
body: bodya,
|
||||
expectedResponseModel: (json) {
|
||||
return json['success'];
|
||||
|
@ -17,8 +17,7 @@ abstract class ApiEndpoints {
|
||||
////// Devices Management ////////////////
|
||||
|
||||
static const String getAllDevices = '/projects/{projectId}/devices';
|
||||
static const String getSpaceDevices =
|
||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
||||
static const String getSpaceDevices = '/projects/{projectId}/devices';
|
||||
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/devices/batch';
|
||||
|
||||
|
Reference in New Issue
Block a user