mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 17:47:53 +00:00
Compare commits
53 Commits
On-change-
...
Community-
Author | SHA1 | Date | |
---|---|---|---|
b97183fb61 | |||
07dfe6b206 | |||
c4fd90b3bc | |||
bbcb947313 | |||
13e9a808ab | |||
3fc6964e15 | |||
4744009cb6 | |||
5beae81596 | |||
f1144762b0 | |||
ca41aa6224 | |||
2d0019200e | |||
475462301f | |||
731ba7a768 | |||
7fda564ee4 | |||
11e2853403 | |||
9c02bed4c0 | |||
4f932b8c35 | |||
44ae8386df | |||
9d4a665547 | |||
8593055923 | |||
18ab9fd24c | |||
3c9494963d | |||
07dd260593 | |||
f38ac58442 | |||
30e940fdfc | |||
520b73717a | |||
e1bb67d7bd | |||
5e0df09cb6 | |||
22070ca04a | |||
6d667af7dc | |||
3b4952db0a | |||
5f59583696 | |||
7397486e7a | |||
487c5a894b | |||
7e0200aad8 | |||
562c67a958 | |||
52b843d514 | |||
423ad6e687 | |||
932e50f518 | |||
c649044a1f | |||
f901983aa5 | |||
010403f1fa | |||
ee1ebeae2e | |||
6e6ef79ed0 | |||
7e5825de45 | |||
95d6e1ecda | |||
d14cc785a8 | |||
379ecec789 | |||
ad00cf35ba | |||
5276f4186c | |||
e6957d566d | |||
71cf0a636e | |||
1200a809c2 |
@ -25,8 +25,8 @@ class AnalyticsDevice {
|
|||||||
|
|
||||||
factory AnalyticsDevice.fromJson(Map<String, dynamic> json) {
|
factory AnalyticsDevice.fromJson(Map<String, dynamic> json) {
|
||||||
return AnalyticsDevice(
|
return AnalyticsDevice(
|
||||||
uuid: json['uuid'] as String,
|
uuid: json['uuid'] as String? ?? '',
|
||||||
name: json['name'] as String,
|
name: json['name'] as String? ?? '',
|
||||||
createdAt: json['createdAt'] != null
|
createdAt: json['createdAt'] != null
|
||||||
? DateTime.parse(json['createdAt'] as String)
|
? DateTime.parse(json['createdAt'] as String)
|
||||||
: null,
|
: null,
|
||||||
@ -39,8 +39,8 @@ class AnalyticsDevice {
|
|||||||
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
|
? ProductDevice.fromJson(json['productDevice'] as Map<String, dynamic>)
|
||||||
: null,
|
: null,
|
||||||
spaceUuid: json['spaceUuid'] as String?,
|
spaceUuid: json['spaceUuid'] as String?,
|
||||||
latitude: json['lat'] != null ? double.parse(json['lat'] as String) : null,
|
latitude: json['lat'] != null ? double.parse(json['lat'] as String? ?? '0.0') : null,
|
||||||
longitude: json['lon'] != null ? double.parse(json['lon'] as String) : null,
|
longitude: json['lon'] != null ? double.parse(json['lon'] as String? ?? '0.0') : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,21 @@ class OccupancyHeatMapModel extends Equatable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
|
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
final eventDate = json['event_date'] as String?;
|
||||||
|
final year = eventDate?.split('-')[0];
|
||||||
|
final month = eventDate?.split('-')[1];
|
||||||
|
final day = eventDate?.split('-')[2];
|
||||||
|
|
||||||
return OccupancyHeatMapModel(
|
return OccupancyHeatMapModel(
|
||||||
uuid: json['uuid'] as String? ?? '',
|
uuid: json['uuid'] as String? ?? '',
|
||||||
eventDate: DateTime.parse(
|
eventDate: DateTime.utc(
|
||||||
json['event_date'] as String? ?? '${DateTime.now()}',
|
int.parse(year ?? '2025'),
|
||||||
|
int.parse(month ?? '1'),
|
||||||
|
int.parse(day ?? '1'),
|
||||||
),
|
),
|
||||||
countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0,
|
countTotalPresenceDetected: num.parse(
|
||||||
|
json['count_total_presence_detected']?.toString() ?? '0',
|
||||||
|
).toInt(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/air_qualit
|
|||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/range_of_aqi/range_of_aqi_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_date_picker_bloc/analytics_date_picker_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_devices/analytics_devices_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_devices/analytics_devices_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_param.dart';
|
import 'package:syncrow_web/pages/analytics/params/get_air_quality_distribution_param.dart';
|
||||||
@ -22,7 +21,6 @@ abstract final class FetchAirQualityDataHelper {
|
|||||||
required String spaceUuid,
|
required String spaceUuid,
|
||||||
bool shouldFetchAnalyticsDevices = true,
|
bool shouldFetchAnalyticsDevices = true,
|
||||||
}) {
|
}) {
|
||||||
final date = context.read<AnalyticsDatePickerBloc>().state.monthlyDate;
|
|
||||||
final aqiType = context.read<AirQualityDistributionBloc>().state.selectedAqiType;
|
final aqiType = context.read<AirQualityDistributionBloc>().state.selectedAqiType;
|
||||||
if (shouldFetchAnalyticsDevices) {
|
if (shouldFetchAnalyticsDevices) {
|
||||||
loadAnalyticsDevices(
|
loadAnalyticsDevices(
|
||||||
|
@ -18,7 +18,11 @@ abstract final class RangeOfAqiChartsHelper {
|
|||||||
(ColorsManager.hazardousPurple, 'Hazardous'),
|
(ColorsManager.hazardousPurple, 'Hazardous'),
|
||||||
];
|
];
|
||||||
|
|
||||||
static FlTitlesData titlesData(BuildContext context, List<RangeOfAqi> data) {
|
static FlTitlesData titlesData(
|
||||||
|
BuildContext context,
|
||||||
|
List<RangeOfAqi> data, {
|
||||||
|
double leftSideInterval = 50,
|
||||||
|
}) {
|
||||||
final titlesData = EnergyManagementChartsHelper.titlesData(context);
|
final titlesData = EnergyManagementChartsHelper.titlesData(context);
|
||||||
return titlesData.copyWith(
|
return titlesData.copyWith(
|
||||||
bottomTitles: titlesData.bottomTitles.copyWith(
|
bottomTitles: titlesData.bottomTitles.copyWith(
|
||||||
@ -39,11 +43,11 @@ abstract final class RangeOfAqiChartsHelper {
|
|||||||
leftTitles: titlesData.leftTitles.copyWith(
|
leftTitles: titlesData.leftTitles.copyWith(
|
||||||
sideTitles: titlesData.leftTitles.sideTitles.copyWith(
|
sideTitles: titlesData.leftTitles.sideTitles.copyWith(
|
||||||
reservedSize: 70,
|
reservedSize: 70,
|
||||||
interval: 50,
|
interval: leftSideInterval,
|
||||||
maxIncluded: false,
|
maxIncluded: false,
|
||||||
minIncluded: true,
|
minIncluded: true,
|
||||||
getTitlesWidget: (value, meta) {
|
getTitlesWidget: (value, meta) {
|
||||||
final text = value >= 300 ? '301+' : value.toInt().toString();
|
final text = value.toInt().toString();
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
|
@ -65,7 +65,7 @@ class AqiDeviceInfo extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
final tvocValue = _getValueForStatus(
|
final tvocValue = _getValueForStatus(
|
||||||
status,
|
status,
|
||||||
'tvoc_value',
|
'voc_value',
|
||||||
formatter: (value) => (value / 100).toStringAsFixed(2),
|
formatter: (value) => (value / 100).toStringAsFixed(2),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/models/air_quality_data_model.dart';
|
import 'package:syncrow_web/pages/analytics/models/air_quality_data_model.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/widgets/charts_x_axis_title.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ class AqiDistributionChart extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final bottomTitles = AxisTitles(
|
final bottomTitles = AxisTitles(
|
||||||
|
axisNameWidget: const ChartsXAxisTitle(),
|
||||||
sideTitles: SideTitles(
|
sideTitles: SideTitles(
|
||||||
showTitles: chartData.isNotEmpty,
|
showTitles: chartData.isNotEmpty,
|
||||||
getTitlesWidget: (value, _) => FittedBox(
|
getTitlesWidget: (value, _) => FittedBox(
|
||||||
|
@ -6,8 +6,8 @@ enum AqiType {
|
|||||||
aqi('AQI', '', 'aqi'),
|
aqi('AQI', '', 'aqi'),
|
||||||
pm25('PM2.5', 'µg/m³', 'pm25'),
|
pm25('PM2.5', 'µg/m³', 'pm25'),
|
||||||
pm10('PM10', 'µg/m³', 'pm10'),
|
pm10('PM10', 'µg/m³', 'pm10'),
|
||||||
hcho('HCHO', 'mg/m³', 'cho2'),
|
hcho('HCHO', 'mg/m³', 'ch2o'),
|
||||||
tvoc('TVOC', 'µg/m³', 'voc'),
|
tvoc('TVOC', 'mg/m³', 'voc'),
|
||||||
co2('CO2', 'ppm', 'co2');
|
co2('CO2', 'ppm', 'co2');
|
||||||
|
|
||||||
const AqiType(this.value, this.unit, this.code);
|
const AqiType(this.value, this.unit, this.code);
|
||||||
|
@ -2,15 +2,18 @@ import 'package:fl_chart/fl_chart.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
import 'package:syncrow_web/pages/analytics/models/range_of_aqi.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/air_quality/helpers/range_of_aqi_charts_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/helpers/range_of_aqi_charts_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_type_dropdown.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class RangeOfAqiChart extends StatelessWidget {
|
class RangeOfAqiChart extends StatelessWidget {
|
||||||
final List<RangeOfAqi> chartData;
|
final List<RangeOfAqi> chartData;
|
||||||
|
final AqiType selectedAqiType;
|
||||||
|
|
||||||
const RangeOfAqiChart({
|
const RangeOfAqiChart({
|
||||||
super.key,
|
super.key,
|
||||||
required this.chartData,
|
required this.chartData,
|
||||||
|
required this.selectedAqiType,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<(List<double> values, Color color, Color? dotColor)> get _lines {
|
List<(List<double> values, Color color, Color? dotColor)> get _lines {
|
||||||
@ -45,15 +48,34 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(double maxY, double interval) get _maxYForAqiType {
|
||||||
|
const aqiMaxValues = <AqiType, (double maxY, double interval)>{
|
||||||
|
AqiType.aqi: (401, 100),
|
||||||
|
AqiType.pm25: (351, 50),
|
||||||
|
AqiType.pm10: (501, 100),
|
||||||
|
AqiType.hcho: (301, 50),
|
||||||
|
AqiType.tvoc: (501, 50),
|
||||||
|
AqiType.co2: (1251, 250),
|
||||||
|
};
|
||||||
|
|
||||||
|
return aqiMaxValues[selectedAqiType]!;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LineChart(
|
return LineChart(
|
||||||
LineChartData(
|
LineChartData(
|
||||||
minY: 0,
|
minY: 0,
|
||||||
maxY: 301,
|
maxY: _maxYForAqiType.$1,
|
||||||
clipData: const FlClipData.vertical(),
|
clipData: const FlClipData.vertical(),
|
||||||
gridData: EnergyManagementChartsHelper.gridData(horizontalInterval: 50),
|
gridData: EnergyManagementChartsHelper.gridData(
|
||||||
titlesData: RangeOfAqiChartsHelper.titlesData(context, chartData),
|
horizontalInterval: _maxYForAqiType.$2,
|
||||||
|
),
|
||||||
|
titlesData: RangeOfAqiChartsHelper.titlesData(
|
||||||
|
context,
|
||||||
|
chartData,
|
||||||
|
leftSideInterval: _maxYForAqiType.$2,
|
||||||
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
lineTouchData: RangeOfAqiChartsHelper.lineTouchData(chartData),
|
lineTouchData: RangeOfAqiChartsHelper.lineTouchData(chartData),
|
||||||
betweenBarsData: [
|
betweenBarsData: [
|
||||||
|
@ -32,7 +32,12 @@ class RangeOfAqiChartBox extends StatelessWidget {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(child: RangeOfAqiChart(chartData: state.filteredRangeOfAqi)),
|
Expanded(
|
||||||
|
child: RangeOfAqiChart(
|
||||||
|
chartData: state.filteredRangeOfAqi,
|
||||||
|
selectedAqiType: state.selectedAqiType,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/helpers/format_number_to_kwh.dart';
|
import 'package:syncrow_web/pages/analytics/helpers/format_number_to_kwh.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/widgets/charts_x_axis_title.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
return FlTitlesData(
|
return FlTitlesData(
|
||||||
show: true,
|
show: true,
|
||||||
bottomTitles: AxisTitles(
|
bottomTitles: AxisTitles(
|
||||||
|
axisNameWidget: const ChartsXAxisTitle(),
|
||||||
drawBelowEverything: true,
|
drawBelowEverything: true,
|
||||||
sideTitles: SideTitles(
|
sideTitles: SideTitles(
|
||||||
interval: 1,
|
interval: 1,
|
||||||
@ -62,17 +64,12 @@ abstract final class EnergyManagementChartsHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getToolTipLabel(num month, double value) {
|
static String getToolTipLabel(double value) => value.formatNumberToKwh;
|
||||||
final monthLabel = month.toString();
|
|
||||||
final valueLabel = value.formatNumberToKwh;
|
|
||||||
final labels = [monthLabel, valueLabel];
|
|
||||||
return labels.where((element) => element.isNotEmpty).join(', ');
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<LineTooltipItem?> getTooltipItems(List<LineBarSpot> touchedSpots) {
|
static List<LineTooltipItem?> getTooltipItems(List<LineBarSpot> touchedSpots) {
|
||||||
return touchedSpots.map((spot) {
|
return touchedSpots.map((spot) {
|
||||||
return LineTooltipItem(
|
return LineTooltipItem(
|
||||||
getToolTipLabel(spot.x, spot.y),
|
getToolTipLabel(spot.y),
|
||||||
const TextStyle(
|
const TextStyle(
|
||||||
color: ColorsManager.textPrimaryColor,
|
color: ColorsManager.textPrimaryColor,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
@ -28,15 +28,29 @@ class AnalyticsDeviceDropdown extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Visibility(
|
child: Visibility(
|
||||||
visible: state.devices.isNotEmpty,
|
visible: state.status != AnalyticsDevicesStatus.loading,
|
||||||
replacement: _buildNoDevicesFound(context),
|
replacement: _buildLoadingIndicator(),
|
||||||
child: _buildDevicesDropdown(context, state),
|
child: Visibility(
|
||||||
|
visible: state.devices.isNotEmpty,
|
||||||
|
replacement: _buildNoDevicesFound(context),
|
||||||
|
child: _buildDevicesDropdown(context, state),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildLoadingIndicator() {
|
||||||
|
return const Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 3),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static const _defaultPadding = EdgeInsetsDirectional.symmetric(
|
static const _defaultPadding = EdgeInsetsDirectional.symmetric(
|
||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
vertical: 2,
|
vertical: 2,
|
||||||
|
@ -37,7 +37,7 @@ class EnergyConsumptionPerDeviceChartBox extends StatelessWidget {
|
|||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: ChartTitle(
|
child: ChartTitle(
|
||||||
title: Text('Energy Consumption per Device'),
|
title: Text('Device energy consumed'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -14,14 +14,17 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
|||||||
return Expanded(
|
return Expanded(
|
||||||
child: LineChart(
|
child: LineChart(
|
||||||
LineChartData(
|
LineChartData(
|
||||||
|
maxY: chartData.isEmpty
|
||||||
|
? null
|
||||||
|
: chartData.map((e) => e.value).reduce((a, b) => a > b ? a : b) + 250,
|
||||||
clipData: const FlClipData.vertical(),
|
clipData: const FlClipData.vertical(),
|
||||||
titlesData: EnergyManagementChartsHelper.titlesData(
|
titlesData: EnergyManagementChartsHelper.titlesData(
|
||||||
context,
|
context,
|
||||||
leftTitlesInterval: 250,
|
leftTitlesInterval: 500,
|
||||||
),
|
),
|
||||||
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
gridData: EnergyManagementChartsHelper.gridData().copyWith(
|
||||||
checkToShowHorizontalLine: (value) => true,
|
checkToShowHorizontalLine: (value) => true,
|
||||||
horizontalInterval: 250,
|
horizontalInterval: 500,
|
||||||
),
|
),
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
lineTouchData: EnergyManagementChartsHelper.lineTouchData(),
|
||||||
@ -29,7 +32,6 @@ class TotalEnergyConsumptionChart extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
duration: Duration.zero,
|
duration: Duration.zero,
|
||||||
curve: Curves.easeIn,
|
curve: Curves.easeIn,
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class TotalEnergyConsumptionChartBox extends StatelessWidget {
|
|||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: ChartTitle(title: Text('Total Energy Consumption')),
|
child: ChartTitle(title: Text('Space energy consumed')),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(flex: 4),
|
const Spacer(flex: 4),
|
||||||
|
@ -81,7 +81,7 @@ abstract final class FetchOccupancyDataHelper {
|
|||||||
param: GetAnalyticsDevicesParam(
|
param: GetAnalyticsDevicesParam(
|
||||||
communityUuid: communityUuid,
|
communityUuid: communityUuid,
|
||||||
spaceUuid: spaceUuid,
|
spaceUuid: spaceUuid,
|
||||||
deviceTypes: ['WPS', 'CPS'],
|
deviceTypes: ['WPS', 'CPS', 'NCPS'],
|
||||||
requestType: AnalyticsDeviceRequestType.occupancy,
|
requestType: AnalyticsDeviceRequestType.occupancy,
|
||||||
),
|
),
|
||||||
onSuccess: (device) {
|
onSuccess: (device) {
|
||||||
|
@ -20,7 +20,7 @@ class AnalyticsOccupancyView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
spacing: 32,
|
spacing: 32,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(height: height * 0.46, child: const OccupancyEndSideBar()),
|
SizedBox(height: height * 0.8, child: const OccupancyEndSideBar()),
|
||||||
SizedBox(height: height * 0.5, child: const OccupancyChartBox()),
|
SizedBox(height: height * 0.5, child: const OccupancyChartBox()),
|
||||||
SizedBox(height: height * 0.5, child: const OccupancyHeatMapBox()),
|
SizedBox(height: height * 0.5, child: const OccupancyHeatMapBox()),
|
||||||
],
|
],
|
||||||
|
@ -39,7 +39,7 @@ class HeatMapTooltip extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const Divider(height: 2, thickness: 1),
|
const Divider(height: 2, thickness: 1),
|
||||||
Text(
|
Text(
|
||||||
'$value Occupants',
|
'Occupancy detected: $value',
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
|
@ -52,7 +52,7 @@ class _InteractiveHeatMapState extends State<InteractiveHeatMap> {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Transform.translate(
|
child: Transform.translate(
|
||||||
offset: Offset(-(widget.cellSize * 2.5), -50),
|
offset: Offset(-(widget.cellSize * 2.5), -50),
|
||||||
child: HeatMapTooltip(date: item.date, value: item.value),
|
child: HeatMapTooltip(date: item.date.toUtc(), value: item.value),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,6 +2,7 @@ import 'package:fl_chart/fl_chart.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/models/occupacy.dart';
|
import 'package:syncrow_web/pages/analytics/models/occupacy.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/energy_management_charts_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/widgets/charts_x_axis_title.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -88,8 +89,8 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
final data = chartData;
|
final data = chartData;
|
||||||
|
|
||||||
final occupancyValue = double.parse(data[group.x.toInt()].occupancy);
|
final occupancyValue = double.parse(data[group.x].occupancy);
|
||||||
final percentage = '${(occupancyValue).toStringAsFixed(0)}%';
|
final percentage = '${occupancyValue.toStringAsFixed(0)}%';
|
||||||
|
|
||||||
return BarTooltipItem(
|
return BarTooltipItem(
|
||||||
percentage,
|
percentage,
|
||||||
@ -116,7 +117,7 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(value).toStringAsFixed(0)}%',
|
'${value.toStringAsFixed(0)}%',
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
@ -128,6 +129,7 @@ class OccupancyChart extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final bottomTitles = AxisTitles(
|
final bottomTitles = AxisTitles(
|
||||||
|
axisNameWidget: const ChartsXAxisTitle(),
|
||||||
sideTitles: SideTitles(
|
sideTitles: SideTitles(
|
||||||
showTitles: true,
|
showTitles: true,
|
||||||
getTitlesWidget: (value, _) => FittedBox(
|
getTitlesWidget: (value, _) => FittedBox(
|
||||||
|
@ -23,10 +23,9 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const AnalyticsSidebarHeader(title: 'Presnce Sensor'),
|
const AnalyticsSidebarHeader(title: 'Presence Sensor'),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
// height: MediaQuery.sizeOf(context).height * 0.2,
|
|
||||||
child: PowerClampEnergyStatusWidget(
|
child: PowerClampEnergyStatusWidget(
|
||||||
status: [
|
status: [
|
||||||
PowerClampEnergyStatus(
|
PowerClampEnergyStatus(
|
||||||
|
@ -9,8 +9,13 @@ import 'package:syncrow_web/pages/analytics/modules/occupancy/widgets/occupancy_
|
|||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class OccupancyHeatMap extends StatelessWidget {
|
class OccupancyHeatMap extends StatelessWidget {
|
||||||
const OccupancyHeatMap({required this.heatMapData, super.key});
|
const OccupancyHeatMap({
|
||||||
|
required this.heatMapData,
|
||||||
|
required this.selectedDate,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
final Map<DateTime, int> heatMapData;
|
final Map<DateTime, int> heatMapData;
|
||||||
|
final DateTime selectedDate;
|
||||||
|
|
||||||
static const _cellSize = 16.0;
|
static const _cellSize = 16.0;
|
||||||
static const _totalWeeks = 53;
|
static const _totalWeeks = 53;
|
||||||
@ -20,7 +25,7 @@ class OccupancyHeatMap extends StatelessWidget {
|
|||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
DateTime _getStartingDate() {
|
DateTime _getStartingDate() {
|
||||||
final jan1 = DateTime(DateTime.now().year, 1, 1);
|
final jan1 = DateTime.utc(selectedDate.year, 1, 1);
|
||||||
final startOfWeek = jan1.subtract(Duration(days: jan1.weekday - 1));
|
final startOfWeek = jan1.subtract(Duration(days: jan1.weekday - 1));
|
||||||
return startOfWeek;
|
return startOfWeek;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ class OccupancyHeatMapBox extends StatelessWidget {
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: OccupancyHeatMap(
|
child: OccupancyHeatMap(
|
||||||
|
selectedDate:
|
||||||
|
context.watch<AnalyticsDatePickerBloc>().state.yearlyDate,
|
||||||
heatMapData: state.heatMapData.asMap().map(
|
heatMapData: state.heatMapData.asMap().map(
|
||||||
(_, value) => MapEntry(
|
(_, value) => MapEntry(
|
||||||
value.eventDate,
|
value.eventDate,
|
||||||
|
23
lib/pages/analytics/widgets/charts_x_axis_title.dart
Normal file
23
lib/pages/analytics/widgets/charts_x_axis_title.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class ChartsXAxisTitle extends StatelessWidget {
|
||||||
|
const ChartsXAxisTitle({
|
||||||
|
this.label = 'Day of month',
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text(
|
||||||
|
label,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.lightGreyColor,
|
||||||
|
fontSize: 8,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
////////////////////////////// forget password //////////////////////////////////
|
////////////////////////////// forget password //////////////////////////////////
|
||||||
final TextEditingController forgetEmailController = TextEditingController();
|
final TextEditingController forgetEmailController = TextEditingController();
|
||||||
final TextEditingController forgetPasswordController = TextEditingController();
|
final TextEditingController forgetPasswordController =
|
||||||
|
TextEditingController();
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
final forgetEmailKey = GlobalKey<FormState>();
|
final forgetEmailKey = GlobalKey<FormState>();
|
||||||
@ -53,7 +54,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_remainingTime = 1;
|
_remainingTime = 1;
|
||||||
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
add(UpdateTimerEvent(
|
||||||
|
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
try {
|
try {
|
||||||
forgetEmailValidate = '';
|
forgetEmailValidate = '';
|
||||||
_remainingTime = (await AuthenticationAPI.sendOtp(
|
_remainingTime = (await AuthenticationAPI.sendOtp(
|
||||||
@ -90,7 +92,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
||||||
} else {
|
} else {
|
||||||
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
add(UpdateTimerEvent(
|
||||||
|
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -100,7 +103,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(
|
Future<void> changePassword(
|
||||||
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
try {
|
try {
|
||||||
@ -122,7 +125,6 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String? validateCode(String? value) {
|
String? validateCode(String? value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Code is required';
|
return 'Code is required';
|
||||||
@ -131,7 +133,9 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
||||||
emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime));
|
emit(TimerState(
|
||||||
|
isButtonEnabled: event.isButtonEnabled,
|
||||||
|
remainingTime: event.remainingTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////// login /////////////////////////////////////
|
///////////////////////////////////// login /////////////////////////////////////
|
||||||
@ -151,7 +155,6 @@ Future<void> changePassword(
|
|||||||
static UserModel? user;
|
static UserModel? user;
|
||||||
bool showValidationMessage = false;
|
bool showValidationMessage = false;
|
||||||
|
|
||||||
|
|
||||||
void _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
|
void _login(LoginButtonPressed event, Emitter<AuthState> emit) async {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
@ -170,11 +173,11 @@ Future<void> changePassword(
|
|||||||
);
|
);
|
||||||
} on APIException catch (e) {
|
} on APIException catch (e) {
|
||||||
validate = e.message;
|
validate = e.message;
|
||||||
emit(LoginInitial());
|
emit(LoginFailure(error: validate));
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
validate = 'Something went wrong';
|
validate = 'Something went wrong';
|
||||||
emit(LoginInitial());
|
emit(LoginFailure(error: validate));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +200,6 @@ Future<void> changePassword(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
checkBoxToggle(
|
checkBoxToggle(
|
||||||
CheckBoxEvent event,
|
CheckBoxEvent event,
|
||||||
Emitter<AuthState> emit,
|
Emitter<AuthState> emit,
|
||||||
@ -339,12 +341,14 @@ Future<void> changePassword(
|
|||||||
static Future<String> getTokenAndValidate() async {
|
static Future<String> getTokenAndValidate() async {
|
||||||
try {
|
try {
|
||||||
const storage = FlutterSecureStorage();
|
const storage = FlutterSecureStorage();
|
||||||
final firstLaunch =
|
final firstLaunch = await SharedPreferencesHelper.readBoolFromSP(
|
||||||
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
|
StringsManager.firstLaunch) ??
|
||||||
|
true;
|
||||||
if (firstLaunch) {
|
if (firstLaunch) {
|
||||||
storage.deleteAll();
|
storage.deleteAll();
|
||||||
}
|
}
|
||||||
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
|
await SharedPreferencesHelper.saveBoolToSP(
|
||||||
|
StringsManager.firstLaunch, false);
|
||||||
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return 'Token not found';
|
return 'Token not found';
|
||||||
@ -397,7 +401,9 @@ Future<void> changePassword(
|
|||||||
final String formattedTime = [
|
final String formattedTime = [
|
||||||
if (days > 0) '${days}d', // Append 'd' for days
|
if (days > 0) '${days}d', // Append 'd' for days
|
||||||
if (days > 0 || hours > 0)
|
if (days > 0 || hours > 0)
|
||||||
hours.toString().padLeft(2, '0'), // Show hours if there are days or hours
|
hours
|
||||||
|
.toString()
|
||||||
|
.padLeft(2, '0'), // Show hours if there are days or hours
|
||||||
minutes.toString().padLeft(2, '0'),
|
minutes.toString().padLeft(2, '0'),
|
||||||
seconds.toString().padLeft(2, '0'),
|
seconds.toString().padLeft(2, '0'),
|
||||||
].join(':');
|
].join(':');
|
||||||
|
@ -68,24 +68,25 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _listenToChanges(deviceId) {
|
StreamSubscription<DatabaseEvent>? _deviceStatusSubscription;
|
||||||
|
|
||||||
|
void _listenToChanges(String deviceId) {
|
||||||
try {
|
try {
|
||||||
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
final ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||||
final stream = ref.onValue;
|
_deviceStatusSubscription = ref.onValue.listen((DatabaseEvent event) async {
|
||||||
|
|
||||||
stream.listen((DatabaseEvent event) async {
|
|
||||||
if (event.snapshot.value == null) return;
|
if (event.snapshot.value == null) return;
|
||||||
|
|
||||||
Map<dynamic, dynamic> usersMap =
|
final usersMap = event.snapshot.value! as Map<dynamic, dynamic>;
|
||||||
event.snapshot.value as Map<dynamic, dynamic>;
|
|
||||||
|
|
||||||
List<Status> statusList = [];
|
final statusList = <Status>[];
|
||||||
|
|
||||||
usersMap['status'].forEach((element) {
|
usersMap['status'].forEach((element) {
|
||||||
statusList.add(Status(code: element['code'], value: element['value']));
|
statusList.add(Status(code: element['code'], value: element['value']));
|
||||||
});
|
});
|
||||||
|
|
||||||
deviceStatus = AcStatusModel.fromJson(usersMap['productUuid'], statusList);
|
deviceStatus = AcStatusModel.fromJson(usersMap['productUuid'], statusList);
|
||||||
|
print('Device status updated: ${deviceStatus.acSwitch}');
|
||||||
|
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
add(AcStatusUpdated(deviceStatus));
|
add(AcStatusUpdated(deviceStatus));
|
||||||
}
|
}
|
||||||
@ -105,22 +106,14 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
AcControlEvent event,
|
AcControlEvent event,
|
||||||
Emitter<AcsState> emit,
|
Emitter<AcsState> emit,
|
||||||
) async {
|
) async {
|
||||||
emit(AcsLoadingState());
|
|
||||||
_updateDeviceFunctionFromCode(event.code, event.value);
|
|
||||||
emit(ACStatusLoaded(status: deviceStatus));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final success = await controlDeviceService.controlDevice(
|
_updateDeviceFunctionFromCode(event.code, event.value);
|
||||||
|
emit(ACStatusLoaded(status: deviceStatus));
|
||||||
|
await controlDeviceService.controlDevice(
|
||||||
deviceUuid: event.deviceId,
|
deviceUuid: event.deviceId,
|
||||||
status: Status(code: event.code, value: event.value),
|
status: Status(code: event.code, value: event.value),
|
||||||
);
|
);
|
||||||
|
} catch (e) {}
|
||||||
if (!success) {
|
|
||||||
emit(const AcsFailedState(error: 'Failed to control device'));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(AcsFailedState(error: e.toString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onFetchAcBatchStatus(
|
FutureOr<void> _onFetchAcBatchStatus(
|
||||||
@ -141,23 +134,16 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
AcBatchControlEvent event,
|
AcBatchControlEvent event,
|
||||||
Emitter<AcsState> emit,
|
Emitter<AcsState> emit,
|
||||||
) async {
|
) async {
|
||||||
emit(AcsLoadingState());
|
|
||||||
_updateDeviceFunctionFromCode(event.code, event.value);
|
_updateDeviceFunctionFromCode(event.code, event.value);
|
||||||
emit(ACStatusLoaded(status: deviceStatus));
|
emit(ACStatusLoaded(status: deviceStatus));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final success = await batchControlDevicesService.batchControlDevices(
|
await batchControlDevicesService.batchControlDevices(
|
||||||
uuids: event.devicesIds,
|
uuids: event.devicesIds,
|
||||||
code: event.code,
|
code: event.code,
|
||||||
value: event.value,
|
value: event.value,
|
||||||
);
|
);
|
||||||
|
} catch (e) {}
|
||||||
if (!success) {
|
|
||||||
emit(const AcsFailedState(error: 'Failed to control devices'));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(AcsFailedState(error: e.toString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFactoryReset(
|
Future<void> _onFactoryReset(
|
||||||
@ -190,8 +176,8 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
void _handleIncreaseTime(IncreaseTimeEvent event, Emitter<AcsState> emit) {
|
void _handleIncreaseTime(IncreaseTimeEvent event, Emitter<AcsState> emit) {
|
||||||
if (state is! ACStatusLoaded) return;
|
if (state is! ACStatusLoaded) return;
|
||||||
final currentState = state as ACStatusLoaded;
|
final currentState = state as ACStatusLoaded;
|
||||||
int newHours = scheduledHours;
|
var newHours = scheduledHours;
|
||||||
int newMinutes = scheduledMinutes + 30;
|
var newMinutes = scheduledMinutes + 30;
|
||||||
newHours += newMinutes ~/ 60;
|
newHours += newMinutes ~/ 60;
|
||||||
newMinutes = newMinutes % 60;
|
newMinutes = newMinutes % 60;
|
||||||
if (newHours > 23) {
|
if (newHours > 23) {
|
||||||
@ -213,7 +199,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
) {
|
) {
|
||||||
if (state is! ACStatusLoaded) return;
|
if (state is! ACStatusLoaded) return;
|
||||||
final currentState = state as ACStatusLoaded;
|
final currentState = state as ACStatusLoaded;
|
||||||
int totalMinutes = (scheduledHours * 60) + scheduledMinutes;
|
var totalMinutes = (scheduledHours * 60) + scheduledMinutes;
|
||||||
totalMinutes = (totalMinutes - 30).clamp(0, 1440);
|
totalMinutes = (totalMinutes - 30).clamp(0, 1440);
|
||||||
scheduledHours = totalMinutes ~/ 60;
|
scheduledHours = totalMinutes ~/ 60;
|
||||||
scheduledMinutes = totalMinutes % 60;
|
scheduledMinutes = totalMinutes % 60;
|
||||||
@ -286,20 +272,24 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
|
|
||||||
void _startCountdownTimer(Emitter<AcsState> emit) {
|
void _startCountdownTimer(Emitter<AcsState> emit) {
|
||||||
_countdownTimer?.cancel();
|
_countdownTimer?.cancel();
|
||||||
int totalSeconds = (scheduledHours * 3600) + (scheduledMinutes * 60);
|
var totalSeconds = (scheduledHours * 3600) + (scheduledMinutes * 60);
|
||||||
|
|
||||||
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
if (totalSeconds > 0) {
|
if (totalSeconds > 0) {
|
||||||
totalSeconds--;
|
totalSeconds--;
|
||||||
scheduledHours = totalSeconds ~/ 3600;
|
scheduledHours = totalSeconds ~/ 3600;
|
||||||
scheduledMinutes = (totalSeconds % 3600) ~/ 60;
|
scheduledMinutes = (totalSeconds % 3600) ~/ 60;
|
||||||
add(UpdateTimerEvent());
|
if (!isClosed) {
|
||||||
|
add(UpdateTimerEvent());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_countdownTimer?.cancel();
|
_countdownTimer?.cancel();
|
||||||
timerActive = false;
|
timerActive = false;
|
||||||
scheduledHours = 0;
|
scheduledHours = 0;
|
||||||
scheduledMinutes = 0;
|
scheduledMinutes = 0;
|
||||||
add(TimerCompletedEvent());
|
if (!isClosed) {
|
||||||
|
add(TimerCompletedEvent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -326,7 +316,9 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
_startCountdownTimer(
|
_startCountdownTimer(
|
||||||
emit,
|
emit,
|
||||||
);
|
);
|
||||||
add(UpdateTimerEvent());
|
if (!isClosed) {
|
||||||
|
add(UpdateTimerEvent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,6 +362,8 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
|||||||
@override
|
@override
|
||||||
Future<void> close() {
|
Future<void> close() {
|
||||||
add(OnClose());
|
add(OnClose());
|
||||||
|
_countdownTimer?.cancel();
|
||||||
|
_deviceStatusSubscription?.cancel();
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
final buttonLabel =
|
final buttonLabel =
|
||||||
(selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
(selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
||||||
|
final isAnyDeviceOffline =
|
||||||
|
selectedDevices.any((element) => !(element.online ?? false));
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: SpaceTreeView(
|
Expanded(child: SpaceTreeView(
|
||||||
@ -103,8 +104,26 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
|
backgroundColor: isAnyDeviceOffline
|
||||||
|
? ColorsManager.primaryColor
|
||||||
|
.withValues(alpha: 0.1)
|
||||||
|
: null,
|
||||||
onPressed: isControlButtonEnabled
|
onPressed: isControlButtonEnabled
|
||||||
? () {
|
? () {
|
||||||
|
if (isAnyDeviceOffline) {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'This Device is Offline',
|
||||||
|
),
|
||||||
|
duration:
|
||||||
|
Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedDevices.length == 1) {
|
if (selectedDevices.length == 1) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -12,7 +12,8 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
|||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
//Smart Power Clamp
|
//Smart Power Clamp
|
||||||
class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
class SmartPowerDeviceControl extends StatelessWidget
|
||||||
|
with HelperResponsiveLayout {
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
|
|
||||||
const SmartPowerDeviceControl({super.key, required this.deviceId});
|
const SmartPowerDeviceControl({super.key, required this.deviceId});
|
||||||
@ -145,13 +146,16 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_left),
|
icon: const Icon(Icons.arrow_left),
|
||||||
onPressed: () {
|
onPressed: blocProvider.currentPage <= 0
|
||||||
blocProvider.add(SmartPowerArrowPressedEvent(-1));
|
? null
|
||||||
pageController.previousPage(
|
: () {
|
||||||
duration: const Duration(milliseconds: 300),
|
blocProvider
|
||||||
curve: Curves.easeInOut,
|
.add(SmartPowerArrowPressedEvent(-1));
|
||||||
);
|
pageController.previousPage(
|
||||||
},
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
currentPage == 0
|
currentPage == 0
|
||||||
@ -165,13 +169,16 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.arrow_right),
|
icon: const Icon(Icons.arrow_right),
|
||||||
onPressed: () {
|
onPressed: blocProvider.currentPage >= 3
|
||||||
blocProvider.add(SmartPowerArrowPressedEvent(1));
|
? null
|
||||||
pageController.nextPage(
|
: () {
|
||||||
duration: const Duration(milliseconds: 300),
|
blocProvider
|
||||||
curve: Curves.easeInOut,
|
.add(SmartPowerArrowPressedEvent(1));
|
||||||
);
|
pageController.nextPage(
|
||||||
},
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -195,8 +202,8 @@ class SmartPowerDeviceControl extends StatelessWidget with HelperResponsiveLayou
|
|||||||
blocProvider.add(SelectDateEvent(context: context));
|
blocProvider.add(SelectDateEvent(context: context));
|
||||||
blocProvider.add(FilterRecordsByDateEvent(
|
blocProvider.add(FilterRecordsByDateEvent(
|
||||||
selectedDate: blocProvider.dateTime!,
|
selectedDate: blocProvider.dateTime!,
|
||||||
viewType:
|
viewType: blocProvider
|
||||||
blocProvider.views[blocProvider.currentIndex]));
|
.views[blocProvider.currentIndex]));
|
||||||
},
|
},
|
||||||
widget: blocProvider.dateSwitcher(),
|
widget: blocProvider.dateSwitcher(),
|
||||||
chartData: blocProvider.energyDataList.isNotEmpty
|
chartData: blocProvider.energyDataList.isNotEmpty
|
||||||
|
@ -79,6 +79,7 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDeviceInfoSection() {
|
Widget _buildDeviceInfoSection() {
|
||||||
|
final isOnlineDevice = device.online != null && device.online!;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 50),
|
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 50),
|
||||||
child: Table(
|
child: Table(
|
||||||
@ -107,7 +108,7 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|||||||
'Installation Date and Time:',
|
'Installation Date and Time:',
|
||||||
formatDateTime(
|
formatDateTime(
|
||||||
DateTime.fromMillisecondsSinceEpoch(
|
DateTime.fromMillisecondsSinceEpoch(
|
||||||
((device.createTime ?? 0) * 1000),
|
(device.createTime ?? 0) * 1000,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -126,12 +127,16 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|||||||
),
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
children: [
|
children: [
|
||||||
_buildInfoRow('Status:', 'Online', statusColor: Colors.green),
|
_buildInfoRow(
|
||||||
|
'Status:',
|
||||||
|
isOnlineDevice ? 'Online' : 'offline',
|
||||||
|
statusColor: isOnlineDevice ? Colors.green : Colors.red,
|
||||||
|
),
|
||||||
_buildInfoRow(
|
_buildInfoRow(
|
||||||
'Last Offline Date and Time:',
|
'Last Offline Date and Time:',
|
||||||
formatDateTime(
|
formatDateTime(
|
||||||
DateTime.fromMillisecondsSinceEpoch(
|
DateTime.fromMillisecondsSinceEpoch(
|
||||||
((device.updateTime ?? 0) * 1000),
|
(device.updateTime ?? 0) * 1000,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
||||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||||
|
import 'package:syncrow_web/pages/roles_and_permission/model/roles_user_model.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_event.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_event.dart';
|
||||||
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart';
|
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/bloc/users_status.dart';
|
||||||
@ -12,8 +14,11 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class EditUserDialog extends StatefulWidget {
|
class EditUserDialog extends StatefulWidget {
|
||||||
final String? userId;
|
final RolesUserModel? user;
|
||||||
const EditUserDialog({super.key, this.userId});
|
const EditUserDialog({
|
||||||
|
super.key,
|
||||||
|
this.user,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_EditUserDialogState createState() => _EditUserDialogState();
|
_EditUserDialogState createState() => _EditUserDialogState();
|
||||||
@ -28,10 +33,11 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
create: (BuildContext context) => UsersBloc()
|
create: (BuildContext context) => UsersBloc()
|
||||||
// ..add(const LoadCommunityAndSpacesEvent())
|
// ..add(const LoadCommunityAndSpacesEvent())
|
||||||
..add(const RoleEvent())
|
..add(const RoleEvent())
|
||||||
..add(GetUserByIdEvent(uuid: widget.userId)),
|
..add(GetUserByIdEvent(uuid: widget.user!.uuid)),
|
||||||
child: BlocConsumer<UsersBloc, UsersState>(listener: (context, state) {
|
child: BlocConsumer<UsersBloc, UsersState>(listener: (context, state) {
|
||||||
if (state is SpacesLoadedState) {
|
if (state is SpacesLoadedState) {
|
||||||
BlocProvider.of<UsersBloc>(context).add(GetUserByIdEvent(uuid: widget.userId));
|
BlocProvider.of<UsersBloc>(context)
|
||||||
|
.add(GetUserByIdEvent(uuid: widget.user!.uuid));
|
||||||
}
|
}
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
final _blocRole = BlocProvider.of<UsersBloc>(context);
|
final _blocRole = BlocProvider.of<UsersBloc>(context);
|
||||||
@ -39,7 +45,8 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
return Dialog(
|
return Dialog(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(20))),
|
||||||
width: 900,
|
width: 900,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -68,7 +75,8 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
children: [
|
children: [
|
||||||
_buildStep1Indicator(1, "Basics", _blocRole),
|
_buildStep1Indicator(1, "Basics", _blocRole),
|
||||||
_buildStep2Indicator(2, "Spaces", _blocRole),
|
_buildStep2Indicator(2, "Spaces", _blocRole),
|
||||||
_buildStep3Indicator(3, "Role & Permissions", _blocRole),
|
_buildStep3Indicator(
|
||||||
|
3, "Role & Permissions", _blocRole),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -86,7 +94,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _getFormContent(widget.userId),
|
child: _getFormContent(widget.user!),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
@ -116,13 +124,14 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
if (currentStep < 3) {
|
if (currentStep < 3) {
|
||||||
currentStep++;
|
currentStep++;
|
||||||
if (currentStep == 2) {
|
if (currentStep == 2) {
|
||||||
_blocRole.add(CheckStepStatus(isEditUser: true));
|
_blocRole
|
||||||
|
.add(CheckStepStatus(isEditUser: true));
|
||||||
} else if (currentStep == 3) {
|
} else if (currentStep == 3) {
|
||||||
_blocRole.add(const CheckSpacesStepStatus());
|
_blocRole.add(const CheckSpacesStepStatus());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_blocRole
|
_blocRole.add(EditInviteUsers(
|
||||||
.add(EditInviteUsers(context: context, userId: widget.userId!));
|
context: context, userId: widget.user!.uuid));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -131,7 +140,8 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: (_blocRole.isCompleteSpaces == false ||
|
color: (_blocRole.isCompleteSpaces == false ||
|
||||||
_blocRole.isCompleteBasics == false ||
|
_blocRole.isCompleteBasics == false ||
|
||||||
_blocRole.isCompleteRolePermissions == false) &&
|
_blocRole.isCompleteRolePermissions ==
|
||||||
|
false) &&
|
||||||
currentStep == 3
|
currentStep == 3
|
||||||
? ColorsManager.grayColor
|
? ColorsManager.grayColor
|
||||||
: ColorsManager.secondaryColor),
|
: ColorsManager.secondaryColor),
|
||||||
@ -146,15 +156,15 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _getFormContent(userid) {
|
Widget _getFormContent(RolesUserModel user) {
|
||||||
switch (currentStep) {
|
switch (currentStep) {
|
||||||
case 1:
|
case 1:
|
||||||
return BasicsView(
|
return BasicsView(
|
||||||
userId: userid,
|
userId: user.uuid,
|
||||||
);
|
);
|
||||||
case 2:
|
case 2:
|
||||||
return SpacesAccessView(
|
return SpacesAccessView(
|
||||||
userId: userid,
|
userId: user.uuid,
|
||||||
);
|
);
|
||||||
case 3:
|
case 3:
|
||||||
return const RolesAndPermission();
|
return const RolesAndPermission();
|
||||||
@ -166,6 +176,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
int step3 = 0;
|
int step3 = 0;
|
||||||
|
|
||||||
Widget _buildStep1Indicator(int step, String label, UsersBloc bloc) {
|
Widget _buildStep1Indicator(int step, String label, UsersBloc bloc) {
|
||||||
|
final isCurrentStep = currentStep == step;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -189,7 +200,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
currentStep == step
|
isCurrentStep
|
||||||
? Assets.currentProcessIcon
|
? Assets.currentProcessIcon
|
||||||
: bloc.isCompleteBasics == false
|
: bloc.isCompleteBasics == false
|
||||||
? Assets.wrongProcessIcon
|
? Assets.wrongProcessIcon
|
||||||
@ -204,8 +215,11 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
label,
|
label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
|
color: isCurrentStep
|
||||||
fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
|
? ColorsManager.blackColor
|
||||||
|
: ColorsManager.greyColor,
|
||||||
|
fontWeight:
|
||||||
|
isCurrentStep ? FontWeight.bold : FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -229,6 +243,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStep2Indicator(int step, String label, UsersBloc bloc) {
|
Widget _buildStep2Indicator(int step, String label, UsersBloc bloc) {
|
||||||
|
final isCurrentStep = currentStep == step;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -248,7 +263,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
currentStep == step
|
isCurrentStep
|
||||||
? Assets.currentProcessIcon
|
? Assets.currentProcessIcon
|
||||||
: bloc.isCompleteSpaces == false
|
: bloc.isCompleteSpaces == false
|
||||||
? Assets.wrongProcessIcon
|
? Assets.wrongProcessIcon
|
||||||
@ -263,8 +278,11 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
label,
|
label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
|
color: isCurrentStep
|
||||||
fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
|
? ColorsManager.blackColor
|
||||||
|
: ColorsManager.greyColor,
|
||||||
|
fontWeight:
|
||||||
|
isCurrentStep ? FontWeight.bold : FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -288,6 +306,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStep3Indicator(int step, String label, UsersBloc bloc) {
|
Widget _buildStep3Indicator(int step, String label, UsersBloc bloc) {
|
||||||
|
final isCurrentStep = currentStep == step;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -306,7 +325,7 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
currentStep == step
|
isCurrentStep
|
||||||
? Assets.currentProcessIcon
|
? Assets.currentProcessIcon
|
||||||
: bloc.isCompleteRolePermissions == false
|
: bloc.isCompleteRolePermissions == false
|
||||||
? Assets.wrongProcessIcon
|
? Assets.wrongProcessIcon
|
||||||
@ -321,8 +340,11 @@ class _EditUserDialogState extends State<EditUserDialog> {
|
|||||||
label,
|
label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
|
color: isCurrentStep
|
||||||
fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
|
? ColorsManager.blackColor
|
||||||
|
: ColorsManager.greyColor,
|
||||||
|
fontWeight:
|
||||||
|
isCurrentStep ? FontWeight.bold : FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -19,6 +19,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class UsersPage extends StatelessWidget {
|
class UsersPage extends StatelessWidget {
|
||||||
UsersPage({super.key});
|
UsersPage({super.key});
|
||||||
|
|
||||||
@ -451,33 +452,31 @@ class UsersPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
user.isEnabled != false
|
if (user.isEnabled != false)
|
||||||
? actionButton(
|
actionButton(
|
||||||
isActive: true,
|
isActive: true,
|
||||||
title: "Edit",
|
title: "Edit",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context
|
context
|
||||||
.read<SpaceTreeBloc>()
|
.read<SpaceTreeBloc>()
|
||||||
.add(ClearCachedData());
|
.add(ClearCachedData());
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return EditUserDialog(
|
return EditUserDialog(user: user);
|
||||||
userId: user.uuid);
|
|
||||||
},
|
|
||||||
).then((v) {
|
|
||||||
if (v != null) {
|
|
||||||
if (v != null) {
|
|
||||||
_blocRole.add(const GetUsers());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
)
|
).then((v) {
|
||||||
: actionButton(
|
if (v != null) {
|
||||||
title: "Edit",
|
_blocRole.add(const GetUsers());
|
||||||
),
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
actionButton(
|
||||||
|
title: "Edit",
|
||||||
|
),
|
||||||
actionButton(
|
actionButton(
|
||||||
title: "Delete",
|
title: "Delete",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -289,7 +289,6 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
|||||||
selectedSpaces: updatedSelectedSpaces,
|
selectedSpaces: updatedSelectedSpaces,
|
||||||
soldCheck: updatedSoldChecks,
|
soldCheck: updatedSoldChecks,
|
||||||
selectedCommunityAndSpaces: communityAndSpaces));
|
selectedCommunityAndSpaces: communityAndSpaces));
|
||||||
emit(state.copyWith(selectedSpaces: updatedSelectedSpaces));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
emit(const SpaceTreeErrorState('Something went wrong'));
|
||||||
}
|
}
|
||||||
@ -445,10 +444,12 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
|||||||
|
|
||||||
List<String> _getThePathToChild(String communityId, String selectedSpaceId) {
|
List<String> _getThePathToChild(String communityId, String selectedSpaceId) {
|
||||||
List<String> ids = [];
|
List<String> ids = [];
|
||||||
for (var community in state.communityList) {
|
final communityDataSource =
|
||||||
|
state.searchQuery.isNotEmpty ? state.filteredCommunity : state.communityList;
|
||||||
|
for (final community in communityDataSource) {
|
||||||
if (community.uuid == communityId) {
|
if (community.uuid == communityId) {
|
||||||
for (var space in community.spaces) {
|
for (final space in community.spaces) {
|
||||||
List<String> list = [];
|
final list = <String>[];
|
||||||
list.add(space.uuid!);
|
list.add(space.uuid!);
|
||||||
ids = _getAllParentsIds(space, selectedSpaceId, List.from(list));
|
ids = _getAllParentsIds(space, selectedSpaceId, List.from(list));
|
||||||
if (ids.isNotEmpty) {
|
if (ids.isNotEmpty) {
|
||||||
|
@ -68,7 +68,7 @@ class VisitorPasswordBloc
|
|||||||
DateTime? startTime = DateTime.now();
|
DateTime? startTime = DateTime.now();
|
||||||
DateTime? endTime;
|
DateTime? endTime;
|
||||||
|
|
||||||
String startTimeAccess = 'Start Time';
|
String startTimeAccess = DateTime.now().toString().split('.').first;
|
||||||
String endTimeAccess = 'End Time';
|
String endTimeAccess = 'End Time';
|
||||||
PasswordStatus? passwordStatus;
|
PasswordStatus? passwordStatus;
|
||||||
selectAccessType(
|
selectAccessType(
|
||||||
@ -136,6 +136,27 @@ class VisitorPasswordBloc
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(selectedTimestamp < DateTime.now().millisecondsSinceEpoch ~/ 1000) {
|
||||||
|
if(selectedTimestamp < DateTime.now().millisecondsSinceEpoch ~/ 1000) {
|
||||||
|
await showDialog<void>(
|
||||||
|
context: event.context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Effective Time cannot be earlier than current time.'),
|
||||||
|
actionsAlignment: MainAxisAlignment.center,
|
||||||
|
content:
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(event.context).pop();
|
||||||
|
add(SelectTimeVisitorPassword(context: event.context, isStart: true, isRepeat: false));
|
||||||
|
},
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
effectiveTimeTimeStamp = selectedTimestamp;
|
effectiveTimeTimeStamp = selectedTimestamp;
|
||||||
startTimeAccess = selectedDateTime.toString().split('.').first;
|
startTimeAccess = selectedDateTime.toString().split('.').first;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,11 +2,13 @@ class FailedOperation {
|
|||||||
final bool success;
|
final bool success;
|
||||||
final dynamic deviceUuid;
|
final dynamic deviceUuid;
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
|
final String deviceName;
|
||||||
|
|
||||||
FailedOperation({
|
FailedOperation({
|
||||||
required this.success,
|
required this.success,
|
||||||
required this.deviceUuid,
|
required this.deviceUuid,
|
||||||
required this.error,
|
required this.error,
|
||||||
|
required this.deviceName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory FailedOperation.fromJson(Map<String, dynamic> json) {
|
factory FailedOperation.fromJson(Map<String, dynamic> json) {
|
||||||
@ -14,6 +16,7 @@ class FailedOperation {
|
|||||||
success: json['success'],
|
success: json['success'],
|
||||||
deviceUuid: json['deviceUuid'],
|
deviceUuid: json['deviceUuid'],
|
||||||
error: json['error'],
|
error: json['error'],
|
||||||
|
deviceName: json['deviceName'] as String? ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,21 +25,22 @@ class FailedOperation {
|
|||||||
'success': success,
|
'success': success,
|
||||||
'deviceUuid': deviceUuid,
|
'deviceUuid': deviceUuid,
|
||||||
'error': error,
|
'error': error,
|
||||||
|
'deviceName': deviceName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SuccessOperation {
|
class SuccessOperation {
|
||||||
final bool success;
|
final bool success;
|
||||||
// final Result result;
|
// final Result result;
|
||||||
final String deviceUuid;
|
final String deviceUuid;
|
||||||
|
final String deviceName;
|
||||||
|
|
||||||
SuccessOperation({
|
SuccessOperation({
|
||||||
required this.success,
|
required this.success,
|
||||||
// required this.result,
|
// required this.result,
|
||||||
required this.deviceUuid,
|
required this.deviceUuid,
|
||||||
|
required this.deviceName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory SuccessOperation.fromJson(Map<String, dynamic> json) {
|
factory SuccessOperation.fromJson(Map<String, dynamic> json) {
|
||||||
@ -44,6 +48,7 @@ class SuccessOperation {
|
|||||||
success: json['success'],
|
success: json['success'],
|
||||||
// result: Result.fromJson(json['result']),
|
// result: Result.fromJson(json['result']),
|
||||||
deviceUuid: json['deviceUuid'],
|
deviceUuid: json['deviceUuid'],
|
||||||
|
deviceName: json['deviceName'] as String? ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +57,7 @@ class SuccessOperation {
|
|||||||
'success': success,
|
'success': success,
|
||||||
// 'result': result.toJson(),
|
// 'result': result.toJson(),
|
||||||
'deviceUuid': deviceUuid,
|
'deviceUuid': deviceUuid,
|
||||||
|
'deviceName': deviceName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +98,6 @@ class SuccessOperation {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PasswordStatus {
|
class PasswordStatus {
|
||||||
final List<SuccessOperation> successOperations;
|
final List<SuccessOperation> successOperations;
|
||||||
final List<FailedOperation> failedOperations;
|
final List<FailedOperation> failedOperations;
|
||||||
@ -121,4 +125,3 @@ class PasswordStatus {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: Text(visitorBloc
|
child: Text(visitorBloc
|
||||||
.passwordStatus!
|
.passwordStatus!
|
||||||
.failedOperations[index]
|
.failedOperations[index]
|
||||||
.deviceUuid)),
|
.deviceName)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -92,7 +92,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: Text(visitorBloc
|
child: Text(visitorBloc
|
||||||
.passwordStatus!
|
.passwordStatus!
|
||||||
.successOperations[index]
|
.successOperations[index]
|
||||||
.deviceUuid)),
|
.deviceName)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user