From 0b66adb57d61138aef91f9f1bb28d21631405ea2 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Tue, 28 Mar 2017 17:50:10 -0700 Subject: [PATCH 01/15] basic structure finished --- lab-brae/.babelrc | 3 + lab-brae/.eslintrc | 21 +++ lab-brae/.gitignore | 131 ++++++++++++++++++ lab-brae/app/component/login/_login.scss | 0 lab-brae/app/component/login/login.html | 31 +++++ lab-brae/app/component/login/login.js | 27 ++++ lab-brae/app/component/signup/_signup.scss | 0 lab-brae/app/component/signup/signup.html | 25 ++++ lab-brae/app/component/signup/signup.js | 25 ++++ lab-brae/app/config/router-config.js | 31 +++++ lab-brae/app/entry.js | 39 ++++++ lab-brae/app/index.html | 11 ++ lab-brae/app/scss/main.scss | 3 + lab-brae/app/service/auth-service.js | 88 ++++++++++++ lab-brae/app/view/home/_home.scss | 0 lab-brae/app/view/home/home-controller.js | 9 ++ lab-brae/app/view/home/home.html | 3 + lab-brae/app/view/landing/_landing.scss | 0 .../app/view/landing/landing-controller.js | 10 ++ lab-brae/app/view/landing/landing.html | 25 ++++ lab-brae/package.json | 42 ++++++ 21 files changed, 524 insertions(+) create mode 100644 lab-brae/.babelrc create mode 100644 lab-brae/.eslintrc create mode 100644 lab-brae/.gitignore create mode 100644 lab-brae/app/component/login/_login.scss create mode 100644 lab-brae/app/component/login/login.html create mode 100644 lab-brae/app/component/login/login.js create mode 100644 lab-brae/app/component/signup/_signup.scss create mode 100644 lab-brae/app/component/signup/signup.html create mode 100644 lab-brae/app/component/signup/signup.js create mode 100644 lab-brae/app/config/router-config.js create mode 100644 lab-brae/app/entry.js create mode 100644 lab-brae/app/index.html create mode 100644 lab-brae/app/scss/main.scss create mode 100644 lab-brae/app/service/auth-service.js create mode 100644 lab-brae/app/view/home/_home.scss create mode 100644 lab-brae/app/view/home/home-controller.js create mode 100644 lab-brae/app/view/home/home.html create mode 100644 lab-brae/app/view/landing/_landing.scss create mode 100644 lab-brae/app/view/landing/landing-controller.js create mode 100644 lab-brae/app/view/landing/landing.html create mode 100644 lab-brae/package.json diff --git a/lab-brae/.babelrc b/lab-brae/.babelrc new file mode 100644 index 00000000..af0f0c3d --- /dev/null +++ b/lab-brae/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} \ No newline at end of file diff --git a/lab-brae/.eslintrc b/lab-brae/.eslintrc new file mode 100644 index 00000000..b663d772 --- /dev/null +++ b/lab-brae/.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" +} \ No newline at end of file diff --git a/lab-brae/.gitignore b/lab-brae/.gitignore new file mode 100644 index 00000000..9cff7ab9 --- /dev/null +++ b/lab-brae/.gitignore @@ -0,0 +1,131 @@ + +# Created by https://www.gitignore.io/api/node,vim,macos,linux,windows + +node_modules/ + +### Node ### +# Logs +logs +*.log +npm-debug.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 + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# 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 + +.env + +### Vim ### +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + + +### macOS ### +*.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 + + +### 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* + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +*.env +build \ No newline at end of file diff --git a/lab-brae/app/component/login/_login.scss b/lab-brae/app/component/login/_login.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/login/login.html b/lab-brae/app/component/login/login.html new file mode 100644 index 00000000..16a3f798 --- /dev/null +++ b/lab-brae/app/component/login/login.html @@ -0,0 +1,31 @@ +
+
+
+ +
+ +
+ +
+ + +
+
\ No newline at end of file diff --git a/lab-brae/app/component/login/login.js b/lab-brae/app/component/login/login.js new file mode 100644 index 00000000..5451929e --- /dev/null +++ b/lab-brae/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'); + }); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/component/signup/_signup.scss b/lab-brae/app/component/signup/_signup.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/signup/signup.html b/lab-brae/app/component/signup/signup.html new file mode 100644 index 00000000..536d1e26 --- /dev/null +++ b/lab-brae/app/component/signup/signup.html @@ -0,0 +1,25 @@ +
+ +
\ No newline at end of file diff --git a/lab-brae/app/component/signup/signup.js b/lab-brae/app/component/signup/signup.js new file mode 100644 index 00000000..2a0efad3 --- /dev/null +++ b/lab-brae/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') + }); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/config/router-config.js b/lab-brae/app/config/router-config.js new file mode 100644 index 00000000..db1ba30c --- /dev/null +++ b/lab-brae/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); + }); +}; \ No newline at end of file diff --git a/lab-brae/app/entry.js b/lab-brae/app/entry.js new file mode 100644 index 00000000..5f702423 --- /dev/null +++ b/lab-brae/app/entry.js @@ -0,0 +1,39 @@ +'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]); + +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); +}); \ No newline at end of file diff --git a/lab-brae/app/index.html b/lab-brae/app/index.html new file mode 100644 index 00000000..99004a4e --- /dev/null +++ b/lab-brae/app/index.html @@ -0,0 +1,11 @@ + + + + + + CFgram + + + + + diff --git a/lab-brae/app/scss/main.scss b/lab-brae/app/scss/main.scss new file mode 100644 index 00000000..35fe4102 --- /dev/null +++ b/lab-brae/app/scss/main.scss @@ -0,0 +1,3 @@ +body { + background: orange; +} diff --git a/lab-brae/app/service/auth-service.js b/lab-brae/app/service/auth-service.js new file mode 100644 index 00000000..7be0b0e3 --- /dev/null +++ b/lab-brae/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.sign = 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('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 = `${__API_URL__}/api/login`; + let base64 = $window.btao(`${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; +}; \ No newline at end of file diff --git a/lab-brae/app/view/home/_home.scss b/lab-brae/app/view/home/_home.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/view/home/home-controller.js b/lab-brae/app/view/home/home-controller.js new file mode 100644 index 00000000..76799de0 --- /dev/null +++ b/lab-brae/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'); +}; \ No newline at end of file diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html new file mode 100644 index 00000000..daf209d6 --- /dev/null +++ b/lab-brae/app/view/home/home.html @@ -0,0 +1,3 @@ +
+

this is home!

+
diff --git a/lab-brae/app/view/landing/_landing.scss b/lab-brae/app/view/landing/_landing.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/view/landing/landing-controller.js b/lab-brae/app/view/landing/landing-controller.js new file mode 100644 index 00000000..8bda683f --- /dev/null +++ b/lab-brae/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'; +}; \ No newline at end of file diff --git a/lab-brae/app/view/landing/landing.html b/lab-brae/app/view/landing/landing.html new file mode 100644 index 00000000..bcd51cc4 --- /dev/null +++ b/lab-brae/app/view/landing/landing.html @@ -0,0 +1,25 @@ +
+
+
+ +

already a member?

+ + sign in here. + +
+
+ +
+
+ +

want to sign up?

