asset tagging cont

main_production_asset_tracking
Sikander Saleem 3 weeks ago
parent 99398a6075
commit 5658059543

@ -89,6 +89,7 @@ class URLs {
static get getAssets => "$_baseUrl/Asset/GetAssets"; // get
static get getFaultDescription => "$_baseUrl/Asset/GetDefectForModelDefinition"; // get
static get getAssetById => "$_baseUrl/Asset/GetAssetById?assetId="; // get
static get assignTagToAsset => "$_baseUrl/Asset/AssignTagToAsset'"; // get
static get getAssetColumnsMetadata => "$_baseUrl/Asset/columns/metadata"; // get asset export columns metadata
static get saveAssetImages => "$_baseUrl/Asset/SaveAssetImages"; // get
static get getModels => "$_baseUrl/ModelDefinition/GetModelDefinitionAsset"; // get ?client=2
@ -639,6 +640,7 @@ class URLs {
static get getPenguinFloors => "$_baseUrl/PenguinIN/floors";
static get getPenguinStatus => "$_baseUrl/PenguinIN/statuses";
static get getPenguinAssetTypes => "$_baseUrl/PenguinIN/assetTypes";
static get getPenguinAssetTags => "$_baseUrl/PenguinIN/tags";
static get getPenguinTagStatusLookup => "$_baseUrl/Lookups/GetLookup?lookupEnum=3037";
static get getPenguinTagAssignmentLookup => "$_baseUrl/Lookups/GetLookup?lookupEnum=3033";

@ -257,4 +257,18 @@ class AssetProvider extends ChangeNotifier {
return false;
}
}
Future<List> linkAssetWithPenguinTag(int assetId, int penguinAssetTagId) async {
try {
final response = await ApiManager.instance.post(URLs.assignTagToAsset, body: {"assetId": assetId, "penguinAssetTagId": penguinAssetTagId});
if (response.statusCode >= 200 && response.statusCode < 300) {
final Map<String, dynamic> jsonData = json.decode(response.body);
List list = jsonData["data"];
return list;
}
return [];
} catch (error) {
return [];
}
}
}

@ -12,6 +12,7 @@ extension WidgetExtensions on Widget {
Widget onPress(VoidCallback? onTap) => InkWell(onTap: onTap, highlightColor: Colors.transparent, splashColor: Colors.transparent, child: this);
Widget get expanded => Expanded(child: this);
Widget get flexible => Flexible(child: this);
Widget get center => Center(child: this);

@ -64,6 +64,7 @@ class AssetByIdModel {
String? modelPhoto;
String? nextPMDate;
String? lastPMDate;
int? penguinAssetTagId;
bool? hasTrainingImageData;
TrainingImageData? trainingImageData;
@ -129,6 +130,7 @@ class AssetByIdModel {
this.modelPhoto,
this.nextPMDate,
this.lastPMDate,
this.penguinAssetTagId,
this.trainingImageData,
this.hasTrainingImageData});
@ -211,6 +213,7 @@ class AssetByIdModel {
modelPhoto = json['modelPhoto'];
nextPMDate = json['nextPMDate'];
lastPMDate = json['lastPMDate'];
penguinAssetTagId = json['penguinAssetTagId'];
hasTrainingImageData = json['hasTrainingImageData'];
trainingImageData = json['trainingImageData'] != null ? TrainingImageData.fromJson(json['trainingImageData']) : null;
}

@ -258,4 +258,34 @@ class AssetTrackingProvider extends ChangeNotifier {
notifyListeners();
}
}
int assetTagPageNumber = 1;
Future<List> getPenguinAssetTags(int tagStatus) async {
try {
final response = await ApiManager.instance.get(URLs.getPenguinAssetTags + "?pageNumber=$assetTagPageNumber&tagStatus=$tagStatus");
if (response.statusCode >= 200 && response.statusCode < 300) {
final Map<String, dynamic> jsonData = json.decode(response.body);
List list = jsonData["data"];
return list;
}
return [];
} catch (error) {
return [];
}
}
Future<List> linkAssetWithPenguinTag(int assetId, int penguinTagId) async {
try {
final response = await ApiManager.instance.get(URLs.getPenguinAssetTags);
if (response.statusCode >= 200 && response.statusCode < 300) {
final Map<String, dynamic> jsonData = json.decode(response.body);
List list = jsonData["data"];
return list;
}
return [];
} catch (error) {
return [];
}
}
}

