Sfoglia il codice sorgente

fixing upload

master
jefry 4 anni fa
parent
commit
5896b24e0a
7 ha cambiato i file con 82 aggiunte e 19 eliminazioni
  1. +18
    -4
      lib/asset_details.dart
  2. +7
    -0
      lib/asset_logs.dart
  3. +1
    -0
      lib/home.dart
  4. +31
    -13
      lib/util/dbHandler.dart
  5. +23
    -1
      lib/util/utils.dart
  6. +1
    -1
      pubspec.lock
  7. +1
    -0
      pubspec.yaml

+ 18
- 4
lib/asset_details.dart Vedi File

@@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'main.dart';
import 'util/Models.dart';
import 'package:http/http.dart' as http;
import 'util/prefsKey.dart';

class AssetDetails extends StatefulWidget {
// AssetDetails({Key key}) : super(key: key);
@@ -217,12 +219,24 @@ class _AssetDetailsState extends State<AssetDetails> with TickerProviderStateMix
alignment: Alignment.centerRight,
child: InkWell(
onTap: ()async {
var result = await DBHelper.database.getRefBlob(_asset.tag_number);
if(result!=null){
if(result.blob!=null) Navigator.push(context, MaterialPageRoute(builder: (context) => PhotoViewer(result.blob,)));
try{
var dbName = await DBHelper.database.getDbName();
var bUnit = await DBHelper.database.getBUnit();
util.showLoading(context);
http.Response result = await http.get(
'${prefs.getString(keyClass.hostAddress)??"https://asset.thamringroup.web.id"}/api/images?q=${_asset.tag_number}&s=${dbName}&b=${bUnit}',
).timeout(Duration(seconds: 3));
Navigator.pop(context);
if(result!=null){
Navigator.push(context, MaterialPageRoute(builder: (context) => PhotoViewer(result.bodyBytes)));
}
else util.showToast('ALERT', "No Archived Images yet");
}
else util.showToast('ALERT', "No Archived Images yet");
catch(e){
Navigator.pop(context);
print(e);
util.showToast('ALERT', "No Archived Images yet");
}
//showPhoto
},
child: Padding(


+ 7
- 0
lib/asset_logs.dart Vedi File

@@ -250,6 +250,13 @@ class _AssetLogsState extends State<AssetLogs> {
],
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: (){

},
icon: Icon(Icons.sync),
label: Text("Sync Approval"),
),
);
}
}

+ 1
- 0
lib/home.dart Vedi File

@@ -323,6 +323,7 @@ class _HomeState extends State<Home> {
// var allUnits = await DBHelper.database.getAllAsset();
// print('${allUnits.length} Units');
util.showToast('ALERT','Data Downloaded');
await DBHelper.database.setOpenState();
}
if(value==-1.0){
util.showToast('ALERT','Data Error ${trans.error}');


+ 31
- 13
lib/util/dbHandler.dart Vedi File

@@ -5,6 +5,7 @@ import 'prefsKey.dart';
import 'dart:io';
import 'dart:async';
import 'package:path/path.dart';
import 'package:intl/intl.dart';

class DBHelper{
DBHelper._();
@@ -78,19 +79,19 @@ class DBHelper{
return null;
}
}
getRefBlob(tagNumber)async{
try{
final database = await db;
var res = await database.query(tableName.ref,where: "${columnName.tag_number} = ?",whereArgs: [tagNumber]);
// var a = await database.rawQuery("select length(${columnName.blob}) / 1024 from ${tableName.insert} where ${columnName.no} = $no");
// print(a);
return res.isNotEmpty ? Asset.fromJson(res.first): null;
}
catch(e){
print(e);
return null;
}
}
// getRefBlob(tagNumber)async{
// try{
// final database = await db;
// var res = await database.query(tableName.insert,where: "${columnName.tag_number} = ?",whereArgs: [tagNumber]);
// // var a = await database.rawQuery("select count(*) from ${tableName.insert}");
// // print(a);
// return res.isNotEmpty ? Asset.fromJson(res.first): null;
// }
// catch(e){
// print(e);
// return null;
// }
// }
searchbyTagNumber(tagNumber) async{
try{
final database = await db;
@@ -256,5 +257,22 @@ class DBHelper{
return null;
}
}
setOpenState()async{
try{
final database = await db;
var check_KEY = await database.rawQuery("SELECT 1 FROM ${tableName.key} where ${columnName.key} = 'STATE'");
if (check_KEY.length<=0){
await database.insert(tableName.key, {columnName.key:"STATE",columnName.value:"OPEN"});
}
else{
await database.update(tableName.key, {columnName.value:"OPEN"},where: "${columnName.key} = ?",whereArgs: ['STATE']);
}
await database.update(tableName.key, {columnName.value:DateFormat("YYYY-MM-DD HH:mm:ss").format(DateTime.now())},where: "${columnName.key} = ?",whereArgs: ['START_DATE']);
}
catch(e){
print(e);
return null;
}
}

}

+ 23
- 1
lib/util/utils.dart Vedi File

@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:barcode_scan/barcode_scan.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../main.dart';
class Util{
scan()async{
String BarcodeText ='';
@@ -18,6 +18,27 @@ class Util{
return {'STATUS':0,'DATA':e};
}
}

showLoadingFuture(context,future,{dismiss=false,onWillPop})async {
var dialogContext;
showDialog(
context: context,
builder: (BuildContext context) {
dialogContext = context;
return WillPopScope(
onWillPop: onWillPop??()async{return true;},
child: new Center(
child: new CircularProgressIndicator(),
),
);
},
barrierDismissible: dismiss,
);
var res = await future;
Navigator.pop(dialogContext);
return res;
}

JsonDataPostRaw(Map jsonData, String url,{timeout:false,duration:10}) async{
const JsonDecoder decoder = const JsonDecoder();
try {
@@ -43,6 +64,7 @@ class Util{
return {"STATUS":"ERROR","ERROR":"Not Connected to Server. $exception"};
}
}

showToast(type,text)async{
await Fluttertoast.cancel();
Fluttertoast.showToast(


+ 1
- 1
pubspec.lock Vedi File

@@ -178,7 +178,7 @@ packages:
source: hosted
version: "1.1.0"
intl:
dependency: transitive
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"


+ 1
- 0
pubspec.yaml Vedi File

@@ -29,6 +29,7 @@ dependencies:
photo_view:
sqflite:
matrix_gesture_detector:
intl:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3


Caricamento…
Annulla
Salva