+ + sign up here. + +
+
+
diff --git a/lab-brae/package.json b/lab-brae/package.json new file mode 100644 index 00000000..15dea177 --- /dev/null +++ b/lab-brae/package.json @@ -0,0 +1,42 @@ +{ + "name": "lab-brae", + "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" + } +} From e8ac5648b1a14f1300e5064a8847ffaee93b492b Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Wed, 29 Mar 2017 21:59:51 -0700 Subject: [PATCH 02/15] pushing progress --- .../create-gallery/_create-gallery.scss} | 0 .../create-gallery/create-gallery.html | 20 +++++ .../gallery/create-gallery/create-gallery.js | 21 +++++ .../login/_login.scss} | 0 .../component/{ => landing}/login/login.html | 0 .../component/{ => landing}/login/login.js | 0 .../app/component/landing/signup/_signup.scss | 0 .../{ => landing}/signup/signup.html | 0 .../component/{ => landing}/signup/signup.js | 2 +- lab-brae/app/component/navbar/_navbar.scss | 0 lab-brae/app/component/navbar/navbar.html | 9 ++ lab-brae/app/component/navbar/navbar.js | 43 ++++++++++ lab-brae/app/config/log-config.js | 7 ++ lab-brae/app/config/router-config.js | 4 +- lab-brae/app/index.html | 10 ++- lab-brae/app/scss/lib/base/_base.scss | 0 lab-brae/app/scss/lib/base/_reset.scss | 0 lab-brae/app/scss/lib/layout/_content.scss | 0 lab-brae/app/scss/lib/layout/_footer.scss | 0 lab-brae/app/scss/lib/layout/_header.scss | 0 lab-brae/app/scss/lib/theme/_vars.scss | 0 lab-brae/app/service/auth-service.js | 8 +- lab-brae/app/service/gallery-service.js | 83 +++++++++++++++++++ lab-brae/app/view/home/home-controller.js | 23 ++++- lab-brae/app/view/home/home.html | 10 ++- .../app/view/landing/landing-controller.js | 2 +- lab-brae/package.json | 2 +- lab-brae/webpack.config.js | 46 ++++++++++ 28 files changed, 275 insertions(+), 15 deletions(-) rename lab-brae/app/component/{login/_login.scss => gallery/create-gallery/_create-gallery.scss} (100%) create mode 100644 lab-brae/app/component/gallery/create-gallery/create-gallery.html create mode 100644 lab-brae/app/component/gallery/create-gallery/create-gallery.js rename lab-brae/app/component/{signup/_signup.scss => landing/login/_login.scss} (100%) rename lab-brae/app/component/{ => landing}/login/login.html (100%) rename lab-brae/app/component/{ => landing}/login/login.js (100%) create mode 100644 lab-brae/app/component/landing/signup/_signup.scss rename lab-brae/app/component/{ => landing}/signup/signup.html (100%) rename lab-brae/app/component/{ => landing}/signup/signup.js (99%) create mode 100644 lab-brae/app/component/navbar/_navbar.scss create mode 100644 lab-brae/app/component/navbar/navbar.html create mode 100644 lab-brae/app/component/navbar/navbar.js create mode 100644 lab-brae/app/config/log-config.js create mode 100644 lab-brae/app/scss/lib/base/_base.scss create mode 100644 lab-brae/app/scss/lib/base/_reset.scss create mode 100644 lab-brae/app/scss/lib/layout/_content.scss create mode 100644 lab-brae/app/scss/lib/layout/_footer.scss create mode 100644 lab-brae/app/scss/lib/layout/_header.scss create mode 100644 lab-brae/app/scss/lib/theme/_vars.scss create mode 100644 lab-brae/app/service/gallery-service.js create mode 100644 lab-brae/webpack.config.js diff --git a/lab-brae/app/component/login/_login.scss b/lab-brae/app/component/gallery/create-gallery/_create-gallery.scss similarity index 100% rename from lab-brae/app/component/login/_login.scss rename to lab-brae/app/component/gallery/create-gallery/_create-gallery.scss diff --git a/lab-brae/app/component/gallery/create-gallery/create-gallery.html b/lab-brae/app/component/gallery/create-gallery/create-gallery.html new file mode 100644 index 00000000..bf4bba09 --- /dev/null +++ b/lab-brae/app/component/gallery/create-gallery/create-gallery.html @@ -0,0 +1,20 @@ + diff --git a/lab-brae/app/component/gallery/create-gallery/create-gallery.js b/lab-brae/app/component/gallery/create-gallery/create-gallery.js new file mode 100644 index 00000000..9057808a --- /dev/null +++ b/lab-brae/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; + }); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/component/signup/_signup.scss b/lab-brae/app/component/landing/login/_login.scss similarity index 100% rename from lab-brae/app/component/signup/_signup.scss rename to lab-brae/app/component/landing/login/_login.scss diff --git a/lab-brae/app/component/login/login.html b/lab-brae/app/component/landing/login/login.html similarity index 100% rename from lab-brae/app/component/login/login.html rename to lab-brae/app/component/landing/login/login.html diff --git a/lab-brae/app/component/login/login.js b/lab-brae/app/component/landing/login/login.js similarity index 100% rename from lab-brae/app/component/login/login.js rename to lab-brae/app/component/landing/login/login.js diff --git a/lab-brae/app/component/landing/signup/_signup.scss b/lab-brae/app/component/landing/signup/_signup.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/signup/signup.html b/lab-brae/app/component/landing/signup/signup.html similarity index 100% rename from lab-brae/app/component/signup/signup.html rename to lab-brae/app/component/landing/signup/signup.html diff --git a/lab-brae/app/component/signup/signup.js b/lab-brae/app/component/landing/signup/signup.js similarity index 99% rename from lab-brae/app/component/signup/signup.js rename to lab-brae/app/component/landing/signup/signup.js index 2a0efad3..b5923714 100644 --- a/lab-brae/app/component/signup/signup.js +++ b/lab-brae/app/component/landing/signup/signup.js @@ -22,4 +22,4 @@ function SignupController($log, $location, authService) { $location.url('/home') }); }; -}; \ No newline at end of file +}; diff --git a/lab-brae/app/component/navbar/_navbar.scss b/lab-brae/app/component/navbar/_navbar.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/navbar/navbar.html b/lab-brae/app/component/navbar/navbar.html new file mode 100644 index 00000000..dbe10a00 --- /dev/null +++ b/lab-brae/app/component/navbar/navbar.html @@ -0,0 +1,9 @@ + diff --git a/lab-brae/app/component/navbar/navbar.js b/lab-brae/app/component/navbar/navbar.js new file mode 100644 index 00000000..3f4fa068 --- /dev/null +++ b/lab-brae/app/component/navbar/navbar.js @@ -0,0 +1,43 @@ +'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('navbarCtrl.logout'); + this.hideButtons = true; + authService.logout() + .then( () => { + $location.url('/'); + }); + }; +}; diff --git a/lab-brae/app/config/log-config.js b/lab-brae/app/config/log-config.js new file mode 100644 index 00000000..c84d58c8 --- /dev/null +++ b/lab-brae/app/config/log-config.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = ['$logProvider', logConfig]; + +function logConfig($logProvider) { + $logProvider.debugEnabled(__DEBUG__); +}; diff --git a/lab-brae/app/config/router-config.js b/lab-brae/app/config/router-config.js index db1ba30c..5357c24b 100644 --- a/lab-brae/app/config/router-config.js +++ b/lab-brae/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'); @@ -28,4 +28,4 @@ function routerConfig($stateProvider, $urlRouterProvider) { states.forEach( state => { $stateProvider.state(state); }); -}; \ No newline at end of file +}; diff --git a/lab-brae/app/index.html b/lab-brae/app/index.html index 99004a4e..888b80d0 100644 --- a/lab-brae/app/index.html +++ b/lab-brae/app/index.html @@ -6,6 +6,14 @@ CFgram - +
+ +
+ +
+ +
+ +
diff --git a/lab-brae/app/scss/lib/base/_base.scss b/lab-brae/app/scss/lib/base/_base.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/scss/lib/base/_reset.scss b/lab-brae/app/scss/lib/base/_reset.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/scss/lib/layout/_content.scss b/lab-brae/app/scss/lib/layout/_content.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/scss/lib/layout/_footer.scss b/lab-brae/app/scss/lib/layout/_footer.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/scss/lib/layout/_header.scss b/lab-brae/app/scss/lib/layout/_header.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/scss/lib/theme/_vars.scss b/lab-brae/app/scss/lib/theme/_vars.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/service/auth-service.js b/lab-brae/app/service/auth-service.js index 7be0b0e3..41fe4c15 100644 --- a/lab-brae/app/service/auth-service.js +++ b/lab-brae/app/service/auth-service.js @@ -31,7 +31,7 @@ function authService($q, $log, $http, $window) { return $q.reject(new Error('token not found')); }; - service.sign = function(user) { + service.signup = function(user) { $log.debug('authService.signup'); let url = `${__API_URL__}/api/signup`; @@ -44,7 +44,7 @@ function authService($q, $log, $http, $window) { return $http.post(url, user, config) .then( res => { - $log.log('success:' res.data); + $log.log('success:', res.data); return setToken(res.data); }) .catch( err => { @@ -65,7 +65,7 @@ function authService($q, $log, $http, $window) { $log.debug('authService.login'); let url = `${__API_URL__}/api/login`; - let base64 = $window.btao(`${user.username}:${user.password}`); + let base64 = $window.btoa(`${user.username}:${user.password}`); let config = { headers: { Accept: 'application/json', @@ -85,4 +85,4 @@ function authService($q, $log, $http, $window) { }; return service; -}; \ No newline at end of file +}; diff --git a/lab-brae/app/service/gallery-service.js b/lab-brae/app/service/gallery-service.js new file mode 100644 index 00000000..faa1d5d2 --- /dev/null +++ b/lab-brae/app/service/gallery-service.js @@ -0,0 +1,83 @@ +'use strict'; + +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}` + } + }; + + // CREATE $HTTP.DELETE REQUEST HERE + }); + }; + + 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; +}; \ No newline at end of file diff --git a/lab-brae/app/view/home/home-controller.js b/lab-brae/app/view/home/home-controller.js index 76799de0..80422164 100644 --- a/lab-brae/app/view/home/home-controller.js +++ b/lab-brae/app/view/home/home-controller.js @@ -1,9 +1,24 @@ 'use strict'; -require('./home.scss'); +require('./_home.scss'); -module.exports = ['$log', HomeController]; +module.exports = ['$log', '$rootScope', 'galleryService', HomeController]; -function HomeController($log) { +function HomeController($log, $rootScope, galleryService) { $log.debug('HomeController'); -}; \ No newline at end of file + + this.galleries = []; + + tihs.fetchGalleries = function() { + galleryService.fetchGalleries() + .then( galleries => { + this.galleries = galleries; + }); + }; + + this.fetchGalleries(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.fetchGalleries(); + }); +}; diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index daf209d6..2327459a 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -1,3 +1,11 @@
-

this is home!

+ + +
    +
  • + name: {{ gallery.name }} + description: {{gallery.desc }} + id: {{ gallery._id }} +
  • +
diff --git a/lab-brae/app/view/landing/landing-controller.js b/lab-brae/app/view/landing/landing-controller.js index 8bda683f..ac3f9342 100644 --- a/lab-brae/app/view/landing/landing-controller.js +++ b/lab-brae/app/view/landing/landing-controller.js @@ -2,7 +2,7 @@ require('./_landing.scss'); -module.exports = ['$log', '$location', '$rootscope', 'authService', LandingController]; +module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; function LandingController($log, $location, authService) { let url = $location.url(); diff --git a/lab-brae/package.json b/lab-brae/package.json index 15dea177..d6209848 100644 --- a/lab-brae/package.json +++ b/lab-brae/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "build": "./node_modules/webpack/bin/webpack.js", - "watch": "./node_modules/webpack-dev-server/bin-webpack-dev-server.js --inline --hot" + "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot" }, "keywords": [], "author": "", diff --git a/lab-brae/webpack.config.js b/lab-brae/webpack.config.js new file mode 100644 index 00000000..c8968b3d --- /dev/null +++ b/lab-brae/webpack.config.js @@ -0,0 +1,46 @@ +'use strict'; + +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`, + 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), + __DEBUG__: JSON.stringify(!production) + }) + ], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + { + test: /\.html$/, + loader: 'html-loader' + }, + { + test: /\.scss$/, + loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + } + ] + } +}; \ No newline at end of file From 884dbff5c2919531a49a4b8f14795ab7a932b430 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Thu, 30 Mar 2017 15:16:47 -0700 Subject: [PATCH 03/15] pushing working code --- .../gallery/edit-gallery/_edit-gallery.scss | 0 .../gallery/edit-gallery/edit-gallery.html | 21 +++++++ .../gallery/edit-gallery/edit-gallery.js | 22 +++++++ .../gallery/gallery-item/_gallery-item.scss | 0 .../gallery/gallery-item/gallery-item.html | 22 +++++++ .../gallery/gallery-item/gallery-item.js | 22 +++++++ .../app/component/landing/signup/signup.html | 2 +- lab-brae/app/service/auth-service.js | 6 +- lab-brae/app/service/gallery-service.js | 62 +++++++++++++++++++ lab-brae/app/view/home/home-controller.js | 2 +- lab-brae/app/view/home/home.html | 9 +-- 11 files changed, 156 insertions(+), 12 deletions(-) create mode 100644 lab-brae/app/component/gallery/edit-gallery/_edit-gallery.scss create mode 100644 lab-brae/app/component/gallery/edit-gallery/edit-gallery.html create mode 100644 lab-brae/app/component/gallery/edit-gallery/edit-gallery.js create mode 100644 lab-brae/app/component/gallery/gallery-item/_gallery-item.scss create mode 100644 lab-brae/app/component/gallery/gallery-item/gallery-item.html create mode 100644 lab-brae/app/component/gallery/gallery-item/gallery-item.js diff --git a/lab-brae/app/component/gallery/edit-gallery/_edit-gallery.scss b/lab-brae/app/component/gallery/edit-gallery/_edit-gallery.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/gallery/edit-gallery/edit-gallery.html b/lab-brae/app/component/gallery/edit-gallery/edit-gallery.html new file mode 100644 index 00000000..5032fe3f --- /dev/null +++ b/lab-brae/app/component/gallery/edit-gallery/edit-gallery.html @@ -0,0 +1,21 @@ +
+ +
diff --git a/lab-brae/app/component/gallery/edit-gallery/edit-gallery.js b/lab-brae/app/component/gallery/edit-gallery/edit-gallery.js new file mode 100644 index 00000000..623cdfec --- /dev/null +++ b/lab-brae/app/component/gallery/edit-gallery/edit-gallery.js @@ -0,0 +1,22 @@ +'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); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/component/gallery/gallery-item/_gallery-item.scss b/lab-brae/app/component/gallery/gallery-item/_gallery-item.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/gallery/gallery-item/gallery-item.html b/lab-brae/app/component/gallery/gallery-item/gallery-item.html new file mode 100644 index 00000000..fe201aa1 --- /dev/null +++ b/lab-brae/app/component/gallery/gallery-item/gallery-item.html @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/lab-brae/app/component/gallery/gallery-item/gallery-item.js b/lab-brae/app/component/gallery/gallery-item/gallery-item.js new file mode 100644 index 00000000..2768da14 --- /dev/null +++ b/lab-brae/app/component/gallery/gallery-item/gallery-item.js @@ -0,0 +1,22 @@ +'use strict'; + +require('./_gallery-item.scss'); + +module.exports = { + template: require('./gallery-item.html'), + controller: ['$log', 'galleryService', GalleryItemController], + controllerAs: 'galleryItemCtrl', + bindings: { + gallery: '<' + } +}; + +function GalleryItemController($log, galleryService) { + $log.debug('GalleryItemController'); + + this.showEditGallery = false; + + this.deleteGallery = function() { + galleryService.deleteGallery(this.gallery._id); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/component/landing/signup/signup.html b/lab-brae/app/component/landing/signup/signup.html index 536d1e26..f1b9f38d 100644 --- a/lab-brae/app/component/landing/signup/signup.html +++ b/lab-brae/app/component/landing/signup/signup.html @@ -17,7 +17,7 @@ diff --git a/lab-brae/app/service/auth-service.js b/lab-brae/app/service/auth-service.js index 41fe4c15..2e404f26 100644 --- a/lab-brae/app/service/auth-service.js +++ b/lab-brae/app/service/auth-service.js @@ -13,7 +13,7 @@ function authService($q, $log, $http, $window) { if (! _token) { return $q.reject(new Error('no token')); - }; + } $window.localStorage.setItem('token', _token); token = _token; @@ -24,10 +24,10 @@ function authService($q, $log, $http, $window) { $log.debug('authService.getToken'); if (token) { return $q.resolve(token); - }; + } token = $window.localStorage.getItem('token'); - if (token) return $q.resolve(token); + if (token) return $q.resolve(token) return $q.reject(new Error('token not found')); }; diff --git a/lab-brae/app/service/gallery-service.js b/lab-brae/app/service/gallery-service.js index faa1d5d2..86d66d71 100644 --- a/lab-brae/app/service/gallery-service.js +++ b/lab-brae/app/service/gallery-service.js @@ -79,5 +79,67 @@ function galleryService($q, $log, $http, authService) { }); }; + 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 authSerivce.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.gallery.splice(i, 1); + break; + } + } + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + return service; }; \ No newline at end of file diff --git a/lab-brae/app/view/home/home-controller.js b/lab-brae/app/view/home/home-controller.js index 80422164..9bddd600 100644 --- a/lab-brae/app/view/home/home-controller.js +++ b/lab-brae/app/view/home/home-controller.js @@ -9,7 +9,7 @@ function HomeController($log, $rootScope, galleryService) { this.galleries = []; - tihs.fetchGalleries = function() { + this.fetchGalleries = function() { galleryService.fetchGalleries() .then( galleries => { this.galleries = galleries; diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index 2327459a..f654b10f 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -1,11 +1,6 @@
- - +
    -
  • - name: {{ gallery.name }} - description: {{gallery.desc }} - id: {{ gallery._id }} -
  • +
