├── examples ├── backend │ ├── myproject │ │ ├── myapp │ │ │ ├── __init__.py │ │ │ ├── migrations │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ │ ├── __init__.cpython-35.pyc │ │ │ │ │ └── 0001_initial.cpython-35.pyc │ │ │ │ └── 0001_initial.py │ │ │ ├── tests.py │ │ │ ├── views.py │ │ │ ├── apps.py │ │ │ ├── __pycache__ │ │ │ │ ├── admin.cpython-35.pyc │ │ │ │ ├── models.cpython-35.pyc │ │ │ │ ├── __init__.cpython-35.pyc │ │ │ │ └── resource.cpython-35.pyc │ │ │ ├── admin.py │ │ │ ├── models.py │ │ │ └── resource.py │ │ ├── myproject │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── urls.cpython-35.pyc │ │ │ │ ├── wsgi.cpython-35.pyc │ │ │ │ ├── __init__.cpython-35.pyc │ │ │ │ └── settings.cpython-35.pyc │ │ │ ├── wsgi.py │ │ │ ├── urls.py │ │ │ └── settings.py │ │ ├── db.sqlite3 │ │ ├── manage.py │ │ └── topsongs.sql │ └── requirements.txt ├── frontend │ ├── simple_app │ │ ├── lib │ │ │ ├── osi_logo_100X133_90ppi.png │ │ │ ├── angular │ │ │ │ ├── angular-resource.min.js │ │ │ │ └── angular-resource.min.js.map │ │ │ └── angular-resource-tastypie.min.js │ │ ├── controller.js │ │ └── index.html │ ├── usability_app │ │ ├── osi_keyhole_100X100_90ppi.png │ │ ├── README │ │ ├── bower.json │ │ ├── controller.js │ │ └── index.html │ └── index.html └── README.md ├── dev ├── art.zargo ├── art.zargo~ ├── ClassDiagram.png └── arq_rest_angular_django.jpg ├── Gruntfile.js ├── package.json ├── LICENSE ├── bower.json ├── README.md └── src ├── angular-resource-tastypie.min.js └── angular-resource-tastypie.js /examples/backend/myproject/myapp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dev/art.zargo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/dev/art.zargo -------------------------------------------------------------------------------- /dev/art.zargo~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/dev/art.zargo~ -------------------------------------------------------------------------------- /dev/ClassDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/dev/ClassDiagram.png -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /dev/arq_rest_angular_django.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/dev/arq_rest_angular_django.jpg -------------------------------------------------------------------------------- /examples/backend/myproject/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/db.sqlite3 -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MyappConfig(AppConfig): 5 | name = 'myapp' 6 | -------------------------------------------------------------------------------- /examples/backend/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.9.5 2 | django-cors-headers==1.1.0 3 | django-tastypie==0.13.3 4 | python-dateutil==2.5.2 5 | python-mimeparse==1.5.1 6 | six==1.10.0 7 | -------------------------------------------------------------------------------- /examples/frontend/simple_app/lib/osi_logo_100X133_90ppi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/frontend/simple_app/lib/osi_logo_100X133_90ppi.png -------------------------------------------------------------------------------- /examples/frontend/usability_app/osi_keyhole_100X100_90ppi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/frontend/usability_app/osi_keyhole_100X100_90ppi.png -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/__pycache__/admin.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/__pycache__/admin.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/__pycache__/models.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/__pycache__/models.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/__pycache__/resource.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/__pycache__/resource.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/__pycache__/urls.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myproject/__pycache__/urls.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/__pycache__/wsgi.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myproject/__pycache__/wsgi.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myproject/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/__pycache__/settings.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myproject/__pycache__/settings.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from myapp.models import Song 3 | 4 | class SongAdmin(admin.ModelAdmin): 5 | pass 6 | 7 | admin.site.register(Song, SongAdmin) 8 | 9 | -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/migrations/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/migrations/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /examples/frontend/usability_app/README: -------------------------------------------------------------------------------- 1 | IMPORTANT 2 | 3 | If you downloaded the project with bower: 4 | EX: "bower install angular-resource-tastypie" 5 | 6 | Then install dependence for usability_app: 7 | bower install bower.json -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/migrations/__pycache__/0001_initial.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mw-ferretti/angular-resource-tastypie/HEAD/examples/backend/myproject/myapp/migrations/__pycache__/0001_initial.cpython-35.pyc -------------------------------------------------------------------------------- /examples/backend/myproject/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | grunt.initConfig({ 3 | uglify: { 4 | compile: { 5 | files: { 6 | 'src/angular-resource-tastypie.min.js': ['src/angular-resource-tastypie.js'] 7 | } 8 | } 9 | } 10 | }); 11 | 12 | grunt.loadNpmTasks('grunt-contrib-uglify'); // load the given tasks 13 | grunt.registerTask('default', ['uglify']); // Default grunt tasks maps to grunt 14 | }; -------------------------------------------------------------------------------- /examples/backend/myproject/myapp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Song(models.Model): 4 | rank = models.IntegerField(blank=True, null=True) 5 | song = models.CharField(max_length=200, blank=True, null=True) 6 | artist = models.CharField(max_length=100, blank=True, null=True) 7 | 8 | def __str__(self): 9 | return '%s - %s, by %s.' % (self.rank, self.song, self.artist) 10 | 11 | class Meta: 12 | ordering = ['rank',] 13 | -------------------------------------------------------------------------------- /examples/backend/myproject/myproject/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for myproject project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /examples/frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |11 |
23 |
24 |
25 | | Id | 84 |Rank | 85 |Song | 86 |Artist | 87 |88 | 89 | 90 | | |
|---|---|---|---|---|---|
| {{obj.id}} | 92 |93 | | 94 | | 95 | | 96 | | 97 | |
No result
101 |104 |
![]() |
111 |
112 |
113 | |
122 | 123 | 131 | | 132 |
47 |
48 |
74 | 125 | {{obj.artist}} 126 |
127 |94 |101 | 102 | ```javascript 103 | //Access $tastypieProvider in the controller 104 | //Login and Logout sample: 105 | .controller('AuthCtrl', ['$scope', '$tastypie', '$http', function($scope, $tastypie, $http){ 106 | $scope.login = function(){ 107 | var data = { 108 | userName: $scope.userName, 109 | password: $scope.password 110 | }; 111 | $http.post('/loginUrl', data).success(function(response){ 112 | $tastypie.setProviderAuth('providerName', response.username, response.apikey) 113 | }); 114 | } 115 | 116 | $scope.logout = function(){ 117 | var provider = $tastypie.getProvider('providerName'); 118 | $http.post('/logoutUrl', {username: provider.username, apikey: provider.apikey}); 119 | $tastypie.clearAuthSession('providerName'); //clean auth session data 120 | } 121 | }]); 122 | ``` 123 | 124 | MULTI "PROVIDER" SAMPLE: 125 | ```javascript 126 | angular.module('myApp', ['ngResourceTastypie']) 127 | 128 | .config(function($tastypieProvider){ 129 | $tastypieProvider 130 | .add('provider1', { 131 | url: 'http://address1/api/v1/', 132 | username: 'username', 133 | apikey: 'apikey' 134 | }) 135 | .add('provider2', { 136 | url: 'http://address2/api/v1/', 137 | username: 'username', 138 | apikey: 'apikey' 139 | }); 140 | 141 | $tastypieProvider.setDefault('provider1'); 142 | }) 143 | 144 | .controller('MyCtrl', ['$scope', '$tastypieResource', function($scope, $tastypieResource){ 145 | 146 | $scope.ServiceEndpoint = new $tastypieResource('ServiceEndpoint', {limit:5}); //using default provider - "provider1". 147 | $scope.ServiceEndpoint.objects.$find(); 148 | 149 | $scope.ServiceEndpoint = new $tastypieResource('ServiceEndpoint', {limit:5}, 'provider2'); //using selected provider - "provider2". 150 | $scope.ServiceEndpoint.objects.$find(); 151 | 152 | }]); 153 | ``` 154 | 155 | 156 | ## Making queries 157 | The $tastypieResource class is held responsible for connecting on the specific "list endpoint". 158 | 159 | Consider the following example: 160 | We have a service called "song", which is responsible for providing the "TOP 100 SONGS CLASSIC ROCK": 161 | ``` 162 | http://127.0.0.1:8001/api/v1/song/ 163 | ``` 164 | Then: 165 | ```javascript 166 | $scope.Song = new $tastypieResource('song'); 167 | 168 | //or with default filters 169 | $scope.Song = new $tastypieResource('song',{limit:5}); 170 | 171 | ``` 172 | 173 | - Creating objects 174 | The "$create()" method will return a "$tastypieObjects" object.95 | This apikey was fixed only for demo purposes.
100 |
96 | You must generate a dynamic api_key after the user login, on backend authorization system, and then configure this attribute.
97 | With django-tastypie this task is quite simple:
98 | http://django-tastypie.readthedocs.org/en/latest/authentication.html 99 |
211 |215 | 216 | 217 | - Updating objects 218 | 219 | ```javascript 220 | $scope.Song.objects.$update({ 221 | id:100, 222 | song:'Sweet Emotion ...' 223 | }); 224 | ``` 225 | 226 | ```javascript 227 | //or with callback 228 | $scope.Song.objects.$update({ 229 | id:100, 230 | song:'Sweet Emotion' 231 | }).then( 232 | function(result){ 233 | console.log(result); 234 | }, 235 | function(error){ 236 | console.log(error); 237 | } 238 | ); 239 | ``` 240 | 241 | ```javascript 242 | //or from get 243 | $scope.Song.objects.$get({id:100}).then( 244 | function(result){ 245 | result.rank += 1; 246 | result.$save(); 247 | } 248 | ); 249 | ``` 250 | 251 | ```javascript 252 | //or from local object 253 | //creating 254 | var song = $scope.Song.objects.$create(); 255 | song.rank = 1; 256 | song.song = "Sweet Emotion"; 257 | song.artist = "Aerosmith"; 258 | song.$save(); 259 | 260 | //updating 261 | song.rank = 2 262 | song.$save(); 263 | ``` 264 | 265 | 266 | - Deleting objects 267 | 268 | ```javascript 269 | $scope.Song.objects.$delete({id:100}); 270 | ``` 271 | 272 | ```javascript 273 | //or with callback 274 | $scope.Song.objects.$delete({id:100}).then( 275 | function(result){ 276 | console.log(result); 277 | }, 278 | function(error){ 279 | console.log(error); 280 | } 281 | ); 282 | ``` 283 | 284 | ```javascript 285 | //or from local object 286 | //creating 287 | var song = $scope.Song.objects.$create(); 288 | song.rank = 1 289 | song.song = "Sweet Emotion" 290 | song.artist = "Aerosmith" 291 | song.$save(); 292 | 293 | //deleting 294 | song.$delete() 295 | ``` 296 | 297 | - Retrieving objects 298 | The "$find()" method will return a "$tastypiePaginator" object.212 | After saving, your obj will be updated. For example, your obj now has an "id".. wow!! 213 |
214 |
323 | NOTE 324 |331 | 332 | ```javascript 333 | //All page attributes: 334 | $scope.Song.page.meta.previous; // URL of previous page 335 | $scope.Song.page.meta.next; // URL of next page 336 | $scope.Song.page.meta.limit; // Limit of records by page 337 | $scope.Song.page.meta.offset; // Current displacement records 338 | $scope.Song.page.meta.total_count; // Total count of found records. 339 | $scope.Song.page.objects; // Objects ($tastypieObjects) list of current page 340 | $scope.Song.page.index; // Current number page 341 | $scope.Song.page.length; // Pages quantity 342 | $scope.Song.page.range; // Numbers list of pages 343 | 344 | //All page methods: 345 | $scope.Song.page.change(index); 346 | $scope.Song.page.next(); 347 | $scope.Song.page.previous(); 348 | $scope.Song.page.refresh(); 349 | $scope.Song.page.first(); 350 | $scope.Song.page.last(); 351 | 352 | //All methods has promise. EX: 353 | $scope.Song.page.next().then( 354 | function(result){ 355 | console.log(result); //The "result" is a "$tastypiePaginator" object. 356 | }, 357 | function(error){ 358 | console.log(error); 359 | } 360 | ); 361 | ``` 362 | 363 | ```javascript 364 | //get object from resource_uri 365 | //In this case, there is no paging. An "$tastypieObjects" is returned. 366 | $scope.Song.objects.$get({id:100}).then( 367 | function(result){ 368 | console.log(result); 369 | }, 370 | function(error){ 371 | console.log(error); 372 | } 373 | ); 374 | ``` 375 | 376 | ## Working status 377 | 1. $tastypie.working: Global requests (return true or false) 378 | 2. YourService.working: Individual service requests (return true or false) 379 | 380 | It is usual for when you need to show an animation of "waiting", "working", "loading", etc ... 381 | at the time the user makes a request. Ex: save, update, delete, search, etc ... 382 | 383 | Informe the request status for user. EX: 384 | 385 | ```javascript 386 | .controller('ProjectCtrl', ['$scope', '$tastypie', '$tastypieResource', function($scope, $tastypie, $tastypieResource){ 387 | $scope.Api = $tastypie; 388 | $scope.Song = new $tastypieResource('song', {limit:4}); 389 | }]) 390 | ``` 391 | 392 | ```html 393 | >>> Api working ... please wait... 394 | >>> Service Song working ... please wait ... 395 | ``` 396 | [See how to use.](https://github.com/mw-ferretti/angular-resource-tastypie/tree/master/examples) 397 | 398 | ## Class Diagram 399 |  400 | 401 | ## Contribute 402 | If you found it useful, please consider paying me a coffee ; 403 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RGQ8NSYPA59FL) 404 | 405 | ## License 406 | angular-resource-tastypie is released under the [MIT License](https://github.com/mw-ferretti/angular-resource-tastypie/blob/master/LICENSE). 407 | -------------------------------------------------------------------------------- /src/angular-resource-tastypie.min.js: -------------------------------------------------------------------------------- 1 | var ngResourceTastypie={name:"Angular Resource Tastypie",description:"RESTful AngularJs client for Django-Tastypie or equivalent schema.",version:{full:"1.0.5",major:1,minor:0,dot:5,codeName:"Cappuccino"},author:{name:"Marcos William Ferretti",email:"ferretti.spo@gmail.com",github:"https://github.com/mw-ferretti/",linkedin:"https://www.linkedin.com/in/mwferretti"},license:"MIT, (c) 2014-2016 Marcos William Ferretti",source:"https://github.com/mw-ferretti/angular-resource-tastypie"};if("undefined"==typeof angular)throw"[ngResourceTastypie v".concat(ngResourceTastypie.version.full,"] Requires AngularJs 1.3+");if(angular.version.major<1||1==angular.version.major&&angular.version.minor<3)throw"[ngResourceTastypie v".concat(ngResourceTastypie.version.full,"] Requires AngularJs 1.3+, your version is ",angular.version.full);angular.module("ngResourceTastypie",["ngResource"]).constant("ngResourceTastypie",ngResourceTastypie).config(["$resourceProvider",function(a){a.defaults.stripTrailingSlashes=!1}]).provider("$tastypie",["$httpProvider",function(a){a.defaults.useXDomain=!0,delete a.defaults.headers.common["X-Requested-With"],a.defaults.headers.common["Content-Type"]="application/json";var b=this,c="",d="",e={username:"",api_key:""};b.providers={},b.default={},b.getProvider=function(a){var c={};if(c="default"==a?b.default||{}:b.providers[a]||{},!c.hasOwnProperty("url"))throw'[$tastypieProvider][GetProvider] provider "'.concat(a,'" not found.');return c},b.setDefault=function(a){if(!b.providers.hasOwnProperty(a))throw"[$tastypieProvider][ProviderSetDefault] Provider ".concat(a," not found.");b.default=b.providers[a],c=b.default.url,d=b.default.domain,e.username=b.default.username,e.api_key=b.default.apikey,"undefined"!=typeof Storage&&(sessionStorage.$tastypieDefaultProvider=angular.toJson(b.default))},b.add=function(a,c){if(!a||!("string"==typeof a||a instanceof String))throw'[$tastypieProvider][ProviderAdd] Invalid providerName string. Usage: add("providerName", {url:"address"})';if(!c||!angular.isObject(c)||!c.hasOwnProperty("url"))throw'[$tastypieProvider][ProviderAdd] Invalid providerObj object. Usage: add("providerName", {url:"address"})';if(b.providers[a])return b;c.name=a;var d=document.createElement("a");d.href=c.url;var e=d.protocol.concat("//",d.hostname);return""!=d.port&&(e=e.concat(":",d.port)),c.domain=e,c.hasOwnProperty("headers")||(c.headers={}),c.headers.hasOwnProperty("Content-Type")||(c.headers["Content-Type"]="application/json"),c.hasOwnProperty("username")&&c.hasOwnProperty("apikey")&&(c.headers.Authorization="ApiKey ".concat(c.username,":",c.apikey)),b.providers[a]=c,b.default.hasOwnProperty("name")||b.setDefault(a),"undefined"!=typeof Storage&&(sessionStorage.$tastypieProviders=angular.toJson(b.providers)),b},b.httpExceptions={},b.httpExceptionsAdd=function(a,c){if(!a)throw"[$tastypieProvider][httpExceptionsAdd] Invalid httpCode integer. Usage: httpExceptionsAdd(httpCode, callback)";if(!c||!angular.isFunction(c))throw"[$tastypieProvider][httpExceptionsAdd] Invalid callback function. Usage: httpExceptionsAdd(httpCode, callback)";return b.httpExceptions["c".concat(a)]=c,b},b.setProviderAuth=function(a,c,d){var e=b.getProvider(a);e.username=c,e.apikey=d,e.hasOwnProperty("headers")||(e.headers={}),e.headers.Authorization="ApiKey ".concat(e.username,":",e.apikey),b.providers[a]=e,b.default.name==a&&(b.default=e,"undefined"!=typeof Storage&&(sessionStorage.$tastypieDefaultProvider=angular.toJson(b.default))),"undefined"!=typeof Storage&&(sessionStorage.$tastypieProviders=angular.toJson(b.providers))},b.setResourceUrl=function(a){if(!a||!("string"==typeof a||a instanceof String))throw"[$tastypieProvider][SetResourceUrl] Invalid URL.";c=a;var e=document.createElement("a");e.href=c,d=e.protocol.concat("//",e.hostname),""!=e.port&&(d=d.concat(":",e.port)),b.default.name="default",b.default.hasOwnProperty("headers")||(b.default.headers={}),b.default.headers.hasOwnProperty("Content-Type")||(b.default.headers["Content-Type"]="application/json"),b.default.url=a,b.default.domain=d,b.providers[b.default.name]=b.default,"undefined"!=typeof Storage&&(sessionStorage.$tastypieDefaultProvider=angular.toJson(b.default),sessionStorage.$tastypieProviders=angular.toJson(b.providers))},b.setAuth=function(a,c){var d=a&&("string"==typeof a||a instanceof String);c&&("string"==typeof c||String);if(!d)throw"[$tastypieProvider][SetResourceUrl] Invalid username.";if(!c)throw"[$tastypieProvider][SetResourceUrl] Invalid apikey.";e.username=a,e.api_key=c,b.default.name="default",b.default.hasOwnProperty("headers")||(b.default.headers={}),b.default.headers.hasOwnProperty("Content-Type")||(b.default.headers["Content-Type"]="application/json"),b.default.username=a,b.default.apikey=c,b.default.headers.Authorization="ApiKey ".concat(a,":",c),b.providers[b.default.name]=b.default,"undefined"!=typeof Storage&&(sessionStorage.$tastypieDefaultProvider=angular.toJson(b.default),sessionStorage.$tastypieProviders=angular.toJson(b.providers))};var f=function(a){if(!angular.isObject(a)||!a.hasOwnProperty("url"))throw"[$tastypieProvider][clearAuthProvider] Invalid provider.";a.hasOwnProperty("username")&&(a.username=""),a.hasOwnProperty("apikey")&&(a.apikey=""),a.hasOwnProperty("headers")&&a.headers.hasOwnProperty("Authorization")&&delete a.headers.Authorization,b.providers[a.name]=a,"undefined"!=typeof Storage&&(sessionStorage.$tastypieProviders=angular.toJson(b.providers)),a.name==b.default.name&&(e.username="",e.api_key="",b.default=a,"undefined"!=typeof Storage&&(sessionStorage.$tastypieDefaultProvider=angular.toJson(b.default)))};b.clearAuthSession=function(a){if(!a||!("string"==typeof a||a instanceof String))throw"[$tastypieProvider][ClearAuthSession] Invalid providerName.";if("all"==a)for(var c=Object.keys(b.providers),d=0;d325 | 1. After running the "$find" method for the first time, you have inside your instance "$tastypieResource" ($scope.Song), a "$tastypiePaginator" object ($scope.Song.page). 326 |
327 |328 | 2. For each item of "$scope.Song.page.objects" you retrieve a "$tastypieObjects" object. ;) 329 |
330 |