From e4b724c754f7950169cb144a9f398fae82643e40 Mon Sep 17 00:00:00 2001 From: brials Date: Tue, 28 Mar 2017 14:31:41 -0700 Subject: [PATCH 01/21] set up initial files --- .babelrc | 3 + .eslintrc | 21 ++++ .gitignore | 129 +++++++++++++++++++++++++ app/component/login/_login.scss | 0 app/component/login/login.html | 0 app/component/login/login.js | 0 app/component/signup/_signup.scss | 0 app/component/signup/signup.html | 0 app/component/signup/signup.js | 0 app/config/router-config.js | 0 app/entry.js | 0 app/index.html | 0 app/scss/lib/base/_base.scss | 0 app/scss/lib/base/_reset.scss | 48 +++++++++ app/scss/lib/layout/_content.scss | 0 app/scss/lib/layout/_footer.scss | 0 app/scss/lib/layout/_header.scss | 0 app/scss/lib/theme/_vars.scss | 0 app/scss/main.scss | 0 app/service/auth-service.js | 0 app/view/home/_home.scss | 0 app/view/home/home-controller.js | 0 app/view/home/home.html | 0 app/view/landing/_landing.scss | 0 app/view/landing/landing-controller.js | 0 app/view/landing/landing.html | 0 gulpfile.js | 23 +++++ package.json | 42 ++++++++ webpack.config.js | 35 +++++++ 29 files changed, 301 insertions(+) create mode 100644 .babelrc create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 app/component/login/_login.scss create mode 100644 app/component/login/login.html create mode 100644 app/component/login/login.js create mode 100644 app/component/signup/_signup.scss create mode 100644 app/component/signup/signup.html create mode 100644 app/component/signup/signup.js create mode 100644 app/config/router-config.js create mode 100644 app/entry.js create mode 100644 app/index.html create mode 100644 app/scss/lib/base/_base.scss create mode 100644 app/scss/lib/base/_reset.scss create mode 100644 app/scss/lib/layout/_content.scss create mode 100644 app/scss/lib/layout/_footer.scss create mode 100644 app/scss/lib/layout/_header.scss create mode 100644 app/scss/lib/theme/_vars.scss create mode 100644 app/scss/main.scss create mode 100644 app/service/auth-service.js create mode 100644 app/view/home/_home.scss create mode 100644 app/view/home/home-controller.js create mode 100644 app/view/home/home.html create mode 100644 app/view/landing/_landing.scss create mode 100644 app/view/landing/landing-controller.js create mode 100644 app/view/landing/landing.html create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..c13c5f62 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..ca514748 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..ac4aad84 --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ + +# Created by https://www.gitignore.io/api/node,osx,windows,linux + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/node,osx,windows,linux diff --git a/app/component/login/_login.scss b/app/component/login/_login.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/login/login.html b/app/component/login/login.html new file mode 100644 index 00000000..e69de29b diff --git a/app/component/login/login.js b/app/component/login/login.js new file mode 100644 index 00000000..e69de29b diff --git a/app/component/signup/_signup.scss b/app/component/signup/_signup.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/signup/signup.html b/app/component/signup/signup.html new file mode 100644 index 00000000..e69de29b diff --git a/app/component/signup/signup.js b/app/component/signup/signup.js new file mode 100644 index 00000000..e69de29b diff --git a/app/config/router-config.js b/app/config/router-config.js new file mode 100644 index 00000000..e69de29b diff --git a/app/entry.js b/app/entry.js new file mode 100644 index 00000000..e69de29b diff --git a/app/index.html b/app/index.html new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/lib/base/_reset.scss b/app/scss/lib/base/_reset.scss new file mode 100644 index 00000000..ed11813c --- /dev/null +++ b/app/scss/lib/base/_reset.scss @@ -0,0 +1,48 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/app/scss/lib/layout/_content.scss b/app/scss/lib/layout/_content.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/lib/layout/_footer.scss b/app/scss/lib/layout/_footer.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/lib/layout/_header.scss b/app/scss/lib/layout/_header.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/lib/theme/_vars.scss b/app/scss/lib/theme/_vars.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/scss/main.scss b/app/scss/main.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/service/auth-service.js b/app/service/auth-service.js new file mode 100644 index 00000000..e69de29b diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js new file mode 100644 index 00000000..e69de29b diff --git a/app/view/home/home.html b/app/view/home/home.html new file mode 100644 index 00000000..e69de29b diff --git a/app/view/landing/_landing.scss b/app/view/landing/_landing.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/view/landing/landing-controller.js b/app/view/landing/landing-controller.js new file mode 100644 index 00000000..e69de29b diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html new file mode 100644 index 00000000..e69de29b diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..d66519fb --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,23 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require ('gulp-mocha'); + +gulp.task('test', function(){ + gulp.src('./test/*-test.js', { read: false}) + .pipe(mocha({ reporter: 'spec'})); +}); + +gulp.task('lint', function() { + return gulp.src(['**/*.js', '!node_modules']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('dev', function(){ + gulp.watch(['**/*.js', '!node_modules/**'], ['lint', 'test']); +}); + +gulp.task('default', ['dev']); diff --git a/package.json b/package.json new file mode 100644 index 00000000..37b4ace9 --- /dev/null +++ b/package.json @@ -0,0 +1,42 @@ +{ + "name": "cfgram-auth", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "./node_modules/webpack/bin/webpack.js", + "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "angular": "^1.6.3", + "angular-animate": "^1.6.3", + "angular-route": "^1.6.3", + "angular-touch": "^1.6.3", + "angular-ui-router": "^0.4.2", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", + "babel-preset-es2015": "^6.24.0", + "camelcase": "^4.0.0", + "clean-webpack-plugin": "^0.1.16", + "css-loader": "^0.27.3", + "dotenv": "^4.0.0", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.10.1", + "html-loader": "^0.4.5", + "html-webpack-plugin": "^2.28.0", + "node-sass": "^4.5.1", + "pascalcase": "^0.1.1", + "resolve-url-loader": "^2.0.2", + "sass-loader": "^6.0.3", + "style-loader": "^0.16.1", + "ui-router": "^1.0.0-alpha.3", + "url-loader": "^0.5.8", + "webpack": "^2.3.2" + }, + "devDependencies": { + "webpack-dev-server": "^2.4.2" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..8fbb4232 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,35 @@ +'use strict'; + +const HTMLPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); + +module.exports = { + entry: `${__dirname}/app/entry.js`, + output: { + filename: 'bundle.js', + path: `${__dirname}/build` + }, + plugins: [ + new HTMLPlugin({ + template: `${__dirname}/app/index.html` + }), + new ExtractTextPlugin('bundle.css') + ], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + { + test: /\.html$/, + loader: 'html-loader' + }, + { + test: /\.scss$/, + loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + } + ] + } +}; From d26a3fd2af02142648235c4ec472134dcf26a844 Mon Sep 17 00:00:00 2001 From: brials Date: Tue, 28 Mar 2017 20:18:10 -0700 Subject: [PATCH 02/21] completed functionality --- app/component/login/login.html | 32 +++++++++++ app/component/login/login.js | 25 +++++++++ app/component/signup/signup.html | 9 +++ app/component/signup/signup.js | 27 +++++++++ app/config/router-config.js | 32 +++++++++++ app/entry.js | 36 ++++++++++++ app/index.html | 16 ++++++ app/service/auth-service.js | 78 ++++++++++++++++++++++++++ app/view/home/home-controller.js | 9 +++ app/view/home/home.html | 3 + app/view/landing/landing-controller.js | 9 +++ app/view/landing/landing.html | 16 ++++++ 12 files changed, 292 insertions(+) diff --git a/app/component/login/login.html b/app/component/login/login.html index e69de29b..997b3711 100644 --- a/app/component/login/login.html +++ b/app/component/login/login.html @@ -0,0 +1,32 @@ + + diff --git a/app/component/login/login.js b/app/component/login/login.js index e69de29b..b4530ce4 100644 --- a/app/component/login/login.js +++ b/app/component/login/login.js @@ -0,0 +1,25 @@ +'use strict'; + +require('./_login.scss'); +module.exports = { + template: require('./login.html'), + controller: ['$log', '$location', 'authService', LoginController], + controllerAs: 'loginCtrl' +} + +function LoginController($log, $location, authService){ + $log.debug('loginController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.login = function(){ + $log.debug('loginCtrl.login'); + authService.login(this.user) + .then(() => { + $location.url('/home'); + }); + }; +} diff --git a/app/component/signup/signup.html b/app/component/signup/signup.html index e69de29b..4a5b5314 100644 --- a/app/component/signup/signup.html +++ b/app/component/signup/signup.html @@ -0,0 +1,9 @@ + diff --git a/app/component/signup/signup.js b/app/component/signup/signup.js index e69de29b..559fc86b 100644 --- a/app/component/signup/signup.js +++ b/app/component/signup/signup.js @@ -0,0 +1,27 @@ +'use strict'; + +require('./_signup.scss'); + +module.exports = { + template: require('./signup.html'), + controller: ['$log', '$location', 'authService', SignUpController], + controllerAs: 'signupCtrl' +}; + +function SignUpController($log, $location, authService){ + + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.signup= function(user){ + $log.debug('SignUpController.signup'); + + authService.signup(user) + .then(() => { + $location.url('/home'); + }); + }; +} diff --git a/app/config/router-config.js b/app/config/router-config.js index e69de29b..f8f1590f 100644 --- a/app/config/router-config.js +++ b/app/config/router-config.js @@ -0,0 +1,32 @@ +'use strict'; + +module.exports = ['$stateProvider', 'urlRouterProvider', routerConfig]; + +function routerConfig($stateProvider, $urlRouterProvider){ + $urlRouterProvider.when('', '/join#signup'); + $urlRouterProvider.when('/', '/join#signup'); + $urlRouterProvider.when('/signup', '/join#signup'); + $urlRouterProvider.when('/login', '/join#signup'); + + + let states = [ + { + name: 'home', + url: '/home', + template: require('../view/home/home.html'), + controller: 'HomeController', + controllerAs: 'homeCtrl' + }, + { + name: 'landing', + url: '/join', + template: require('../view/landing/landing.html'), + controller: 'LandingController', + controllerAs: 'landingCtrl' + } + ]; + + states.forEach(state => { + $stateProvider.state(state); + }); +} diff --git a/app/entry.js b/app/entry.js index e69de29b..390c11a3 100644 --- a/app/entry.js +++ b/app/entry.js @@ -0,0 +1,36 @@ +'use strict'; + +require('./scss/main.scss'); + +const angular = require('angular'); +const pascalcase = require('pascalcase'); +const camelcase = require('camelcase'); +const uiRouter = require('angular-ui-router'); +const ngTouch = require('angular-touch'); +const ngAnimate = require('angular-animate'); +const path = require('path'); + +const brianGram = angular.module('brianGram',[ngTouch, ngAnimate, uiRouter]); + +let context = require.context('./config/', true, /\.js$/); +context.keys().forEach(key => { + brianGram.config(context(key)); +}); + +context = require.context('./view/', true, /\.js$/); +context.keys().forEach(key => { + let name = pascalcase(path.basename(key, '.js')); + brianGram.controller(name, context(key)); +}); + +context = require.context('./service/', true, /\.js$/); +context.keys().forEach(key => { + let name = camelcase(path.basename(key, '.js')); + brianGram.service(name, context(key)); +}); + +context = require.context('./component/', true, /\.js$/); +context.keys().forEach(key => { + let name = camelcase(path.basename(key, '.js')); + brianGram.service(name, context(key)); +}); diff --git a/app/index.html b/app/index.html index e69de29b..9372655b 100644 --- a/app/index.html +++ b/app/index.html @@ -0,0 +1,16 @@ + + + + + + Brians Gram App + + +
+
+ +
+ +
+ + diff --git a/app/service/auth-service.js b/app/service/auth-service.js index e69de29b..4ccbabea 100644 --- a/app/service/auth-service.js +++ b/app/service/auth-service.js @@ -0,0 +1,78 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', '$window', authService]; + +function authService($q, $log, $http, $window){ + $log.debug('authService'); + let service = {}; + let token = null; + + function setToken(_token){ + $log.debug('authService setToken'); + if(!_token){ + return $q.reject(new Error('no token')); + } + $window.localStorage.setItem('token', _token); + token = _token; + return $q.resolve(token); + } + + service.getToken = function(){ + $log.debug('authService.getToken'); + if(token) return $q.resolve(token); + token = $window.localStorage.getItem('token'); + if(token) return $q.resolve(token); + return $q.reject(new Error('token not found')); + }; + + service.signup = function(user){ + $log.debug('authService.signup'); + let url = 'https://slugram-backend.herokuapp.com/api/signup'; + let config = { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }; + + return $http.post(url, user, config) + .then(res => { + $log.log('success:', res.data); + return setToken(res.data); + }) + .catch(err => { + $log.error('failure:', err.message); + return $q.reject(err); + }); + }; + + service.logout = function(){ + $log.debug('authService.logout'); + $window.localStorage.removeItem('token'); + token = null; + return $q.resolve; + }; + + service.login = function(user){ + $log.debug('authService.login'); + let url = `https://slugram-backend.herokuapp.com/api/login`; //eslint-disable-line + let base64 = $window.btoa(`${user.username}:${user.password}`); + let config = { + headers: { + Accept: 'application/json', + Authorization: `Basic ${base64}` + } + }; + + return $http.get(url, config) + .then(res => { + $log.log('success', res.data); + return setToken(res.data); + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + return service; +} diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js index e69de29b..93c24505 100644 --- a/app/view/home/home-controller.js +++ b/app/view/home/home-controller.js @@ -0,0 +1,9 @@ +'use strict'; + +require('./_home.scss'); + +module.exports = ['$log', HomeController]; + +function HomeController($log){ + $log.debug('Home Controller'); +} diff --git a/app/view/home/home.html b/app/view/home/home.html index e69de29b..4079b005 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -0,0 +1,3 @@ +
+

Welcome Home

+
diff --git a/app/view/landing/landing-controller.js b/app/view/landing/landing-controller.js index e69de29b..0eb0fd0f 100644 --- a/app/view/landing/landing-controller.js +++ b/app/view/landing/landing-controller.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; + +function LandingController($log, $location, authService){ + $log.debug('LandingController'); + let url = $location.url(); + this.showSignup = url === '/join#signup' || url === '/join'; +} diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html index e69de29b..5be73c36 100644 --- a/app/view/landing/landing.html +++ b/app/view/landing/landing.html @@ -0,0 +1,16 @@ +
+
+
+ +

Already a member?

+ Sign In Here +
+
+
+
+ +

Want to Signup?

+ Sign In Here +
+
+
From cd4e7dc2bba4ea4683c65492553143f97f152565 Mon Sep 17 00:00:00 2001 From: brials Date: Tue, 28 Mar 2017 20:54:48 -0700 Subject: [PATCH 03/21] added some basic stylings --- app/config/router-config.js | 2 +- app/entry.js | 2 +- app/index.html | 2 +- app/scss/lib/base/_base.scss | 15 +++++++++++++++ app/scss/lib/layout/_content.scss | 5 +++++ app/scss/lib/layout/_footer.scss | 5 +++++ app/scss/lib/layout/_header.scss | 5 +++++ app/scss/lib/theme/_vars.scss | 5 +++++ app/scss/main.scss | 7 +++++++ app/view/landing/landing.html | 21 +++++++++++++++------ package.json | 2 +- 11 files changed, 61 insertions(+), 10 deletions(-) diff --git a/app/config/router-config.js b/app/config/router-config.js index f8f1590f..38bbf9e8 100644 --- a/app/config/router-config.js +++ b/app/config/router-config.js @@ -1,6 +1,6 @@ 'use strict'; -module.exports = ['$stateProvider', 'urlRouterProvider', routerConfig]; +module.exports = ['$stateProvider', '$urlRouterProvider', routerConfig]; function routerConfig($stateProvider, $urlRouterProvider){ $urlRouterProvider.when('', '/join#signup'); diff --git a/app/entry.js b/app/entry.js index 390c11a3..13e50101 100644 --- a/app/entry.js +++ b/app/entry.js @@ -32,5 +32,5 @@ context.keys().forEach(key => { context = require.context('./component/', true, /\.js$/); context.keys().forEach(key => { let name = camelcase(path.basename(key, '.js')); - brianGram.service(name, context(key)); + brianGram.component(name, context(key)); }); diff --git a/app/index.html b/app/index.html index 9372655b..d84e014e 100644 --- a/app/index.html +++ b/app/index.html @@ -8,7 +8,7 @@
- +
diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss index e69de29b..3d8d42b6 100644 --- a/app/scss/lib/base/_base.scss +++ b/app/scss/lib/base/_base.scss @@ -0,0 +1,15 @@ +a{ + text-decoration: none; + color: $white; +} + +button{ + padding-left: 30%; + padding-right: 30%; + border-radius: 10px; + background-color: $brand-primary; +} + +body{ + font-family: helvetica; +} diff --git a/app/scss/lib/layout/_content.scss b/app/scss/lib/layout/_content.scss index e69de29b..0a21926a 100644 --- a/app/scss/lib/layout/_content.scss +++ b/app/scss/lib/layout/_content.scss @@ -0,0 +1,5 @@ +main{ + width: 1000%; + background: $brand-secondary; + min-height: 960px; +} diff --git a/app/scss/lib/layout/_footer.scss b/app/scss/lib/layout/_footer.scss index e69de29b..d235a51f 100644 --- a/app/scss/lib/layout/_footer.scss +++ b/app/scss/lib/layout/_footer.scss @@ -0,0 +1,5 @@ +footer{ + height: 100px; + width: 100%; + background: $brand-primary; +} diff --git a/app/scss/lib/layout/_header.scss b/app/scss/lib/layout/_header.scss index e69de29b..e81b6ba7 100644 --- a/app/scss/lib/layout/_header.scss +++ b/app/scss/lib/layout/_header.scss @@ -0,0 +1,5 @@ +header{ + height: 100px; + width: 100%; + background: $brand-primary; +} diff --git a/app/scss/lib/theme/_vars.scss b/app/scss/lib/theme/_vars.scss index e69de29b..5d1f3034 100644 --- a/app/scss/lib/theme/_vars.scss +++ b/app/scss/lib/theme/_vars.scss @@ -0,0 +1,5 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$gutter: 20px; diff --git a/app/scss/main.scss b/app/scss/main.scss index e69de29b..bd6a2076 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -0,0 +1,7 @@ +@import './lib/base/reset'; +@import './lib/theme/vars'; +@import './lib/base/base'; + +@import './lib/layout/header'; +@import './lib/layout/content'; +@import './lib/layout/footer'; diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html index 5be73c36..efa4547a 100644 --- a/app/view/landing/landing.html +++ b/app/view/landing/landing.html @@ -1,16 +1,25 @@
-
+
-

Already a member?

- Sign In Here +

already a member?

+ + sign in here. +
-
+ +
-

Want to Signup?

- Sign In Here +

want to sign up?

+ + sign up here. +
diff --git a/package.json b/package.json index 37b4ace9..0accc979 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "cfgram-auth", + "name": "brianGram", "version": "1.0.0", "description": "", "main": "index.js", From 7770253eb6652fddead18fe3d15699e79dc890f8 Mon Sep 17 00:00:00 2001 From: brials Date: Tue, 28 Mar 2017 21:54:12 -0700 Subject: [PATCH 04/21] done with assignment and it looks really good. --- app/component/login/_login.scss | 20 ++++++++++++++++++++ app/component/signup/_signup.scss | 17 +++++++++++++++++ app/component/signup/signup.html | 2 +- app/index.html | 4 +++- app/scss/lib/layout/_content.scss | 5 +++-- app/scss/lib/layout/_header.scss | 6 ++++++ app/scss/lib/theme/_vars.scss | 2 +- app/scss/main.scss | 3 +++ app/view/home/_home.scss | 16 ++++++++++++++++ app/view/landing/_landing.scss | 16 ++++++++++++++++ app/view/landing/landing.html | 2 ++ 11 files changed, 88 insertions(+), 5 deletions(-) diff --git a/app/component/login/_login.scss b/app/component/login/_login.scss index e69de29b..f6771944 100644 --- a/app/component/login/_login.scss +++ b/app/component/login/_login.scss @@ -0,0 +1,20 @@ +.login-form{ + form{ + div{ + margin: 60px auto; + input{ + display: block; + width: 80%; + height: 30px; + margin: 60px auto; + border-radius: 10px; + text-align: center; + } + + } + button{ + margin-left: 20%; + height: 30px; + } + } +} diff --git a/app/component/signup/_signup.scss b/app/component/signup/_signup.scss index e69de29b..eb6bce4f 100644 --- a/app/component/signup/_signup.scss +++ b/app/component/signup/_signup.scss @@ -0,0 +1,17 @@ +.signup{ + form{ + input{ + display: block; + width: 80%; + height: 30px; + margin: 60px auto; + border-radius: 10px; + text-align: center; + } + + button{ + margin-left: 20%; + height: 30px; + } + } +} diff --git a/app/component/signup/signup.html b/app/component/signup/signup.html index 4a5b5314..aace45a1 100644 --- a/app/component/signup/signup.html +++ b/app/component/signup/signup.html @@ -4,6 +4,6 @@ - + diff --git a/app/index.html b/app/index.html index d84e014e..f2ce93f4 100644 --- a/app/index.html +++ b/app/index.html @@ -6,7 +6,9 @@ Brians Gram App -
+
+ +
diff --git a/app/scss/lib/layout/_content.scss b/app/scss/lib/layout/_content.scss index 0a21926a..4b97a526 100644 --- a/app/scss/lib/layout/_content.scss +++ b/app/scss/lib/layout/_content.scss @@ -1,5 +1,6 @@ main{ - width: 1000%; + overflow:auto; + width: 100%; background: $brand-secondary; - min-height: 960px; + min-height: 720px; } diff --git a/app/scss/lib/layout/_header.scss b/app/scss/lib/layout/_header.scss index e81b6ba7..55fafc46 100644 --- a/app/scss/lib/layout/_header.scss +++ b/app/scss/lib/layout/_header.scss @@ -2,4 +2,10 @@ header{ height: 100px; width: 100%; background: $brand-primary; + img{ + height: 50px; + width:50px; + margin-top: 25px; + margin-left: 30px; + } } diff --git a/app/scss/lib/theme/_vars.scss b/app/scss/lib/theme/_vars.scss index 5d1f3034..80409a74 100644 --- a/app/scss/lib/theme/_vars.scss +++ b/app/scss/lib/theme/_vars.scss @@ -2,4 +2,4 @@ $brand-primary: #444; $brand-secondary: #888; $black: #000; $white: #fff; -$gutter: 20px; +$gutter: 60px; diff --git a/app/scss/main.scss b/app/scss/main.scss index bd6a2076..20ed08fa 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -5,3 +5,6 @@ @import './lib/layout/header'; @import './lib/layout/content'; @import './lib/layout/footer'; + +@import '../view/landing/landing'; +@import '../view/home/home'; diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss index e69de29b..eef60400 100644 --- a/app/view/home/_home.scss +++ b/app/view/home/_home.scss @@ -0,0 +1,16 @@ +.join-container{ + h2{ + margin-left: 10%; + margin-top: 50px; + font-size: 4vw; + } +} + + +.join-inner{ + p{ + margin-left: 50%; + float:left; + margin-right:10px; + } +} diff --git a/app/view/landing/_landing.scss b/app/view/landing/_landing.scss index e69de29b..eef60400 100644 --- a/app/view/landing/_landing.scss +++ b/app/view/landing/_landing.scss @@ -0,0 +1,16 @@ +.join-container{ + h2{ + margin-left: 10%; + margin-top: 50px; + font-size: 4vw; + } +} + + +.join-inner{ + p{ + margin-left: 50%; + float:left; + margin-right:10px; + } +} diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html index efa4547a..3033a7e3 100644 --- a/app/view/landing/landing.html +++ b/app/view/landing/landing.html @@ -1,6 +1,7 @@
+

Sign Up.

already a member?

@@ -13,6 +14,7 @@
+

Sign In.

want to sign up?

From b423595e84a5969bd41bb89648ba04acd1824713 Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 10:20:44 -0700 Subject: [PATCH 05/21] updated webpack config and created log-config file. --- app/config/log-config.js | 7 +++++++ webpack.config.js | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/config/log-config.js diff --git a/app/config/log-config.js b/app/config/log-config.js new file mode 100644 index 00000000..683171b9 --- /dev/null +++ b/app/config/log-config.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = ['$logProvider', logConfig]; + +function logConfig($logProvider){ + $logProvider.debugEnabled(__DEBUG__); +} diff --git a/webpack.config.js b/webpack.config.js index 8fbb4232..0f235540 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,17 @@ 'use strict'; +const dotenv = require('dotenv'); + const HTMLPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const webpack = require('webpack'); + +const production = process.env.NODE_ENV === 'production'; + +dotenv.load(); module.exports = { + devtool: 'eval', entry: `${__dirname}/app/entry.js`, output: { filename: 'bundle.js', @@ -13,7 +21,11 @@ module.exports = { new HTMLPlugin({ template: `${__dirname}/app/index.html` }), - new ExtractTextPlugin('bundle.css') + new ExtractTextPlugin('bundle.css'), + new webpack.DefinePlugin({ + __API_URL__: JSON.stringify(process.env.API_URL), + __DEBUG__: JSON.stringify(!production) + }) ], module: { rules: [ From b9e3bc8c6311dd9b56772d1fb6f459c9eeda364e Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 10:46:20 -0700 Subject: [PATCH 06/21] added first route to new gallery-service file. --- app/service/gallery-service.js | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/service/gallery-service.js diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js new file mode 100644 index 00000000..dc93ee42 --- /dev/null +++ b/app/service/gallery-service.js @@ -0,0 +1,37 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'authService', gallerySerivce]; + +function gallerySerivce($q, $log, $http, authService){ + $log.debug('gallerySerivce'); + + let service = {}; + service.galleries = []; + + service.createGallery = function(gallery){ + $log.debug('gallerySerivce.createGallery'); + + return authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.post(url, gallery, config); + }) + .then(res => { + $log.log('gallery created'); + let gallery = res.data; + service.galleries.unshift(gallery); + return gallery; + }) + .catch(err => { + $log.error(err.message); + }); + }; +} From a10dcf5e09f13309ec7c6a43b6e7c3551ee1c14e Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 10:54:13 -0700 Subject: [PATCH 07/21] wrote out partial deleteGallery added TODO for next couple days --- app/service/gallery-service.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js index dc93ee42..e7277ee4 100644 --- a/app/service/gallery-service.js +++ b/app/service/gallery-service.js @@ -34,4 +34,19 @@ function gallerySerivce($q, $log, $http, authService){ $log.error(err.message); }); }; + + service.deleteGallery = function(galleryId, galleryData) { + $log.debug('service.deleteGallery'); + return authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery/${galleryId}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + }; + }); + //TODO finish this route; + }; } From 2202408efd7e4b0887c68bf0a6e5479f9d9baf93 Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 11:46:03 -0700 Subject: [PATCH 08/21] added navbar and buttons --- app/component/navbar/_navbar.scss | 0 app/component/navbar/navbar.html | 8 +++++++ app/component/navbar/navbar.js | 40 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 app/component/navbar/_navbar.scss create mode 100644 app/component/navbar/navbar.html create mode 100644 app/component/navbar/navbar.js diff --git a/app/component/navbar/_navbar.scss b/app/component/navbar/_navbar.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/navbar/navbar.html b/app/component/navbar/navbar.html new file mode 100644 index 00000000..615d739f --- /dev/null +++ b/app/component/navbar/navbar.html @@ -0,0 +1,8 @@ + diff --git a/app/component/navbar/navbar.js b/app/component/navbar/navbar.js new file mode 100644 index 00000000..89cbe940 --- /dev/null +++ b/app/component/navbar/navbar.js @@ -0,0 +1,40 @@ +'use strict'; + +require('./_navbar.scss'); + +module.exports = { + template: require('./navbar.html'), + controller: ['$log', '$location', '$rootScope', 'authService', NavbarController], + controllerAs: 'navbarCtrl' +}; + +function NavbarController($log, $location, $rootScope, authService){ + $log.debug('NavbarController'); + + this.checkPath = function(){ + let path = $location.path(); + if(path === '/join') this.hideButtons = true; + if(path !== '/join') { + this.hideButtons = false; + authService.getToken() + .catch(() => { + $location.url('/join#login'); + }); + } + }; + + this.checkPath(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.checkPath(); + }); + + this.logout = function(){ + $log.log('NavbarController.logout'); + this.hideButtons = true; + authService.logout() + .then(() => { + $location.url('/'); + }); + }; +} From 48652601115d85456715d10e7437af06354b6754 Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 12:02:39 -0700 Subject: [PATCH 09/21] moved some files created gallery component --- app/component/gallery/_create-gallery.scss | 0 app/component/gallery/create-gallery.html | 13 ++++++++++++ app/component/gallery/create-gallery.js | 23 ++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 app/component/gallery/_create-gallery.scss create mode 100644 app/component/gallery/create-gallery.html create mode 100644 app/component/gallery/create-gallery.js diff --git a/app/component/gallery/_create-gallery.scss b/app/component/gallery/_create-gallery.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/create-gallery.html b/app/component/gallery/create-gallery.html new file mode 100644 index 00000000..d31360ef --- /dev/null +++ b/app/component/gallery/create-gallery.html @@ -0,0 +1,13 @@ + diff --git a/app/component/gallery/create-gallery.js b/app/component/gallery/create-gallery.js new file mode 100644 index 00000000..fff8f544 --- /dev/null +++ b/app/component/gallery/create-gallery.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./_create-gallery.scss'); + +module.exports = { + template: require('./create-gallery.html'), + controller: ['$log', 'gallerySerivce', CreateGalleryController], + controllerAs: 'createGalleryCtrl' +}; + +function CreateGalleryController($log, gallerySerivce){ + $log.debug('CreateGalleryController'); + + this.gallery ={}; + + this.createGallery=function(){ + gallerySerivce.createGallery(this.gallery) + .then(() => { + this.gallery.name = null; + this.gallery.desc = null; + }); + }; +} From 1a4349d473c509b91e41e68a4acc7991acce8f9e Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 12:03:25 -0700 Subject: [PATCH 10/21] last commit from lower file actually including some changes now --- app/component/{ => landing}/login/_login.scss | 0 app/component/{ => landing}/login/login.html | 0 app/component/{ => landing}/login/login.js | 0 .../{ => landing}/signup/_signup.scss | 0 .../{ => landing}/signup/signup.html | 0 app/component/{ => landing}/signup/signup.js | 0 app/service/gallery-service.js | 27 +++++++++++++++++++ 7 files changed, 27 insertions(+) rename app/component/{ => landing}/login/_login.scss (100%) rename app/component/{ => landing}/login/login.html (100%) rename app/component/{ => landing}/login/login.js (100%) rename app/component/{ => landing}/signup/_signup.scss (100%) rename app/component/{ => landing}/signup/signup.html (100%) rename app/component/{ => landing}/signup/signup.js (100%) diff --git a/app/component/login/_login.scss b/app/component/landing/login/_login.scss similarity index 100% rename from app/component/login/_login.scss rename to app/component/landing/login/_login.scss diff --git a/app/component/login/login.html b/app/component/landing/login/login.html similarity index 100% rename from app/component/login/login.html rename to app/component/landing/login/login.html diff --git a/app/component/login/login.js b/app/component/landing/login/login.js similarity index 100% rename from app/component/login/login.js rename to app/component/landing/login/login.js diff --git a/app/component/signup/_signup.scss b/app/component/landing/signup/_signup.scss similarity index 100% rename from app/component/signup/_signup.scss rename to app/component/landing/signup/_signup.scss diff --git a/app/component/signup/signup.html b/app/component/landing/signup/signup.html similarity index 100% rename from app/component/signup/signup.html rename to app/component/landing/signup/signup.html diff --git a/app/component/signup/signup.js b/app/component/landing/signup/signup.js similarity index 100% rename from app/component/signup/signup.js rename to app/component/landing/signup/signup.js diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js index e7277ee4..59d66593 100644 --- a/app/service/gallery-service.js +++ b/app/service/gallery-service.js @@ -49,4 +49,31 @@ function gallerySerivce($q, $log, $http, authService){ }); //TODO finish this route; }; + + service.fetchGalleries = function(){ + $log.debug('gallerySerivce.fetchGalleries'); + + return authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.get(url, config); + }) + .then(res => { + $log.log('galleries retrieved'); + service.galleries = res.data; + return service.galleries; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + return service; } From 1fcca2d0d2fd672033c4910c5b24dbdfa337f969 Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 12:10:22 -0700 Subject: [PATCH 11/21] updated home view controller and html --- app/view/home/home-controller.js | 17 +++++++++++++++-- app/view/home/home.html | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js index 93c24505..e94dbaf9 100644 --- a/app/view/home/home-controller.js +++ b/app/view/home/home-controller.js @@ -2,8 +2,21 @@ require('./_home.scss'); -module.exports = ['$log', HomeController]; +module.exports = ['$log', '$rootScope', 'galleryService', HomeController]; -function HomeController($log){ +function HomeController($log, $rootScope, galleryService){ $log.debug('Home Controller'); + this.galleries =[]; + + this.fetchGalleries = function(){ + galleryService.fetchGalleries() + .then(galleries => { + this.galleries = galleries; + }); + }; + + this.fetchGalleries; + $rootScope.$on('$locationChangeSuccess', () => { + this.fetchGalleries(); + }); } diff --git a/app/view/home/home.html b/app/view/home/home.html index 4079b005..9df1534b 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -1,3 +1,9 @@
-

