Forráskód Böngészése

authorization engine changed from sqlstorage to localstorage service bindings

robert 8 éve
szülő
commit
9557efcede

+ 2 - 1
bower.json

@@ -10,6 +10,7 @@
     "ionic-filter-bar": "^1.1.1",
     "ionic-toast": "^0.4.1",
     "angular-translate": "^2.11.1",
-    "squel": "^5.3.3"
+    "squel": "^5.3.3",
+    "ngstorage": "^0.3.11"
   }
 }

+ 1 - 2
package.json

@@ -23,8 +23,7 @@
     "ionic-plugin-keyboard",
     "cordova-plugin-camera",
     "cordova-plugin-contacts",
-    "cordova-plugin-vibration",
-    "cordova-plugin-file"
+    "cordova-plugin-vibration"
   ],
   "cordovaPlatforms": [
     "android"

+ 1 - 2
www/index.html

@@ -37,9 +37,7 @@
 
     <!-- Factories -->
     <script src="js/factories/utils.factory.js"></script>
-    <script src="js/factories/preferences.factory.js"></script>
     <script src="js/factories/odoo.factory.js"></script>
-    <script src="js/factories/user.storage.factory.js"></script>
     <script src="js/factories/database.factory.js"></script>
     <script src="js/factories/sales/customer.storage.factory.js"></script>
     <script src="js/factories/sales/customer.sync.factory.js"></script>
@@ -55,6 +53,7 @@
     <script src="lib/angular-xmlrpc/xmlrpc.js"></script>
     <script src="lib/ionic-toast/dist/ionic-toast.bundle.min.js"></script>
     <script src="lib/squel/dist/squel-basic.js"></script>
+    <script src="lib/ngstorage/ngStorage.js"></script>
   </head>
   <body ng-app="odoo">
       <ion-nav-view animation="slide-left-right"></ion-nav-view>

+ 0 - 90
www/init.sql

@@ -1,90 +0,0 @@
--- User Table
-CREATE TABLE IF NOT EXISTS 'user' (
-    'id' INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT,
-    'remote_id' INTEGER DEFAULT 0,
-    'host' VARCHAR(35) DEFAULT 0,
-    'port' INTEGER DEFAULT 0,
-    'database' VARCHAR(35) DEFAULT NULL,
-    'username' VARCHAR(35) DEFAULT NULL,
-    'password' VARCHAR(35) DEFAULT NULL
-);
-
--- Partner Table
-CREATE TABLE IF NOT EXISTS 'partner' (
-    'id' INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT,
-    'remote_id' INTEGER DEFAULT 0,
-    'modified' INTEGER DEFAULT 0,
-    'modified_date' TEXT DEFAULT CURRENT_TIMESTAMP,
-    'name' VARCHAR(35) DEFAULT NULL,
-    'city' VARCHAR(35) DEFAULT NULL,
-    'mobile' VARCHAR(20) DEFAULT NULL,
-    'phone' VARCHAR(20) DEFAULT NULL,
-    'fax' VARCHAR(20) DEFAULT NULL,
-    'email' VARCHAR(100) DEFAULT NULL,
-    'street' VARCHAR(35) DEFAULT NULL,
-    'street2' VARCHAR(35) DEFAULT NULL,
-    'image_medium' BLOB DEFAULT NULL,
-    'image_small' BLOB DEFAULT NULL,
-    'comment' VARCHAR(160) DEFAULT NULL,
-    'customer' INTEGER DEFAULT 0,
-    'employee' INTEGER DEFAULT 0,
-    'is_company' INTEGER DEFAULT 0,
-    'debit' INTEGER DEFAULT 0,
-    'debit_limit' INTEGER DEFAULT 0,
-    'opportunity_count' INTEGER DEFAULT 0,
-    'contracts_count' INTEGER DEFAULT 0,
-    'journal_item_count' INTEGER DEFAULT 0,
-    'meeting_count' INTEGER DEFAULT 0,
-    'phonecall_count' INTEGER DEFAULT 0,
-    'sale_order_count' INTEGER DEFAULT NULL,
-    'total_invoiced' INTEGER DEFAULT NULL
-);
-
-
--- Lead Table
-CREATE TABLE IF NOT EXISTS 'crm_lead' (
-    'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
-    'remote_id' INTEGER DEFAULT 0,
-    'modified' INTEGER DEFAULT 0,
-    'modified_date' TEXT DEFAULT CURRENT_TIMESTAMP,
-    'name' VARCHAR(35) DEFAULT NULL,
-    'description' VARCHAR(100) DEFAULT NULL,
-    'contact_name' VARCHAR(100) DEFAULT NULL,
-    'phone' VARCHAR(20) DEFAULT NULL,
-    'mobile' VARCHAR(20) DEFAULT NULL,
-    'fax' VARCHAR(20) DEFAULT NULL,
-    'street' VARCHAR(35) DEFAULT NULL,
-    'street2' VARCHAR(35) DEFAULT NULL,
-    'meeting_count' INTEGER DEFAULT 0,
-    'message_bounce' INTEGER DEFAULT 0,
-    'planned_cost' INTEGER DEFAULT 0,
-    'planned_revenue' INTEGER DEFAULT 0,
-    'priority' INTEGER DEFAULT 0,
-    'probability' INTEGER DEFAULT 0,
-    'type' VARCHAR(20) DEFAULT NULL,
-    'stage_id' INTEGER DEFAULT NULL,
-    'user_id' INTEGER DEFAULT 0,
-    'partner_id' INTEGER DEFAULT 0
-);
-
--- CRM Stages Table
-CREATE TABLE IF NOT EXISTS 'crm_stage' (
-    'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
-    'remote_id' INTEGER DEFAULT 0,
-    'modified' INTEGER DEFAULT 0,
-    'modified_date' TEXT DEFAULT CURRENT_TIMESTAMP,
-    'name' VARCHAR(35) DEFAULT NULL,
-    'probability' REAL DEFAULT 0,
-    'type' VARCHAR(100) DEFAULT 'both'
-);
-
-// datetime
-// boolean
-// one2many
-// char
-// many2many
-// text
-// integer
-// many2one
-// float
-// selection

+ 7 - 13
www/js/app.js

@@ -2,10 +2,11 @@ angular.module(
     'odoo',
     [
         'ionic',
+        'ionic-toast',
         'ngCordova',
+        'ngStorage',
         'xml-rpc',
         'jett.ionic.filter.bar',
-        'ionic-toast',
         'pascalprecht.translate'
     ]
 )
@@ -13,8 +14,7 @@ angular.module(
     .run(function (
         $ionicPlatform,
         $state,
-        databaseFactory,
-        configFactory
+        $localStorage
     ) {
 
         $ionicPlatform.ready(function () {
@@ -31,17 +31,11 @@ angular.module(
             if (window.sqlitePlugin) {
                 db = sqlitePlugin.openDatabase({ name: 'odoo.db', location: 'default' });
 
-                databaseFactory.initTables();
-
-                configFactory(function (configuration) {
-                    if (configuration) {
-                        $state.go('app.main');
-                    } else {
-                        $state.go('configuration');
-                    }
-                }, function (err) {
+                if ($localStorage.id) {
+                     $state.go('app.main');
+                } else {
                     $state.go('configuration');
-                });
+                }
             }
         });
     })

+ 36 - 55
www/js/controllers/configuration.controller.js

@@ -1,61 +1,42 @@
 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.105', 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) {
+    .controller('ConfigurationController', function (
+        $scope,
+        $state,
+        $ionicLoading,
+        $ionicPopup,
+        $localStorage,
+        odooFactory,
+        databaseFactory
+    ) {
+        $scope.loading = false;
+        $scope.configuration = $localStorage.$default({
+            host: '192.168.2.105',
+            port: 8069,
+            database: 'odoo',
+            username: 'admin',
+            password: 'admin',
+            id: null
+        });
 
-                        $ionicLoading.hide();
-                    });
-                }, function (error) {
-                    $ionicLoading.hide();
+        // Auth app
+        $scope.auth = function () {
+            $scope.loading = true;
 
-                    var message = 'Configuración no válida';
-                    if (angular.isObject(error)) {
-                        message = 'No se pudo establecer una llamada al servidor';
-                    }
+            odooFactory.auth($scope.configuration, function (id) {
+                $scope.configuration.id = id;
 
-                    $ionicPopup.alert({ title: 'Ha fallado el inicio de sesión', template: message });
+                databaseFactory.initTables(function (result) {
+                    $scope.loading = false;
+                    $state.go('app.main');
+                }, function (err) {
+                    $scope.loading = false;
+                    console.log(err);
                 });
-            } else {
-                $ionicLoading.hide();
-                $state.go('app.main');
-            }
-        }, function (error) {
-            $ionicLoading.hide();
-        });
-    }
-});
+
+            }, function (err) {
+                $scope.loading = false;
+                console.log(err);
+            });
+        }
+    });