@ -13,6 +13,7 @@ import 'package:test_sa/models/generic_attachment_model.dart';
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/widgets/equipment/asset_tag_listview.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
import 'package:test_sa/views/widgets/equipment/asset_image_upload_page.dart';
@ -216,6 +217,13 @@ class _AssetDetailPageState extends State<AssetDetailPage> with SingleTickerProv
),
);
// final assetTagAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
// CurvedAnimation(
// parent: _animationController,
// curve: const Interval(0.80, 1.0, curve: Curves.easeOut),
// ),
// );
return Column(
children: [
SingleChildScrollView(
@ -336,6 +344,41 @@ class _AssetDetailPageState extends State<AssetDetailPage> with SingleTickerProv
InfoTextWidget(label: context.translation.installationDate, value: assetModel?.installationDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: context.translation.nextPmDate, value: assetModel?.nextPMDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: context.translation.lastPmDate, value: assetModel?.lastPMDate?.toAssetDetailsFormat, showEmptyValue: true),
if (assetModel?.penguinAssetTagId == null && context.userProvider.isEngineer) ...[
const Divider().defaultStyle(context),
Row(
mainAxisSize: MainAxisSize.min,
children: [
const InfoTextLabelWidget(label: '*Asset is not associated with tag', color: AppColor.red30).flexible,
Container(
margin: const EdgeInsets.only(left: 12, right: 12),
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
decoration: BoxDecoration(
color: AppColor.primary10,
borderRadius: BorderRadius.circular(35),
),
child: Text(
"Link Tag",
style: AppTextStyles.bodyText2.copyWith(color: AppColor.textStyleColor(context)),
),
).onPress(() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => AssetTagListView(),
),
);
}),
],
),
] else ...[
const Divider().defaultStyle(context),
InfoHeaderWidget("Tag Information"),
InfoTextWidget(label: "Label", value: assetModel?.installationDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: "Tag ID", value: assetModel?.installationDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: "MAC Address", value: assetModel?.nextPMDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: "Type", value: assetModel?.lastPMDate?.toAssetDetailsFormat, showEmptyValue: true),
InfoTextWidget(label: "Status", value: assetModel?.lastPMDate?.toAssetDetailsFormat, showEmptyValue: true),
],
],
),
),

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/modules/asset_tracking/asset_tracking_provider.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
class AssetTagListView extends StatelessWidget {
AssetTagListView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const DefaultAppBar(title: "Available Tags"),
body: SizedBox());
// FutureBuilder<List>(
// future: Provider.of<AssetTrackingProvider>(context, listen: false).getPenguinAssetTags(),
// builder: (BuildContext context, AsyncSnapshot<List> snapshot) {
// if (snapshot.connectionState == ConnectionState.waiting) {
// return const Center(child: ALoading());
// } else if (snapshot.hasData) {}
//
// return SizedBox();
//
// // return ListView.separated(
// // key: const ValueKey('list_view'),
// // padding: const EdgeInsets.all(16),
// // itemCount: _searchableList.length,
// // separatorBuilder: (listContext, itemIndex) => 12.height,
// // itemBuilder: (listContext, itemIndex) {
// // // Calculate staggered animation delay
// // final delay = itemIndex * 0.08;
// // final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
// // CurvedAnimation(
// // parent: _animationController,
// // curve: Interval(
// // delay.clamp(0.0, 0.7),
// // (delay + 0.4).clamp(0.0, 1.0),
// // curve: Curves.easeOut,
// // ),
// // ),
// // );
// //
// // final slideAnimation = Tween<Offset>(
// // begin: const Offset(0.0, 0.15),
// // end: Offset.zero,
// // ).animate(
// // CurvedAnimation(
// // parent: _animationController,
// // curve: Interval(
// // delay.clamp(0.0, 0.7),
// // (delay + 0.4).clamp(0.0, 1.0),
// // curve: Curves.easeOutCubic,
// // ),
// // ),
// // );
// //
// // return FadeTransition(
// // opacity: animation,
// // child: SlideTransition(
// // position: slideAnimation,
// // child: AssetItemListView(
// // device: _searchableList[itemIndex],
// // onPressed: (device) {
// // widget.fromBottomBar ? Navigator.of(context).pushNamed(AssetDetailPage.id, arguments: device.id) : Navigator.of(context).pop(device);
// // },
// // ),
// // ),
// // );
// // },
// // );
// }));
}
}
Loading…
Cancel
Save