Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,24 +500,25 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
.map((i) => i.userUuid.toString())
.toList();
await processDashboardConfig(
dashboardConfig.first.dashboardConfigs
dashboardConfig: dashboardConfig.first.dashboardConfigs
?.where((config) =>
config.projectTypeId == event.model.projectTypeId ||
config.projectTypeCode == event.model.projectType)
.first
.charts ??
[],
startDate,
endDate,
isar,
DateTime.now(),
dashboardRemoteRepository,
dashboardActionPath.trim().isNotEmpty
startDate: startDate,
endDate: endDate,
isar: isar,
lastSelectedDate: DateTime.now(),
dashboardRemoteRepo: dashboardRemoteRepository,
actionPath: dashboardActionPath.trim().isNotEmpty
? dashboardActionPath
: Constants.dashboardAnalyticsPath,
envConfig.variables.tenantId,
event.model.id,
userUUIDList,
tenantId: envConfig.variables.tenantId,
projectId: event.model.id,
projectTypeId: event.model.projectTypeId,
userList: userUUIDList,
);
}
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion apps/health_campaign_field_worker_app/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class _HomePageState extends LocalizedState<HomePage> {

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final state = context.read<AuthBloc>().state;
final localSecureStore = LocalSecureStore.instance;
if (state is! AuthAuthenticatedState) {
Expand Down Expand Up @@ -865,6 +864,7 @@ void setPackagesSingleton(BuildContext context) {
);
DashboardSingleton().setInitialData(
projectId: context.projectId,
projectTypeId: context.selectedProject.projectTypeId ?? '',
tenantId: envConfig.variables.tenantId,
dashboardConfig: filteredDashboardConfig.firstOrNull,
appVersion: Constants().version,
Expand Down
23 changes: 12 additions & 11 deletions packages/digit_dss/lib/blocs/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,22 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
.map((i) => i.userUuid.toString())
.toList();
await processDashboardConfig(
dashboardConfig
dashboardConfig: dashboardConfig
?.where((chart) =>
(chart.name ?? '').isNotEmpty &&
(chart.chartType ?? '').isNotEmpty)
.toList() ??
[],
startDate,
endDate,
isar,
event.selectedDate,
dashboardRemoteRepo,
DashboardSingleton().actionPath,
DashboardSingleton().tenantId,
DashboardSingleton().projectId,
userUUIDList,
startDate: startDate,
endDate: endDate,
isar: isar,
lastSelectedDate: event.selectedDate,
dashboardRemoteRepo: dashboardRemoteRepo,
actionPath: DashboardSingleton().actionPath,
tenantId: DashboardSingleton().tenantId,
projectId: DashboardSingleton().projectId,
projectTypeId: DashboardSingleton().projectTypeId,
userList: userUUIDList,
); // Process dashboard configuration

add(DashboardEvent.handleSearch(
Expand Down Expand Up @@ -208,7 +209,7 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
double.parse(plot.value.toString())
.toInt()
.toString()))
: ''
: '-'
: double.parse(plot.value.toString()) ==
double.parse(plot.value.toString()).toInt()
? double.parse(plot.value.toString())
Expand Down
2 changes: 2 additions & 0 deletions packages/digit_dss/lib/models/entities/dss_enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ enum DSSEnums {
uuid,
@MappableValue("projectId")
projectId,
@MappableValue("projectTypeId")
projectTypeId,
@MappableValue("Last synced time")
lastSyncedTime,
@MappableValue("amount")
Expand Down
4 changes: 4 additions & 0 deletions packages/digit_dss/lib/models/entities/dss_enums.mapper.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions packages/digit_dss/lib/pages/dashboard/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:digit_ui_components/theme/spacers.dart';
import 'package:digit_ui_components/widgets/atoms/digit_info_card.dart';
import 'package:digit_ui_components/widgets/atoms/digit_loader.dart';
import 'package:digit_ui_components/widgets/atoms/digit_toast.dart';
import 'package:digit_ui_components/widgets/atoms/table_cell.dart';
import 'package:digit_ui_components/widgets/molecules/digit_table.dart';
import 'package:digit_ui_components/widgets/powered_by_digit.dart';
import 'package:digit_ui_components/widgets/scrollable_content.dart';
Expand Down Expand Up @@ -138,7 +139,10 @@ class UserDashboardPageState extends LocalizedState<UserDashboardPage> {
? const ClampingScrollPhysics()
: const NeverScrollableScrollPhysics(),
rows: table.tableData,
columns: table.headerList,
columns: table.headerList.map((h) => DigitTableColumn(
header: localizations.translate(h.header),
cellValue: h.cellValue,
)).toList() ,
tableHeight:
MediaQuery.of(context).size.height * .3,
showSelectedState: false,
Expand All @@ -151,9 +155,9 @@ class UserDashboardPageState extends LocalizedState<UserDashboardPage> {
alignment: Alignment.center,
child: InfoCard(
title: localizations
.translate(i18.dashboard.noteHeader),
.translate('${i18.dashboard.noteHeader}_${DashboardSingleton().selectedProject?.projectType ?? ''}'),
description: localizations
.translate(i18.dashboard.noteDescription),
.translate('${i18.dashboard.noteDescription}_${DashboardSingleton().selectedProject?.projectType ?? ''}'),
type: InfoType.info,
),
)
Expand Down
35 changes: 22 additions & 13 deletions packages/digit_dss/lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,19 @@ DashboardRequestModel getRequestModel({
}

Future<void> processDashboardConfig(
List<DashboardChartConfigSchema> dashboardConfig,
int startDate,
int endDate,
Isar isar,
DateTime lastSelectedDate,
DashboardRemoteRepository dashboardRemoteRepo,
String actionPath,
String tenantId,
String projectId,
List<String> userList,
) async {
{
required List<DashboardChartConfigSchema> dashboardConfig,
required int startDate,
required int endDate,
required Isar isar,
DateTime? lastSelectedDate,
required DashboardRemoteRepository dashboardRemoteRepo,
required String actionPath,
required String tenantId,
required String projectId,
String? projectTypeId,
List<String>? userList,
}) async {
if (dashboardConfig.isNotEmpty) {
for (var entry in dashboardConfig) {
String visualizationType = entry.chartType ?? '';
Expand All @@ -124,8 +126,11 @@ Future<void> processDashboardConfig(
visualizationType: visualizationType,
visualizationCode: visualizationCode,
filters: {
DSSEnums.uuid.toValue(): userList,
DSSEnums.projectId.toValue(): projectId
if((userList ?? []).isNotEmpty)
DSSEnums.uuid.toValue(): userList,
DSSEnums.projectId.toValue(): projectId,
if(projectTypeId != null)
DSSEnums.projectTypeId.toValue(): projectTypeId,
},
moduleLevel: "",
queryType: "",
Expand Down Expand Up @@ -163,20 +168,23 @@ class DashboardSingleton {

String? _tenantId;
String? _projectId;
String? _projectTypeId;
String? _actionPath;
String? _appVersion;
ProjectModel? _selectedProject;
DashboardConfigSchema? _dashboardConfig;

void setInitialData({
required String projectId,
required String projectTypeId,
required String tenantId,
required String actionPath,
required String appVersion,
required ProjectModel selectedProject,
DashboardConfigSchema? dashboardConfig,
}) {
_projectId = projectId;
_projectTypeId = projectTypeId;
_tenantId = tenantId;
_actionPath = actionPath.trim().isNotEmpty
? actionPath
Expand All @@ -189,6 +197,7 @@ class DashboardSingleton {
String get tenantId => _tenantId ?? '';

String get projectId => _projectId ?? '';
String get projectTypeId => _projectTypeId ?? '';

String get appVersion => _appVersion ?? '';

Expand Down
Loading