From 882ca827b2e6f8648a1f8ad910c029373b30f6a3 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Thu, 30 Mar 2017 22:47:47 -0700 Subject: [PATCH 04/15] im bad at css --- lab-brae/app/scss/lib/base/_reset.scss | 48 ++++++++++++++++++++++ lab-brae/app/scss/lib/layout/_content.scss | 5 +++ lab-brae/app/scss/lib/layout/_header.scss | 14 +++++++ lab-brae/app/scss/lib/theme/_vars.scss | 6 +++ lab-brae/app/scss/main.scss | 24 +++++++++-- 5 files changed, 94 insertions(+), 3 deletions(-) diff --git a/lab-brae/app/scss/lib/base/_reset.scss b/lab-brae/app/scss/lib/base/_reset.scss index e69de29b..af944401 100644 --- a/lab-brae/app/scss/lib/base/_reset.scss +++ b/lab-brae/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; +} \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_content.scss b/lab-brae/app/scss/lib/layout/_content.scss index e69de29b..63388566 100644 --- a/lab-brae/app/scss/lib/layout/_content.scss +++ b/lab-brae/app/scss/lib/layout/_content.scss @@ -0,0 +1,5 @@ +@import '../theme/vars'; + +main { + background: $white; +} \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_header.scss b/lab-brae/app/scss/lib/layout/_header.scss index e69de29b..64d038dd 100644 --- a/lab-brae/app/scss/lib/layout/_header.scss +++ b/lab-brae/app/scss/lib/layout/_header.scss @@ -0,0 +1,14 @@ +@import '../theme/vars'; + +header { + background: $brand-secondary; + font-family: Helvetica; + color: $white; + height: 8vw; + margin-top: 5%; + + h2 { + font-size: 4vw; + } + +} \ No newline at end of file diff --git a/lab-brae/app/scss/lib/theme/_vars.scss b/lab-brae/app/scss/lib/theme/_vars.scss index e69de29b..91572adb 100644 --- a/lab-brae/app/scss/lib/theme/_vars.scss +++ b/lab-brae/app/scss/lib/theme/_vars.scss @@ -0,0 +1,6 @@ +$font-family: Helvetica; +$white: #fff; +$black: #000; +$brand-primary: #d7d7d7; +$brand-secondary: #494949; +$gutter-std: 5%; \ No newline at end of file diff --git a/lab-brae/app/scss/main.scss b/lab-brae/app/scss/main.scss index 35fe4102..4db5a236 100644 --- a/lab-brae/app/scss/main.scss +++ b/lab-brae/app/scss/main.scss @@ -1,3 +1,21 @@ -body { - background: orange; -} +// :: BASE :: // +@import './lib/base/reset'; +@import './lib/base/base'; + +// :: LAYOUT :: // +@import './lib/layout/content'; +@import './lib/layout/footer'; +@import './lib/layout/header'; + +// :: VIEWS :: // +@import '/../view/home/home'; +@import '/../view/landing/landing'; + +// :: COMPONENTS :: // +@import '/../component/navbar/navbar'; +@import '/../component/landing/login/login'; +@import '/../component/landing/signup/signup'; +@import '/../component/gallery/create-gallery/create-gallery'; +@import '/../component/gallery/edit-gallery/edit-gallery'; +@import '/../component/gallery/gallery-item/gallery-item'; + From b1b2dc6b5016b935583f48f79c9fda1b22fc058e Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Mon, 3 Apr 2017 15:41:53 -0700 Subject: [PATCH 05/15] delete galleries working --- lab-brae/app/component/gallery/gallery-item/gallery-item.html | 4 ++-- lab-brae/app/service/gallery-service.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lab-brae/app/component/gallery/gallery-item/gallery-item.html b/lab-brae/app/component/gallery/gallery-item/gallery-item.html index fe201aa1..0cd6a23a 100644 --- a/lab-brae/app/component/gallery/gallery-item/gallery-item.html +++ b/lab-brae/app/component/gallery/gallery-item/gallery-item.html @@ -16,7 +16,7 @@ edit - - delete + + delete \ No newline at end of file diff --git a/lab-brae/app/service/gallery-service.js b/lab-brae/app/service/gallery-service.js index 86d66d71..06376e34 100644 --- a/lab-brae/app/service/gallery-service.js +++ b/lab-brae/app/service/gallery-service.js @@ -115,7 +115,7 @@ function galleryService($q, $log, $http, authService) { service.deleteGallery = function(galleryID) { $log.debug('galleryService.deleteGallery'); - return authSerivce.getToken() + return authService.getToken() .then( token => { let url = `${__API_URL__}/api/gallery/${galleryID}`; let config = { @@ -130,7 +130,7 @@ function galleryService($q, $log, $http, authService) { for (let i=0; i < service.galleries.length; i++) { let current = service.galleries[i]; if(current._id === galleryID) { - service.gallery.splice(i, 1); + service.galleries.splice(i, 1); break; } } From 71baa0168a7ffba05646cac33c5c263f79363029 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Mon, 3 Apr 2017 17:39:53 -0700 Subject: [PATCH 06/15] i think my code is fine but sluggram tells me my s3 bucket doesn't exist --- .../gallery/gallery-item/gallery-item.html | 3 +- .../_thumbnail-container.scss | 0 .../thumbnail-container.html | 8 ++++ .../thumbnail-container.js | 11 +++++ .../gallery/thumbnail/_thumbnail.scss | 0 .../gallery/thumbnail/thumbnail.html | 5 +++ .../component/gallery/thumbnail/thumbnail.js | 20 +++++++++ .../gallery/upload-pic/_upload-pic.scss | 0 .../gallery/upload-pic/upload-pic.html | 23 ++++++++++ .../gallery/upload-pic/upload-pic.js | 27 ++++++++++++ lab-brae/app/entry.js | 3 +- lab-brae/app/service/pic-service.js | 43 +++++++++++++++++++ lab-brae/app/view/home/home.html | 9 +++- lab-brae/package.json | 1 + 14 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 lab-brae/app/component/gallery/thumbnail-container/_thumbnail-container.scss create mode 100644 lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html create mode 100644 lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.js create mode 100644 lab-brae/app/component/gallery/thumbnail/_thumbnail.scss create mode 100644 lab-brae/app/component/gallery/thumbnail/thumbnail.html create mode 100644 lab-brae/app/component/gallery/thumbnail/thumbnail.js create mode 100644 lab-brae/app/component/gallery/upload-pic/_upload-pic.scss create mode 100644 lab-brae/app/component/gallery/upload-pic/upload-pic.html create mode 100644 lab-brae/app/component/gallery/upload-pic/upload-pic.js create mode 100644 lab-brae/app/service/pic-service.js diff --git a/lab-brae/app/component/gallery/gallery-item/gallery-item.html b/lab-brae/app/component/gallery/gallery-item/gallery-item.html index 0cd6a23a..9903fbb2 100644 --- a/lab-brae/app/component/gallery/gallery-item/gallery-item.html +++ b/lab-brae/app/component/gallery/gallery-item/gallery-item.html @@ -17,6 +17,7 @@ edit - delete + + delete \ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail-container/_thumbnail-container.scss b/lab-brae/app/component/gallery/thumbnail-container/_thumbnail-container.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html new file mode 100644 index 00000000..99577f18 --- /dev/null +++ b/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -0,0 +1,8 @@ +
+

