Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
467fdec73a | ||
|
|
fde17e18d1 |
88 changed files with 15401 additions and 20380 deletions
|
|
@ -1,21 +0,0 @@
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
insert_final_newline = true
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
[*.{yml,yaml}]
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[*.{vue,js}]
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
[docker-compose.yml]
|
|
||||||
indent_size = 4
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
.vscode/*
|
|
||||||
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
9
.idea/com-app.iml
generated
9
.idea/com-app.iml
generated
|
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/com-app.iml" filepath="$PROJECT_DIR$/.idea/com-app.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
23
.vscode/settings.json
vendored
23
.vscode/settings.json
vendored
|
|
@ -1,23 +0,0 @@
|
||||||
{
|
|
||||||
"workbench.colorCustomizations": {
|
|
||||||
"activityBar.activeBackground": "#3e8040",
|
|
||||||
"activityBar.activeBorder": "#ffffff",
|
|
||||||
"activityBar.background": "#3e8040",
|
|
||||||
"activityBar.foreground": "#e7e7e7",
|
|
||||||
"activityBar.inactiveForeground": "#e7e7e799",
|
|
||||||
"activityBarBadge.background": "#aaa9d5",
|
|
||||||
"activityBarBadge.foreground": "#15202b",
|
|
||||||
"sash.hoverBorder": "#3e8040",
|
|
||||||
"statusBar.background": "#2d5e2f",
|
|
||||||
"statusBar.foreground": "#e7e7e7",
|
|
||||||
"statusBarItem.hoverBackground": "#3e8040",
|
|
||||||
"statusBarItem.remoteBackground": "#2d5e2f",
|
|
||||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
|
||||||
"titleBar.activeBackground": "#8d1800",
|
|
||||||
"titleBar.activeForeground": "#e7e7e7",
|
|
||||||
"titleBar.inactiveBackground": "#2d5e2f99",
|
|
||||||
"titleBar.inactiveForeground": "#e7e7e799",
|
|
||||||
"commandCenter.border": "#e7e7e799"
|
|
||||||
},
|
|
||||||
"peacock.remoteColor": "#2d5e2f"
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
arrowParens: 'avoid',
|
arrowParens: 'avoid',
|
||||||
bracketSameLine: true,
|
bracketSameLine: true,
|
||||||
bracketSpacing: true,
|
bracketSpacing: false,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: 'all',
|
trailingComma: 'all',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,7 @@
|
||||||
# CHANGELOG
|
# 2.0.0
|
||||||
|
## Bug
|
||||||
## 4.0.0
|
|
||||||
|
|
||||||
### Évolution - 4.0.0
|
|
||||||
|
|
||||||
- Delete store.ldc.fr dependance
|
|
||||||
- Remove useless MySpace feature
|
|
||||||
|
|
||||||
## 3.2.1
|
|
||||||
|
|
||||||
### Évolution - 3.2.1
|
|
||||||
|
|
||||||
- Update select and select multiple fields to get list in alphabetical order
|
|
||||||
|
|
||||||
## 3.1.1
|
|
||||||
|
|
||||||
### Évolution - 3.1.1
|
|
||||||
|
|
||||||
- Update Install and Download docs call to handle tenant changes
|
|
||||||
|
|
||||||
## 3.0.1
|
|
||||||
|
|
||||||
### Bug - 3.0.1
|
|
||||||
|
|
||||||
- Fix sendBrochure call, put data into data axios object instead of params
|
|
||||||
|
|
||||||
## 3.0.0
|
|
||||||
|
|
||||||
### Bug - 3.0.0
|
|
||||||
|
|
||||||
- Fix add contact from HomeScreen Error
|
|
||||||
- Fixed appID was not properly setup `com.comapp.ldc`
|
|
||||||
- Lint du Code, Ajout de définitions
|
|
||||||
- L'ordre d'affichage des contacts est respecté
|
|
||||||
- Tri des contact lors de l'envoi d'un contact
|
|
||||||
|
|
||||||
### Évolution - 3.0.0
|
|
||||||
|
|
||||||
- Ajout d'une synchronisation users discrete on Login (pour sync les news users apres que l'app ai déjà été installé)
|
|
||||||
- Changed les Formulaires sont dynamiques
|
|
||||||
- La synchro utilise 3 méthodes pour les contacts
|
|
||||||
- Ajout de timestamp sur contact pour définir le contact le plus a jour a conserver (pour un utilisateur)
|
|
||||||
|
|
||||||
## 2.0.0
|
|
||||||
|
|
||||||
### Bug - 2.0.0
|
|
||||||
|
|
||||||
- Fix format vidéo lors de la rotation de l'écran
|
- Fix format vidéo lors de la rotation de l'écran
|
||||||
|
## Évolution
|
||||||
### Évolution - 2.0.0
|
|
||||||
|
|
||||||
- Bump React Native 0.70.1 -> 0.70.6
|
- Bump React Native 0.70.1 -> 0.70.6
|
||||||
- Amélioration de l'usage de Redux avec reducers, actions, etc.
|
- Amélioration de l'usage de Redux avec reducers, actions, etc.
|
||||||
- Amélioration sur l'arborescence du projet.
|
- Amélioration sur l'arborescence du projet.
|
||||||
|
|
@ -59,4 +11,4 @@
|
||||||
- Mise en place de vérification par regex des champs obligatoires sur le formulaire de contact.
|
- Mise en place de vérification par regex des champs obligatoires sur le formulaire de contact.
|
||||||
- Ajout d'un bouton dans le header de la home pour aller directement sur la page d'ajout de contact.
|
- Ajout d'un bouton dans le header de la home pour aller directement sur la page d'ajout de contact.
|
||||||
- Ajout de la possibilité de revenir à l'écran d'accueil en cliquant sur le logo présent dans le header.
|
- Ajout de la possibilité de revenir à l'écran d'accueil en cliquant sur le logo présent dans le header.
|
||||||
- Ajout d'un espace plus important entre les éléments cliquables du header + ajout d'un menu en overlay.
|
- Ajout d'un espace plus important entre les éléments cliquables du header + ajout d'un menu en overlay.
|
||||||
|
|
@ -1,18 +1,4 @@
|
||||||
# ComApp
|
# ComApp
|
||||||
|
|
||||||
# Run with Windows + WSL
|
|
||||||
|
|
||||||
- Install Android studio and create a Virtual Device
|
|
||||||
- Launch emulator
|
|
||||||
- In WSL :
|
|
||||||
```bash
|
|
||||||
adb reverse tcp:8081 tcp:8081
|
|
||||||
npx react-native start // TO start metro
|
|
||||||
npx react-native run-android --deviceId emulator-5554 // TO build and run to this Emulator
|
|
||||||
```
|
|
||||||
|
|
||||||
You can set internet proxy in emulator params
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- i18n-js
|
- i18n-js
|
||||||
- @react-native-community/netinfo
|
- @react-native-community/netinfo
|
||||||
|
|
@ -39,8 +25,4 @@ You can set internet proxy in emulator params
|
||||||
- react-native-blob-util
|
- react-native-blob-util
|
||||||
- react-native-flash-message
|
- react-native-flash-message
|
||||||
- @react-native-picker/picker
|
- @react-native-picker/picker
|
||||||
- vcard-parser
|
- vcard-parser
|
||||||
- react-native-email-link
|
|
||||||
- buffer
|
|
||||||
- react-native-sectioned-multi-select
|
|
||||||
- react-native-uuid
|
|
||||||
|
|
@ -35,12 +35,12 @@ android_library(
|
||||||
|
|
||||||
android_build_config(
|
android_build_config(
|
||||||
name = "build_config",
|
name = "build_config",
|
||||||
package = "com.comapp.ldc",
|
package = "com.comapp",
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.comapp.ldc",
|
package = "com.comapp",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ android {
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "4.0.0"
|
versionName "2.0.0"
|
||||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||||
|
|
||||||
if (isNewArchitectureEnabled()) {
|
if (isNewArchitectureEnabled()) {
|
||||||
|
|
@ -329,4 +329,4 @@ def isNewArchitectureEnabled() {
|
||||||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
|
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||||
* directory of this source tree.
|
* directory of this source tree.
|
||||||
*/
|
*/
|
||||||
package com.comapp.ldc;
|
package com.comapp;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.comapp.ldc">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.comapp">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.CAMERA"/>
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
<application
|
<application
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.ldc;
|
package com.comapp;
|
||||||
|
|
||||||
import expo.modules.ReactActivityDelegateWrapper;
|
import expo.modules.ReactActivityDelegateWrapper;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.ldc;
|
package com.comapp;
|
||||||
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import expo.modules.ApplicationLifecycleDispatcher;
|
import expo.modules.ApplicationLifecycleDispatcher;
|
||||||
|
|
@ -13,7 +13,7 @@ import com.facebook.react.ReactNativeHost;
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
import com.facebook.react.config.ReactFeatureFlags;
|
import com.facebook.react.config.ReactFeatureFlags;
|
||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
import com.comapp.ldc.newarchitecture.MainApplicationReactNativeHost;
|
import com.comapp.newarchitecture.MainApplicationReactNativeHost;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||||
We use reflection here to pick up the class that initializes Flipper,
|
We use reflection here to pick up the class that initializes Flipper,
|
||||||
since Flipper library is not available in release mode
|
since Flipper library is not available in release mode
|
||||||
*/
|
*/
|
||||||
Class<?> aClass = Class.forName("com.comapp.ldc.ReactNativeFlipper");
|
Class<?> aClass = Class.forName("com.comapp.ReactNativeFlipper");
|
||||||
aClass
|
aClass
|
||||||
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
||||||
.invoke(null, context, reactInstanceManager);
|
.invoke(null, context, reactInstanceManager);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.ldc.newarchitecture;
|
package com.comapp.newarchitecture;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -19,9 +19,9 @@ import com.facebook.react.fabric.CoreComponentsRegistry;
|
||||||
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
||||||
import com.facebook.react.fabric.ReactNativeConfig;
|
import com.facebook.react.fabric.ReactNativeConfig;
|
||||||
import com.facebook.react.uimanager.ViewManagerRegistry;
|
import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||||
import com.comapp.ldc.BuildConfig;
|
import com.comapp.BuildConfig;
|
||||||
import com.comapp.ldc.newarchitecture.components.MainComponentsRegistry;
|
import com.comapp.newarchitecture.components.MainComponentsRegistry;
|
||||||
import com.comapp.ldc.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
import com.comapp.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.ldc.newarchitecture.components;
|
package com.comapp.newarchitecture.components;
|
||||||
|
|
||||||
import com.facebook.jni.HybridData;
|
import com.facebook.jni.HybridData;
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.ldc.newarchitecture.modules;
|
package com.comapp.newarchitecture.modules;
|
||||||
|
|
||||||
import com.facebook.jni.HybridData;
|
import com.facebook.jni.HybridData;
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,5 @@ newArchEnabled=false
|
||||||
|
|
||||||
MYAPP_UPLOAD_STORE_FILE=upload.keystore
|
MYAPP_UPLOAD_STORE_FILE=upload.keystore
|
||||||
MYAPP_UPLOAD_KEY_ALIAS=app-native-1
|
MYAPP_UPLOAD_KEY_ALIAS=app-native-1
|
||||||
MYAPP_UPLOAD_STORE_PASSWORD=
|
MYAPP_UPLOAD_STORE_PASSWORD=9LjCAts7qtetVqMT
|
||||||
MYAPP_UPLOAD_KEY_PASSWORD=
|
MYAPP_UPLOAD_KEY_PASSWORD=9LjCAts7qtetVqMT
|
||||||
|
|
|
||||||
1483
ComApp/package-lock.json
generated
1483
ComApp/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,17 +11,16 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-community/netinfo": "^9.3.7",
|
"@react-native-community/netinfo": "^9.3.7",
|
||||||
"@react-native-community/slider": "4.2.4",
|
"@react-native-community/slider": "^4.3.2",
|
||||||
"@react-native-picker/picker": "^2.4.6",
|
"@react-native-picker/picker": "^2.4.6",
|
||||||
"@react-navigation/native": "^6.0.13",
|
"@react-navigation/native": "^6.0.13",
|
||||||
"@react-navigation/native-stack": "^6.9.0",
|
"@react-navigation/native-stack": "^6.9.0",
|
||||||
"@rneui/base": "^4.0.0-rc.7",
|
"@rneui/base": "^0.0.0-edge.2",
|
||||||
"@rneui/themed": "^4.0.0-rc.7",
|
"@rneui/themed": "^0.0.0-edge.2",
|
||||||
"@sentry/react-native": "^4.12.0",
|
"@sentry/react-native": "^4.12.0",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"buffer": "^6.0.3",
|
|
||||||
"expo": "^47.0.10",
|
"expo": "^47.0.10",
|
||||||
"expo-av": "~13.0.3",
|
"expo-av": "^13.0.2",
|
||||||
"expo-barcode-scanner": "^11.4.0",
|
"expo-barcode-scanner": "^11.4.0",
|
||||||
"expo-splash-screen": "^0.16.2",
|
"expo-splash-screen": "^0.16.2",
|
||||||
"expo-video-player": "^2.2.0",
|
"expo-video-player": "^2.2.0",
|
||||||
|
|
@ -34,16 +33,13 @@
|
||||||
"react-native-animated-tree-view": "^0.1.4",
|
"react-native-animated-tree-view": "^0.1.4",
|
||||||
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.1.0.tgz",
|
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.1.0.tgz",
|
||||||
"react-native-blob-util": "^0.16.2",
|
"react-native-blob-util": "^0.16.2",
|
||||||
"react-native-email-link": "^1.14.6",
|
|
||||||
"react-native-flash-message": "^0.3.1",
|
"react-native-flash-message": "^0.3.1",
|
||||||
"react-native-gesture-handler": "^2.7.0",
|
"react-native-gesture-handler": "^2.7.0",
|
||||||
"react-native-pdf": "^6.6.2",
|
"react-native-pdf": "^6.6.2",
|
||||||
"react-native-progress": "^5.0.0",
|
"react-native-progress": "^5.0.0",
|
||||||
"react-native-safe-area-context": "^4.4.1",
|
"react-native-safe-area-context": "^4.4.1",
|
||||||
"react-native-screens": "^3.18.0",
|
"react-native-screens": "^3.18.0",
|
||||||
"react-native-sectioned-multi-select": "^0.10.0",
|
|
||||||
"react-native-svg": "^13.2.0",
|
"react-native-svg": "^13.2.0",
|
||||||
"react-native-uuid": "^2.0.1",
|
|
||||||
"react-native-vector-icons": "^9.2.0",
|
"react-native-vector-icons": "^9.2.0",
|
||||||
"react-redux": "^8.0.4",
|
"react-redux": "^8.0.4",
|
||||||
"realm": "^11.0.0-rc.2",
|
"realm": "^11.0.0-rc.2",
|
||||||
|
|
@ -58,11 +54,9 @@
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"metro-react-native-babel-preset": "^0.72.3",
|
"metro-react-native-babel-preset": "^0.72.3",
|
||||||
"patch-package": "^8.0.0",
|
|
||||||
"react-test-renderer": "18.1.0"
|
"react-test-renderer": "18.1.0"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "react-native"
|
"preset": "react-native"
|
||||||
},
|
}
|
||||||
"postinstall": "patch-package"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/node_modules/react-native/ReactAndroid/build.gradle b/node_modules/react-native/ReactAndroid/build.gradle
|
|
||||||
index 3be8b26..3f7bba8 100644
|
|
||||||
--- a/node_modules/react-native/ReactAndroid/build.gradle
|
|
||||||
+++ b/node_modules/react-native/ReactAndroid/build.gradle
|
|
||||||
@@ -61,7 +61,7 @@ task createNativeDepsDirectories {
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
||||||
- src("https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
|
|
||||||
+ src("https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
|
|
||||||
onlyIfNewer(true)
|
|
||||||
overwrite(false)
|
|
||||||
dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
|
|
||||||
|
|
@ -1,58 +1,49 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from '@sentry/react-native';
|
import * as Sentry from "@sentry/react-native";
|
||||||
// Redux
|
// Redux
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { initDocuments } from './App/Store/Actions/documents';
|
|
||||||
import { store } from './App/Store/ConfigureStore';
|
import { store } from './App/Store/ConfigureStore';
|
||||||
|
import { initDocuments } from './App/Store/Actions/documents';
|
||||||
// Deps
|
// Deps
|
||||||
|
import 'react-native-gesture-handler';
|
||||||
import { NavigationContainer } from '@react-navigation/native';
|
import { NavigationContainer } from '@react-navigation/native';
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import { navigationRef, navigate } from './Navigation';
|
||||||
import {
|
import { TouchableOpacity, View, Image, Text, TextInput, Alert, DrawerLayoutAndroid, Button } from 'react-native';
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
DrawerLayoutAndroid,
|
|
||||||
Image,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
TouchableOpacity,
|
|
||||||
View,
|
|
||||||
} from 'react-native';
|
|
||||||
import FlashMessage, { showMessage } from 'react-native-flash-message';
|
|
||||||
import 'react-native-gesture-handler';
|
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
import { navigate, navigationRef } from './Navigation';
|
import FlashMessage, { showMessage } from 'react-native-flash-message';
|
||||||
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Application infos
|
// Application infos
|
||||||
import * as Application from 'expo-application';
|
import * as Application from 'expo-application';
|
||||||
// i18n
|
// i18n
|
||||||
import i18n from './I18n';
|
import i18n from "./I18n";
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
// Views
|
// Views
|
||||||
import ContactDetailsScreen from './App/Views/ContactDetailsScreen';
|
|
||||||
import ContactScreen from './App/Views/ContactScreen';
|
|
||||||
import DirectoriesScreen from './App/Views/DirectoriesScreen';
|
|
||||||
import HomeScreen from './App/Views/HomeScreen';
|
|
||||||
import InstallScreen from './App/Views/InstallScreen';
|
import InstallScreen from './App/Views/InstallScreen';
|
||||||
import LoginScreen from './App/Views/LoginScreen';
|
import LoginScreen from './App/Views/LoginScreen';
|
||||||
import OnlyVideosScreen from './App/Views/OnlyVideosScreen';
|
|
||||||
import PDFScreen from './App/Views/PDFScreen';
|
|
||||||
import SearchScreen from './App/Views/SearchScreen';
|
|
||||||
import SyncScreen from './App/Views/SyncScreen';
|
import SyncScreen from './App/Views/SyncScreen';
|
||||||
|
import HomeScreen from './App/Views/HomeScreen';
|
||||||
|
import DirectoriesScreen from './App/Views/DirectoriesScreen';
|
||||||
|
import PDFScreen from './App/Views/PDFScreen';
|
||||||
import VideoScreen from './App/Views/VideoScreen';
|
import VideoScreen from './App/Views/VideoScreen';
|
||||||
|
import OnlyVideosScreen from './App/Views/OnlyVideosScreen';
|
||||||
|
import ContactScreen from './App/Views/ContactScreen';
|
||||||
|
import ContactDetailsScreen from './App/Views/ContactDetailsScreen';
|
||||||
|
import SearchScreen from "./App/Views/SearchScreen";
|
||||||
|
import MySpaceScreen from './App/Views/MySpaceScreen';
|
||||||
// Style
|
// Style
|
||||||
import Helpers from './App/Lib/Helpers';
|
|
||||||
import styles from './Resources/Styles/NavigationStyle';
|
import styles from './Resources/Styles/NavigationStyle';
|
||||||
// Controllers
|
// Controllers
|
||||||
import SyncController from './App/Controllers/SyncController';
|
import SyncController from './App/Controllers/SyncController';
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: 'https://ab87e8d840324f41873c95b06903b0bf@o4504314935640064.ingest.sentry.io/4504441255886848',
|
dsn: "https://ab87e8d840324f41873c95b06903b0bf@o4504314935640064.ingest.sentry.io/4504441255886848",
|
||||||
});
|
});
|
||||||
|
|
||||||
Sentry.setContext('app', {
|
Sentry.setContext("app", {
|
||||||
boUrl: SyncController.getUrlBo(),
|
boUrl: SyncController.getUrlBo()
|
||||||
});
|
});
|
||||||
|
|
||||||
SplashScreen.preventAutoHideAsync(); //Keep
|
SplashScreen.preventAutoHideAsync(); //Keep
|
||||||
|
|
@ -70,7 +61,7 @@ class App extends React.Component {
|
||||||
searchTxt: '',
|
searchTxt: '',
|
||||||
sendEmail: '',
|
sendEmail: '',
|
||||||
mainColor: '',
|
mainColor: '',
|
||||||
drawerRef: React.createRef(),
|
drawerRef: React.createRef()
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
@ -78,7 +69,7 @@ class App extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
isSetup: store.getState().app.isSetup,
|
isSetup: store.getState().app.isSetup,
|
||||||
isLogged: store.getState().app.logged,
|
isLogged: store.getState().app.logged,
|
||||||
mainColor: store.getState().app.mainColor,
|
mainColor: store.getState().app.mainColor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,8 +77,9 @@ class App extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
isSetup: store.getState().app.isSetup,
|
isSetup: store.getState().app.isSetup,
|
||||||
isLogged: store.getState().app.logged,
|
isLogged: store.getState().app.logged,
|
||||||
mainColor: store.getState().app.mainColor,
|
mainColor: store.getState().app.mainColor
|
||||||
}); // to force re-rendering
|
}); // to force re-rendering
|
||||||
|
console.log("state changed")
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationView = () => (
|
navigationView = () => (
|
||||||
|
|
@ -97,23 +89,16 @@ class App extends React.Component {
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.state.drawerRef.current.closeDrawer();
|
this.state.drawerRef.current.closeDrawer();
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
store.dispatch(
|
store.dispatch(initDocuments(store.getState().locale.locale, store.getState().directories.global))
|
||||||
initDocuments(
|
|
||||||
store.getState().locale.locale,
|
|
||||||
store.getState().directories.global,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
style={styles.drawer.btn}>
|
style={styles.drawer.btn}>
|
||||||
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
||||||
<Text style={styles.drawer.btnText}>
|
<Text style={styles.drawer.btnText}>{i18n.t('global.change_lang')}</Text>
|
||||||
{i18n.t('global.change_lang')}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.state.drawerRef.current.closeDrawer();
|
this.state.drawerRef.current.closeDrawer();
|
||||||
navigate('SyncScreen');
|
navigate('SyncScreen')
|
||||||
}}
|
}}
|
||||||
style={styles.drawer.btn}>
|
style={styles.drawer.btn}>
|
||||||
<Icon name="sync-alt" size={20} />
|
<Icon name="sync-alt" size={20} />
|
||||||
|
|
@ -130,9 +115,7 @@ class App extends React.Component {
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
<View>
|
<View>
|
||||||
<Text style={{ marginBottom: 10 }}>
|
<Text style={{ marginBottom: 10 }}>Version : {Application.nativeApplicationVersion}</Text>
|
||||||
Version : {Application.nativeApplicationVersion}
|
|
||||||
</Text>
|
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.close')}
|
title={i18n.t('global.close')}
|
||||||
color={this.state.mainColor}
|
color={this.state.mainColor}
|
||||||
|
|
@ -149,226 +132,202 @@ class App extends React.Component {
|
||||||
<DrawerLayoutAndroid
|
<DrawerLayoutAndroid
|
||||||
ref={this.state.drawerRef}
|
ref={this.state.drawerRef}
|
||||||
drawerWidth={300}
|
drawerWidth={300}
|
||||||
drawerPosition={'right'}
|
drawerPosition={"right"}
|
||||||
drawerLockMode={'locked-open'}
|
drawerLockMode={'locked-open'}
|
||||||
renderNavigationView={this.navigationView}>
|
renderNavigationView={this.navigationView}
|
||||||
<Stack.Navigator initialRouteName="HomeScreen">
|
>
|
||||||
{this.state.isSetup === false && (
|
<Stack.Navigator initialRouteName="HomeScreen">
|
||||||
<Stack.Screen
|
{this.state.isSetup === false &&
|
||||||
name="InstallScreen"
|
|
||||||
component={InstallScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () =>
|
|
||||||
this.LogoTitle(
|
|
||||||
navigation,
|
|
||||||
i18n.t('install.installation'),
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
headerRight: () => (
|
|
||||||
<View
|
|
||||||
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => {
|
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
|
||||||
}}
|
|
||||||
style={{ marginRight: 15 }}>
|
|
||||||
<Image
|
|
||||||
source={this.renderFlag()}
|
|
||||||
style={{ width: 25, height: 25 }}
|
|
||||||
/>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
),
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{this.state.isLogged === false ? (
|
|
||||||
<Stack.Screen
|
|
||||||
name="LoginScreen"
|
|
||||||
component={LoginScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () =>
|
|
||||||
this.LogoTitle(navigation, i18n.t('global.login'), false),
|
|
||||||
headerRight: () => (
|
|
||||||
<View
|
|
||||||
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => {
|
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
|
||||||
}}
|
|
||||||
style={{ marginRight: 15 }}>
|
|
||||||
<Image
|
|
||||||
source={this.renderFlag()}
|
|
||||||
style={{ width: 25, height: 25 }}
|
|
||||||
/>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
),
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Stack.Screen
|
|
||||||
name="HomeScreen"
|
|
||||||
component={HomeScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () =>
|
|
||||||
this.LogoTitle(navigation, i18n.t('global.home')),
|
|
||||||
headerRight: () => (
|
|
||||||
<View
|
|
||||||
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
||||||
<View style={{ flexDirection: 'row', marginRight: 50 }}>
|
|
||||||
<TextInput
|
|
||||||
style={{
|
|
||||||
...styles.searchInput,
|
|
||||||
borderColor: this.state.mainColor,
|
|
||||||
}}
|
|
||||||
placeholder={i18n.t('global.search')}
|
|
||||||
value={this.state.searchTxt}
|
|
||||||
onChangeText={text =>
|
|
||||||
this.setState({ searchTxt: text })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<TouchableOpacity
|
|
||||||
style={{
|
|
||||||
...styles.btnSearch,
|
|
||||||
backgroundColor: this.state.mainColor,
|
|
||||||
}}
|
|
||||||
onPress={() => {
|
|
||||||
if (this.state.searchTxt.length > 0) {
|
|
||||||
navigation.navigation.navigate('SearchScreen', {
|
|
||||||
needle: this.state.searchTxt,
|
|
||||||
onlyVideos: false,
|
|
||||||
});
|
|
||||||
this.setState({ searchTxt: '' });
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<Icon name={'search'} size={20} color={'white'} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() =>
|
|
||||||
navigation.navigation.navigate('ContactScreen', {
|
|
||||||
action: 'add',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
style={{ marginRight: 25 }}>
|
|
||||||
<Icon name="user-plus" size={20} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => {
|
|
||||||
this.state.drawerRef.current.openDrawer();
|
|
||||||
}}
|
|
||||||
style={{ marginRight: 25 }}>
|
|
||||||
<Icon name="sliders-h" size={20} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
),
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="SyncScreen"
|
name="InstallScreen"
|
||||||
component={SyncScreen}
|
component={InstallScreen}
|
||||||
initialParams={{ forceSync: false }}
|
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () =>
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('install.installation'), false),
|
||||||
this.LogoTitle(
|
|
||||||
navigation,
|
|
||||||
i18n.t('global.synchronization'),
|
|
||||||
),
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<Stack.Screen
|
|
||||||
name="DirectoriesScreen"
|
|
||||||
component={DirectoriesScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () =>
|
|
||||||
this.LogoTitle(navigation, i18n.t('app.folders')),
|
|
||||||
})}
|
|
||||||
/>
|
|
||||||
<Stack.Screen
|
|
||||||
name="OnlyVideosScreen"
|
|
||||||
component={OnlyVideosScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () =>
|
|
||||||
this.LogoTitle(navigation, i18n.t('global.videos')),
|
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<View style={{ flexDirection: 'row', marginRight: 5 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<TextInput
|
|
||||||
style={{
|
|
||||||
...styles.searchInput,
|
|
||||||
borderColor: this.state.mainColor,
|
|
||||||
}}
|
|
||||||
placeholder={i18n.t('global.search')}
|
|
||||||
value={this.state.searchTxt}
|
|
||||||
onChangeText={text =>
|
|
||||||
this.setState({ searchTxt: text })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{
|
|
||||||
...styles.btnSearch,
|
|
||||||
backgroundColor: this.state.mainColor,
|
|
||||||
}}
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (this.state.searchTxt.length > 0) {
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
navigation.navigation.navigate('SearchScreen', {
|
}}
|
||||||
needle: this.state.searchTxt,
|
style={{ marginRight: 15 }}>
|
||||||
onlyVideos: true,
|
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
||||||
});
|
|
||||||
this.setState({ searchTxt: '' });
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<Icon name={'search'} size={20} color={'white'} />
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
),
|
),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
{this.state.isLogged === false ? (
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="VideoScreen"
|
name="LoginScreen"
|
||||||
component={VideoScreen}
|
component={LoginScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () =>
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.login'), false),
|
||||||
this.LogoTitle(navigation, i18n.t('app.video')),
|
headerRight: () => (
|
||||||
headerRight: () => this.SendEmail(),
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
orientation: 'landscape',
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
|
}}
|
||||||
|
style={{ marginRight: 15 }}>
|
||||||
|
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
) : (
|
||||||
name="PDFScreen"
|
<Stack.Screen
|
||||||
component={PDFScreen}
|
name="HomeScreen"
|
||||||
|
component={HomeScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, 'PDF'),
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.home')),
|
||||||
headerRight: () => this.SendEmail(),
|
headerRight: () => (
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
|
<View style={{ flexDirection: 'row', marginRight: 50 }}>
|
||||||
|
<TextInput
|
||||||
|
style={{ ...styles.searchInput, borderColor: this.state.mainColor }}
|
||||||
|
placeholder={i18n.t('global.search')}
|
||||||
|
value={this.state.searchTxt}
|
||||||
|
onChangeText={(text) => this.setState({ searchTxt: text })}
|
||||||
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }}
|
||||||
|
onPress={() => {
|
||||||
|
if (this.state.searchTxt.length > 0) {
|
||||||
|
navigation.navigation.navigate('SearchScreen', {
|
||||||
|
needle: this.state.searchTxt,
|
||||||
|
onlyVideos: false,
|
||||||
|
});
|
||||||
|
this.setState({ searchTxt: '' });
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<Icon name={'search'} size={20} color={'white'} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
{store.getState().app.ShowIsActive === '1' && (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => navigation.navigation.navigate('MySpaceScreen')}
|
||||||
|
style={{ marginRight: 25 }}>
|
||||||
|
<Icon name="user-circle" size={25} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => navigation.navigation.navigate('ContactScreen', {
|
||||||
|
action: 'add',
|
||||||
|
})}
|
||||||
|
style={{ marginRight: 25 }}>
|
||||||
|
<Icon name="user-plus" size={20} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
this.state.drawerRef.current.openDrawer()
|
||||||
|
}}
|
||||||
|
style={{ marginRight: 25 }}>
|
||||||
|
<Icon name="sliders-h" size={20} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
)}
|
||||||
name="ContactScreen"
|
<Stack.Screen
|
||||||
component={ContactScreen}
|
name="SyncScreen"
|
||||||
options={(navigation, route) => ({
|
component={SyncScreen}
|
||||||
headerTitle: () =>
|
initialParams={{ forceSync: false }}
|
||||||
this.LogoTitle(navigation, i18n.t('global.contacts')),
|
options={(navigation, route) => ({
|
||||||
})}
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.synchronization'))
|
||||||
initialParams={{ contactAdded: false }}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="ContactDetailsScreen"
|
name="DirectoriesScreen"
|
||||||
component={ContactDetailsScreen}
|
component={DirectoriesScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () =>
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.folders'))
|
||||||
this.LogoTitle(navigation, i18n.t('app.contact_details')),
|
})}
|
||||||
})}
|
/>
|
||||||
/>
|
<Stack.Screen
|
||||||
<Stack.Screen
|
name="OnlyVideosScreen"
|
||||||
name="SearchScreen"
|
component={OnlyVideosScreen}
|
||||||
component={SearchScreen}
|
options={(navigation, route) => ({
|
||||||
options={(navigation, route) => ({
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.videos')),
|
||||||
headerTitle: () =>
|
headerRight: () => (
|
||||||
this.LogoTitle(navigation, i18n.t('app.results_search')),
|
<View style={{ flexDirection: 'row', marginRight: 5 }}>
|
||||||
})}
|
<TextInput style={{ ...styles.searchInput, borderColor: this.state.mainColor }} placeholder={i18n.t('global.search')} value={this.state.searchTxt} onChangeText={(text) => this.setState({ searchTxt: text })} />
|
||||||
/>
|
<TouchableOpacity style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }} onPress={() => {
|
||||||
</Stack.Navigator>
|
if (this.state.searchTxt.length > 0) {
|
||||||
|
navigation.navigation.navigate('SearchScreen', {
|
||||||
|
needle: this.state.searchTxt,
|
||||||
|
onlyVideos: true,
|
||||||
|
});
|
||||||
|
this.setState({ searchTxt: '' });
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<Icon name={'search'} size={20} color={'white'} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="VideoScreen"
|
||||||
|
component={VideoScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.video')),
|
||||||
|
headerRight: () => this.SendEmail(),
|
||||||
|
orientation: 'landscape'
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="PDFScreen"
|
||||||
|
component={PDFScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, 'PDF'),
|
||||||
|
headerRight: () => this.SendEmail()
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="ContactScreen"
|
||||||
|
component={ContactScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.contacts'))
|
||||||
|
})}
|
||||||
|
initialParams={{ contactAdded: false }}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="ContactDetailsScreen"
|
||||||
|
component={ContactDetailsScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.contact_details'))
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="SearchScreen"
|
||||||
|
component={SearchScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.results_search'))
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="MySpaceScreen"
|
||||||
|
component={MySpaceScreen}
|
||||||
|
options={(navigation, route) => ({
|
||||||
|
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.my_space')),
|
||||||
|
headerRight: () => (
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
const folder = store.getState().directories.treeview.filter(tmp => tmp.id === 1);
|
||||||
|
navigation.navigation.navigate('DirectoriesScreen', { folder: folder })
|
||||||
|
}}
|
||||||
|
style={{ marginRight: 15 }}>
|
||||||
|
<Icon name="briefcase" size={20} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</Stack.Navigator>
|
||||||
<FlashMessage position="top" />
|
<FlashMessage position="top" />
|
||||||
</DrawerLayoutAndroid>
|
</DrawerLayoutAndroid>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
|
|
@ -379,23 +338,20 @@ class App extends React.Component {
|
||||||
LogoTitle(navigation, title, wantBtn = true) {
|
LogoTitle(navigation, title, wantBtn = true) {
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity onPress={() => {
|
||||||
onPress={() => {
|
if (wantBtn) {
|
||||||
if (wantBtn) {
|
navigation.navigation.navigate('HomeScreen')
|
||||||
navigation.navigation.navigate('HomeScreen');
|
}
|
||||||
}
|
}}>
|
||||||
}}>
|
|
||||||
{this.state.isSetup ? (
|
{this.state.isSetup ? (
|
||||||
<Image
|
<Image
|
||||||
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
||||||
source={{
|
source={{ uri: FileSystem.documentDirectory + 'RectangleLogo.png' }}
|
||||||
uri: FileSystem.documentDirectory + 'RectangleLogo.png',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Image
|
<Image
|
||||||
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
||||||
source={require('./Resources/assets/img/logo.png')}
|
source={require('./Resources/assets/img/logo.png')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
@ -406,47 +362,35 @@ class App extends React.Component {
|
||||||
|
|
||||||
SendEmail() {
|
SendEmail() {
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={{ flexDirection: 'row', alignItems: 'center', marginRight: 10 }}>
|
||||||
style={{ flexDirection: 'row', alignItems: 'center', marginRight: 10 }}>
|
<TextInput style={{ ...styles.searchInput, borderColor: this.state.mainColor }} placeholder={i18n.t('global.email')} value={this.state.sendEmail} onChangeText={(text) => this.setState({ sendEmail: text })} />
|
||||||
<TextInput
|
<TouchableOpacity style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }} onPress={() => {
|
||||||
style={{ ...styles.searchInput, borderColor: this.state.mainColor }}
|
if (this.state.sendEmail.length > 0) {
|
||||||
placeholder={i18n.t('global.email')}
|
if (Helpers.isEmailValid(this.state.sendEmail)) {
|
||||||
value={this.state.sendEmail}
|
const email = {
|
||||||
onChangeText={text => this.setState({ sendEmail: text })}
|
email: this.state.sendEmail,
|
||||||
/>
|
subject: i18n.t('app.file_sharing'),
|
||||||
<TouchableOpacity
|
message: '',
|
||||||
style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }}
|
documents: JSON.stringify([store.getState().currentOpenedDoc]),
|
||||||
onPress={() => {
|
user_id: store.getState().currentUser.id
|
||||||
if (this.state.sendEmail.length > 0) {
|
};
|
||||||
if (Helpers.isEmailValid(this.state.sendEmail)) {
|
store.dispatch({ type: 'SEND_BROCHURE', data: email });
|
||||||
const email = {
|
showMessage({
|
||||||
email: this.state.sendEmail,
|
message: i18n.t('global.message_sent') + '.',
|
||||||
subject: i18n.t('app.file_sharing'),
|
description: i18n.t('global.message_will_be_sent_after_sync') + '.',
|
||||||
message: '',
|
type: 'success',
|
||||||
documents: JSON.stringify([
|
duration: 1500,
|
||||||
store.getState().app.currentOpenedDoc,
|
});
|
||||||
]),
|
this.setState({ sendEmail: '' });
|
||||||
app_user_id: store.getState().app.currentUser.id,
|
} else {
|
||||||
};
|
Alert.alert(i18n.t('global.warning') + ' !', i18n.t('error.invalid_email_address') + '.', [
|
||||||
store.dispatch({ type: 'SEND_BROCHURE', data: email });
|
{ text: 'OK' },
|
||||||
showMessage({
|
],
|
||||||
message: i18n.t('global.message_sent') + '.',
|
{ cancelable: false },
|
||||||
description:
|
);
|
||||||
i18n.t('global.message_will_be_sent_after_sync') + '.',
|
|
||||||
type: 'success',
|
|
||||||
duration: 1500,
|
|
||||||
});
|
|
||||||
this.setState({ sendEmail: '' });
|
|
||||||
} else {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('global.warning') + ' !',
|
|
||||||
i18n.t('error.invalid_email_address') + '.',
|
|
||||||
[{ text: 'OK' }],
|
|
||||||
{ cancelable: false },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}}>
|
}
|
||||||
|
}}>
|
||||||
<Icon name={'paper-plane'} size={20} color={'white'} />
|
<Icon name={'paper-plane'} size={20} color={'white'} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -456,21 +400,22 @@ class App extends React.Component {
|
||||||
renderFlag() {
|
renderFlag() {
|
||||||
let flag;
|
let flag;
|
||||||
switch (store.getState().locale.locale) {
|
switch (store.getState().locale.locale) {
|
||||||
case 'fr':
|
case "fr":
|
||||||
flag = require('./assets/img/flags/fr.png');
|
flag = require('./assets/img/flags/fr.png');
|
||||||
break;
|
break;
|
||||||
case 'en':
|
case "en":
|
||||||
flag = require('./assets/img/flags/en.png');
|
flag = require('./assets/img/flags/en.png');
|
||||||
break;
|
break;
|
||||||
case 'de':
|
case "de":
|
||||||
flag = require('./assets/img/flags/de.png');
|
flag = require('./assets/img/flags/de.png');
|
||||||
break;
|
break;
|
||||||
case 'es':
|
case "es":
|
||||||
flag = require('./assets/img/flags/es.png');
|
flag = require('./assets/img/flags/es.png');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Sentry.wrap(App);
|
export default Sentry.wrap(App);
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,63 @@
|
||||||
import { Alert } from 'react-native';
|
import { Alert } from "react-native";
|
||||||
// Lodash
|
// Lodash
|
||||||
|
import _ from 'lodash';
|
||||||
// Http Client
|
// Http Client
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// Network Infos
|
// Network Infos
|
||||||
import NetInfo from '@react-native-community/netinfo';
|
import NetInfo from "@react-native-community/netinfo";
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../I18n';
|
import i18n from "../../I18n";
|
||||||
// Database
|
// Database
|
||||||
import { Setting } from '../../Database';
|
import { Setting } from "../../Database";
|
||||||
|
|
||||||
const api_token = 'G9Q62jt8eL8gN4Ls';
|
const api_token = 'G9Q62jt8eL8gN4Ls';
|
||||||
class InstallController {
|
class InstallController {
|
||||||
async getConfig(url) {
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
url: url + '/api/settings',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getAppConfig(url) {
|
async getConfig(url) {
|
||||||
NetInfo.fetch().then(state => {
|
return axios({
|
||||||
if (state.isConnected) {
|
method: 'GET',
|
||||||
axios({
|
url: url + '/api/settings',
|
||||||
method: 'GET',
|
responseType: 'json',
|
||||||
url: url + '/api/app',
|
params: {
|
||||||
responseType: 'json',
|
token: api_token
|
||||||
params: {
|
},
|
||||||
token: api_token,
|
});
|
||||||
},
|
}
|
||||||
})
|
|
||||||
.then(function (response) {
|
getAppConfig(url) {
|
||||||
if (response.data) {
|
NetInfo.fetch().then(state => {
|
||||||
if (response.data.status === 'OK') {
|
if (state.isConnected) {
|
||||||
Setting.upsert({
|
axios({
|
||||||
key: 'HomeFolders',
|
method: 'GET',
|
||||||
value: JSON.stringify(response.data.datas.folders),
|
url: url + '/api/app',
|
||||||
});
|
responseType: 'json',
|
||||||
} else {
|
params: {
|
||||||
Alert.alert(
|
token: api_token
|
||||||
i18n.t('alert.error'),
|
},
|
||||||
i18n.t('error.error_has_occurred'),
|
})
|
||||||
);
|
.then(function (response) {
|
||||||
|
if (response.data) {
|
||||||
|
if (response.data.status === "OK") {
|
||||||
|
Setting.upsert({ key: 'HomeFolders', value: JSON.stringify(response.data.datas.folders) });
|
||||||
|
} else {
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.log(error)
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet"));
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.catch(function (error) {
|
return true;
|
||||||
console.error(error);
|
}
|
||||||
Alert.alert(
|
|
||||||
i18n.t('alert.error'),
|
|
||||||
i18n.t('error.error_has_occurred'),
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('alert.error'),
|
|
||||||
i18n.t('error.tablet_not_connected_internet'),
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new InstallController();
|
export default new InstallController();
|
||||||
|
|
@ -1,24 +1,28 @@
|
||||||
// Database
|
// Database
|
||||||
import { Setting } from '../../Database';
|
import { Setting } from "../../Database";
|
||||||
// BCrypt
|
// BCrypt
|
||||||
import { verify } from 'react-native-b-crypt-bridge';
|
import { verify } from 'react-native-b-crypt-bridge';
|
||||||
|
|
||||||
class LoginController {
|
class LoginController {
|
||||||
async verify(user, password) {
|
|
||||||
return await verify(password, user.password);
|
|
||||||
}
|
|
||||||
|
|
||||||
login(user) {
|
verify(user, password) {
|
||||||
Setting.upsert({
|
return verify(
|
||||||
key: 'isLogged',
|
password,
|
||||||
value: JSON.stringify(user),
|
user.password
|
||||||
});
|
);
|
||||||
Setting.upsert({
|
}
|
||||||
key: 'loggedTime',
|
|
||||||
value: Date.now().toString(),
|
login(user) {
|
||||||
});
|
Setting.upsert({
|
||||||
Setting.upsert({ key: 'lastUser', value: user.id.toString() });
|
key: 'isLogged',
|
||||||
}
|
value: JSON.stringify(user),
|
||||||
|
});
|
||||||
|
Setting.upsert({
|
||||||
|
key: 'loggedTime',
|
||||||
|
value: Date.now().toString(),
|
||||||
|
});
|
||||||
|
Setting.upsert({ key: 'lastUser', value: user.id.toString() });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new LoginController();
|
export default new LoginController();
|
||||||
|
|
@ -1,207 +1,213 @@
|
||||||
// Lodash
|
// Lodash
|
||||||
|
import _ from 'lodash';
|
||||||
// Http Client
|
// Http Client
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// Network Infos
|
// Network Infos
|
||||||
import NetInfo from '@react-native-community/netinfo';
|
import NetInfo from "@react-native-community/netinfo";
|
||||||
// Database
|
// Application infos
|
||||||
import { Contact, Document, SendBrochure, Setting } from '../../Database';
|
import * as Application from 'expo-application';
|
||||||
import { ContactData } from '../Models/Contact';
|
// Database
|
||||||
|
import { Setting, Contact, SendBrochure, Document } from '../../Database';
|
||||||
|
|
||||||
const api_token = 'G9Q62jt8eL8gN4Ls';
|
const api_token = 'G9Q62jt8eL8gN4Ls';
|
||||||
|
|
||||||
class SyncController {
|
class SyncController {
|
||||||
getUrlBo() {
|
|
||||||
const test = Setting.get('bo_url');
|
getUrlBo() {
|
||||||
if (test === null) {
|
const test = Setting.get('bo_url');
|
||||||
return 'noset';
|
if (test === false || test === undefined) {
|
||||||
|
return "noset";
|
||||||
|
}
|
||||||
|
return test.value;
|
||||||
}
|
}
|
||||||
return test.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkConnection() {
|
getAppStoreUUID() {
|
||||||
return NetInfo.fetch();
|
const test = Setting.get('AppStoreUUID');
|
||||||
}
|
if (test === false || test === undefined) {
|
||||||
|
return "noset";
|
||||||
async getUsers() {
|
}
|
||||||
return axios({
|
return test.value;
|
||||||
method: 'GET',
|
|
||||||
// * users.index
|
|
||||||
url: this.getUrlBo() + '/api/users',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id
|
|
||||||
*/
|
|
||||||
async getContacts(app_user_id) {
|
|
||||||
// * We retrieve all contacts avec upsert and destroy
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
// * contacts.index
|
|
||||||
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id
|
|
||||||
*/
|
|
||||||
async upsertContacts(app_user_id) {
|
|
||||||
const contacts = Contact.getAll(app_user_id).map(contact => {
|
|
||||||
// * This casts contact to a simple Object
|
|
||||||
// * Realm object does not support changing prop type
|
|
||||||
/** @type {ContactData} */
|
|
||||||
contact = contact.toJSON();
|
|
||||||
// * Convert to UTC timestamp
|
|
||||||
contact.timestamp = contact.timestamp.toUTCString();
|
|
||||||
|
|
||||||
// * Unstringify complex Fields
|
|
||||||
contact.data = JSON.parse(contact.data);
|
|
||||||
contact.visits = JSON.parse(contact.visits);
|
|
||||||
return contact;
|
|
||||||
});
|
|
||||||
return axios({
|
|
||||||
method: 'POST',
|
|
||||||
// * contacts.index
|
|
||||||
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
contacts: contacts,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id
|
|
||||||
*/
|
|
||||||
async deleteContacts(app_user_id) {
|
|
||||||
const contactsToDelete = Contact.getAllToDelete(app_user_id);
|
|
||||||
return axios({
|
|
||||||
method: 'DELETE',
|
|
||||||
// * contacts.index
|
|
||||||
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
contactUuidList: contactsToDelete.map(contact => contact.id),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async sendBrochure(brochure) {
|
|
||||||
return axios({
|
|
||||||
method: 'POST',
|
|
||||||
// * send-flyers
|
|
||||||
url: this.getUrlBo() + '/api/sendBrochure',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
emails: brochure,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getDirectories() {
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
// * directories.index
|
|
||||||
url: this.getUrlBo() + '/api/directories',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getDocuments() {
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
// * documents.index
|
|
||||||
url: this.getUrlBo() + '/api/documents',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getFormularies() {
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
// * formularies.index
|
|
||||||
url: this.getUrlBo() + '/api/formularies',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLastModificationDoc(id, date) {
|
|
||||||
Document.update({ id: id, updated_at: date.toString() }, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
isSynced(app_user_id) {
|
|
||||||
const brochures = SendBrochure.getAll();
|
|
||||||
const Contacts = Contact.getAll(app_user_id);
|
|
||||||
|
|
||||||
if (brochures !== undefined && Contacts !== undefined) {
|
|
||||||
const noSynced = Contacts.filtered('synced = false');
|
|
||||||
if (brochures.length > 0 || noSynced.length > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
isLogged() {
|
async checkConnection() {
|
||||||
const logged = Setting.get('isLogged');
|
return NetInfo.fetch();
|
||||||
const loggedTime = Setting.get('loggedTime');
|
}
|
||||||
if (logged !== null && loggedTime !== null) {
|
|
||||||
let seconds =
|
async getVersion() {
|
||||||
Math.abs(new Date(Number(loggedTime.value)) - Date.now()) / 1000;
|
return axios({
|
||||||
if (seconds < 14400) {
|
method: 'GET',
|
||||||
// 4h
|
url: this.getUrlBo() + '/api/version',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
app_uuid: this.getAppStoreUUID(),
|
||||||
|
app_version: Application.nativeApplicationVersion
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getUsers() {
|
||||||
|
return axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: this.getUrlBo() + '/api/users',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getContacts(userId) {
|
||||||
|
let contacts = Contact.getAll();
|
||||||
|
return axios({
|
||||||
|
method: 'POST',
|
||||||
|
url: this.getUrlBo() + '/api/contacts',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
contacts: contacts,
|
||||||
|
userId: userId,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async sendBrochure(brochure) {
|
||||||
|
return axios({
|
||||||
|
method: 'POST',
|
||||||
|
url: this.getUrlBo() + '/api/sendBrochure',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
emails: brochure,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDirectories() {
|
||||||
|
return axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: this.getUrlBo() + '/api/directories',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDocuments() {
|
||||||
|
return axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: this.getUrlBo() + '/api/documents',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLastModificationDoc(id, date) {
|
||||||
|
Document.update({ id: id, updated_at: date.toString() }, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateVersion(version) {
|
||||||
|
const localVersion = Setting.get('version');
|
||||||
|
if (localVersion === false || localVersion === undefined) {
|
||||||
|
Setting.add({ key: 'version', value: version });
|
||||||
|
} else {
|
||||||
|
Setting.update({ id: localVersion.id, key: 'version', value: version });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateShowIsActive(value) {
|
||||||
|
const local = Setting.get('ShowIsActive');
|
||||||
|
if (local === false || local === undefined) {
|
||||||
|
Setting.add({ key: 'ShowIsActive', value: value });
|
||||||
|
} else {
|
||||||
|
Setting.update({ id: local.id, key: 'ShowIsActive', value: value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isSynced() {
|
||||||
|
const brochures = SendBrochure.getAll();
|
||||||
|
const Contacts = Contact.getAll();
|
||||||
|
|
||||||
|
if (brochures !== undefined && Contacts !== undefined) {
|
||||||
|
const noSynced = Contacts.filtered('synced = false');
|
||||||
|
if (brochures.length > 0 || noSynced.length > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setInstalled(remove = false) {
|
isLogged() {
|
||||||
if (remove) {
|
const logged = Setting.get('isLogged');
|
||||||
Setting.delete('installed');
|
const loggedTime = Setting.get('loggedTime');
|
||||||
} else {
|
if (
|
||||||
Setting.add({ key: 'installed', value: 'true' });
|
logged !== false &&
|
||||||
|
loggedTime !== false &&
|
||||||
|
logged !== undefined &&
|
||||||
|
loggedTime !== undefined
|
||||||
|
) {
|
||||||
|
let seconds =
|
||||||
|
Math.abs(new Date(Number(loggedTime.value)) - Date.now()) / 1000;
|
||||||
|
if (seconds < 14400) {
|
||||||
|
// 4h
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
isInstalled() {
|
needSync(callback) {
|
||||||
const test = Setting.get('installed');
|
NetInfo.fetch().then(state => {
|
||||||
if (test === null) {
|
if (state.isConnected) {
|
||||||
return false;
|
axios({
|
||||||
|
method: 'get',
|
||||||
|
url: this.getUrlBo() + '/version',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
const localVersion = Setting.get('version');
|
||||||
|
if (
|
||||||
|
localVersion === undefined ||
|
||||||
|
localVersion === false ||
|
||||||
|
localVersion.value !== response.data.version
|
||||||
|
) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
setInstalled(remove = false) {
|
||||||
|
if (remove) {
|
||||||
|
Setting.delete('installed');
|
||||||
|
} else {
|
||||||
|
Setting.add({ key: 'installed', value: "true" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isInstalled() {
|
||||||
|
const test = Setting.get('installed');
|
||||||
|
if (test === false || test === undefined) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new SyncController();
|
export default new SyncController();
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/** InputStatusEnum */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {keyof InputStatusKeys} InputStatus
|
|
||||||
*/
|
|
||||||
export const InputStatus = {
|
|
||||||
SYSTEM: 1,
|
|
||||||
LOCKED: 2,
|
|
||||||
DEFAULT: 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const InputStatusKeys = {
|
|
||||||
1: 'SYSTEM',
|
|
||||||
2: 'LOCKED',
|
|
||||||
3: 'DEFAULT',
|
|
||||||
};
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/** InputTypeEnum */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {keyof InputTypeKeys} InputType
|
|
||||||
*/
|
|
||||||
export const InputType = {
|
|
||||||
TEXT: 1,
|
|
||||||
EMAIL: 2,
|
|
||||||
PHONE: 3,
|
|
||||||
RADIO: 4,
|
|
||||||
SELECT: 5,
|
|
||||||
SELECT_MULTIPLE: 6,
|
|
||||||
CHECKBOX: 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const InputTypeKeys = {
|
|
||||||
1: 'TEXT',
|
|
||||||
2: 'EMAIL',
|
|
||||||
3: 'PHONE',
|
|
||||||
4: 'RADIO',
|
|
||||||
5: 'SELECT',
|
|
||||||
6: 'SELECT_MULTIPLE',
|
|
||||||
7: 'CHECKBOX',
|
|
||||||
};
|
|
||||||
|
|
@ -1,78 +1,50 @@
|
||||||
class Helpers {
|
class Helpers {
|
||||||
compareValues(key, order = 'asc') {
|
compareValues(key, order = 'asc') {
|
||||||
return function innerSort(a, b) {
|
return function innerSort(a, b) {
|
||||||
if (!(key in a) || !(key in b)) {
|
if (!(key in a) || !(key in b)) {
|
||||||
// property doesn't exist on either object
|
// property doesn't exist on either object
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];
|
const varA = (typeof a[key] === 'string')
|
||||||
const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];
|
? a[key].toUpperCase() : a[key];
|
||||||
|
const varB = (typeof b[key] === 'string')
|
||||||
let comparison = 0;
|
? b[key].toUpperCase() : b[key];
|
||||||
if (varA > varB) {
|
|
||||||
comparison = 1;
|
let comparison = 0;
|
||||||
} else if (varA < varB) {
|
if (varA > varB) {
|
||||||
comparison = -1;
|
comparison = 1;
|
||||||
}
|
} else if (varA < varB) {
|
||||||
return order === 'desc' ? comparison * -1 : comparison;
|
comparison = -1;
|
||||||
};
|
}
|
||||||
}
|
return (
|
||||||
|
(order === 'desc') ? (comparison * -1) : comparison
|
||||||
isEmailValid(email) {
|
);
|
||||||
const expression =
|
};
|
||||||
/(?!.*\.{2})^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([\t]*\r\n)?[\t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([\t]*\r\n)?[\t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
|
}
|
||||||
return expression.test(String(email).toLowerCase());
|
|
||||||
}
|
isEmailValid(email) {
|
||||||
|
const expression = /(?!.*\.{2})^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([\t]*\r\n)?[\t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([\t]*\r\n)?[\t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
|
||||||
/**
|
return expression.test(String(email).toLowerCase());
|
||||||
* Test url is valid
|
}
|
||||||
* @param {string} value Url to test.
|
|
||||||
* @returns {boolean}
|
isUrlValid(value) {
|
||||||
*/
|
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value.toLowerCase());
|
||||||
isUrlValid(value) {
|
}
|
||||||
const re_weburl = new RegExp(
|
|
||||||
'^' +
|
generateUUID() { // Public Domain/MIT
|
||||||
// protocol identifier (optional)
|
let d = new Date().getTime();//Timestamp
|
||||||
// short syntax // still required
|
let d2 = new Date().getUTCMilliseconds() + Math.random();//Time in microseconds since page-load or 0 if unsupported
|
||||||
'(?:(?:(?:https?|ftp):)?\\/\\/)' +
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
// user:pass BasicAuth (optional)
|
let r = Math.random() * 16;//random number between 0 and 16
|
||||||
'(?:\\S+(?::\\S*)?@)?' +
|
if(d > 0){//Use timestamp until depleted
|
||||||
'(?:' +
|
r = (d + r)%16 | 0;
|
||||||
// IP address exclusion
|
d = Math.floor(d/16);
|
||||||
// private & local networks
|
} else {//Use microseconds since page-load if supported
|
||||||
'(?!(?:10|127)(?:\\.\\d{1,3}){3})' +
|
r = (d2 + r)%16 | 0;
|
||||||
'(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})' +
|
d2 = Math.floor(d2/16);
|
||||||
'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
|
}
|
||||||
// IP address dotted notation octets
|
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
||||||
// excludes loopback network 0.0.0.0
|
});
|
||||||
// excludes reserved space >= 224.0.0.0
|
}
|
||||||
// excludes network & broadcast addresses
|
}
|
||||||
// (first & last IP address of each class)
|
export default new Helpers();
|
||||||
'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])' +
|
|
||||||
'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' +
|
|
||||||
'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))' +
|
|
||||||
'|' +
|
|
||||||
// host & domain names, may end with dot
|
|
||||||
// can be replaced by a shortest alternative
|
|
||||||
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
|
|
||||||
'(?:' +
|
|
||||||
'(?:' +
|
|
||||||
'[a-z0-9\\u00a1-\\uffff]' +
|
|
||||||
'[a-z0-9\\u00a1-\\uffff_-]{0,62}' +
|
|
||||||
')?' +
|
|
||||||
'[a-z0-9\\u00a1-\\uffff]\\.' +
|
|
||||||
')+' +
|
|
||||||
// TLD identifier name, may end with dot
|
|
||||||
'(?:[a-z\\u00a1-\\uffff]{2,}\\.?)' +
|
|
||||||
')' +
|
|
||||||
// port number (optional)
|
|
||||||
'(?::\\d{2,5})?' +
|
|
||||||
// resource path (optional)
|
|
||||||
'(?:[/?#]\\S*)?' +
|
|
||||||
'$',
|
|
||||||
'i',
|
|
||||||
);
|
|
||||||
return re_weburl.test(value.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default new Helpers();
|
|
||||||
|
|
|
||||||
|
|
@ -1,195 +1,107 @@
|
||||||
import { default as UuidGenerator } from 'react-native-uuid';
|
|
||||||
import { UpdateMode } from 'realm';
|
|
||||||
import { InputType } from './../Enums/InputType';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {typeof ContactData} ContactData
|
|
||||||
*/
|
|
||||||
export const ContactData = {
|
|
||||||
/** @type {string|undefined} */
|
|
||||||
id: undefined,
|
|
||||||
/** @type {string} */
|
|
||||||
email: undefined,
|
|
||||||
/** @type {string|null} */
|
|
||||||
lastname: null,
|
|
||||||
/** @type {string|null} */
|
|
||||||
firstname: null,
|
|
||||||
/** @type {string|null} */
|
|
||||||
phone: null,
|
|
||||||
/** @type {Array<InputDataType>} */
|
|
||||||
data: [],
|
|
||||||
/** @type {string|null} */
|
|
||||||
notes: null,
|
|
||||||
/** @type {Array<Record<string,string>>|null} */
|
|
||||||
visits: null,
|
|
||||||
/** @type {Date} */
|
|
||||||
timestamp: null,
|
|
||||||
/** @type {number} The app user id */
|
|
||||||
app_user_id: undefined,
|
|
||||||
/** @type {number|null} The app user id that should receive this contact on sync */
|
|
||||||
send_to_app_user_id: null,
|
|
||||||
/** @type {boolean} If this model is to delete */
|
|
||||||
to_delete: false,
|
|
||||||
/** @type {boolean} This model need sync */
|
|
||||||
synced: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ContactsSchema = {
|
export const ContactsSchema = {
|
||||||
name: 'Contacts',
|
name: 'Contacts',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
...ContactData,
|
id: 'int',
|
||||||
...{
|
email: 'string',
|
||||||
id: 'string',
|
type: 'string',
|
||||||
email: 'string',
|
other: { type: 'string', optional: true },
|
||||||
lastname: { type: 'string', optional: true },
|
select1: { type: 'string', optional: true },
|
||||||
firstname: { type: 'string', optional: true },
|
select2: { type: 'string', optional: true },
|
||||||
phone: { type: 'string', optional: true },
|
name: 'string',
|
||||||
/** Json encoded string of ContactData.data */
|
firstname: 'string',
|
||||||
data: { type: 'string', default: '[]' },
|
company: { type: 'string', optional: true },
|
||||||
notes: { type: 'string', optional: true },
|
address: { type: 'string', optional: true },
|
||||||
/** Json encoded string of ContactData.visists */
|
phone: 'string',
|
||||||
visits: { type: 'string', default: '[]' },
|
products: { type: 'string', optional: true },
|
||||||
timestamp: 'date',
|
// TODO : card_url ?
|
||||||
send_to_app_user_id: { type: 'int', optional: true, default: null },
|
notes: { type: 'string', optional: true },
|
||||||
app_user_id: 'int',
|
visits: { type: 'string', optional: true },
|
||||||
to_delete: { type: 'bool', default: false },
|
user_id: 'int',
|
||||||
synced: { type: 'bool', default: true },
|
uniq_id: 'string',
|
||||||
},
|
to_delete: { type: 'bool', default: false },
|
||||||
|
synced: { type: 'bool', default: true },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {typeof InputData} InputDataType
|
|
||||||
*/
|
|
||||||
export const InputData = {
|
|
||||||
title: '',
|
|
||||||
formSlug: '',
|
|
||||||
/** @type {import('./../Enums/InputType').InputType} */
|
|
||||||
type: InputType.TEXT,
|
|
||||||
/** @type {string|Array<number,string>} */
|
|
||||||
value: '',
|
|
||||||
required: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof ContactData> & import('realm').Object} Contact
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ContactModel {
|
class ContactModel {
|
||||||
/**
|
|
||||||
* ContactModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
/** @type string */
|
|
||||||
this.schema = 'Contacts';
|
this.schema = 'Contacts';
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Unmanaged<typeof ContactData>} */
|
add(data) {
|
||||||
new() {
|
data.uniq_id = data.id;
|
||||||
return Object.assign({}, ContactData);
|
data.id = undefined;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set contact
|
|
||||||
* ! We can use only set since all contacts are dropped and redownloaded on sync
|
|
||||||
* @param {Contact} data
|
|
||||||
*/
|
|
||||||
set(data) {
|
|
||||||
const isNew = typeof data.id !== 'string' || !data.id?.length;
|
|
||||||
if (isNew) {
|
|
||||||
console.debug('is new', data);
|
|
||||||
// * Set Local UUID until it get synced
|
|
||||||
//* it will be ignore and new one will be generated by BO
|
|
||||||
data.id = UuidGenerator.v4();
|
|
||||||
}
|
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
|
if (data.id === undefined) {
|
||||||
|
let id = this.realm.objects(this.schema).max('id');
|
||||||
|
data.id = id === undefined ? 1 : id + 1;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
this.realm.create(
|
this.realm.create(this.schema, data, 'never');
|
||||||
this.schema,
|
|
||||||
data,
|
|
||||||
isNew ? UpdateMode.Never : UpdateMode.Modified,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('db contact set', e);
|
console.log('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
upsert(data) {
|
||||||
* get contact with uuid
|
let tmp = this.get(data.key);
|
||||||
* @param {number} app_user_id App User id
|
if (tmp === false || tmp === undefined) {
|
||||||
* @param {string} uuid
|
this.add(data);
|
||||||
* @returns {Contact?}
|
} else {
|
||||||
*/
|
if (data.id === undefined) {
|
||||||
get(app_user_id, uuid) {
|
data.id = tmp.id;
|
||||||
/** @type {import('realm').Results<Contact>} */
|
}
|
||||||
const tmp = this.realm
|
|
||||||
.objects(this.schema)
|
|
||||||
.filtered(`app_user_id = ${app_user_id}`);
|
|
||||||
if (tmp.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return tmp.filtered(`id = '${uuid}'`)[0] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id App User id
|
|
||||||
* @returns {import('realm').Results<Contact>}
|
|
||||||
*/
|
|
||||||
getAll(app_user_id) {
|
|
||||||
return this.realm
|
|
||||||
.objects(this.schema)
|
|
||||||
.filtered(`to_delete = false AND app_user_id = ${app_user_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id App User id
|
|
||||||
* @returns {import('realm').Results<Contact>}
|
|
||||||
*/
|
|
||||||
getAllEditable(app_user_id) {
|
|
||||||
return this.realm
|
|
||||||
.objects(this.schema)
|
|
||||||
.filtered(
|
|
||||||
`to_delete = false AND send_to_app_user_id = null AND app_user_id = ${app_user_id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} app_user_id App User id
|
|
||||||
* @returns {import('realm').Results<Contact>}
|
|
||||||
*/
|
|
||||||
getAllToDelete(app_user_id) {
|
|
||||||
return this.realm
|
|
||||||
.objects(this.schema)
|
|
||||||
.filtered(`to_delete = true AND app_user_id = ${app_user_id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete contact with id
|
|
||||||
* @param {number} app_user_id App User id
|
|
||||||
* @param {string} uuid
|
|
||||||
*/
|
|
||||||
delete(app_user_id, uuid) {
|
|
||||||
const contact = this.get(app_user_id, uuid);
|
|
||||||
if (typeof contact === 'object') {
|
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(contact);
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
update(data) {
|
||||||
* @param {number} app_user_id App User id
|
|
||||||
*/
|
|
||||||
clear(app_user_id) {
|
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll(app_user_id));
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get(id) {
|
||||||
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
if (tmp.length === 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
tmp = tmp.filtered('id = ' + id)[0];
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
getByUser(userId) {
|
||||||
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
tmp = tmp.filtered('to_delete = false AND user_id = ' + userId);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll() {
|
||||||
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.delete(this.getAll());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(key) {
|
||||||
|
const tmp = this.get(key);
|
||||||
|
if (typeof tmp === 'object') {
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.delete(tmp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ContactModel;
|
export default ContactModel;
|
||||||
|
|
|
||||||
|
|
@ -2,91 +2,58 @@ export const DirectoriesSchema = {
|
||||||
name: 'Directories',
|
name: 'Directories',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
/** @type {number} */
|
|
||||||
id: 'int',
|
id: 'int',
|
||||||
name: 'string',
|
name: 'string',
|
||||||
/** @type {number|null} */
|
|
||||||
parent: { type: 'int', optional: true },
|
parent: { type: 'int', optional: true },
|
||||||
/** @type {number} */
|
|
||||||
order: 'int',
|
order: 'int',
|
||||||
/** @type {number} */
|
|
||||||
needAuthorization: 'int',
|
needAuthorization: 'int',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof DirectoriesSchema.properties> & import('realm').Object} Directory
|
|
||||||
*/
|
|
||||||
|
|
||||||
class DirectoryModel {
|
class DirectoryModel {
|
||||||
/**
|
|
||||||
* DirectoryModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
/** @type string */
|
|
||||||
this.schema = 'Directories';
|
this.schema = 'Directories';
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Directory} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data);
|
this.realm.create(this.schema, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Directory} data
|
|
||||||
*/
|
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get directory with id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {Directory?}
|
|
||||||
*/
|
|
||||||
get(id) {
|
get(id) {
|
||||||
/** @type {import('realm').Results<Directory>} */
|
let tmp = this.realm.objects(this.schema);
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return null;
|
return false;
|
||||||
|
} else {
|
||||||
|
tmp = tmp.filtered('id = ' + id)[0];
|
||||||
}
|
}
|
||||||
return tmp.filtered('id = ' + id)[0] ?? null;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getAll(role, authorizedFolders, format, lang) {
|
||||||
* @param {string} role
|
if (authorizedFolders !== null && authorizedFolders !== undefined) {
|
||||||
* @param {string} authorizedDirs JSON array of {Directory}
|
authorizedFolders = JSON.parse(authorizedFolders);
|
||||||
* @param {boolean} format
|
}
|
||||||
* @param {string} lang
|
|
||||||
* @returns {import('realm').Results<Directory>}
|
|
||||||
*/
|
|
||||||
getAll(role, authorizedDirs, format, lang) {
|
|
||||||
/** @type {Array<Directory>} */
|
|
||||||
const allowedDirs =
|
|
||||||
authorizedDirs !== null && authorizedDirs !== undefined
|
|
||||||
? JSON.parse(authorizedDirs)
|
|
||||||
: [];
|
|
||||||
/** @type {import('realm').Results<Directory>} */
|
|
||||||
let tmp = this.realm.objects(this.schema);
|
let tmp = this.realm.objects(this.schema);
|
||||||
if (role === 'USER') {
|
if (role === 'USER') {
|
||||||
if (allowedDirs.length > 0) {
|
if (authorizedFolders.length > 0) {
|
||||||
tmp = tmp.filtered(
|
tmp = tmp.filtered(
|
||||||
'needAuthorization = 0 OR ' +
|
'needAuthorization = 0 OR ' +
|
||||||
allowedDirs
|
authorizedFolders
|
||||||
.map(directory => ' id = "' + directory.id + '"')
|
.map(folder => ' id = "' + folder.id + '"')
|
||||||
.join(' OR '),
|
.join(' OR '),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
tmp = tmp.filtered('needAuthorization = 0');
|
tmp = tmp.filtered(
|
||||||
|
'needAuthorization = 0'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (format) {
|
if (format) {
|
||||||
|
|
@ -95,28 +62,18 @@ class DirectoryModel {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete all */
|
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.realm.objects(this.schema));
|
this.realm.delete(this.realm.objects(this.schema));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursive Dir filter
|
|
||||||
*
|
|
||||||
* @param {import('realm').Results<Directory>} list
|
|
||||||
* @param {string} lang
|
|
||||||
* @param {DirectoryData} parent
|
|
||||||
* @returns {DirectoryData[]}
|
|
||||||
*/
|
|
||||||
_recursiveDir(list, lang, parent = null) {
|
_recursiveDir(list, lang, parent = null) {
|
||||||
const root = list.filter(e => e.parent === parent);
|
let root = list.filter(e => e.parent === parent);
|
||||||
const tmp = [];
|
let tmp = [];
|
||||||
for (let i = 0; i < root.length; i++) {
|
for (let i = 0; i < root.length; i++) {
|
||||||
const childs = this._recursiveDir(list, lang, root[i].id);
|
let childs = this._recursiveDir(list, lang, root[i].id);
|
||||||
/** @type {Object<string,string>} */
|
let name = JSON.parse(root[i].name);
|
||||||
const name = JSON.parse(root[i].name);
|
|
||||||
tmp[i] = {};
|
tmp[i] = {};
|
||||||
tmp[i].id = root[i].id;
|
tmp[i].id = root[i].id;
|
||||||
tmp[i].name = this.getI18nName(lang, name);
|
tmp[i].name = this.getI18nName(lang, name);
|
||||||
|
|
@ -132,26 +89,19 @@ class DirectoryModel {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get i18n name
|
|
||||||
* @param {string} lang
|
|
||||||
* @param {Record<string,string>} name
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
getI18nName(lang, name) {
|
getI18nName(lang, name) {
|
||||||
/** @type {string} */
|
let tmp = undefined;
|
||||||
let tmp;
|
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case 'fr':
|
case "fr":
|
||||||
tmp = name.fr;
|
tmp = name.fr;
|
||||||
break;
|
break;
|
||||||
case 'en':
|
case "en":
|
||||||
tmp = name.en;
|
tmp = name.en;
|
||||||
break;
|
break;
|
||||||
case 'de':
|
case "de":
|
||||||
tmp = name.de;
|
tmp = name.de;
|
||||||
break;
|
break;
|
||||||
case 'es':
|
case "es":
|
||||||
tmp = name.es;
|
tmp = name.es;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -160,6 +110,7 @@ class DirectoryModel {
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DirectoryModel;
|
export default DirectoryModel;
|
||||||
|
|
|
||||||
|
|
@ -1,126 +1,79 @@
|
||||||
export const DocumentsSchema = {
|
export const DocumentsSchema = {
|
||||||
name: 'Documents',
|
name: 'Documents',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
/** @type {number} */
|
id: 'int',
|
||||||
id: 'int',
|
uuid: 'string',
|
||||||
uuid: 'string',
|
title: 'string',
|
||||||
title: 'string',
|
type: 'string',
|
||||||
type: 'string',
|
path: 'string',
|
||||||
path: 'string',
|
directory: 'int',
|
||||||
/** @type {number} */
|
lang: 'string',
|
||||||
directory: 'int',
|
updated_at: 'string',
|
||||||
lang: 'string',
|
},
|
||||||
updated_at: 'string',
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof DocumentsSchema.properties> & import('realm').Object} Document
|
|
||||||
*/
|
|
||||||
|
|
||||||
class DocumentModel {
|
class DocumentModel {
|
||||||
/**
|
constructor(realm) {
|
||||||
* DocumentModel
|
this.schema = 'Documents';
|
||||||
* @param {Realm} realm
|
this.realm = realm;
|
||||||
*/
|
|
||||||
constructor(realm) {
|
|
||||||
/** @type string */
|
|
||||||
this.schema = 'Documents';
|
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Document} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
|
||||||
this.realm.write(() => {
|
|
||||||
this.realm.create(this.schema, data, 'never');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Document} data
|
|
||||||
* @param {boolean} updatedAtChange
|
|
||||||
*/
|
|
||||||
update(data, updatedAtChange = false) {
|
|
||||||
const tmp = this.get(data.id);
|
|
||||||
if (tmp === null) {
|
|
||||||
this.add(data);
|
|
||||||
} else {
|
|
||||||
this.realm.write(() => {
|
|
||||||
if (updatedAtChange === false) {
|
|
||||||
this.realm.create(
|
|
||||||
this.schema,
|
|
||||||
{
|
|
||||||
id: tmp.id,
|
|
||||||
uuid: data.uuid,
|
|
||||||
title: data.title,
|
|
||||||
type: data.type,
|
|
||||||
path: data.path,
|
|
||||||
directory: data.directory,
|
|
||||||
},
|
|
||||||
'modified',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.realm.create(this.schema, data, 'modified');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
add(document) {
|
||||||
* get document with id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {Document?}
|
|
||||||
*/
|
|
||||||
get(id) {
|
|
||||||
/** @type {Realm.Results<Document>} */
|
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return tmp.filtered('id = ' + id)[0] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Array<import("./Directory").Directory>} authorizedDirs
|
|
||||||
* @returns {import('realm').Results<Document>}
|
|
||||||
*/
|
|
||||||
getAll(authorizedDirs = false) {
|
|
||||||
/** @type {Realm.Results<Document>} */
|
|
||||||
let tmp = this.realm.objects(this.schema);
|
|
||||||
if (authorizedDirs) {
|
|
||||||
authorizedDirs = authorizedDirs.map(item => item.id);
|
|
||||||
tmp = tmp.filter(doc => authorizedDirs.includes(doc.directory));
|
|
||||||
}
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { { uuid: typeof DocumentsSchema.properties.uuid, type: typeof DocumentsSchema.properties.type } } DocumentCleared
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all
|
|
||||||
* @param {Array<Document>} docs
|
|
||||||
* @param {Array<DocumentCleared>} toDelete
|
|
||||||
* @returns {Array<DocumentCleared>}
|
|
||||||
*/
|
|
||||||
clear(docs, toDelete = []) {
|
|
||||||
const localDocs = this.getAll();
|
|
||||||
localDocs.forEach(doc => {
|
|
||||||
const tmp = docs.filter(item => item.uuid === doc.uuid);
|
|
||||||
if (tmp.length === 0) {
|
|
||||||
toDelete.push({ uuid: doc.uuid, type: doc.type });
|
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(doc);
|
this.realm.create(this.schema, document, 'never');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return toDelete;
|
update(document, updatedAtChange = false) {
|
||||||
}
|
let tmp = this.get(document.id);
|
||||||
|
if (tmp === undefined) {
|
||||||
|
this.add(document);
|
||||||
|
} else {
|
||||||
|
this.realm.write(() => {
|
||||||
|
if (updatedAtChange === false) {
|
||||||
|
this.realm.create(this.schema, {
|
||||||
|
id: tmp.id,
|
||||||
|
uuid: document.uuid,
|
||||||
|
title: document.title,
|
||||||
|
type: document.type,
|
||||||
|
path: document.path,
|
||||||
|
directory: document.directory
|
||||||
|
}, 'modified');
|
||||||
|
} else {
|
||||||
|
this.realm.create(this.schema, document, 'modified');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get(id) {
|
||||||
|
let tmp = this.realm.objects(this.schema).filtered('id = ' + id)[0];
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAll(authorizedDirs = false) {
|
||||||
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
if (authorizedDirs) {
|
||||||
|
authorizedDirs = authorizedDirs.map(item => item.id);
|
||||||
|
tmp = tmp.filter(doc => authorizedDirs.includes(doc.directory));
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(docs, toDelete = []) {
|
||||||
|
const localDocs = this.getAll();
|
||||||
|
localDocs.forEach(doc => {
|
||||||
|
let tmp = docs.filter(item => item.uuid === doc.uuid);
|
||||||
|
if (tmp.length === 0) {
|
||||||
|
toDelete.push({ uuid: doc.uuid, type: doc.type });
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.delete(doc);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return toDelete;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DocumentModel;
|
export default DocumentModel;
|
||||||
|
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
import { UpdateMode } from 'realm';
|
|
||||||
|
|
||||||
export const FormData = {
|
|
||||||
/** @type {number} */
|
|
||||||
id: undefined,
|
|
||||||
/** @type {import('./../Enums/InputType').InputType} */
|
|
||||||
type: undefined,
|
|
||||||
/** @type {string} */
|
|
||||||
name: undefined,
|
|
||||||
/** @type {string} */
|
|
||||||
slug: undefined,
|
|
||||||
|
|
||||||
/** @type {import('realm').Dictionary<string>} list of translated placeholders Map<string,string> */
|
|
||||||
placeholder: {},
|
|
||||||
/** @type {import('realm').List<string>} list of json encoded translated details, list of Map<string,string> */
|
|
||||||
details: [],
|
|
||||||
/** @type {boolean} */
|
|
||||||
is_visible: false,
|
|
||||||
/** @type {boolean} */
|
|
||||||
required: false,
|
|
||||||
/** @type {import('./../Enums/InputStatus').InputStatus} */
|
|
||||||
status: 0,
|
|
||||||
/** @type {number} */
|
|
||||||
order: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const FormsSchema = {
|
|
||||||
name: 'Formularies',
|
|
||||||
primaryKey: 'id',
|
|
||||||
properties: {
|
|
||||||
id: 'int',
|
|
||||||
type: 'int',
|
|
||||||
name: 'string',
|
|
||||||
slug: 'string',
|
|
||||||
placeholder: { type: 'dictionary', objectType: 'string' },
|
|
||||||
details: { type: 'list', objectType: 'string' },
|
|
||||||
is_visible: 'bool',
|
|
||||||
required: 'bool',
|
|
||||||
status: 'int',
|
|
||||||
order: 'int',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof FormData> & import('realm').Object} Form
|
|
||||||
*/
|
|
||||||
|
|
||||||
class FormModel {
|
|
||||||
/**
|
|
||||||
* DocumentModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
|
||||||
/** @type string */
|
|
||||||
this.schema = 'Formularies';
|
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Form} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
|
||||||
this.realm.write(() => {
|
|
||||||
this.realm.create(this.schema, data, UpdateMode.Never);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get document with id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {Form?}
|
|
||||||
*/
|
|
||||||
get(id) {
|
|
||||||
/** @type {Realm.Results<Form>} */
|
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return tmp.filtered(`id = ${id}`)[0] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {import('./../Enums/InputStatus').InputStatus|null} status
|
|
||||||
* @returns {import('realm').Results<Form>}
|
|
||||||
*/
|
|
||||||
getAll(status = null) {
|
|
||||||
const objects = this.realm.objects(this.schema);
|
|
||||||
if (status !== null) {
|
|
||||||
return objects.filtered(`status = ${status}`);
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { { uuid: typeof FormsSchema.properties.uuid, type: typeof FormsSchema.properties.type } } DocumentCleared
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Delete all */
|
|
||||||
clear() {
|
|
||||||
this.realm.write(() => {
|
|
||||||
this.realm.delete(this.getAll());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FormModel;
|
|
||||||
|
|
@ -2,36 +2,21 @@ export const SendBrochuresSchema = {
|
||||||
name: 'SendBrochures',
|
name: 'SendBrochures',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
/** @type {number} */
|
|
||||||
id: 'int',
|
id: 'int',
|
||||||
email: 'string',
|
email: 'string',
|
||||||
subject: 'string',
|
subject: 'string',
|
||||||
message: 'string',
|
message: 'string',
|
||||||
documents: 'string',
|
documents: 'string',
|
||||||
/** @type {number} */
|
user_id: 'int'
|
||||||
app_user_id: 'int',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof SendBrochuresSchema.properties> & import('realm').Object} SendBrochure
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SendBrochureModel {
|
class SendBrochureModel {
|
||||||
/**
|
|
||||||
* SendBrochureModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
/** @type string */
|
|
||||||
this.schema = 'SendBrochures';
|
this.schema = 'SendBrochures';
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {SendBrochure} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -41,17 +26,14 @@ class SendBrochureModel {
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('db setting add', e);
|
console.log('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {SendBrochure} data
|
|
||||||
*/
|
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
const tmp = this.get(data.key);
|
let tmp = this.get(data.key);
|
||||||
if (tmp === null) {
|
if (tmp === false || tmp === undefined) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -63,55 +45,42 @@ class SendBrochureModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {SendBrochure} data
|
|
||||||
*/
|
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get sendBrochure with id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {SendBrochure?}
|
|
||||||
*/
|
|
||||||
get(id) {
|
get(id) {
|
||||||
/** @type {import('realm').Results<SendBrochure>} */
|
let tmp = this.realm.objects(this.schema);
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return null;
|
return false;
|
||||||
|
} else {
|
||||||
|
tmp = tmp.filtered('id = ' + id)[0];
|
||||||
}
|
}
|
||||||
return tmp.filtered('id = ' + id)[0] ?? null;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {import('realm').Results<SendBrochure>}
|
|
||||||
*/
|
|
||||||
getAll() {
|
getAll() {
|
||||||
return this.realm.objects(this.schema);
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete all */
|
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll());
|
this.realm.delete(this.getAll());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
delete(key) {
|
||||||
* delete sendBrochure with id
|
const tmp = this.get(key);
|
||||||
* @param {number} id id
|
|
||||||
*/
|
|
||||||
delete(id) {
|
|
||||||
const tmp = this.get(id);
|
|
||||||
if (typeof tmp === 'object') {
|
if (typeof tmp === 'object') {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(tmp);
|
this.realm.delete(tmp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SendBrochureModel;
|
export default SendBrochureModel;
|
||||||
|
|
|
||||||
|
|
@ -2,52 +2,35 @@ export const SettingsSchema = {
|
||||||
name: 'Settings',
|
name: 'Settings',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
/** @type {number} */
|
|
||||||
id: 'int',
|
id: 'int',
|
||||||
key: 'string',
|
key: 'string',
|
||||||
value: 'string',
|
value: 'string',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof SettingsSchema.properties> & import('realm').Object} Setting
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SettingModel {
|
class SettingModel {
|
||||||
/**
|
|
||||||
* SettingModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
/** @type string */
|
this.schema = 'Settings';
|
||||||
this.schema = 'Settings';
|
this.realm = realm;
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Setting} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
const id = this.realm.objects(this.schema).max('id');
|
let id = this.realm.objects(this.schema).max('id');
|
||||||
data.id = id === undefined ? 1 : id + 1;
|
data.id = id === undefined ? 1 : id + 1;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('db setting add', e);
|
console.log('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Setting} data
|
|
||||||
*/
|
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
const tmp = this.get(data.key);
|
let tmp = this.get(data.key);
|
||||||
if (tmp === null) {
|
if (tmp === false || tmp === undefined) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -59,41 +42,31 @@ class SettingModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Setting} data
|
|
||||||
*/
|
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get setting with key
|
|
||||||
* @param {string} key
|
|
||||||
* @returns {Setting?}
|
|
||||||
*/
|
|
||||||
get(key) {
|
get(key) {
|
||||||
/** @type {import('realm').Results<Setting>} */
|
let tmp = this.realm.objects(this.schema);
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return null;
|
return false;
|
||||||
|
} else {
|
||||||
|
tmp = tmp.filtered('key = "' + key + '"')[0];
|
||||||
}
|
}
|
||||||
return tmp.filtered('key = "' + key + '"')[0] ?? null;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
delete(key) {
|
||||||
* delete setting with id
|
const tmp = this.get(key);
|
||||||
* @param {number} id id
|
|
||||||
*/
|
|
||||||
delete(id) {
|
|
||||||
const tmp = this.get(id);
|
|
||||||
if (typeof tmp === 'object') {
|
if (typeof tmp === 'object') {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(tmp);
|
this.realm.delete(tmp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SettingModel;
|
export default SettingModel;
|
||||||
|
|
@ -1,55 +1,23 @@
|
||||||
/**
|
|
||||||
* @typedef {typeof UserData} UserData
|
|
||||||
*/
|
|
||||||
export const UserData = {
|
|
||||||
/** @type {string|undefined} */
|
|
||||||
id: undefined,
|
|
||||||
/** @type {string} */
|
|
||||||
surname: undefined,
|
|
||||||
/** @type {string|null} */
|
|
||||||
lastname: null,
|
|
||||||
/** @type {string|null} */
|
|
||||||
firstname: null,
|
|
||||||
/** @type {string|null} */
|
|
||||||
role: null,
|
|
||||||
/** @type {string|null} */
|
|
||||||
authorizedFolders: null,
|
|
||||||
};
|
|
||||||
export const UsersSchema = {
|
export const UsersSchema = {
|
||||||
name: 'Users',
|
name: 'Users',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
/** @type {number} */
|
|
||||||
id: 'int',
|
id: 'int',
|
||||||
email: 'string',
|
email: 'string',
|
||||||
surname: 'string',
|
surname: 'string',
|
||||||
firstname: 'string',
|
firstname: 'string',
|
||||||
password: 'string',
|
password: 'string',
|
||||||
role: 'string',
|
role: 'string',
|
||||||
/** Json encoded string of {import('./Models/Directory').Directory[]} */
|
|
||||||
authorizedFolders: 'string',
|
authorizedFolders: 'string',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Unmanaged<typeof UsersSchema.properties> & import('realm').Object} User
|
|
||||||
*/
|
|
||||||
|
|
||||||
class UserModel {
|
class UserModel {
|
||||||
/**
|
|
||||||
* UserModel
|
|
||||||
* @param {Realm} realm
|
|
||||||
*/
|
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
/** @type string */
|
|
||||||
this.schema = 'Users';
|
this.schema = 'Users';
|
||||||
/** @type {Realm} */
|
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {User} data
|
|
||||||
*/
|
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -59,16 +27,13 @@ class UserModel {
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('db setting add', e);
|
console.log('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {User} data
|
|
||||||
*/
|
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
const tmp = this.get(data.key);
|
let tmp = this.get(data.key);
|
||||||
if (tmp === false || tmp === undefined) {
|
if (tmp === false || tmp === undefined) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -81,42 +46,33 @@ class UserModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {User} data
|
|
||||||
*/
|
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get user with id
|
|
||||||
* @param {number} id
|
|
||||||
* @returns {User?}
|
|
||||||
*/
|
|
||||||
get(id) {
|
get(id) {
|
||||||
/** @type {import('realm').Results<User>} */
|
let tmp = this.realm.objects(this.schema);
|
||||||
const tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return null;
|
return false;
|
||||||
|
} else {
|
||||||
|
tmp = tmp.filtered('id = ' + id)[0];
|
||||||
}
|
}
|
||||||
return tmp.filtered('key = "' + id + '"')[0] ?? null;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {import('realm').Results<User>}
|
|
||||||
*/
|
|
||||||
getAll() {
|
getAll() {
|
||||||
return this.realm.objects(this.schema);
|
let tmp = this.realm.objects(this.schema);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete all */
|
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll());
|
this.realm.delete(this.getAll());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserModel;
|
export default UserModel;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
// Locale
|
// Locale
|
||||||
export const INIT_LOCALE = 'INIT_LOCALE';
|
export const INIT_LOCALE = "INIT_LOCALE";
|
||||||
export const EDIT_LOCALE = 'EDIT_LOCALE';
|
export const EDIT_LOCALE = "EDIT_LOCALE";
|
||||||
// Users
|
// Users
|
||||||
export const INIT_USERS = 'INIT_USERS';
|
export const INIT_USERS = "INIT_USERS";
|
||||||
// Contacts
|
// Contacts
|
||||||
export const INIT_CONTACT = 'INIT_CONTACT';
|
export const INIT_CONTACT = "INIT_CONTACT";
|
||||||
export const SET_CONTACT = 'ADD_CONTACT';
|
export const ADD_CONTACT = "ADD_CONTACT";
|
||||||
export const DELETE_CONTACT = 'DELETE_CONTACT';
|
export const EDIT_CONTACT = "EDIT_CONTACT";
|
||||||
|
export const DELETE_CONTACT = "DELETE_CONTACT";
|
||||||
// Directories
|
// Directories
|
||||||
export const INIT_DIRECTORIES = 'INIT_DIRECTORIES';
|
export const INIT_DIRECTORIES = "INIT_DIRECTORIES";
|
||||||
// Documents
|
// Documents
|
||||||
export const INIT_DOCUMENTS = 'INIT_DOCUMENTS';
|
export const INIT_DOCUMENTS = "INIT_DOCUMENTS";
|
||||||
// Formularies
|
|
||||||
export const INIT_FORMS = 'INIT_FORMS';
|
|
||||||
|
|
@ -1,52 +1,53 @@
|
||||||
import { DELETE_CONTACT, INIT_CONTACT, SET_CONTACT } from './actionType';
|
import { INIT_CONTACT, ADD_CONTACT, EDIT_CONTACT, DELETE_CONTACT } from "./actionType";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {currentUser: import('../../Models/User').User, data: import('../../Models/Contact').Contact} } InitContactAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init contact
|
* Init contact
|
||||||
* @param {import('../../Models/User').User} currentUser The currentUser
|
* @param {object} currentUser The currentUser
|
||||||
* @param {import('../../Models/Contact').Contact} data The contact data
|
* @param {object} data The contact data
|
||||||
*/
|
*/
|
||||||
export const initContact = (currentUser, data) => {
|
export const initContact = (currentUser, data) => {
|
||||||
return {
|
return {
|
||||||
type: INIT_CONTACT,
|
type: INIT_CONTACT,
|
||||||
currentUser,
|
currentUser,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {currentUser: import('../../Models/User').User, data: import('../../Models/Contact').Contact} } SetContactAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add contact
|
* Add contact
|
||||||
* @param {import('../../Models/User').User} currentUser The currentUser
|
* @param {object} currentUser The currentUser
|
||||||
* @param {import('../../Models/Contact').Contact} data The contact data
|
* @param {object} data The contact data
|
||||||
*/
|
*/
|
||||||
export const setContact = (currentUser, data) => {
|
export const addContact = (currentUser, data) => {
|
||||||
return {
|
return {
|
||||||
type: SET_CONTACT,
|
type: ADD_CONTACT,
|
||||||
currentUser,
|
currentUser,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef { {currentUser: import('../../Models/User').User, uuid: string} } DeleteContactAction
|
* Edit contact
|
||||||
|
* @param {object} currentUser The currentUser
|
||||||
|
* @param {object} data The contact data
|
||||||
*/
|
*/
|
||||||
|
export const editContact = (currentUser, data) => {
|
||||||
|
return {
|
||||||
|
type: EDIT_CONTACT,
|
||||||
|
currentUser,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete contact
|
* Delete contact
|
||||||
* @param {import('../../Models/User').User} currentUser The currentUser
|
* @param {object} currentUser The currentUser
|
||||||
* @param {string} uuid The contact uuid
|
* @param {string} id The contact id
|
||||||
*/
|
*/
|
||||||
export const deleteContact = (currentUser, uuid) => {
|
export const deleteContact = (currentUser, id) => {
|
||||||
return {
|
return {
|
||||||
type: DELETE_CONTACT,
|
type: DELETE_CONTACT,
|
||||||
currentUser,
|
currentUser,
|
||||||
uuid: uuid,
|
id,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -1,21 +1,16 @@
|
||||||
import { INIT_DIRECTORIES } from './actionType';
|
import { INIT_DIRECTORIES } from "./actionType";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof INIT_DIRECTORIES, lang: string, user: import('../../Models/User').User, data: import('../../Models/Directory').Directory} } InitDirectoryAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init
|
* Init
|
||||||
* @param {string} lang The lang
|
* @param {string} lang The lang
|
||||||
* @param {import('../../Models/User').User} user
|
* @param {object} user User
|
||||||
* @param {import('../../Models/Directory').Directory} data The document data
|
* @param {object} data The document data
|
||||||
* @returns {InitDirectoryAction}
|
|
||||||
*/
|
*/
|
||||||
export const initDirectories = (lang, user, data) => {
|
export const initDirectories = (lang, user, data) => {
|
||||||
return {
|
return {
|
||||||
type: INIT_DIRECTORIES,
|
type: INIT_DIRECTORIES,
|
||||||
lang,
|
lang,
|
||||||
user,
|
user,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
import { INIT_DOCUMENTS } from './actionType';
|
import { INIT_DOCUMENTS } from "./actionType";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof INIT_DOCUMENTS, lang: string, directories: import('realm').Results<import('../../Models/Directory').Directory>, data: import('../../Models/Document').Document } } InitDocumentsAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init contact
|
* Init contact
|
||||||
* @param {string} lang The lang
|
* @param {string} lang The lang
|
||||||
* @param {Realm.Results<import('../../Models/Directory').Directory>} directories Directories
|
* @param {object} directories Directories
|
||||||
* @param {import('../../Models/Document').Document} data The document data
|
* @param {object} data The document data
|
||||||
*/
|
*/
|
||||||
export const initDocuments = (lang, directories, data) => {
|
export const initDocuments = (lang, directories, data) => {
|
||||||
return {
|
return {
|
||||||
type: INIT_DOCUMENTS,
|
type: INIT_DOCUMENTS,
|
||||||
lang,
|
lang,
|
||||||
directories,
|
directories,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import { INIT_FORMS } from './actionType';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof INIT_FORMS, data: import('../../Models/Form').Form } } InitFormAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init forms
|
|
||||||
* @param {import('../../Models/Form').Form} data The forms data
|
|
||||||
*/
|
|
||||||
export const initFormularies = data => {
|
|
||||||
return {
|
|
||||||
type: INIT_FORMS,
|
|
||||||
data,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
@ -1,31 +1,23 @@
|
||||||
import { EDIT_LOCALE, INIT_LOCALE } from './actionType';
|
import { INIT_LOCALE, EDIT_LOCALE } from "./actionType";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof INIT_LOCALE, data: string } } InitLocaleAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init locale
|
* Init locale
|
||||||
* @param {string} data The locale data
|
* @param {object} data The locale data
|
||||||
*/
|
*/
|
||||||
export const initLocale = data => {
|
export const initLocale = data => {
|
||||||
return {
|
return {
|
||||||
type: INIT_LOCALE,
|
type: INIT_LOCALE,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof EDIT_LOCALE, data: string } } EditLocaleAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit locale
|
* Edit locale
|
||||||
* @param {string} data The locale data
|
* @param {object} data The locale data
|
||||||
*/
|
*/
|
||||||
export const editLocale = data => {
|
export const editLocale = data => {
|
||||||
return {
|
return {
|
||||||
type: EDIT_LOCALE,
|
type: EDIT_LOCALE,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import { INIT_USERS } from './actionType';
|
import { INIT_USERS } from "./actionType";
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef { {type: typeof INIT_USERS, data: import('../../Models/User').User } } InitUserAction
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init users
|
* Init users
|
||||||
* @param {import('../../Models/User').User} data The users data
|
* @param {object} data The users data
|
||||||
*/
|
*/
|
||||||
export const initUsers = data => {
|
export const initUsers = data => {
|
||||||
return {
|
return {
|
||||||
type: INIT_USERS,
|
type: INIT_USERS,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
import { combineReducers, createStore } from 'redux';
|
import { createStore, combineReducers } from "redux";
|
||||||
|
|
||||||
import appReducer from './Reducers/AppReducer';
|
import appReducer from "./Reducers/AppReducer";
|
||||||
import contactsReducer from './Reducers/contacts';
|
import contactsReducer from "./Reducers/contacts";
|
||||||
import directoriesReducer from './Reducers/directories';
|
import documentsReducer from "./Reducers/documents";
|
||||||
import documentsReducer from './Reducers/documents';
|
import directoriesReducer from "./Reducers/directories";
|
||||||
import formulariesReducer from './Reducers/formularies';
|
import localesReducer from "./Reducers/locales";
|
||||||
import localesReducer from './Reducers/locales';
|
import usersReducer from "./Reducers/users";
|
||||||
import usersReducer from './Reducers/users';
|
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
app: appReducer,
|
app: appReducer,
|
||||||
contacts: contactsReducer,
|
contacts: contactsReducer,
|
||||||
documents: documentsReducer,
|
documents: documentsReducer,
|
||||||
directories: directoriesReducer,
|
directories: directoriesReducer,
|
||||||
locale: localesReducer,
|
locale: localesReducer,
|
||||||
users: usersReducer,
|
users: usersReducer
|
||||||
formularies: formulariesReducer,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const store = createStore(rootReducer);
|
export const store = createStore(rootReducer);
|
||||||
|
|
@ -1,108 +1,125 @@
|
||||||
import SyncController from '../../Controllers/SyncController';
|
import SyncController from "../../Controllers/SyncController";
|
||||||
// Database
|
// Database
|
||||||
import { SendBrochure, Setting } from '../../../Database';
|
import { Setting, SendBrochure } from '../../../Database';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
isSetup: false,
|
isSetup: false,
|
||||||
locale: 'fr',
|
locale: 'fr',
|
||||||
currentUser: {},
|
currentUser: {},
|
||||||
logged: false,
|
logged: false,
|
||||||
forceSync: false,
|
syncVersion: 0,
|
||||||
currentOpenedDoc: {},
|
forceSync: false,
|
||||||
HomeBtns: {},
|
currentOpenedDoc: {},
|
||||||
mainColor: '#D4021D',
|
ShowIsActive: 0,
|
||||||
|
HomeBtns: {},
|
||||||
|
mainColor: '#D4021D',
|
||||||
|
FormSelect1: {},
|
||||||
|
FormSelect2: {},
|
||||||
|
FormCheck: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
let saved;
|
let saved;
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'INIT':
|
case 'INIT':
|
||||||
let MainColor = Setting.get('MainColor');
|
let ShowIsActive = Setting.get('ShowIsActive');
|
||||||
saved = Setting.get('isSetup');
|
let MainColor = Setting.get('MainColor');
|
||||||
return {
|
let FormSelect1 = Setting.get('FormSelect1');
|
||||||
...state,
|
let FormSelect2 = Setting.get('FormSelect2');
|
||||||
isSetup:
|
let FormCheck = Setting.get('FormCheck');
|
||||||
saved === undefined ? false : saved?.value === 'true' ? true : false,
|
saved = Setting.get('isSetup');
|
||||||
mainColor:
|
return {
|
||||||
MainColor === undefined
|
...state,
|
||||||
? initialState.mainColor
|
isSetup: saved === undefined ? false : saved.value === "true" ? true : false,
|
||||||
: MainColor === null
|
ShowIsActive: ShowIsActive === undefined ? false : ShowIsActive.value,
|
||||||
? initialState.mainColor
|
mainColor: MainColor === undefined ? initialState.mainColor : MainColor === false ? initialState.mainColor : MainColor.value,
|
||||||
: MainColor?.value,
|
FormSelect1: FormSelect1 === undefined ? initialState.FormSelect1 : FormSelect1 === false ? initialState.FormSelect1 : JSON.parse(FormSelect1.value),
|
||||||
};
|
FormSelect2: FormSelect2 === undefined ? initialState.FormSelect2 : FormSelect2 === false ? initialState.FormSelect2 : JSON.parse(FormSelect2.value),
|
||||||
case 'INIT_HOME_BTNS': {
|
FormCheck: FormCheck === undefined ? initialState.FormCheck : FormCheck === false ? initialState.FormCheck : JSON.parse(FormCheck.value),
|
||||||
let HomeFolders = Setting.get('HomeFolders');
|
};
|
||||||
let Btns = HomeFolders ? JSON.parse(HomeFolders?.value) : [];
|
case 'INIT_HOME_BTNS': {
|
||||||
return {
|
let HomeFolders = Setting.get('HomeFolders');
|
||||||
...state,
|
let Btns = JSON.parse(HomeFolders.value);
|
||||||
HomeBtns: Btns,
|
return {
|
||||||
};
|
...state,
|
||||||
|
HomeBtns: Btns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 'SET_ISSETUP':
|
||||||
|
Setting.upsert({ key: 'isSetup', value: "true" });
|
||||||
|
saved = Setting.get('isSetup');
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isSetup: saved === undefined ? false : saved.value === "true" ? true : false
|
||||||
|
};
|
||||||
|
case 'SET_CURRENT_USER':
|
||||||
|
let user = false;
|
||||||
|
let isLogged = false;
|
||||||
|
if (action.data === false) {
|
||||||
|
Setting.delete('isLogged');
|
||||||
|
} else {
|
||||||
|
userObj = Setting.get('isLogged').value
|
||||||
|
user = JSON.parse(userObj)
|
||||||
|
isLogged = true
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentUser: user !== false ? user : initialState.currentUser,
|
||||||
|
logged: isLogged
|
||||||
|
};
|
||||||
|
// case 'UPDATE_LOCALE':
|
||||||
|
// let nxt;
|
||||||
|
// if (action.data === undefined) {
|
||||||
|
// const availableLocales = ['fr', 'en', 'de'];
|
||||||
|
// if (availableLocales.indexOf(i18n.locale) === availableLocales.length - 1) {
|
||||||
|
// nxt = availableLocales[0];
|
||||||
|
// } else {
|
||||||
|
// nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// nxt = action.data;
|
||||||
|
// }
|
||||||
|
// i18n.locale = nxt;
|
||||||
|
// Setting.upsert({ key: 'locale', value: nxt });
|
||||||
|
// let docsL = Document.getAll(Directory.getAll(
|
||||||
|
// state.currentUser.role,
|
||||||
|
// state.currentUser.authorizedFolders,
|
||||||
|
// false,
|
||||||
|
// nxt
|
||||||
|
// ));
|
||||||
|
// return {
|
||||||
|
// ...state,
|
||||||
|
// locale: nxt,
|
||||||
|
// directories: Directory.getAll(
|
||||||
|
// state.currentUser.role,
|
||||||
|
// state.currentUser.authorizedFolders,
|
||||||
|
// true,
|
||||||
|
// nxt
|
||||||
|
// ),
|
||||||
|
// documents: docsL.filter(item => item.lang === nxt),
|
||||||
|
// };
|
||||||
|
case 'SET_CURRENT_OPENED_DOC':
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
currentOpenedDoc: action.data
|
||||||
|
};
|
||||||
|
case 'UPDATE_VERSION':
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
syncVersion: action.data,
|
||||||
|
};
|
||||||
|
case 'UPDATE_SHOW_IS_ACTIVE':
|
||||||
|
SyncController.updateShowIsActive(action.data);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
ShowIsActive: action.data,
|
||||||
|
};
|
||||||
|
case 'SEND_BROCHURE':
|
||||||
|
SendBrochure.add(action.data);
|
||||||
|
return state;
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
case 'SET_ISSETUP':
|
}
|
||||||
Setting.upsert({ key: 'isSetup', value: 'true' });
|
|
||||||
saved = Setting.get('isSetup');
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
isSetup:
|
|
||||||
saved === undefined ? false : saved?.value === 'true' ? true : false,
|
|
||||||
};
|
|
||||||
case 'SET_CURRENT_USER':
|
|
||||||
let user = false;
|
|
||||||
let isLogged = false;
|
|
||||||
if (action.data === false) {
|
|
||||||
Setting.delete('isLogged');
|
|
||||||
} else {
|
|
||||||
let userObj = Setting.get('isLogged');
|
|
||||||
user = userObj ? JSON.parse(userObj?.value) : false;
|
|
||||||
isLogged = true;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
currentUser: user !== false ? user : initialState.currentUser,
|
|
||||||
logged: isLogged,
|
|
||||||
};
|
|
||||||
// case 'UPDATE_LOCALE':
|
|
||||||
// let nxt;
|
|
||||||
// if (action.data === undefined) {
|
|
||||||
// const availableLocales = ['fr', 'en', 'de'];
|
|
||||||
// if (availableLocales.indexOf(i18n.locale) === availableLocales.length - 1) {
|
|
||||||
// nxt = availableLocales[0];
|
|
||||||
// } else {
|
|
||||||
// nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// nxt = action.data;
|
|
||||||
// }
|
|
||||||
// i18n.locale = nxt;
|
|
||||||
// Setting.upsert({ key: 'locale', value: nxt });
|
|
||||||
// let docsL = Document.getAll(Directory.getAll(
|
|
||||||
// state.currentUser.role,
|
|
||||||
// state.currentUser.authorizedFolders,
|
|
||||||
// false,
|
|
||||||
// nxt
|
|
||||||
// ));
|
|
||||||
// return {
|
|
||||||
// ...state,
|
|
||||||
// locale: nxt,
|
|
||||||
// directories: Directory.getAll(
|
|
||||||
// state.currentUser.role,
|
|
||||||
// state.currentUser.authorizedFolders,
|
|
||||||
// true,
|
|
||||||
// nxt
|
|
||||||
// ),
|
|
||||||
// documents: docsL.filter(item => item.lang === nxt),
|
|
||||||
// };
|
|
||||||
case 'SET_CURRENT_OPENED_DOC':
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
currentOpenedDoc: action.data,
|
|
||||||
};
|
|
||||||
case 'SEND_BROCHURE':
|
|
||||||
SendBrochure.add(action.data);
|
|
||||||
return state;
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
@ -1,38 +1,32 @@
|
||||||
import {
|
import { INIT_CONTACT, ADD_CONTACT, EDIT_CONTACT, DELETE_CONTACT } from "../Actions/actionType";
|
||||||
DELETE_CONTACT,
|
|
||||||
INIT_CONTACT,
|
|
||||||
SET_CONTACT,
|
|
||||||
} from '../Actions/actionType';
|
|
||||||
// Models
|
// Models
|
||||||
import { Contact } from '../../../Database';
|
import { Contact } from "../../../Database";
|
||||||
|
|
||||||
/** @type {import('../../Models/Contact').Contact[]} */
|
|
||||||
const initialState = [];
|
const initialState = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/contacts').InitContactAction|import('../Actions/contacts').SetContactAction|import('../Actions/contacts').DeleteContactAction} action
|
|
||||||
* @returns {import('realm').Results<import('../../Models/Contact').Contact>}
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_CONTACT: {
|
case INIT_CONTACT: {
|
||||||
return Contact.getAllEditable(action.currentUser.id);
|
return Contact.getByUser(action.currentUser.id);
|
||||||
}
|
}
|
||||||
case SET_CONTACT: {
|
case ADD_CONTACT: {
|
||||||
action.data.app_user_id = action.currentUser.id;
|
action.data.user_id = action.currentUser.id;
|
||||||
Contact.set(action.data);
|
Contact.add(action.data);
|
||||||
return Contact.getAllEditable(action.currentUser.id);
|
return Contact.getByUser(action.currentUser.id);
|
||||||
}
|
}
|
||||||
case DELETE_CONTACT: {
|
case EDIT_CONTACT: {
|
||||||
Contact.delete(action.currentUser.id, action.uuid);
|
Contact.update(action.data);
|
||||||
return Contact.getAllEditable(action.currentUser.id);
|
return Contact.getByUser(action.currentUser.id);
|
||||||
}
|
}
|
||||||
|
case DELETE_CONTACT: {
|
||||||
|
Contact.delete(action.id);
|
||||||
|
return Contact.getByUser(action.currentUser.id);
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,32 @@
|
||||||
import { Directory } from '../../../Database';
|
import { INIT_DIRECTORIES } from "../Actions/actionType";
|
||||||
import { INIT_DIRECTORIES } from '../Actions/actionType';
|
|
||||||
// Models
|
// Models
|
||||||
|
import { Directory } from "../../../Database";
|
||||||
|
|
||||||
const initialState = {
|
const initialState = [];
|
||||||
/** @type {Realm.Results<import('../../Models/Directory').Directory>} */
|
|
||||||
global: [],
|
|
||||||
/** @type {Realm.Results<import('../../Models/Directory').Directory>} */
|
|
||||||
treeview: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/directories').InitDirectoryAction} action
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_DIRECTORIES: {
|
case INIT_DIRECTORIES: {
|
||||||
return {
|
return {
|
||||||
global: Directory.getAll(
|
global: Directory.getAll(
|
||||||
action.user.role,
|
action.user.role,
|
||||||
action.user.authorizedFolders,
|
action.user.authorizedFolders,
|
||||||
false,
|
false,
|
||||||
action.lang,
|
action.lang
|
||||||
),
|
),
|
||||||
treeview: Directory.getAll(
|
treeview: Directory.getAll(
|
||||||
action.user.role,
|
action.user.role,
|
||||||
action.user.authorizedFolders,
|
action.user.authorizedFolders,
|
||||||
true,
|
true,
|
||||||
action.lang,
|
action.lang
|
||||||
),
|
)
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,23 @@
|
||||||
import { INIT_DOCUMENTS } from '../Actions/actionType';
|
import { INIT_DOCUMENTS } from "../Actions/actionType";
|
||||||
// Models
|
// Models
|
||||||
import { Document } from '../../../Database';
|
import { Document } from "../../../Database";
|
||||||
|
|
||||||
/** @type {import('../../Models/Document').Document[]} */
|
|
||||||
const initialState = [];
|
const initialState = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/documents').InitDocumentsAction} action
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_DOCUMENTS: {
|
case INIT_DOCUMENTS: {
|
||||||
const docs = Document.getAll(action.directories);
|
let docs = Document.getAll(action.directories);
|
||||||
if (docs.length === 0) {
|
if (docs.length === 0) {
|
||||||
return state;
|
return state
|
||||||
}
|
}
|
||||||
return docs.filter(item => item.lang === action.lang);
|
return docs.filter(item => item.lang === action.lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
import { INIT_FORMS } from '../Actions/actionType';
|
|
||||||
// Models
|
|
||||||
import { Form } from '../../../Database';
|
|
||||||
|
|
||||||
const initialState = {
|
|
||||||
/** @type {Realm.Results<import('../../Models/Form').Form>} */
|
|
||||||
users: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/formularies').InitFormAction} action
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
|
||||||
switch (action.type) {
|
|
||||||
case INIT_FORMS: {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
forms: Form.getAll(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default reducer;
|
|
||||||
|
|
@ -1,55 +1,45 @@
|
||||||
import { EDIT_LOCALE, INIT_LOCALE } from '../Actions/actionType';
|
import { INIT_LOCALE, EDIT_LOCALE } from "../Actions/actionType";
|
||||||
// Models
|
// Models
|
||||||
import { Setting } from '../../../Database';
|
import { Setting } from "../../../Database";
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../../I18n';
|
import i18n from "../../../I18n";
|
||||||
|
|
||||||
const initialState = {
|
const initialState = [];
|
||||||
locale: 'fr',
|
|
||||||
};
|
|
||||||
const availableLocales = ['fr', 'en', 'de'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/locales').InitLocaleAction|import('../Actions/locales').EditLocaleAction} action
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_LOCALE: {
|
case INIT_LOCALE: {
|
||||||
const savedLocale = Setting.get('locale');
|
const savedLocale = Setting.get('locale');
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
locale: savedLocale === null ? initialState.locale : savedLocale.value,
|
locale: savedLocale === undefined ? 'fr' : savedLocale === false ? 'fr' : savedLocale.value
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
case EDIT_LOCALE: {
|
|
||||||
let nxt;
|
|
||||||
if (action.data === undefined) {
|
|
||||||
if (
|
|
||||||
availableLocales.indexOf(i18n.locale) ===
|
|
||||||
availableLocales.length - 1
|
|
||||||
) {
|
|
||||||
nxt = availableLocales[0];
|
|
||||||
} else {
|
|
||||||
nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
nxt = action.data;
|
|
||||||
}
|
|
||||||
i18n.locale = nxt;
|
|
||||||
Setting.upsert({ key: 'locale', value: nxt });
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
locale: nxt,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
case EDIT_LOCALE: {
|
||||||
return state;
|
let nxt;
|
||||||
|
if (action.data === undefined) {
|
||||||
|
const availableLocales = ['fr', 'en', 'de'];
|
||||||
|
if (availableLocales.indexOf(i18n.locale) === availableLocales.length - 1) {
|
||||||
|
nxt = availableLocales[0];
|
||||||
|
} else {
|
||||||
|
nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nxt = action.data;
|
||||||
|
}
|
||||||
|
i18n.locale = nxt;
|
||||||
|
Setting.upsert({ key: 'locale', value: nxt });
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
locale: nxt,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,22 @@
|
||||||
import { INIT_USERS } from '../Actions/actionType';
|
import { INIT_USERS } from "../Actions/actionType";
|
||||||
// Models
|
// Models
|
||||||
import { User } from '../../../Database';
|
import { User } from "../../../Database";
|
||||||
|
|
||||||
const initialState = {
|
const initialState = [];
|
||||||
/** @type {Realm.Results<import('../../Models/User').User>} */
|
|
||||||
users: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {typeof initialState} state
|
|
||||||
* @param {import('../Actions/users').InitUserAction} action
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_USERS: {
|
case INIT_USERS: {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
users: User.getAll(),
|
users: User.getAll(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
return state;
|
return state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,14 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
import {
|
||||||
|
View,
|
||||||
|
ScrollView,
|
||||||
|
TouchableOpacity,
|
||||||
|
Text,
|
||||||
|
Image
|
||||||
|
} from 'react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { initDocuments } from '../Store/Actions/documents';
|
||||||
// Treeview
|
// Treeview
|
||||||
import TreeView from 'react-native-animated-tree-view';
|
import TreeView from 'react-native-animated-tree-view';
|
||||||
// Icon
|
// Icon
|
||||||
|
|
@ -12,72 +19,72 @@ import arrowDown from '../../Resources/assets/img/arrow_down.png';
|
||||||
import styles from '../../Resources/Styles/DirectoriesStyle';
|
import styles from '../../Resources/Styles/DirectoriesStyle';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
documents: state.documents,
|
documents: state.documents,
|
||||||
directories: state.directories,
|
directories: state.directories,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
mainColor: state.app.mainColor,
|
mainColor: state.app.mainColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class DirectoriesScreen extends React.Component {
|
class DirectoriesScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
documents: [],
|
documents: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { folder } = this.props.route.params;
|
const { folder } = this.props.route.params;
|
||||||
let documentList = this.state.documents.map(document => {
|
let documentList = this.state.documents.map(document => {
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={document.id.toString()}
|
key={document.id.toString()}
|
||||||
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
||||||
onPress={() => this.openDocument(document)}>
|
onPress={() => this.openDocument(document)}>
|
||||||
{document.type === 'pdf' ? (
|
{document.type === 'pdf' ? (
|
||||||
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
||||||
) : (
|
) : (
|
||||||
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
||||||
)}
|
)}
|
||||||
<Text style={styles.fileTxt}>{document.title}</Text>
|
<Text style={styles.fileTxt}>{document.title}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View
|
<View
|
||||||
style={{ width: 290, borderRightWidth: 1, borderColor: 'lightgrey' }}>
|
style={{ width: 290, borderRightWidth: 1, borderColor: 'lightgrey' }}>
|
||||||
<TreeView
|
<TreeView
|
||||||
data={folder}
|
data={folder}
|
||||||
leftImage={{}}
|
leftImage={{}}
|
||||||
rightImage={{ uri: Image.resolveAssetSource(arrowDown).uri }}
|
rightImage={{ uri: Image.resolveAssetSource(arrowDown).uri }}
|
||||||
containerStyle={styles.treeviewContainer}
|
containerStyle={styles.treeviewContainer}
|
||||||
onClick={folder => {
|
onClick={folder => {
|
||||||
this.setState({
|
this.setState({
|
||||||
documents: this.props.documents.filter(
|
documents: this.props.documents.filter(
|
||||||
tmp => tmp.directory === folder.id,
|
tmp => tmp.directory === folder.id,
|
||||||
),
|
)
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<ScrollView style={styles.scrollview}>
|
<ScrollView style={styles.scrollview}>
|
||||||
<View style={styles.filesContainer}>{documentList}</View>
|
<View style={styles.filesContainer}>{documentList}</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
openDocument(document) {
|
openDocument(document) {
|
||||||
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
||||||
if (document.type === 'pdf') {
|
if (document.type === 'pdf') {
|
||||||
this.props.navigation.navigate('PDFScreen', { uuid: document.uuid });
|
this.props.navigation.navigate('PDFScreen', { uuid: document.uuid });
|
||||||
} else if (document.type === 'mp4') {
|
} else if (document.type === 'mp4') {
|
||||||
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
||||||
} else {
|
} else {
|
||||||
console.error('Type de document Inconnu');
|
console.log('Inconnu');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps)(DirectoriesScreen);
|
export default connect(mapStateToProps)(DirectoriesScreen);
|
||||||
|
|
|
||||||
|
|
@ -1,151 +1,125 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { View, ImageBackground, TouchableOpacity, Text, Image } from 'react-native';
|
||||||
Image,
|
// Common Styles
|
||||||
ImageBackground,
|
|
||||||
Text,
|
|
||||||
TouchableOpacity,
|
|
||||||
View,
|
|
||||||
} from 'react-native';
|
|
||||||
// Common Styles
|
|
||||||
import commonStyles from '../../Resources/CommonStyles';
|
import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { initDocuments } from '../Store/Actions/documents';
|
||||||
import { initContact } from '../Store/Actions/contacts';
|
import { initContact } from '../Store/Actions/contacts';
|
||||||
import { initDirectories } from '../Store/Actions/directories';
|
import { initDirectories } from '../Store/Actions/directories';
|
||||||
import { initDocuments } from '../Store/Actions/documents';
|
// SplashScreen
|
||||||
// SplashScreen
|
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/HomeStyle';
|
import styles from '../../Resources/Styles/HomeStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../I18n';
|
import i18n from "../../I18n";
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
// NetInfo
|
||||||
|
import NetInfo from '@react-native-community/netinfo';
|
||||||
// Controller
|
// Controller
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
btns: state.app.HomeBtns,
|
btns: state.app.HomeBtns,
|
||||||
directories: state.directories,
|
directories: state.directories,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
currentUser: state.app.currentUser,
|
currentUser: state.app.currentUser
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
||||||
initDocuments: (lang, directories) =>
|
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
||||||
dispatch(initDocuments(lang, directories)),
|
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HomeScreen extends React.Component {
|
class HomeScreen extends React.Component {
|
||||||
state = {
|
|
||||||
lastSyncCall: '1970-01-01',
|
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
state = {
|
||||||
if (!SyncController.isInstalled()) {
|
lastSyncCall: '1970-01-01',
|
||||||
return this.openSync();
|
};
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
if (!SyncController.isInstalled()) {
|
||||||
|
return this.openSync();
|
||||||
|
}
|
||||||
|
this.props.initBtns();
|
||||||
|
this.props.initContact(this.props.currentUser);
|
||||||
|
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
||||||
|
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||||
|
|
||||||
|
SplashScreen.hideAsync();
|
||||||
}
|
}
|
||||||
this.props.initBtns();
|
|
||||||
console.debug(this.props.currentUser);
|
|
||||||
this.props.initContact(this.props.currentUser);
|
|
||||||
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
|
||||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
|
||||||
|
|
||||||
SplashScreen.hideAsync();
|
unsubscribe() {
|
||||||
}
|
NetInfo.addEventListener(state => {
|
||||||
|
if (state.isConnected === true) {
|
||||||
|
let seconds =
|
||||||
|
Math.abs(new Date(this.state.lastSyncCall) - Date.now()) / 1000;
|
||||||
|
if (seconds > 30) {
|
||||||
|
this.setState({ lastSyncCall: Date.now() });
|
||||||
|
SyncController.needSync(this.openSync.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openSync() {
|
openSync() {
|
||||||
this.props.navigation.navigate('SyncScreen', { forceSync: true });
|
this.props.navigation.navigate('SyncScreen', { forceSync: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
i18n.locale = this.props.locale;
|
i18n.locale = this.props.locale;
|
||||||
return (
|
return (
|
||||||
<ImageBackground
|
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background} resizeMode='cover'>
|
||||||
source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }}
|
<View style={styles.container}>
|
||||||
style={commonStyles.background}
|
{this.renderBtns()}
|
||||||
resizeMode="cover">
|
<TouchableOpacity
|
||||||
<View style={styles.container}>
|
key={'OnlyVideos'}
|
||||||
{this.renderBtns()}
|
onPress={() => {
|
||||||
<TouchableOpacity
|
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||||
key={'OnlyVideos'}
|
this.props.navigation.navigate('OnlyVideosScreen');
|
||||||
onPress={() => {
|
}}
|
||||||
this.props.initDocuments(
|
style={styles.button}>
|
||||||
this.props.locale,
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||||
this.props.directories.global,
|
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
||||||
);
|
</TouchableOpacity>
|
||||||
this.props.navigation.navigate('OnlyVideosScreen');
|
<TouchableOpacity key={'Contacts'} onPress={() => this.props.navigation.navigate('ContactScreen')} style={styles.button}>
|
||||||
}}
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||||
style={styles.button}>
|
<Text style={styles.btnTxt}>{i18n.t('global.contacts')}</Text>
|
||||||
<Image
|
</TouchableOpacity>
|
||||||
source={{
|
</View>
|
||||||
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
</ImageBackground>
|
||||||
}}
|
);
|
||||||
style={styles.btnImg}
|
}
|
||||||
/>
|
|
||||||
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
|
||||||
key={'Contacts'}
|
|
||||||
onPress={() => {
|
|
||||||
this.props.initDocuments(
|
|
||||||
this.props.locale,
|
|
||||||
this.props.directories.global,
|
|
||||||
);
|
|
||||||
this.props.navigation.navigate('ContactScreen');
|
|
||||||
}}
|
|
||||||
style={styles.button}>
|
|
||||||
<Image
|
|
||||||
source={{
|
|
||||||
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
|
||||||
}}
|
|
||||||
style={styles.btnImg}
|
|
||||||
/>
|
|
||||||
<Text style={styles.btnTxt}>{i18n.t('global.contacts')}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
</ImageBackground>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBtns() {
|
renderBtns() {
|
||||||
let locale = this.props.locale;
|
let locale = this.props.locale;
|
||||||
let objBtns = this.props.btns;
|
let objBtns = this.props.btns;
|
||||||
let array = Object.keys(objBtns).map(function (key) {
|
let array = Object.keys(objBtns).map(function (key) { return objBtns[key]; });
|
||||||
return objBtns[key];
|
return array.map((item, index) => {
|
||||||
});
|
let names = JSON.parse(item.name);
|
||||||
return array.map((item, index) => {
|
let name = (locale in names) ? names[locale] : names.fr;
|
||||||
let names = JSON.parse(item.name);
|
return (
|
||||||
let name = locale in names ? names[locale] : names.fr;
|
<TouchableOpacity key={index} onPress={() => this.openFolder(item.id)} style={styles.button}>
|
||||||
return (
|
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
||||||
<TouchableOpacity
|
<Text style={styles.btnTxt}>{name}</Text>
|
||||||
key={index}
|
</TouchableOpacity>
|
||||||
onPress={() => this.openFolder(item.id)}
|
)
|
||||||
style={styles.button}>
|
});
|
||||||
<Image
|
}
|
||||||
source={{
|
|
||||||
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
|
||||||
}}
|
|
||||||
style={styles.btnImg}
|
|
||||||
/>
|
|
||||||
<Text style={styles.btnTxt}>{name}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
openFolder(id) {
|
openFolder(id) {
|
||||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||||
const folder = this.props.directories.treeview.filter(tmp => tmp.id === id);
|
const folder = this.props.directories.treeview.filter(tmp => tmp.id === id);
|
||||||
this.props.navigation.navigate('DirectoriesScreen', { folder: folder });
|
this.props.navigation.navigate('DirectoriesScreen', { folder: folder });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(HomeScreen);
|
export default connect(mapStateToProps, mapDispatchToProps)(HomeScreen);
|
||||||
|
|
@ -1,219 +1,191 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { ImageBackground, View, Image, Text, TextInput, Button, Alert } from 'react-native';
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
Image,
|
|
||||||
ImageBackground,
|
|
||||||
Text,
|
|
||||||
TextInput,
|
|
||||||
View,
|
|
||||||
} from 'react-native';
|
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from '@sentry/react-native';
|
import * as Sentry from "@sentry/react-native";
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Helpers
|
// Helpers
|
||||||
import Helpers from '../Lib/Helpers';
|
import Helpers from '../Lib/Helpers';
|
||||||
// Lodash
|
// Lodash
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
// Common Styles
|
// Common Styles
|
||||||
import commonStyles from '../../Resources/CommonStyles';
|
import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/InstallStyle';
|
import styles from '../../Resources/Styles/InstallStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../I18n';
|
import i18n from "../../I18n";
|
||||||
// Controller
|
// Controller
|
||||||
import InstallController from '../Controllers/InstallController';
|
import InstallController from '../Controllers/InstallController';
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
// Database
|
// Database
|
||||||
import { Setting, User } from '../../Database';
|
import { User, Setting } from '../../Database';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
isSetup: state.app.isSetup,
|
isSetup: state.app.isSetup,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
||||||
init: () => dispatch({ type: 'INIT' }),
|
init: () => dispatch({ type: 'INIT' })
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
class InstallScreen extends React.Component {
|
class InstallScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
processing: false,
|
processing: false,
|
||||||
txtStep: '',
|
txtStep: '',
|
||||||
url: '',
|
url: "",
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
SplashScreen.hideAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
i18n.locale = this.props.locale;
|
|
||||||
return (
|
|
||||||
<ImageBackground
|
|
||||||
source={require('../../Resources/assets/img/background_ldc.png')}
|
|
||||||
style={commonStyles.background}>
|
|
||||||
<View style={styles.container}>
|
|
||||||
<Image
|
|
||||||
source={require('../../Resources/assets/img/logo-square-ldc.png')}
|
|
||||||
style={styles.logo}
|
|
||||||
/>
|
|
||||||
<View style={styles.actions}>
|
|
||||||
<TextInput
|
|
||||||
keyboardType="url"
|
|
||||||
autoCapitalize="none"
|
|
||||||
style={commonStyles.textInput}
|
|
||||||
placeholder={i18n.t('install.enter_url')}
|
|
||||||
onChangeText={newText => this.setState({ url: newText })}
|
|
||||||
value={this.state.url}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
disabled={this.state.processing}
|
|
||||||
color={'#D4021D'}
|
|
||||||
title={i18n.t('install.install')}
|
|
||||||
onPress={() => {
|
|
||||||
if (this.state.url.length === 0) {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('alert.error'),
|
|
||||||
i18n.t('install.enter_url'),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// * Ignore ths check on dev, just install.
|
|
||||||
if (__DEV__ || Helpers.isUrlValid(this.state.url)) {
|
|
||||||
this.install();
|
|
||||||
} else {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('alert.error'),
|
|
||||||
i18n.t('install.url_invalid'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.actions}>
|
|
||||||
<Text>{this.state.txtStep}</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</ImageBackground>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async install() {
|
|
||||||
let url = this.state.url.toLowerCase();
|
|
||||||
Setting.upsert({ key: 'bo_url', value: url });
|
|
||||||
const isConnected = await SyncController.checkConnection()
|
|
||||||
.then(state => {
|
|
||||||
console.debug(state.isConnected);
|
|
||||||
return state.isConnected;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if (!isConnected) {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('global.warning'),
|
|
||||||
i18n.t('error.must_be_connected_internet_sync'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this.setState({
|
|
||||||
processing: true,
|
componentDidMount() {
|
||||||
txtStep: i18n.t('install.get_app_setting'),
|
SplashScreen.hideAsync();
|
||||||
});
|
}
|
||||||
const toDL = await InstallController.getConfig(url)
|
|
||||||
.then(response => {
|
render() {
|
||||||
let toDL = [];
|
i18n.locale = this.props.locale;
|
||||||
if (response.data) {
|
return (
|
||||||
if (response.data.status === 'OK') {
|
<ImageBackground source={require('../../Resources/assets/img/background_ldc.png')} style={commonStyles.background}>
|
||||||
const rootUrl = url.substring(0, url.lastIndexOf('/'));
|
<View style={styles.container}>
|
||||||
_.forEach(response.data.datas, function (value, key) {
|
<Image source={require('../../Resources/assets/img/logo-square-ldc.png')} style={styles.logo} />
|
||||||
switch (key) {
|
<View style={styles.actions}>
|
||||||
case 'MainColor':
|
<TextInput
|
||||||
Setting.upsert({ key: key, value: value });
|
keyboardType='url'
|
||||||
break;
|
autoCapitalize='none'
|
||||||
case 'SquaredLogo':
|
style={commonStyles.textInput}
|
||||||
case 'RectangleLogo':
|
placeholder={i18n.t("install.enter_url")}
|
||||||
case 'BackgroundImage':
|
onChangeText={(newText) => this.setState({ url: newText })}
|
||||||
case 'HomeButtonImage':
|
value={this.state.url}
|
||||||
toDL.push({
|
/>
|
||||||
source: rootUrl + '/' + value,
|
<Button
|
||||||
dest: FileSystem.documentDirectory + key + '.png',
|
disabled={this.state.processing}
|
||||||
});
|
color={'#D4021D'}
|
||||||
break;
|
title={ i18n.t('install.install')}
|
||||||
}
|
onPress={() => {
|
||||||
});
|
if (this.state.url.length === 0) {
|
||||||
return toDL;
|
Alert.alert(i18n.t("alert.error"), i18n.t("install.enter_url"));
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(
|
if (Helpers.isUrlValid(this.state.url)) {
|
||||||
i18n.t('alert.error'),
|
this.install();
|
||||||
i18n.t('error.error_has_occurred'),
|
} else {
|
||||||
);
|
Alert.alert(i18n.t("alert.error"), i18n.t("install.url_invalid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.actions}>
|
||||||
|
<Text>
|
||||||
|
{this.state.txtStep}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ImageBackground>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async install() {
|
||||||
|
let url = this.state.url.toLowerCase();
|
||||||
|
Setting.upsert({ key: 'bo_url', value: url });
|
||||||
|
const isConnected = await SyncController.checkConnection().then(state => {
|
||||||
|
//console.log(state.isConnected)
|
||||||
|
return state.isConnected
|
||||||
|
}).catch(error => {
|
||||||
|
//console.log(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
|
if (!isConnected) {
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('global.warning'),
|
||||||
|
i18n.t('error.must_be_connected_internet_sync')
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
})
|
this.setState({ processing: true, txtStep: i18n.t("install.get_app_setting") });
|
||||||
.catch(function (error) {
|
const toDL = await InstallController.getConfig(url).then(response => {
|
||||||
Sentry.captureException(error);
|
let toDL = [];
|
||||||
console.error(error);
|
if (response.data) {
|
||||||
Alert.alert(i18n.t('alert.error'), i18n.t('error.error_has_occurred'));
|
if (response.data.status === "OK") {
|
||||||
return false;
|
_.forEach(response.data.datas, function (value, key) {
|
||||||
});
|
switch (key) {
|
||||||
if (!toDL) {
|
case "MainColor":
|
||||||
this.setState({ processing: false, txtStep: '' });
|
case "AppStoreUUID":
|
||||||
return false;
|
case "FormSelect1":
|
||||||
}
|
case "FormSelect2":
|
||||||
for await (const file of toDL) {
|
case "FormCheck":
|
||||||
await FileSystem.downloadAsync(file.source, file.dest)
|
Setting.upsert({ key: key, value: value });
|
||||||
.then(({ uri }) => {
|
break;
|
||||||
console.debug('Finished downloading to ', uri);
|
case "SquaredLogo":
|
||||||
})
|
case "RectangleLogo":
|
||||||
.catch(error => {
|
case "BackgroundImage":
|
||||||
Alert.alert(
|
case "HomeButtonImage":
|
||||||
i18n.t('alert.error'),
|
toDL.push({
|
||||||
i18n.t('install.resource_dl_error') + file.dest,
|
source: url + "/" + value,
|
||||||
);
|
dest: FileSystem.documentDirectory + key + '.png'
|
||||||
console.error(error);
|
});
|
||||||
return false;
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return toDL;
|
||||||
|
} else {
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).catch(function (error) {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
if (!toDL) {
|
||||||
|
this.setState({ processing: false, txtStep: "" });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for await (const file of toDL) {
|
||||||
|
await FileSystem.downloadAsync(
|
||||||
|
file.source,
|
||||||
|
file.dest
|
||||||
|
)
|
||||||
|
.then(({ uri }) => {
|
||||||
|
console.log('Finished downloading to ', uri);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
Alert.alert(i18n.t("alert.error"), i18n.t("install.resource_dl_error") + file.dest);
|
||||||
|
console.error(error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({ txtStep: i18n.t('install.get_content_setting') });
|
this.setState({ txtStep: i18n.t("install.get_content_setting") });
|
||||||
if (InstallController.getAppConfig(url)) {
|
if (InstallController.getAppConfig(url)) {
|
||||||
// getUsers
|
// getUsers
|
||||||
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
||||||
const resUsers = await SyncController.getUsers()
|
const resUsers = await SyncController.getUsers().then(res => {
|
||||||
.then(res => {
|
User.clear();
|
||||||
User.clear();
|
return res.data;
|
||||||
return res.data;
|
}).catch(error => {
|
||||||
})
|
console.log(error);
|
||||||
.catch(error => {
|
Alert.alert(
|
||||||
console.error(error);
|
i18n.t('error.error'),
|
||||||
Alert.alert(
|
i18n.t('error.error_has_occurred')
|
||||||
i18n.t('error.error'),
|
);
|
||||||
i18n.t('error.error_has_occurred'),
|
return
|
||||||
);
|
});
|
||||||
return;
|
resUsers.forEach(user => {
|
||||||
});
|
User.add(user);
|
||||||
resUsers.forEach(user => {
|
});
|
||||||
User.add(user);
|
this.props.init();
|
||||||
});
|
this.props.setIsSetup();
|
||||||
this.props.init();
|
this.props.navigation.navigate('LoginScreen');
|
||||||
this.props.setIsSetup();
|
}
|
||||||
this.props.navigation.navigate('LoginScreen');
|
this.setState({ processing: false, txtStep: "" });
|
||||||
}
|
}
|
||||||
this.setState({ processing: false, txtStep: '' });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(InstallScreen);
|
export default connect(mapStateToProps, mapDispatchToProps)(InstallScreen);
|
||||||
|
|
@ -1,296 +1,151 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { View, ImageBackground, TextInput, Button, Image, Alert } from 'react-native';
|
||||||
Alert,
|
|
||||||
Button,
|
|
||||||
Image,
|
|
||||||
ImageBackground,
|
|
||||||
TextInput,
|
|
||||||
View,
|
|
||||||
} from 'react-native';
|
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Common Styles
|
// Common Styles
|
||||||
import commonStyles from '../../Resources/CommonStyles';
|
import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/LoginStyle';
|
import styles from '../../Resources/Styles/LoginStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../I18n';
|
import i18n from "../../I18n";
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
// Controller
|
// Controller
|
||||||
import LoginController from '../Controllers/LoginController';
|
import LoginController from '../Controllers/LoginController';
|
||||||
// Database
|
// Database
|
||||||
import _ from 'lodash';
|
import { Setting } from '../../Database';
|
||||||
import { Setting, User } from '../../Database';
|
|
||||||
import InstallController from '../Controllers/InstallController';
|
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
app: state.app,
|
app: state.app,
|
||||||
users: state.users.users,
|
users: state.users.users,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
mainColor: state.app.mainColor,
|
mainColor: state.app.mainColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
setCurrentUser: () => dispatch({ type: 'SET_CURRENT_USER' }),
|
setCurrentUser: () => dispatch({ type: 'SET_CURRENT_USER' }),
|
||||||
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
};
|
||||||
init: () => dispatch({ type: 'INIT' }),
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoginScreen extends React.Component {
|
class LoginScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
syncWorking: false,
|
login: '',
|
||||||
login: '',
|
password: '',
|
||||||
password: '',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (SyncController.isLogged()) {
|
if (SyncController.isLogged()) {
|
||||||
this.props.setCurrentUser(false);
|
this.props.setCurrentUser(false);
|
||||||
}
|
|
||||||
SplashScreen.hideAsync();
|
|
||||||
this.syncUsersIfPossibleAsync();
|
|
||||||
this.syncAppConfigIfPossibleAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<ImageBackground
|
|
||||||
source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }}
|
|
||||||
style={commonStyles.background}>
|
|
||||||
<View style={styles.container}>
|
|
||||||
<Image
|
|
||||||
source={{ uri: FileSystem.documentDirectory + 'SquaredLogo.png' }}
|
|
||||||
style={styles.logo}
|
|
||||||
/>
|
|
||||||
<View>
|
|
||||||
<TextInput
|
|
||||||
style={styles.text}
|
|
||||||
placeholder={i18n.t('login_s.username')}
|
|
||||||
value={this.state.login}
|
|
||||||
onChangeText={text => this.setState({ login: text })}
|
|
||||||
autoCapitalize={'none'}
|
|
||||||
autoCorrect={false}
|
|
||||||
keyboardType={'email-address'}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
style={styles.text}
|
|
||||||
placeholder={i18n.t('login_s.password')}
|
|
||||||
value={this.state.password}
|
|
||||||
onChangeText={text => this.setState({ password: text })}
|
|
||||||
secureTextEntry={true}
|
|
||||||
autoCapitalize={'none'}
|
|
||||||
autoCorrect={false}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
disabled={this.state.syncWorking}
|
|
||||||
title={i18n.t('global.login')}
|
|
||||||
onPress={() =>
|
|
||||||
this.login(this.state.login.toLowerCase(), this.state.password)
|
|
||||||
}
|
|
||||||
color={!this.state.syncWorking ? this.props.mainColor : 'gray'}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</ImageBackground>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async login(login, password) {
|
|
||||||
if (login === '' || password === '') {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('global.warning'),
|
|
||||||
i18n.t('error.must_fill_login_fields'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/** @type {Array<import('../Models/User').User>} */
|
|
||||||
const users = this.props.users;
|
|
||||||
if (users.length === 0) {
|
|
||||||
Alert.alert(i18n.t('global.warning'), i18n.t('login_s.missing_users'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const user = users.find(tmp => tmp.email === login);
|
|
||||||
if (user === undefined) {
|
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const verified = await LoginController.verify(user, password);
|
|
||||||
if (!verified) {
|
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const isConnected = await SyncController.checkConnection()
|
|
||||||
.then(state => {
|
|
||||||
console.debug(state.isConnected);
|
|
||||||
return state.isConnected;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.debug(error);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
const lastUser = Setting.get('lastUser');
|
|
||||||
|
|
||||||
// * Si on est sur une installation
|
|
||||||
if (lastUser === null) {
|
|
||||||
console.debug('New Install');
|
|
||||||
// * Si la tablette est connectée à internet pour forcer la synchro
|
|
||||||
if (!isConnected) {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.tablet_not_connected_internet'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return this.loginAction(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
// * On a deja eu une install
|
|
||||||
|
|
||||||
// * Si on a une précédente connexion
|
|
||||||
if (lastUser.value === user.id.toString()) {
|
|
||||||
console.debug('Was previously logged in');
|
|
||||||
return this.loginAction(user);
|
|
||||||
}
|
|
||||||
// Si le user precedent est different du user courant
|
|
||||||
// Si user !== last user && last user not synced
|
|
||||||
if (!SyncController.isSynced(user.id)) {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.tablet_not_synced_last_user'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Si la tablette est connectée à internet pour forcer la synchro
|
|
||||||
if (!isConnected) {
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.tablet_not_connected_internet'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.debug('New user loggin');
|
|
||||||
SyncController.setInstalled(true);
|
|
||||||
return this.loginAction(user, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
async syncUsersIfPossibleAsync() {
|
|
||||||
const isConnected = await SyncController.checkConnection();
|
|
||||||
if (!isConnected.isInternetReachable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.debug('sync users ?');
|
|
||||||
this.setState({ syncWorking: true });
|
|
||||||
if (InstallController.getAppConfig(SyncController.getUrlBo())) {
|
|
||||||
// getUsers
|
|
||||||
const resUsers = await SyncController.getUsers()
|
|
||||||
.then(res => {
|
|
||||||
User.clear();
|
|
||||||
console.debug('got users');
|
|
||||||
return res.data;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
if (!resUsers?.length) {
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resUsers.forEach(user => {
|
|
||||||
User.add(user);
|
|
||||||
});
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async syncAppConfigIfPossibleAsync() {
|
|
||||||
const isConnected = await SyncController.checkConnection();
|
|
||||||
if (!isConnected.isInternetReachable) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.debug('sync settings ?');
|
|
||||||
this.setState({ syncWorking: true });
|
|
||||||
const url = Setting.get('bo_url')?.value;
|
|
||||||
if (!url) {
|
|
||||||
console.warn('url config is wrong');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const toDL = await InstallController.getConfig(url)
|
|
||||||
.then(response => {
|
|
||||||
const toDLArray = [];
|
|
||||||
if (response.data) {
|
|
||||||
if (response.data.status === 'OK') {
|
|
||||||
console.debug('got settings');
|
|
||||||
_.forEach(response.data.datas, function (value, key) {
|
|
||||||
switch (key) {
|
|
||||||
case 'MainColor':
|
|
||||||
Setting.upsert({ key: key, value: value });
|
|
||||||
break;
|
|
||||||
case 'SquaredLogo':
|
|
||||||
case 'RectangleLogo':
|
|
||||||
case 'BackgroundImage':
|
|
||||||
case 'HomeButtonImage':
|
|
||||||
toDLArray.push({
|
|
||||||
source: url + '/' + value,
|
|
||||||
dest: FileSystem.documentDirectory + key + '.png',
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return toDLArray;
|
|
||||||
} else {
|
|
||||||
console.debug('got Ko settings');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.debug(response);
|
|
||||||
}
|
}
|
||||||
})
|
SplashScreen.hideAsync();
|
||||||
.catch(function (error) {
|
|
||||||
console.error(error);
|
|
||||||
console.error(error.response);
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
if (!toDL?.length) {
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
for await (const file of toDL) {
|
|
||||||
await FileSystem.downloadAsync(file.source, file.dest)
|
|
||||||
.then(({ uri }) => {
|
|
||||||
console.debug('Finished downloading to ', uri);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error);
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.props.init();
|
|
||||||
this.props.setIsSetup();
|
|
||||||
this.setState({ syncWorking: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
render() {
|
||||||
* @param {import('../Models/User').User} user
|
return (
|
||||||
*/
|
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background}>
|
||||||
loginAction(user) {
|
<View style={styles.container}>
|
||||||
this.setState({ login: '', password: '' });
|
<Image source={{ uri: FileSystem.documentDirectory + 'SquaredLogo.png' }} style={styles.logo} />
|
||||||
console.debug('loginAction');
|
<View>
|
||||||
LoginController.login(user);
|
<TextInput
|
||||||
this.props.setCurrentUser();
|
style={styles.text}
|
||||||
}
|
placeholder={i18n.t('login_s.username')}
|
||||||
|
value={this.state.login}
|
||||||
|
onChangeText={text => this.setState({ login: text })}
|
||||||
|
autoCapitalize={'none'}
|
||||||
|
autoCorrect={false}
|
||||||
|
keyboardType={'email-address'}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
style={styles.text}
|
||||||
|
placeholder={i18n.t('login_s.password')}
|
||||||
|
value={this.state.password}
|
||||||
|
onChangeText={text => this.setState({ password: text })}
|
||||||
|
secureTextEntry={true}
|
||||||
|
autoCapitalize={'none'}
|
||||||
|
autoCorrect={false}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
title={i18n.t('global.login')}
|
||||||
|
onPress={() => this.login(this.state.login.toLowerCase(), this.state.password)}
|
||||||
|
color={this.props.mainColor}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</ImageBackground >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async login(login, password) {
|
||||||
|
if (login === '' || password === '') {
|
||||||
|
Alert.alert(i18n.t("global.warning"), i18n.t('error.must_fill_login_fields'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var usersSize = Object.keys(this.props.users).length;
|
||||||
|
if (usersSize === 0) {
|
||||||
|
Alert.alert(i18n.t("global.warning"), i18n.t('login_s.missing_users'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let user = this.props.users.filter(tmp => tmp.email === login);
|
||||||
|
if (user.length === 0) {
|
||||||
|
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user = user[0];
|
||||||
|
const verified = LoginController.verify(user, password).then(verified => verified);
|
||||||
|
if (!verified) {
|
||||||
|
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isConnected = await SyncController.checkConnection().then(state => {
|
||||||
|
//console.log(state.isConnected)
|
||||||
|
return state.isConnected
|
||||||
|
}).catch(error => {
|
||||||
|
//console.log(error);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
const lastUser = Setting.get('lastUser');
|
||||||
|
// Si on est sur une installation
|
||||||
|
if (lastUser === false || lastUser == undefined) {
|
||||||
|
// Si la tablette est connectée à internet pour forcer la synchro
|
||||||
|
if (!isConnected) {
|
||||||
|
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.loginAction(user);
|
||||||
|
}
|
||||||
|
// Si on a deja une install
|
||||||
|
if (lastUser !== false && lastUser !== undefined) {
|
||||||
|
// Si on a une précédente connexion
|
||||||
|
if (lastUser.value === user.id.toString()) {
|
||||||
|
this.loginAction(user);
|
||||||
|
} else { // Si le user precedent est different du user courant
|
||||||
|
// Si user !== last user && last user not synced
|
||||||
|
if (!SyncController.isSynced()) {
|
||||||
|
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_synced_last_user'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Si la tablette est connectée à internet pour forcer la synchro
|
||||||
|
if (!isConnected) {
|
||||||
|
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SyncController.setInstalled(true);
|
||||||
|
this.loginAction(user, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loginAction(user) {
|
||||||
|
this.setState({ login: '', password: '' });
|
||||||
|
LoginController.login(user);
|
||||||
|
this.props.setCurrentUser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(LoginScreen);
|
export default connect(mapStateToProps, mapDispatchToProps)(LoginScreen);
|
||||||
28
ComApp/src/App/Views/MySpaceScreen.js
Normal file
28
ComApp/src/App/Views/MySpaceScreen.js
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
} from 'react-native';
|
||||||
|
// Redux
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
// Style
|
||||||
|
import styles from '../../Resources/Styles/MySpaceStyle';
|
||||||
|
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
|
documents: state.app.documents,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class MySpaceScreen extends React.Component {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text>Mon Espace</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(MySpaceScreen);
|
||||||
|
|
@ -1,63 +1,61 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
import {
|
||||||
// Redux
|
View,
|
||||||
import { connect } from 'react-redux';
|
ScrollView,
|
||||||
// Icons
|
TouchableOpacity,
|
||||||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
Text,
|
||||||
// Style
|
} from 'react-native';
|
||||||
import styles from '../../Resources/Styles/OnlyVideosStyle';
|
// Redux
|
||||||
|
import { connect } from 'react-redux';
|
||||||
function mapStateToProps(state) {
|
// Icons
|
||||||
return {
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
||||||
documents: state.documents,
|
// Style
|
||||||
mainColor: state.app.mainColor,
|
import styles from '../../Resources/Styles/OnlyVideosStyle';
|
||||||
};
|
|
||||||
}
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
class OnlyVideosScreen extends React.Component {
|
documents: state.documents,
|
||||||
state = {
|
mainColor: state.app.mainColor
|
||||||
documents: [],
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
class OnlyVideosScreen extends React.Component {
|
||||||
this.setState({
|
state = {
|
||||||
documents: this.props.documents.filter(tmp => tmp.type === 'mp4'),
|
documents: [],
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
componentDidMount() {
|
||||||
render() {
|
this.setState({ documents: this.props.documents.filter(tmp => tmp.type === 'mp4') });
|
||||||
let documentList = this.state.documents.map(document => {
|
}
|
||||||
return (
|
|
||||||
<TouchableOpacity
|
render() {
|
||||||
key={document.id.toString()}
|
let documentList = this.state.documents.map(document => {
|
||||||
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
return (
|
||||||
onPress={() => {
|
<TouchableOpacity
|
||||||
this.props.dispatch({
|
key={document.id.toString()}
|
||||||
type: 'SET_CURRENT_OPENED_DOC',
|
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
||||||
data: document,
|
onPress={() => {
|
||||||
});
|
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
||||||
this.props.navigation.navigate('VideoScreen', {
|
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
||||||
uuid: document.uuid,
|
}}>
|
||||||
});
|
{document.type === 'pdf' ? (
|
||||||
}}>
|
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
||||||
{document.type === 'pdf' ? (
|
) : (
|
||||||
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
||||||
) : (
|
)}
|
||||||
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
<Text style={styles.fileTxt}>{document.title}</Text>
|
||||||
)}
|
</TouchableOpacity>
|
||||||
<Text style={styles.fileTxt}>{document.title}</Text>
|
);
|
||||||
</TouchableOpacity>
|
});
|
||||||
);
|
|
||||||
});
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
return (
|
<ScrollView style={styles.scrollview}>
|
||||||
<View style={styles.container}>
|
<View style={styles.filesContainer}>{documentList}</View>
|
||||||
<ScrollView style={styles.scrollview}>
|
</ScrollView>
|
||||||
<View style={styles.filesContainer}>{documentList}</View>
|
</View>
|
||||||
</ScrollView>
|
);
|
||||||
</View>
|
}
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
export default connect(mapStateToProps)(OnlyVideosScreen);
|
||||||
|
|
||||||
export default connect(mapStateToProps)(OnlyVideosScreen);
|
|
||||||
|
|
|
||||||
|
|
@ -8,33 +8,33 @@ import * as FileSystem from 'expo-file-system';
|
||||||
import styles from '../../Resources/Styles/PDFStyle';
|
import styles from '../../Resources/Styles/PDFStyle';
|
||||||
|
|
||||||
class PDFScreen extends React.Component {
|
class PDFScreen extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { uuid } = this.props.route.params;
|
const { uuid } = this.props.route.params;
|
||||||
const source = {
|
const source = {
|
||||||
uri: FileSystem.documentDirectory + uuid + '.pdf',
|
uri: FileSystem.documentDirectory + uuid + '.pdf',
|
||||||
cache: false,
|
cache: false,
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Pdf
|
<Pdf
|
||||||
source={source}
|
source={source}
|
||||||
onLoadComplete={(numberOfPages, filePath) => {
|
onLoadComplete={(numberOfPages, filePath) => {
|
||||||
console.debug(`number of pages: ${numberOfPages}`);
|
//console.log(`number of pages: ${numberOfPages}`);
|
||||||
}}
|
}}
|
||||||
onPageChanged={(page, numberOfPages) => {
|
onPageChanged={(page, numberOfPages) => {
|
||||||
console.debug(`current page: ${page}`);
|
//console.log(`current page: ${page}`);
|
||||||
}}
|
}}
|
||||||
onError={error => {
|
onError={error => {
|
||||||
console.error(error);
|
console.log(error);
|
||||||
}}
|
}}
|
||||||
onPressLink={uri => {
|
onPressLink={uri => {
|
||||||
console.debug(`Link presse: ${uri}`);
|
//console.log(`Link presse: ${uri}`);
|
||||||
}}
|
}}
|
||||||
style={styles.pdf}
|
style={styles.pdf}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PDFScreen;
|
export default PDFScreen;
|
||||||
|
|
|
||||||
|
|
@ -1,87 +1,86 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
import {
|
||||||
// Reduxs
|
View,
|
||||||
import { connect } from 'react-redux';
|
ScrollView,
|
||||||
// Helpers
|
TouchableOpacity,
|
||||||
import Helpers from '../Lib/Helpers';
|
Text,
|
||||||
// Translations
|
} from 'react-native';
|
||||||
import i18n from '../../I18n';
|
// Reduxs
|
||||||
// Icons
|
import { connect } from 'react-redux';
|
||||||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
// Helpers
|
||||||
// Style
|
import Helpers from "../Lib/Helpers";
|
||||||
import styles from '../../Resources/Styles/SearchStyle';
|
// Translations
|
||||||
|
import i18n from "../../I18n";
|
||||||
function mapStateToProps(state) {
|
// Icons
|
||||||
return {
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
||||||
documents: state.documents,
|
// Style
|
||||||
mainColor: state.app.mainColor,
|
import styles from '../../Resources/Styles/SearchStyle';
|
||||||
};
|
|
||||||
}
|
function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
class SearchScreen extends React.Component {
|
documents: state.documents,
|
||||||
state = {
|
mainColor: state.app.mainColor
|
||||||
documents: [],
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
openDocument(document) {
|
class SearchScreen extends React.Component {
|
||||||
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
state = {
|
||||||
if (document.type === 'pdf') {
|
documents: [],
|
||||||
this.props.navigation.navigate('PDFScreen', { uuid: document.uuid });
|
};
|
||||||
} else if (document.type === 'mp4') {
|
|
||||||
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
openDocument(document) {
|
||||||
} else {
|
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
||||||
console.error('Type de document inconnu');
|
if (document.type === 'pdf') {
|
||||||
}
|
this.props.navigation.navigate('PDFScreen', { uuid: document.uuid });
|
||||||
}
|
} else if (document.type === 'mp4') {
|
||||||
|
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
||||||
componentDidMount() {
|
} else {
|
||||||
const { needle, onlyVideos } = this.props.route.params;
|
console.log('Inconnu');
|
||||||
let objDocs = this.props.documents;
|
}
|
||||||
let arrayDocs = Object.keys(objDocs).map(function (key) {
|
}
|
||||||
return objDocs[key];
|
|
||||||
});
|
componentDidMount() {
|
||||||
let sorted = arrayDocs.sort(Helpers.compareValues('title', 'asc'));
|
const { needle, onlyVideos } = this.props.route.params;
|
||||||
let filtered = sorted.filter(
|
let objDocs = this.props.documents;
|
||||||
item => item.title.toLowerCase().indexOf(needle.toLowerCase()) >= 0,
|
let arrayDocs = Object.keys(objDocs).map(function (key) { return objDocs[key]; });
|
||||||
);
|
let sorted = arrayDocs.sort(Helpers.compareValues('title', 'asc'));
|
||||||
if (onlyVideos === true) {
|
let filtered = sorted.filter(item => item.title.toLowerCase().indexOf(needle.toLowerCase()) >= 0);
|
||||||
filtered = filtered.filter(item => item.type === 'mp4');
|
if (onlyVideos === true) {
|
||||||
}
|
filtered = filtered.filter(item => item.type === 'mp4');
|
||||||
this.setState({
|
}
|
||||||
documents: filtered,
|
this.setState({
|
||||||
});
|
documents: filtered,
|
||||||
}
|
});
|
||||||
|
}
|
||||||
render() {
|
|
||||||
let documentList = this.state.documents.map(document => {
|
render() {
|
||||||
return (
|
let documentList = this.state.documents.map(document => {
|
||||||
<TouchableOpacity
|
return (
|
||||||
key={document.id.toString()}
|
<TouchableOpacity
|
||||||
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
key={document.id.toString()}
|
||||||
onPress={() => this.openDocument(document)}>
|
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
||||||
{document.type === 'pdf' ? (
|
onPress={() => this.openDocument(document)}>
|
||||||
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
{document.type === 'pdf' ? (
|
||||||
) : (
|
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
||||||
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
) : (
|
||||||
)}
|
<FontAwesome5 name="file-video" color={'white'} size={60} />
|
||||||
<Text style={styles.fileTxt}>{document.title}</Text>
|
)}
|
||||||
</TouchableOpacity>
|
<Text style={styles.fileTxt}>{document.title}</Text>
|
||||||
);
|
</TouchableOpacity>
|
||||||
});
|
);
|
||||||
|
});
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
return (
|
||||||
<ScrollView style={styles.scrollview}>
|
<View style={styles.container}>
|
||||||
<View style={styles.filesContainer}>{documentList}</View>
|
<ScrollView style={styles.scrollview}>
|
||||||
{this.state.documents.length === 0 && (
|
<View style={styles.filesContainer}>{documentList}</View>
|
||||||
<Text style={{ textAlign: 'center', marginTop: 50, fontSize: 30 }}>
|
{this.state.documents.length === 0 && (
|
||||||
{i18n.t('search_s.no_result')}
|
<Text style={{ textAlign: 'center', marginTop: 50, fontSize: 30 }}>{i18n.t('search_s.no_result')}</Text>
|
||||||
</Text>
|
)}
|
||||||
)}
|
</ScrollView>
|
||||||
</ScrollView>
|
</View>
|
||||||
</View>
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
export default connect(mapStateToProps)(SearchScreen);
|
||||||
export default connect(mapStateToProps)(SearchScreen);
|
|
||||||
|
|
|
||||||
|
|
@ -1,459 +1,379 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Alert, Button, Linking, Text, View } from 'react-native';
|
import { View, Button, Alert, Text } from 'react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { initContact } from '../Store/Actions/contacts';
|
|
||||||
import { initDirectories } from '../Store/Actions/directories';
|
import { initDirectories } from '../Store/Actions/directories';
|
||||||
|
import { initContact } from '../Store/Actions/contacts';
|
||||||
import { initDocuments } from '../Store/Actions/documents';
|
import { initDocuments } from '../Store/Actions/documents';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from '@sentry/react-native';
|
import * as Sentry from "@sentry/react-native";
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/SyncStyle';
|
import styles from '../../Resources/Styles/SyncStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from '../../I18n';
|
import i18n from "../../I18n";
|
||||||
// Controller
|
// Controller
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
// Progress
|
// Progress
|
||||||
import * as Progress from 'react-native-progress';
|
import * as Progress from 'react-native-progress';
|
||||||
// Database
|
// Database
|
||||||
import {
|
import { User, Contact, Directory, Document, SendBrochure } from '../../Database';
|
||||||
Contact,
|
|
||||||
Directory,
|
|
||||||
Document,
|
|
||||||
Form,
|
|
||||||
SendBrochure,
|
|
||||||
User,
|
|
||||||
} from '../../Database';
|
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
currentUser: state.app.currentUser,
|
syncVersion: state.app.syncVersion,
|
||||||
locale: state.locale.locale,
|
currentUser: state.app.currentUser,
|
||||||
mainColor: state.app.mainColor,
|
locale: state.locale.locale,
|
||||||
directories: state.directories,
|
mainColor: state.app.mainColor,
|
||||||
};
|
directories: state.directories
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
init: () => dispatch({ type: 'INIT' }),
|
init: () => dispatch({ type: 'INIT' }),
|
||||||
initUsers: () => dispatch({ type: 'INIT_USERS' }),
|
initUsers: () => dispatch({ type: 'INIT_USERS' }),
|
||||||
initFormularies: () => dispatch({ type: 'INIT_FORMS' }),
|
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
||||||
initDocuments: (lang, directories) =>
|
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||||
dispatch(initDocuments(lang, directories)),
|
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
||||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
updateVersion: version => dispatch({
|
||||||
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' })
|
type: 'UPDATE_VERSION',
|
||||||
};
|
data: version,
|
||||||
|
}),
|
||||||
|
updateShowIsActive: value => dispatch({
|
||||||
|
type: 'UPDATE_SHOW_IS_ACTIVE',
|
||||||
|
data: value,
|
||||||
|
})
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class SyncScreen extends React.Component {
|
class SyncScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
progress: 0,
|
progress: 0,
|
||||||
txtStep: '',
|
txtStep: '',
|
||||||
downloadProgress: 0,
|
downloadProgress: 0,
|
||||||
downloadingFile: false,
|
downloadingFile: false,
|
||||||
processing: false,
|
processing: false,
|
||||||
forced: false,
|
newApp: false,
|
||||||
};
|
forced: false
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
const { forceSync } = this.props.route.params;
|
|
||||||
if (forceSync === true) {
|
|
||||||
this.setState({ forced: true });
|
|
||||||
this.sync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const fileProgress = this.fileProgress();
|
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
|
||||||
<Progress.Circle
|
|
||||||
size={250}
|
|
||||||
progress={this.state.progress}
|
|
||||||
showsText={true}
|
|
||||||
color={this.props.mainColor}
|
|
||||||
/>
|
|
||||||
<View style={styles.btnWrapper}>
|
|
||||||
<Button
|
|
||||||
disabled={this.state.processing}
|
|
||||||
color={this.props.mainColor}
|
|
||||||
title={i18n.t('sync_s.start_sync')}
|
|
||||||
onPress={() => this.sync()}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.btnWrapper}>
|
|
||||||
<Text>
|
|
||||||
{this.state.txtStep} {fileProgress}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async sync() {
|
|
||||||
let errorStatus = false;
|
|
||||||
|
|
||||||
console.debug('Sync');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Promise<import('@react-native-community/netinfo').NetInfoState>} promise
|
|
||||||
* @param {(error:any) => void|null} onError
|
|
||||||
*/
|
|
||||||
const getCall = (promise, onError = null) => {
|
|
||||||
if (onError === null) {
|
|
||||||
/** @param {import('axios').AxiosError} error */
|
|
||||||
onError = error => {
|
|
||||||
let message = 'Erreur de la communication serveur';
|
|
||||||
if (error?.response?.status === 422) {
|
|
||||||
message =
|
|
||||||
this.parseValidationErrors(error.response?.data?.errors ?? {}) ||
|
|
||||||
message;
|
|
||||||
console.warn(error.response?.data?.errors ?? {});
|
|
||||||
} else if (error?.response?.status === 419) {
|
|
||||||
// * CSRF TOKEN MISMATCH (On ne pourrais plus faire d'appels AJAX sans recharger la page)
|
|
||||||
message = 'Votre session a expiré, la page va être rechargée';
|
|
||||||
} else if (error?.response?.status === 403) {
|
|
||||||
// * Access denied
|
|
||||||
message = "Vous n'êtes pas autorisé a effectuer cette action";
|
|
||||||
} else {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
console.warn(message);
|
|
||||||
|
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred'),
|
|
||||||
);
|
|
||||||
errorStatus = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return promise.catch(onError);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isConnected = await SyncController.checkConnection().catch(
|
componentDidMount() {
|
||||||
error => false,
|
const { forceSync } = this.props.route.params;
|
||||||
);
|
if (forceSync === true) {
|
||||||
if (!isConnected) {
|
this.setState({ forced: true });
|
||||||
Alert.alert(
|
this.sync();
|
||||||
i18n.t('global.warning'),
|
}
|
||||||
i18n.t('error.must_be_connected_internet_sync'),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.setState({ processing: true });
|
|
||||||
// * --- getUsers
|
|
||||||
this.setState({
|
|
||||||
progress: 0.1,
|
|
||||||
txtStep: i18n.t('sync_s.updating_users') + '...',
|
|
||||||
});
|
|
||||||
const resUsers = await getCall(
|
|
||||||
SyncController.getUsers().then(res => {
|
|
||||||
User.clear();
|
|
||||||
return res.data;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
resUsers.forEach(user => {
|
|
||||||
User.add(user);
|
|
||||||
});
|
|
||||||
|
|
||||||
// * --- Contacts Sync
|
|
||||||
/*
|
|
||||||
* This is done only for actual app user
|
|
||||||
- 1 Upsert all contacts
|
|
||||||
- 2 Delete contacts where to_delete is true
|
|
||||||
- 3 Get all contacts
|
|
||||||
*/
|
|
||||||
this.setState({
|
|
||||||
progress: 0.2,
|
|
||||||
txtStep: i18n.t('sync_s.updating_contacts') + '...',
|
|
||||||
});
|
|
||||||
|
|
||||||
// * --- Contacts Sync -- STEP 1
|
|
||||||
await getCall(SyncController.upsertContacts(this.props.currentUser.id));
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * --- Contacts Sync -- STEP 2
|
render() {
|
||||||
this.setState({
|
const fileProgress = this.fileProgress();
|
||||||
progress: 0.23,
|
return (
|
||||||
});
|
<View style={styles.container}>
|
||||||
await getCall(SyncController.deleteContacts(this.props.currentUser.id));
|
<Progress.Circle
|
||||||
if (errorStatus) {
|
size={250}
|
||||||
return false;
|
progress={this.state.progress}
|
||||||
|
showsText={true}
|
||||||
|
color={this.props.mainColor}
|
||||||
|
/>
|
||||||
|
<View style={styles.btnWrapper}>
|
||||||
|
<Button
|
||||||
|
disabled={this.state.processing}
|
||||||
|
color={this.props.mainColor}
|
||||||
|
title={i18n.t('sync_s.start_sync')}
|
||||||
|
onPress={() => this.sync()}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.btnWrapper}>
|
||||||
|
<Text>
|
||||||
|
{this.state.txtStep} {fileProgress}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * --- Contacts Sync -- STEP 3
|
async sync() {
|
||||||
this.setState({
|
let errorStatus = false;
|
||||||
progress: 0.26,
|
const isConnected = await SyncController.checkConnection().then(state => {
|
||||||
});
|
//console.log(state.isConnected)
|
||||||
const resContacts = await getCall(
|
return state.isConnected
|
||||||
SyncController.getContacts(this.props.currentUser.id).then(res => {
|
}).catch(error => {
|
||||||
// * Clear Contacts, in order to fetch them all after.
|
//console.log(error);
|
||||||
Contact.clear(this.props.currentUser.id);
|
return false;
|
||||||
return res.data;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/** @type {(contact: import('./../Models/Contact').ContactData ) => void} */
|
|
||||||
const contactMapper = contact => {
|
|
||||||
// * Stringify complex Fields
|
|
||||||
contact.data = JSON.stringify(contact.data);
|
|
||||||
contact.visits = JSON.stringify(contact.visits);
|
|
||||||
contact.timestamp = new Date(contact.timestamp);
|
|
||||||
Contact.set(contact);
|
|
||||||
};
|
|
||||||
resContacts.forEach(contactMapper);
|
|
||||||
|
|
||||||
// * --- sendBrochures
|
|
||||||
this.setState({
|
|
||||||
progress: 0.3,
|
|
||||||
txtStep: i18n.t('sync_s.sending_flyers') + '...',
|
|
||||||
});
|
|
||||||
const brochures = SendBrochure.getAll();
|
|
||||||
for (const brochure of brochures) {
|
|
||||||
await getCall(
|
|
||||||
SyncController.sendBrochure(brochure).then(res => {
|
|
||||||
SendBrochure.delete(brochure.id);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// * --- getDirectories
|
|
||||||
this.setState({
|
|
||||||
progress: 0.4,
|
|
||||||
txtStep: i18n.t('sync_s.updating_folders') + '...',
|
|
||||||
});
|
|
||||||
const resDirectories = await getCall(
|
|
||||||
SyncController.getDirectories().then(res => {
|
|
||||||
Directory.clear();
|
|
||||||
return res.data;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
resDirectories.forEach(dir => {
|
|
||||||
Directory.add(dir);
|
|
||||||
});
|
|
||||||
|
|
||||||
// * --- getFormularies
|
|
||||||
this.setState({
|
|
||||||
progress: 0.5,
|
|
||||||
txtStep: i18n.t('sync_s.updating_forms') + '...',
|
|
||||||
});
|
|
||||||
const resFormularies = await getCall(
|
|
||||||
SyncController.getFormularies().then(res => {
|
|
||||||
Form.clear();
|
|
||||||
return res.data;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
resFormularies.forEach(form => Form.add(form));
|
|
||||||
|
|
||||||
// * --- getDocuments
|
|
||||||
this.setState({
|
|
||||||
progress: 0.6,
|
|
||||||
txtStep: i18n.t('sync_s.updating_docs') + '...',
|
|
||||||
});
|
|
||||||
const resDocuments = await getCall(
|
|
||||||
SyncController.getDocuments().then(res => {
|
|
||||||
return res.data;
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (errorStatus) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const toDelete = Document.clear(resDocuments);
|
|
||||||
resDocuments.forEach(document => {
|
|
||||||
Document.update(document);
|
|
||||||
});
|
|
||||||
this.downloadDocuments(Document.getAll(), toDelete);
|
|
||||||
|
|
||||||
// * --- End
|
|
||||||
}
|
|
||||||
|
|
||||||
fileProgress() {
|
|
||||||
if (this.state.downloadingFile === true) {
|
|
||||||
return this.state.downloadProgress + ' %';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadDocuments(docs, toDelete) {
|
|
||||||
this.getToDL(docs, 0).then(toDownload => {
|
|
||||||
if (toDownload.length > 0) {
|
|
||||||
this.setState({ progress: 0.6 });
|
|
||||||
const docProgress = 0.4 / toDownload.length;
|
|
||||||
this.download(toDownload, docProgress, 0).then(status => {
|
|
||||||
if (status === true) {
|
|
||||||
this.deleteFile(toDelete, 0).then(delStatus => {
|
|
||||||
this.finishSync();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
txtStep: i18n.t('error.error_has_occurred') + '.',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
if (!isConnected) {
|
||||||
this.deleteFile(toDelete, 0).then(status => {
|
Alert.alert(
|
||||||
this.setState({ progress: 1 });
|
i18n.t('global.warning'),
|
||||||
this.finishSync();
|
i18n.t('error.must_be_connected_internet_sync')
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setState({ processing: true });
|
||||||
|
// getVersion
|
||||||
|
const resVersion = await SyncController.getVersion().then(res => {
|
||||||
|
return res.data;
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred')
|
||||||
|
);
|
||||||
|
errorStatus = true
|
||||||
});
|
});
|
||||||
}
|
if (errorStatus) {
|
||||||
});
|
return false;
|
||||||
}
|
}
|
||||||
|
this.props.updateVersion(resVersion.version);
|
||||||
|
this.props.updateShowIsActive(resVersion.ShowIsActive);
|
||||||
|
this.setState({ newApp: resVersion.newApp });
|
||||||
|
// getUsers
|
||||||
|
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
||||||
|
const resUsers = await SyncController.getUsers().then(res => {
|
||||||
|
User.clear();
|
||||||
|
return res.data;
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred')
|
||||||
|
);
|
||||||
|
errorStatus = true
|
||||||
|
});
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
resUsers.forEach(user => {
|
||||||
|
User.add(user);
|
||||||
|
});
|
||||||
|
// getContacts
|
||||||
|
this.setState({ progress: 0.1, txtStep: i18n.t('sync_s.updating_contacts') + '...' });
|
||||||
|
const resContacts = await SyncController.getContacts(this.props.currentUser.id).then(res => {
|
||||||
|
Contact.clear();
|
||||||
|
return res.data;
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred')
|
||||||
|
);
|
||||||
|
errorStatus = true
|
||||||
|
});
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
resContacts.forEach(contact => {
|
||||||
|
Contact.add(contact);
|
||||||
|
});
|
||||||
|
//sendBrochures
|
||||||
|
this.setState({ progress: 0.2, txtStep: i18n.t('sync_s.sending_flyers') + '...' });
|
||||||
|
let brochures = SendBrochure.getAll();
|
||||||
|
for (const brochure of brochures) {
|
||||||
|
await SyncController.sendBrochure(brochure).then(res => {
|
||||||
|
SendBrochure.delete(brochure.id);
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred') + ' : Brochures'
|
||||||
|
);
|
||||||
|
errorStatus = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//getDirectories
|
||||||
|
this.setState({ progress: 0.3, txtStep: i18n.t('sync_s.updating_folders') + '...' });
|
||||||
|
const resDirectories = await SyncController.getDirectories().then(res => {
|
||||||
|
Directory.clear();
|
||||||
|
return res.data;
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred')
|
||||||
|
);
|
||||||
|
errorStatus = true
|
||||||
|
});
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
resDirectories.forEach(dir => {
|
||||||
|
Directory.add(dir);
|
||||||
|
});
|
||||||
|
// getDocuments
|
||||||
|
this.setState({ progress: 0.4, txtStep: i18n.t('sync_s.updating_docs') + '...' });
|
||||||
|
const resDocuments = await SyncController.getDocuments().then(res => {
|
||||||
|
return res.data;
|
||||||
|
}).catch(error => {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred')
|
||||||
|
);
|
||||||
|
errorStatus = true
|
||||||
|
});
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const toDelete = Document.clear(resDocuments);
|
||||||
|
resDocuments.forEach(document => {
|
||||||
|
Document.update(document);
|
||||||
|
});
|
||||||
|
this.downloadDocuments(Document.getAll(), toDelete);
|
||||||
|
// End
|
||||||
|
this.setState({ txtStep: i18n.t('sync_s.update_completed') + '.', processing: false });
|
||||||
|
}
|
||||||
|
|
||||||
async getToDL(docs, i, toDL = []) {
|
fileProgress() {
|
||||||
if (docs.length < 1) {
|
if (this.state.downloadingFile === true) {
|
||||||
return toDL;
|
return this.state.downloadProgress + ' %';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const item = docs[i];
|
|
||||||
const { exists, modificationTime } = await FileSystem.getInfoAsync(
|
|
||||||
FileSystem.documentDirectory + item.uuid + '.' + item.type,
|
|
||||||
);
|
|
||||||
if (exists === false) {
|
|
||||||
toDL.push(item);
|
|
||||||
} else {
|
|
||||||
if (modificationTime.toString() !== item.updated_at) {
|
|
||||||
toDL.push(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i < docs.length - 1) {
|
|
||||||
return this.getToDL(docs, i + 1, toDL);
|
|
||||||
}
|
|
||||||
return toDL;
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteFile(docs, i) {
|
downloadDocuments(docs, toDelete) {
|
||||||
if (docs.length > 0) {
|
const version = this.props.syncVersion;
|
||||||
const file = docs[i];
|
this.getToDL(docs, 0).then(toDownload => {
|
||||||
await FileSystem.deleteAsync(
|
if (toDownload.length > 0) {
|
||||||
FileSystem.documentDirectory + file.uuid + '.' + file.type,
|
this.setState({ progress: 0.5 });
|
||||||
{ idempotent: true },
|
const docProgress = 0.5 / toDownload.length;
|
||||||
);
|
this.download(toDownload, docProgress, 0).then(status => {
|
||||||
if (i < docs.length - 1) {
|
if (status === true) {
|
||||||
return this.deleteFile(docs, i + 1);
|
this.deleteFile(toDelete, 0).then(status => {
|
||||||
}
|
this.finishSync(version);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({ txtStep: i18n.t('error.error_has_occurred') + '.' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.deleteFile(toDelete, 0).then(status => {
|
||||||
|
this.setState({ progress: 1 });
|
||||||
|
this.finishSync(version);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(downloadProgress) {
|
async getToDL(docs, i, toDL = []) {
|
||||||
let progress =
|
if (docs.length < 1)
|
||||||
(downloadProgress.totalBytesWritten /
|
return toDL;
|
||||||
downloadProgress.totalBytesExpectedToWrite) *
|
const item = docs[i];
|
||||||
100;
|
const { exists, modificationTime } = await FileSystem.getInfoAsync(FileSystem.documentDirectory + item.uuid + '.' + item.type);
|
||||||
progress = Math.round(progress);
|
if (exists === false) {
|
||||||
progress = progress.toString();
|
toDL.push(item);
|
||||||
this.setState({
|
} else {
|
||||||
downloadProgress: progress,
|
if (modificationTime.toString() !== item.updated_at) {
|
||||||
});
|
toDL.push(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
downloadResumable(url, uuid, type) {
|
if (i < docs.length - 1) {
|
||||||
return FileSystem.createDownloadResumable(
|
return this.getToDL(docs, i + 1, toDL);
|
||||||
url,
|
}
|
||||||
FileSystem.documentDirectory + uuid + '.' + type,
|
return toDL;
|
||||||
{},
|
|
||||||
this.callback.bind(this),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async download(documents, progress, i) {
|
|
||||||
if (this.state.downloadingFile === false) {
|
|
||||||
this.setState({ downloadingFile: true });
|
|
||||||
}
|
}
|
||||||
const tenantUrl = SyncController.getUrlBo();
|
|
||||||
const rootUrl = tenantUrl.substring(0, tenantUrl.lastIndexOf('/'));
|
|
||||||
const tenantId = tenantUrl.match(/[^\/]+$/)[0];
|
|
||||||
const endpoint = rootUrl + '/storage/docs/' + tenantId + "/";
|
|
||||||
const doc = documents[i];
|
|
||||||
this.setState({
|
|
||||||
txtStep:
|
|
||||||
i18n.t('sync_s.download') +
|
|
||||||
' : ' +
|
|
||||||
doc.title +
|
|
||||||
' (' +
|
|
||||||
doc.type.toUpperCase() +
|
|
||||||
') ...',
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
const uri = `${endpoint}${doc.uuid}.${doc.type}`;
|
|
||||||
await this.downloadResumable(
|
|
||||||
endpoint + doc.uuid + '.' + doc.type,
|
|
||||||
doc.uuid,
|
|
||||||
doc.type,
|
|
||||||
).downloadAsync();
|
|
||||||
const { modificationTime } = await FileSystem.getInfoAsync(
|
|
||||||
FileSystem.documentDirectory + doc.uuid + '.' + doc.type,
|
|
||||||
);
|
|
||||||
SyncController.updateLastModificationDoc(doc.id, modificationTime);
|
|
||||||
console.debug('Finished downloading to ', uri);
|
|
||||||
this.setState({ progress: this.state.progress + progress });
|
|
||||||
if (i < documents.length - 1) {
|
|
||||||
return this.download(documents, progress, i + 1);
|
|
||||||
}
|
|
||||||
this.setState({ downloadingFile: false });
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finishSync() {
|
async deleteFile(docs, i) {
|
||||||
this.props.init();
|
if (docs.length > 0) {
|
||||||
this.props.initUsers();
|
const file = docs[i];
|
||||||
this.props.initContact(this.props.currentUser);
|
await FileSystem.deleteAsync(FileSystem.documentDirectory + file.uuid + '.' + file.type, { idempotent: true });
|
||||||
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
if (i < docs.length - 1) {
|
||||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
return this.deleteFile(docs, i + 1);
|
||||||
this.props.initBtns();
|
}
|
||||||
if (this.state.forced) {
|
}
|
||||||
SyncController.setInstalled();
|
return true;
|
||||||
}
|
}
|
||||||
this.setState({
|
|
||||||
txtStep: i18n.t('sync_s.update_completed') + '.',
|
|
||||||
processing: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
callback(downloadProgress) {
|
||||||
* Parse error messages for a specific input.
|
let progress =
|
||||||
*
|
(downloadProgress.totalBytesWritten /
|
||||||
* @param {Record<string, Array<string>>} allErrors
|
downloadProgress.totalBytesExpectedToWrite) *
|
||||||
* @return {string | null}
|
100;
|
||||||
*/
|
progress = Math.round(progress);
|
||||||
parseValidationErrors(allErrors = {}) {
|
progress = progress.toString();
|
||||||
const errorList = Object.values(allErrors);
|
this.setState({
|
||||||
if (!errorList.length) {
|
downloadProgress: progress,
|
||||||
return null;
|
});
|
||||||
}
|
}
|
||||||
return errorList
|
|
||||||
.reduce((oldInputErrors, inputErrors) =>
|
downloadResumable(url, uuid, type) {
|
||||||
oldInputErrors ? oldInputErrors.concat(inputErrors) : inputErrors,
|
return FileSystem.createDownloadResumable(
|
||||||
)
|
url,
|
||||||
.reduce(
|
FileSystem.documentDirectory + uuid + '.' + type,
|
||||||
(oldInputString, inputString) =>
|
{},
|
||||||
(oldInputString ? `${oldInputString}, ` : '') + inputString,
|
this.callback.bind(this),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async download(documents, progress, i) {
|
||||||
|
if (this.state.downloadingFile === false) {
|
||||||
|
this.setState({ downloadingFile: true });
|
||||||
|
}
|
||||||
|
const endpoint = SyncController.getUrlBo() + '/storage/docs/'
|
||||||
|
const doc = documents[i];
|
||||||
|
this.setState({
|
||||||
|
txtStep:
|
||||||
|
i18n.t('sync_s.download') + ' : ' +
|
||||||
|
doc.title +
|
||||||
|
' (' +
|
||||||
|
doc.type.toUpperCase() +
|
||||||
|
') ...',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await this.downloadResumable(
|
||||||
|
endpoint + doc.uuid + "." + doc.type,
|
||||||
|
doc.uuid,
|
||||||
|
doc.type,
|
||||||
|
).downloadAsync();
|
||||||
|
const { modificationTime } = await FileSystem.getInfoAsync(FileSystem.documentDirectory + doc.uuid + '.' + doc.type);
|
||||||
|
SyncController.updateLastModificationDoc(doc.id, modificationTime);
|
||||||
|
//console.log('Finished downloading to ', uri);
|
||||||
|
this.setState({ progress: this.state.progress + progress });
|
||||||
|
if (i < documents.length - 1) {
|
||||||
|
return this.download(documents, progress, i + 1);
|
||||||
|
}
|
||||||
|
this.setState({ downloadingFile: false });
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finishSync(version) {
|
||||||
|
this.props.init();
|
||||||
|
this.props.initUsers();
|
||||||
|
this.props.initContact(this.props.currentUser);
|
||||||
|
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
||||||
|
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||||
|
this.props.initBtns();
|
||||||
|
if (this.state.forced) {
|
||||||
|
SyncController.setInstalled();
|
||||||
|
}
|
||||||
|
SyncController.updateVersion(version);
|
||||||
|
this.setState({ txtStep: i18n.t('sync_s.update_completed') + '.', processing: false });
|
||||||
|
if (this.state.newApp === true) {
|
||||||
|
const appUUID = SyncController.getAppStoreUUID();
|
||||||
|
const url = 'https://store.ldc.fr' + '/app/' + appUUID;
|
||||||
|
Alert.alert(
|
||||||
|
'LDC Store',
|
||||||
|
i18n.t('sync_s.new_app_version'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text: i18n.t('global.cancel'),
|
||||||
|
onPress: () => console.log('Cancel Pressed'),
|
||||||
|
style: 'cancel',
|
||||||
|
},
|
||||||
|
{ text: i18n.t('sync_s.open_store'), onPress: () => Linking.openURL(url).catch((err) => console.error('An error occurred', err)) },
|
||||||
|
],
|
||||||
|
{ cancelable: false },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(SyncScreen);
|
export default connect(mapStateToProps, mapDispatchToProps)(SyncScreen);
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Dimensions, View } from 'react-native';
|
import { View, Dimensions } from 'react-native';
|
||||||
// Reduxs
|
// Reduxs
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
|
|
@ -7,71 +7,53 @@ import * as FileSystem from 'expo-file-system';
|
||||||
// Video
|
// Video
|
||||||
import { ResizeMode } from 'expo-av';
|
import { ResizeMode } from 'expo-av';
|
||||||
import VideoPlayer from 'expo-video-player';
|
import VideoPlayer from 'expo-video-player';
|
||||||
// Sentry
|
|
||||||
import * as Sentry from '@sentry/react-native';
|
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
mainColor: state.app.mainColor,
|
mainColor: state.app.mainColor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoScreen extends React.Component {
|
class VideoScreen extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { uuid } = this.props.route.params;
|
const { uuid } = this.props.route.params;
|
||||||
let width = Dimensions.get('window').width;
|
let width = Dimensions.get("window").width;
|
||||||
let height = Dimensions.get('window').height;
|
let height = Dimensions.get("window").height;
|
||||||
|
|
||||||
// * If on portrait
|
// if portrait
|
||||||
if (height > width) {
|
if (height > width) {
|
||||||
const tmpHeight = height;
|
let tmpHeight = height;
|
||||||
height = width - 150;
|
height = width - 150;
|
||||||
width = tmpHeight + 100;
|
width = tmpHeight + 100;
|
||||||
} else {
|
} else {
|
||||||
height = height - 100;
|
height = height - 100;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View style={{ flex: 1, backgroundColor: 'black' }}>
|
||||||
|
<VideoPlayer
|
||||||
|
defaultControlsVisible={true}
|
||||||
|
fullscreen={{
|
||||||
|
visible: false
|
||||||
|
}}
|
||||||
|
slider={{
|
||||||
|
minimumTrackTintColor: this.props.mainColor,
|
||||||
|
thumbTintColor: this.props.mainColor,
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
height: height,
|
||||||
|
width: width
|
||||||
|
}}
|
||||||
|
videoProps={{
|
||||||
|
shouldPlay: true,
|
||||||
|
resizeMode: ResizeMode.CONTAIN,
|
||||||
|
source: {
|
||||||
|
uri: FileSystem.documentDirectory + uuid + '.mp4',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const videoUri = `${FileSystem.documentDirectory}${uuid}.mp4`;
|
|
||||||
console.debug({
|
|
||||||
shouldPlay: true,
|
|
||||||
resizeMode: ResizeMode.CONTAIN,
|
|
||||||
source: {
|
|
||||||
uri: videoUri,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
return (
|
|
||||||
<View style={{ flex: 1, backgroundColor: 'black' }}>
|
|
||||||
<VideoPlayer
|
|
||||||
defaultControlsVisible={true}
|
|
||||||
fullscreen={{
|
|
||||||
visible: false,
|
|
||||||
}}
|
|
||||||
slider={{
|
|
||||||
minimumTrackTintColor: this.props.mainColor,
|
|
||||||
thumbTintColor: this.props.mainColor,
|
|
||||||
}}
|
|
||||||
style={{
|
|
||||||
height: height,
|
|
||||||
width: width,
|
|
||||||
}}
|
|
||||||
videoProps={{
|
|
||||||
shouldPlay: true,
|
|
||||||
resizeMode: ResizeMode.CONTAIN,
|
|
||||||
source: {
|
|
||||||
uri: videoUri,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
errorCallback={e => {
|
|
||||||
console.error(e);
|
|
||||||
Sentry.captureException(e);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps)(VideoScreen);
|
export default connect(mapStateToProps)(VideoScreen);
|
||||||
|
|
@ -1,34 +1,29 @@
|
||||||
import Realm from 'realm';
|
import Realm from "realm";
|
||||||
|
|
||||||
import ContactModel, { ContactsSchema } from './App/Models/Contact';
|
import ContactModel, { ContactsSchema } from "./App/Models/Contact";
|
||||||
import DirectoryModel, { DirectoriesSchema } from './App/Models/Directory';
|
import DirectoryModel, { DirectoriesSchema } from "./App/Models/Directory";
|
||||||
import DocumentModel, { DocumentsSchema } from './App/Models/Document';
|
import DocumentModel, { DocumentsSchema } from "./App/Models/Document";
|
||||||
import FormModel, { FormsSchema } from './App/Models/Form';
|
import SendBrochureModel, { SendBrochuresSchema } from "./App/Models/SendBrochure";
|
||||||
import SendBrochureModel, {
|
import SettingModel, { SettingsSchema } from "./App/Models/Setting";
|
||||||
SendBrochuresSchema,
|
import UserModel, { UsersSchema } from "./App/Models/User";
|
||||||
} from './App/Models/SendBrochure';
|
|
||||||
import SettingModel, { SettingsSchema } from './App/Models/Setting';
|
const Database = {
|
||||||
import UserModel, { UsersSchema } from './App/Models/User';
|
schema: [
|
||||||
|
ContactsSchema,
|
||||||
const Database = {
|
DirectoriesSchema,
|
||||||
schema: [
|
DocumentsSchema,
|
||||||
ContactsSchema,
|
SendBrochuresSchema,
|
||||||
DirectoriesSchema,
|
SettingsSchema,
|
||||||
DocumentsSchema,
|
UsersSchema
|
||||||
SendBrochuresSchema,
|
],
|
||||||
SettingsSchema,
|
//encryptionKey: new Int8Array(64)
|
||||||
UsersSchema,
|
};
|
||||||
FormsSchema,
|
|
||||||
],
|
let realm = new Realm(Database);
|
||||||
//encryptionKey: new Int8Array(64)
|
|
||||||
};
|
export let Contact = new ContactModel(realm);
|
||||||
|
export let Directory = new DirectoryModel(realm);
|
||||||
let realm = new Realm(Database);
|
export let Document = new DocumentModel(realm);
|
||||||
|
export let SendBrochure = new SendBrochureModel(realm);
|
||||||
export const Contact = new ContactModel(realm);
|
export let Setting = new SettingModel(realm);
|
||||||
export const Directory = new DirectoryModel(realm);
|
export let User = new UserModel(realm);
|
||||||
export const Document = new DocumentModel(realm);
|
|
||||||
export const SendBrochure = new SendBrochureModel(realm);
|
|
||||||
export const Setting = new SettingModel(realm);
|
|
||||||
export const User = new UserModel(realm);
|
|
||||||
export const Form = new FormModel(realm);
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import { I18n } from 'i18n-js';
|
import { I18n } from 'i18n-js';
|
||||||
|
|
||||||
import de from './Resources/Locales/de';
|
import fr from './Resources/Locales/fr';
|
||||||
import en from './Resources/Locales/en';
|
import en from './Resources/Locales/en';
|
||||||
import fr from './Resources/Locales/fr';
|
import de from './Resources/Locales/de';
|
||||||
|
|
||||||
const i18n = new I18n({
|
const i18n = new I18n({
|
||||||
fr: fr,
|
fr: fr,
|
||||||
en: en,
|
en: en,
|
||||||
de: de,
|
de: de
|
||||||
});
|
});
|
||||||
|
|
||||||
i18n.defaultLocale = 'fr';
|
i18n.defaultLocale = 'fr';
|
||||||
i18n.locale = 'fr';
|
i18n.locale = 'fr';
|
||||||
i18n.enableFallback = true;
|
i18n.enableFallback = true;
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { createNavigationContainerRef } from '@react-navigation/native';
|
import { createNavigationContainerRef } from '@react-navigation/native';
|
||||||
|
|
||||||
export const navigationRef = createNavigationContainerRef();
|
export const navigationRef = createNavigationContainerRef()
|
||||||
|
|
||||||
export function navigate(name, params) {
|
export function navigate(name, params) {
|
||||||
if (navigationRef.isReady()) {
|
if (navigationRef.isReady()) {
|
||||||
navigationRef.navigate(name, params);
|
navigationRef.navigate(name, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
|
||||||
const commonStyles = StyleSheet.create({
|
const commonStyles = StyleSheet.create({
|
||||||
background: {
|
background: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: 'center',
|
justifyContent: "center"
|
||||||
},
|
},
|
||||||
textInput: {
|
textInput: {
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
@ -12,8 +12,8 @@ const commonStyles = StyleSheet.create({
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
paddingLeft: 10,
|
paddingLeft: 10
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default commonStyles;
|
export default commonStyles;
|
||||||
|
|
@ -1,120 +1,118 @@
|
||||||
{
|
{
|
||||||
"install": {
|
"install": {
|
||||||
"installation": "Installation",
|
"installation": "Installation",
|
||||||
"install": "Installieren Sie",
|
"install": "Installieren Sie",
|
||||||
"enter_url": "Bitte geben Sie den Link zu Ihrem Backoffice ein",
|
"enter_url": "Bitte geben Sie den Link zu Ihrem Backoffice ein",
|
||||||
"url_invalid": "Der eingegebene Link ist ungültig.",
|
"url_invalid": "Der eingegebene Link ist ungültig.",
|
||||||
"resource_dl_error": "Beim Herunterladen der folgenden Lerneinheit ist ein Fehler aufgetreten: ",
|
"resource_dl_error": "Beim Herunterladen der folgenden Lerneinheit ist ein Fehler aufgetreten: ",
|
||||||
"install_complete": "Installation abgeschlossen!",
|
"install_complete": "Installation abgeschlossen!",
|
||||||
"get_app_setting": "Wiederherstellen der Konfiguration der Anwendung",
|
"get_app_setting": "Wiederherstellen der Konfiguration der Anwendung",
|
||||||
"get_content_setting": "Abrufen der Konfiguration des Inhalts der Anwendung"
|
"get_content_setting": "Abrufen der Konfiguration des Inhalts der Anwendung"
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
"change_lang": "Sprache wechseln",
|
"change_lang": "Sprache wechseln",
|
||||||
"sync": "Synchronisation",
|
"sync": "Synchronisation",
|
||||||
"logout": "Abmeldung",
|
"logout": "Abmeldung",
|
||||||
"close": "Schließen Sie",
|
"close": "Schließen Sie",
|
||||||
"install": "Installieren",
|
"install": "Installieren",
|
||||||
"yes": "Ja",
|
"yes": "Ja",
|
||||||
"no": "Nein",
|
"no": "Nein",
|
||||||
"home": "Startseite",
|
"home": "Startseite",
|
||||||
"search": "Suche",
|
"search": "Suche",
|
||||||
"login": "Verbindung",
|
"login": "Verbindung",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"message_sent": "Email geschickt",
|
"message_sent": "Email geschickt",
|
||||||
"message_will_be_sent_after_sync": "Die Nachricht wird nach Synchronisation geschickt",
|
"message_will_be_sent_after_sync": "Die Nachricht wird nach Synchronisation geschickt",
|
||||||
"warning": "Achtung",
|
"warning": "Achtung",
|
||||||
"synchronization": "Synchronisation ",
|
"synchronization": "Synchronisation ",
|
||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"contacts": "Kontakt",
|
"contacts": "Kontakt",
|
||||||
"confirmation": "Bestätigung",
|
"confirmation": "Bestätigung",
|
||||||
"lastname": "Name",
|
"name": "Name",
|
||||||
"firstname": "Vorname",
|
"firstname": "Vorname",
|
||||||
"address": "Adresse",
|
"address": "Adresse",
|
||||||
"phone": "Telefonnummer",
|
"phone": "Telefonnummer",
|
||||||
"company": "Firma",
|
"company": "Firma",
|
||||||
"add": "Addieren",
|
"add": "Addieren",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"subject": "Betreff",
|
"subject": "Betreff",
|
||||||
"message": "Nachricht",
|
"message": "Nachricht",
|
||||||
"send": "Senden",
|
"send": "Senden",
|
||||||
"required": "erforderlich",
|
"required": "erforderlich",
|
||||||
"save": "Speichern",
|
"save": "Speichern",
|
||||||
"retry": "Noch einmal versuchen",
|
"retry": "Noch einmal versuchen",
|
||||||
"next": "Nächstes"
|
"next": "Nächstes"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"file_sharing": " Dateifreigabe",
|
"file_sharing": " Dateifreigabe",
|
||||||
"folders": "Ordner",
|
"folders": "Ordner",
|
||||||
"video": "Video",
|
"video": "Video",
|
||||||
"contact_details": "Kontaktdaten",
|
"contact_details": "Kontaktdaten",
|
||||||
"results_search": "Suchergebnisse"
|
"results_search": "Suchergebnisse",
|
||||||
},
|
"my_space": "Mein Raum"
|
||||||
"login_s": {
|
},
|
||||||
"username": "Benutzername",
|
"login_s": {
|
||||||
"password": "Passwort"
|
"username": "Benutzername",
|
||||||
},
|
"password": "Passwort"
|
||||||
"search_s": {
|
},
|
||||||
"no_result": "Keine Ergebnisse"
|
"search_s": {
|
||||||
},
|
"no_result": "Keine Ergebnisse"
|
||||||
"sync_s": {
|
},
|
||||||
"download": "Download",
|
"sync_s": {
|
||||||
"update_completed": "Update abgeschlossen",
|
"download": "Download",
|
||||||
"updating_docs": "Dokumentaktualisierung",
|
"update_completed": "Update abgeschlossen",
|
||||||
"updating_forms": "Formulare aktualisieren",
|
"updating_docs": "Dokumentaktualisierung",
|
||||||
"updating_folders": "Dateien aktualisieren",
|
"updating_folders": "Dateien aktualisieren",
|
||||||
"sending_flyers": "Brochure senden",
|
"sending_flyers": "Brochure senden",
|
||||||
"updating_contacts": "Kontakt aktualisieren",
|
"updating_contacts": "Kontakt aktualisieren",
|
||||||
"user_install_completed": "Benutzerinstallation abgeschlossen",
|
"user_install_completed": "Benutzerinstallation abgeschlossen",
|
||||||
"updating_users": "Benutzer-Update",
|
"updating_users": "Benutzer-Update",
|
||||||
"user_install": "Benutzerinstallation",
|
"user_install": "Benutzerinstallation",
|
||||||
"start_sync": "Synchronisation starten",
|
"start_sync": "Synchronisation starten",
|
||||||
"new_app_version": "Eine neue Version der Anwendung ist verfügbar!",
|
"new_app_version": "Eine neue Version der Anwendung ist verfügbar!",
|
||||||
"open_store": "Öffnen Sie den App Store"
|
"open_store": "Öffnen Sie den App Store"
|
||||||
},
|
},
|
||||||
"contact_s": {
|
"contact_s": {
|
||||||
"contact_transferred": "Kontakt weiterleiten",
|
"contact_transferred": "Kontakt weiterleiten",
|
||||||
"contact_will_be_sent_after_sync": "Der Kontakt wird nach der Synchronisation gesendet",
|
"contact_will_be_sent_after_sync": "Der Kontakt wird nach der Synchronisation gesendet",
|
||||||
"confirm_contact_delete": "Möchten Sie diesen Kontakt wirklich löschen?",
|
"confirm_contact_delete": "Möchten Sie diesen Kontakt wirklich löschen?",
|
||||||
"contact_deleted": "Kontakt gelöscht",
|
"contact_deleted": "Kontakt gelöscht",
|
||||||
"contact_added": "Kontakt hinzugefügt",
|
"contact_added": "Kontakt hinzugefügt",
|
||||||
"send_flyer": "Senden Sie eine Broschüre",
|
"send_flyer": "Senden Sie eine Broschüre",
|
||||||
"select_contact": "Wählen Sie einen Benutzer aus",
|
"select_contact": "Wählen Sie den Kontakt",
|
||||||
"transfer": "weiterleiten",
|
"transfer": "weiterleiten",
|
||||||
"contact_list": "Kontaktliste",
|
"contact_list": "Kontaktliste",
|
||||||
"documents_list": "Liste der Dokumente",
|
"documents_list": "Liste der Dokumente"
|
||||||
"input_required": "Das Feld %{placeholder} ist erforderlich",
|
},
|
||||||
"input_too_long": "Das Feld %{placeholder} ist zu lang",
|
"contact_details_s": {
|
||||||
"input_email": "Das Feld %{placeholder} muss eine gültige E-Mail-Adresse sein"
|
"visits": "Besuche",
|
||||||
},
|
"notes": "Notes",
|
||||||
"contact_details_s": {
|
"contact_saved": "Kontakt gespeichert",
|
||||||
"visits": "Besuche",
|
"confirm_visit_delete": "Sind Sie sicher, dass Sie diesen Besuch löschen möchten?",
|
||||||
"notes": "Notes",
|
"qrcode_not_vcard_format": "Dieser QRCode ist nicht im vCard-Format",
|
||||||
"contact_saved": "Kontakt gespeichert",
|
"customer": "Kunde",
|
||||||
"confirm_visit_delete": "Sind Sie sicher, dass Sie diesen Besuch löschen möchten?",
|
"prospect": "potenzieller Kunde",
|
||||||
"qrcode_not_vcard_format": "Dieser QRCode ist nicht im vCard-Format",
|
"other": "Andere",
|
||||||
"description": "Beschreibung",
|
"description": "Beschreibung",
|
||||||
"no_visits": "Kein Besuch",
|
"no_visits": "Kein Besuch",
|
||||||
"visit_name": "Besuchsname",
|
"visit_name": "Besuchsname"
|
||||||
"input_select_please_choose": "Wähle einen Wert",
|
},
|
||||||
"input_select_multiple_search": "Suchen"
|
"error": {
|
||||||
},
|
"error": "Fehler ",
|
||||||
"error": {
|
"tablet_not_connected_internet": "Das Tablet ist nicht mit dem Internet verbunden.",
|
||||||
"error": "Fehler ",
|
"tablet_not_synced_last_user": "Das Tablet wurde vom vorherigen Benutzer nicht synchronisiert",
|
||||||
"tablet_not_connected_internet": "Das Tablet ist nicht mit dem Internet verbunden.",
|
"incorrect_credentials": "Falsche Anmeldeinformationen",
|
||||||
"tablet_not_synced_last_user": "Das Tablet wurde vom vorherigen Benutzer nicht synchronisiert",
|
"must_fill_login_fields": "Sie müssen die Verbindungsfelder ausfüllen",
|
||||||
"incorrect_credentials": "Falsche Anmeldeinformationen",
|
"invalid_email_address": "Ungültige E-Mail-Adresse",
|
||||||
"must_fill_login_fields": "Sie müssen die Verbindungsfelder ausfüllen",
|
"error_has_occurred": "Ein Fehler ist aufgetreten",
|
||||||
"invalid_email_address": "Ungültige E-Mail-Adresse",
|
"must_be_connected_internet_sync": "Sie müssen mit dem Internet verbunden sein, um die Synchronisierung zu starten",
|
||||||
"invalid_firstname": "Vorname ist ungültig",
|
"incomplete_form": "Unvollständiges Formular",
|
||||||
"invalid_lastname": "Nachname ist ungültig",
|
"fill_all_fields_and_1_doc_min": "Bitte füllen Sie alle Felder, mindestens 1 Dokument und eine gültige E-Mail-Adresse aus.",
|
||||||
"invalid_phone": "Die Telefonnummer ist ungültig",
|
"fill_other_field": "Füllen Sie das Beschreibungsfeld für: Andere",
|
||||||
"field_required": "Das Feld %{placeholder} ist erforderlich",
|
"specify_type_contact": "Bitte geben Sie die Art des Kontakts an",
|
||||||
"error_has_occurred": "Ein Fehler ist aufgetreten",
|
"invalid_name": "ungültiger Name",
|
||||||
"must_be_connected_internet_sync": "Sie müssen mit dem Internet verbunden sein, um die Synchronisierung zu starten",
|
"invalid_firstname": "ungültiger Vorname",
|
||||||
"incomplete_form": "Unvollständiges Formular",
|
"camera_permission_denied": "Kameraerlaubnis verweigert",
|
||||||
"fill_all_fields_and_1_doc_min": "Bitte füllen Sie alle Felder, mindestens 1 Dokument und eine gültige E-Mail-Adresse aus.",
|
"pending_camera_permission": "Warten auf Kameraerlaubnis"
|
||||||
"camera_permission_denied": "Kameraerlaubnis verweigert",
|
}
|
||||||
"pending_camera_permission": "Warten auf Kameraerlaubnis"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,120 +1,118 @@
|
||||||
{
|
{
|
||||||
"install": {
|
"install": {
|
||||||
"installation": "Installation",
|
"installation": "Installation",
|
||||||
"install": "Install",
|
"install": "Install",
|
||||||
"enter_url": "Please enter your back office link",
|
"enter_url": "Please enter your back office link",
|
||||||
"url_invalid": "The link you entered is invalid.",
|
"url_invalid": "The link you entered is invalid.",
|
||||||
"resource_dl_error": "An error occurred while downloading the following resource: ",
|
"resource_dl_error": "An error occurred while downloading the following resource: ",
|
||||||
"install_complete": "Installation is complete!",
|
"install_complete": "Installation is complete!",
|
||||||
"get_app_setting": "Retrieving the application's configuration",
|
"get_app_setting": "Retrieving the application's configuration",
|
||||||
"get_content_setting": "Retrieving the configuration of the application content"
|
"get_content_setting": "Retrieving the configuration of the application content"
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
"change_lang": "Change language",
|
"change_lang": "Change language",
|
||||||
"sync": "Synchronization",
|
"sync": "Synchronization",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"install": "Install",
|
"install": "Install",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
"login": "Login",
|
"login": "Login",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"message_sent": "Message Sent",
|
"message_sent": "Message Sent",
|
||||||
"message_will_be_sent_after_sync": "Message will be send after synchronization",
|
"message_will_be_sent_after_sync": "Message will be send after synchronization",
|
||||||
"warning": "Warning",
|
"warning": "Warning",
|
||||||
"synchronization": "Synchronization",
|
"synchronization": "Synchronization",
|
||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"contacts": "Contacts",
|
"contacts": "Contacts",
|
||||||
"confirmation": "Confirmation",
|
"confirmation": "Confirmation",
|
||||||
"lastname": "Lastname",
|
"name": "Lastname",
|
||||||
"firstname": "Firstname",
|
"firstname": "Firstname",
|
||||||
"address": "Adress",
|
"address": "Adress",
|
||||||
"phone": "Phone number",
|
"phone": "Phone number",
|
||||||
"company": "Company",
|
"company": "Company",
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"subject": "Object",
|
"subject": "Object",
|
||||||
"message": "Message",
|
"message": "Message",
|
||||||
"send": "Send",
|
"send": "Send",
|
||||||
"required": "required",
|
"required": "required",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"retry": "Retry",
|
"retry": "Retry",
|
||||||
"next": "Next"
|
"next": "Next"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"file_sharing": "File Sharing",
|
"file_sharing": "File Sharing",
|
||||||
"folders": "Folders",
|
"folders": "Folders",
|
||||||
"video": "Video",
|
"video": "Video",
|
||||||
"contact_details": "Contact information",
|
"contact_details": "Contact information",
|
||||||
"results_search": "Search results"
|
"results_search": "Search results",
|
||||||
},
|
"my_space": "Personal Dashboard"
|
||||||
"login_s": {
|
},
|
||||||
"username": "Username",
|
"login_s": {
|
||||||
"password": "Password"
|
"username": "Username",
|
||||||
},
|
"password": "Password"
|
||||||
"search_s": {
|
},
|
||||||
"no_result": "No Result"
|
"search_s": {
|
||||||
},
|
"no_result": "No Result"
|
||||||
"sync_s": {
|
},
|
||||||
"download": "Download",
|
"sync_s": {
|
||||||
"update_completed": "Update Done",
|
"download": "Download",
|
||||||
"updating_docs": "Updating documents",
|
"update_completed": "Update Done",
|
||||||
"updating_forms": "Updating forms",
|
"updating_docs": "Updating documents",
|
||||||
"updating_folders": "Updating folders",
|
"updating_folders": "Updating folders",
|
||||||
"sending_flyers": "Sending documents",
|
"sending_flyers": "Sending documents",
|
||||||
"updating_contacts": "Updating contacts",
|
"updating_contacts": "Updating contacts",
|
||||||
"user_install_completed": "User install completed",
|
"user_install_completed": "User install completed",
|
||||||
"updating_users": "Updating Users",
|
"updating_users": "Updating Users",
|
||||||
"user_install": "Installing Users",
|
"user_install": "Installing Users",
|
||||||
"start_sync": "START SYNCHRONIZATION",
|
"start_sync": "START SYNCHRONIZATION",
|
||||||
"new_app_version": "A new version of the application is available!",
|
"new_app_version": "A new version of the application is available!",
|
||||||
"open_store": "Open the store"
|
"open_store": "Open the store"
|
||||||
},
|
},
|
||||||
"contact_s": {
|
"contact_s": {
|
||||||
"contact_transferred": "Contact Transferred",
|
"contact_transferred": "Contact Transferred",
|
||||||
"contact_will_be_sent_after_sync": "The contact will be sent after synchronization",
|
"contact_will_be_sent_after_sync": "The contact will be sent after synchronization",
|
||||||
"confirm_contact_delete": "Are you sure to delete this contact ?",
|
"confirm_contact_delete": "Are you sure to delete this contact ?",
|
||||||
"contact_deleted": "Contact deleted",
|
"contact_deleted": "Contact deleted",
|
||||||
"contact_added": "Contact added",
|
"contact_added": "Contact added",
|
||||||
"send_flyer": "Send a document",
|
"send_flyer": "Send a document",
|
||||||
"select_contact": "Select a user",
|
"select_contact": "Select the contact",
|
||||||
"transfer": "Transfer",
|
"transfer": "Transfer",
|
||||||
"contact_list": "Contact List",
|
"contact_list": "Contact List",
|
||||||
"documents_list": "Documents List"
|
"documents_list": "Documents List"
|
||||||
},
|
},
|
||||||
"contact_details_s": {
|
"contact_details_s": {
|
||||||
"visits": "Visits",
|
"visits": "Visits",
|
||||||
"notes": "Notes",
|
"notes": "Notes",
|
||||||
"contact_saved": "Contact saved",
|
"contact_saved": "Contact saved",
|
||||||
"confirm_visit_delete": "are you sure to delete this visit ?",
|
"confirm_visit_delete": "are you sure to delete this visit ?",
|
||||||
"qrcode_not_vcard_format": "This QRCode is not a VCard",
|
"qrcode_not_vcard_format": "This QRCode is not a VCard",
|
||||||
"description": "Description",
|
"customer": "Customer",
|
||||||
"no_visits": "No visits available",
|
"prospect": "Prospect",
|
||||||
"visit_name": "visits name",
|
"other": "Other",
|
||||||
"input_select_please_choose": "Select a value",
|
"description": "Description",
|
||||||
"input_select_multiple_search": "Search",
|
"no_visits": "No visits available",
|
||||||
"input_required": "The %{placeholder} field is required",
|
"visit_name": "visits name"
|
||||||
"input_too_long": "%{placeholder} field is too long",
|
},
|
||||||
"input_email": "The %{placeholder} field must be a valid email"
|
"error": {
|
||||||
},
|
"error": "Error",
|
||||||
"error": {
|
"tablet_not_connected_internet": "The tablet is not connected to Internet",
|
||||||
"error": "Error",
|
"tablet_not_synced_last_user": "The previous user didn't synchronised the tablet",
|
||||||
"tablet_not_connected_internet": "The tablet is not connected to Internet",
|
"incorrect_credentials": "Incorrect Credentials",
|
||||||
"tablet_not_synced_last_user": "The previous user didn't synchronised the tablet",
|
"must_fill_login_fields": "You must fill the login fields.",
|
||||||
"incorrect_credentials": "Incorrect Credentials",
|
"invalid_email_address": "Invalid E-mail adress",
|
||||||
"must_fill_login_fields": "You must fill the login fields.",
|
"error_has_occurred": "An error occured",
|
||||||
"invalid_email_address": "Invalid E-mail adress",
|
"must_be_connected_internet_sync": "You must be connected to internet to be able to synchronize",
|
||||||
"invalid_firstname": "Firstname is not valid",
|
"incomplete_form": "Incomplete Form",
|
||||||
"invalid_lastname": "Lastname is not valid",
|
"fill_all_fields_and_1_doc_min": "Please fill up all the fields, at least one document and a valid e-mail adress",
|
||||||
"invalid_phone": "Phone is not valid",
|
"fill_other_field": "You must fill the description field for : Other",
|
||||||
"field_required": "The %{placeholder} field is required",
|
"specify_type_contact": "You must specify the contact type",
|
||||||
"error_has_occurred": "An error occured",
|
"invalid_name": "Invalid lastname",
|
||||||
"must_be_connected_internet_sync": "You must be connected to internet to be able to synchronize",
|
"invalid_firstname": "Invalid firstname",
|
||||||
"incomplete_form": "Incomplete Form",
|
"camera_permission_denied": "Camera Permission Denied",
|
||||||
"fill_all_fields_and_1_doc_min": "Please fill up all the fields, at least one document and a valid e-mail adress",
|
"pending_camera_permission": "Waiting for the camera permission"
|
||||||
"camera_permission_denied": "Camera Permission Denied",
|
}
|
||||||
"pending_camera_permission": "Waiting for the camera permission"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,124 +1,122 @@
|
||||||
{
|
{
|
||||||
"install": {
|
"install": {
|
||||||
"installation": "Installation",
|
"installation": "Installation",
|
||||||
"install": "Installer",
|
"install": "Installer",
|
||||||
"enter_url": "Veuillez entrer le lien de votre back-office",
|
"enter_url": "Veuillez entrer le lien de votre back-office",
|
||||||
"url_invalid": "Le lien saisi est invalide.",
|
"url_invalid": "Le lien saisi est invalide.",
|
||||||
"resource_dl_error": "Une erreur est survenue lors du téléchargement de la ressource suivante : ",
|
"resource_dl_error": "Une erreur est survenue lors du téléchargement de la ressource suivante : ",
|
||||||
"install_complete": "Installation terminée !",
|
"install_complete": "Installation terminée !",
|
||||||
"get_app_setting": "Récupération de la configuration de l'application",
|
"get_app_setting": "Récupération de la configuration de l'application",
|
||||||
"get_content_setting": "Récupération de la configuration du contenu de l'application"
|
"get_content_setting": "Récupération de la configuration du contenu de l'application"
|
||||||
},
|
},
|
||||||
"global": {
|
"global": {
|
||||||
"change_lang": "Changer de langue",
|
"change_lang": "Changer de langue",
|
||||||
"sync": "Synchronisation",
|
"sync": "Synchronisation",
|
||||||
"logout": "Se déconnecter",
|
"logout": "Se déconnecter",
|
||||||
"close": "Fermer",
|
"close": "Fermer",
|
||||||
"yes": "Oui",
|
"yes": "Oui",
|
||||||
"no": "Non",
|
"no": "Non",
|
||||||
"home": "Accueil",
|
"home": "Accueil",
|
||||||
"search": "Recherche",
|
"search": "Recherche",
|
||||||
"login": "Connexion",
|
"login": "Connexion",
|
||||||
"email": "Email",
|
"email": "Email",
|
||||||
"message_sent": "Message envoyé",
|
"message_sent": "Message envoyé",
|
||||||
"message_will_be_sent_after_sync": "Le message sera envoyé après synchronisation",
|
"message_will_be_sent_after_sync": "Le message sera envoyé après synchronisation",
|
||||||
"warning": "Attention",
|
"warning": "Attention",
|
||||||
"synchronization": "Synchronisation",
|
"synchronization": "Synchronisation",
|
||||||
"videos": "Vidéos",
|
"videos": "Vidéos",
|
||||||
"contacts": "Contacts",
|
"contacts": "Contacts",
|
||||||
"confirmation": "Confirmation",
|
"confirmation": "Confirmation",
|
||||||
"lastname": "Nom",
|
"name": "Nom",
|
||||||
"firstname": "Prénom",
|
"firstname": "Prénom",
|
||||||
"address": "Adresse",
|
"address": "Adresse",
|
||||||
"phone": "Téléphone",
|
"phone": "Téléphone",
|
||||||
"company": "Société",
|
"company": "Société",
|
||||||
"add": "Ajouter",
|
"add": "Ajouter",
|
||||||
"cancel": "Annuler",
|
"cancel": "Annuler",
|
||||||
"subject": "Objet",
|
"subject": "Objet",
|
||||||
"message": "Message",
|
"message": "Message",
|
||||||
"send": "Envoyer",
|
"send": "Envoyer",
|
||||||
"required": "requis",
|
"required": "requis",
|
||||||
"save": "Enregistrer",
|
"save": "Enregistrer",
|
||||||
"retry": "Réessayer",
|
"retry": "Réessayer",
|
||||||
"next": "Suivant"
|
"next": "Suivant"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"file_sharing": "Partage de fichier",
|
"file_sharing": "Partage de fichier",
|
||||||
"folders": "Dossiers",
|
"folders": "Dossiers",
|
||||||
"video": "Vidéo",
|
"video": "Vidéo",
|
||||||
"contact_details": "Détails du contact",
|
"contact_details": "Détails du contact",
|
||||||
"results_search": "Résultat(s) de votre recherche"
|
"results_search": "Résultat(s) de votre recherche",
|
||||||
},
|
"my_space": "Mon espace"
|
||||||
"login_s": {
|
},
|
||||||
"username": "Identifiant",
|
"login_s": {
|
||||||
"password": "Mot de passe",
|
"username": "Identifiant",
|
||||||
"missing_users": "Utilisateurs introuvables"
|
"password": "Mot de passe",
|
||||||
},
|
"missing_users": "Utilisateurs introuvables"
|
||||||
"search_s": {
|
},
|
||||||
"no_result": "Aucun résultat"
|
"search_s": {
|
||||||
},
|
"no_result": "Aucun résultat"
|
||||||
"sync_s": {
|
},
|
||||||
"download": "Téléchargement",
|
"sync_s": {
|
||||||
"update_completed": "Mise à jour effectuée",
|
"download": "Téléchargement",
|
||||||
"updating_docs": "Mise à jour des documents",
|
"update_completed": "Mise à jour effectuée",
|
||||||
"updating_forms": "Mise à jour des formulaires",
|
"updating_docs": "Mise à jour des documents",
|
||||||
"updating_folders": "Mise à jour des dossiers",
|
"updating_folders": "Mise à jour des dossiers",
|
||||||
"sending_flyers": "Envoi des brochures",
|
"sending_flyers": "Envoi des brochures",
|
||||||
"updating_contacts": "Mise à jour des contacts",
|
"updating_contacts": "Mise à jour des contacts",
|
||||||
"user_install_completed": "Installation des utilisateurs effectuée",
|
"user_install_completed": "Installation des utilisateurs effectuée",
|
||||||
"updating_users": "Mise à jour des utilisateurs",
|
"updating_users": "Mise à jour des utilisateurs",
|
||||||
"user_install": "Installation des utilisateurs",
|
"user_install": "Installation des utilisateurs",
|
||||||
"start_sync": "LANCER LA SYNCHRONISATION",
|
"start_sync": "LANCER LA SYNCHRONISATION",
|
||||||
"new_app_version": "Une nouvelle version de l'application est disponible !",
|
"new_app_version": "Une nouvelle version de l'application est disponible !",
|
||||||
"open_store": "Ouvrir le store"
|
"open_store": "Ouvrir le store"
|
||||||
},
|
},
|
||||||
"contact_s": {
|
"contact_s": {
|
||||||
"contact_transferred": "Contact transféré",
|
"contact_transferred": "Contact transféré",
|
||||||
"contact_will_be_sent_after_sync": "Le contact sera envoyé après synchronisation",
|
"contact_will_be_sent_after_sync": "Le contact sera envoyé après synchronisation",
|
||||||
"confirm_contact_delete": "Êtes-vous sûr de vouloir supprimer ce contact ?",
|
"confirm_contact_delete": "Êtes-vous sûr de vouloir supprimer ce contact ?",
|
||||||
"contact_deleted": "Contact supprimé",
|
"contact_deleted": "Contact supprimé",
|
||||||
"contact_added": "Contact ajouté",
|
"contact_added": "Contact ajouté",
|
||||||
"send_flyer": "Envoyer une brochure",
|
"send_flyer": "Envoyer une brochure",
|
||||||
"select_contact": "Sélectionnez un utilisateur",
|
"select_contact": "Sélectionnez le contact",
|
||||||
"transfer": "Transférer",
|
"transfer": "Transférer",
|
||||||
"contact_list": "Liste des contacts",
|
"contact_list": "Liste des contacts",
|
||||||
"documents_list": "Liste des documents"
|
"documents_list": "Liste des documents"
|
||||||
},
|
},
|
||||||
"contact_details_s": {
|
"contact_details_s": {
|
||||||
"visits": "Visites",
|
"visits": "Visites",
|
||||||
"notes": "Notes",
|
"notes": "Notes",
|
||||||
"contact_saved": "Contact enregistré",
|
"contact_saved": "Contact enregistré",
|
||||||
"confirm_visit_delete": "Êtes-vous sûr de vouloir supprimer cette visite ?",
|
"confirm_visit_delete": "Êtes-vous sûr de vouloir supprimer cette visite ?",
|
||||||
"qrcode_not_vcard_format": "Ce QRCode n'est pas au format vCard",
|
"qrcode_not_vcard_format": "Ce QRCode n'est pas au format vCard",
|
||||||
"description": "Description",
|
"customer": "Client",
|
||||||
"no_visits": "Aucune visites",
|
"prospect": "Prospect",
|
||||||
"visit_name": "Nom de la visite",
|
"other": "Autre",
|
||||||
"input_select_please_choose": "Selectionnez un élément",
|
"description": "Description",
|
||||||
"input_select_multiple_search": "Recherche",
|
"no_visits": "Aucune visites",
|
||||||
"input_required": "Le champ %{placeholder} est obligatoire",
|
"visit_name": "Nom de la visite"
|
||||||
"input_too_long": "Le champ %{placeholder} est trop long",
|
},
|
||||||
"input_email": "Le champ %{placeholder} doit être un email valide"
|
"error": {
|
||||||
},
|
"error": "Erreur",
|
||||||
"error": {
|
"tablet_not_connected_internet": "La tablette n'est pas connectée à internet.",
|
||||||
"error": "Erreur",
|
"tablet_not_synced_last_user": "La tablette n'as pas été synchronisée par l'utilisateur précédent.",
|
||||||
"tablet_not_connected_internet": "La tablette n'est pas connectée à internet.",
|
"incorrect_credentials": "Identifiants incorrect.",
|
||||||
"tablet_not_synced_last_user": "La tablette n'as pas été synchronisée par l'utilisateur précédent.",
|
"must_fill_login_fields": "Vous devez-remplir les champs de connexion.",
|
||||||
"incorrect_credentials": "Identifiants incorrect.",
|
"invalid_email_address": "Adresse email invalide",
|
||||||
"must_fill_login_fields": "Vous devez-remplir les champs de connexion.",
|
"error_has_occurred": "Une erreur est survenue",
|
||||||
"invalid_email_address": "Adresse email invalide",
|
"must_be_connected_internet_sync": "Vous devez être connecté à internet pour lancer la synchronisation",
|
||||||
"invalid_firstname": "Prénom invalide",
|
"incomplete_form": "Formulaire incomplet",
|
||||||
"invalid_lastname": "Nom invalide",
|
"fill_all_fields_and_1_doc_min": "Veuillez remplir tous les champs, 1 document minimum et une adresse email valide",
|
||||||
"invalid_phone": "Téléphone invalide",
|
"fill_other_field": "Vous devez remplir le champs description pour : Autre",
|
||||||
"field_required": "Le champ %{placeholder} est obligatoire",
|
"specify_type_contact": "Vous devez préciser le type de contact",
|
||||||
"error_has_occurred": "Une erreur est survenue",
|
"invalid_name": "Nom invalide",
|
||||||
"must_be_connected_internet_sync": "Vous devez être connecté à internet pour lancer la synchronisation",
|
"invalid_firstname": "Prénom invalide",
|
||||||
"incomplete_form": "Formulaire incomplet",
|
"camera_permission_denied": "Permission caméra refusée",
|
||||||
"fill_all_fields_and_1_doc_min": "Veuillez remplir tous les champs, 1 document minimum et une adresse email valide",
|
"pending_camera_permission": "En attente de permission caméra"
|
||||||
"camera_permission_denied": "Permission caméra refusée",
|
},
|
||||||
"pending_camera_permission": "En attente de permission caméra"
|
"alert": {
|
||||||
},
|
"error": "Erreur",
|
||||||
"alert": {
|
"info": "Information"
|
||||||
"error": "Erreur",
|
}
|
||||||
"info": "Information"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,43 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
margin: 10,
|
margin: 10,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
},
|
},
|
||||||
clearCheckbox: {
|
clearCheckbox: {
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
},
|
},
|
||||||
clearRadio: {
|
clearRadio: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
backgroundColor: '#00000000',
|
backgroundColor: '#00000000',
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
flex: 2,
|
flex: 2,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
},
|
},
|
||||||
textArea: {
|
textArea: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
textAlignVertical: 'top',
|
textAlignVertical: 'top',
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
width: 35,
|
width: 35,
|
||||||
height: 35,
|
height: 35,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
margin: 2,
|
margin: 2,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,74 +1,74 @@
|
||||||
import {Dimensions, StyleSheet} from 'react-native';
|
import { StyleSheet, Dimensions } from 'react-native';
|
||||||
|
|
||||||
const {width} = Dimensions.get('window');
|
const { width } = Dimensions.get('window');
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
padding: 15,
|
padding: 15,
|
||||||
marginHorizontal: 15,
|
marginHorizontal: 15,
|
||||||
},
|
},
|
||||||
clickable: {
|
clickable: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
width: width / 4,
|
width: width / 4,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold'
|
||||||
},
|
},
|
||||||
company: {
|
company: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
width: width / 4,
|
width: width / 4,
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
width: width / 4,
|
width: width / 4,
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
width: width / 4,
|
width: width / 4,
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
width: 35,
|
width: 35,
|
||||||
height: 35,
|
height: 35,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
margin: 2,
|
margin: 2,
|
||||||
},
|
},
|
||||||
txtSendBrochure: {
|
txtSendBrochure: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: 'lightgrey',
|
borderColor: 'lightgrey',
|
||||||
width: 280,
|
width: 280,
|
||||||
marginBottom: 5,
|
marginBottom: 5,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
},
|
},
|
||||||
textAreaSendBrochure: {
|
textAreaSendBrochure: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderColor: 'lightgrey',
|
borderColor: 'lightgrey',
|
||||||
width: 280,
|
width: 280,
|
||||||
height: 150,
|
height: 150,
|
||||||
marginBottom: 5,
|
marginBottom: 5,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
textAlignVertical: 'top',
|
textAlignVertical: 'top',
|
||||||
},
|
},
|
||||||
inputSearch: {
|
inputSearch: {
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
width: 200,
|
width: 200,
|
||||||
paddingLeft: 20,
|
paddingLeft: 20
|
||||||
},
|
},
|
||||||
btnSearch: {
|
btnSearch: {
|
||||||
width: 50,
|
width: 50,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center'
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,36 +1,36 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
treeviewContainer: {
|
treeviewContainer: {
|
||||||
width: 290,
|
width: 290,
|
||||||
},
|
},
|
||||||
scrollview: {
|
scrollview: {
|
||||||
flex: 2,
|
flex: 2,
|
||||||
},
|
},
|
||||||
filesContainer: {
|
filesContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: 200,
|
height: 200,
|
||||||
width: 180,
|
width: 180,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
},
|
},
|
||||||
fileTxt: {
|
fileTxt: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5,
|
padding: 5
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,39 +1,39 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'flex-end',
|
alignItems: 'flex-end',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 300,
|
width: 300,
|
||||||
borderColor: 'grey',
|
borderColor: 'grey',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
marginRight: 50,
|
marginRight: 50,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 80,
|
height: 80,
|
||||||
borderRadius: 10,
|
borderRadius: 10
|
||||||
},
|
},
|
||||||
btnTxt: {
|
btnTxt: {
|
||||||
fontSize: 20,
|
fontSize: 20
|
||||||
},
|
},
|
||||||
btnImg: {
|
btnImg: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: 15,
|
left: 15,
|
||||||
height: 50,
|
height: 50,
|
||||||
width: 50,
|
width: 50,
|
||||||
resizeMode: 'stretch',
|
resizeMode: 'stretch'
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
marginBottom: 20,
|
marginBottom: 20
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
marginTop: 20,
|
marginTop: 20
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
marginBottom: 20,
|
marginBottom: 20
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 300,
|
width: 300,
|
||||||
borderColor: 'grey',
|
borderColor: 'grey',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
paddingLeft: 10,
|
paddingLeft: 10
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
searchInput: {
|
searchInput: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
width: 200,
|
width: 200,
|
||||||
paddingLeft: 20,
|
paddingLeft: 20,
|
||||||
},
|
|
||||||
btnSearch: {
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
},
|
|
||||||
drawer: {
|
|
||||||
container: {
|
|
||||||
flex: 1,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
backgroundColor: '#ffffff',
|
|
||||||
padding: 20,
|
|
||||||
},
|
},
|
||||||
btn: {
|
btnSearch: {
|
||||||
borderWidth: 1,
|
width: 50,
|
||||||
borderColor: 'black',
|
height: 50,
|
||||||
flexDirection: 'row',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
|
||||||
padding: 10,
|
|
||||||
marginBottom: 10,
|
|
||||||
},
|
},
|
||||||
btnText: {
|
drawer: {
|
||||||
marginLeft: 10,
|
container: {
|
||||||
},
|
flex: 1,
|
||||||
},
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
padding: 20
|
||||||
|
},
|
||||||
|
btn: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: 'black',
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
padding: 10,
|
||||||
|
marginBottom: 10
|
||||||
|
},
|
||||||
|
btnText: {
|
||||||
|
marginLeft: 10
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
scrollview: {
|
scrollview: {
|
||||||
flex: 2,
|
flex: 2,
|
||||||
},
|
},
|
||||||
filesContainer: {
|
filesContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: 200,
|
height: 200,
|
||||||
width: 180,
|
width: 180,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
},
|
},
|
||||||
fileTxt: {
|
fileTxt: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5,
|
padding: 5
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
import { Dimensions, StyleSheet } from 'react-native';
|
import { StyleSheet, Dimensions } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 300,
|
width: 300,
|
||||||
borderColor: 'grey',
|
borderColor: 'grey',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
},
|
},
|
||||||
pdf: {
|
pdf: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
width: Dimensions.get('window').width,
|
width: Dimensions.get('window').width,
|
||||||
height: Dimensions.get('window').height,
|
height: Dimensions.get('window').height,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
scrollview: {
|
scrollview: {
|
||||||
flex: 2,
|
flex: 2,
|
||||||
},
|
},
|
||||||
filesContainer: {
|
filesContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: 200,
|
height: 200,
|
||||||
width: 180,
|
width: 180,
|
||||||
margin: 10,
|
margin: 10,
|
||||||
},
|
},
|
||||||
fileTxt: {
|
fileTxt: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5,
|
padding: 5
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
btnWrapper: {
|
btnWrapper: {
|
||||||
marginTop: 20,
|
marginTop: 20
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
17387
ComApp/yarn.lock
17387
ComApp/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue