2022-09-29 15:03:47 +02:00
|
|
|
// Lodash
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
// Http Client
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
// Network Infos
|
|
|
|
|
import NetInfo from "@react-native-community/netinfo";
|
|
|
|
|
// Translations
|
|
|
|
|
import i18n from "../../I18n";
|
2022-09-29 16:22:58 +02:00
|
|
|
// Database
|
|
|
|
|
import { Setting } from "../../Database";
|
2022-09-29 15:03:47 +02:00
|
|
|
|
|
|
|
|
const api_token = 'toto';
|
|
|
|
|
|
2022-09-28 18:08:39 +02:00
|
|
|
class InstallController {
|
|
|
|
|
|
|
|
|
|
getConfig(url) {
|
2022-09-29 15:03:47 +02:00
|
|
|
NetInfo.fetch().then(state => {
|
|
|
|
|
if (state.isConnected) {
|
|
|
|
|
axios({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: url + '/api/settings',
|
|
|
|
|
responseType: 'json',
|
|
|
|
|
params: {
|
|
|
|
|
token: api_token
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.then(function (response) {
|
|
|
|
|
if (response.data) {
|
|
|
|
|
if (response.data.status === "OK") {
|
|
|
|
|
_.forEach(response.data.datas, function (value, key) {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case "MainColor":
|
2022-09-29 16:22:58 +02:00
|
|
|
Setting.add({ key: key, value: value });
|
2022-09-29 15:03:47 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2022-09-29 16:22:58 +02:00
|
|
|
});
|
2022-09-29 15:03:47 +02:00
|
|
|
} else {
|
|
|
|
|
alert(i18n.t("error.error_has_occurred"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(function (error) {
|
2022-09-29 16:22:58 +02:00
|
|
|
console.log(error)
|
2022-09-29 15:03:47 +02:00
|
|
|
alert(i18n.t("error.error_has_occurred"));
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
alert(i18n.t("error.tablet_not_connected_internet"));
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-09-28 18:08:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default new InstallController();
|