1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- angular.module('odoo')
- .controller('ConfigurationController', function($scope, $state, $ionicLoading, $ionicPopup, odoo, storage) {
- $scope.config = { host: '192.168.88.116', port: 8069, database: 'odoo', username: 'admin', password: 'admin' }
- // Apply configuration for app
- $scope.configure = function () {
- $ionicLoading.show();
- storage.count('user', function (total) {
- if (total == 0) {
- odoo.auth($scope.config, function (user) {
- storage.saveUser(
- [
- user.id,
- $scope.config.host,
- $scope.config.port,
- $scope.config.database,
- user.username,
- user.password
- ], function (newId) {
- $ionicLoading.hide();
- $state.go('app.main');
- console.log(newId);
- }, function (error) {
- $ionicLoading.hide();
- console.log(error);
- });
- }, function (error) {
- $ionicLoading.hide();
- var message = 'Configuración no válida';
- if (angular.isObject(error)) {
- message = 'No se pudo establecer una llamada al servidor';
- }
- $ionicPopup.alert({ title: 'Ha fallado el inicio de sesión', template: message });
- });
- } else {
- $ionicLoading.hide();
- $state.go('app.main');
- }
- }, function (error) {
- $ionicLoading.hide();
- console.log(error);
- });
- }
- });
|