diff --git a/testflutter104-bflutter-d/authsec_mysql/mysql/wf_table/wf_table.sql b/testflutter104-bflutter-d/authsec_mysql/mysql/wf_table/wf_table.sql new file mode 100755 index 0000000..871005d --- /dev/null +++ b/testflutter104-bflutter-d/authsec_mysql/mysql/wf_table/wf_table.sql @@ -0,0 +1,2 @@ +CREATE TABLE bflutter.Testadv01(id BIGINT NOT NULL AUTO_INCREMENT, calculated_field_field_sub VARCHAR(400), currency VARCHAR(400), qrcode_field VARCHAR(400), fileupload_field VARCHAR(400), number_field_a int, barcode_field VARCHAR(400), number_field_b int, name VARCHAR(400), PRIMARY KEY (id)); + diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_api_service.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_api_service.dart new file mode 100644 index 0000000..3a1d984 --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_api_service.dart @@ -0,0 +1,104 @@ +import 'dart:typed_data'; +import 'package:dio/dio.dart'; +import 'package:http_parser/http_parser.dart'; +import '../../../../resources/api_constants.dart'; +import '../../../../data/network/base_network_service.dart'; +import '../../../../data/network/network_api_service.dart'; + +class Testadv01ApiService { + final String baseUrl = ApiConstants.baseUrl; + + final BaseNetworkService _helper = NetworkApiService(); + + + + Future>> getEntities() async { + + try { + final response = await _helper.getGetApiResponse('$baseUrl/Testadv01/Testadv01'); + final entities = (response as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all entities: $e'); + } + } +Future>> getAllWithPagination( + int page, int size) async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl/Testadv01/Testadv01/getall/page?page=$page&size=$size'); + final entities = + (response['content'] as List).cast>(); + return entities; + } catch (e) { + throw Exception('Failed to get all without pagination: $e'); + } + } + Future> createEntity( + Map entity) async { + try { + print("in post api$entity"); + final response = + await _helper.getPostApiResponse('$baseUrl/Testadv01/Testadv01', entity); + + print(entity); + + // Assuming the response is a Map + Map responseData = response; + + return responseData; + } catch (e) { + throw Exception('Failed to create entity: $e'); + } + } + + + + + + + + + + + + + + + + + + Future updateEntity( int entityId, Map entity) async { + try { + await _helper.getPutApiResponse('$baseUrl/Testadv01/Testadv01/$entityId', + entity); print(entity); + + } catch (e) { + throw Exception('Failed to update entity: $e'); + } + } + + Future deleteEntity( int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl/Testadv01/Testadv01/$entityId'); + } catch (e) { + throw Exception('Failed to delete entity: $e'); + } + } + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_create_entity_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_create_entity_screen.dart new file mode 100644 index 0000000..1b9ab16 --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_create_entity_screen.dart @@ -0,0 +1,92 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:provider/provider.dart'; +import '../Testadv01_viewModel/Testadv01_view_model_screen.dart'; +import 'Testadv01_fields.dart';import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; +import '../../../../utils/image_constant.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../theme/app_style.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import '../../../../widgets/custom_button.dart'; +import '../../../../widgets/custom_text_form_field.dart'; +import '../../../../widgets/custom_dropdown_field.dart'; +import 'dart:math'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:barcode_widget/barcode_widget.dart'; +import 'package:intl/intl.dart'; + +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:http/http.dart' as http; +import 'package:flutter/services.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import '../../../../Reuseable/reusable_date_picker_field.dart'; +import '../../../../Reuseable/reusable_date_time_picker_field.dart' +;import 'package:multi_select_flutter/multi_select_flutter.dart'; +import 'package:just_audio/just_audio.dart'; +import 'package:video_player/video_player.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:lottie/lottie.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import 'dart:io'; +import '../../../../Reuseable/reusable_text_field.dart'; +import '../../../../Reuseable/reusable_dropdown_field.dart'; + + + + + + + + + + + + + + + + +class Testadv01CreateEntityScreen extends StatefulWidget { + const Testadv01CreateEntityScreen({super.key}); + + @override + _Testadv01CreateEntityScreenState createState() => _Testadv01CreateEntityScreenState(); +} + +class _Testadv01CreateEntityScreenState extends State { + +final Map formData = {}; + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, viewModel, child) { + return EntityCreateScreen( + fields: Testadv01Fields.getFields(context), + onSubmit: (data) => _handleSubmit(data), + title: 'Testadv01', + isLoading: viewModel.isLoading, + errorMessage: + viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, + ); + }, + ); + } + + Future _handleSubmit(Map formData) async { + final provider = + Provider.of(context, listen: false); + final success = await provider.createEntity(formData); + + if (success && mounted) { + Navigator.pop(context); + } + } +} \ No newline at end of file diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_details_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_details_screen.dart new file mode 100644 index 0000000..7873421 --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_details_screen.dart @@ -0,0 +1,100 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../../../BuilderField/shared/ui/entity_details.dart'; +import '../Testadv01_viewModel/Testadv01_view_model_screen.dart'; +import 'Testadv01_update_entity_screen.dart'; + +class Testadv01DetailsScreen extends StatefulWidget { + final Map entity; + + const Testadv01DetailsScreen({ + super.key, + required this.entity, + }); + + @override + State createState() => _Testadv01DetailsScreenState(); +} + +class _Testadv01DetailsScreenState extends State { + void _navigateToUpdateScreen(Map entity) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Testadv01ViewModelScreen(), + child: Testadv01UpdateEntityScreen(entity: entity), + ), + ), + ).then((_) { + // Refresh the details screen with updated data + setState(() {}); + }); + } + + void _showDeleteDialog(Map entity) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Confirm Deletion'), + content: const Text('Are you sure you want to delete this Testadv01?'), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Delete'), + onPressed: () async { + Navigator.of(context).pop(); + final vm = + Provider.of(context, listen: false); + final success = await vm.deleteEntity(entity['id']); + if (success && mounted) { + Navigator.pop(context); // Go back to list + } + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, viewModel, child) { + return EntityDetails( + entity: widget.entity, + onEdit: (entity) => _navigateToUpdateScreen(entity), + onDelete: (entity) => _showDeleteDialog(entity), + title: 'Testadv01', + displayFields: [ + {'key': 'name', 'label': 'Name', 'type': 'text'}, + + + + {'key': 'currency', 'label': 'Currency', 'type': 'currency'}, + + {'key': 'qrcode_field', 'label': 'QRCode Field', 'type': 'qr_code'}, + + {'key': 'barcode_field', 'label': 'BarCode Field', 'type': 'bar_code'}, + + {'key': 'number_field_a', 'label': 'Number Field a', 'type': 'number'}, + + {'key': 'number_field_b', 'label': 'Number Field b', 'type': 'number'}, + + {'key': 'calculated_field_field_sub', 'label': 'calculated field Field sub', 'type': 'calculated_field'}, + + ], + isLoading: viewModel.isLoading, + ); + }, + ); + } +} diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_entity_list_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_entity_list_screen.dart new file mode 100644 index 0000000..0e222cf --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_entity_list_screen.dart @@ -0,0 +1,160 @@ +// ignore_for_file: use_build_context_synchronously +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:base_project/BuilderField/shared/ui/entity_list.dart'; +import 'Testadv01_create_entity_screen.dart'; +import 'Testadv01_update_entity_screen.dart'; +import '../Testadv01_viewModel/Testadv01_view_model_screen.dart'; +import 'Testadv01_details_screen.dart';import 'package:flutter/services.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; +import '../../../../theme/app_style.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../widgets/custom_icon_button.dart'; +import '../../../../utils/image_constant.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import '../../../../theme/app_decoration.dart'; +import 'package:multi_select_flutter/multi_select_flutter.dart'; +import '../../../../Reuseable/reusable_text_field.dart'; +import 'package:provider/provider.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +class Testadv01_entity_list_screen extends StatefulWidget { + static const String routeName = '/entity-list'; + + @override + _Testadv01_entity_list_screenState createState() => _Testadv01_entity_list_screenState(); +} + +class _Testadv01_entity_list_screenState extends State { + @override + void initState() { + super.initState(); + _loadData(); + } + + void _loadData() { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) { + final vm = Provider.of(context, listen: false); + vm.getAllWithPagination(refresh: true); + } + }); + } + + void _navigateToCreateScreen() { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Testadv01ViewModelScreen(), + child: const Testadv01CreateEntityScreen(), + ), + ), + ).then((_) { + final vm = Provider.of(context, listen: false); + vm.refreshData(); + }); + } + + void _navigateToUpdateScreen(Map entity) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Testadv01ViewModelScreen(), + child: Testadv01UpdateEntityScreen(entity: entity), + ), + ), + ).then((_) { + final vm = Provider.of(context, listen: false); + vm.refreshData(); + }); + } + + void _navigateToDetailsScreen(Map entity) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Testadv01ViewModelScreen(), + child: Testadv01DetailsScreen(entity: entity), + ), + ), + ); + } + + void _showDeleteDialog(Map entity) { + final parentContext = context; + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Confirm Deletion'), + content: const Text('Are you sure you want to delete this Testadv01?'), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Delete'), + onPressed: () async { + Navigator.of(context).pop(); + final vm = + Provider.of(parentContext, listen: false); + await vm.deleteEntity(entity['id']); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, viewModel, child) { + return EntityList( + entities: viewModel.filteredList, + isLoading: viewModel.isLoading, + errorMessage: + viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, + hasMoreData: viewModel.hasMoreData, + searchQuery: viewModel.searchQuery, + onSearchChanged: (query) => viewModel.searchtestadv01(query), + onEdit: (entity) => _navigateToUpdateScreen(entity), + onDelete: (entity) => _showDeleteDialog(entity), + onTap: (entity) => _navigateToDetailsScreen(entity), + onRefresh: () => viewModel.refreshData(), + onLoadMore: () => viewModel.getAllWithPagination(), + title: 'Testadv01', + onAddNew: _navigateToCreateScreen, + displayFields: [ + {'key': 'name', 'label': 'Name', 'type': 'text'}, + + + + {'key': 'currency', 'label': 'Currency', 'type': 'currency'}, + + {'key': 'qrcode_field', 'label': 'QRCode Field', 'type': 'qr_code'}, + + {'key': 'barcode_field', 'label': 'BarCode Field', 'type': 'bar_code'}, + + {'key': 'number_field_a', 'label': 'Number Field a', 'type': 'number'}, + + {'key': 'number_field_b', 'label': 'Number Field b', 'type': 'number'}, + + {'key': 'calculated_field_field_sub', 'label': 'calculated field Field sub', 'type': 'calculated_field'}, + + ], + ); + }, + ); + } +} diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_fields.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_fields.dart new file mode 100644 index 0000000..4dafc9e --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_fields.dart @@ -0,0 +1,135 @@ +import 'package:base_project/BuilderField/shared/fields/number_field.dart'; +import 'package:base_project/BuilderField/shared/fields/password_field.dart'; +import 'package:base_project/BuilderField/shared/fields/phone_field.dart'; +import 'package:base_project/BuilderField/shared/fields/custom_text_field.dart'; + +import '../../../../BuilderField/shared/fields/base_field.dart'; + +import '../../../../BuilderField/shared/fields/date_field.dart'; +import '../../../../BuilderField/shared/fields/datetime_field.dart'; +import '../../../../BuilderField/shared/fields/email_field.dart'; +import 'package:base_project/BuilderField/shared/fields/url_field.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../../BuilderField/shared/fields/custom_text_field.dart' as shared_text; +import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; +import '../../../../BuilderField/shared/fields/calculated_field.dart'; +import '../../../../BuilderField/shared/fields/one_to_many_field.dart'; +import '../../../../BuilderField/shared/fields/value_list_picker_field.dart'; +import '../../../../BuilderField/shared/fields/captcha_field.dart'; +import '../../../../BuilderField/shared/fields/switch_field.dart'; +import '../../../../BuilderField/shared/fields/url_field.dart'; + +import '../../../../BuilderField/shared/fields/audio_upload_field.dart'; +import '../../../../BuilderField/shared/fields/checkbox_field.dart'; +import '../../../../BuilderField/shared/fields/file_upload_field.dart'; +import '../../../../BuilderField/shared/fields/image_upload_field.dart'; +import '../../../../BuilderField/shared/fields/radio_field.dart'; +import '../../../../BuilderField/shared/fields/video_upload_field.dart'; + +import '../../../../BuilderField/shared/fields/autocomplete_dropdown_field.dart'; +import '../../../../BuilderField/shared/fields/autocomplete_multiselect_field.dart'; +import '../../../../BuilderField/shared/fields/one_to_one_relation_field.dart'; +import '../../../../BuilderField/shared/fields/data_grid_field.dart'; +import '../../../../BuilderField/shared/fields/dropdown_field.dart'; +import '../../../../BuilderField/shared/fields/dynamic_dropdown_field.dart'; +import '../../../../BuilderField/shared/fields/dynamic_multiselect_dropdown_field.dart'; +import '../../../../BuilderField/shared/fields/static_multiselect_field.dart'; +import '../../../../BuilderField/shared/fields/currency_field.dart'; +import '../../../../BuilderField/shared/fields/field_group_field.dart'; +import '../../../../BuilderField/shared/fields/qr_code_field.dart'; +import '../../../../BuilderField/shared/fields/barcode_field.dart'; +import '../Testadv01_viewModel/Testadv01_view_model_screen.dart';/// Field definitions for Testadv01 entity +/// This defines the structure and validation for Testadv01 forms +class Testadv01Fields { + /// Get field definitions for Testadv01 entity + static List getFields(BuildContext context) { + final viewModel = + Provider.of(context, listen: false); + return [ + // Basic Information + CustomTextField( + fieldKey: 'name', + label: 'Name', + hint: 'Enter Name', + isRequired: true, + maxLength: 50, + ), + +FileUploadField( + fieldKey: 'fileupload_field', + label: 'Fileupload Field', + isRequired: false, + ), + + +CurrencyField( + fieldKey: 'currency', + label: 'Currency', + hint: 'Enter Currency', + isRequired: false, + currencySymbol: '₹', + ), + + + QRCodeField( + fieldKey: 'qrcode_field', + label: 'QRCode Field', + hint: 'Scan or enter QRCode Field', + scanner: viewModel.scanQrqrcode_field, + ), + + + BarcodeField( + fieldKey: 'barcode_field', + label: 'BarCode Field', + hint: 'Scan or enter BarCode Field', + scanner: viewModel.scanBarbarcode_field, + ), + + // Number Fields + NumberField( + fieldKey: 'number_field_a', + label: 'Number Field a', + hint: 'Enter Number Field a', + isRequired: false, + min: 0, + decimalPlaces: 0, + ), + + // Number Fields + NumberField( + fieldKey: 'number_field_b', + label: 'Number Field b', + hint: 'Enter Number Field b', + isRequired: false, + min: 0, + decimalPlaces: 0, + ), + + CalculatedField( + fieldKey: 'calculated_field_field_sub', + label: 'calculated field Field sub', + hint: '', + sourceKeys: const [ + + +'number_field_a', + + + + +'number_field_b', + + + + + +], + operation: 'Subtraction', + ), + + ]; + } +} diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_update_entity_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_update_entity_screen.dart new file mode 100644 index 0000000..23ab4ac --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_update_entity_screen.dart @@ -0,0 +1,87 @@ +// ignore_for_file: use_build_context_synchronously +import 'dart:convert'; +import 'package:provider/provider.dart'; +import '../Testadv01_viewModel/Testadv01_view_model_screen.dart'; +import 'package:base_project/BuilderField/shared/ui/entity_screens.dart'; +import 'Testadv01_fields.dart';import '../../../../utils/image_constant.dart'; +import '../../../../utils/size_utils.dart'; +import '../../../../theme/app_style.dart'; +import '../../../../widgets/app_bar/appbar_image.dart'; +import '../../../../widgets/app_bar/appbar_title.dart'; +import '../../../../widgets/app_bar/custom_app_bar.dart'; +import 'package:barcode_widget/barcode_widget.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import '../../../../widgets/custom_button.dart'; +import '../../../../widgets/custom_text_form_field.dart'; +import 'package:flutter/material.dart'; +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; +import 'package:qr_flutter/qr_flutter.dart'; +import 'package:intl/intl.dart'; + +import 'dart:math'; +import '../../../../Reuseable/reusable_text_field.dart'; +import '../../../../Reuseable/reusable_date_picker_field.dart'; +import '../../../../Reuseable/reusable_date_time_picker_field.dart'; +import '../../../../Reuseable/reusable_dropdown_field.dart'; +import 'package:flutter/services.dart'; +class Testadv01UpdateEntityScreen extends StatefulWidget { + final Map entity; + + + Testadv01UpdateEntityScreen({required this.entity}); + + @override + _Testadv01UpdateEntityScreenState createState() => _Testadv01UpdateEntityScreenState(); +} + +class _Testadv01UpdateEntityScreenState extends State { + final _formKey = GlobalKey(); + +@override + Widget build(BuildContext context) { + return Consumer( + builder: (context, viewModel, child) { +// Start with all fields, then remove upload fields (generic filter by keys) + final Set hiddenKeys = { + + +'fileupload_field', + + + + + + + + + + + + + + }; + final fields = Testadv01Fields.getFields(context) + .where((f) => !hiddenKeys.contains(f.fieldKey)) + .toList(); return EntityUpdateScreen( + fields: fields, + initialData: widget.entity, + onSubmit: (data) => _handleSubmit(data), + title: 'Testadv01', + isLoading: viewModel.isLoading, + errorMessage: + viewModel.errorMessage.isNotEmpty ? viewModel.errorMessage : null, + ); + }, + ); + } + + Future _handleSubmit(Map formData) async { + final provider = + Provider.of(context, listen: false); + final success = await provider.updateEntity(widget.entity['id'], formData); + + if (success && mounted) { + Navigator.pop(context); + } + } +} diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_Repo/Testadv01_repo_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_Repo/Testadv01_repo_screen.dart new file mode 100644 index 0000000..ca987ca --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_Repo/Testadv01_repo_screen.dart @@ -0,0 +1,114 @@ +import 'package:dio/dio.dart'; +import '../../../../data/network/base_network_service.dart'; +import '../../../../data/network/network_api_service.dart'; +import '../../../../resources/api_constants.dart'; +import 'package:base_project/data/response/api_response.dart'; + +class Testadv01RepoScreen { + + final String baseUrl = ApiConstants.baseUrl; + final BaseNetworkService _helper = NetworkApiService(); + final String _endpointPath = '/Testadv01/Testadv01'; + + Future>>> getEntities() async { + try { + final response = + await _helper.getGetApiResponse('$baseUrl$_endpointPath'); + print('Response received: $response'); + List> entities = const []; + if (response is List) { + entities = response + .whereType() + .map((e) => Map.from(e as Map)) + .toList(); + } else if (response is Map) { + final dynamic content = response['content']; + if (content is List) { + entities = content + .whereType() + .map((e) => Map.from(e as Map)) + .toList(); + } + } + return ApiResponse.success(entities); + } catch (e) { + print(' error got $e'); + return ApiResponse.error('Failed to get all entities: $e'); + } + } + + Future>>> getAllWithPagination( + int page, int size) async { + try { + final response = await _helper.getGetApiResponse( + '$baseUrl$_endpointPath/getall/page?page=$page&size=$size'); + + if (response is Map && response['content'] is List) { + final List> entities = + (response['content'] as List).cast>().toList(); + return ApiResponse.success(entities); + } else { + return ApiResponse.error('Invalid response format'); + } + } catch (e) { + return ApiResponse.error('Failed to get all without pagination: $e'); + } + } + + Future>> createEntity( + Map entity) async { + try { + print("in post api$entity"); + final response = + await _helper.getPostApiResponse('$baseUrl$_endpointPath', entity); + return ApiResponse.success(response as Map); + } catch (e) { + return ApiResponse.error('Failed to create entity: $e'); + } + } + + Future>> updateEntity( + int entityId, Map entity) async { + try { + final response = await _helper.getPutApiResponse( + '$baseUrl$_endpointPath/$entityId', entity); + return ApiResponse.success(response as Map); + } catch (e) { + return ApiResponse.error('Failed to update entity: $e'); + } + } + + Future> deleteEntity(int entityId) async { + try { + await _helper.getDeleteApiResponse('$baseUrl$_endpointPath/$entityId'); + return ApiResponse.success(null); + } catch (e) { + return ApiResponse.error('Failed to delete entity: $e'); + } + } + + + Future fileupload_fieldUpload( + String ref, String refTableNmae, FormData entity) async { + try { + String apiUrl = "$baseUrl/FileUpload/Uploadeddocs/$ref/$refTableNmae"; + final response = await _helper.getPostApiResponse(apiUrl, entity); + return response; + } catch (e) { + throw Exception('Failed to Upload File: $e'); + } + } + + + + + + + + + + + + + +} diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_viewModel/Testadv01_view_model_screen.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_viewModel/Testadv01_view_model_screen.dart new file mode 100644 index 0000000..f9941aa --- /dev/null +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/Entity/angulardatatype/Testadv01/Testadv01_viewModel/Testadv01_view_model_screen.dart @@ -0,0 +1,479 @@ +import 'package:base_project/data/response/status.dart'; +import 'dart:typed_data'; +import 'package:dio/dio.dart'; +import 'package:http_parser/http_parser.dart'; +import '../../../../utils/toast_messages/toast_message_util.dart'; +import '../../../../BuilderField/shared/utils/entity_field_store.dart'; +import 'package:flutter/material.dart'; +import '../Testadv01_Repo/Testadv01_repo_screen.dart'; + +class Testadv01ViewModelScreen extends ChangeNotifier{ + final Testadv01RepoScreen repo = Testadv01RepoScreen(); + + + // State variables + List> _testadv01List = []; + List> _filteredList = []; + bool _isLoading = false; + String _errorMessage = ''; + int _currentPage = 0; + int _pageSize = 10; + bool _hasMoreData = true; + String _searchQuery = ''; + + // Getters + List> get testadv01List => _testadv01List; + List> get filteredList => _filteredList; + bool get isLoading => _isLoading; + String get errorMessage => _errorMessage; + bool get hasMoreData => _hasMoreData; + String get searchQuery => _searchQuery; + + // Set loading state + void _setLoading(bool loading) { + _isLoading = loading; + notifyListeners(); + } + + // Set error message + void _setError(String error) { + _errorMessage = error; + notifyListeners(); + } + + // Clear error + void clearError() { + _errorMessage = ''; + notifyListeners(); + } + + // Get testadv01 list + Future getEntities() async { + _setLoading(true); + _setError(''); + + try { + final response = await repo.getEntities(); + + if (response.status == Status.SUCCESS) { + _testadv01List = response.data ?? []; + _filteredList = List.from(_testadv01List); + _currentPage = 0; + _hasMoreData = true; + } else { + _setError(response.message ?? 'Failed to fetch testadv01 list'); + } + } catch (e) { + _setError('Failed to fetch testadv01 list: $e'); + } finally { + _setLoading(false); + } + } + + // Get testadv01 list with pagination + Future getAllWithPagination({bool refresh = false}) async { + if (refresh) { + _currentPage = 0; + _testadv01List.clear(); + _filteredList.clear(); + _hasMoreData = true; + } + + if (!_hasMoreData || _isLoading) return; + + _setLoading(true); + _setError(''); + + try { + final response = await repo.getAllWithPagination(_currentPage, _pageSize); + + if (response.status == Status.SUCCESS) { + final newItems = response.data ?? []; + + if (refresh) { + _testadv01List = newItems; + } else { + _testadv01List.addAll(newItems); + } + + _filteredList = List.from(_testadv01List); + _currentPage++; + + // Check if we have more data + _hasMoreData = newItems.length == _pageSize; + } else { + _setError(response.message ?? 'Failed to fetch Testadv01 list'); + } + } catch (e) { + _setError('Failed to fetch testadv01 list: $e'); + } finally { + _setLoading(false); + } + } + + + +// Variable to store image files + List> _fileupload_fieldFiles = []; + + + + + + + + + + + + + + // Create Testadv01 + Future createEntity(Map entity) async { + _setLoading(true); + _setError(''); + + try { + + + // Always source image selections from EntityFieldStore for simplicity + final List storefilefileupload_field = EntityFieldStore.instance + .get>('fileupload_field') ?? + []; + + _fileupload_fieldFiles = storefilefileupload_field + .map((u) => {'path': u.fileName, 'bytes': u.bytes}) + .toList(); + + + entity.remove('fileupload_field'); + + + + + + + + + + + + + + + final response = await repo.createEntity(entity); + + if (response.status == Status.SUCCESS) { +// Get the response ID for image upload + + final responseId = response.data!['id'].toString(); + + +// Upload File if available + if (_fileupload_fieldFiles.isNotEmpty) { + await _uploadfileupload_field(responseId, _fileupload_fieldFiles); + _fileupload_fieldFiles.clear(); // Clear after upload + } + + + + + + + + + + + + + + ToastMessageUtil.showToast( + message: 'testadv01 created successfully', + toastType: ToastType.success, + ); + + // Refresh the list + await getEntities(); + + + EntityFieldStore.instance.remove('fileupload_field'); + + + + + + + + + + + + + + + return true; + } else { + _setError(response.message ?? 'Failed to create Testadv01'); + ToastMessageUtil.showToast( + message: response.message ?? 'Failed to create Testadv01', + toastType: ToastType.error, + ); + return false; + } + } catch (e) { + _setError('Failed to create testadv01: $e'); + ToastMessageUtil.showToast( + message: 'Failed to create Testadv01: $e', + toastType: ToastType.error, + ); + return false; + } finally { + _setLoading(false); + } + } + + // Update testadv01 + Future updateEntity(int id, Map entity) async { + _setLoading(true); + _setError(''); + + try { + final response = await repo.updateEntity(id, entity); + + if (response.status == Status.SUCCESS) { + ToastMessageUtil.showToast( + message: 'Testadv01 updated successfully', + toastType: ToastType.success, + ); + + // Update the item in the list + final index = _testadv01List.indexWhere((item) => item['id'] == id); + if (index != -1) { + _testadv01List[index] = response.data!; + _filteredList = List.from(_testadv01List); + notifyListeners(); + } + return true; + } else { + _setError(response.message ?? 'Failed to update Testadv01'); + ToastMessageUtil.showToast( + message: response.message ?? 'Failed to update Testadv01', + toastType: ToastType.error, + ); + return false; + } + } catch (e) { + _setError('Failed to update testadv01: $e'); + ToastMessageUtil.showToast( + message: 'Failed to update Testadv01: $e', + toastType: ToastType.error, + ); + return false; + } finally { + _setLoading(false); + } + } + + // Delete testadv01 + Future deleteEntity(int id) async { + _setLoading(true); + _setError(''); + + try { + final response = await repo.deleteEntity(id); + + if (response.status == Status.SUCCESS) { + ToastMessageUtil.showToast( + message: 'Testadv01 deleted successfully', + toastType: ToastType.success, + ); + + // Remove the item from the list + _testadv01List.removeWhere((item) => item['id'] == id); + _filteredList = List.from(_testadv01List); + notifyListeners(); + return true; + } else { + _setError(response.message ?? 'Failed to delete Testadv01'); + ToastMessageUtil.showToast( + message: response.message ?? 'Failed to delete Testadv01', + toastType: ToastType.error, + ); + return false; + } + } catch (e) { + _setError('Failed to delete testadv01: $e'); + ToastMessageUtil.showToast( + message: 'Failed to delete Testadv01: $e', + toastType: ToastType.error, + ); + return false; + } finally { + _setLoading(false); + } + } + + // Search testadv01 + void searchtestadv01(String query) { + _searchQuery = query; + + if (query.isEmpty) { + _filteredList = List.from(_testadv01List); + } else { + _filteredList = _testadv01List.where((item) { + return + + +(item['name']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || + + + + + + + +(item['currency']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || + + + + + +(item['qrcode_field']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || + + + + + +(item['barcode_field']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || + + + + + +(item['number_field_a']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) || + + + + + +(item['number_field_b']?.toString().toLowerCase().contains(query.toLowerCase()) ??false) + + + + +; + }).toList(); + } + notifyListeners(); + } + + // Clear search + void clearSearch() { + _searchQuery = ''; + _filteredList = List.from(_testadv01List); + notifyListeners(); + } + + // Refresh data + Future refreshData() async { + await getAllWithPagination(refresh: true); + } + + + + + + + + // Helper method to upload multiple image files + Future _uploadfileupload_field( + String responseId, List Files) async { + try { + for (var File in Files) { + if (File is Map && + File.containsKey('path')) { + String filePath = File['path']; + Uint8List fileBytes = File['bytes']; + + // Upload each image file + await uploadfileupload_field( + responseId, 'Testadv01', filePath, fileBytes); + } + } + } catch (error) { + print('Error uploading files: $error'); + ToastMessageUtil.showToast( + message: "Failed to upload images", toastType: ToastType.error); + } + } + +// Modify the uploadfileupload_fieldimage function + Future uploadfileupload_field(String ref, String refTableNmae, + String selectedFilePath, Uint8List imageTimageBytes) async { + try { + + final Uint8List fileBytes = imageTimageBytes!; + final mimeType = fileupload_fieldlookupMimeType(selectedFilePath); + + FormData formData = FormData.fromMap({ + 'file': MultipartFile.fromBytes( + fileBytes, + filename: selectedFilePath + .split('/') + .last, // Get the file name from the path + contentType: MediaType.parse(mimeType!), + ), + }); + + + await repo.fileupload_fieldUpload(ref, refTableNmae, formData).then((value) { + ToastMessageUtil.showToast( + message: "File uploaded successfully", + toastType: ToastType.success); + }).onError( + (error, stackTrace) { + print("error--$error"); + ToastMessageUtil.showToast( + message: "Failed to upload file", toastType: ToastType.error); + }, + ); + } catch (error) { + print('Error occurred during form submission: $error'); + } + } + +// Modify the lookupMimeType function if needed + String fileupload_fieldlookupMimeType(String filePath) { + final ext = filePath.split('.').last; + switch (ext) { + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + case 'png': + return 'image/png'; + case 'pdf': + return 'application/pdf'; + // Add more cases for other file types as needed + default: + return 'application/octet-stream'; // Default MIME type + } + } + + + +Future scanQrqrcode_field() async { + return null; + } + + + Future scanBarbarcode_field() async { + return null; + } + + + + + + + +} \ No newline at end of file diff --git a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/view/dashboard/home.dart b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/view/dashboard/home.dart index f640e18..a98c211 100644 --- a/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/view/dashboard/home.dart +++ b/testflutter104-demot1-f/authsec_flutter_new/base_project/lib/view/dashboard/home.dart @@ -1,3 +1,6 @@ +import '../../Entity/angulardatatype/Testadv01/Testadv01View/Testadv01_entity_list_screen.dart'; +import '../../Entity/angulardatatype/Testadv01/Testadv01_viewModel/Testadv01_view_model_screen.dart'; + import 'package:base_project/core/constants/ui_constants.dart'; import 'package:base_project/core/theme/color_scheme.dart'; import 'package:base_project/routes/route_names.dart'; @@ -11,595 +14,612 @@ import 'package:base_project/view_model/system_params/system_params_view_model.d import 'package:flutter/material.dart'; class HomeView extends StatefulWidget { - const HomeView({super.key}); +const HomeView({super.key}); - @override - State createState() => _HomeViewState(); +@override +State createState() => _HomeViewState(); } class _HomeViewState extends State with TickerProviderStateMixin { - // Animation Controllers - late AnimationController _pageAnimationController; - late AnimationController _cardsAnimationController; - late AnimationController _actionsAnimationController; +// Animation Controllers +late AnimationController _pageAnimationController; +late AnimationController _cardsAnimationController; +late AnimationController _actionsAnimationController; - // Animations - late Animation _pageFadeAnimation; - late Animation _pageSlideAnimation; - late Animation _cardsScaleAnimation; - late Animation _actionsScaleAnimation; +// Animations +late Animation _pageFadeAnimation; +late Animation _pageSlideAnimation; +late Animation _cardsScaleAnimation; +late Animation _actionsScaleAnimation; - // Dashboard stats (replace with real API data) - List> _dashboardStats = []; +// Dashboard stats (replace with real API data) +List> _dashboardStats = []; - final List> _quickActions = [ - { - 'label': 'Profile', - 'icon': Icons.person, - 'onTap': () {}, - 'backgroundColor': null, // Use theme default - }, - { - 'label': 'Settings', - 'icon': Icons.settings, - 'onTap': () {}, - 'backgroundColor': null, - }, - { - 'label': 'Security', - 'icon': Icons.security, - 'onTap': () {}, - 'backgroundColor': null, - }, - { - 'label': 'Reports', - 'icon': Icons.analytics, - 'onTap': () {}, - 'backgroundColor': null, - }, - ]; +final List> _quickActions = [ +{ +'label': 'Profile', +'icon': Icons.person, +'onTap': () {}, +'backgroundColor': null, // Use theme default +}, +{ +'label': 'Settings', +'icon': Icons.settings, +'onTap': () {}, +'backgroundColor': null, +}, +{ +'label': 'Security', +'icon': Icons.security, +'onTap': () {}, +'backgroundColor': null, +}, +{ +'label': 'Reports', +'icon': Icons.analytics, +'onTap': () {}, +'backgroundColor': null, +}, +]; - final List _drawerItems = [ - DrawerItem( - icon: Icons.person, - title: 'Profile', - subtitle: 'Manage your account', - onTap: (context) { - Navigator.pushNamed(context, RouteNames.profileView); - }, - ), - DrawerItem( - icon: Icons.system_security_update, - title: 'System Parameters', - subtitle: 'Configure system settings', - onTap: (context) { - Navigator.pushNamed(context, RouteNames.systemParamsView); - }, - ), - DrawerItem( - icon: Icons.password, - title: 'Change Password', - subtitle: 'Update your password', - onTap: (context) { - Navigator.pushNamed(context, RouteNames.changePasswordView); - }, +final List _drawerItems = [ +DrawerItem( +icon: Icons.person, +title: 'Profile', +subtitle: 'Manage your account', +onTap: (context) { +Navigator.pushNamed(context, RouteNames.profileView); +}, +), +DrawerItem( +icon: Icons.system_security_update, +title: 'System Parameters', +subtitle: 'Configure system settings', +onTap: (context) { +Navigator.pushNamed(context, RouteNames.systemParamsView); +}, +), +DrawerItem( +icon: Icons.password, +title: 'Change Password', +subtitle: 'Update your password', +onTap: (context) { +Navigator.pushNamed(context, RouteNames.changePasswordView); +}, +), + +// NEW ITEMS + +// NEW MENU + DrawerItem( + icon: Icons.data_object, + title: 'Testadv01 Management', + subtitle: 'Manage Testadv01 entities', + onTap: (context) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (context) => Testadv01ViewModelScreen(), + child: Testadv01_entity_list_screen(), + ), + ), + ); + }, ), - // NEW ITEMS +]; - // NEW MENU - ]; - - @override - void initState() { - super.initState(); - _initializeAnimations(); - _startPageAnimation(); - _loadDashboardData(); - } - - void _initializeAnimations() { - // Page Animation Controller - _pageAnimationController = AnimationController( - duration: UIConstants.durationSlow, - vsync: this, - ); - - // Cards Animation Controller - _cardsAnimationController = AnimationController( - duration: UIConstants.durationNormal, - vsync: this, - ); - - // Actions Animation Controller - _actionsAnimationController = AnimationController( - duration: UIConstants.durationNormal, - vsync: this, - ); - - // Page Animations - _pageFadeAnimation = Tween(begin: 0.0, end: 1.0).animate( - CurvedAnimation( - parent: _pageAnimationController, - curve: UIConstants.curveNormal, - ), - ); - - _pageSlideAnimation = - Tween(begin: const Offset(0, 0.3), end: Offset.zero).animate( - CurvedAnimation( - parent: _pageAnimationController, - curve: UIConstants.curveNormal, - ), - ); - - // Cards Animations - _cardsScaleAnimation = Tween(begin: 0.8, end: 1.0).animate( - CurvedAnimation( - parent: _cardsAnimationController, - curve: UIConstants.curveElastic, - ), - ); - - // Actions Animations - _actionsScaleAnimation = Tween(begin: 0.8, end: 1.0).animate( - CurvedAnimation( - parent: _actionsAnimationController, - curve: UIConstants.curveElastic, - ), - ); - } - - void _startPageAnimation() async { - await Future.delayed(const Duration(milliseconds: 300)); - _pageAnimationController.forward(); - - await Future.delayed(const Duration(milliseconds: 400)); - _cardsAnimationController.forward(); - - await Future.delayed(const Duration(milliseconds: 300)); - _actionsAnimationController.forward(); - } - - Future _loadDashboardData() async { - // TODO: replace with actual API calls, e.g., via a DashboardViewModel - // Simulate network delay - await Future.delayed(const Duration(milliseconds: 400)); - - setState(() { - _dashboardStats = [ - { - 'title': 'Total Users', - 'subtitle': 'Active accounts', - 'numericValue': 1234, - 'valueSuffix': '', - 'icon': Icons.people, - 'type': DashboardCardType.primary, - 'onTap': () {}, - }, - { - 'title': 'System Uptime', - 'subtitle': 'All systems operational', - 'numericValue': 99.9, - 'valueSuffix': '%', - 'icon': Icons.check_circle, - 'type': DashboardCardType.success, - 'onTap': () {}, - }, - { - 'title': 'Security Alerts', - 'subtitle': 'Last 24 hours', - 'numericValue': 2, - 'valueSuffix': '', - 'icon': Icons.security, - 'type': DashboardCardType.info, - 'onTap': () {}, - }, - { - 'title': 'Avg. Response Time', - 'subtitle': 'System performance', - 'numericValue': 2.3, - 'valueSuffix': 's', - 'icon': Icons.speed, - 'type': DashboardCardType.secondary, - 'onTap': () {}, - }, - ]; - }); - } - - @override - void dispose() { - _pageAnimationController.dispose(); - _cardsAnimationController.dispose(); - _actionsAnimationController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - final colorScheme = theme.colorScheme; - final size = MediaQuery.of(context).size; - final userName = UserManager().userName; - - return Scaffold( - backgroundColor: colorScheme.background, - appBar: ModernAppBar( - title: 'Dashboard', - centerTitle: false, - showLogoInTitle: true, - logoImage: _getDashboardLogoImage(colorScheme), - userAvatar: null, - userAvatarImage: _getDashboardLogoImage(colorScheme), - userName: userName, - onProfilePressed: () { - Navigator.pushNamed(context, RouteNames.profileView); - }, - ), - drawer: ModernDrawer(items: _drawerItems), - body: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - colorScheme.background, - colorScheme.surfaceVariant.withOpacity(0.1), - colorScheme.primaryContainer.withOpacity(0.05), - ], - ), - ), - child: SafeArea( - child: SingleChildScrollView( - padding: UIConstants.getResponsivePadding( - context, - mobile: const EdgeInsets.all(UIConstants.spacing24), - tablet: const EdgeInsets.all(UIConstants.spacing32), - desktop: const EdgeInsets.all(UIConstants.spacing40), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Welcome Section - _buildWelcomeSection(theme, colorScheme, userName), - - SizedBox( - height: UIConstants.getResponsiveSpacing( - context, - mobile: UIConstants.spacing32, - tablet: UIConstants.spacing40, - desktop: UIConstants.spacing48, - ), - ), - - // Dashboard Stats - _buildDashboardStats(theme, colorScheme), - - SizedBox( - height: UIConstants.getResponsiveSpacing( - context, - mobile: UIConstants.spacing40, - tablet: UIConstants.spacing56, - desktop: UIConstants.spacing72, - ), - ), - - // Quick Actions - _buildQuickActions(theme, colorScheme), - - SizedBox( - height: UIConstants.getResponsiveSpacing( - context, - mobile: UIConstants.spacing40, - tablet: UIConstants.spacing56, - desktop: UIConstants.spacing72, - ), - ), - - // Recent Activity Section - _buildRecentActivity(theme, colorScheme), - ], - ), - ), - ), - ), - ); - } - - ImageProvider? _getDashboardLogoImage(ColorScheme cs) { - // Prefer dynamic logo from system parameters if present - try { - final sysVm = Provider.of(context, listen: true); - if (sysVm.profileImageBytes != null && - sysVm.profileImageBytes!.isNotEmpty) { - return MemoryImage(sysVm.profileImageBytes!); - } - } catch (_) { - // Provider not available – fall through to default asset - } - - // Default asset logo - return const AssetImage('assets/images/image_not_found.png'); - } - - Widget _buildWelcomeSection( - ThemeData theme, - ColorScheme colorScheme, - String? userName, - ) { - return AnimatedBuilder( - animation: _pageAnimationController, - builder: (context, child) { - return FadeTransition( - opacity: _pageFadeAnimation, - child: SlideTransition( - position: _pageSlideAnimation, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Welcome back, ${userName ?? 'User'}! 👋', - style: theme.textTheme.headlineMedium?.copyWith( - color: colorScheme.onBackground, - fontWeight: FontWeight.w700, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - const SizedBox(height: UIConstants.spacing8), - Text( - 'Here\'s what\'s happening with your system today', - style: theme.textTheme.bodyLarge?.copyWith( - color: colorScheme.onSurfaceVariant, - ), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - ); - }, - ); - } - - // Removed in-body logo: AppBar now displays the logo. - - Widget _buildDashboardStats(ThemeData theme, ColorScheme colorScheme) { - return AnimatedBuilder( - animation: _cardsAnimationController, - builder: (context, child) { - return Transform.scale( - scale: _cardsScaleAnimation.value, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'System Overview', - style: theme.textTheme.titleLarge?.copyWith( - color: colorScheme.onBackground, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: UIConstants.spacing24), - - // Responsive Grid - LayoutBuilder( - builder: (context, constraints) { - final crossAxisCount = UIConstants.isMobile(context) - ? 2 - : UIConstants.isTablet(context) - ? 3 - : 4; - - // Use fixed mainAxisExtent per breakpoint to avoid overflow - final double mainAxisExtent = UIConstants.isMobile(context) - ? 130 - : (UIConstants.isTablet(context) ? 160 : 180); - - return GridView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: crossAxisCount, - crossAxisSpacing: UIConstants.spacing16, - mainAxisSpacing: UIConstants.spacing16, - mainAxisExtent: mainAxisExtent, - ), - itemCount: _dashboardStats.length, - itemBuilder: (context, index) { - final stat = _dashboardStats[index]; - return DashboardCard( - title: stat['title'], - subtitle: stat['subtitle'], - value: stat['value'], - numericValue: stat['numericValue'], - valueSuffix: stat['valueSuffix'], - animationDuration: UIConstants.durationNormal, - icon: stat['icon'], - type: stat['type'], - onTap: stat['onTap'], - ); - }, - ); - }, - ), - ], - ), - ); - }, - ); - } - - Widget _buildQuickActions(ThemeData theme, ColorScheme colorScheme) { - return AnimatedBuilder( - animation: _actionsAnimationController, - builder: (context, child) { - return Transform.scale( - scale: _actionsScaleAnimation.value, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Quick Actions', - style: theme.textTheme.titleLarge?.copyWith( - color: colorScheme.onBackground, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: UIConstants.spacing24), - - // Responsive Grid - LayoutBuilder( - builder: (context, constraints) { - final crossAxisCount = UIConstants.isMobile(context) - ? 2 - : UIConstants.isTablet(context) - ? 4 - : 6; - - return GridView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: crossAxisCount, - crossAxisSpacing: UIConstants.spacing16, - mainAxisSpacing: UIConstants.spacing16, - childAspectRatio: 1.0, - ), - itemCount: _quickActions.length, - itemBuilder: (context, index) { - final action = _quickActions[index]; - return QuickActionButton( - label: action['label'], - icon: action['icon'], - onTap: action['onTap'], - backgroundColor: action['backgroundColor'], - size: UIConstants.logoSizeMedium, - ); - }, - ); - }, - ), - ], - ), - ); - }, - ); - } - - Widget _buildRecentActivity(ThemeData theme, ColorScheme colorScheme) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Recent Activity', - style: theme.textTheme.titleLarge?.copyWith( - color: colorScheme.onBackground, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: UIConstants.spacing24), - Container( - padding: UIConstants.cardPaddingMedium, - decoration: BoxDecoration( - color: colorScheme.surface, - borderRadius: BorderRadius.circular(UIConstants.radius16), - boxShadow: [ - BoxShadow( - color: colorScheme.shadow.withOpacity(0.1), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], - ), - child: Column( - children: [ - _buildActivityItem( - theme, - colorScheme, - Icons.security, - 'Security scan completed', - 'System security check finished successfully', - '2 minutes ago', - AppColorScheme.success, - ), - const Divider(height: UIConstants.spacing24), - _buildActivityItem( - theme, - colorScheme, - Icons.update, - 'System updated', - 'Latest security patches installed', - '1 hour ago', - AppColorScheme.info, - ), - const Divider(height: UIConstants.spacing24), - _buildActivityItem( - theme, - colorScheme, - Icons.backup, - 'Backup completed', - 'Daily backup process finished', - '3 hours ago', - colorScheme.primary, - ), - ], - ), - ), - ], - ); - } - - Widget _buildActivityItem( - ThemeData theme, - ColorScheme colorScheme, - IconData icon, - String title, - String subtitle, - String time, - Color iconColor, - ) { - return Row( - children: [ - Container( - padding: const EdgeInsets.all(UIConstants.spacing8), - decoration: BoxDecoration( - color: iconColor.withOpacity(0.1), - borderRadius: BorderRadius.circular(UIConstants.radius8), - ), - child: Icon(icon, color: iconColor, size: UIConstants.iconSizeMedium), - ), - const SizedBox(width: UIConstants.spacing16), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: theme.textTheme.titleMedium?.copyWith( - color: colorScheme.onSurface, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: UIConstants.spacing4), - Text( - subtitle, - style: theme.textTheme.bodyMedium?.copyWith( - color: colorScheme.onSurfaceVariant, - ), - ), - ], - ), - ), - Text( - time, - style: theme.textTheme.bodySmall?.copyWith( - color: colorScheme.onSurfaceVariant, - ), - ), - ], - ); - } +@override +void initState() { +super.initState(); +_initializeAnimations(); +_startPageAnimation(); +_loadDashboardData(); } + +void _initializeAnimations() { +// Page Animation Controller +_pageAnimationController = AnimationController( +duration: UIConstants.durationSlow, +vsync: this, +); + +// Cards Animation Controller +_cardsAnimationController = AnimationController( +duration: UIConstants.durationNormal, +vsync: this, +); + +// Actions Animation Controller +_actionsAnimationController = AnimationController( +duration: UIConstants.durationNormal, +vsync: this, +); + +// Page Animations +_pageFadeAnimation = Tween(begin: 0.0, end: 1.0).animate( +CurvedAnimation( +parent: _pageAnimationController, +curve: UIConstants.curveNormal, +), +); + +_pageSlideAnimation = +Tween(begin: const Offset(0, 0.3), end: Offset.zero).animate( +CurvedAnimation( +parent: _pageAnimationController, +curve: UIConstants.curveNormal, +), +); + +// Cards Animations +_cardsScaleAnimation = Tween(begin: 0.8, end: 1.0).animate( +CurvedAnimation( +parent: _cardsAnimationController, +curve: UIConstants.curveElastic, +), +); + +// Actions Animations +_actionsScaleAnimation = Tween(begin: 0.8, end: 1.0).animate( +CurvedAnimation( +parent: _actionsAnimationController, +curve: UIConstants.curveElastic, +), +); +} + +void _startPageAnimation() async { +await Future.delayed(const Duration(milliseconds: 300)); +_pageAnimationController.forward(); + +await Future.delayed(const Duration(milliseconds: 400)); +_cardsAnimationController.forward(); + +await Future.delayed(const Duration(milliseconds: 300)); +_actionsAnimationController.forward(); +} + +Future _loadDashboardData() async { +// TODO: replace with actual API calls, e.g., via a DashboardViewModel +// Simulate network delay +await Future.delayed(const Duration(milliseconds: 400)); + +setState(() { +_dashboardStats = [ +{ +'title': 'Total Users', +'subtitle': 'Active accounts', +'numericValue': 1234, +'valueSuffix': '', +'icon': Icons.people, +'type': DashboardCardType.primary, +'onTap': () {}, +}, +{ +'title': 'System Uptime', +'subtitle': 'All systems operational', +'numericValue': 99.9, +'valueSuffix': '%', +'icon': Icons.check_circle, +'type': DashboardCardType.success, +'onTap': () {}, +}, +{ +'title': 'Security Alerts', +'subtitle': 'Last 24 hours', +'numericValue': 2, +'valueSuffix': '', +'icon': Icons.security, +'type': DashboardCardType.info, +'onTap': () {}, +}, +{ +'title': 'Avg. Response Time', +'subtitle': 'System performance', +'numericValue': 2.3, +'valueSuffix': 's', +'icon': Icons.speed, +'type': DashboardCardType.secondary, +'onTap': () {}, +}, +]; +}); +} + +@override +void dispose() { +_pageAnimationController.dispose(); +_cardsAnimationController.dispose(); +_actionsAnimationController.dispose(); +super.dispose(); +} + +@override +Widget build(BuildContext context) { +final theme = Theme.of(context); +final colorScheme = theme.colorScheme; +final size = MediaQuery.of(context).size; +final userName = UserManager().userName; + +return Scaffold( +backgroundColor: colorScheme.background, +appBar: ModernAppBar( +title: 'Dashboard', +centerTitle: false, +showLogoInTitle: true, +logoImage: _getDashboardLogoImage(colorScheme), +userAvatar: null, +userAvatarImage: _getDashboardLogoImage(colorScheme), +userName: userName, +onProfilePressed: () { +Navigator.pushNamed(context, RouteNames.profileView); +}, +), +drawer: ModernDrawer(items: _drawerItems), +body: Container( +decoration: BoxDecoration( +gradient: LinearGradient( +begin: Alignment.topLeft, +end: Alignment.bottomRight, +colors: [ +colorScheme.background, +colorScheme.surfaceVariant.withOpacity(0.1), +colorScheme.primaryContainer.withOpacity(0.05), +], +), +), +child: SafeArea( +child: SingleChildScrollView( +padding: UIConstants.getResponsivePadding( +context, +mobile: const EdgeInsets.all(UIConstants.spacing24), +tablet: const EdgeInsets.all(UIConstants.spacing32), +desktop: const EdgeInsets.all(UIConstants.spacing40), +), +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +// Welcome Section +_buildWelcomeSection(theme, colorScheme, userName), + +SizedBox( +height: UIConstants.getResponsiveSpacing( +context, +mobile: UIConstants.spacing32, +tablet: UIConstants.spacing40, +desktop: UIConstants.spacing48, +), +), + +// Dashboard Stats +_buildDashboardStats(theme, colorScheme), + +SizedBox( +height: UIConstants.getResponsiveSpacing( +context, +mobile: UIConstants.spacing40, +tablet: UIConstants.spacing56, +desktop: UIConstants.spacing72, +), +), + +// Quick Actions +_buildQuickActions(theme, colorScheme), + +SizedBox( +height: UIConstants.getResponsiveSpacing( +context, +mobile: UIConstants.spacing40, +tablet: UIConstants.spacing56, +desktop: UIConstants.spacing72, +), +), + +// Recent Activity Section +_buildRecentActivity(theme, colorScheme), +], +), +), +), +), +); +} + +ImageProvider? _getDashboardLogoImage(ColorScheme cs) { +// Prefer dynamic logo from system parameters if present +try { +final sysVm = Provider.of(context, listen: true); +if (sysVm.profileImageBytes != null && +sysVm.profileImageBytes!.isNotEmpty) { +return MemoryImage(sysVm.profileImageBytes!); +} +} catch (_) { +// Provider not available – fall through to default asset +} + +// Default asset logo +return const AssetImage('assets/images/image_not_found.png'); +} + +Widget _buildWelcomeSection( +ThemeData theme, +ColorScheme colorScheme, +String? userName, +) { +return AnimatedBuilder( +animation: _pageAnimationController, +builder: (context, child) { +return FadeTransition( +opacity: _pageFadeAnimation, +child: SlideTransition( +position: _pageSlideAnimation, +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Text( +'Welcome back, ${userName ?? 'User'}! 👋', +style: theme.textTheme.headlineMedium?.copyWith( +color: colorScheme.onBackground, +fontWeight: FontWeight.w700, +), +maxLines: 1, +overflow: TextOverflow.ellipsis, +), +const SizedBox(height: UIConstants.spacing8), +Text( +'Here\'s what\'s happening with your system today', +style: theme.textTheme.bodyLarge?.copyWith( +color: colorScheme.onSurfaceVariant, +), +maxLines: 2, +overflow: TextOverflow.ellipsis, +), +], +), +), +); +}, +); +} + +// Removed in-body logo: AppBar now displays the logo. + +Widget _buildDashboardStats(ThemeData theme, ColorScheme colorScheme) { +return AnimatedBuilder( +animation: _cardsAnimationController, +builder: (context, child) { +return Transform.scale( +scale: _cardsScaleAnimation.value, +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Text( +'System Overview', +style: theme.textTheme.titleLarge?.copyWith( +color: colorScheme.onBackground, +fontWeight: FontWeight.w600, +), +), +const SizedBox(height: UIConstants.spacing24), + +// Responsive Grid +LayoutBuilder( +builder: (context, constraints) { +final crossAxisCount = UIConstants.isMobile(context) +? 2 +: UIConstants.isTablet(context) +? 3 +: 4; + +// Use fixed mainAxisExtent per breakpoint to avoid overflow +final double mainAxisExtent = UIConstants.isMobile(context) +? 130 +: (UIConstants.isTablet(context) ? 160 : 180); + +return GridView.builder( +shrinkWrap: true, +physics: const NeverScrollableScrollPhysics(), +gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +crossAxisCount: crossAxisCount, +crossAxisSpacing: UIConstants.spacing16, +mainAxisSpacing: UIConstants.spacing16, +mainAxisExtent: mainAxisExtent, +), +itemCount: _dashboardStats.length, +itemBuilder: (context, index) { +final stat = _dashboardStats[index]; +return DashboardCard( +title: stat['title'], +subtitle: stat['subtitle'], +value: stat['value'], +numericValue: stat['numericValue'], +valueSuffix: stat['valueSuffix'], +animationDuration: UIConstants.durationNormal, +icon: stat['icon'], +type: stat['type'], +onTap: stat['onTap'], +); +}, +); +}, +), +], +), +); +}, +); +} + +Widget _buildQuickActions(ThemeData theme, ColorScheme colorScheme) { +return AnimatedBuilder( +animation: _actionsAnimationController, +builder: (context, child) { +return Transform.scale( +scale: _actionsScaleAnimation.value, +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Text( +'Quick Actions', +style: theme.textTheme.titleLarge?.copyWith( +color: colorScheme.onBackground, +fontWeight: FontWeight.w600, +), +), +const SizedBox(height: UIConstants.spacing24), + +// Responsive Grid +LayoutBuilder( +builder: (context, constraints) { +final crossAxisCount = UIConstants.isMobile(context) +? 2 +: UIConstants.isTablet(context) +? 4 +: 6; + +return GridView.builder( +shrinkWrap: true, +physics: const NeverScrollableScrollPhysics(), +gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( +crossAxisCount: crossAxisCount, +crossAxisSpacing: UIConstants.spacing16, +mainAxisSpacing: UIConstants.spacing16, +childAspectRatio: 1.0, +), +itemCount: _quickActions.length, +itemBuilder: (context, index) { +final action = _quickActions[index]; +return QuickActionButton( +label: action['label'], +icon: action['icon'], +onTap: action['onTap'], +backgroundColor: action['backgroundColor'], +size: UIConstants.logoSizeMedium, +); +}, +); +}, +), +], +), +); +}, +); +} + +Widget _buildRecentActivity(ThemeData theme, ColorScheme colorScheme) { +return Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Text( +'Recent Activity', +style: theme.textTheme.titleLarge?.copyWith( +color: colorScheme.onBackground, +fontWeight: FontWeight.w600, +), +), +const SizedBox(height: UIConstants.spacing24), +Container( +padding: UIConstants.cardPaddingMedium, +decoration: BoxDecoration( +color: colorScheme.surface, +borderRadius: BorderRadius.circular(UIConstants.radius16), +boxShadow: [ +BoxShadow( +color: colorScheme.shadow.withOpacity(0.1), +blurRadius: 8, +offset: const Offset(0, 2), +), +], +), +child: Column( +children: [ +_buildActivityItem( +theme, +colorScheme, +Icons.security, +'Security scan completed', +'System security check finished successfully', +'2 minutes ago', +AppColorScheme.success, +), +const Divider(height: UIConstants.spacing24), +_buildActivityItem( +theme, +colorScheme, +Icons.update, +'System updated', +'Latest security patches installed', +'1 hour ago', +AppColorScheme.info, +), +const Divider(height: UIConstants.spacing24), +_buildActivityItem( +theme, +colorScheme, +Icons.backup, +'Backup completed', +'Daily backup process finished', +'3 hours ago', +colorScheme.primary, +), +], +), +), +], +); +} + +Widget _buildActivityItem( +ThemeData theme, +ColorScheme colorScheme, +IconData icon, +String title, +String subtitle, +String time, +Color iconColor, +) { +return Row( +children: [ +Container( +padding: const EdgeInsets.all(UIConstants.spacing8), +decoration: BoxDecoration( +color: iconColor.withOpacity(0.1), +borderRadius: BorderRadius.circular(UIConstants.radius8), +), +child: Icon(icon, color: iconColor, size: UIConstants.iconSizeMedium), +), +const SizedBox(width: UIConstants.spacing16), +Expanded( +child: Column( +crossAxisAlignment: CrossAxisAlignment.start, +children: [ +Text( +title, +style: theme.textTheme.titleMedium?.copyWith( +color: colorScheme.onSurface, +fontWeight: FontWeight.w600, +), +), +const SizedBox(height: UIConstants.spacing4), +Text( +subtitle, +style: theme.textTheme.bodyMedium?.copyWith( +color: colorScheme.onSurfaceVariant, +), +), +], +), +), +Text( +time, +style: theme.textTheme.bodySmall?.copyWith( +color: colorScheme.onSurfaceVariant, +), +), +], +); +} +} \ No newline at end of file diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java index f9801fb..0b28bef 100644 --- a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/Builders/Services/BuilderService.java @@ -69,6 +69,9 @@ public class BuilderService { executeDump(true); // ADD OTHER SERVICE +addCustomMenu( "Testadv01","Testadv01", "Transcations"); + + System.out.println("dashboard and menu inserted..."); diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/Testadv01Controller.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/Testadv01Controller.java new file mode 100644 index 0000000..2f459ca --- /dev/null +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/Testadv01Controller.java @@ -0,0 +1,139 @@ +package com.realnet.angulardatatype.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.springframework.web.bind.annotation.CrossOrigin; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.realnet.config.EmailService; +import com.realnet.users.entity1.AppUser; +import com.realnet.users.service1.AppUserServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.data.domain.*; +import com.realnet.fnd.response.EntityResponse; +import org.springframework.http.*; +import org.springframework.beans.factory.annotation.*; +import com.realnet.angulardatatype.Entity.Testadv01; +import com.realnet.angulardatatype.Services.Testadv01Service ; + + + + + + + + + + + + + + + + +@RequestMapping(value = "/Testadv01") + @CrossOrigin("*") +@RestController +public class Testadv01Controller { + @Autowired + private Testadv01Service Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + + + + + @PostMapping("/Testadv01") + public Testadv01 Savedata(@RequestBody Testadv01 data) { + Testadv01 save = Service.Savedata(data) ; + + + + + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testadv01/{id}") + public Testadv01 update(@RequestBody Testadv01 data,@PathVariable Integer id ) { + Testadv01 update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testadv01/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = Service.getAllWithPagination(paging); + + return get; + + } + @GetMapping("/Testadv01") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testadv01") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testadv01/{id}") + public Testadv01 getdetailsbyId(@PathVariable Integer id ) { + Testadv01 get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testadv01/{id}") + public ResponseEntity delete_by_id(@PathVariable Integer id ) { + Service.delete_by_id(id); + return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); + + } + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/tokenFree_Testadv01Controller.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/tokenFree_Testadv01Controller.java new file mode 100644 index 0000000..5fe8cdb --- /dev/null +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Controllers/tokenFree_Testadv01Controller.java @@ -0,0 +1,139 @@ +package com.realnet.angulardatatype.Controllers; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.springframework.web.bind.annotation.CrossOrigin; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.realnet.config.EmailService; +import com.realnet.users.entity1.AppUser; +import com.realnet.users.service1.AppUserServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.data.domain.*; +import com.realnet.fnd.response.EntityResponse; +import org.springframework.http.*; +import org.springframework.beans.factory.annotation.*; +import com.realnet.angulardatatype.Entity.Testadv01; +import com.realnet.angulardatatype.Services.Testadv01Service ; + + + + + + + + + + + + + + + + +@RequestMapping(value = "/token/Testadv01") + @CrossOrigin("*") +@RestController +public class tokenFree_Testadv01Controller { + @Autowired + private Testadv01Service Service; + +@Value("${projectPath}") + private String projectPath; + + + + + + + + + + + + + + + + + + @PostMapping("/Testadv01") + public Testadv01 Savedata(@RequestBody Testadv01 data) { + Testadv01 save = Service.Savedata(data) ; + + + + + + + + + + + + + + + + System.out.println("data saved..." + save); + + return save; + } +@PutMapping("/Testadv01/{id}") + public Testadv01 update(@RequestBody Testadv01 data,@PathVariable Integer id ) { + Testadv01 update = Service.update(data,id); + System.out.println("data update..." + update); + return update; + } +// get all with pagination + @GetMapping("/Testadv01/getall/page") + public Page getall(@RequestParam(value = "page", required = false) Integer page, + @RequestParam(value = "size", required = false) Integer size) { + Pageable paging = PageRequest.of(page, size); + Page get = Service.getAllWithPagination(paging); + + return get; + + } + @GetMapping("/Testadv01") + public List getdetails() { + List get = Service.getdetails(); + return get; +} +// get all without authentication + + @GetMapping("/token/Testadv01") + public List getallwioutsec() { + List get = Service.getdetails(); + return get; +} +@GetMapping("/Testadv01/{id}") + public Testadv01 getdetailsbyId(@PathVariable Integer id ) { + Testadv01 get = Service.getdetailsbyId(id); + return get; + } +@DeleteMapping("/Testadv01/{id}") + public ResponseEntity delete_by_id(@PathVariable Integer id ) { + Service.delete_by_id(id); + return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); + + } + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Entity/Testadv01.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Entity/Testadv01.java new file mode 100644 index 0000000..e5cb580 --- /dev/null +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Entity/Testadv01.java @@ -0,0 +1,53 @@ +package com.realnet.angulardatatype.Entity; + import lombok.*; +import com.realnet.WhoColumn.Entity.Extension; + import javax.persistence.*; + import java.time.LocalDateTime; + import java.util.*; + + + + + + + + + + + + + + + + + @Entity + @Data + public class Testadv01 extends Extension { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + +private String name; + +private String fileupload_fieldname; +private String fileupload_fieldpath ; + +private String currency; + +private String qrcode_field; + +private String barcode_field; + +private int number_field_a; + +private int number_field_b; + +private String calculated_field_field_sub; + + +} diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Repository/Testadv01Repository.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Repository/Testadv01Repository.java new file mode 100644 index 0000000..e60ea2a --- /dev/null +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Repository/Testadv01Repository.java @@ -0,0 +1,40 @@ +package com.realnet.angulardatatype.Repository; + + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import org.springframework.stereotype.Repository; +import java.util.*; + + + + + + + + + + + + + + + + + + + +import com.realnet.angulardatatype.Entity.Testadv01; + +@Repository +public interface Testadv01Repository extends JpaRepository { + +@Query(value = "select * from testadv01 where created_by=?1", nativeQuery = true) + List findAll(Long creayedBy); + +@Query(value = "select * from testadv01 where created_by=?1", nativeQuery = true) + Page findAll( Long creayedBy,Pageable page); +} \ No newline at end of file diff --git a/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Services/Testadv01Service.java b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Services/Testadv01Service.java new file mode 100644 index 0000000..61bc628 --- /dev/null +++ b/testflutter104-test2-b/authsec_springboot/backend/src/main/java/com/realnet/angulardatatype/Services/Testadv01Service.java @@ -0,0 +1,143 @@ +package com.realnet.angulardatatype.Services; +import com.realnet.angulardatatype.Repository.Testadv01Repository; +import com.realnet.angulardatatype.Entity.Testadv01 +;import java.util.*; + +import org.springframework.beans.factory.annotation.Autowired; +import com.realnet.SequenceGenerator.Service.SequenceService; +import org.springframework.data.domain.Page; +import com.realnet.realm.Entity.Realm; +import com.realnet.realm.Services.RealmService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.*; +import com.realnet.users.service1.AppUserServiceImpl; +import com.realnet.users.entity1.AppUser; + + + + + + + + + + + + + + + + + import org.springframework.stereotype.Service; + +@Service + public class Testadv01Service { +@Autowired +private Testadv01Repository Repository; + @Autowired + private AppUserServiceImpl userService; +@Autowired + private RealmService realmService; + + + + + + + + + + + + + + + +public Testadv01 Savedata(Testadv01 data) { + + + + + + + + + + + + + + + + + data.setUpdatedBy(getUser().getUserId()); + data.setCreatedBy(getUser().getUserId()); + data.setAccountId(getUser().getAccount().getAccount_id()); +Testadv01 save = Repository.save(data); + return save; + } + + +// get all with pagination + public Page getAllWithPagination(Pageable page) { + return Repository.findAll( getUser().getUserId(),page); + } +public List getdetails() { + List realm = realmService.findByUserId(getUser().getUserId()); +List all = Repository.findAll(getUser().getUserId()); + + return all ; } + + +public Testadv01 getdetailsbyId(Integer id) { + return Repository.findById(id).get(); + } + + + public void delete_by_id(Integer id) { + Repository.deleteById(id); +} + + +public Testadv01 update(Testadv01 data,Integer id) { + Testadv01 old = Repository.findById(id).get(); +old.setName(data.getName()); + + + +old.setCurrency(data.getCurrency()); + +old.setQrcode_field(data.getQrcode_field()); + +old.setBarcode_field(data.getBarcode_field()); + +old.setNumber_field_a(data.getNumber_field_a()); + +old.setNumber_field_b(data.getNumber_field_b()); + +old.setCalculated_field_field_sub(data.getCalculated_field_field_sub()); + +final Testadv01 test = Repository.save(old); + data.setUpdatedBy(getUser().getUserId()); + return test;} + + + + + + + + + + + + + + + + + public AppUser getUser() { + AppUser user = userService.getLoggedInUser(); + return user; + + }}