Skip to content

Commit

Permalink
Merge pull request #106 from mendix/release/7.1.2
Browse files Browse the repository at this point in the history
Update module and test project to v7.1.2
  • Loading branch information
MxMurshed authored Jul 4, 2023
2 parents 1f57e90 + 0e4ccb3 commit f7e5e72
Show file tree
Hide file tree
Showing 88 changed files with 1,663 additions and 810 deletions.
Binary file modified test/PushNotfications.mpr
Binary file not shown.
22 changes: 22 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/Base64Decode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import { Base64 } from 'js-base64';

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* @param {string} base64
* @returns {Promise.<string>}
*/
export async function Base64Decode(base64) {
// BEGIN USER CODE
return Base64.decode(base64);
// END USER CODE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import { Base64 } from 'js-base64';

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* @param {string} base64
* @param {MxObject} image
* @returns {Promise.<boolean>}
*/
export async function Base64DecodeToImage(base64, image) {
// BEGIN USER CODE
if (!base64) {
throw new Error("base64 String should not be empty");
}
if (!image) {
throw new Error("image should not be null");
}
const blob = new Blob([Base64.toUint8Array(base64)], { type: "image/png" });
return new Promise((resolve, reject) => {
mx.data.saveDocument(image.getGuid(), "camera image", {}, blob, () => resolve(true), reject);
});
// END USER CODE
}
22 changes: 22 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/Base64Encode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import { Base64 } from 'js-base64';

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* @param {string} string
* @returns {Promise.<string>}
*/
export async function Base64Encode(string) {
// BEGIN USER CODE
return Base64.encode(string);
// END USER CODE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* Clears saved session data from the local storage for offline native and PWAs.
* @returns {Promise.<void>}
*/
export async function ClearCachedSessionData() {
// BEGIN USER CODE
if (mx.session && mx.session.clearCachedSessionData === undefined) {
return Promise.reject(new Error("JS action 'Clear cached session data' is not supported prior to Mendix client v9.14"));
}
await mx.session.clearCachedSessionData();
// END USER CODE
}
27 changes: 27 additions & 0 deletions test/javascriptsource/nanoflowcommons/actions/ClearLocalStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* @returns {Promise.<boolean>}
*/
export async function ClearLocalStorage() {
// BEGIN USER CODE
try {
localStorage.clear();
return true;
}
catch (e) {
console.error(e);
return false;
}
// END USER CODE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
* @param {MxObject[]} list
* @param {string} objectGUID
* @returns {Promise.<MxObject>}
*/
export async function FindObjectWithGUID(list, objectGUID) {
// BEGIN USER CODE
return list.find(element => element.getGuid() === objectGUID);
// END USER CODE
}
18 changes: 8 additions & 10 deletions test/javascriptsource/nanoflowcommons/actions/GenerateUniqueID.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@ function sleep(time) {
async function initializeCounter() {
currentCounter = JSON.parse((await getItem(COUNTER_STORE)) || "-1");
}
function getItem(key) {
async function getItem(key) {
if (navigator && navigator.product === "ReactNative") {
const AsyncStorage = require("@react-native-community/async-storage").default;
const AsyncStorage = (await import('@react-native-community/async-storage')).default;
return AsyncStorage.getItem(key);
}
if (window) {
const value = window.localStorage.getItem(key);
return Promise.resolve(value);
return window.localStorage.getItem(key);
}
return Promise.reject(new Error("No storage API available"));
throw new Error("No storage API available");
}
function setItem(key, value) {
async function setItem(key, value) {
if (navigator && navigator.product === "ReactNative") {
const AsyncStorage = require("@react-native-community/async-storage").default;
const AsyncStorage = (await import('@react-native-community/async-storage')).default;
return AsyncStorage.setItem(key, value);
}
if (window) {
window.localStorage.setItem(key, value);
return Promise.resolve();
return window.localStorage.setItem(key, value);
}
return Promise.reject(new Error("No storage API available"));
throw new Error("No storage API available");
}
// END EXTRA CODE

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"nativeDependencies": {
"@react-native-community/async-storage": "1.12.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import { Big } from "big.js";
import Geolocation from "@react-native-community/geolocation";
import Geolocation from '@react-native-community/geolocation';

// BEGIN EXTRA CODE
// END EXTRA CODE
Expand All @@ -27,29 +27,59 @@ import Geolocation from "@react-native-community/geolocation";
*/
export async function GetCurrentLocation(timeout, maximumAge, highAccuracy) {
// BEGIN USER CODE
if (navigator && navigator.product === "ReactNative" && !navigator.geolocation) {
navigator.geolocation = Geolocation;
let reactNativeModule;
let geolocationModule;
if (navigator && navigator.product === "ReactNative") {
reactNativeModule = require("react-native");
if (!reactNativeModule) {
return Promise.reject(new Error("React Native module could not be found"));
}
if (reactNativeModule.NativeModules.RNFusedLocation) {
geolocationModule = (await import('react-native-geolocation-service')).default;
}
else if (reactNativeModule.NativeModules.RNCGeolocation) {
geolocationModule = Geolocation;
}
else {
return Promise.reject(new Error("Geolocation module could not be found"));
}
}
else if (navigator && navigator.geolocation) {
geolocationModule = navigator.geolocation;
}
else {
return Promise.reject(new Error("Geolocation module could not be found"));
}
return new Promise((resolve, reject) => {
const options = getOptions();
navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
geolocationModule === null || geolocationModule === void 0 ? void 0 : geolocationModule.getCurrentPosition(onSuccess, onError, options);
function onSuccess(position) {
mx.data.create({
entity: "NanoflowCommons.Geolocation",
callback: mxObject => {
const geolocation = mapPositionToMxObject(mxObject, position);
resolve(geolocation);
},
error: () =>
reject(new Error("Could not create 'NanoflowCommons.Geolocation' object to store location"))
error: () => reject(new Error("Could not create 'NanoflowCommons.Geolocation' object to store location"))
});
}
function onError(error) {
return reject(new Error(error.message));
}
function getOptions() {
const timeoutNumber = timeout && Number(timeout.toString());
let timeoutNumber = timeout && Number(timeout.toString());
const maximumAgeNumber = maximumAge && Number(maximumAge.toString());
// If the timeout is 0 or undefined (empty), it causes a crash on iOS.
// If the timeout is undefined (empty); we set timeout to 30 sec (default timeout)
// If the timeout is 0; we set timeout to 1 hour (no timeout)
if ((reactNativeModule === null || reactNativeModule === void 0 ? void 0 : reactNativeModule.Platform.OS) === "ios") {
if (timeoutNumber === undefined) {
timeoutNumber = 30000;
}
else if (timeoutNumber === 0) {
timeoutNumber = 3600000;
}
}
return {
timeout: timeoutNumber,
maximumAge: maximumAgeNumber,
Expand All @@ -70,8 +100,8 @@ export async function GetCurrentLocation(timeout, maximumAge, highAccuracy) {
if (position.coords.heading != null && position.coords.heading !== -1) {
mxObject.set("Heading", new Big(position.coords.heading.toFixed(8)));
}
if (position.coords.speed != null) {
mxObject.set("AltitudeAccuracy", new Big(position.coords.speed.toFixed(8)));
if (position.coords.speed != null && position.coords.speed !== -1) {
mxObject.set("Speed", new Big(position.coords.speed.toFixed(8)));
}
return mxObject;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"nativeDependencies": {
"@react-native-community/geolocation": "2.0.2"
"@react-native-community/geolocation": "2.0.2",
"react-native-geolocation-service": "5.2.0"
}
}
Loading

0 comments on commit f7e5e72

Please sign in to comment.