2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-26 20:46:48 +00:00

Bug fixes (#637)
Some checks failed
Android / build (push) Has been cancelled
CI / test (push) Has been cancelled
iOS / build (push) Has been cancelled

* Fix formatting

* Handle case where server does not provide permissions information

* Enhanced URL checks

* Enhanced check

* Fix for error dialog

* Bump version information
This commit is contained in:
Oliver 2025-04-18 19:12:34 +10:00 committed by GitHub
parent 762d1ae156
commit 52879c0fc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 29 deletions

View File

@ -1,3 +1,7 @@
### 0.18.1 - April 2025
---
- Fix bug associated with handling invalid URLs
### 0.18.0 - April 2025
---
- Adds ability to create new companies from the app

View File

@ -287,65 +287,67 @@ class InvenTreeAPI {
int get apiVersion => (serverInfo["apiVersion"] ?? 1) as int;
// Consolidated search request API v102 or newer
bool get supportsConsolidatedSearch =>apiVersion >= 102;
bool get supportsConsolidatedSearch => apiVersion >= 102;
// ReturnOrder supports API v104 or newer
bool get supportsReturnOrders =>apiVersion >= 104;
bool get supportsReturnOrders => apiVersion >= 104;
// "Contact" model exposed to API
bool get supportsContactModel =>apiVersion >= 104;
bool get supportsContactModel => apiVersion >= 104;
// Status label endpoints API v105 or newer
bool get supportsStatusLabelEndpoints =>apiVersion >= 105;
bool get supportsStatusLabelEndpoints => apiVersion >= 105;
// Regex search API v106 or newer
bool get supportsRegexSearch =>apiVersion >= 106;
bool get supportsRegexSearch => apiVersion >= 106;
// Order barcodes API v107 or newer
bool get supportsOrderBarcodes =>apiVersion >= 107;
bool get supportsOrderBarcodes => apiVersion >= 107;
// Project codes require v109 or newer
bool get supportsProjectCodes =>apiVersion >= 109;
bool get supportsProjectCodes => apiVersion >= 109;
// Does the server support extra fields on stock adjustment actions?
bool get supportsStockAdjustExtraFields =>apiVersion >= 133;
bool get supportsStockAdjustExtraFields => apiVersion >= 133;
// Does the server support receiving items against a PO using barcodes?
bool get supportsBarcodePOReceiveEndpoint =>apiVersion >= 139;
bool get supportsBarcodePOReceiveEndpoint => apiVersion >= 139;
// Does the server support adding line items to a PO using barcodes?
bool get supportsBarcodePOAddLineEndpoint =>apiVersion >= 153;
bool get supportsBarcodePOAddLineEndpoint => apiVersion >= 153;
// Does the server support allocating stock to sales order using barcodes?
bool get supportsBarcodeSOAllocateEndpoint =>apiVersion >= 160;
bool get supportsBarcodeSOAllocateEndpoint => apiVersion >= 160;
// Does the server support the "modern" test results API
// Ref: https://github.com/inventree/InvenTree/pull/6430/
bool get supportsModernTestResults =>apiVersion >= 169;
bool get supportsModernTestResults => apiVersion >= 169;
// Does the server support "null" top-level filtering for PartCategory and StockLocation endpoints?
bool get supportsNullTopLevelFiltering =>apiVersion < 174;
bool get supportsNullTopLevelFiltering => apiVersion < 174;
// Does the server support "active" status on Company and SupplierPart API endpoints?
bool get supportsCompanyActiveStatus =>apiVersion >= 189;
bool get supportsCompanyActiveStatus => apiVersion >= 189;
// Does the server support the "modern" (consolidated) label printing API?
bool get supportsModernLabelPrinting =>apiVersion >= 201;
bool get supportsModernLabelPrinting => apiVersion >= 201;
// Does the server support the "modern" (consolidated) attachment API?
// Ref: https://github.com/inventree/InvenTree/pull/7420
bool get supportsModernAttachments =>apiVersion >= 207;
bool get supportsModernAttachments => apiVersion >= 207;
bool get supportsUserPermissions => apiVersion >= 207;
// Does the server support the "destination" field on the PurchaseOrder model?
// Ref: https://github.com/inventree/InvenTree/pull/8403
bool get supportsPurchaseOrderDestination =>apiVersion >= 276;
bool get supportsPurchaseOrderDestination => apiVersion >= 276;
// Does the server support the "start_date" field for orders?
// Ref: https://github.com/inventree/InvenTree/pull/8966
bool get supportsStartDate =>apiVersion >= 306;
bool get supportsStartDate => apiVersion >= 306;
// Supports separate search against "supplier" / "customer" / "manufacturer"
bool get supportsSplitCompanySearch =>apiVersion >= 315;
bool get supportsSplitCompanySearch => apiVersion >= 315;
// Cached list of plugins (refreshed when we connect to the server)
List<InvenTreePlugin> _plugins = [];
@ -725,7 +727,12 @@ class InvenTreeAPI {
}
roles = (data["roles"] ?? {}) as Map<String, dynamic>;
permissions = (data["permissions"] ?? {}) as Map<String, dynamic>;
if (supportsUserPermissions && data.containsKey("permissions")) {
permissions = (data["permissions"] ?? {}) as Map<String, dynamic>;
} else {
permissions = {};
}
return true;
}
@ -1194,6 +1201,15 @@ class InvenTreeAPI {
var _url = makeApiUrl(url);
if (_url.isEmpty) {
showServerError(
url,
L10().invalidHost,
L10().invalidHostDetails
);
return null;
}
// Add any required query parameters to the URL using ?key=value notation
if (urlParams.isNotEmpty) {
String query = "?";
@ -1210,13 +1226,12 @@ class InvenTreeAPI {
Uri? _uri = Uri.tryParse(_url);
if (_uri == null) {
showServerError(url, L10().invalidHost, L10().invalidHostDetails);
return null;
}
if (_uri.host.isEmpty) {
showServerError(url, L10().invalidHost, L10().invalidHostDetails);
if (_uri == null || _uri.host.isEmpty) {
showServerError(
_url,
L10().invalidHost,
L10().invalidHostDetails
);
return null;
}

View File

@ -228,13 +228,15 @@ Future<void> showServerError(String url, String title, String description) async
playAudioFile("sounds/server_error.mp3");
}
description += "\nURL: $url";
showSnackIcon(
title,
success: false,
actionText: L10().details,
onAction: () {
showErrorDialog(
L10().serverError,
title,
description: description,
icon: TablerIcons.server
);

View File

@ -1,7 +1,7 @@
name: inventree
description: InvenTree stock management
version: 0.18.0+97
version: 0.18.1+98
environment:
sdk: ">=2.19.5 <3.13.0"