12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- angular.module('odoo')
- .controller('ConfigurationController', function (
- $scope,
- $state,
- $ionicLoading,
- $ionicPopup,
- userStorageFactory,
- odooFactory,
- sqlFactory
- ) {
- // $scope.config = { host: 'localhost', port: 8069, database: 'odoo', username: 'admin', password: 'admin' };
- $scope.config = { host: '192.168.2.106', port: 8069, database: 'odoo', username: 'admin', password: 'admin' };
- $scope.$on('ionicView.enter', function () {
- console.log('Evaluar usuario');
- });
- // Apply configuration for app
- $scope.configure = function () {
- $ionicLoading.show();
- sqlFactory.count('user', function (total) {
- if (total == 0) {
- odooFactory.auth($scope.config, function (user) {
- userStorageFactory.save(
- [
- user.id,
- $scope.config.host,
- $scope.config.port,
- $scope.config.database,
- user.username,
- user.password
- ], function (newId) {
- $ionicLoading.hide();
- $state.go('app.main');
- }, function (error) {
- $ionicLoading.hide();
- });
- }, 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();
- });
- }
- });
|