Welcome Home

+ +
    +
  • + name: {{gallery.name}} + desc: {{gallery.desc}} +
  • +
From 842ced021fb5652fd88520a22ca1c16bcf0270b2 Mon Sep 17 00:00:00 2001 From: brials Date: Wed, 29 Mar 2017 14:27:43 -0700 Subject: [PATCH 12/21] fixed minor errors and got app functioning properly --- app/component/gallery/create-gallery.js | 6 ++-- app/component/navbar/navbar.html | 1 + app/component/navbar/navbar.js | 19 ++++++----- app/index.html | 2 +- app/service/auth-service.js | 2 +- app/service/gallery-service.js | 42 ++++++++++++------------- app/view/home/home-controller.js | 2 +- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/app/component/gallery/create-gallery.js b/app/component/gallery/create-gallery.js index fff8f544..5bc3fb22 100644 --- a/app/component/gallery/create-gallery.js +++ b/app/component/gallery/create-gallery.js @@ -4,17 +4,17 @@ require('./_create-gallery.scss'); module.exports = { template: require('./create-gallery.html'), - controller: ['$log', 'gallerySerivce', CreateGalleryController], + controller: ['$log', 'galleryService', CreateGalleryController], controllerAs: 'createGalleryCtrl' }; -function CreateGalleryController($log, gallerySerivce){ +function CreateGalleryController($log, galleryService){ $log.debug('CreateGalleryController'); this.gallery ={}; this.createGallery=function(){ - gallerySerivce.createGallery(this.gallery) + galleryService.createGallery(this.gallery) .then(() => { this.gallery.name = null; this.gallery.desc = null; diff --git a/app/component/navbar/navbar.html b/app/component/navbar/navbar.html index 615d739f..dbe10a00 100644 --- a/app/component/navbar/navbar.html +++ b/app/component/navbar/navbar.html @@ -1,5 +1,6 @@