configuration.controller.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. angular.module('odoo')
  2. /**
  3. *
  4. */
  5. .controller('ConfigurationController', function (
  6. $scope,
  7. $state,
  8. $ionicLoading,
  9. $ionicPopup,
  10. $localStorage,
  11. odooFactory,
  12. databaseFactory
  13. ) {
  14. $scope.loading = false;
  15. $scope.configuration = $localStorage.$default({
  16. host: '192.168.2.105',
  17. port: 8069,
  18. database: 'odoo',
  19. username: 'admin',
  20. password: 'admin',
  21. id: null,
  22. user_name: null,
  23. company_id: null
  24. });
  25. /**
  26. *
  27. */
  28. $scope.auth = function () {
  29. $scope.loading = true;
  30. odooFactory.auth(function (id) {
  31. $scope.configuration.id = id;
  32. odooFactory.read('res.users', [['id', '=', id]], function (user) {
  33. var data = user[0];
  34. $scope.configuration.user_name = data.name;
  35. $scope.configuration.company_id = data.company_id[0];
  36. databaseFactory.initTables(function (result) {
  37. $scope.loading = false;
  38. $state.go('app.main');
  39. }, function (err) {
  40. $scope.loading = false;
  41. console.log(err);
  42. });
  43. }, function (readErr) {
  44. $scope.loading = false;
  45. console.log(readErr);
  46. });
  47. }, function (err) {
  48. $scope.loading = false;
  49. console.log(err);
  50. });
  51. }
  52. });