Skip to content

Commit

Permalink
Merge branch 'develop' into 5870-fix-report-error-handling-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fergie-nz committed Dec 20, 2024
2 parents 3a42a10 + e2a41b4 commit e2163d4
Show file tree
Hide file tree
Showing 24 changed files with 358 additions and 230 deletions.
32 changes: 27 additions & 5 deletions client/packages/android/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ This requires a couple of steps.

Currently, we support only 1 Android architecture (64bit);

| rust target | android ABI |
| aarch64-linux-android | arm64-v8a |
| rust target | android ABI |
| aarch64-linux-android | arm64-v8a |
| ----------------------- | ----------- |


To add the required build targets to Rust run:

```bash
Expand All @@ -41,7 +40,30 @@ echo "export NDK_BIN=~/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/pre
Open a new terminal and validate that `$NDK_BIN` is set correctly: `ls $NDK_BIN` (this should give a list of files starting with aarch64 and armv7a)
Note, which linker Rust should use is defined in `server/android/.cargo/config.toml`, under [target.*].

You can now use `yarn build:server` from this directory, this builds the `libremote_server_lib.so` binaries and relocate them to `app/src/main/jniLibs`.
### Java Installation

In your terminal, run `java --version` to check if you have it installed. As at 19/12/2024 version `17.0.7-tem` is tested and works with our setup

- install [SDK man](https://sdkman.io/) through your terminal by running `curl -s "https://get.sdkman.io" | bash`
- Open a new terminal

Install Java: Run `sdk install java 17.0.7-tem`

Then set the defaults using the following commands:

- `sdk use java 17.0.7-tem`
- `sdk default java 17.0.7-tem`

Go to Android Studio settings -> Build -> Build Settings

- Change Gradle JDK to 17.0.7-tem
![omSupply Gradle JDK](./doc/omSupply_android_gradle_jdk.png)

You may also see prompts in Android Studio to sync - keep an eye out for these and run the sync as needed

## Running Android Studio

You can now use `yarn build:server` from the `server/android/` directory, this builds the `libremote_server_lib.so` binaries and relocate them to `app/src/main/jniLibs`.
Please see `client/packages/android/app/src/main/java/org/openmsupply/client/RemoteServer.java` for more details of how these libs are loaded.
It's important to note that web app is bundled in the remote server binary, and web app needs to be built from `client` directory with `yarn build` command, so it's best to use `yarn android:build:server` from client directory as it does both (builds web app and then build android remote server).

Expand Down Expand Up @@ -76,7 +98,7 @@ yarn android:build:debug
yarn android:build:release
```

### Know script issues
### Known script issues

