Skip to content

Commit

Permalink
Merge pull request #38 from Hari-egov/ISNE-262
Browse files Browse the repository at this point in the history
INSE-262
  • Loading branch information
pradeepkumarcm-egov authored Nov 11, 2024
2 parents e75fe44 + ab75c02 commit 73629fc
Show file tree
Hide file tree
Showing 19 changed files with 363 additions and 133 deletions.
34 changes: 24 additions & 10 deletions frontend/mgramseva/assets/icons/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,45 @@
]
},
{
"uid": "33ecd3048ff383febdfc4a2dd7ea6ba1",
"css": "updateexpenses",
"code": 59400,
"uid": "7575e60d98fe96288614b8e6bbb34c8e",
"css": "gpwscdetails",
"code": 59412,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M616.2 679.7H195.2V197.4H440.8V118.4H195.2C156.6 118.4 125 153.9 125 197.4V671.1C125 714.5 156.6 750 195.2 750H616.2C654.8 750 686.4 714.5 686.4 671.1V394.7H616.2V679.7ZM686.4 118.4L616.2 118.4 511 118.4C511.3 118.8 511 197.4 511 197.4H616.2V315.4C616.6 315.8 686.4 315.4 686.4 315.4V197.4 118.4ZM546.1 276.3H265.4V355.3H546.1V276.3ZM265.4 394.7V473.7H546.1V394.7H440.8 265.4ZM546.1 513.2H265.4V592.1H546.1V513.2ZM969.7 536.1L936.1 502.5C914.4 480.8 879.2 480.8 857.5 502.5L783.1 576.9 541.7 818.3V930.6H653.9L896.7 687.8 969.7 614.7C991.7 593.1 991.7 557.8 969.7 536.1ZM630.8 875H597.2V841.4L837.8 600.8 871.4 634.4 630.8 875ZM763.9 930.6L875 819.4H1041.7V930.6H763.9Z",
"path": "M888.9 0H111.1C50 0 0 50 0 111.1V888.9C0 950 50 1000 111.1 1000H888.9C950 1000 1000 950 1000 888.9V111.1C1000 50 950 0 888.9 0ZM611.1 777.8H222.2V666.7H611.1V777.8ZM777.8 555.6H222.2V444.4H777.8V555.6ZM777.8 333.3H222.2V222.2H777.8V333.3Z",
"width": 1000
},
"search": [
"updateexpenses"
"gpwscdetails"
]
},
{
"uid": "7575e60d98fe96288614b8e6bbb34c8e",
"css": "gpwscdetails",
"code": 59412,
"uid": "333a57be9d13d97e6f8f5c9b2b7b1cb5",
"css": "anurakshak",
"code": 59405,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M888.9 0H111.1C50 0 0 50 0 111.1V888.9C0 950 50 1000 111.1 1000H888.9C950 1000 1000 950 1000 888.9V111.1C1000 50 950 0 888.9 0ZM611.1 777.8H222.2V666.7H611.1V777.8ZM777.8 555.6H222.2V444.4H777.8V555.6ZM777.8 333.3H222.2V222.2H777.8V333.3Z",
"path": "M837.3 889.2C820.5 906 798.4 914.4 776.3 914.4 754.2 914.4 732.1 906 715.2 889.2 681.5 855.4 681.5 800.8 715.2 767L776.3 707.3 837.3 767C871.1 800.7 871.1 855.4 837.3 889.2ZM465.4 154.5L638.1 154.5 638.1 85.4 223.6 85.4 223.6 154.5 396.3 154.5 396.3 258.1 85.4 258.1 85.4 534.5 465.4 534.5 465.4 154.5ZM603.6 258.1L534.5 258.1 534.5 534.5 603.6 534.5C622.6 534.5 638.1 549.9 638.1 569L638.1 638.1 914.4 638.1 914.4 569C914.4 397.6 775 258.1 603.6 258.1Z",
"width": 1000
},
"search": [
"gpwscdetails"
"untitled-(1)"
]
},
{
"uid": "33ecd3048ff383febdfc4a2dd7ea6ba1",
"css": "updateexpenses",
"code": 59400,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M616.2 679.7H195.2V197.4H440.8V118.4H195.2C156.6 118.4 125 153.9 125 197.4V671.1C125 714.5 156.6 750 195.2 750H616.2C654.8 750 686.4 714.5 686.4 671.1V394.7H616.2V679.7ZM686.4 118.4L616.2 118.4 511 118.4C511.3 118.8 511 197.4 511 197.4H616.2V315.4C616.6 315.8 686.4 315.4 686.4 315.4V197.4 118.4ZM546.1 276.3H265.4V355.3H546.1V276.3ZM265.4 394.7V473.7H546.1V394.7H440.8 265.4ZM546.1 513.2H265.4V592.1H546.1V513.2ZM969.7 536.1L936.1 502.5C914.4 480.8 879.2 480.8 857.5 502.5L783.1 576.9 541.7 818.3V930.6H653.9L896.7 687.8 969.7 614.7C991.7 593.1 991.7 557.8 969.7 536.1ZM630.8 875H597.2V841.4L837.8 600.8 871.4 634.4 630.8 875ZM763.9 930.6L875 819.4H1041.7V930.6H763.9Z",
"width": 1000
},
"search": [
"updateexpenses"
]
}
]
Expand Down
Binary file modified frontend/mgramseva/assets/icons/fonts/HomeIcons.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion frontend/mgramseva/lib/icons/home_icons_icons.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Flutter icons HomeIcons
/// Copyright (C) 2021 by original authors @ fluttericon.com, fontello.com
/// Copyright (C) 2024 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
Expand Down Expand Up @@ -30,5 +30,6 @@ class HomeIcons {
static const IconData printreciept = IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData updateconsumer = IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData updateexpenses = IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData anurakshak = IconData(0xe80d, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData gpwscdetails = IconData(0xe814, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
16 changes: 9 additions & 7 deletions frontend/mgramseva/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'dart:io';
import 'dart:isolate';
import 'dart:ui';
Expand Down Expand Up @@ -146,14 +147,15 @@ class _MyAppState extends State<MyApp> {
}

afterViewBuild() async {

if (kIsWeb) return;
IsolateNameServer.registerPortWithName(
_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = data[1];
int progress = data[2];
print("Download progress: "+progress.toString());
// print("Download progress: "+progress.toString());
if (status == DownloadTaskStatus.complete) {
if (CommonProvider.downloadUrl.containsKey(id)) {
if (CommonProvider.downloadUrl[id] != null) OpenFilex.open(CommonProvider.downloadUrl[id] ?? '');
Expand All @@ -165,9 +167,9 @@ class _MyAppState extends State<MyApp> {
CommonProvider.downloadUrl.remove(id);
}
}
setState(() {
print("Download progress: "+progress.toString());
});
// setState(() {
// print("Download progress: "+progress.toString());
// });
});
FlutterDownloader.registerCallback(downloadCallback);
}
Expand Down Expand Up @@ -293,8 +295,8 @@ class _LandingPageState extends State<LandingPage> {
@override
Widget build(BuildContext context) {
var commonProvider = Provider.of<CommonProvider>(context, listen: false);
var languageProvider =
Provider.of<LanguageProvider>(context, listen: false);


return Scaffold(
body: StreamBuilder(
stream: commonProvider.userLoggedStreamCtrl.stream,
Expand All @@ -309,7 +311,7 @@ class _LandingPageState extends State<LandingPage> {
return Notifiers.networkErrorPage(context, () {});
} else {
if (snapshot.data != null &&
commonProvider.userDetails!.isFirstTimeLogin == true) {
commonProvider.userDetails!.isFirstTimeLogin == true) {
return Home();
}
return SelectLanguage();
Expand Down
37 changes: 37 additions & 0 deletions frontend/mgramseva/lib/model/mdms/links.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class LinkResponse {
final List<Links> links;

const LinkResponse({
required this.links,
});

factory LinkResponse.fromJson(Map<String, dynamic> json) => LinkResponse(
links: (json['links'] as List<dynamic>)
.map((item) => Links.fromJson(item as Map<String, dynamic>))
.toList(),
);
}

class Links {
final String tenantID;
final String dashboardURL;
final int id;
final bool isEnabled;
final List<String> roles;

const Links({
required this.tenantID,
required this.dashboardURL,
required this.id,
required this.isEnabled,
required this.roles,
});

factory Links.fromJson(Map<String, dynamic> json) => Links(
tenantID: json['tenantID'] as String,
dashboardURL: json['dashboardURL'] as String,
id: json['id'] as int,
isEnabled: json['isEnabled'] as bool,
roles: (json['roles'] as List<dynamic>).cast<String>(),
);
}
1 change: 1 addition & 0 deletions frontend/mgramseva/lib/providers/common_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CommonProvider with ChangeNotifier {
AppVersion? appVersion;
static Map<String, String> downloadUrl = {};

@override
dispose() {
userLoggedStreamCtrl.close();
super.dispose();
Expand Down
42 changes: 42 additions & 0 deletions frontend/mgramseva/lib/providers/dashboard_provider.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:mgramseva/model/common/metric.dart';
import 'package:mgramseva/model/connection/water_connection.dart';
import 'package:mgramseva/model/connection/water_connections.dart';
import 'package:mgramseva/model/expenses_details/expenses_details.dart';
import 'package:mgramseva/model/mdms/links.dart';
import 'package:mgramseva/model/mdms/property_type.dart';
import 'package:mgramseva/providers/common_provider.dart';
import 'package:mgramseva/providers/home_provider.dart';
import 'package:mgramseva/repository/core_repo.dart';
import 'package:mgramseva/repository/dashboard.dart';
import 'package:mgramseva/repository/expenses_repo.dart';
Expand Down Expand Up @@ -45,6 +49,8 @@ class DashBoardProvider with ChangeNotifier {
var scrollController = ScrollController();
Map? userFeedBackInformation;
List<Metric>? metricInformation;
LinkResponse? dashboardLinks;


@override
void dispose() {
Expand Down Expand Up @@ -809,4 +815,40 @@ class DashBoardProvider with ChangeNotifier {
userFeedBackInformation ?? {})
.pdfPreview();
}


Future<void> getDashboardLinks({String? tenentId}) async {
try {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);

var homeProvider = Provider.of<HomeProvider>(
navigatorKey.currentContext!,
listen: false);
var userResponse = await DashBoardRepository().fetchDashboardLinks(getDashboardLinksMDMS(commonProvider.userDetails!.userRequest!.tenantId.toString()));
userResponse.links.forEach((item){
if(tenentId != null){
if(tenentId == item.tenantID){
if(item.isEnabled){
homeProvider.setAnurakshakDashboardLink(value: "${item.dashboardURL}",link: item);
}
}
}
else if(commonProvider.userDetails?.selectedtenant?.code == item.tenantID){
if(item.isEnabled){
homeProvider.setAnurakshakDashboardLink(value: "${item.dashboardURL}",link: item);
}
}
});

dashboardLinks = userResponse;
streamController.add(userResponse);
} catch (e, s) {
ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s);
streamController.addError('error');
}
}


}
18 changes: 18 additions & 0 deletions frontend/mgramseva/lib/providers/home_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:mgramseva/model/mdms/links.dart';
import 'package:mgramseva/screeens/home/home_walk_through/home_walk_through_list.dart';
import 'package:mgramseva/utils/role_actions.dart';

Expand All @@ -9,6 +10,23 @@ class HomeProvider with ChangeNotifier {
late List<HomeWalkWidgets> homeWalkthroughList;
int activeIndex = 0;

String anurakshakDashboardLink = "";
String getAnurakshakDashboardLink() => anurakshakDashboardLink;

void setAnurakshakDashboardLink({required String value,Links? link}) {
anurakshakDashboardLink = value;
setLinkInfo(link);
notifyListeners();
}
Links? links;
String getLinkInfo() => anurakshakDashboardLink;

void setLinkInfo(Links? value) {
links = value;
}



void setWalkThrough(value) {
homeWalkthroughList = value
.where((element) => RoleActionsFiltering()
Expand Down
4 changes: 3 additions & 1 deletion frontend/mgramseva/lib/providers/tenants_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import 'common_provider.dart';
class TenantsProvider with ChangeNotifier {
Tenant? tenants;
var streamController = StreamController.broadcast();



@override
dispose() {
streamController.close();
super.dispose();
Expand Down
20 changes: 20 additions & 0 deletions frontend/mgramseva/lib/repository/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import 'package:mgramseva/model/dashboard/revenue_dashboard.dart';
import 'package:mgramseva/model/dashboard/revenue_chart.dart';
import 'package:mgramseva/model/mdms/links.dart';
import 'package:mgramseva/providers/common_provider.dart';
import 'package:mgramseva/services/request_info.dart';
import 'package:mgramseva/services/base_service.dart';
Expand Down Expand Up @@ -144,4 +145,23 @@ class DashBoardRepository extends BaseService {
return revenueGraph;
}


Future<LinkResponse> fetchDashboardLinks(Map body, [String? token]) async {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
late LinkResponse links;
final requestInfo = RequestInfo('mGramSeva', .01, "", "search", "", "", "",
token ?? commonProvider.userDetails!.accessToken);
var res = await makeRequest(
url: Url.MDMS,
body: body,
requestInfo: requestInfo,
method: RequestType.POST);
if (res != null) {
links = LinkResponse.fromJson(res['MdmsRes']['anurakshak-dashboard']);
}
return links;
}

}
3 changes: 3 additions & 0 deletions frontend/mgramseva/lib/routers/routers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ class Routes {
static const String TERMS_OF_USE = '/terms';
static const String PRIVACY_POLICY_S = '/privacy/';
static const String TERMS_OF_USE_S = '/terms/';

// Hrms
static const String ANURAKSHAK_DASHBOARD = '/home/dashboard/anurakshak';
}
12 changes: 8 additions & 4 deletions frontend/mgramseva/lib/screeens/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:mgramseva/components/notifications/notifications_list.dart';
import 'package:mgramseva/providers/common_provider.dart';
import 'package:mgramseva/providers/dashboard_provider.dart';
import 'package:mgramseva/providers/home_provider.dart';
import 'package:mgramseva/providers/language.dart';
import 'package:mgramseva/providers/notifications_provider.dart';
Expand Down Expand Up @@ -29,16 +32,15 @@ class Home extends StatefulWidget {

class _HomeState extends State<Home> {
@override
void initState() {
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) => afterViewBuild());
super.initState();
}

afterViewBuild() {
Provider.of<TenantsProvider>(context, listen: false)..getTenants();
Provider.of<TenantsProvider>(context, listen: false).getTenants();
var languageProvider =
Provider.of<LanguageProvider>(context, listen: false);

languageProvider.getLocalizationData(context);
}

Expand Down Expand Up @@ -129,7 +131,9 @@ class _HomeState extends State<Home> {
}
}
}));
})));
})

));
}

Widget _buildHome(BoxConstraints constraint) {
Expand Down
Loading

0 comments on commit 73629fc

Please sign in to comment.