mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Slightly improved login info on main screen
This commit is contained in:
parent
d918079440
commit
18b4783c11
@ -8,12 +8,14 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'dsn.dart';
|
||||
import 'preferences.dart';
|
||||
|
||||
import 'package:sentry/sentry.dart';
|
||||
|
||||
// Use the secret app key
|
||||
final SentryClient _sentry = SentryClient(dsn: SENTRY_DSN_KEY);
|
||||
final SentryClient _sentry = SentryClient(
|
||||
SentryOptions(
|
||||
dsn: SENTRY_DSN_KEY,
|
||||
));
|
||||
|
||||
bool isInDebugMode() {
|
||||
bool inDebugMode = false;
|
||||
@ -31,13 +33,15 @@ Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
||||
print(stackTrace);
|
||||
return;
|
||||
} else {
|
||||
// Send the Exception and Stacktrace to Sentry in Production mode.
|
||||
_sentry.captureException(
|
||||
exception: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
|
||||
print("Sending error to sentry.io");
|
||||
try {
|
||||
await _sentry.captureException(
|
||||
error,
|
||||
stackTrace: stackTrace
|
||||
);
|
||||
} catch (e) {
|
||||
print("Sending error report to sentry.io failed: ${e}");
|
||||
print("Original error: ${error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,12 +51,8 @@ void main() async {
|
||||
|
||||
runZoned<Future<void>>(() async {
|
||||
runApp(InvenTreeApp());
|
||||
}, onError: (error, stackTrace) {
|
||||
// Whenever an error occurs, call the `_reportError` function. This sends
|
||||
// Dart errors to the dev console or Sentry depending on the environment.
|
||||
_reportError(error, stackTrace);
|
||||
});
|
||||
|
||||
}, onError: _reportError
|
||||
);
|
||||
}
|
||||
|
||||
class InvenTreeApp extends StatelessWidget {
|
||||
|
@ -10,12 +10,8 @@ import '../user_profile.dart';
|
||||
|
||||
class InvenTreeLoginSettingsWidget extends StatefulWidget {
|
||||
|
||||
final List<UserProfile> _profiles;
|
||||
|
||||
InvenTreeLoginSettingsWidget(this._profiles) : super();
|
||||
|
||||
@override
|
||||
_InvenTreeLoginSettingsState createState() => _InvenTreeLoginSettingsState(_profiles);
|
||||
_InvenTreeLoginSettingsState createState() => _InvenTreeLoginSettingsState();
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +23,9 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
||||
|
||||
List<UserProfile> profiles;
|
||||
|
||||
_InvenTreeLoginSettingsState(this.profiles);
|
||||
_InvenTreeLoginSettingsState() {
|
||||
_reload();
|
||||
}
|
||||
|
||||
void _reload() async {
|
||||
|
||||
|
@ -72,7 +72,7 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
|
||||
|
||||
List<UserProfile> profiles = await UserProfileDBManager().getAllProfiles();
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget(profiles)));
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget()));
|
||||
}
|
||||
|
||||
void _about() async {
|
||||
|
@ -9,6 +9,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:InvenTree/barcode.dart';
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
import 'package:InvenTree/settings/login.dart';
|
||||
|
||||
import 'package:InvenTree/widget/category_display.dart';
|
||||
import 'package:InvenTree/widget/company_list.dart';
|
||||
import 'package:InvenTree/widget/location_display.dart';
|
||||
@ -25,6 +27,8 @@ class InvenTreeHomePage extends StatefulWidget {
|
||||
class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
|
||||
_InvenTreeHomePageState() : super() {
|
||||
|
||||
_loadProfile();
|
||||
}
|
||||
|
||||
String _serverStatus = "Connecting to server";
|
||||
@ -37,6 +41,59 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
|
||||
Color _serverStatusColor = Color.fromARGB(255, 50, 50, 250);
|
||||
|
||||
// Selected user profile
|
||||
UserProfile _profile;
|
||||
|
||||
void _loadProfile() async {
|
||||
|
||||
final profile = await UserProfileDBManager().getSelectedProfile();
|
||||
|
||||
print("Loaded selected profile");
|
||||
|
||||
// If a different profile is selected, re-connect
|
||||
if (_profile == null || (_profile.key != profile.key)) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
_profile = profile;
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
ListTile _serverTile() {
|
||||
|
||||
// No profile selected
|
||||
// Tap to select / create a profile
|
||||
if (_profile == null) {
|
||||
return ListTile(
|
||||
title: Text("No Profile Selected"),
|
||||
subtitle: Text("Tap to create or select a profile"),
|
||||
leading: FaIcon(FontAwesomeIcons.user),
|
||||
onTap: () {
|
||||
_selectProfile();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Profile is selected ...
|
||||
if (InvenTreeAPI().isConnected()) {
|
||||
return ListTile(
|
||||
title: Text("Connected to ${_profile.server}"),
|
||||
);
|
||||
} else {
|
||||
return ListTile(
|
||||
title: Text("Could not connect to server"),
|
||||
subtitle: Text("Error connecting to ${_profile.server}"),
|
||||
leading: FaIcon(FontAwesomeIcons.times),
|
||||
onTap: () {
|
||||
_selectProfile();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void onConnectSuccess(String msg) async {
|
||||
|
||||
final profile = await UserProfileDBManager().getSelectedProfile();
|
||||
@ -134,6 +191,10 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CustomerListWidget()));
|
||||
}
|
||||
|
||||
void _selectProfile() {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => InvenTreeLoginSettingsWidget()));
|
||||
}
|
||||
|
||||
void _unsupported() {
|
||||
showDialog(
|
||||
context: context,
|
||||
@ -313,20 +374,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
title: Text("$_serverStatus",
|
||||
style: TextStyle(color: _serverStatusColor),
|
||||
),
|
||||
subtitle: Text("$_serverMessage",
|
||||
style: TextStyle(color: _serverStatusColor),
|
||||
),
|
||||
leading: _serverIcon,
|
||||
onTap: () {
|
||||
if (!_serverConnection) {
|
||||
_checkServerConnection(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: _serverTile(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user