From a61300eb8cea010deb9a0fbb8b03d01b99177f77 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Tue, 28 Mar 2017 20:13:26 -0700 Subject: [PATCH 01/14] done --- .babelrc | 3 + .gitignore | 65 +++++++++++++++++++ app/component/login/_login.scss | 0 app/component/login/login.html | 28 ++++++++ app/component/login/login.js | 27 ++++++++ app/component/signup/_signup.scss | 0 app/component/signup/signup.html | 24 +++++++ app/component/signup/signup.js | 25 ++++++++ app/config/router-config.js | 31 +++++++++ app/entry.js | 46 ++++++++++++++ app/index.html | 17 +++++ app/scss/lib/base/_base.scss | 53 ++++++++++++++++ app/scss/lib/base/_reset.scss | 48 ++++++++++++++ app/scss/lib/layout/_content.scss | 14 ++++ 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 | 18 ++++++ app/service/auth-service.js | 88 ++++++++++++++++++++++++++ app/view/home/_home.scss | 0 app/view/home/home-controller.js | 9 +++ app/view/home/home.html | 3 + app/view/landing/_landing.scss | 0 app/view/landing/landing-controller.js | 10 +++ app/view/landing/landing.html | 29 +++++++++ package.json | 50 +++++++++++++++ webpack.config.js | 42 ++++++++++++ 27 files changed, 630 insertions(+) create mode 100644 .babelrc 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 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/.gitignore b/.gitignore new file mode 100644 index 00000000..57026783 --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ + +# Created by https://www.gitignore.io/api/node + +### 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 + + +# End of https://www.gitignore.io/api/node 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..1c6ed38f --- /dev/null +++ b/app/component/login/login.html @@ -0,0 +1,28 @@ +
+

sign in

+
+
+ +
+
+ +
+ +
+
diff --git a/app/component/login/login.js b/app/component/login/login.js new file mode 100644 index 00000000..77c2c83e --- /dev/null +++ b/app/component/login/login.js @@ -0,0 +1,27 @@ +'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.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..a75d862e --- /dev/null +++ b/app/component/signup/signup.html @@ -0,0 +1,24 @@ +
+

sign up

