Skip to content

Commit

Permalink
Merge branch 'develop' into HCMPRE-1144-json_config
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashwat12-egov authored Nov 12, 2024
2 parents d251d2f + fafde86 commit ada1bf4
Show file tree
Hide file tree
Showing 342 changed files with 13,725 additions and 2,568 deletions.
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.16.5"
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ migrate_working_dir/
*.iws
.idea/


# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
Expand Down Expand Up @@ -57,3 +56,7 @@ pubspec_overrides.yaml
apps/health_campaign_field_worker_app/.env
apps/health_campaign_field_worker_app/libisar.dylib
*.properties

# FVM Version Cache
.fvm/
.fvmrc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ class _ChecklistDataShowcaseData {
import '../../../utils/i18_key_constants.dart' as i18;
import '../showcase_wrappers.dart';
part 'checklist_data.dart';
part 'survey_form_data.dart';
final checklistDataShowcaseData = _ChecklistDataShowcaseData();
```
Expand Down
4 changes: 4 additions & 0 deletions apps/health_campaign_field_worker_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# FVM Version Cache
.fvm/
.fvmrc
8 changes: 8 additions & 0 deletions apps/health_campaign_field_worker_app/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:attendance_management/attendance_management.dart';
import 'package:survey_form/survey_form.dart';
import 'package:closed_household/blocs/closed_household.dart';
import 'package:closed_household/closed_household.dart';
import 'package:digit_components/digit_components.dart';
Expand All @@ -25,6 +26,8 @@ import 'blocs/localization/localization.dart';
import 'blocs/project/project.dart';
import 'data/local_store/app_shared_preferences.dart';
import 'data/network_manager.dart';
import 'data/remote_client.dart';
import 'data/repositories/remote/bandwidth_check.dart';
import 'data/repositories/remote/localization.dart';
import 'data/repositories/remote/mdms.dart';
import 'router/app_navigator_observer.dart';
Expand Down Expand Up @@ -201,6 +204,11 @@ class MainApplicationState extends State<MainApplication>
),
BlocProvider(
create: (ctx) => ProjectBloc(
bandwidthCheckRepository: BandwidthCheckRepository(
DioClient().dio,
bandwidthPath:
envConfig.variables.checkBandwidthApiPath,
),
mdmsRepository: MdmsRepository(widget.client),
dashboardRemoteRepository:
DashboardRemoteRepository(widget.client),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class MdmsConfig {
final List<ServiceRegistry> serviceRegistryList;
final DashboardConfigSchema? dashboardConfigSchema;


const MdmsConfig(
{required this.appConfigs,
required this.serviceRegistryList,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:collection/collection.dart';
import 'package:digit_data_model/data/local_store/sql_store/sql_store.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
import '../../data/local_store/no_sql/schema/app_configuration.dart';
import 'app_localization.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'dart:core';

import 'package:attendance_management/attendance_management.dart';
import 'package:survey_form/survey_form.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:digit_components/digit_components.dart';
import 'package:digit_data_model/data_model.dart';
Expand All @@ -19,10 +20,12 @@ import '../../data/local_store/no_sql/schema/app_configuration.dart';
import '../../data/local_store/no_sql/schema/row_versions.dart';
import '../../data/local_store/no_sql/schema/service_registry.dart';
import '../../data/local_store/secure_store/secure_store.dart';
import '../../data/repositories/remote/bandwidth_check.dart';
import '../../data/repositories/remote/mdms.dart';
import '../../models/app_config/app_config_model.dart';
import '../../models/auth/auth_model.dart';
import '../../models/entities/roles_type.dart';
import '../../utils/background_service.dart';
import '../../utils/environment_config.dart';
import '../../utils/utils.dart';

Expand All @@ -35,6 +38,8 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
final Isar isar;
final MdmsRepository mdmsRepository;

final BandwidthCheckRepository bandwidthCheckRepository;

/// Project Staff Repositories
final RemoteRepository<ProjectStaffModel, ProjectStaffSearchModel>
projectStaffRemoteRepository;
Expand Down Expand Up @@ -76,6 +81,7 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
final RemoteRepository<StockModel, StockSearchModel> stockRemoteRepository;
final LocalRepository<StockModel, StockSearchModel> stockLocalRepository;

/// Service Definition Repositories
final RemoteRepository<ServiceDefinitionModel, ServiceDefinitionSearchModel>
serviceDefinitionRemoteRepository;
final LocalRepository<ServiceDefinitionModel, ServiceDefinitionSearchModel>
Expand Down Expand Up @@ -103,6 +109,7 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {

ProjectBloc({
LocalSecureStore? localSecureStore,
required this.bandwidthCheckRepository,
required this.projectStaffRemoteRepository,
required this.projectRemoteRepository,
required this.projectStaffLocalRepository,
Expand Down Expand Up @@ -169,6 +176,7 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
}

FutureOr<void> _loadOnline(ProjectEmitter emit) async {
final batchSize = await _getBatchSize();
final userObject = await localSecureStore.userRequestModel;
final uuid = userObject?.uuid;

Expand Down Expand Up @@ -288,8 +296,11 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
}

if (projects.isNotEmpty) {

// INFO : Need to add project load functions

try {
await _loadProjectFacilities(projects);
await _loadProjectFacilities(projects, batchSize);
} catch (_) {
emit(
state.copyWith(
Expand Down Expand Up @@ -360,7 +371,8 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
);
}

FutureOr<void> _loadProjectFacilities(List<ProjectModel> projects) async {
FutureOr<void> _loadProjectFacilities(
List<ProjectModel> projects, int batchSize) async {
final projectFacilities = await projectFacilityRemoteRepository.search(
ProjectFacilitySearchModel(
projectId: projects.map((e) => e.id).toList(),
Expand All @@ -371,6 +383,7 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {

final facilities = await facilityRemoteRepository.search(
FacilitySearchModel(tenantId: envConfig.variables.tenantId),
limit: batchSize,
);

await facilityLocalRepository.bulkCreate(facilities);
Expand Down Expand Up @@ -584,8 +597,6 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
loading: false,
syncError: ProjectSyncErrorType.boundary,
));

return;
}

emit(state.copyWith(
Expand All @@ -594,6 +605,25 @@ class ProjectBloc extends Bloc<ProjectEvent, ProjectState> {
syncError: null,
));
}

FutureOr<int> _getBatchSize() async {
try {
final configs = await isar.appConfigurations.where().findAll();

final double speed = await bandwidthCheckRepository.pingBandwidthCheck(
bandWidthCheckModel: null,
);

int configuredBatchSize = getBatchSizeToBandwidth(
speed,
configs,
isDownSync: true,
);
return configuredBatchSize;
} catch (e) {
rethrow;
}
}
}

@freezed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:complaints/complaints.dart';

import 'package:attendance_management/models/entities/attendance_log.dart';
import 'package:survey_form/survey_form.dart';
import 'package:digit_data_model/data/local_store/no_sql/schema/entity_mapper_listener.dart';
import 'package:digit_data_model/data_model.dart';
import 'package:digit_data_model/models/entities/user_action.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class NetworkManager {
return isSyncCompleted;
}

//

FutureOr<void> writeToEntityDB(
Map<String, dynamic> response,
List<LocalRepository> localRepositories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BandwidthCheckRepository {
final speed = (((800 / timeconsumed) / 1000));

return speed;
} on DioError catch (e) {
} on DioException catch (e) {
rethrow;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ class MdmsRepository {

final List<ChecklistTypes>? checklistTypes =
element?.checklistTypes.map((e) {
final checklist = ChecklistTypes()
final surveyForm = ChecklistTypes()
..name = e.name
..code = e.code;

return checklist;
return surveyForm;
}).toList();

final List<TransportTypes>? transportTypes =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:collection/collection.dart';
import 'package:digit_data_model/data_model.dart';


class RepositoryType {
static RemoteRepository getRemoteForType(
DataModelType type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class PerformSyncDown {
.whereNotNull()
.toList(),
),
limit: bandwidthModel.batchSize,
);

for (var element in operationGroupedEntity.value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:complaints/complaints.dart';

import 'dart:async';

import 'package:collection/collection.dart';
Expand Down Expand Up @@ -213,6 +215,7 @@ class PerformSyncUp {
final entities = getEntityModel(sublist, local);
if (operationGroupedEntity.key == DataOperation.create) {
switch (typeGroupedEntity.key) {

case DataModelType.complaints:
for (final entity in entities) {
if (remote is PgrServiceRemoteRepository &&
Expand Down Expand Up @@ -284,6 +287,7 @@ class PerformSyncUp {
}
}
break;

default:
await remote.bulkCreate(entities);
}
Expand Down
1 change: 0 additions & 1 deletion apps/health_campaign_field_worker_app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:collection/collection.dart';
import 'package:digit_components/digit_components.dart';
import 'package:digit_data_model/data/local_store/sql_store/sql_store.dart';
import 'package:dio/dio.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_portal/flutter_portal.dart';
import 'package:isar/isar.dart';
import 'package:location/location.dart';
import 'package:registration_delivery/registration_delivery.dart';
import 'package:survey_form/survey_form.dart';

import '../blocs/localization/app_localization.dart';
import '../blocs/projects_beneficiary_downsync/project_beneficiaries_downsync.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,14 @@ class _BoundarySelectionPageState
children: [
Expanded(
child: ListView.builder(
itemCount: labelList.length,
itemCount: labelList.length+1,
itemBuilder: (context, labelIndex) {

if (labelIndex == labelList.length) {
// Return a SizedBox for whitespace after the last item
return const SizedBox(height: kPadding*3); // Adjust height as needed
}

final label = labelList.elementAt(labelIndex);

final filteredItems =
Expand Down
Loading

0 comments on commit ada1bf4

Please sign in to comment.