Commit bde8b7856a544f71a92d9e21c439fac68ce7196a
1 parent
8cff6302
Exists in
master
and in
8 other branches
Remove 'programa service' in favor 'article service' using restangular
Showing
9 changed files
with
131 additions
and
138 deletions
Show diff stats
src/app/components/programa/programa.directive.js
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | .directive('programaBox', programaBox); | 6 | .directive('programaBox', programaBox); |
7 | 7 | ||
8 | /** @ngInject */ | 8 | /** @ngInject */ |
9 | - function programaBox(ProgramaService, $log) { | 9 | + function programaBox($log) { |
10 | 10 | ||
11 | /** @ngInject */ | 11 | /** @ngInject */ |
12 | function ProgramaController() { | 12 | function ProgramaController() { |
src/app/components/programa/programa.service.js
@@ -1,129 +0,0 @@ | @@ -1,129 +0,0 @@ | ||
1 | -(function() { | ||
2 | - 'use strict'; | ||
3 | - | ||
4 | - angular | ||
5 | - .module('dialoga') | ||
6 | - .factory('ProgramaService', ProgramaService); | ||
7 | - | ||
8 | - /** @ngInject */ | ||
9 | - function ProgramaService($http, $q, private_token, ErrorService, $log) { | ||
10 | - var apiHost = 'http://login.dialoga.gov.br/api/v1'; | ||
11 | - | ||
12 | - var endpoint = { | ||
13 | - home: apiHost + '/articles/103358?private_token=null&fields=id,children,categories,abstract,title,image,url,setting,position', | ||
14 | - articles: apiHost + '/articles?private_token=' + private_token + '&fields=id,children,created_by,categories,tag_list,abstract,setting,profile&content_type=ProposalsDiscussionPlugin::Proposal', | ||
15 | - tasks: apiHost + '/task?private_token=' + private_token + '&fields=id,children,created_by,categories,tag_list,abstract,setting,profile&content_type=ProposalsDiscussionPlugin::Proposal' | ||
16 | - }; | ||
17 | - | ||
18 | - var service = { | ||
19 | - | ||
20 | - // mock | ||
21 | - mockPrograma: mockPrograma, | ||
22 | - | ||
23 | - // api | ||
24 | - getArticles: getArticles, | ||
25 | - getProposal: getProposal | ||
26 | - }; | ||
27 | - | ||
28 | - return service; | ||
29 | - | ||
30 | - // --- | ||
31 | - // PUBLIC METHODS | ||
32 | - // --- | ||
33 | - | ||
34 | - /** | ||
35 | - * Mock Data | ||
36 | - * @return {Object} a new instance with dumb data; | ||
37 | - */ | ||
38 | - function mockPrograma () { | ||
39 | - return { | ||
40 | - id: -1, | ||
41 | - title: "Valorização dos Professores", | ||
42 | - abstract: "<p>Caminho para uma educação de qualidade.</p>", | ||
43 | - image: {url: "/image_uploads/dialoga/0000/0140/valorizacao_professor.jpg"}, | ||
44 | - categories: [{name: "[category]", id: -1, slug: "[category-slug]", image: null}], | ||
45 | - author: '[author]', | ||
46 | - position: -1, // ? | ||
47 | - profile: { // ? | ||
48 | - id: -1, | ||
49 | - identifier: '[profile.identifier]', | ||
50 | - name: '[profile.name]', | ||
51 | - }, | ||
52 | - setting: { // ? | ||
53 | - author_name: '[setting.author_name]', | ||
54 | - comment_paragraph_plugin_activate: false | ||
55 | - }, | ||
56 | - children: [], // ? | ||
57 | - tag_list: [] | ||
58 | - }; | ||
59 | - } | ||
60 | - | ||
61 | - /** | ||
62 | - * Get a list of articles | ||
63 | - * @param {Number} limit per_page (default is 30) | ||
64 | - * @return {Array} a list of articles | ||
65 | - */ | ||
66 | - function getArticles (limit) { | ||
67 | - if (!limit) { | ||
68 | - limit = 30; | ||
69 | - } | ||
70 | - | ||
71 | - return $http.get(endpoint.articles) | ||
72 | - .then(handleSuccess) | ||
73 | - .catch(handleError); | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * Get a task by id | ||
78 | - * @param {Number} id of task | ||
79 | - * @return {Object} the wanted task or a new one. | ||
80 | - */ | ||
81 | - function getProposal (id) { | ||
82 | - if (!id) { | ||
83 | - throw new Error(ErrorService.paramRequired('id')); | ||
84 | - } | ||
85 | - | ||
86 | - return $http.get(endpoint.tasks) | ||
87 | - .then(handleSuccess) | ||
88 | - .catch(handleError); | ||
89 | - } | ||
90 | - | ||
91 | - // --- | ||
92 | - // PRIVATE METHODS | ||
93 | - // --- | ||
94 | - | ||
95 | - /** | ||
96 | - * Transform the successful response, unwrapping the application data | ||
97 | - * from the API response payload. | ||
98 | - * | ||
99 | - * @param {Object} response from the server. | ||
100 | - * @return {Object} the data unwrapped. | ||
101 | - */ | ||
102 | - function handleSuccess (response){ | ||
103 | - return response.data; | ||
104 | - } | ||
105 | - | ||
106 | - /** | ||
107 | - * Transform the error response, unwrapping the application data from | ||
108 | - * the API response payload. | ||
109 | - * | ||
110 | - * @param {Object} error from the server. | ||
111 | - * @return {Promise} promise rejection called. | ||
112 | - */ | ||
113 | - function handleError (error){ | ||
114 | - | ||
115 | - $log.error('XHR Failed on ProgramaService.\n' + angular.toJson(error.data, true)); | ||
116 | - | ||
117 | - // The API response from the server should be returned in a | ||
118 | - // nomralized format. However, if the request was not handled by the | ||
119 | - // server (or what not handles properly - ex. server error), then we | ||
120 | - // may have to normalize it on our end, as best we can. | ||
121 | - if ( !angular.isObject( error.data ) || !error.data.message) { | ||
122 | - return( $q.reject( 'An unknown error occurred.' ) ); | ||
123 | - } | ||
124 | - | ||
125 | - // Otherwise, use expected error message. | ||
126 | - return $q.reject(error.data.message); | ||
127 | - } | ||
128 | - } | ||
129 | -})(); |
src/app/index.config.js
@@ -3,9 +3,16 @@ | @@ -3,9 +3,16 @@ | ||
3 | 3 | ||
4 | angular | 4 | angular |
5 | .module('dialoga') | 5 | .module('dialoga') |
6 | + .config(configRestangular) | ||
6 | .config(config); | 7 | .config(config); |
7 | 8 | ||
8 | /** @ngInject */ | 9 | /** @ngInject */ |
10 | + function configRestangular(RestangularProvider, api) { | ||
11 | + RestangularProvider.setBaseUrl(api.host); | ||
12 | + RestangularProvider.setDefaultRequestParams({ apiKey: api.token }); | ||
13 | + } | ||
14 | + | ||
15 | + /** @ngInject */ | ||
9 | function config($logProvider) { | 16 | function config($logProvider) { |
10 | // Enable log | 17 | // Enable log |
11 | $logProvider.debugEnabled(true); | 18 | $logProvider.debugEnabled(true); |
src/app/index.constants.js
@@ -4,7 +4,13 @@ | @@ -4,7 +4,13 @@ | ||
4 | 4 | ||
5 | angular | 5 | angular |
6 | .module('dialoga') | 6 | .module('dialoga') |
7 | - .constant('private_token', null) | 7 | + .constant('api', { |
8 | + token: null, | ||
9 | + host: 'http://login.dialoga.gov.br/api/v1/', | ||
10 | + articleId: { | ||
11 | + home: 103358 | ||
12 | + } | ||
13 | + }) | ||
8 | .constant('Modernizr', Modernizr) | 14 | .constant('Modernizr', Modernizr) |
9 | // .constant('key', value) | 15 | // .constant('key', value) |
10 | ; | 16 | ; |
src/app/index.run.js
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +(function() { | ||
2 | + 'use strict'; | ||
3 | + | ||
4 | + angular | ||
5 | + .module('dialoga') | ||
6 | + .factory('ArticleService', ArticleService); | ||
7 | + | ||
8 | + /** @ngInject */ | ||
9 | + function ArticleService(Restangular, api, $log) { | ||
10 | + $log.debug('ArticleService'); | ||
11 | + | ||
12 | + var articlesRest = Restangular.all('articles'); | ||
13 | + | ||
14 | + var service = { | ||
15 | + getList: articlesRest.getList, | ||
16 | + getHome: getHome | ||
17 | + }; | ||
18 | + | ||
19 | + return service; | ||
20 | + | ||
21 | + function getHome () { | ||
22 | + return articlesRest.get(api.articleId.home, { | ||
23 | + private_token: api.token, | ||
24 | + fields: 'id,children,categories,abstract,title,image,url,setting,position' | ||
25 | + }); | ||
26 | + } | ||
27 | + } | ||
28 | +})(); |
@@ -0,0 +1,68 @@ | @@ -0,0 +1,68 @@ | ||
1 | +(function() { | ||
2 | + 'use strict'; | ||
3 | + | ||
4 | + describe('article services', function() { | ||
5 | + var ArticleService, httpBackend; | ||
6 | + | ||
7 | + beforeEach(module('dialoga')); | ||
8 | + | ||
9 | + beforeEach(inject(function(_ArticleService_, $httpBackend) { | ||
10 | + ArticleService = _ArticleService_; | ||
11 | + httpBackend = $httpBackend; | ||
12 | + })); | ||
13 | + | ||
14 | + it('should return the main article', function() { | ||
15 | + | ||
16 | + httpBackend.whenGET('http://login.dialoga.gov.br/api/v1/articles/103358?fields=id,children,categories,abstract,title,image,url,setting,position').respond({ | ||
17 | + 'article':{'id':103358,'abstract':'\u003Cp style=\"text-align: center;\"\u003E\u003Ciframe src=\"https://www.youtube.com/embed/kpAdrO-emV0?rel=0\u0026amp;showinfo=0\u0026amp;iv_load_policy=3\u0026amp;controls=1\" style=\"max-width: 1000px; left: 5%;\" width=\"275\" height=\"200\"\u003E\u003C/iframe\u003E\u003C/p\u003E','title':'Dialoga Brasil','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null},{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null},{'name':'Educa\u00e7\u00e3o','id':181,'slug':'educacao','image':null},{'name':'Redu\u00e7\u00e3o da Pobreza','id':183,'slug':'reducao-da-pobreza','image':null}],'image':null,'setting':{'custom_body_label':'Corpo','phase':'proposals','allow_topics':true,'moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Leandro Nunes dos Santos','moderate_proposals':true,'allow_members_to_edit':false},'position':null,'children':[{'id':103644,'abstract':'\u003Cp\u003EUm caminho de oportunidades com o Enem: Sisu, Prouni, Fies, Ci\u00eancia sem Fronteiras\u003C/p\u003E','title':'Ensino Superior','categories':[{'name':'Educa\u00e7\u00e3o','id':181,'slug':'educacao','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0128/enem.jpg'},'setting':{'color':'#cfe2f3','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':9},{'id':103673,'abstract':'\u003Cp\u003EA melhor escolha \u00e9 se informar.\u003C/p\u003E','title':'Incentivo ao Parto Normal','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0092/parto-normal.jpg'},'setting':{'color':'#ff0000','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':6},{'id':103397,'abstract':'\u003Cp\u003ERenda, inclus\u00e3o produtiva e acesso a servi\u00e7os.\u003C/p\u003E','title':'Brasil Sem Mis\u00e9ria','categories':[{'name':'Redu\u00e7\u00e3o da Pobreza','id':183,'slug':'reducao-da-pobreza','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0116/bsm_redim.jpg'},'setting':{'color':'','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':18},{'id':103379,'abstract':'\u003Cp\u003EResgate e atendimento 24 horas, sete dias da semana.\u003C/p\u003E','title':'SAMU 192 e UPAs','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0060/SAMU.jpg'},'setting':{'color':'#45818e','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':4},{'id':103521,'abstract':'\u003Cp\u003EMais atendimento nos munic\u00edpios, mais sa\u00fade para quem mais precisa.\u003C/p\u003E','title':'Mais M\u00e9dicos','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0025/Mais_M_dicos.jpg'},'setting':{'color':'#ffe599','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':1},{'id':103390,'abstract':'\u003Cp\u003EPreven\u00e7\u00e3o, tratamento e enfrentamento ao tr\u00e1fico.\u003C/p\u003E','title':'Crack, \u00e9 poss\u00edvel vencer!','categories':[{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0104/crack.jpg'},'setting':{'color':'#00ff00','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':14},{'id':103592,'abstract':'\u003Cp\u003EGarantir acesso \u00e0 prote\u00e7\u00e3o social.\u003C/p\u003E','title':'Assist\u00eancia Social','categories':[{'name':'Redu\u00e7\u00e3o da Pobreza','id':183,'slug':'reducao-da-pobreza','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0122/assistencia_social.jpg'},'setting':{'color':'#a61c00','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':19},{'id':103426,'abstract':'\u003Cp\u003EDa sa\u00fade se cuida todos os dias.\u003C/p\u003E','title':'Vida saud\u00e1vel','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0046/vida_saudavel.jpg'},'setting':{'color':'#d9d2e9','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':7},{'id':103695,'abstract':'\u003Cp\u003ENovo modelo de atua\u00e7\u00e3o em Seguran\u00e7a P\u00fablica.\u003C/p\u003E','title':'Seguran\u00e7a P\u00fablica Integrada','categories':[{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0152/policiaintegrada.jpg'},'setting':{'color':'#ff00ff','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':13},{'id':103663,'abstract':'\u003Cp\u003EMais educa\u00e7\u00e3o profissional e tecnol\u00f3gica, mais desenvolvimento\u003C/p\u003E','title':'Ensino T\u00e9cnico','categories':[{'name':'Educa\u00e7\u00e3o','id':181,'slug':'educacao','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0134/Ensino_tecnico.jpg'},'setting':{'color':'#d0e0e3','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':10},{'id':103472,'abstract':'\u003Cp\u003EPol\u00edcia Federal, Pol\u00edcia Rodovi\u00e1ria Federal e For\u00e7a Nacional de Seguran\u00e7a P\u00fablica.\u003C/p\u003E','title':'For\u00e7as Federais de Seguran\u00e7a','categories':[{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0031/federais2.png'},'setting':{'color':'','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':16},{'id':103612,'abstract':'\u003Cp\u003EGarantir \u00e1gua para beber e produzir.\u003C/p\u003E','title':'Cisternas','categories':[{'name':'Redu\u00e7\u00e3o da Pobreza','id':183,'slug':'reducao-da-pobreza','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0039/cisterna_redim.jpg'},'setting':{'color':'#0000ff','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':20},{'id':103442,'abstract':'\u003Cp\u003EComplemento \u00e0 renda e acompanhamento em educa\u00e7\u00e3o e sa\u00fade.\u003C/p\u003E','title':'Bolsa Fam\u00edlia','categories':[{'name':'Redu\u00e7\u00e3o da Pobreza','id':183,'slug':'reducao-da-pobreza','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0013/bolsa_familia_redim.jpg'},'setting':{'color':'#ff9900','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':17},{'id':103507,'abstract':'\u003Cp\u003ETecnologia a servi\u00e7o da seguran\u00e7a do cidad\u00e3o.\u003C/p\u003E','title':'Sinesp','categories':[{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0098/sinesp.png'},'setting':{'color':'#00ff00','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':12},{'id':103683,'abstract':'\u003Cp\u003ESa\u00fade n\u00e3o tem pre\u00e7o.\u003C/p\u003E','title':'Aqui tem Farm\u00e1cia Popular','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0019/saude_nao_tem_preco.jpg'},'setting':{'color':'#e69138','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':5},{'id':103457,'abstract':'\u003Cp\u003EA\u00e7\u00e3o conjunta e coopera\u00e7\u00e3o transfronteiri\u00e7a.\u003C/p\u003E','title':'Prote\u00e7\u00e3o das Fronteiras','categories':[{'name':'Seguran\u00e7a P\u00fablica','id':182,'slug':'seguranca-publica','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0110/fronteira_redim.jpg'},'setting':{'color':'#a64d79','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':15},{'id':103494,'abstract':'\u003Cp\u003EDa Educa\u00e7\u00e3o Infantil ao Ensino M\u00e9dio.\u003C/p\u003E','title':'Educa\u00e7\u00e3o B\u00e1sica','categories':[{'name':'Educa\u00e7\u00e3o','id':181,'slug':'educacao','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0076/Educa__o_B_sica.jpg'},'setting':{'color':'#fce5cd','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':8},{'id':103359,'abstract':'\u003Cp\u003EAcesso a exames e consultas com especialistas.\u003C/p\u003E','title':'Mais Especialidades','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0083/mais_especialidades1.png'},'setting':{'color':'#ea9999','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':2},{'id':103485,'abstract':'\u003Cp\u003ECaminho para uma educa\u00e7\u00e3o de qualidade.\u003C/p\u003E','title':'Valoriza\u00e7\u00e3o dos Professores','categories':[{'name':'Educa\u00e7\u00e3o','id':181,'slug':'educacao','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0140/valorizacao_professor.jpg'},'setting':{'color':'#ffff00','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':11},{'id':103416,'abstract':'\u003Cp\u003EEstrutura adequada para atender melhor a popula\u00e7\u00e3o na aten\u00e7\u00e3o b\u00e1sica.\u003C/p\u003E','title':'Melhorar os Postos de Sa\u00fade','categories':[{'name':'Sa\u00fade','id':180,'slug':'saude','image':null}],'image':{'url':'/image_uploads/dialoga/0000/0053/requalif_redim.jpg'},'setting':{'color':'#cc4125','moderate_comments':false,'comment_paragraph_plugin_activate':false,'author_name':'Ronald Emerson Scherolt da Costa','allow_members_to_edit':false},'position':3}]}}); | ||
18 | + | ||
19 | + ArticleService.getHome().then(function(result) { | ||
20 | + | ||
21 | + expect(result.article).toBeDefined(); | ||
22 | + expect(result.article.title).toEqual('Dialoga Brasil'); | ||
23 | + | ||
24 | + }); | ||
25 | + | ||
26 | + httpBackend.flush(); | ||
27 | + }); | ||
28 | + | ||
29 | + // it('should return a list of articles', function() { | ||
30 | + | ||
31 | + // httpBackend.whenGET('http://login.dialoga.gov.br/api/v1/articles').respond({ | ||
32 | + // "articles": [ | ||
33 | + // { | ||
34 | + // abstract: "Que exista educação continuada permanente dos profissionais!!", | ||
35 | + // author: null, | ||
36 | + // body: "", | ||
37 | + // categories: [], | ||
38 | + // children: [], | ||
39 | + // created_at: "2015/08/04 16:36:13", | ||
40 | + // end_date: null, | ||
41 | + // hits: 0, | ||
42 | + // id: 120568, | ||
43 | + // image: null, | ||
44 | + // parent: {id: 103379,…}, | ||
45 | + // position: null, | ||
46 | + // profile: {identifier: "dialoga", name: "dialoga", id: 19195, created_at: "2015/04/15 09:38:36", image: null}, | ||
47 | + // setting: {comment_paragraph_plugin_activate: false, author_name: "estacio"}, | ||
48 | + // start_date: null, | ||
49 | + // tag_list: [], | ||
50 | + // title: "article_f4f4601c-0f36-e90e-d01a-9871f0bd126b", | ||
51 | + // votes_against: 0, | ||
52 | + // votes_for: 0, | ||
53 | + // } | ||
54 | + // ] | ||
55 | + // }); | ||
56 | + | ||
57 | + // ArticleService.getList().then(function(result) { | ||
58 | + // console.log('result', result); | ||
59 | + | ||
60 | + // expect(result.data.article).toBeDefined(); | ||
61 | + // expect(result.data.article.title).toEqual('Dialoga Brasil'); | ||
62 | + | ||
63 | + // }); | ||
64 | + | ||
65 | + // httpBackend.flush(); | ||
66 | + // }); | ||
67 | + }); | ||
68 | +})(); |
src/app/partials/header/header.controller.js
1 | +/* globals document:true*/ | ||
1 | (function() { | 2 | (function() { |
2 | 'use strict'; | 3 | 'use strict'; |
3 | 4 | ||
@@ -17,7 +18,7 @@ | @@ -17,7 +18,7 @@ | ||
17 | 18 | ||
18 | HeaderController.prototype.toggleContrast = function () { | 19 | HeaderController.prototype.toggleContrast = function () { |
19 | this.contrast = !this.contrast; | 20 | this.contrast = !this.contrast; |
20 | - console.debug('contrast', this.contrast); | 21 | + this.$log.debug('contrast', this.contrast); |
21 | }; | 22 | }; |
22 | 23 | ||
23 | HeaderController.prototype.focusMainContent = function ($event) { | 24 | HeaderController.prototype.focusMainContent = function ($event) { |
src/app/partials/inicio/inicio.controller.js
@@ -6,9 +6,25 @@ | @@ -6,9 +6,25 @@ | ||
6 | .controller('InicioController', InicioController); | 6 | .controller('InicioController', InicioController); |
7 | 7 | ||
8 | /** @ngInject */ | 8 | /** @ngInject */ |
9 | - function InicioController($log) { | 9 | + function InicioController(ArticleService, $log) { |
10 | $log.debug('InicioController'); | 10 | $log.debug('InicioController'); |
11 | - // var vm = this; | 11 | + |
12 | + var vm = this; | ||
13 | + | ||
14 | + | ||
15 | + $log.log('ArticleService', ArticleService); | ||
16 | + | ||
17 | + // ArticleService.getList().then(function(articles){ | ||
18 | + vm.loading = true; | ||
19 | + ArticleService.getHome().then(function(homeArticle){ | ||
20 | + $log.log('ArticleService.getList().then() homeArticle.article', homeArticle.article); | ||
21 | + | ||
22 | + vm.article = homeArticle.article; | ||
23 | + vm.loading = false; | ||
24 | + }, function () { | ||
25 | + $log.error('error'); | ||
26 | + vm.loading = false; | ||
27 | + }); | ||
12 | 28 | ||
13 | // vm.awesomeThings = []; | 29 | // vm.awesomeThings = []; |
14 | // vm.classAnimation = ''; | 30 | // vm.classAnimation = ''; |