configuration.controller.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. angular.module('odoo')
  2. /**
  3. * ___ __ _ _ _ ___ _ _ _
  4. * / __|___ _ _ / _(_)__ _ _ _ _ _ __ _| |_(_)___ _ _ / __|___ _ _| |_ _ _ ___| | |___ _ _
  5. * | (__/ _ \ ' \| _| / _` | || | '_/ _` | _| / _ \ ' \ | (__/ _ \ ' \ _| '_/ _ \ | / -_) '_|
  6. * \___\___/_||_|_| |_\__, |\_,_|_| \__,_|\__|_\___/_||_| \___\___/_||_\__|_| \___/_|_\___|_|
  7. * |___/
  8. */
  9. .controller('ConfigurationController', function (
  10. $scope,
  11. $state,
  12. $ionicLoading,
  13. $ionicPopup,
  14. $localStorage,
  15. odooFactory,
  16. deviceFactory,
  17. databaseFactory
  18. ) {
  19. $scope.loading = false;
  20. $scope.configuration = $localStorage.$default({
  21. host: '192.168.88.132',
  22. port: 8069,
  23. database: 'odoo',
  24. username: 'admin',
  25. password: 'admin',
  26. id: null,
  27. user_name: null,
  28. company_id: null
  29. });
  30. /**
  31. *
  32. */
  33. $scope.auth = function () {
  34. $scope.loading = true;
  35. odooFactory.auth(function (id) {
  36. $scope.configuration.id = id;
  37. odooFactory.read('res.users', [['id', '=', id]], function (user) {
  38. var data = user[0];
  39. $scope.configuration.user_name = data.name;
  40. $scope.configuration.company_id = data.company_id[0];
  41. databaseFactory.initTables(function (result) {
  42. $scope.loading = false;
  43. $state.go('app.main');
  44. }, function (err) {
  45. $scope.loading = false;
  46. console.log(err);
  47. });
  48. }, function (readErr) {
  49. console.log(readErr);
  50. $scope.loading = false;
  51. deviceFactory.toast('No se ha podido identificar al usuario');
  52. });
  53. }, function (err) {
  54. console.log(err);
  55. $scope.loading = false;
  56. deviceFactory.toast('No se ha podido establecer una conexión al servidor');
  57. });
  58. }
  59. });