diff --git a/blogproject/bower.json b/blogproject/bower.json index 7ee4c03..6ae0b0a 100644 --- a/blogproject/bower.json +++ b/blogproject/bower.json @@ -49,6 +49,10 @@ "paper-dialog": "PolymerElements/paper-dialog#^1.0.0", "paper-button": "PolymerElements/paper-button#^1.0.0", "paper-dialog-scrollable": "PolymerElements/paper-dialog-scrollable#^1.0.0", - "paper-input": "PolymerElements/paper-input#^1.0.0" + "paper-input": "PolymerElements/paper-input#^1.0.0", + "angular-material": "~0.10.0" + }, + "resolutions": { + "angular": "1.4.3" } } diff --git a/blogproject/gulpfile.js b/blogproject/gulpfile.js index bebd4d1..43dcd57 100644 --- a/blogproject/gulpfile.js +++ b/blogproject/gulpfile.js @@ -44,4 +44,4 @@ gulp.task('start-client', ['start-server'], function() { gulp.watch(['./web/**/*.css'], browserSync.reload); }); -gulp.task('default', ['start-client']); \ No newline at end of file +gulp.task('default', ['start-client']); diff --git a/blogproject/web/core/app.js b/blogproject/web/core/app.js index 31e6af3..951a3ff 100644 --- a/blogproject/web/core/app.js +++ b/blogproject/web/core/app.js @@ -4,6 +4,8 @@ angular.module( 'polymerblog', [ 'polymerblog.home', 'polymerblog.login', 'polymerblog.posts', + 'polymerblog.services', + 'ngMaterial', 'angular-storage', 'angular-jwt', 'pascalprecht.translate' @@ -72,4 +74,3 @@ angular.module( 'polymerblog', [ }) ; - diff --git a/blogproject/web/core/services.js b/blogproject/web/core/services.js new file mode 100644 index 0000000..dd0c328 --- /dev/null +++ b/blogproject/web/core/services.js @@ -0,0 +1,58 @@ +var Post = function ($resource, $http) { + var actions = { + save: { + // method: 'POST', + // transformRequest: [function(data) { + // var newData = _.extend({}, data); + // if (newData.query_id === undefined) { + // newData.query_id = newData.query.id; + // delete newData.query; + // } + // + // return newData; + // }].concat($http.defaults.transformRequest) + }, + + getAll: { + + } + + }; + + // var resource = $resource('/api/alerts/:id', {id: '@id'}, actions); + + return resource; +}; + +AuthService = function(auth, $location, $filter, store){ + + var all = { + auth: auth, + + login: function(){ + auth.signin({}, function(profile, token) { + store.set('profile', profile); + store.set('token', token); + $location.path("/"); + }, function(error) { + console.log($filter('translate')('login.loginFail'), error); + }); + + }, + + logout: function() { + auth.signout(); + store.remove('profile'); + store.remove('token'); + $location.path('/login'); + } + + }; + + return all; +}; + +angular.module('polymerblog.services', ['auth0']) + // .factory('Post', ['$resource', '$timeout', '$q', '$http', Post]) + .service('AuthService', ['auth', '$location', '$filter', 'store', AuthService]) + ; diff --git a/blogproject/web/elements/post-list.html b/blogproject/web/elements/post-list.html index 2820fff..872f754 100644 --- a/blogproject/web/elements/post-list.html +++ b/blogproject/web/elements/post-list.html @@ -1,22 +1,23 @@ - -