+ +
diff --git a/app/component/signup/signup.js b/app/component/signup/signup.js new file mode 100644 index 00000000..2f58215c --- /dev/null +++ b/app/component/signup/signup.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = { + template: require('./signup.html'), + controller: ['$log', '$location', 'authService', SignupController], + controllerAs: 'signupCtrl' +}; + +function SignupController($log, $location, authService) { + $log.debug('SignupController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.signup = function(user) { + $log.debug('signupCtrl.signup'); + + authService.signup(user) + .then( () => { + $location.url('/home'); + }); + }; +} diff --git a/app/config/router-config.js b/app/config/router-config.js new file mode 100644 index 00000000..31d817b6 --- /dev/null +++ b/app/config/router-config.js @@ -0,0 +1,31 @@ +'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#login'); + + 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 new file mode 100644 index 00000000..b380be14 --- /dev/null +++ b/app/entry.js @@ -0,0 +1,46 @@ +'use strict'; + +require('./scss/main.scss'); + +const path = require('path'); +const angular = require('angular'); +const camelcase = require('camelcase'); +const pascalcase = require('pascalcase'); +const uiRouter = require('angular-ui-router'); +const ngTouch = require('angular-touch'); +const ngAnimate = require('angular-animate'); + +const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter]); + +// try logging "context" check out "keys" +// log the shit out of this +// name module +// name dependencies +// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + +let context = require.context('./config/', true, /\.js$/); +context.keys().forEach( key => { + cfgram.config(context(key)); +}); + + +context = require.context('./view/', true, /\.js$/); +context.keys().forEach( key => { + let name = pascalcase(path.basename(key, '.js')); + let module = context(key); + cfgram.controller(name, module); +}); + +context = require.context('./service/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.service(name, module); +}); + +context = require.context('./component/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.component(name, module); +}); diff --git a/app/index.html b/app/index.html new file mode 100644 index 00000000..eb9feb22 --- /dev/null +++ b/app/index.html @@ -0,0 +1,17 @@ + + + + + + cfgram + + +
+ + cfgram +
+ + + + + diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss new file mode 100644 index 00000000..cc0ca87f --- /dev/null +++ b/app/scss/lib/base/_base.scss @@ -0,0 +1,53 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +body { + background-color: $grey; + color: $brand-primary; + width: 100%; +} + +header { + background-color: $brand-primary; + color: $white; +} +h2{ + font-size: 125%; + margin-top: $gutter / 2; + margin-left: $gutterP / 2; +} +button{ + background-color: $brand-primary; + color: $white; +} +.btn-std { + background-color: $brand-primary; + color: $white; + width: 25%; + float: right; + margin-left: 0; + margin-right: $gutterP / 2; + +} + +input{ + width:40%; + margin-left: $gutterP / 2; + margin-right: 55%; + margin-top: $gutter; + height: 30px; + border-radius: 3px; + transition: 350ms; +} + +input:focus { + margin-right: $gutterP / 2; + border: 3px solid #555; + width: 90%; + outline: 0; +} 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..ca04f321 --- /dev/null +++ b/app/scss/lib/layout/_content.scss @@ -0,0 +1,14 @@ +.signin-login-wrapper { + clear: both; + float: right; + margin-right: $gutterP / 2; + p{ + display: inline-block; + } + a{ + display: inline-block; + text-decoration: none; + color: $brand-primary; + font-weight: bold; + } +} 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..403732fc --- /dev/null +++ b/app/scss/main.scss @@ -0,0 +1,18 @@ +@import "lib/base/reset"; +@import "lib/base/base"; + +@import "lib/layout/header"; +@import "lib/layout/footer"; +@import "lib/layout/content"; + +@import "lib/theme/vars"; + +@import "../component/login/login"; +@import "../component/signup/signup"; + +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; diff --git a/app/service/auth-service.js b/app/service/auth-service.js new file mode 100644 index 00000000..2dcd2119 --- /dev/null +++ b/app/service/auth-service.js @@ -0,0 +1,88 @@ +'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 = `${__API_URL__}/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('failuire:', 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 = `${__API_URL__}/api/login`; + 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.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..dd9d54bf --- /dev/null +++ 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('HomeController'); +} diff --git a/app/view/home/home.html b/app/view/home/home.html new file mode 100644 index 00000000..12d2ecfc --- /dev/null +++ b/app/view/home/home.html @@ -0,0 +1,3 @@ +
+

Welcome Home!

+
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..e8d6eaf1 --- /dev/null +++ b/app/view/landing/landing-controller.js @@ -0,0 +1,10 @@ +'use strict'; + +require('./_landing.scss'); + +module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; + +function LandingController($log, $location, authService) { + 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 new file mode 100644 index 00000000..04378f2c --- /dev/null +++ b/app/view/landing/landing.html @@ -0,0 +1,29 @@ +
+
+
+ + +
+
+ +
+
+ + +
+
+
diff --git a/package.json b/package.json new file mode 100644 index 00000000..c458ace6 --- /dev/null +++ b/package.json @@ -0,0 +1,50 @@ +{ + "name": "25-angular_auth", + "version": "1.0.0", + "description": "![cf](https://i.imgur.com/7v5ASc8.png) Lab 25 - Client Side Auth\r ======", + "main": "index.js", + "scripts": { + "build": "./node_modules/webpack/bin/webpack.js", + "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/noahgribbin/25-angular_auth.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/noahgribbin/25-angular_auth/issues" + }, + "homepage": "https://github.com/noahgribbin/25-angular_auth#readme", + "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..5125b9f7 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,42 @@ +'use strict'; + +require('dotenv').load(); + +const webpack = require('webpack'); +const HTMLPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); + +module.exports = { + devtool: 'eval', + entry: `${__dirname}/app/entry.js`, + output: { + filename: 'bundle.js', + path: `${__dirname}/build` + }, + plugins: [ + new HTMLPlugin({ + template: `${__dirname}/app/index.html` + }), + new ExtractTextPlugin('bundle.css'), + new webpack.DefinePlugin({ + __API_URL__: JSON.stringify(process.env.API_URL) + }) + ], + 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 5a193062a75159d1212c57433fa332becbb92005 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Tue, 28 Mar 2017 20:36:06 -0700 Subject: [PATCH 02/14] more styling --- app/index.html | 3 ++- app/scss/lib/base/_base.scss | 13 +++++++++---- app/scss/lib/layout/_header.scss | 8 ++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/index.html b/app/index.html index eb9feb22..9cefa3c4 100644 --- a/app/index.html +++ b/app/index.html @@ -8,7 +8,8 @@
- cfgram + +

cfgram

diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss index cc0ca87f..85c9c760 100644 --- a/app/scss/lib/base/_base.scss +++ b/app/scss/lib/base/_base.scss @@ -16,15 +16,18 @@ header { background-color: $brand-primary; color: $white; } + h2{ font-size: 125%; margin-top: $gutter / 2; margin-left: $gutterP / 2; } + button{ background-color: $brand-primary; color: $white; } + .btn-std { background-color: $brand-primary; color: $white; @@ -32,22 +35,24 @@ button{ float: right; margin-left: 0; margin-right: $gutterP / 2; - + padding: 0; + height: 40px; } input{ - width:40%; + width:90%; margin-left: $gutterP / 2; - margin-right: 55%; + margin-right: $gutterP / 2; margin-top: $gutter; height: 30px; border-radius: 3px; transition: 350ms; + padding: 10px; } input:focus { margin-right: $gutterP / 2; border: 3px solid #555; - width: 90%; + // width: 90%; outline: 0; } diff --git a/app/scss/lib/layout/_header.scss b/app/scss/lib/layout/_header.scss index e69de29b..2df1e28c 100644 --- a/app/scss/lib/layout/_header.scss +++ b/app/scss/lib/layout/_header.scss @@ -0,0 +1,8 @@ +header{ + height: 100px; + line-height: 100px; + font-size: 175%; + p{ + margin-left: $gutter; + } +} From 6482617c9818d228960d24e5f926cbdcf60eaf31 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Wed, 29 Mar 2017 15:32:41 -0700 Subject: [PATCH 03/14] add gallery service and component --- .../create-gallery/_create-gallery.scss} | 0 .../create-gallery/create-gallery.html | 24 ++++++ .../gallery/create-gallery/create-gallery.js | 21 +++++ .../login/_login.scss} | 0 app/component/{ => landing}/login/login.html | 2 +- app/component/{ => landing}/login/login.js | 0 app/component/landing/signup/_signup.scss | 0 .../{ => landing}/signup/signup.html | 0 app/component/{ => landing}/signup/signup.js | 0 app/component/navbar/_navbar.scss | 0 app/component/navbar/navbar.html | 9 ++ app/component/navbar/navbar.js | 43 ++++++++++ app/config/log-config.js | 7 ++ app/index.html | 9 +- app/scss/lib/base/_base.scss | 12 ++- app/scss/main.scss | 4 +- app/service/gallery-service.js | 81 ++++++++++++++++++ app/view/home/home-controller.js | 18 +++- app/view/home/home.html | 10 ++- assets/cf-logo.png | Bin 0 -> 6821 bytes webpack.config.js | 10 ++- 21 files changed, 234 insertions(+), 16 deletions(-) rename app/component/{login/_login.scss => gallery/create-gallery/_create-gallery.scss} (100%) create mode 100644 app/component/gallery/create-gallery/create-gallery.html create mode 100644 app/component/gallery/create-gallery/create-gallery.js rename app/component/{signup/_signup.scss => landing/login/_login.scss} (100%) rename app/component/{ => landing}/login/login.html (96%) rename app/component/{ => landing}/login/login.js (100%) create mode 100644 app/component/landing/signup/_signup.scss rename app/component/{ => landing}/signup/signup.html (100%) rename app/component/{ => landing}/signup/signup.js (100%) create mode 100644 app/component/navbar/_navbar.scss create mode 100644 app/component/navbar/navbar.html create mode 100644 app/component/navbar/navbar.js create mode 100644 app/config/log-config.js create mode 100644 app/service/gallery-service.js create mode 100644 assets/cf-logo.png diff --git a/app/component/login/_login.scss b/app/component/gallery/create-gallery/_create-gallery.scss similarity index 100% rename from app/component/login/_login.scss rename to app/component/gallery/create-gallery/_create-gallery.scss diff --git a/app/component/gallery/create-gallery/create-gallery.html b/app/component/gallery/create-gallery/create-gallery.html new file mode 100644 index 00000000..691988d3 --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.html @@ -0,0 +1,24 @@ + diff --git a/app/component/gallery/create-gallery/create-gallery.js b/app/component/gallery/create-gallery/create-gallery.js new file mode 100644 index 00000000..a6da00a7 --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = { + template: require('./create-gallery.html'), + controller: ['$log', 'galleryService', CreateGalleryController], + controllerAs: 'createGalleryCtrl' +}; + +function CreateGalleryController($log, galleryService) { + $log.debug('CreateGalleryController'); + + this.gallery = {}; + + this.createGallery = function() { + galleryService.createGallery(this.gallery) + .then( () => { + this.gallery.name = null; + this.gallery.desc = null; + }); + }; +} diff --git a/app/component/signup/_signup.scss b/app/component/landing/login/_login.scss similarity index 100% rename from app/component/signup/_signup.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 96% rename from app/component/login/login.html rename to app/component/landing/login/login.html index 1c6ed38f..7c635098 100644 --- a/app/component/login/login.html +++ b/app/component/landing/login/login.html @@ -16,7 +16,7 @@

sign in

'error': loginForm.password.$invalid && loginForm.$submitted, 'success': loginForm.password.$valid }"> - + +

cfgram

+ + diff --git a/app/component/navbar/navbar.js b/app/component/navbar/navbar.js new file mode 100644 index 00000000..79c48ef3 --- /dev/null +++ b/app/component/navbar/navbar.js @@ -0,0 +1,43 @@ +'use strict'; + +require('./_navbar.scss'); + +module.exports = { + template: require('./navbar.html'), + conroller: ['$log', '$location', '$rootScope', 'authService', NavbarConroller], + conrollerAs: 'navbarCtrl' +}; + +function NavbarConroller($log, $location, $rootScope, authService) { + $log.debug('NavbarConroller'); + + 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.debug('navbarCtrl.logout'); + this.hideButtons = true; + authService.logout() + .then( () => { + $location.url('/'); + }); + }; +} diff --git a/app/config/log-config.js b/app/config/log-config.js new file mode 100644 index 00000000..06c0f4b4 --- /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/app/index.html b/app/index.html index 9cefa3c4..1b24412b 100644 --- a/app/index.html +++ b/app/index.html @@ -7,12 +7,11 @@
- - -

cfgram

+
- - +
+ +
diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss index 85c9c760..8923409b 100644 --- a/app/scss/lib/base/_base.scss +++ b/app/scss/lib/base/_base.scss @@ -37,6 +37,14 @@ button{ margin-right: $gutterP / 2; padding: 0; height: 40px; + outline: 0; +} +.btn-std:focus{ + outline: 0; + +} +.btn-std:hover{ + } input{ @@ -52,7 +60,7 @@ input{ input:focus { margin-right: $gutterP / 2; - border: 3px solid #555; + outline: 3px solid #555; // width: 90%; - outline: 0; + // outline: 0; } diff --git a/app/scss/main.scss b/app/scss/main.scss index 403732fc..ff7521e2 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -7,8 +7,8 @@ @import "lib/theme/vars"; -@import "../component/login/login"; -@import "../component/signup/signup"; +@import "../component/landing/login/login"; +@import "../component/landing/signup/signup"; $brand-primary: #444; $brand-secondary: #888; diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js new file mode 100644 index 00000000..01daf0b4 --- /dev/null +++ b/app/service/gallery-service.js @@ -0,0 +1,81 @@ +'use strict'; +// listen to brain talk about this file, end of vid 2 +module.exports = ['$q', '$log', '$http', 'authService', galleryService]; + +function galleryService($q, $log, $http, authService) { + $log.debug('galleryService'); + + let service = {}; + service.galleries = []; + + service.createGallery = function(gallery) { + $log.debug('galleryService.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); + return $q.reject(err); + }); + }; + + // service.deleteGalleries = function(galleryID) { + // $log.debug('galleryService.deleteGalleries'); + // + // return authService.getToken() + // .then( token => { + // let url = `${__API_URL__}/api/gallery/${galleryID}`; + // let config = { + // headers: { + // Accept: 'application/json', + // Authorization: `Bearer ${token}` + // } + // }; + // // TODO: Create $http.delete request + // }); + // }; + + service.fetchGalleries = function() { + $log.debug('galleryService.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; +} diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js index dd9d54bf..ab341240 100644 --- a/app/view/home/home-controller.js +++ b/app/view/home/home-controller.js @@ -2,8 +2,22 @@ require('./_home.scss'); -module.exports = ['$log', HomeController]; +module.exports = ['$log', '$rootScope', 'galleryService', HomeController]; -function HomeController($log) { +function HomeController($log, $rootScope, galleryService) { $log.debug('HomeController'); + + 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 12d2ecfc..9c023fb5 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -1,3 +1,11 @@
-

Welcome Home!

+ + +
    +
  • + name: {{ gallery.name }} + description: {{ gallery.desc }} + id: {{ gallery._id }} +
  • +
diff --git a/assets/cf-logo.png b/assets/cf-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..38a23b2d1d0dc6944768b2f98fae55197b0155b7 GIT binary patch literal 6821 zcmdT}c{r5c+aF9COBpFtb|G1Y?2Iv%LSnK+_H0R(!C1yJ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(Vrj)ruAzMR{a!AFFjyJ9 zX^#v;<70Cj3`WPCm8be08`oxzSp^~$BTCGoct>?s*G-l&9FRpYR`fyuQaDKK2u@Lo z0Ao(Xx7P59Cy%1Fy5JP^gI!bW)A1Vloq?!jsqj7nfHMb^U<{J_8O`aSdL zV3UJ`Ot$yuZA#PyFeq_;(xJ%YeF^-{&Aq36^_-oOO9iBx@ked+yr{I)cA*n)}>JQ*TEqm#KeffD%7S`ijx5}#if|Bjs*x%AcsEmeYbky zRS|baaDzhKCX3|BNVrynydE+#*Qib6uz237En@W=91z0+s?F*UG|i}Cx?_9IGOe(% zP^qtVAy5J+7_B9~HK1F#Lgm@&E%n@$@7lEU504>%kvaRtKFd|{bD?` zOUfHHL#fp=7uNj1;fzy=TPrV(S5MGmBTCZn1hi8{#iX8ZMNefPSF=1xB>}~q% zPQo6ajJ^uji6u3Z9Y+H@IEtj8@lc#<`5DOFSK9YF;8HHxy4mkXC!lS|Wb}g|JKjAQ zug`>5#)V#QA|Jj!m3HUFuhe;AX7uV;X=vS!E+z56+;{f}{}2)12IkVIUai-Aw1V)UfqmL^BSm^`gZ*w@jt?jQV6pnEEiB zqW;@|;L_4Bb9Som7HTnx2Ed>9F9zYRI}|kMRqli9UdEH0E&<655ce<3!IY71=IOu# zmO1&>LCqqS;b$l4X%+s$3nxi0i@Ml%AC~i%Z*uIO<4^N5oyb=<2RW2_)}8Ha`(1;a z-r#ULd2z1qxUX+Z-^RuU$m#v$Zic@i&@oZMlltU4W~{?BJiJtEW(q6#>ES~6H~5SU tDE(?whoeo-4M8ydROtV>6aWv8`?gQapd|}F{5cFVykeqPrgJ;yzW_S-o{9hf literal 0 HcmV?d00001 diff --git a/webpack.config.js b/webpack.config.js index 5125b9f7..c97f75a3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,14 @@ 'use strict'; -require('dotenv').load(); - +const dotenv = require('dotenv'); const webpack = require('webpack'); const HTMLPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const production = process.env.NODE_ENV === 'production'; + +dotenv.load(); + module.exports = { devtool: 'eval', entry: `${__dirname}/app/entry.js`, @@ -19,7 +22,8 @@ module.exports = { }), new ExtractTextPlugin('bundle.css'), new webpack.DefinePlugin({ - __API_URL__: JSON.stringify(process.env.API_URL) + __API_URL__: JSON.stringify(process.env.API_URL), + __DEGUB__: JSON.stringify(!production) }) ], module: { From 0a4e2d515d9f52675fa6ca864b7139466006d00e Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Wed, 29 Mar 2017 19:48:24 -0700 Subject: [PATCH 04/14] styling gallery and nav --- .../create-gallery/_create-gallery.scss | 12 +++++ .../create-gallery/create-gallery.html | 13 +++--- .../gallery/create-gallery/create-gallery.js | 3 +- app/component/navbar/navbar.html | 4 +- app/component/navbar/navbar.js | 12 ++--- app/scss/lib/base/_base.scss | 8 ++-- app/scss/lib/layout/_header.scss | 45 ++++++++++++++++--- app/view/home/_home.scss | 31 +++++++++++++ app/view/home/home-controller.js | 2 +- app/view/home/home.html | 1 - 10 files changed, 106 insertions(+), 25 deletions(-) diff --git a/app/component/gallery/create-gallery/_create-gallery.scss b/app/component/gallery/create-gallery/_create-gallery.scss index e69de29b..71f0e5d5 100644 --- a/app/component/gallery/create-gallery/_create-gallery.scss +++ b/app/component/gallery/create-gallery/_create-gallery.scss @@ -0,0 +1,12 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +.evilbutton{ + margin-top: $gutter / 2; + margin-bottom: $gutter / 2; +} diff --git a/app/component/gallery/create-gallery/create-gallery.html b/app/component/gallery/create-gallery/create-gallery.html index 691988d3..1c749567 100644 --- a/app/component/gallery/create-gallery/create-gallery.html +++ b/app/component/gallery/create-gallery/create-gallery.html @@ -2,23 +2,24 @@ diff --git a/app/component/gallery/create-gallery/create-gallery.js b/app/component/gallery/create-gallery/create-gallery.js index a6da00a7..52b3743e 100644 --- a/app/component/gallery/create-gallery/create-gallery.js +++ b/app/component/gallery/create-gallery/create-gallery.js @@ -1,5 +1,7 @@ 'use strict'; +require('./_create-gallery.scss') + module.exports = { template: require('./create-gallery.html'), controller: ['$log', 'galleryService', CreateGalleryController], @@ -8,7 +10,6 @@ module.exports = { function CreateGalleryController($log, galleryService) { $log.debug('CreateGalleryController'); - this.gallery = {}; this.createGallery = function() { diff --git a/app/component/navbar/navbar.html b/app/component/navbar/navbar.html index 28fecf38..314166cc 100644 --- a/app/component/navbar/navbar.html +++ b/app/component/navbar/navbar.html @@ -1,9 +1,9 @@ diff --git a/app/component/navbar/navbar.js b/app/component/navbar/navbar.js index 79c48ef3..4444ddee 100644 --- a/app/component/navbar/navbar.js +++ b/app/component/navbar/navbar.js @@ -4,12 +4,12 @@ require('./_navbar.scss'); module.exports = { template: require('./navbar.html'), - conroller: ['$log', '$location', '$rootScope', 'authService', NavbarConroller], - conrollerAs: 'navbarCtrl' + controller: ['$log', '$location', '$rootScope', 'authService', NavbarController], + controllerAs: 'navbarCtrl' }; -function NavbarConroller($log, $location, $rootScope, authService) { - $log.debug('NavbarConroller'); +function NavbarController($log, $location, $rootScope, authService) { + $log.debug('NavbarController'); this.checkPath = function() { let path = $location.path(); @@ -28,11 +28,11 @@ function NavbarConroller($log, $location, $rootScope, authService) { this.checkPath(); - $rootScope.$on('locationChangeSuccess', () => { + $rootScope.$on('$locationChangeSuccess', () => { this.checkPath(); }); - this.logout = function() { + this.logout = function() { $log.debug('navbarCtrl.logout'); this.hideButtons = true; authService.logout() diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss index 8923409b..8e423294 100644 --- a/app/scss/lib/base/_base.scss +++ b/app/scss/lib/base/_base.scss @@ -49,13 +49,15 @@ button{ input{ width:90%; - margin-left: $gutterP / 2; + margin-left: $gutterP / 2 ; margin-right: $gutterP / 2; margin-top: $gutter; height: 30px; - border-radius: 3px; + border-radius: 5px; transition: 350ms; - padding: 10px; + // padding: 10px; + // padding is causing page to grow wide + // margin is also slightly too big, slight growth wide } input:focus { diff --git a/app/scss/lib/layout/_header.scss b/app/scss/lib/layout/_header.scss index 2df1e28c..efc02148 100644 --- a/app/scss/lib/layout/_header.scss +++ b/app/scss/lib/layout/_header.scss @@ -1,8 +1,43 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + header{ - height: 100px; - line-height: 100px; - font-size: 175%; - p{ - margin-left: $gutter; + + .navbar{ + height: 100px; + background: $brand-primary; + width: 100%; + h2{ + height: 100px; + line-height: 100px; + display: inline-block; + margin-top: 0; + float: left; + } + nav{ + display:inline-block; + width: 100px; + line-height: 100px; + height:100px; + float: right; + margin-right: $gutterP / 2; + div{ + // line-height: 100px; + // button{ + // margin-top: 30px; + height:100px; + width: 100%; + input{ + width: 100%; + background: $grey; + color: $brand-primary; + } + } + } } } diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss index e69de29b..9f72202d 100644 --- a/app/view/home/_home.scss +++ b/app/view/home/_home.scss @@ -0,0 +1,31 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +.home{ + ul{ + clear: both; + li{ + padding-top: 10px; + padding-bottom: 10px; + background: $brand-secondary; + width: 90%; + margin: $gutterP /2; + border-radius: 5px; + // color: + span{ + display: block; + margin-bottom: $gutter; + margin-left: $gutter; + margin-right: $gutter; + } + span:last-child { + margin-bottom: 0; + } + } + } +} diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js index ab341240..a8cb6e64 100644 --- a/app/view/home/home-controller.js +++ b/app/view/home/home-controller.js @@ -17,7 +17,7 @@ function HomeController($log, $rootScope, galleryService) { this.fetchGalleries(); - $rootScope.$on('locationChangeSuccess', () => { + $rootScope.$on('$locationChangeSuccess', () => { this.fetchGalleries(); }); } diff --git a/app/view/home/home.html b/app/view/home/home.html index 9c023fb5..7ff4dc9d 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -5,7 +5,6 @@
  • name: {{ gallery.name }} description: {{ gallery.desc }} - id: {{ gallery._id }}
  • From 710da763f17c1a0d50927c4bae5ab52818d3f4ce Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Thu, 30 Mar 2017 14:21:56 -0700 Subject: [PATCH 05/14] added delete and update gallery features --- .../gallery/edit-gallery/_edit-gallery.scss | 0 .../gallery/edit-gallery/edit-gallery.html | 26 ++++++++ .../gallery/edit-gallery/edit-gallery.js | 23 +++++++ .../gallery/gallery-item/_gallery-item.scss | 0 .../gallery/gallery-item/gallery-item.html | 24 +++++++ .../gallery/gallery-item/gallery-item.js | 24 +++++++ app/service/gallery-service.js | 62 +++++++++++++++++++ app/view/home/home.html | 9 +-- 8 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 app/component/gallery/edit-gallery/_edit-gallery.scss create mode 100644 app/component/gallery/edit-gallery/edit-gallery.html create mode 100644 app/component/gallery/edit-gallery/edit-gallery.js create mode 100644 app/component/gallery/gallery-item/_gallery-item.scss create mode 100644 app/component/gallery/gallery-item/gallery-item.html create mode 100644 app/component/gallery/gallery-item/gallery-item.js diff --git a/app/component/gallery/edit-gallery/_edit-gallery.scss b/app/component/gallery/edit-gallery/_edit-gallery.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/edit-gallery/edit-gallery.html b/app/component/gallery/edit-gallery/edit-gallery.html new file mode 100644 index 00000000..082efe20 --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.html @@ -0,0 +1,26 @@ +
    + +
    diff --git a/app/component/gallery/edit-gallery/edit-gallery.js b/app/component/gallery/edit-gallery/edit-gallery.js new file mode 100644 index 00000000..586c30cb --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./_edit-gallery.scss'); + +module.exports = { + template: require('./edit-gallery.html'), + controller: ['$log', 'galleryService', EditGalleryController], + controllerAs: 'editGalleryCtrl', + bindings: { + gallery: '<' + } +}; + +function EditGalleryController($log, galleryService) { + $log.debug('EditGalleryController'); + + this.updateGallery = function() { + $log.debug('editGalleryCtrl.updateGallery'); + galleryService.updateGallery(this.gallery._id, this.gallery); + console.log(this.gallery.id); + console.log(this.gallery); + }; +} diff --git a/app/component/gallery/gallery-item/_gallery-item.scss b/app/component/gallery/gallery-item/_gallery-item.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html new file mode 100644 index 00000000..7444a4de --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -0,0 +1,24 @@ + + diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js new file mode 100644 index 00000000..c6dfd03b --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -0,0 +1,24 @@ +'use strict'; + +require('./_gallery-item.scss'); + +module.exports = { + template: require('./gallery-item.html'), + controller: ['$log', 'galleryService', GalleryItemController], + controllerAs: 'galleryItemCtrl', + bindings: { + gallery: '<' + // log this shit + } +}; + +function GalleryItemController($log, galleryService) { + $log.debug('GalleryItemController'); + + this.showEditGallery= false; + + this.deleteGallery = function() { + galleryService.deleteGallery(this.gallery._id); + + }; +} diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js index 01daf0b4..ea0534f3 100644 --- a/app/service/gallery-service.js +++ b/app/service/gallery-service.js @@ -77,5 +77,67 @@ function galleryService($q, $log, $http, authService) { return $q.reject(err); }); }; + + service.updateGallery = function(galleryID, galleryData) { + $log.debug('galleryService.updateGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json' + } + }; + return $http.put(url, galleryData, config); + }) + .then( res => { + for (let i=0; i < service.galleries.length; i++) { + let current = service.galleries[i]; + if (current._id === galleryID) { + service.galleries[i] = res.data; + break; + } + } + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deleteGallery = function(galleryID) { + $log.debug('galleryService.deleteGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Authorization: `Bearer ${token}`, + } + }; + return $http.delete(url, config); + }) + .then( res => { + for (let i=0; i < service.galleries.length; i++) { + let current = service.galleries[i]; + if (current._id === galleryID) { + service.galleries.splice(i, 1); + break; + } + } + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + return service; } diff --git a/app/view/home/home.html b/app/view/home/home.html index 7ff4dc9d..b35ae79d 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -2,9 +2,10 @@
      -
    • - name: {{ gallery.name }} - description: {{ gallery.desc }} -
    • + + + +
    From ef10240ba6bc167ff6cb8e82671cf9f89e261ba7 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Thu, 30 Mar 2017 19:08:21 -0700 Subject: [PATCH 06/14] styling and start hide edit button --- .../gallery/edit-gallery/_edit-gallery.scss | 37 +++++++++++++++++++ .../gallery/edit-gallery/edit-gallery.html | 7 +--- .../gallery/gallery-item/_gallery-item.scss | 35 ++++++++++++++++++ .../gallery/gallery-item/gallery-item.html | 13 +++++-- .../gallery/gallery-item/gallery-item.js | 3 +- app/view/home/_home.scss | 12 ++++-- 6 files changed, 94 insertions(+), 13 deletions(-) diff --git a/app/component/gallery/edit-gallery/_edit-gallery.scss b/app/component/gallery/edit-gallery/_edit-gallery.scss index e69de29b..4f10285c 100644 --- a/app/component/gallery/edit-gallery/_edit-gallery.scss +++ b/app/component/gallery/edit-gallery/_edit-gallery.scss @@ -0,0 +1,37 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +.edit-gallery { + background:$brand-secondary; + padding-top: $gutter / 2; + padding-bottom: $gutter / 2; + border-radius: 5px; + fieldset { + margin-bottom: $gutter / 2; + } + .fieldset-last-child-fix { + margin-bottom: 0; } + span{ + display: inline-block; + } + input{ + display: inline-block; + margin-top: 0; + width: 70%; + float: right; + } +} + +.update-btn{ + height: 30px; + width: 25%; + border-radius: 5px; + outline: 0; + border-style: none; + margin-top: $gutter * 1.5; +} diff --git a/app/component/gallery/edit-gallery/edit-gallery.html b/app/component/gallery/edit-gallery/edit-gallery.html index 082efe20..b774f51e 100644 --- a/app/component/gallery/edit-gallery/edit-gallery.html +++ b/app/component/gallery/edit-gallery/edit-gallery.html @@ -9,10 +9,8 @@ class="input-std" type="text" ng-model="editGalleryCtrl.gallery.name"> - - -
    +
    description:
    - - + diff --git a/app/component/gallery/gallery-item/_gallery-item.scss b/app/component/gallery/gallery-item/_gallery-item.scss index e69de29b..f5ffdd62 100644 --- a/app/component/gallery/gallery-item/_gallery-item.scss +++ b/app/component/gallery/gallery-item/_gallery-item.scss @@ -0,0 +1,35 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; + +.gallery-item { + .current-item { + background-color: $brand-secondary; + padding-top: $gutter / 2; + padding-bottom: $gutter / 2; + border-radius: 5px; + div{ + margin-bottom: $gutter / 2; + height: 35px; + } + div:last-child { + margin-bottom: 0; + + } + } + + .gallery-button{ + border-radius: 5px; + height: 30px; + text-align: center; + line-height: 30px; + margin-top: $gutter; + margin-left: 0; + } + .gallery-button:last-child{ + background: $brand-secondary; + } +} diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html index 7444a4de..466f65b1 100644 --- a/app/component/gallery/gallery-item/gallery-item.html +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -16,9 +16,16 @@ gallery="galleryItemCtrl.gallery"> - + edit - - delete + + delete + diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js index c6dfd03b..3982fcc3 100644 --- a/app/component/gallery/gallery-item/gallery-item.js +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -15,7 +15,8 @@ module.exports = { function GalleryItemController($log, galleryService) { $log.debug('GalleryItemController'); - this.showEditGallery= false; + this.showEditGallery = false; + this.hideEditButtons = false; this.deleteGallery = function() { galleryService.deleteGallery(this.gallery._id); diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss index 9f72202d..f57a2d01 100644 --- a/app/view/home/_home.scss +++ b/app/view/home/_home.scss @@ -10,21 +10,25 @@ $gutterP: 10%; ul{ clear: both; li{ + // can move everything from li down into gallery-item .scss padding-top: 10px; padding-bottom: 10px; - background: $brand-secondary; + // background: $brand-secondary; width: 90%; margin: $gutterP /2; border-radius: 5px; // color: span{ - display: block; - margin-bottom: $gutter; + // display: block; + // margin-bottom: $gutter; + // margin-right: $gutter; margin-left: $gutter; - margin-right: $gutter; + font-weight: bold; } span:last-child { margin-bottom: 0; + margin-left: 0; + font-weight: normal; } } } From bcf11d746ecd20b769233be9d02835daee7a883c Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Thu, 30 Mar 2017 19:11:04 -0700 Subject: [PATCH 07/14] cleaning comments --- app/component/gallery/gallery-item/gallery-item.js | 1 - app/view/home/_home.scss | 5 ----- 2 files changed, 6 deletions(-) diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js index 3982fcc3..21cefa42 100644 --- a/app/component/gallery/gallery-item/gallery-item.js +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -8,7 +8,6 @@ module.exports = { controllerAs: 'galleryItemCtrl', bindings: { gallery: '<' - // log this shit } }; diff --git a/app/view/home/_home.scss b/app/view/home/_home.scss index f57a2d01..71e70c22 100644 --- a/app/view/home/_home.scss +++ b/app/view/home/_home.scss @@ -13,15 +13,10 @@ $gutterP: 10%; // can move everything from li down into gallery-item .scss padding-top: 10px; padding-bottom: 10px; - // background: $brand-secondary; width: 90%; margin: $gutterP /2; border-radius: 5px; - // color: span{ - // display: block; - // margin-bottom: $gutter; - // margin-right: $gutter; margin-left: $gutter; font-weight: bold; } From 2f99b765603d3919a6d2c19b2c5bb52c97d8d61a Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Mon, 3 Apr 2017 17:53:42 -0800 Subject: [PATCH 08/14] added image upload and delete --- .../gallery/create-gallery/create-gallery.js | 2 +- .../gallery/gallery-item/_gallery-item.scss | 1 + .../gallery/gallery-item/gallery-item.js | 1 + .../_thumbnail-container.scss | 0 .../thumbnail-container.html | 11 +++ .../thumbnail-container.js | 11 +++ .../gallery/thumbnail/_thumbnail.scss | 0 .../gallery/thumbnail/thumbnail.html | 5 ++ app/component/gallery/thumbnail/thumbnail.js | 22 +++++ .../gallery/upload-pic/_upload-pic.scss | 0 .../gallery/upload-pic/upload-pic.html | 22 +++++ .../gallery/upload-pic/upload-pic.js | 27 ++++++ app/entry.js | 3 +- app/service/pic-service.js | 82 +++++++++++++++++++ app/view/home/home-controller.js | 8 ++ app/view/home/home.html | 8 +- package.json | 1 + 17 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 app/component/gallery/thumbnail-container/_thumbnail-container.scss create mode 100644 app/component/gallery/thumbnail-container/thumbnail-container.html create mode 100644 app/component/gallery/thumbnail-container/thumbnail-container.js create mode 100644 app/component/gallery/thumbnail/_thumbnail.scss create mode 100644 app/component/gallery/thumbnail/thumbnail.html create mode 100644 app/component/gallery/thumbnail/thumbnail.js create mode 100644 app/component/gallery/upload-pic/_upload-pic.scss create mode 100644 app/component/gallery/upload-pic/upload-pic.html create mode 100644 app/component/gallery/upload-pic/upload-pic.js create mode 100644 app/service/pic-service.js diff --git a/app/component/gallery/create-gallery/create-gallery.js b/app/component/gallery/create-gallery/create-gallery.js index 52b3743e..8f16bb41 100644 --- a/app/component/gallery/create-gallery/create-gallery.js +++ b/app/component/gallery/create-gallery/create-gallery.js @@ -1,6 +1,6 @@ 'use strict'; -require('./_create-gallery.scss') +require('./_create-gallery.scss'); module.exports = { template: require('./create-gallery.html'), diff --git a/app/component/gallery/gallery-item/_gallery-item.scss b/app/component/gallery/gallery-item/_gallery-item.scss index f5ffdd62..18f4642e 100644 --- a/app/component/gallery/gallery-item/_gallery-item.scss +++ b/app/component/gallery/gallery-item/_gallery-item.scss @@ -11,6 +11,7 @@ $gutter: 30px; padding-top: $gutter / 2; padding-bottom: $gutter / 2; border-radius: 5px; + margin-top: $gutter; div{ margin-bottom: $gutter / 2; height: 35px; diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js index 21cefa42..9a18baba 100644 --- a/app/component/gallery/gallery-item/gallery-item.js +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -18,6 +18,7 @@ function GalleryItemController($log, galleryService) { this.hideEditButtons = false; this.deleteGallery = function() { + $log.debug('galleryItemCtrl.deleteGallery'); galleryService.deleteGallery(this.gallery._id); }; diff --git a/app/component/gallery/thumbnail-container/_thumbnail-container.scss b/app/component/gallery/thumbnail-container/_thumbnail-container.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/thumbnail-container/thumbnail-container.html b/app/component/gallery/thumbnail-container/thumbnail-container.html new file mode 100644 index 00000000..975b28be --- /dev/null +++ b/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -0,0 +1,11 @@ +
    +

    {{ thumbnailContainerCtrl.gallery.name }}

    + + +
    + + +
    +
    diff --git a/app/component/gallery/thumbnail-container/thumbnail-container.js b/app/component/gallery/thumbnail-container/thumbnail-container.js new file mode 100644 index 00000000..18bf16d4 --- /dev/null +++ b/app/component/gallery/thumbnail-container/thumbnail-container.js @@ -0,0 +1,11 @@ +'use strict'; + +require('./_thumbnail-container.scss'); + +module.exports = { + template: require('./thumbnail-container.html'), + controllerAs: 'thumbnailContainerCtrl', + bindings: { + gallery: '<' + } +}; diff --git a/app/component/gallery/thumbnail/_thumbnail.scss b/app/component/gallery/thumbnail/_thumbnail.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/thumbnail/thumbnail.html b/app/component/gallery/thumbnail/thumbnail.html new file mode 100644 index 00000000..cfdbfb72 --- /dev/null +++ b/app/component/gallery/thumbnail/thumbnail.html @@ -0,0 +1,5 @@ +
    + {{ thumbnailCtrl.pic.desc }} + delete + +
    diff --git a/app/component/gallery/thumbnail/thumbnail.js b/app/component/gallery/thumbnail/thumbnail.js new file mode 100644 index 00000000..b55cbcd9 --- /dev/null +++ b/app/component/gallery/thumbnail/thumbnail.js @@ -0,0 +1,22 @@ +'use strict'; + +require('./_thumbnail.scss'); + +module.exports = { + template: require('./thumbnail.html'), + controller: [ '$log', 'picService', ThumbnailController], + controllerAs: 'thumbnailCtrl', + bindings: { + pic: '<', + gallery: '<' + } +}; + +function ThumbnailController($log, picService) { + $log.debug('ThumbnailController'); + + this.deletePic = function() { + $log.debug('thumbnailCtrl.deletePic'); + picService.deletePic(this.gallery, this.pic); + }; +} diff --git a/app/component/gallery/upload-pic/_upload-pic.scss b/app/component/gallery/upload-pic/_upload-pic.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/gallery/upload-pic/upload-pic.html b/app/component/gallery/upload-pic/upload-pic.html new file mode 100644 index 00000000..76051a8c --- /dev/null +++ b/app/component/gallery/upload-pic/upload-pic.html @@ -0,0 +1,22 @@ +
    +
    + +

    upload a new pic

    + +
    + + +
    + +
    +

    + select a pic to upload +

    + + +
    +
    +
    diff --git a/app/component/gallery/upload-pic/upload-pic.js b/app/component/gallery/upload-pic/upload-pic.js new file mode 100644 index 00000000..2dd3e912 --- /dev/null +++ b/app/component/gallery/upload-pic/upload-pic.js @@ -0,0 +1,27 @@ +'use strict'; + +require('./_upload-pic.scss'); + +module.exports = { + template: require('./upload-pic.html'), + controller: [ '$log', 'picService', UploadPicController], + controllerAs: 'uploadPicCtrl', + bindings: { + gallery: '<' + } +}; + +function UploadPicController($log, picService) { + $log.debug('UploadPicController'); + + this.pic = {}; + + this.uploadPic = function() { + picService.uploadGalleryPic(this.gallery, this.pic) + .then( () => { + this.pic.name = null; + this.pic.desc = null; + this.pic.file = null; + }); + }; +} diff --git a/app/entry.js b/app/entry.js index b380be14..1633cef2 100644 --- a/app/entry.js +++ b/app/entry.js @@ -9,8 +9,9 @@ const pascalcase = require('pascalcase'); const uiRouter = require('angular-ui-router'); const ngTouch = require('angular-touch'); const ngAnimate = require('angular-animate'); +const ngFileUpload = require('ng-file-upload'); -const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter]); +const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter, ngFileUpload]); // try logging "context" check out "keys" // log the shit out of this diff --git a/app/service/pic-service.js b/app/service/pic-service.js new file mode 100644 index 00000000..670a80aa --- /dev/null +++ b/app/service/pic-service.js @@ -0,0 +1,82 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'Upload', 'authService', picSercive]; + +function picSercive($q, $log, $http, Upload, authService) { + $log.debug('picSercive'); + + let service = {}; + + service.uploadGalleryPic = function(galleryData, picData) { + $log.debug('service.uploadGalleryPic'); + // log galleryData + // console.log('galleryData'); + // mongo object? + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic`; + let headers = { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + }; + return Upload.upload({ + url, + headers, + method: 'POST', + data: { + name: picData.name, + desc: picData.desc, + file: picData.file + } + }); + }) + .then( res => { + $log.log('pic uploaded'); + // let pic = res.data + // galleryData.pics.unshift(pic); + galleryData.pics.unshift(res.data); + console.log(res.data); + console.log(galleryData); + console.log(picData); + return res.data; + // return pic + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deletePic = function(galleryData, picData) { + $log.debug('service.deltePic'); + console.log(galleryData); + console.log(picData); + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic/${picData._id}`; + let config = { + headers: { + Authorization: `Bearer ${token}` + } + }; + return $http.delete(url, config); + }) + .then( res => { + for (let i=0; i < galleryData.pics.length; i++) { + let current = galleryData.pics[i]; + if (current._id === picData._id) { + galleryData.pics.splice(i, 1); + break; + } + } + return 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 a8cb6e64..e51b99a1 100644 --- a/app/view/home/home-controller.js +++ b/app/view/home/home-controller.js @@ -8,13 +8,21 @@ function HomeController($log, $rootScope, galleryService) { $log.debug('HomeController'); this.galleries = []; + this.fetchGalleries = function() { galleryService.fetchGalleries() .then( galleries => { this.galleries = galleries; + this.currentGallery = galleries[0]; }); }; + this.galleryDeleteDone = function(gallery) { + if (this.currentGallery._id === gallery._id) { + this.currentGallery = null; + } + }; + this.fetchGalleries(); $rootScope.$on('$locationChangeSuccess', () => { diff --git a/app/view/home/home.html b/app/view/home/home.html index b35ae79d..3f3f03f7 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -3,9 +3,13 @@
      + gallery="item" + delete-done="homeCtrl.galleryDeleteDone(galleryData)" + ng-click="homeCtrl.currentGallery = item"> -
    + + diff --git a/package.json b/package.json index c458ace6..ad58a868 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "file-loader": "^0.10.1", "html-loader": "^0.4.5", "html-webpack-plugin": "^2.28.0", + "ng-file-upload": "^12.2.13", "node-sass": "^4.5.1", "pascalcase": "^0.1.1", "resolve-url-loader": "^2.0.2", From 53dd0060768831413550ec3a410b32056d2871bb Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Mon, 3 Apr 2017 19:38:19 -0800 Subject: [PATCH 09/14] stlying --- .../_thumbnail-container.scss | 21 +++++++++++ .../gallery/thumbnail/_thumbnail.scss | 26 ++++++++++++++ .../gallery/thumbnail/thumbnail.html | 4 ++- .../gallery/upload-pic/_upload-pic.scss | 35 +++++++++++++++++++ .../gallery/upload-pic/upload-pic.html | 10 +++--- app/scss/lib/base/_base.scss | 2 ++ 6 files changed, 92 insertions(+), 6 deletions(-) diff --git a/app/component/gallery/thumbnail-container/_thumbnail-container.scss b/app/component/gallery/thumbnail-container/_thumbnail-container.scss index e69de29b..1a0c43b1 100644 --- a/app/component/gallery/thumbnail-container/_thumbnail-container.scss +++ b/app/component/gallery/thumbnail-container/_thumbnail-container.scss @@ -0,0 +1,21 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +.thumbnail-container { + width:90%; + background-color: $grey; + padding-top: $gutter / 2; + padding-bottom: $gutter / 2; + border-radius: 5px; + margin-top: $gutter; + margin-left: $gutterP / 2; + margin-right: $gutterP / 2; + h3{ + font-size: 125%; + } +} diff --git a/app/component/gallery/thumbnail/_thumbnail.scss b/app/component/gallery/thumbnail/_thumbnail.scss index e69de29b..6b122df0 100644 --- a/app/component/gallery/thumbnail/_thumbnail.scss +++ b/app/component/gallery/thumbnail/_thumbnail.scss @@ -0,0 +1,26 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + + +.thumbnail{ + div{ + } + img{ + // width: 100%; + // margin-left: $gutterP / 2; + // margin-right: $gutterP / 2; + clear: both; + float: right; + text-align: center; + } + span{ + clear: both; + float: right; + line-height: 40px; + } +} diff --git a/app/component/gallery/thumbnail/thumbnail.html b/app/component/gallery/thumbnail/thumbnail.html index cfdbfb72..a991a3d0 100644 --- a/app/component/gallery/thumbnail/thumbnail.html +++ b/app/component/gallery/thumbnail/thumbnail.html @@ -1,5 +1,7 @@
    - {{ thumbnailCtrl.pic.desc }} +
    + {{ thumbnailCtrl.pic.desc }} +
    delete
    diff --git a/app/component/gallery/upload-pic/_upload-pic.scss b/app/component/gallery/upload-pic/_upload-pic.scss index e69de29b..d5c70a14 100644 --- a/app/component/gallery/upload-pic/_upload-pic.scss +++ b/app/component/gallery/upload-pic/_upload-pic.scss @@ -0,0 +1,35 @@ +$brand-primary: #444; +$brand-secondary: #888; +$black: #000; +$white: #fff; +$grey: #ccc; +$gutter: 30px; +$gutterP: 10%; + +.upload-pic{ + .grab-img{ + display: inline-block; + height: 40px; + line-height: 40px; + float: right; + margin-right: $gutter; + text-decoration: underline; + } + h3{ + text-decoration: underline; + } + input{ + width: 100%; + margin-left: 0; + margin-right: 0; + background-color: $brand-secondary; + color: $white; + padding-left: 10px; + padding-right: -10px; + } + button{ + display: inline-block; + // clear: both; + float:right; + } +} diff --git a/app/component/gallery/upload-pic/upload-pic.html b/app/component/gallery/upload-pic/upload-pic.html index 76051a8c..24ae1eaf 100644 --- a/app/component/gallery/upload-pic/upload-pic.html +++ b/app/component/gallery/upload-pic/upload-pic.html @@ -10,13 +10,13 @@

    upload a new pic

    -

    - select a pic to upload -

    +

    + select a pic to upload +

    diff --git a/app/scss/lib/base/_base.scss b/app/scss/lib/base/_base.scss index 8e423294..d0432560 100644 --- a/app/scss/lib/base/_base.scss +++ b/app/scss/lib/base/_base.scss @@ -38,6 +38,8 @@ button{ padding: 0; height: 40px; outline: 0; + border-radius: 5px; + text-align: center; } .btn-std:focus{ outline: 0; From 72d9db9ee845a27390f9a8246f361084873d1e89 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Tue, 4 Apr 2017 09:35:37 -0800 Subject: [PATCH 10/14] fix hide edit buttons --- app/component/gallery/gallery-item/gallery-item.html | 5 +++-- karma.conf.js | 0 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 karma.conf.js diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html index 466f65b1..f552abfa 100644 --- a/app/component/gallery/gallery-item/gallery-item.html +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -17,14 +17,15 @@ edit delete diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..e69de29b From 746ba8b139e4589d31434b22bcbf6f1e21bf6243 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Tue, 4 Apr 2017 19:56:54 -0800 Subject: [PATCH 11/14] testing auth and gallery service --- app/config/router-config.js | 2 +- gallery-service-test.js | 0 karma.conf.js | 29 ++++++++++ package.json | 11 +++- pic-service-test.js | 0 test/auth-service-test.js | 29 ++++++++++ test/gallery-service-test.js | 101 +++++++++++++++++++++++++++++++++++ test/pic-service-test.js | 0 test/sample-test.js | 1 + 9 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 gallery-service-test.js create mode 100644 pic-service-test.js create mode 100644 test/auth-service-test.js create mode 100644 test/gallery-service-test.js create mode 100644 test/pic-service-test.js create mode 100644 test/sample-test.js diff --git a/app/config/router-config.js b/app/config/router-config.js index 31d817b6..454854df 100644 --- a/app/config/router-config.js +++ b/app/config/router-config.js @@ -24,7 +24,7 @@ function routerConfig($stateProvider, $urlRouterProvider) { controllerAs: 'landingCtrl' } ]; - + states.forEach( state => { $stateProvider.state(state); }); diff --git a/gallery-service-test.js b/gallery-service-test.js new file mode 100644 index 00000000..e69de29b diff --git a/karma.conf.js b/karma.conf.js index e69de29b..917dc042 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -0,0 +1,29 @@ +const webpack = require('./webpack.config.js'); +delete webpack.entry; + +module.exports = function(config) { + config.set({ + webpack, + basePath: '', + frameworks: ['jasmine'], + files: [ + 'app/entry.js', + 'test/**/*-test.js', + 'node_modules/angular-mocks/angular-mocks.js' + ], + exclude: [ + ], + preprocessors: { + 'test/**/*-test.js': ['webpack'], + 'app/entry.js': ['webpack'] + }, + reporters: ['mocha'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + concurrency: Infinity + }); +}; diff --git a/package.json b/package.json index ad58a868..ad4d3553 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "index.js", "scripts": { "build": "./node_modules/webpack/bin/webpack.js", - "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot" + "build-watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", + "test": "./node_modules/karma/bin/karma --single-run", + "test-watch": "./node_modules/karma/bin/karma start" }, "repository": { "type": "git", @@ -46,6 +48,13 @@ "webpack": "^2.3.2" }, "devDependencies": { + "angular-mocks": "^1.6.4", + "jasmine-core": "^2.5.2", + "karma": "^1.5.0", + "karma-chrome-launcher": "^2.0.0", + "karma-jasmine": "^1.1.0", + "karma-mocha-reporter": "^2.2.3", + "karma-webpack": "^2.0.3", "webpack-dev-server": "^2.4.2" } } diff --git a/pic-service-test.js b/pic-service-test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/auth-service-test.js b/test/auth-service-test.js new file mode 100644 index 00000000..69253923 --- /dev/null +++ b/test/auth-service-test.js @@ -0,0 +1,29 @@ +'use strict'; + +describe('Auth Service', function() { + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, $window, $httpBackend) => { + this.$window = $window; + this.$rootScope = $rootScope; + this.authService = authService; + this.$httpBackend = $httpBackend; + }); + }); + describe('authService.getToken', () => { + it('should return a token', () => { + this.authService.tojen = null; + this.$window.localStorage.setItem('token', 'test token'); + + this.authService.getToken() + .then( token => { + expect(token).toEqual('test token'); + }) + .catch( err => { + expect(err).toEqual(null); + }); + + this.$rootScope.$apply(); + }); + }); +}); diff --git a/test/gallery-service-test.js b/test/gallery-service-test.js new file mode 100644 index 00000000..2b46d526 --- /dev/null +++ b/test/gallery-service-test.js @@ -0,0 +1,101 @@ +'use strict'; + +describe('Gallery Service', function() { + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, galleryService, $window, $httpBackend) => { + this.$window = $window; + this.$rootScope = $rootScope; + this.authService = authService; + this.galleryService = galleryService; + this.$httpBackend = $httpBackend; + }); + }); + + describe('galleryService.createGallery', () => { + it('should create a new gallery', () => { + let galleryData = { + name: 'example gallery', + desc: 'example desc' + }; + + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPOST('https://slugram-backend.herokuapp.com/api/gallery', galleryData, headers) + .respond(200, { + _id: '1234', + username: 'testuser', + name: galleryData.name, + desc: galleryData.desc, + pics: [] + }); + + this.galleryService.createGallery(galleryData); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + + describe('galleryService.postGallery', () => { + it('should update a gallery', () => { + let galleryID = 'testid' + + let galleryData = { + name: 'example gallery', + desc: 'example desc' + }; + + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPUT(`${__API_URL__}/api/gallery/testid`, galleryData, headers) + .respond(200); + + this.galleryService.updateGallery(galleryID, galleryData); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + + describe('galleryService.deleteGallery', () => { + it('should delete a gallery', () => { + let galleryID = 'testid' + let headers = { + Authorization: 'Bearer test token', + Accept: 'application/json, text/plain, */*' + }; + + this.$httpBackend.expectDELETE(`${__API_URL__}/api/gallery/testid`, headers) + .respond(204); + + this.galleryService.deleteGallery(galleryID); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + + describe('galleryService.fetchGallery', () => { + it('should fetch galleries', () => { + let headers = { + Authorization: 'Bearer test token', + Accept: 'application/json' + }; + + this.$httpBackend.expectGET(`${__API_URL__}/api/gallery`, headers) + .respond(200); + + this.galleryService.fetchGalleries(); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + +}); diff --git a/test/pic-service-test.js b/test/pic-service-test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/sample-test.js b/test/sample-test.js new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/sample-test.js @@ -0,0 +1 @@ + From fc731d25a70d449ae73aa6ba16c28823b307c7ee Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Wed, 5 Apr 2017 19:04:33 -0800 Subject: [PATCH 12/14] testing components --- test/auth-service-test.js | 1 - test/edit-gallery-component-test.js | 62 +++++++++++++++++++++++++++++ test/gallery-item-component-test.js | 34 ++++++++++++++++ test/gallery-service-test.js | 3 +- 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 test/edit-gallery-component-test.js create mode 100644 test/gallery-item-component-test.js diff --git a/test/auth-service-test.js b/test/auth-service-test.js index 69253923..65297620 100644 --- a/test/auth-service-test.js +++ b/test/auth-service-test.js @@ -7,7 +7,6 @@ describe('Auth Service', function() { this.$window = $window; this.$rootScope = $rootScope; this.authService = authService; - this.$httpBackend = $httpBackend; }); }); describe('authService.getToken', () => { diff --git a/test/edit-gallery-component-test.js b/test/edit-gallery-component-test.js new file mode 100644 index 00000000..6c3f479f --- /dev/null +++ b/test/edit-gallery-component-test.js @@ -0,0 +1,62 @@ +'use strict'; + +describe('Edit Gallery Component', function() { + beforeEach( () => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, $componentController, $httpBackend, authService) => { + this.$rootScope = $rootScope; + this.$componentController = $componentController; + this.$httpBackend = $httpBackend; + this.$httpBackend = $httpBackend; + }); + }); + + it('should contain the propper component bindings', () => { + let mockBindings = { + gallery: { + name: 'test gallery name', + desc: 'test gallery description' + } + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + expect(editGalleryCtrl.gallery.name).toEqual(mockBindings.gallery.name); + expect(editGalleryCtrl.gallery.desc).toEqual(mockBindings.gallery.desc); + + this.$rootScope.$apply(); + }); + + describe('editGalleryCtrl.updateGallery', () => { + it('should make a valid put request', () => { + let url = `${__API_URL__}/api/gallery/testid`; + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPUT(url, { + _id: 'testid', + name: 'updated name', + desc: 'updated desc' + }, headers).respond(200); + + let mockBindings = { + gallery: { + _id: 'testid', + name: 'updated name', + desc: 'updated desc' + } + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + editGalleryCtrl.gallery.name = 'updated name'; + editGalleryCtrl.gallery.desc = 'updated desc'; + editGalleryCtrl.updateGallery(); + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + +}); diff --git a/test/gallery-item-component-test.js b/test/gallery-item-component-test.js new file mode 100644 index 00000000..40140437 --- /dev/null +++ b/test/gallery-item-component-test.js @@ -0,0 +1,34 @@ +'use strict'; + +describe('Gallery Item Component', function() { + beforeEach( () => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, $componentController, $httpBackend, authService) => { + this.$rootScope = $rootScope; + this.$componentController = $componentController; + this.$httpBackend = $httpBackend; + this.authService = authService; + }); + }); + + describe('galleryItemCtrl.deleteDone', () => { + it('should call deleteDone', () => { + let mockBindings = { + gallery: { + _id: 'testid', + name: 'test name', + desc: 'test description', + pics: [] + }, + deleteDone: function(data) { + expect(data.galleryData._id).toEqual('testid'); + } + }; + + let galleryItemCtrl = this.$componentController('galleryItem', null, mockBindings); + galleryItemCtrl.deleteDone({ galleryData: galleryItemCtrl.gallery }); + + this.$rootScope.$apply(); + }); + }); +}); diff --git a/test/gallery-service-test.js b/test/gallery-service-test.js index 2b46d526..d4c767c3 100644 --- a/test/gallery-service-test.js +++ b/test/gallery-service-test.js @@ -67,7 +67,8 @@ describe('Gallery Service', function() { describe('galleryService.deleteGallery', () => { it('should delete a gallery', () => { - let galleryID = 'testid' + let galleryID = 'testid'; + let headers = { Authorization: 'Bearer test token', Accept: 'application/json, text/plain, */*' From 74f7c1d4dc4b9ace32438ad5261f1ed10d7037da Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Thu, 6 Apr 2017 18:53:36 -0800 Subject: [PATCH 13/14] added fuzzy search --- {assets => app/assets}/cf-logo.png | Bin app/assets/spritesheet.png | Bin 0 -> 3958 bytes .../gallery/gallery-item/gallery-item.html | 4 +-- .../thumbnail-container.html | 2 +- .../gallery/thumbnail/_thumbnail.scss | 1 + app/directive/social-icons.html | 5 +++ app/directive/social-icons.js | 20 +++++++++++ app/entry.js | 14 ++++++++ app/filter/gallery-search.js | 16 +++++++++ app/index.html | 4 ++- app/scss/lib/layout/_footer.scss | 32 ++++++++++++++++++ app/view/home/home.html | 4 ++- webpack.config.js | 4 +++ 13 files changed, 101 insertions(+), 5 deletions(-) rename {assets => app/assets}/cf-logo.png (100%) create mode 100644 app/assets/spritesheet.png create mode 100644 app/directive/social-icons.html create mode 100644 app/directive/social-icons.js create mode 100644 app/filter/gallery-search.js diff --git a/assets/cf-logo.png b/app/assets/cf-logo.png similarity index 100% rename from assets/cf-logo.png rename to app/assets/cf-logo.png diff --git a/app/assets/spritesheet.png b/app/assets/spritesheet.png new file mode 100644 index 0000000000000000000000000000000000000000..51773804afbe8dbbcbbc67ce1be46fedd778910a GIT binary patch literal 3958 zcmYjUdpr~B|96gPu2IAoxgXcuQbViL5HqwwCYQ)%?ly!bC5`2_bBt}xwbdjM$|b~c zY&Q2xo-|u<7p6B`J^LZ}s=lQ%p?@t!O%~3{DMN&jWL~(;+aP%lT{F{i#0SL_gj7PHnN@)mpvspglT>qf3P0{zp=>EG8U8$`Gu2f+I zR<0CMsq=kdmDxcsqw&Aqkrr0VO|R9NEG<8!zlx}shTD3R#J4Uf7O5$(0Q|-s>$MXc z7yFOZTY%wP+(XW7IQjWRppMAg=cFJTF!^)sc5XHxX!sErg_Mxq zWqDm>7ltL$Z`vrH-VU0cDS<8mbvm4R-r6faym-~R5Fg%t-5)P5G~mezFxYca!qugK zfycw}Hn+R+MmeQ|WG}FfM8`wA66`*n+J2GuLpL>&`0eLE>r@>zjU~hL*QCb>U&alONcY7gRz69v8LgbUy=Z+wRC>Q_R{9_f`oveYj0n-b$i40HOke) zaUtwY-5-qV3ibk0r5(y+-QSMw(5RZ8tI-r(BKiY22PyD2D*fg$qQ~xpJR>eMQA02q zX>9gAF>eH}pV@`FZ+*yuI`Gqdpuc;;ylCgq-N`>s<2F~5ej`WLCH*mCr>|!lTx2z1 zmhx3*Yf#fmFq#Bw3)`8E?^4~Y%c9r*T8T%D-Q9H*=UN{(Ly=po^XaBeHZjR-WyCTB zwrXwH5KRWKEEyKv?Weua$Ob$m;Z0UQ>(<&f6jrtyJks>;OX&^hA>EW!tsi?DF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b3?2yai*qkqsD|WTT$fn|! o8qH|;cp~oq*wE|j;y)t6jwydjZcY3mtfxg_4sQ0f(17&+0H6hRYybcN literal 0 HcmV?d00001 diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html index f552abfa..721f3093 100644 --- a/app/component/gallery/gallery-item/gallery-item.html +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -4,11 +4,11 @@ ng-if="!galleryItemCtrl.showEditGallery">
    name: - {{galleryItemCtrl.gallery.name}} + {{ galleryItemCtrl.gallery.name }}
    description: - {{galleryItemCtrl.gallery.desc}} + {{ galleryItemCtrl.gallery.desc }}
    diff --git a/app/component/gallery/thumbnail-container/thumbnail-container.html b/app/component/gallery/thumbnail-container/thumbnail-container.html index 975b28be..86d66e44 100644 --- a/app/component/gallery/thumbnail-container/thumbnail-container.html +++ b/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -1,5 +1,5 @@
    -

    {{ thumbnailContainerCtrl.gallery.name }}

    +

    {{ thumbnailContainerCtrl.gallery.name | uppercase }}

    diff --git a/app/component/gallery/thumbnail/_thumbnail.scss b/app/component/gallery/thumbnail/_thumbnail.scss index 6b122df0..a7fbe2ad 100644 --- a/app/component/gallery/thumbnail/_thumbnail.scss +++ b/app/component/gallery/thumbnail/_thumbnail.scss @@ -22,5 +22,6 @@ $gutterP: 10%; clear: both; float: right; line-height: 40px; + margin-bottom: $gutter; } } diff --git a/app/directive/social-icons.html b/app/directive/social-icons.html new file mode 100644 index 00000000..4d8d6dad --- /dev/null +++ b/app/directive/social-icons.html @@ -0,0 +1,5 @@ + diff --git a/app/directive/social-icons.js b/app/directive/social-icons.js new file mode 100644 index 00000000..0a0a9316 --- /dev/null +++ b/app/directive/social-icons.js @@ -0,0 +1,20 @@ +'use strict'; + +module.exports = function(){ + return { + restrict: 'EAC', + template: require('./social-icons.html'), + controller: ['$log', SocialIconsController], + bindToController: true, + controllerAs: 'socialIconsCtrl', + scope: { + tester: '@' + } + }; +}; + +function SocialIconsController($log) { + $log.debug('SocialIconsController'); + + this.icons = ['fb', 'twitter', 'linkedin']; +} diff --git a/app/entry.js b/app/entry.js index 1633cef2..8cb08285 100644 --- a/app/entry.js +++ b/app/entry.js @@ -45,3 +45,17 @@ context.keys().forEach( key => { let module = context(key); cfgram.component(name, module); }); + +context = require.context('./filter/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.filter(name, module); +}); + +context = require.context('./directive/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.directive(name, module); +}); diff --git a/app/filter/gallery-search.js b/app/filter/gallery-search.js new file mode 100644 index 00000000..f673d429 --- /dev/null +++ b/app/filter/gallery-search.js @@ -0,0 +1,16 @@ +'use strict'; +module.exports = function() { + return function(galleries, searchTerm) { + let fuzzyRegex = generateFuzzyRegex(searchTerm); + + return galleries.filter(gallery => { + return fuzzyRegex.test(gallery.name.toUpperCase()); + }); + }; +}; + +function generateFuzzyRegex(input) { + if(!input) return /.*/; + let fuzzyString = '.*' + input.toUpperCase().split('').join('.*') + '.*'; + return new RegExp(fuzzyString); +} diff --git a/app/index.html b/app/index.html index 1b24412b..43159ed9 100644 --- a/app/index.html +++ b/app/index.html @@ -12,6 +12,8 @@
    -
    +
    + +
    diff --git a/app/scss/lib/layout/_footer.scss b/app/scss/lib/layout/_footer.scss index e69de29b..ae9bf1bb 100644 --- a/app/scss/lib/layout/_footer.scss +++ b/app/scss/lib/layout/_footer.scss @@ -0,0 +1,32 @@ +.twitter { + background: url('../assets/spritesheet.png') no-repeat -5px -63px; + width: 48px; + height: 48px; +} +.fb{ + background: url('../assets/spritesheet.png') no-repeat -63px -63px; + width: 48px; + height: 48px; +} +.linkedin{ + background: url('../assets/spritesheet.png') no-repeat -63px -5px; + width: 48px; + height: 48px; +} +.social-icon{ + display: inline-block; + +} +footer{ + height: 150px; + background: grey; + margin-top: 30px; + clear: both; +} +.social-nav{ + ul{ + line-height: 174px; + height: 150px; + text-align: center; + } +} diff --git a/app/view/home/home.html b/app/view/home/home.html index 3f3f03f7..71de0f86 100644 --- a/app/view/home/home.html +++ b/app/view/home/home.html @@ -1,8 +1,10 @@
    + +
      - diff --git a/webpack.config.js b/webpack.config.js index c97f75a3..c499bf7f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -40,6 +40,10 @@ module.exports = { { test: /\.scss$/, loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + }, + { + test: /\.png$/, + loader: 'url-loader' } ] } From f08a198b4ee6b120ed86338bb9b3429705ecb394 Mon Sep 17 00:00:00 2001 From: noahgribbin Date: Mon, 10 Apr 2017 18:11:57 -0800 Subject: [PATCH 14/14] added bootstrap carousel --- .../component/carousel/_carousel.scss | 0 app/component/carousel/carousel.html | 5 + app/component/carousel/carousel.js | 32 + app/component/landing/login/login.html | 1 + app/component/navbar/navbar.html | 1 - app/entry.js | 3 +- .../lib/bootstrap/_custom-bootstrap-vars.scss | 885 ++++++++++++++++++ app/scss/lib/bootstrap/_custom-bootstrap.scss | 50 + app/scss/main.scss | 2 + app/view/landing/landing.html | 2 + package.json | 2 + pic-service-test.js | 0 webpack.config.js | 3 + 13 files changed, 984 insertions(+), 2 deletions(-) rename gallery-service-test.js => app/component/carousel/_carousel.scss (100%) create mode 100644 app/component/carousel/carousel.html create mode 100644 app/component/carousel/carousel.js create mode 100644 app/scss/lib/bootstrap/_custom-bootstrap-vars.scss create mode 100644 app/scss/lib/bootstrap/_custom-bootstrap.scss delete mode 100644 pic-service-test.js diff --git a/gallery-service-test.js b/app/component/carousel/_carousel.scss similarity index 100% rename from gallery-service-test.js rename to app/component/carousel/_carousel.scss diff --git a/app/component/carousel/carousel.html b/app/component/carousel/carousel.html new file mode 100644 index 00000000..a9f8dbc6 --- /dev/null +++ b/app/component/carousel/carousel.html @@ -0,0 +1,5 @@ +
      +
      + +
      +
      diff --git a/app/component/carousel/carousel.js b/app/component/carousel/carousel.js new file mode 100644 index 00000000..32d70dab --- /dev/null +++ b/app/component/carousel/carousel.js @@ -0,0 +1,32 @@ +'use strict'; + +require('./_carousel.scss'); + +module.exports = { + template: require('./carousel.html'), + controller: ['$log', CarouselController], + controllerAs: 'carouselCtrl' +}; + +function CarouselController($log) { + $log.debug('CarouselController'); + + var currIndex = 0; + this.myInterval = 3000; + this.noWrapSlides = false; + this.active = 0; + this.slides = [ + { + image: 'http://lorempixel.com/400/200/food', + id: currIndex++ + }, + { + image: 'http://lorempixel.com/400/200/sports', + id: currIndex++ + }, + { + image: 'http://lorempixel.com/400/200/', + id: currIndex++ + } + ]; +} diff --git a/app/component/landing/login/login.html b/app/component/landing/login/login.html index 7c635098..af9de32b 100644 --- a/app/component/landing/login/login.html +++ b/app/component/landing/login/login.html @@ -7,6 +7,7 @@

      sign in

      'success': loginForm.username.$valid }">

      cfgram

      -
    + + diff --git a/package.json b/package.json index ad4d3553..bce2f082 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,12 @@ "angular-animate": "^1.6.3", "angular-route": "^1.6.3", "angular-touch": "^1.6.3", + "angular-ui-bootstrap": "^2.5.0", "angular-ui-router": "^0.4.2", "babel-core": "^6.24.0", "babel-loader": "^6.4.1", "babel-preset-es2015": "^6.24.0", + "bootstrap-sass": "^3.3.7", "camelcase": "^4.0.0", "clean-webpack-plugin": "^0.1.16", "css-loader": "^0.27.3", diff --git a/pic-service-test.js b/pic-service-test.js deleted file mode 100644 index e69de29b..00000000 diff --git a/webpack.config.js b/webpack.config.js index c499bf7f..2cbbc909 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -45,6 +45,9 @@ module.exports = { test: /\.png$/, loader: 'url-loader' } + // { + // test: /\. + // } ] } };