configuration.controller.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. databaseFactory
  17. ) {
  18. $scope.loading = false;
  19. $scope.configuration = $localStorage.$default({
  20. host: '192.168.2.105',
  21. port: 8069,
  22. database: 'odoo',
  23. username: 'admin',
  24. password: 'admin',
  25. id: null,
  26. user_name: null,
  27. company_id: null
  28. });
  29. /**
  30. *
  31. */
  32. $scope.auth = function () {
  33. $scope.loading = true;
  34. odooFactory.auth(function (id) {
  35. $scope.configuration.id = id;
  36. odooFactory.read('res.users', [['id', '=', id]], function (user) {
  37. var data = user[0];
  38. $scope.configuration.user_name = data.name;
  39. $scope.configuration.company_id = data.company_id[0];
  40. databaseFactory.initTables(function (result) {
  41. $scope.loading = false;
  42. $state.go('app.main');
  43. }, function (err) {
  44. $scope.loading = false;
  45. console.log(err);
  46. });
  47. }, function (readErr) {
  48. $scope.loading = false;
  49. console.log(readErr);
  50. });
  51. }, function (err) {
  52. $scope.loading = false;
  53. console.log(err);
  54. });
  55. }
  56. });