diff --git a/bower.json b/bower.json index 27865f4..d69dd62 100644 --- a/bower.json +++ b/bower.json @@ -8,7 +8,7 @@ "angular-sanitize": "~1.4.2", "angular-messages": "~1.4.2", "angular-aria": "~1.4.2", - "angular-resource": "~1.4.2", + "restangular": "~1.5.1", "angular-ui-router": "~0.2.15", "bootstrap-sass": "~3.3.5", "angular-bootstrap": "~0.13.4", diff --git a/src/app/components/noosfero/noosfero.service.js b/src/app/components/noosfero/noosfero.service.js index 77c54a8..d247c4f 100644 --- a/src/app/components/noosfero/noosfero.service.js +++ b/src/app/components/noosfero/noosfero.service.js @@ -3,14 +3,14 @@ angular.module('angular').service('noosfero', noosfero); - function noosfero($resource) { + function noosfero() { this.communities = communities; this.articles = articles; function communities() { - return $resource('/api/v1/communities/:id'); + // return $resource('/api/v1/communities/:id'); } function articles() { - return $resource('/api/v1/articles/:id'); + // return $resource('/api/v1/articles/:id'); } } })(); diff --git a/src/app/content-viewer/content-viewer.controller.js b/src/app/content-viewer/content-viewer.controller.js index 909738e..b374859 100644 --- a/src/app/content-viewer/content-viewer.controller.js +++ b/src/app/content-viewer/content-viewer.controller.js @@ -7,17 +7,15 @@ /** @ngInject */ - function ContentViewerController(noosfero, $log, $stateParams) { + function ContentViewerController(noosfero, $log, $stateParams, Restangular, $state) { var vm = this; vm.article = null; activate(); function activate() { - $log.log($stateParams.page); - noosfero.articles().get({path: $stateParams.page, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (article) { - //FIXME - vm.content = article.articles[0]; - console.log(vm.content); + Restangular.one('communities', $state.current.data.profile.id).one('articles').get({path: $stateParams.page}).then(function(articles) { + $log.log(articles); + vm.content = articles.article; }); } } diff --git a/src/app/index.config.js b/src/app/index.config.js index c3f37b9..2329d78 100644 --- a/src/app/index.config.js +++ b/src/app/index.config.js @@ -6,11 +6,10 @@ .config(config); /** @ngInject */ - function config($logProvider, $locationProvider) { - // Enable log + function config($logProvider, $locationProvider, RestangularProvider) { $logProvider.debugEnabled(true); - $locationProvider.html5Mode({enabled: true}); + RestangularProvider.setBaseUrl('/api/v1'); } })(); diff --git a/src/app/index.module.js b/src/app/index.module.js index 4eeada8..5a13e79 100644 --- a/src/app/index.module.js +++ b/src/app/index.module.js @@ -2,6 +2,6 @@ 'use strict'; angular - .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr']); + .module('angular', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'restangular', 'ui.router', 'ui.bootstrap', 'toastr']); })(); diff --git a/src/app/index.route.js b/src/app/index.route.js index dcbe692..95bf1dc 100644 --- a/src/app/index.route.js +++ b/src/app/index.route.js @@ -13,7 +13,10 @@ url: '/:profile', templateUrl: 'app/profile/profile.html', controller: 'ProfileController', - controllerAs: 'vm' + controllerAs: 'vm', + data: { + profile: null + } }) .state('profile.page', { url: '/{page:.*}', diff --git a/src/app/profile/profile.controller.js b/src/app/profile/profile.controller.js index 8daa1f4..0afb4b1 100644 --- a/src/app/profile/profile.controller.js +++ b/src/app/profile/profile.controller.js @@ -7,15 +7,16 @@ /** @ngInject */ - function ProfileController(noosfero, $log, $stateParams) { + function ProfileController(noosfero, $log, $stateParams, $state, Restangular) { var vm = this; vm.boxes = []; activate(); function activate() { - noosfero.communities().get({identifier: $stateParams.profile, private_token: '1b00325e5f769a0c38550bd35b3f1d64'}).$promise.then(function (profile) { - $log.log(profile); - vm.owner = profile.communities[0]; + Restangular.one('communities').get({private_token: '1b00325e5f769a0c38550bd35b3f1d64', identifier: $stateParams.profile}).then(function(communities) { + $log.log(communities); + vm.owner = communities.communities[0]; + $state.current.data.profile = vm.owner; }); } -- libgit2 0.21.2