+ 13 - 17
www/js/factories/database.factory.js

@@ -3,7 +3,7 @@ angular.module('odoo')
     /**
      *
      */
-    .factory('databaseFactory', function (odooFactory, configFactory, asyncLoopFactory) {
+    .factory('databaseFactory', function ($localStorage, odooFactory, asyncLoopFactory) {
 
         var mappings = [
             {
@@ -58,26 +58,22 @@ angular.module('odoo')
          */
         var fetchMaps = function (success, error) {
             var maps = [];
+            console.log($localStorage);
+            asyncLoopFactory(mappings.length, function (loop) {
+                var map = mappings[loop.iteration()];
 
-            configFactory(function (configuration) {
-                asyncLoopFactory(mappings.length, function (loop) {
-                    var map = mappings[loop.iteration()];
+                odooFactory.fields(map.model, $localStorage, function (response) {
+                    maps.push({ table: map.table, model: response });
 
-                    odooFactory.fields(map.model, configuration, function (response) {
-                        maps.push({ table: map.table, model: response });
+                    loop.next();
+                }, function (odooErr) {
+                    console.log(odooErr);
 
-                        loop.next();
-                    }, function (odooErr) {
-                        console.log(odooErr);
-
-                        loop.next();
-                    });
-
-                }, function () {
-                    success(maps);
+                    loop.next();
                 });
-            }, function (configErr) {
-                error(configErr);
+
+            }, function () {
+                success(maps);
             });
         }
 

+ 12 - 17
www/js/factories/odoo.factory.js

@@ -5,20 +5,18 @@ angular.module('odoo')
             auth: function (config, success, error) {
                 xmlrpc.callMethod(methodCallManager.call('authenticate', config), [config.database, config.username, config.password, {}]).then(function (response) {
                     if (!response || response['faultCode']) {
-                        error(response);
-                        return;
+                        return error(response);
                     }
 
-                    success({ id: response, username: config.username, password: config.password });
+                    success(response);
                 }, function (xmlrpcError) {
                     error(xmlrpcError);
                 });
             },
             read: function (model, domain, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'search_read', [domain]]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'search_read', [domain]]).then(function (response) {
                     if (!response || response['faultCode']) {
-                        error(response);
-                        return;
+                        return error(response);
                     }
 
                     success(response);
@@ -27,10 +25,9 @@ angular.module('odoo')
                 });
             },
             create: function (model, data, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'create', [data]]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'create', [data]]).then(function (response) {
                     if (!response || response['faultCode']) {
-                        error(response);
-                        return;
+                        return error(response);
                     }
 
                     success(response);
@@ -39,10 +36,9 @@ angular.module('odoo')
                 });
             },
             write: function (model, id, data, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'write', [[id], data]]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'write', [[id], data]]).then(function (response) {
                     if (!response || response['faultCode']) {
-                        error(response);
-                        return;
+                        return error(response);
                     }
 
                     success(response);
@@ -51,10 +47,9 @@ angular.module('odoo')
                 });
             },
             unlink: function (model, id, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'unlink', [[id]]]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'unlink', [[id]]]).then(function (response) {
                     if (!response || response['faultCode']) {
-                        error(response);
-                        return;
+                        return error(response);
                     }
 
                     success(response);
@@ -63,7 +58,7 @@ angular.module('odoo')
                 });
             },
             check: function (model, operation, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'check_access_rights', [operation], { 'raise_exception': false }]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'check_access_rights', [operation], { 'raise_exception': false }]).then(function (response) {
                     if (!response || response['faultCode']) {
                         return error(response);
                     }
@@ -74,7 +69,7 @@ angular.module('odoo')
                 });
             },
             fields: function (model, config, success, error) {
-                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.remote_id, config.password, model, 'fields_get', [], { 'attributes': ['type', 'readonly', 'required', 'relation', 'relation_field'] }]).then(function (response) {
+                xmlrpc.callMethod(methodCallManager.call('execute_kw', config), [config.database, config.id, config.password, model, 'fields_get', [], { 'attributes': ['type', 'readonly', 'required', 'relation', 'relation_field'] }]).then(function (response) {
                     if (!response || response['faultCode']) {
                         return error(response);
                     }

+ 0 - 50
www/js/factories/preferences.factory.js

@@ -1,50 +0,0 @@
-angular.module('odoo')
-
-    /**
-     *
-     */
-    .factory('preferencesFactory', function ($cordovaPreferences) {
-
-        /**
-         *
-         */
-        var save = function (key, value, encrypt, success, error) {
-            if (encrypt) {
-                value = '';
-            }
-
-            $cordovaPreferences.store(key, value).success(function (value) { 
-                success(value);
-            }).error(function (err) {
-                error(err);
-            });
-        }
-        
-        /**
-         *
-         */
-        var get = function (key, success, error) {
-            $cordovaPreferences.fetch(key).success(function (value) { 
-                success(value);
-            }).error(function (err) {
-                error(err);
-            });
-        }
-
-        /**
-         *
-         */
-        var remove = function (key, success, error) {
-            $cordovaPreferences.remove(key).success(function (value) { 
-                success(value);
-            }).error(function (err) {
-                error(err);
-            });
-        }
-
-        return {
-            save: save,
-            get: get,
-            remove: remove
-        }
-    });

+ 0 - 35
www/js/factories/user.storage.factory.js

@@ -1,35 +0,0 @@
-angular.module('odoo')
-
-/**
- * -----------------------------------------------------------------------------
- *  Description:    Local storage manager for users data
- * -----------------------------------------------------------------------------
- */
-.factory('userStorageFactory', function () {
-
-    // Save user data to local storage
-    var save = function (data, success, error) {
-        var sql = 'INSERT INTO user(remote_id, host, port, database, username, password) VALUES(?, ?, ?, ?, ?, ?)';
-
-        db.executeSql(sql, data, function (result) {
-            success(result.insertId);
-        }, function (err) {
-            error(err);
-        });
-    };
-
-    var remove = function (success, error) {
-        var sql = 'DELETE FROM user';
-
-        db.executeSql(sql, [], function(result) {
-            success(result.rowsAffected);
-        }, function(err) {
-            error(err);
-        });
-    }
-
-    return {
-        save: save,
-        remove: remove
-    }
-});

+ 47 - 0
www/lib/ngstorage/.bower.json

@@ -0,0 +1,47 @@
+{
+  "name": "ngstorage",
+  "version": "0.3.11",
+  "main": "./ngStorage.js",
+  "keywords": [
+    "angular",
+    "cookie",
+    "storage",
+    "local",
+    "localstorage",
+    "session",
+    "sessionstorage"
+  ],
+  "ignore": [
+    "CHANGELOG.md",
+    "components",
+    "node_modules",
+    "test",
+    "package.json",
+    "Gruntfile.js",
+    ".bowerrc",
+    ".gitignore",
+    ".travis.yml"
+  ],
+  "dependencies": {
+    "angular": ">=1.0.8"
+  },
+  "devDependencies": {
+    "angular-mocks": ">=1.0.8",
+    "chai": "^2.0.0"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/gsklee/ngStorage.git"
+  },
+  "homepage": "https://github.com/gsklee/ngStorage",
+  "_release": "0.3.11",
+  "_resolution": {
+    "type": "version",
+    "tag": "0.3.11",
+    "commit": "253b718a0b35b044fba25c78b1b2020d672c4017"
+  },
+  "_source": "https://github.com/gsklee/ngStorage.git",
+  "_target": "^0.3.11",
+  "_originalSource": "ngstorage",
+  "_direct": true
+}

+ 14 - 0
www/lib/ngstorage/.editorconfig

@@ -0,0 +1,14 @@
+# http://editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false

+ 3 - 0
www/lib/ngstorage/.gitattributes

@@ -0,0 +1,3 @@
+# http://git-scm.com/docs/gitattributes
+
+* text=auto

+ 7 - 0
www/lib/ngstorage/.npmignore

@@ -0,0 +1,7 @@
+# https://docs.npmjs.com/misc/developers
+
+*
+!.gitignore
+!LICENSE
+!ngStorage.js
+!ngStorage.min.js

+ 21 - 0
www/lib/ngstorage/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Gias Kay Lee
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 263 - 0
www/lib/ngstorage/README.md

@@ -0,0 +1,263 @@
+ngStorage
+=========
+
+[![Build Status](https://travis-ci.org/gsklee/ngStorage.svg)](https://travis-ci.org/gsklee/ngStorage)
+[![Dependency Status](https://david-dm.org/gsklee/ngStorage.svg)](https://david-dm.org/gsklee/ngStorage)
+[![devDependency Status](https://david-dm.org/gsklee/ngStorage/dev-status.svg)](https://david-dm.org/gsklee/ngStorage#info=devDependencies)
+
+An [AngularJS](https://github.com/angular/angular.js) module that makes Web Storage working in the *Angular Way*. Contains two services: `$localStorage` and `$sessionStorage`.
+
+### Differences with Other Implementations
+
+* **No Getter 'n' Setter Bullshit** - Right from AngularJS homepage: "Unlike other frameworks, there is no need to [...] wrap the model in accessors methods. Just plain old JavaScript here." Now you can enjoy the same benefit while achieving data persistence with Web Storage.
+
+* **sessionStorage** - We got this often-overlooked buddy covered.
+
+* **Cleanly-Authored Code** - Written in the *Angular Way*, well-structured with testability in mind.
+
+* **No Cookie Fallback** - With Web Storage being [readily available](http://caniuse.com/namevalue-storage) in [all the browsers AngularJS officially supports](http://docs.angularjs.org/misc/faq#canidownloadthesourcebuildandhosttheangularjsenvironmentlocally), such fallback is largely redundant.
+
+Install
+=======
+
+### Bower
+
+```bash
+bower install ngstorage
+```
+
+*NOTE:* We are `ngstorage` and *NOT* `ngStorage`. The casing is important!
+
+### NPM
+```bash
+npm install ngstorage
+```
+
+*NOTE:* We are `ngstorage` and *NOT* `ngStorage`. The casing is important!
+
+### nuget
+
+```bash
+Install-Package gsklee.ngStorage
+```
+
+Or search for `Angular ngStorage` in the nuget package manager. <https://www.nuget.org/packages/gsklee.ngStorage>
+
+CDN
+===
+
+### cdnjs
+cdnjs now hosts ngStorage at <https://cdnjs.com/libraries/ngStorage>
+
+To use it
+
+``` html
+<script src="https://cdnjs.cloudflare.com/ajax/libs/ngStorage/0.3.6/ngStorage.min.js"></script>
+```
+
+### jsDelivr
+
+jsDelivr hosts ngStorage at <http://www.jsdelivr.com/#!ngstorage>
+
+To use is
+
+``` html
+<script src="https://cdn.jsdelivr.net/ngstorage/0.3.6/ngStorage.min.js"></script>
+```
+
+Usage
+=====
+
+### Require ngStorage and Inject the Services
+
+```javascript
+angular.module('app', [
+    'ngStorage'
+]).controller('Ctrl', function(
+    $scope,
+    $localStorage,
+    $sessionStorage
+){});
+```
+
+### Read and Write | [Demo](http://plnkr.co/edit/3vfRkvG7R9DgQxtWbGHz?p=preview)
+
+Pass `$localStorage` (or `$sessionStorage`) by reference to a hook under `$scope` in plain ol' JavaScript:
+
+```javascript
+$scope.$storage = $localStorage;
+```
+
+And use it like you-already-know:
+
+```html
+<body ng-controller="Ctrl">
+    <button ng-click="$storage.counter = $storage.counter + 1">{{$storage.counter}}</button>
+</body>
+```
+
+> Optionally, specify default values using the `$default()` method:
+>
+> ```javascript
+> $scope.$storage = $localStorage.$default({
+>     counter: 42
+> });
+> ```
+
+With this setup, changes will be automatically sync'd between `$scope.$storage`, `$localStorage`, and localStorage - even across different browser tabs!
+
+### Read and Write Alternative (Not Recommended) | [Demo](http://plnkr.co/edit/9ZmkzRkYzS3iZkG8J5IK?p=preview)
+
+If you're not fond of the presence of `$scope.$storage`, you can always use watchers:
+
+```javascript
+$scope.counter = $localStorage.counter || 42;
+
+$scope.$watch('counter', function() {
+    $localStorage.counter = $scope.counter;
+});
+
+$scope.$watch(function() {
+    return angular.toJson($localStorage);
+}, function() {
+    $scope.counter = $localStorage.counter;
+});
+```
+
+This, however, is not the way ngStorage is designed to be used with. As can be easily seen by comparing the demos, this approach is way more verbose, and may have potential performance implications as the values being watched quickly grow.
+
+### Delete | [Demo](http://plnkr.co/edit/o4w3VGqmp8opfrWzvsJy?p=preview)
+
+Plain ol' JavaScript again, what else could you better expect?
+
+```javascript
+// Both will do
+delete $scope.$storage.counter;
+delete $localStorage.counter;
+```
+
+This will delete the corresponding entry inside the Web Storage.
+
+### Delete Everything | [Demo](http://plnkr.co/edit/YiG28KTFdkeFXskolZqs?p=preview)
+
+If you wish to clear the Storage in one go, use the `$reset()` method:
+
+```javascript
+$localStorage.$reset();
+````
+
+> Optionally, pass in an object you'd like the Storage to reset to:
+>
+> ```javascript
+> $localStorage.$reset({
+>     counter: 42
+> });
+> ```
+
+### Permitted Values | [Demo](http://plnkr.co/edit/n0acYLdhk3AeZmPOGY9Z?p=preview)
+
+You can store anything except those [not supported by JSON](http://www.json.org/js.html):
+
+* `Infinity`, `NaN` - Will be replaced with `null`.
+* `undefined`, Function - Will be removed.
+
+### Usage from config phase
+
+To read and set values during the Angular config phase use the `.get/.set`
+functions provided by the provider.
+
+```javascript
+var app = angular.module('app', ['ngStorage'])
+.config(['$localStorageProvider',
+    function ($localStorageProvider) {
+        $localStorageProvider.get('MyKey');
+
+        $localStorageProvider.set('MyKey', { k: 'value' });
+    }]);
+```
+
+### Prefix
+
+To change the prefix used by ngStorage use the provider function `setKeyPrefix`
+during the config phase.
+
+```javascript
+var app = angular.module('app', ['ngStorage'])
+.config(['$localStorageProvider',
+    function ($localStorageProvider) {
+        $localStorageProvider.setKeyPrefix('NewPrefix');
+    }])
+```
+
+### Custom serialization
+
+To change how ngStorage serializes and deserializes values (uses JSON by default) you can use your own functions.
+
+```javascript
+angular.module('app', ['ngStorage'])
+.config(['$localStorageProvider', 
+  function ($localStorageProvider) {
+    var mySerializer = function (value) {
+      // Do what you want with the value.
+      return value;
+    };
+    
+    var myDeserializer = function (value) {
+      return value;
+    };
+
+    $localStorageProvider.setSerializer(mySerializer);
+    $localStorageProvider.setDeserializer(myDeserializer);
+  }];)
+```
+
+### Minification
+Just run `$ npm install` to install dependencies.  Then run `$ grunt` for minification.
+
+### Hints
+
+#### Watch the watch
+
+ngStorage internally uses an Angular watch to monitor changes to the `$storage`/`$localStorage` objects. That means that a digest cycle is required to persist your new values into the browser local storage.
+Normally this is not a problem, but, for example, if you launch a new window after saving a value...
+
+```javascript
+$scope.$storage.school = theSchool;
+$log.debug("launching " + url);
+var myWindow = $window.open("", "_self");
+myWindow.document.write(response.data);
+```
+
+the new values will not reliably be saved into the browser local storage. Allow a digest cycle to occur by using a zero-value `$timeout` as:
+
+```javascript
+$scope.$storage.school = theSchool;
+$log.debug("launching and saving the new value" + url);
+$timeout(function(){
+   var myWindow = $window.open("", "_self");
+   myWindow.document.write(response.data);
+});
+```
+
+or better using `$scope.$evalAsync` as:
+
+```javascript
+$scope.$storage.school = theSchool;
+$log.debug("launching and saving the new value" + url);
+$scope.$evalAsync(function(){
+   var myWindow = $window.open("", "_self");
+   myWindow.document.write(response.data);
+});
+```
+
+And your new values will be persisted correctly.
+
+Todos
+=====
+
+* ngdoc Documentation
+* Namespace Support
+* Unit Tests
+* Grunt Tasks
+
+Any contribution will be appreciated.

+ 36 - 0
www/lib/ngstorage/bower.json

@@ -0,0 +1,36 @@
+{
+    "name": "ngstorage",
+    "version": "0.3.11",
+    "main": "./ngStorage.js",
+    "keywords": [
+        "angular",
+        "cookie",
+        "storage",
+        "local",
+        "localstorage",
+        "session",
+        "sessionstorage"
+    ],
+    "ignore": [
+        "CHANGELOG.md",
+        "components",
+        "node_modules",
+        "test",
+        "package.json",
+        "Gruntfile.js",
+        ".bowerrc",
+        ".gitignore",
+        ".travis.yml"
+    ],
+    "dependencies": {
+        "angular": ">=1.0.8"
+    },
+    "devDependencies": {
+        "angular-mocks": ">=1.0.8",
+        "chai": "^2.0.0"
+    },
+    "repository": {
+        "type": "git",
+        "url": "git://github.com/gsklee/ngStorage.git"
+    }
+}

+ 237 - 0
www/lib/ngstorage/ngStorage.js

@@ -0,0 +1,237 @@
+(function (root, factory) {
+  'use strict';
+
+  if (typeof define === 'function' && define.amd) {
+    define(['angular'], factory);
+  } else if (root.hasOwnProperty('angular')) {
+    // Browser globals (root is window), we don't register it.
+    factory(root.angular);
+  } else if (typeof exports === 'object') {
+    module.exports = factory(require('angular'));
+  }
+}(this , function (angular) {
+    'use strict';
+
+    // In cases where Angular does not get passed or angular is a truthy value
+    // but misses .module we can fall back to using window.
+    angular = (angular && angular.module ) ? angular : window.angular;
+
+
+    function isStorageSupported($window, storageType) {
+
+      // Some installations of IE, for an unknown reason, throw "SCRIPT5: Error: Access is denied"
+      // when accessing window.localStorage. This happens before you try to do anything with it. Catch
+      // that error and allow execution to continue.
+
+      // fix 'SecurityError: DOM Exception 18' exception in Desktop Safari, Mobile Safari
+      // when "Block cookies": "Always block" is turned on
+      var supported;
+      try {
+        supported = $window[storageType];
+      }
+      catch(err) {
+        supported = false;
+      }
+
+      // When Safari (OS X or iOS) is in private browsing mode, it appears as though localStorage and sessionStorage
+      // is available, but trying to call .setItem throws an exception below:
+      // "QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota."
+      if(supported) {
+        var key = '__' + Math.round(Math.random() * 1e7);
+        try {
+          $window[storageType].setItem(key, key);
+          $window[storageType].removeItem(key, key);
+        }
+        catch(err) {
+          supported = false;
+        }
+      }
+
+      return supported;
+    }
+
+    /**
+     * @ngdoc overview
+     * @name ngStorage
+     */
+
+    return angular.module('ngStorage', [])
+
+    /**
+     * @ngdoc object
+     * @name ngStorage.$localStorage
+     * @requires $rootScope
+     * @requires $window
+     */
+
+    .provider('$localStorage', _storageProvider('localStorage'))
+
+    /**
+     * @ngdoc object
+     * @name ngStorage.$sessionStorage
+     * @requires $rootScope
+     * @requires $window
+     */
+
+    .provider('$sessionStorage', _storageProvider('sessionStorage'));
+
+    function _storageProvider(storageType) {
+        var providerWebStorage = isStorageSupported(window, storageType);
+
+        return function () {
+          var storageKeyPrefix = 'ngStorage-';
+
+          this.setKeyPrefix = function (prefix) {
+            if (typeof prefix !== 'string') {
+              throw new TypeError('[ngStorage] - ' + storageType + 'Provider.setKeyPrefix() expects a String.');
+            }
+            storageKeyPrefix = prefix;
+          };
+
+          var serializer = angular.toJson;
+          var deserializer = angular.fromJson;
+
+          this.setSerializer = function (s) {
+            if (typeof s !== 'function') {
+              throw new TypeError('[ngStorage] - ' + storageType + 'Provider.setSerializer expects a function.');
+            }
+
+            serializer = s;
+          };
+
+          this.setDeserializer = function (d) {
+            if (typeof d !== 'function') {
+              throw new TypeError('[ngStorage] - ' + storageType + 'Provider.setDeserializer expects a function.');
+            }
+
+            deserializer = d;
+          };
+
+          this.supported = function() {
+            return !!providerWebStorage;
+          };
+
+          // Note: This is not very elegant at all.
+          this.get = function (key) {
+            return providerWebStorage && deserializer(providerWebStorage.getItem(storageKeyPrefix + key));
+          };
+
+          // Note: This is not very elegant at all.
+          this.set = function (key, value) {
+            return providerWebStorage && providerWebStorage.setItem(storageKeyPrefix + key, serializer(value));
+          };
+
+          this.remove = function (key) {
+            providerWebStorage && providerWebStorage.removeItem(storageKeyPrefix + key);
+          }
+
+          this.$get = [
+              '$rootScope',
+              '$window',
+              '$log',
+              '$timeout',
+              '$document',
+
+              function(
+                  $rootScope,
+                  $window,
+                  $log,
+                  $timeout,
+                  $document
+              ){
+
+                // The magic number 10 is used which only works for some keyPrefixes...
+                // See https://github.com/gsklee/ngStorage/issues/137
+                var prefixLength = storageKeyPrefix.length;
+
+                // #9: Assign a placeholder object if Web Storage is unavailable to prevent breaking the entire AngularJS app
+                // Note: recheck mainly for testing (so we can use $window[storageType] rather than window[storageType])
+                var isSupported = isStorageSupported($window, storageType),
+                    webStorage = isSupported || ($log.warn('This browser does not support Web Storage!'), {setItem: angular.noop, getItem: angular.noop, removeItem: angular.noop}),
+                    $storage = {
+                        $default: function(items) {
+                            for (var k in items) {
+                                angular.isDefined($storage[k]) || ($storage[k] = angular.copy(items[k]) );
+                            }
+
+                            $storage.$sync();
+                            return $storage;
+                        },
+                        $reset: function(items) {
+                            for (var k in $storage) {
+                                '$' === k[0] || (delete $storage[k] && webStorage.removeItem(storageKeyPrefix + k));
+                            }
+
+                            return $storage.$default(items);
+                        },
+                        $sync: function () {
+                            for (var i = 0, l = webStorage.length, k; i < l; i++) {
+                                // #8, #10: `webStorage.key(i)` may be an empty string (or throw an exception in IE9 if `webStorage` is empty)
+                                (k = webStorage.key(i)) && storageKeyPrefix === k.slice(0, prefixLength) && ($storage[k.slice(prefixLength)] = deserializer(webStorage.getItem(k)));
+                            }
+                        },
+                        $apply: function() {
+                            var temp$storage;
+
+                            _debounce = null;
+
+                            if (!angular.equals($storage, _last$storage)) {
+                                temp$storage = angular.copy(_last$storage);
+                                angular.forEach($storage, function(v, k) {
+                                    if (angular.isDefined(v) && '$' !== k[0]) {
+                                        webStorage.setItem(storageKeyPrefix + k, serializer(v));
+                                        delete temp$storage[k];
+                                    }
+                                });
+
+                                for (var k in temp$storage) {
+                                    webStorage.removeItem(storageKeyPrefix + k);
+                                }
+
+                                _last$storage = angular.copy($storage);
+                            }
+                        },
+                        $supported: function() {
+                            return !!isSupported;
+                        }
+                    },
+                    _last$storage,
+                    _debounce;
+
+                $storage.$sync();
+
+                _last$storage = angular.copy($storage);
+
+                $rootScope.$watch(function() {
+                    _debounce || (_debounce = $timeout($storage.$apply, 100, false));
+                });
+
+                // #6: Use `$window.addEventListener` instead of `angular.element` to avoid the jQuery-specific `event.originalEvent`
+                $window.addEventListener && $window.addEventListener('storage', function(event) {
+                    if (!event.key) {
+                      return;
+                    }
+
+                    // Reference doc.
+                    var doc = $document[0];
+
+                    if ( (!doc.hasFocus || !doc.hasFocus()) && storageKeyPrefix === event.key.slice(0, prefixLength) ) {
+                        event.newValue ? $storage[event.key.slice(prefixLength)] = deserializer(event.newValue) : delete $storage[event.key.slice(prefixLength)];
+
+                        _last$storage = angular.copy($storage);
+
+                        $rootScope.$apply();
+                    }
+                });
+
+                $window.addEventListener && $window.addEventListener('beforeunload', function() {
+                    $storage.$apply();
+                });
+
+                return $storage;
+              }
+          ];
+      };
+    }
+
+}));

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
www/lib/ngstorage/ngStorage.min.js


+ 13 - 0
www/lib/ngstorage/package.js

@@ -0,0 +1,13 @@
+Package.describe({
+  name: 'gsklee:ngstorage',
+  version: '0.3.11',
+  summary: 'ngStorage package for Meteor',
+  git: 'https://github.com/gsklee/ngStorage',
+  documentation: 'README.md'
+});
+
+Package.onUse(function(api) {
+  api.versionsFrom('METEOR@0.9.0.1');
+  api.use('urigo:angular@0.8.4', 'client');
+  api.addFiles('ngStorage.js', 'client');
+});

+ 16 - 9
www/templates/configuration.html

@@ -1,34 +1,41 @@
 <ion-view title="Sign-In">
+
     <ion-header-bar class="bar-positive">
         <h1 class="title">Configuración</h1>
         <div class="buttons">
-            <button class="button button-clear ion-checkmark-round" style="font-size:22px !important;" type="submit" form="configuration-form" ng-disabled="!config.host || !config.port || !config.database || !config.username || !config.password"></button>
+            <button class="button button-clear ion-checkmark-round" style="font-size:22px !important;" type="submit" form="configuration-form"
+                ng-disabled="!configuration.host || !configuration.port || !configuration.database || !configuration.username || !configuration.password"></button>
         </div>
     </ion-header-bar>
-	<ion-content>
-        <form id="configuration-form" ng-submit="configure()">
+
+    <ion-content>
+
+        <ion-spinner class="centered-spinner" ng-show="loading"></ion-spinner>
+
+        <form id="configuration-form" ng-submit="auth()" ng-show="!loading">
             <div class="list">
                 <label class="item item-input item-stacked-label">
                     <span class="input-label">Host</span>
-                    <input type="text" autofocus="autofocus" placeholder="localhost" ng-model="config.host">
+                    <input type="text" autofocus="autofocus" placeholder="localhost" ng-model="configuration.host">
                 </label>
                 <label class="item item-input item-stacked-label">
                     <span class="input-label">Puerto</span>
-                    <input type="number" placeholder="8069" value="8069" ng-model="config.port">
+                    <input type="number" placeholder="8069" value="8069" ng-model="configuration.port">
                 </label>
                 <label class="item item-input item-stacked-label">
                     <span class="input-label">Base de datos</span>
-                    <input type="text" placeholder="odoo" ng-model="config.database">
+                    <input type="text" placeholder="odoo" ng-model="configuration.database">
                 </label>
                 <label class="item item-input item-stacked-label">
                     <span class="input-label">Usuario</span>
-                    <input type="text" placeholder="admin" ng-model="config.username">
+                    <input type="text" placeholder="admin" ng-model="configuration.username">
                 </label>
                 <label class="item item-input item-stacked-label">
                     <span class="input-label">Contraseña</span>
-                    <input type="password" placeholder="admin" ng-model="config.password">
+                    <input type="password" placeholder="admin" ng-model="configuration.password">
                 </label>
             </div>
         </form>
+        
     </ion-content>
-</ion-view>
+</ion-view>

+ 1 - 0
www/templates/preferences.html

@@ -5,6 +5,7 @@
 	<ion-content>
         <div class="list">
             <label class="item">
+                
                 <button class="button button-assertive button-block" name="button" ng-click="deleteAccount()">ELIMINAR CUENTA</button>
             </label>
         </div>

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott