diff --git a/ComApp/src/App/Controllers/InstallController.js b/ComApp/src/App/Controllers/InstallController.js index 894dc71..c08570c 100644 --- a/ComApp/src/App/Controllers/InstallController.js +++ b/ComApp/src/App/Controllers/InstallController.js @@ -12,7 +12,6 @@ import { Setting } from "../../Database"; // FileSytem import * as FileSystem from 'expo-file-system'; - const api_token = 'toto'; class InstallController { @@ -29,38 +28,43 @@ class InstallController { }, }) .then(function (response) { - if (response.data) { - if (response.data.status === "OK") { - _.forEach(response.data.datas, function (value, key) { - switch (key) { - case "MainColor": - Setting.add({ key: key, value: value }); - break; - case "SquaredLogo": - console.log("SquaredLogo"); - break; - case "RectangleLogo": - console.log("RectangleLogo"); - break; - case "BackgroundImage": - console.log("BackgroundImage"); - break; - case "HomeButtonImage": - console.log("HomeButtonImage"); - break; - } - }); - } else { - Alert.alert(i18n.t("error.error"), i18n.t("error.error_has_occurred")); + if (response.data) { + if (response.data.status === "OK") { + _.forEach(response.data.datas, function (value, key) { + switch (key) { + case "MainColor": + Setting.add({ key: key, value: value }); + break; + case "SquaredLogo": + case "RectangleLogo": + case "BackgroundImage": + case "HomeButtonImage": + FileSystem.downloadAsync( + url + "/" + value, + FileSystem.documentDirectory + key + '.png' + ) + .then(({ uri }) => { + console.log('Finished downloading to ', uri); + }) + .catch(error => { + Alert.alert(i18n.t("alert.error"), i18n.t("install.resource_dl_error") + key); + console.error(error); + }); + break; + } + }); + Alert.alert(i18n.t("alert.info"), i18n.t("install.install_complete")); + } else { + Alert.alert(i18n.t("alert.error"), i18n.t("alert.error_has_occurred")); + } } - } - }) + }) .catch(function (error) { console.log(error) - Alert.alert(i18n.t("error.error"), i18n.t("error.error_has_occurred")); - }) + Alert.alert(i18n.t("alert.error"), i18n.t("alert.error_has_occurred")); + }) } else { - Alert.alert(i18n.t("error.error"), i18n.t("error.tablet_not_connected_internet")); + Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet")); } }); } diff --git a/ComApp/src/App/Views/InstallScreen.js b/ComApp/src/App/Views/InstallScreen.js index b60fce9..4f1a175 100644 --- a/ComApp/src/App/Views/InstallScreen.js +++ b/ComApp/src/App/Views/InstallScreen.js @@ -31,12 +31,12 @@ class InstallScreen extends React.Component { title={ i18n.t('install.install')} onPress={() => { if (this.state.url.length === 0) { - Alert.alert(i18n.t("error.error"), i18n.t("install.enter_url")); + Alert.alert(i18n.t("alert.error"), i18n.t("install.enter_url")); } else { if (Helpers.isUrlValid(this.state.url)) { InstallController.getConfig(this.state.url); } else { - Alert.alert(i18n.t("error.error"), i18n.t("install.url_invalid")); + Alert.alert(i18n.t("alert.error"), i18n.t("install.url_invalid")); } } }} diff --git a/ComApp/src/Resources/Locales/fr.json b/ComApp/src/Resources/Locales/fr.json index 2911634..44ba89f 100644 --- a/ComApp/src/Resources/Locales/fr.json +++ b/ComApp/src/Resources/Locales/fr.json @@ -2,7 +2,9 @@ "install": { "install": "Installer", "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 : ", + "install_complete": "Installation terminée !" }, "global": { "yes": "Oui", @@ -110,6 +112,10 @@ "camera_permission_denied": "Permission caméra refusée", "pending_camera_permission": "En attente de permission caméra" }, + "alert": { + "error": "Erreur", + "info": "Information" + }, "custom": { "select-1": { "title": "Type de commerce",