When building apk `properties.local` files is required (it can be empty). Also can sometime get a lock on gradle build, can run `find ~/.gradle -type f -name "*.lock" -delete` to fix it

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
InsertAssetLogInput,
FnUtils,
ClickableStepper,
UserPermission,
useAuthContext,
} from '@openmsupply-client/common';
import { StatusTab } from './StatusTab';
import { UploadTab } from './UploadTab';
Expand Down Expand Up @@ -43,10 +45,19 @@ export const UpdateStatusButtonComponent = ({
const { currentTab, onChangeTab } = useTabs(Tabs.Status);
const t = useTranslation();
const { Modal, hideDialog, showDialog } = useDialog({ onClose });
const { error, success } = useNotification();
const { error, success, info } = useNotification();
const [draft, setDraft] = useState<Partial<Draft>>(getEmptyAssetLog(''));
const { insertLog, invalidateQueries } = useAssets.log.insert();

const permission = UserPermission.AssetMutate;
const { userHasPermission } = useAuthContext();

const onUpdateStatus = () => {
if (userHasPermission(permission)) {
showDialog();
} else info(t('error.no-asset-edit-permission'))();
};

const onNext = useDebounceCallback(() => {
onChangeTab(Tabs.Upload);
}, []);
Expand Down Expand Up @@ -188,7 +199,7 @@ export const UpdateStatusButtonComponent = ({
<ButtonWithIcon
Icon={<PlusCircleIcon />}
label={t('button.update-status')}
onClick={showDialog}
onClick={onUpdateStatus}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
useConfirmationModal,
FnUtils,
AssetLogStatusInput,
UserPermission,
useAuthContext,
} from '@openmsupply-client/common';
import { AppRoute } from '@openmsupply-client/config';
import { useAssets } from '../api';
Expand All @@ -24,7 +26,7 @@ export const AddFromScannerButtonComponent = () => {
const t = useTranslation();
const { isConnected, isEnabled, isScanning, startScanning, stopScan } =
useBarcodeScannerContext();
const { error } = useNotification();
const { error, info } = useNotification();
const buttonRef = useRef<HTMLButtonElement>(null);
const navigate = useNavigate();
const { DisabledNotification, show } = useDisabledNotificationPopover({
Expand All @@ -35,11 +37,13 @@ export const AddFromScannerButtonComponent = () => {
AppRoute.Equipment
);
const { mutateAsync: fetchAsset } = useAssets.document.fetch();
const { mutateAsync: fetchOrCreateFromGS1 } = useAssets.document.gs1();
const { mutateAsync: fetchFromGS1 } = useAssets.document.gs1();
const { mutateAsync: saveNewAsset } = useAssets.document.insert();
const { insertLog, invalidateQueries } = useAssets.log.insert();
const newAssetData = useRef<DraftAsset>();

const { userHasPermission } = useAuthContext();

const showCreateConfirmation = useConfirmationModal({
onConfirm: () => {
if (newAssetData.current) {
Expand All @@ -59,8 +63,8 @@ export const AddFromScannerButtonComponent = () => {
.catch(e => error(t('error.unable-to-save-asset', { error: e }))());
}
},
message: t('heading.create-new-asset'),
title: t('messages.create-new-asset-confirmation'),
title: t('heading.create-new-asset'),
message: t('messages.create-new-asset-confirmation'),
});

const handleScanResult = async (result: ScanResult) => {
Expand All @@ -81,7 +85,7 @@ export const AddFromScannerButtonComponent = () => {
}

// send the GS1 data to backend to handle
const asset = await fetchOrCreateFromGS1(gs1).catch(() => {});
const asset = await fetchFromGS1(gs1).catch(() => {});

if (asset?.__typename !== 'AssetNode') {
error(t('error.no-matching-asset', { id: result.content }))();
Expand All @@ -93,7 +97,8 @@ export const AddFromScannerButtonComponent = () => {
}

// If not existing, offer to create from the parsed GS1 data
if (!asset?.id) {
const permission = UserPermission.AssetMutate;
if (userHasPermission(permission)) {
newAssetData.current = {
...asset,
id: FnUtils.generateUUID(),
Expand All @@ -102,16 +107,21 @@ export const AddFromScannerButtonComponent = () => {
parsedCatalogProperties: {},
};
showCreateConfirmation();
}
} else info(t('error.no-asset-create-permission'))();
}
};

const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {
const permission = UserPermission.AssetQuery;

if (!userHasPermission(permission)) {
info(t('error.no-asset-view-permission'))();
return;
}
if (!isConnected) {
show(e);
return;
}

buttonRef.current?.blur();
if (isScanning) {
stopScan();
Expand Down Expand Up @@ -151,7 +161,9 @@ export const AddFromScannerButtonComponent = () => {
<Box>
<ButtonWithIcon
ref={buttonRef}
onClick={handleClick}
onClick={e => {
handleClick(e);
}}
Icon={
isScanning ? (
<CircularProgress size={20} color="primary" />
Expand Down
26 changes: 14 additions & 12 deletions client/packages/common/src/intl/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
"error.more-info": "More information",
"error.name-program-duplicate": "Vaccine course name already exists for this program",
"error.no-asset-create-permission": "You do not have permission to create a new asset.",
"error.no-asset-edit-permission": "You do not have permission to edit assets.",
"error.no-asset-view-permission": "You do not have permission to view assets.",
"error.no-customer-return-items": "No items have been added to this return.",
"error.no-customer-returns": "There are no Customer Returns to display.",
"error.no-data": "No data available",
Expand Down Expand Up @@ -859,7 +861,7 @@
"label.not-set": "Not set",
"label.note": "Note",
"label.notes": "Notes",
"label.num-packs": "Pack Qty",
"label.num-packs": "Number of packs",
"label.number": "Number",
"label.number-months_few": "{{count}} Months",
"label.number-months_many": "{{count}} Months",
Expand Down Expand Up @@ -1403,6 +1405,7 @@
"messages.logout-confirm": "This will log you out.",
"messages.max-or-min-temperature": "Max / min temperature",
"messages.message-not-sent": "Error! Your message was not sent",
"messages.message-sent": "Your message has been sent successfully!",
"messages.must-allocate-all-lines": "Cannot change the status until all lines have been allocated.",
"messages.native-mode": "Select the mode which you would like to run. Note that you can change this option later if you have administrator access.",
"messages.native-mode-client": "This mode allows you to select which server to connect to.",
Expand Down Expand Up @@ -1484,7 +1487,6 @@
"messages.select-rows-to-delete": "Select rows to delete them",
"messages.select-rows-to-delete-them": "Select rows to delete them",
"messages.select-rows-to-return": "Select rows to return them",
"messages.message-sent": "Your message has been sent successfully!",
"messages.service-charges-description": "Total amounts of service charges. The calculated tax amount is an effective tax rate using the total tax paid over the subtotal of all service charges.",
"messages.shipment-saved": "Shipment saved 🥳",
"messages.stock-charges-description": "Total charges for stock lines. The calculated tax amount is an effective tax rate using the total tax paid over the subtotal of all stock lines.",
Expand Down Expand Up @@ -1551,11 +1553,13 @@
"reason.stored": "Stored",
"reason.unknown": "Unknown",
"replenishment": "Replenishment",
"report.AMC-lookback": "AMC Lookback Period",
"report.actual": "Actual",
"report.actual-stock": "Actual stock",
"report.amc-12-months": "AMC (12 months)",
"report.amc-24-months": "AMC (24 months)",
"report.authorized-by": "Authorized by",
"report.available-stock-on-hand": "Available stock on hand",
"report.collected-by": "Collected by",
"report.comments": "Comments",
"report.confirm-date": "Confirm date",
Expand All @@ -1566,6 +1570,8 @@
"report.counted-packs": "Counted packs",
"report.created-date": "Created date",
"report.entered-code": "Entered code",
"report.entered-date": "Entered date",
"report.error-translating": "Error generating translation for key {{key}}",
"report.expected-usage": "Expected usage",
"report.expiring": "Expiring",
"report.expiring-12-months": "Expiring in 12 months",
Expand All @@ -1575,11 +1581,11 @@
"report.extension": "Extension",
"report.global-total": "Global total",
"report.in-stock": "In stock",
"report.available-stock-on-hand": "Available stock on hand",
"report.invoice": "Invoice",
"report.invoice-type": "Invoice type",
"report.issued": "Issued",
"report.item-code": "Item code",
"report.item-code-or-name": "Item Code or Name",
"report.item-name": "Item name",
"report.line": "Line",
"report.months-cover": "Months cover",
Expand All @@ -1605,13 +1611,15 @@
"report.sell-price": "Sell price",
"report.shipped-date": "Shipped date",
"report.snapshot-packs": "Snapshot packs",
"report.sort-by": "Sort by",
"report.sort-direction": "Sort direction",
"report.stat": "Stat",
"report.status": "Status",
"report.stock-take-sheet": "Stock take sheet",
"report.stock-take-number": "Stock take number",
"report.stock-at-risk": "Stock at risk",
"report.stock-on-hand": "Stock on hand",
"report.stock-on-order": "Stock on order",
"report.stock-take-number": "Stock take number",
"report.stock-take-sheet": "Stock take sheet",
"report.stock-take-variance-report": "Stock Take Variance Report",
"report.stocktake-number": "Stocktake number",
"report.stocktake-sheet": "Stocktake sheet",
Expand All @@ -1626,12 +1634,6 @@
"report.variance-packs": "Variance (packs)",
"report.variance-value": "Variance (value)",
"report.well-stocked": "Well stocked",
"report.item-code-or-name": "Item Code or Name",
"report.AMC-lookback": "AMC Lookback Period",
"report.error-translating": "Error generating translation for key {{key}}",
"report.sort-by": "Sort by",
"report.sort-direction": "Sort direction",
"report.entered-date": "Entered date",
"reports": "Reports",
"returns": "Returns",
"saving": "Saving…",
Expand Down Expand Up @@ -1714,4 +1716,4 @@
"warning.caps-lock": "Warning: Caps lock is on",
"warning.field-not-parsed": "{{field}} not parsed",
"warning.nothing-to-supply": "Nothing left to supply!"
}
}
Loading

0 comments on commit e2163d4

Please sign in to comment.