mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-10 07:07:17 +00:00
Refactor API endpoint for getting device reports and fix the record title
This commit is contained in:
@ -119,7 +119,7 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
|||||||
Emitter<FlushSensorState> emit) async {
|
Emitter<FlushSensorState> emit) async {
|
||||||
emit(FlushSensorLoadingInitialState());
|
emit(FlushSensorLoadingInitialState());
|
||||||
try {
|
try {
|
||||||
await DevicesAPI.getDeviceReports(deviceId, event.code).then((value) {
|
await DevicesAPI.getReports(deviceId, event.code).then((value) {
|
||||||
emit(FlushSensorDeviceReportsState(
|
emit(FlushSensorDeviceReportsState(
|
||||||
deviceReport: value, code: event.code));
|
deviceReport: value, code: event.code));
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ class FlushPresenceRecords extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: title,
|
title: 'Presence Record',
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) => FlushSensorBloc(deviceId: deviceId)
|
create: (context) => FlushSensorBloc(deviceId: deviceId)
|
||||||
..add(FlushSensorGetDeviceReportsEvent(
|
..add(FlushSensorGetDeviceReportsEvent(
|
||||||
|
@ -61,7 +61,7 @@ class FlushMountedInterface extends StatelessWidget {
|
|||||||
statusBarIconBrightness: Brightness.light,
|
statusBarIconBrightness: Brightness.light,
|
||||||
),
|
),
|
||||||
child: DefaultScaffold(
|
child: DefaultScaffold(
|
||||||
title: deviceModel.name!,
|
title: FlushSensorBloc.deviceName,
|
||||||
actions: [
|
actions: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
@ -11,7 +11,7 @@ class WaterHeaterFunctionsHelper {
|
|||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Reverse Switch',
|
operationName: 'Switch',
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
@ -32,7 +32,7 @@ class WaterHeaterFunctionsHelper {
|
|||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'CountDown',
|
operationName: 'Timer',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.countdown,
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
@ -126,8 +126,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||||
static const String deviceFunctionsStatus =
|
static const String deviceFunctionsStatus =
|
||||||
'/devices/{deviceUuid}/functions/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
static const String powerClamp =
|
static const String powerClamp = '/devices/{deviceUuid}/functions/status';
|
||||||
'/devices/{deviceUuid}/functions/status';
|
|
||||||
|
|
||||||
///Device Permission Module
|
///Device Permission Module
|
||||||
//POST
|
//POST
|
||||||
@ -233,4 +232,6 @@ abstract class ApiEndpoints {
|
|||||||
static const String getPermission = '/permission/{roleUuid}';
|
static const String getPermission = '/permission/{roleUuid}';
|
||||||
static const String getAllDevices =
|
static const String getAllDevices =
|
||||||
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
||||||
|
|
||||||
|
static const String getReportLogs = '/devices/{uuid}/report-logs?code={code}';
|
||||||
}
|
}
|
||||||
|
@ -569,6 +569,22 @@ class DevicesAPI {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<DeviceReport> getReports(
|
||||||
|
String uuid,
|
||||||
|
String code,
|
||||||
|
) async {
|
||||||
|
final response = await HTTPService().get(
|
||||||
|
path: ApiEndpoints.getReportLogs
|
||||||
|
.replaceAll('{uuid}', uuid)
|
||||||
|
.replaceAll('{code}', code),
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) {
|
||||||
|
return DeviceReport.fromJson(json);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
static Future<List<DeviceModel>> getAllDevices({
|
static Future<List<DeviceModel>> getAllDevices({
|
||||||
required String communityUuid,
|
required String communityUuid,
|
||||||
required String spaceUuid,
|
required String spaceUuid,
|
||||||
|
Reference in New Issue
Block a user