2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Adds debug message helper

This commit is contained in:
Oliver Walters 2022-05-22 09:13:49 +10:00
parent 2e86a02343
commit 625d29fcf1
3 changed files with 22 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import "package:flutter_cache_manager/flutter_cache_manager.dart";
import "package:inventree/widget/dialogs.dart"; import "package:inventree/widget/dialogs.dart";
import "package:inventree/l10.dart"; import "package:inventree/l10.dart";
import "package:inventree/helpers.dart";
import "package:inventree/inventree/sentry.dart"; import "package:inventree/inventree/sentry.dart";
import "package:inventree/inventree/model.dart"; import "package:inventree/inventree/model.dart";
import "package:inventree/user_profile.dart"; import "package:inventree/user_profile.dart";

View File

@ -7,9 +7,23 @@
* supressing trailing zeroes * supressing trailing zeroes
*/ */
import "dart:io";
import "package:audioplayers/audioplayers.dart"; import "package:audioplayers/audioplayers.dart";
import "package:one_context/one_context.dart"; import "package:one_context/one_context.dart";
/*
* Display a debug message if we are in testing mode, or running in debug mode
*/
void debug(dynamic msg) {
if (Platform.environment.containsKey("FLUTTER_TEST")) {
print("DEBUG: ${msg.toString()}");
}
}
String simpleNumberString(double number) { String simpleNumberString(double number) {
// Ref: https://stackoverflow.com/questions/55152175/how-to-remove-trailing-zeros-using-dart // Ref: https://stackoverflow.com/questions/55152175/how-to-remove-trailing-zeros-using-dart
@ -19,7 +33,7 @@ String simpleNumberString(double number) {
/* /*
* Play an audio file from the requested path. * Play an audio file from the requested path.
* *
* Note: If OneContext module fails the 'hasConext' check, * Note: If OneContext module fails the 'hasContext' check,
* we will not attempt to play the sound * we will not attempt to play the sound
*/ */
Future<void> playAudioFile(String path) async { Future<void> playAudioFile(String path) async {

View File

@ -1,6 +1,7 @@
import "package:sembast/sembast.dart"; import "package:sembast/sembast.dart";
import "package:inventree/helpers.dart";
import "package:inventree/preferences.dart"; import "package:inventree/preferences.dart";
class UserProfile { class UserProfile {
@ -85,7 +86,7 @@ class UserProfileDBManager {
Future<bool> addProfile(UserProfile profile) async { Future<bool> addProfile(UserProfile profile) async {
if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) { if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) {
print("Profile missing required values - not adding to database"); debug("addProfile() : Profile missing required values - not adding to database");
return false; return false;
} }
@ -93,7 +94,7 @@ class UserProfileDBManager {
final bool exists = await profileNameExists(profile.name); final bool exists = await profileNameExists(profile.name);
if (exists) { if (exists) {
print("UserProfile '${profile.name}' already exists"); debug("addProfile() : UserProfile '${profile.name}' already exists");
return false; return false;
} }
@ -120,7 +121,7 @@ class UserProfileDBManager {
// Prevent invalid profile data from being updated // Prevent invalid profile data from being updated
if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) { if (profile.name.isEmpty || profile.username.isEmpty || profile.password.isEmpty) {
print("Profile missing required values - not updating"); debug("updateProfile() : Profile missing required values - not updating");
return false; return false;
} }
@ -151,11 +152,11 @@ class UserProfileDBManager {
final profiles = await store.find(await _db); final profiles = await store.find(await _db);
print("getSelectedProfile() - ${profiles.length} profiles available - selected = ${selected}"); debug("getSelectedProfile() : ${profiles.length} profiles available - selected = ${selected}");
for (int idx = 0; idx < profiles.length; idx++) { for (int idx = 0; idx < profiles.length; idx++) {
print("- Checking ${idx} - key = ${profiles[idx].key} - ${profiles[idx].value.toString()}"); debug("- Checking ${idx} - key = ${profiles[idx].key} - ${profiles[idx].value.toString()}");
if (profiles[idx].key is int && profiles[idx].key == selected) { if (profiles[idx].key is int && profiles[idx].key == selected) {
return UserProfile.fromJson( return UserProfile.fromJson(