{{ thumbnailContainerCtrl.gallery.name }}

+ + +
+ +
+
\ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.js b/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.js new file mode 100644 index 00000000..68b89a02 --- /dev/null +++ b/lab-brae/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: '<' + } +}; \ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail/_thumbnail.scss b/lab-brae/app/component/gallery/thumbnail/_thumbnail.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/gallery/thumbnail/thumbnail.html b/lab-brae/app/component/gallery/thumbnail/thumbnail.html new file mode 100644 index 00000000..2eea53ac --- /dev/null +++ b/lab-brae/app/component/gallery/thumbnail/thumbnail.html @@ -0,0 +1,5 @@ +
+ {{ thumbnailCtrl.pic.desc }} + delete + +
\ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail/thumbnail.js b/lab-brae/app/component/gallery/thumbnail/thumbnail.js new file mode 100644 index 00000000..780ee86d --- /dev/null +++ b/lab-brae/app/component/gallery/thumbnail/thumbnail.js @@ -0,0 +1,20 @@ +'use strict'; + +require('./_thumbnail.scss'); + +module.exports = { + template: require('./thumbnail.html'), + controller: ['$log', 'picService', ThumbnailController], + controllerAs: 'thumbnailCtrl', + bindings: { + pic: '<' + } +}; + +function ThumbnailController($log, picService) { + $log.debug('ThumbnailController'); + + this.deletePic = function() { + $log.debug('thumbnailCtrl.deletePic'); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/component/gallery/upload-pic/_upload-pic.scss b/lab-brae/app/component/gallery/upload-pic/_upload-pic.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-brae/app/component/gallery/upload-pic/upload-pic.html b/lab-brae/app/component/gallery/upload-pic/upload-pic.html new file mode 100644 index 00000000..a7b82dfa --- /dev/null +++ b/lab-brae/app/component/gallery/upload-pic/upload-pic.html @@ -0,0 +1,23 @@ +
+
+ +

upload a new pic

+ +
+ + +
+ +
+

+ select a pic +

+ + +
+
+
\ No newline at end of file diff --git a/lab-brae/app/component/gallery/upload-pic/upload-pic.js b/lab-brae/app/component/gallery/upload-pic/upload-pic.js new file mode 100644 index 00000000..0321d3fe --- /dev/null +++ b/lab-brae/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; + }); + }; +}; \ No newline at end of file diff --git a/lab-brae/app/entry.js b/lab-brae/app/entry.js index 5f702423..c0eac06e 100644 --- a/lab-brae/app/entry.js +++ b/lab-brae/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]); let context = require.context('./config/', true, /\.js$/); context.keys().forEach( key => { diff --git a/lab-brae/app/service/pic-service.js b/lab-brae/app/service/pic-service.js new file mode 100644 index 00000000..9bc2fcf5 --- /dev/null +++ b/lab-brae/app/service/pic-service.js @@ -0,0 +1,43 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'Upload', 'authService', picService]; + +function picService($q, $log, $http, Upload, authService) { + $log.debug('picService'); + + let service = {}; + + service.uploadGalleryPic = function(galleryData, picData) { + $log.debug('service.uploadGalleryPic'); + + 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 => { + galleryData.pics.unshift(res.data); + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + return service; +}; \ No newline at end of file diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index f654b10f..bca2ae9e 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -1,6 +1,13 @@
    - +
+ +
diff --git a/lab-brae/package.json b/lab-brae/package.json index d6209848..40a4b030 100644 --- a/lab-brae/package.json +++ b/lab-brae/package.json @@ -27,6 +27,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 5c4e5ce876771f56b8668fe7011bb8d10371b03d Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Mon, 3 Apr 2017 23:55:48 -0700 Subject: [PATCH 07/15] 500 aws error --- .../gallery/thumbnail/thumbnail.html | 3 +-- lab-brae/app/service/pic-service.js | 24 +++++++++++++++++++ lab-brae/app/view/home/home-controller.js | 7 ++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lab-brae/app/component/gallery/thumbnail/thumbnail.html b/lab-brae/app/component/gallery/thumbnail/thumbnail.html index 2eea53ac..8a67f682 100644 --- a/lab-brae/app/component/gallery/thumbnail/thumbnail.html +++ b/lab-brae/app/component/gallery/thumbnail/thumbnail.html @@ -1,5 +1,4 @@
{{ thumbnailCtrl.pic.desc }} - delete - + delete
\ No newline at end of file diff --git a/lab-brae/app/service/pic-service.js b/lab-brae/app/service/pic-service.js index 9bc2fcf5..a8df435d 100644 --- a/lab-brae/app/service/pic-service.js +++ b/lab-brae/app/service/pic-service.js @@ -39,5 +39,29 @@ function picService($q, $log, $http, Upload, authService) { }); }; + service.deleteGalleryPic = function(galleryData, picData) { + $log.debug('service.deleteGalleryPic'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic/${picId}`; + let config = { + header: { + Authorization: `Bearer ${token}` + } + }; + + return $http.delete(url, config); + }) + .then(res => { + galleryData.pics.shift(); + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + return service; }; \ No newline at end of file diff --git a/lab-brae/app/view/home/home-controller.js b/lab-brae/app/view/home/home-controller.js index 9bddd600..69a2bbcb 100644 --- a/lab-brae/app/view/home/home-controller.js +++ b/lab-brae/app/view/home/home-controller.js @@ -13,9 +13,16 @@ function HomeController($log, $rootScope, galleryService) { galleryService.fetchGalleries() .then( galleries => { this.galleries = galleries; + this.currentGallery = galleries[0]; }); }; + this.galleryDeleteDone = function(gallery) { + if (this.currentGallery._id === galler._id) { + this.currentGallery = null; + } + }; + this.fetchGalleries(); $rootScope.$on('$locationChangeSuccess', () => { From eadc963e5b4d83b8a4307203cd83994d736fa83c Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Tue, 4 Apr 2017 20:57:17 -0700 Subject: [PATCH 08/15] picture deletion working --- .../thumbnail-container.html | 2 +- .../gallery/thumbnail/thumbnail.html | 8 +- .../component/gallery/thumbnail/thumbnail.js | 4 +- .../gallery/upload-pic/upload-pic.html | 2 +- lab-brae/app/service/pic-service.js | 19 +++-- lab-brae/app/view/home/home-controller.js | 2 +- lab-brae/app/view/home/home.html | 3 +- lab-brae/karma.conf.js | 75 +++++++++++++++++++ lab-brae/package.json | 11 ++- lab-brae/test/auth-service-test.js | 32 ++++++++ lab-brae/test/example-test.js | 7 ++ lab-brae/test/gallery-service-test.js | 46 ++++++++++++ 12 files changed, 198 insertions(+), 13 deletions(-) create mode 100644 lab-brae/karma.conf.js create mode 100644 lab-brae/test/auth-service-test.js create mode 100644 lab-brae/test/example-test.js create mode 100644 lab-brae/test/gallery-service-test.js diff --git a/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html index 99577f18..6ea1fe6f 100644 --- a/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html +++ b/lab-brae/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -3,6 +3,6 @@

{{ thumbnailContainerCtrl.gallery.name }}

- +
\ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail/thumbnail.html b/lab-brae/app/component/gallery/thumbnail/thumbnail.html index 8a67f682..88765c43 100644 --- a/lab-brae/app/component/gallery/thumbnail/thumbnail.html +++ b/lab-brae/app/component/gallery/thumbnail/thumbnail.html @@ -1,4 +1,10 @@
{{ thumbnailCtrl.pic.desc }} - delete + + + delete + +
\ No newline at end of file diff --git a/lab-brae/app/component/gallery/thumbnail/thumbnail.js b/lab-brae/app/component/gallery/thumbnail/thumbnail.js index 780ee86d..9f4c8c25 100644 --- a/lab-brae/app/component/gallery/thumbnail/thumbnail.js +++ b/lab-brae/app/component/gallery/thumbnail/thumbnail.js @@ -7,7 +7,8 @@ module.exports = { controller: ['$log', 'picService', ThumbnailController], controllerAs: 'thumbnailCtrl', bindings: { - pic: '<' + pic: '<', + gallery: '<' } }; @@ -16,5 +17,6 @@ function ThumbnailController($log, picService) { this.deletePic = function() { $log.debug('thumbnailCtrl.deletePic'); + picService.deleteGalleryPic(this.gallery, this.pic); }; }; \ No newline at end of file diff --git a/lab-brae/app/component/gallery/upload-pic/upload-pic.html b/lab-brae/app/component/gallery/upload-pic/upload-pic.html index a7b82dfa..65cb4c09 100644 --- a/lab-brae/app/component/gallery/upload-pic/upload-pic.html +++ b/lab-brae/app/component/gallery/upload-pic/upload-pic.html @@ -7,7 +7,7 @@

upload a new pic

- +
diff --git a/lab-brae/app/service/pic-service.js b/lab-brae/app/service/pic-service.js index a8df435d..0d736938 100644 --- a/lab-brae/app/service/pic-service.js +++ b/lab-brae/app/service/pic-service.js @@ -40,22 +40,29 @@ function picService($q, $log, $http, Upload, authService) { }; service.deleteGalleryPic = function(galleryData, picData) { - $log.debug('service.deleteGalleryPic'); + $log.debug('picService.deleteGalleryPic'); return authService.getToken() .then( token => { - let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic/${picId}`; + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic/${picData._id}`; let config = { - header: { + headers: { Authorization: `Bearer ${token}` } }; return $http.delete(url, config); }) - .then(res => { - galleryData.pics.shift(); - return res.data; + .then( res => { + $log.log(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; + } + } }) .catch( err => { $log.error(err.message); diff --git a/lab-brae/app/view/home/home-controller.js b/lab-brae/app/view/home/home-controller.js index 69a2bbcb..24cacec9 100644 --- a/lab-brae/app/view/home/home-controller.js +++ b/lab-brae/app/view/home/home-controller.js @@ -18,7 +18,7 @@ function HomeController($log, $rootScope, galleryService) { }; this.galleryDeleteDone = function(gallery) { - if (this.currentGallery._id === galler._id) { + if (this.currentGallery._id === gallery._id) { this.currentGallery = null; } }; diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index bca2ae9e..fc70d6d3 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -1,10 +1,11 @@
+
diff --git a/lab-brae/karma.conf.js b/lab-brae/karma.conf.js new file mode 100644 index 00000000..cfa0bbfe --- /dev/null +++ b/lab-brae/karma.conf.js @@ -0,0 +1,75 @@ +// Karma configuration +// Generated on Tue Apr 04 2017 10:16:51 GMT-0700 (PDT) +const webpack = require('./webpack.config.js'); +delete webpack.entry; + +module.exports = function(config) { + config.set({ + webpack, + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'app/entry.js', + 'test/**/*-test.js', + 'node_modules/angular-mocks/angular-mocks.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'test/**/*-test.js': ['webpack'], + 'app/entry.js': ['webpack'] + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }) +} diff --git a/lab-brae/package.json b/lab-brae/package.json index 40a4b030..d882a673 100644 --- a/lab-brae/package.json +++ b/lab-brae/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 start --single-run", + "test-watch": "./node_modules/karma/bin/karma start" }, "keywords": [], "author": "", @@ -38,6 +40,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/lab-brae/test/auth-service-test.js b/lab-brae/test/auth-service-test.js new file mode 100644 index 00000000..9e10f162 --- /dev/null +++ b/lab-brae/test/auth-service-test.js @@ -0,0 +1,32 @@ +'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.token = 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(); + + }); + }); +}); \ No newline at end of file diff --git a/lab-brae/test/example-test.js b/lab-brae/test/example-test.js new file mode 100644 index 00000000..01b00f20 --- /dev/null +++ b/lab-brae/test/example-test.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('Example Test', function() { + it('should pass this test', () => { + expect(true).toEqual(true); + }); +}); \ No newline at end of file diff --git a/lab-brae/test/gallery-service-test.js b/lab-brae/test/gallery-service-test.js new file mode 100644 index 00000000..0c989216 --- /dev/null +++ b/lab-brae/test/gallery-service-test.js @@ -0,0 +1,46 @@ +'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 description' + }; + + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPOST('http://localhost:8000/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(); + }); + }); + + // TODO: create another test for deleting a gallery + // expectDELETE, give it url which will hit endpoint, pass in headers, res with 204 +}) \ No newline at end of file From 5774eb45d4952fc8d44a0fb779f53aed833fd580 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Tue, 4 Apr 2017 22:25:29 -0700 Subject: [PATCH 09/15] delete test is passing --- lab-brae/test/example-test.js | 7 ------- lab-brae/test/gallery-service-test.js | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 lab-brae/test/example-test.js diff --git a/lab-brae/test/example-test.js b/lab-brae/test/example-test.js deleted file mode 100644 index 01b00f20..00000000 --- a/lab-brae/test/example-test.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -describe('Example Test', function() { - it('should pass this test', () => { - expect(true).toEqual(true); - }); -}); \ No newline at end of file diff --git a/lab-brae/test/gallery-service-test.js b/lab-brae/test/gallery-service-test.js index 0c989216..7eeba3ee 100644 --- a/lab-brae/test/gallery-service-test.js +++ b/lab-brae/test/gallery-service-test.js @@ -41,6 +41,20 @@ describe('Gallery Service', function() { }); }); - // TODO: create another test for deleting a gallery - // expectDELETE, give it url which will hit endpoint, pass in headers, res with 204 -}) \ No newline at end of file + describe('galleryService.deleteGallery', () => { + it('should delete a gallery', () => { + let galleryID = 'testingID'; + let headers = { + Authorization: 'Bearer test token', + Accept: 'application/json, text/plain, */*' + }; + + this.$httpBackend.expectDELETE('http://localhost:8000/api/gallery/testingID', headers) + .respond(204); + + this.galleryService.deleteGallery(galleryID); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); +}); \ No newline at end of file From 1146ab192a14fdf07f5caa3550ec48d3b95d1d03 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Wed, 5 Apr 2017 00:17:17 -0700 Subject: [PATCH 10/15] some styling finished --- lab-brae/app/scss/lib/base/_base.scss | 14 ++++++++++++++ lab-brae/app/scss/lib/layout/_header.scss | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lab-brae/app/scss/lib/base/_base.scss b/lab-brae/app/scss/lib/base/_base.scss index e69de29b..6af218b8 100644 --- a/lab-brae/app/scss/lib/base/_base.scss +++ b/lab-brae/app/scss/lib/base/_base.scss @@ -0,0 +1,14 @@ +@import '../theme/vars'; + +button { + border: none; + border-radius: 3px; + background: $brand-secondary; + color: $white; + padding: 1% 5%; + cursor: pointer; +} + +a { + text-decoration: none; +} \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_header.scss b/lab-brae/app/scss/lib/layout/_header.scss index 64d038dd..f06ea953 100644 --- a/lab-brae/app/scss/lib/layout/_header.scss +++ b/lab-brae/app/scss/lib/layout/_header.scss @@ -5,7 +5,6 @@ header { font-family: Helvetica; color: $white; height: 8vw; - margin-top: 5%; h2 { font-size: 4vw; From 042404b8947984717f15ebdc9433ad5a3be9db54 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Wed, 5 Apr 2017 10:26:36 -0700 Subject: [PATCH 11/15] more styling --- lab-brae/app/scss/lib/layout/_content.scss | 2 +- lab-brae/app/scss/lib/layout/_footer.scss | 8 ++++++++ lab-brae/app/scss/lib/theme/_vars.scss | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lab-brae/app/scss/lib/layout/_content.scss b/lab-brae/app/scss/lib/layout/_content.scss index 63388566..4eadaac1 100644 --- a/lab-brae/app/scss/lib/layout/_content.scss +++ b/lab-brae/app/scss/lib/layout/_content.scss @@ -1,5 +1,5 @@ @import '../theme/vars'; main { - background: $white; + background: $brand-primary; } \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_footer.scss b/lab-brae/app/scss/lib/layout/_footer.scss index e69de29b..e106e26d 100644 --- a/lab-brae/app/scss/lib/layout/_footer.scss +++ b/lab-brae/app/scss/lib/layout/_footer.scss @@ -0,0 +1,8 @@ +@import '../theme/vars'; + +footer { + background: $brand-tertiary; + font-family: Helvetica; + color: $white; + height: 8vw; +} \ No newline at end of file diff --git a/lab-brae/app/scss/lib/theme/_vars.scss b/lab-brae/app/scss/lib/theme/_vars.scss index 91572adb..5f2fc6a7 100644 --- a/lab-brae/app/scss/lib/theme/_vars.scss +++ b/lab-brae/app/scss/lib/theme/_vars.scss @@ -3,4 +3,5 @@ $white: #fff; $black: #000; $brand-primary: #d7d7d7; $brand-secondary: #494949; +$brand-tertiary: #9b9b9b; $gutter-std: 5%; \ No newline at end of file From 5eeb69380e82710676034c74fb5694a8ce374acd Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Wed, 5 Apr 2017 17:20:22 -0700 Subject: [PATCH 12/15] create gallery test written --- .../test/create-gallery-component-test.js | 41 ++++++++++++ lab-brae/test/edit-gallery-component-test.js | 65 +++++++++++++++++++ lab-brae/test/gallery-item-component-test.js | 64 ++++++++++++++++++ lab-brae/test/gallery-service-test.js | 4 +- 4 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 lab-brae/test/create-gallery-component-test.js create mode 100644 lab-brae/test/edit-gallery-component-test.js create mode 100644 lab-brae/test/gallery-item-component-test.js diff --git a/lab-brae/test/create-gallery-component-test.js b/lab-brae/test/create-gallery-component-test.js new file mode 100644 index 00000000..5822ca22 --- /dev/null +++ b/lab-brae/test/create-gallery-component-test.js @@ -0,0 +1,41 @@ +'use strict'; + +describe('Create 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.authService = authService; + }); + }); + + describe('createGalleryCtrl.createGallery()', () => { + it('should make a valid POST request', () => { + let url = `${__API_URL__}/api/gallery`; + let exampleGallery = { + name: 'test name', + desc: 'test description' + }; + + let headers = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + Authorization: 'Bearer test token' + }; + + + this.$httpBackend.expectPOST(url, exampleGallery, headers).respond(200); + + let createGalleryCtrl = this.$componentController('createGallery', null); + + createGalleryCtrl.gallery = exampleGallery; + expect(createGalleryCtrl.gallery.name).toEqual(exampleGallery.name); + expect(createGalleryCtrl.gallery.desc).toEqual(exampleGallery.desc); + createGalleryCtrl.createGallery(); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }) + }) +}) \ No newline at end of file diff --git a/lab-brae/test/edit-gallery-component-test.js b/lab-brae/test/edit-gallery-component-test.js new file mode 100644 index 00000000..3e2857ed --- /dev/null +++ b/lab-brae/test/edit-gallery-component-test.js @@ -0,0 +1,65 @@ +'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.authService = authService; + }); + }); + + it('should contain the proper 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 = 'http://localhost:8000/api/gallery/12345'; + let headers = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPUT(url, { + _id: '12345', + name: 'updated name', + desc: 'updated description' + }, headers).respond(200); + + let mockBindings = { + gallery: { + _id: '12345', + name: 'updated name', + desc: 'updated description' + } + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + editGalleryCtrl.gallery.name = 'updated name'; + editGalleryCtrl.gallery.desc = 'updated description'; + editGalleryCtrl.updateGallery(); + + expect(editGalleryCtrl.gallery._id).toEqual(mockBindings.gallery._id); + expect(editGalleryCtrl.gallery.name).toEqual(mockBindings.gallery.name); + expect(editGalleryCtrl.gallery.desc).toEqual(mockBindings.gallery.desc); + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); +}); \ No newline at end of file diff --git a/lab-brae/test/gallery-item-component-test.js b/lab-brae/test/gallery-item-component-test.js new file mode 100644 index 00000000..dd608687 --- /dev/null +++ b/lab-brae/test/gallery-item-component-test.js @@ -0,0 +1,64 @@ +'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: '12345', + name: 'test name', + desc: 'test description', + pics: [] + }, + deleteDone: function(data){ + expect(data.galleryData._id).toEqual('12345'); + } + }; + + let galleryItemCtrl = this.$componentController('galleryItem', null, mockBindings); + galleryItemCtrl.deleteDone({ + galleryData: galleryItemCtrl.gallery + }); + + this.$rootScope.$apply(); + }); + }); + + it('should call deleteDone with gallery after galleryDelete', () => { + let url = `${__API_URL__}/api/gallery/12345`; + let headers = { + Authorization: 'Bearer test token', + Accept: 'application/json, text/plain, */*' + }; + + let mockBindings = { + gallery: { + _id: '12345', + name: 'test name', + desc: 'test description', + pics: [] + }, + deleteDone: function(data){ + expect(data.galleryData._id).toEqual(mockBindings.gallery._id); + } + }; + + this.$httpBackend.expectDELETE(url, headers).respond(204); + + let galleryItemCtrl = this.$componentController('galleryItem', null, mockBindings); + galleryItemCtrl.deleteGallery(); + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); +}); \ No newline at end of file diff --git a/lab-brae/test/gallery-service-test.js b/lab-brae/test/gallery-service-test.js index 7eeba3ee..d9113217 100644 --- a/lab-brae/test/gallery-service-test.js +++ b/lab-brae/test/gallery-service-test.js @@ -26,7 +26,7 @@ describe('Gallery Service', function() { Authorization: 'Bearer test token' }; - this.$httpBackend.expectPOST('http://localhost:8000/api/gallery', galleryData, headers) + this.$httpBackend.expectPOST(`${__API_URL__}/api/gallery`, galleryData, headers) .respond(200, { _id: '1234', username: 'testuser', @@ -49,7 +49,7 @@ describe('Gallery Service', function() { Accept: 'application/json, text/plain, */*' }; - this.$httpBackend.expectDELETE('http://localhost:8000/api/gallery/testingID', headers) + this.$httpBackend.expectDELETE(`${__API_URL__}/api/gallery/testingID`, headers) .respond(204); this.galleryService.deleteGallery(galleryID); From a401c720f5ade17d0d4522c728cee2bef05c8448 Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Wed, 5 Apr 2017 23:34:43 -0700 Subject: [PATCH 13/15] styling --- .../app/component/landing/login/_login.scss | 13 +++++++ lab-brae/app/scss/lib/base/_base.scss | 36 +++++++++++++++++++ lab-brae/app/scss/lib/layout/_content.scss | 3 ++ lab-brae/app/scss/lib/layout/_footer.scss | 1 + lab-brae/app/scss/main.scss | 5 +++ lab-brae/app/view/landing/_landing.scss | 17 +++++++++ 6 files changed, 75 insertions(+) diff --git a/lab-brae/app/component/landing/login/_login.scss b/lab-brae/app/component/landing/login/_login.scss index e69de29b..8d08f751 100644 --- a/lab-brae/app/component/landing/login/_login.scss +++ b/lab-brae/app/component/landing/login/_login.scss @@ -0,0 +1,13 @@ +@import "../../../scss/lib/theme/vars"; + +.signup { + .input-std { + margin-bottom: 2.5%; + } + + button { + float: right; + padding-top: 1.5vw; + padding-bottom: 1.5vw; + } +} diff --git a/lab-brae/app/scss/lib/base/_base.scss b/lab-brae/app/scss/lib/base/_base.scss index 6af218b8..01b77d55 100644 --- a/lab-brae/app/scss/lib/base/_base.scss +++ b/lab-brae/app/scss/lib/base/_base.scss @@ -1,5 +1,10 @@ @import '../theme/vars'; +html, body { + width: 100%; + height: 100%; +} + button { border: none; border-radius: 3px; @@ -11,4 +16,35 @@ button { a { text-decoration: none; +} + +input[type="text"] { + width: 100%; + padding: 1.5vw 2vw; + font-size: 2vw; + border: solid 1px $brand-primary; + border-radius: 3px; + box-sizing: border-box; + + a:focus { + background: $brand-primary; + color: $white; + } +} + +input[type="password"] { + @extend input[type="text"]; +} + +input[disabled="disabled"] { + background: #e3e3e3; +} + +.input-std { + @extend input[type="text"]; + display: inline-block; +} + +fieldset { + margin: 2% 0; } \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_content.scss b/lab-brae/app/scss/lib/layout/_content.scss index 4eadaac1..ebb3b596 100644 --- a/lab-brae/app/scss/lib/layout/_content.scss +++ b/lab-brae/app/scss/lib/layout/_content.scss @@ -2,4 +2,7 @@ main { background: $brand-primary; + width: 90%; + margin: 5%; + min-height: 600px; } \ No newline at end of file diff --git a/lab-brae/app/scss/lib/layout/_footer.scss b/lab-brae/app/scss/lib/layout/_footer.scss index e106e26d..14303680 100644 --- a/lab-brae/app/scss/lib/layout/_footer.scss +++ b/lab-brae/app/scss/lib/layout/_footer.scss @@ -5,4 +5,5 @@ footer { font-family: Helvetica; color: $white; height: 8vw; + margin-top: $gutter-std * 2; } \ No newline at end of file diff --git a/lab-brae/app/scss/main.scss b/lab-brae/app/scss/main.scss index 4db5a236..3404ae12 100644 --- a/lab-brae/app/scss/main.scss +++ b/lab-brae/app/scss/main.scss @@ -18,4 +18,9 @@ @import '/../component/gallery/create-gallery/create-gallery'; @import '/../component/gallery/edit-gallery/edit-gallery'; @import '/../component/gallery/gallery-item/gallery-item'; +@import '/../component/gallery/thumbnail-container/thumbnail-container'; +@import '/../component/gallery/thumbnail/thumbnail'; +@import '/../component/gallery/upload-pic/upload-pic'; + + diff --git a/lab-brae/app/view/landing/_landing.scss b/lab-brae/app/view/landing/_landing.scss index e69de29b..32bd1dfb 100644 --- a/lab-brae/app/view/landing/_landing.scss +++ b/lab-brae/app/view/landing/_landing.scss @@ -0,0 +1,17 @@ +@import "../../scss/lib/theme/vars"; + +.join-inner { + div:last-child { + margin-top: 1.75vw; + text-align: right; + font-size: 2vw; + p { + display: inline; + margin-right: 1vw; + } + + a { + margin-right: 1.5vw; + } + } +} \ No newline at end of file From 0c5da18c71cb8296f847ace1478784ec325bdf7e Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Thu, 6 Apr 2017 13:05:24 -0700 Subject: [PATCH 14/15] fuzzy search and social icons setup --- lab-brae/app/directive/social-icons.html | 9 +++++++++ lab-brae/app/directive/social-icons.js | 19 +++++++++++++++++++ lab-brae/app/entry.js | 14 ++++++++++++++ lab-brae/app/filter/gallery-search.js | 17 +++++++++++++++++ lab-brae/app/index.html | 4 +++- lab-brae/app/view/home/home.html | 22 +++++++++++++--------- 6 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 lab-brae/app/directive/social-icons.html create mode 100644 lab-brae/app/directive/social-icons.js create mode 100644 lab-brae/app/filter/gallery-search.js diff --git a/lab-brae/app/directive/social-icons.html b/lab-brae/app/directive/social-icons.html new file mode 100644 index 00000000..b8c25dae --- /dev/null +++ b/lab-brae/app/directive/social-icons.html @@ -0,0 +1,9 @@ + diff --git a/lab-brae/app/directive/social-icons.js b/lab-brae/app/directive/social-icons.js new file mode 100644 index 00000000..3c7d47c5 --- /dev/null +++ b/lab-brae/app/directive/social-icons.js @@ -0,0 +1,19 @@ +'use strict'; + +module.exports = function() { + return { + restrict: 'EAC', + template: require('./social-icons.html'), + controller: ['$log', SocialIconsController], + bindToController: true, + controllerAs: 'socialIconsCtrl', + scope: { + tester: '@' + } + }; +}; + +function SocialIconsController() { + this.icons = ['fb', 'twitter', 'instagram']; +}; + diff --git a/lab-brae/app/entry.js b/lab-brae/app/entry.js index c0eac06e..b48b3553 100644 --- a/lab-brae/app/entry.js +++ b/lab-brae/app/entry.js @@ -37,4 +37,18 @@ context.keys().forEach( key => { let name = camelcase(path.basename(key, '.js')); 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); }); \ No newline at end of file diff --git a/lab-brae/app/filter/gallery-search.js b/lab-brae/app/filter/gallery-search.js new file mode 100644 index 00000000..66a89f5f --- /dev/null +++ b/lab-brae/app/filter/gallery-search.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function() { + return function(gallery, searchTerm) { + let fuzzyRegex = generateFuzzyRegex(searchTerm); + + return gallery.filter( gallery => { + return fuzzyRegex.test(gallery.name.toUpperCase()); + }); + }; +}; + +function generateFuzzyRegex(input) { + if (!input) return /.*/; + let fuzzyString = '.*' + input.toUpperCase().split('').join('.*') + '.*'; + return new RegExp(fuzzyString); +}; \ No newline at end of file diff --git a/lab-brae/app/index.html b/lab-brae/app/index.html index 888b80d0..b1ac4d73 100644 --- a/lab-brae/app/index.html +++ b/lab-brae/app/index.html @@ -14,6 +14,8 @@ -
+
+ +
diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index fc70d6d3..f6637658 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -1,14 +1,18 @@
- -
    - -
+ + + +
From 94129d7e37f204f3e566745a4fd7e56cc06e018e Mon Sep 17 00:00:00 2001 From: 0blu3 Date: Thu, 6 Apr 2017 23:03:39 -0700 Subject: [PATCH 15/15] giving up on social icons for now --- .../create-gallery/create-gallery.html | 7 +++--- lab-brae/app/directive/_social-icons.scss | 19 +++++++++++++++ lab-brae/app/directive/social-icons.html | 4 +--- lab-brae/app/directive/social-icons.js | 4 +++- lab-brae/app/scss/lib/layout/_footer.scss | 23 +++++++++++++++++++ lab-brae/app/scss/main.scss | 1 + lab-brae/app/view/home/home.html | 2 +- 7 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 lab-brae/app/directive/_social-icons.scss diff --git a/lab-brae/app/component/gallery/create-gallery/create-gallery.html b/lab-brae/app/component/gallery/create-gallery/create-gallery.html index bf4bba09..dd4dc8b7 100644 --- a/lab-brae/app/component/gallery/create-gallery/create-gallery.html +++ b/lab-brae/app/component/gallery/create-gallery/create-gallery.html @@ -3,16 +3,15 @@ class="gallery-form" ng-submit="createGalleryCtrl.createGallery()"> +

Create a new gallery.

- + ng-model="createGalleryCtrl.gallery.name" required placeholder="gallery name">
- + ng-model="createGalleryCtrl.gallery.desc" required placeholder="gallery description">
diff --git a/lab-brae/app/directive/_social-icons.scss b/lab-brae/app/directive/_social-icons.scss new file mode 100644 index 00000000..a40063be --- /dev/null +++ b/lab-brae/app/directive/_social-icons.scss @@ -0,0 +1,19 @@ + + +.social-icon-facebook { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -36px -27px; + width: 128px; + height: 128px; + } + + .social-icon-twitter { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -436px -27px; + width: 128px; + height: 128px; + } + + .social-icon-instagram { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -636px -27px; + width: 128px; + height: 128px; + } diff --git a/lab-brae/app/directive/social-icons.html b/lab-brae/app/directive/social-icons.html index b8c25dae..73190466 100644 --- a/lab-brae/app/directive/social-icons.html +++ b/lab-brae/app/directive/social-icons.html @@ -2,8 +2,6 @@

{{ socialIconsCtrl.tester }}

    - +
diff --git a/lab-brae/app/directive/social-icons.js b/lab-brae/app/directive/social-icons.js index 3c7d47c5..c76ddc87 100644 --- a/lab-brae/app/directive/social-icons.js +++ b/lab-brae/app/directive/social-icons.js @@ -1,5 +1,7 @@ 'use strict'; +require('./_social-icons.scss') + module.exports = function() { return { restrict: 'EAC', @@ -14,6 +16,6 @@ module.exports = function() { }; function SocialIconsController() { - this.icons = ['fb', 'twitter', 'instagram']; + this.icons = ['facebook', 'twitter', 'instagram']; }; diff --git a/lab-brae/app/scss/lib/layout/_footer.scss b/lab-brae/app/scss/lib/layout/_footer.scss index 14303680..59dfe795 100644 --- a/lab-brae/app/scss/lib/layout/_footer.scss +++ b/lab-brae/app/scss/lib/layout/_footer.scss @@ -6,4 +6,27 @@ footer { color: $white; height: 8vw; margin-top: $gutter-std * 2; +} + +.social-icon { + li { + .sprite-facebook { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -36px -27px; + width: 128px; + height: 128px; + } + + + .sprite-twitter { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -436px -27px; + width: 128px; + height: 128px; + } + + .sprite-instagram { + background: url('https://s3-us-west-2.amazonaws.com/slugtestbucket/social-icons-sprite-sheet.png') no-repeat -636px -27px; + width: 128px; + height: 128px; + } + } } \ No newline at end of file diff --git a/lab-brae/app/scss/main.scss b/lab-brae/app/scss/main.scss index 3404ae12..d01d80b9 100644 --- a/lab-brae/app/scss/main.scss +++ b/lab-brae/app/scss/main.scss @@ -21,6 +21,7 @@ @import '/../component/gallery/thumbnail-container/thumbnail-container'; @import '/../component/gallery/thumbnail/thumbnail'; @import '/../component/gallery/upload-pic/upload-pic'; +@import '/../directive/social-icons'; diff --git a/lab-brae/app/view/home/home.html b/lab-brae/app/view/home/home.html index f6637658..ced10903 100644 --- a/lab-brae/app/view/home/home.html +++ b/lab-brae/app/view/home/home.html @@ -6,7 +6,7 @@