From aa21c295b42c6e4fb2377da82a24b9b0ba263dc5 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 28 Mar 2017 13:53:40 -0700 Subject: [PATCH 01/29] basic filestructure in place, dependencies installed, contents of webpack config, karma config, and env files added --- lab-yana/.babelrc | 1 + lab-yana/.env | 1 + lab-yana/.eslintrc | 21 +++ lab-yana/.gitignore | 120 ++++++++++++++++++ lab-yana/app/component/login/_login.scss | 0 lab-yana/app/component/login/login.html | 0 lab-yana/app/component/login/login.js | 0 lab-yana/app/component/signup/_signup.scss | 0 lab-yana/app/component/signup/signup.html | 0 lab-yana/app/component/signup/signup.js | 0 lab-yana/app/config/router-config.js | 0 lab-yana/app/entry.js | 0 lab-yana/app/index.html | 0 lab-yana/app/scss/lib/base/_base.scss | 0 lab-yana/app/scss/lib/base/_reset.scss | 0 lab-yana/app/scss/lib/layout/_layout.scss | 0 lab-yana/app/scss/lib/theme/_vars.scss | 0 lab-yana/app/scss/main.scss | 0 lab-yana/app/service/auth-service.js | 0 lab-yana/app/view/home/_home.scss | 0 lab-yana/app/view/home/home-controller.js | 0 lab-yana/app/view/home/home.html | 0 lab-yana/app/view/landing/_landing.scss | 0 .../app/view/landing/landing-controller.js | 0 lab-yana/app/view/landing/landing.html | 0 lab-yana/karma.config.js | 76 +++++++++++ lab-yana/package.json | 46 +++++++ lab-yana/webpack.config.js | 38 ++++++ 28 files changed, 303 insertions(+) create mode 100644 lab-yana/.babelrc create mode 100644 lab-yana/.env create mode 100644 lab-yana/.eslintrc create mode 100644 lab-yana/.gitignore create mode 100644 lab-yana/app/component/login/_login.scss create mode 100644 lab-yana/app/component/login/login.html create mode 100644 lab-yana/app/component/login/login.js create mode 100644 lab-yana/app/component/signup/_signup.scss create mode 100644 lab-yana/app/component/signup/signup.html create mode 100644 lab-yana/app/component/signup/signup.js create mode 100644 lab-yana/app/config/router-config.js create mode 100644 lab-yana/app/entry.js create mode 100644 lab-yana/app/index.html create mode 100644 lab-yana/app/scss/lib/base/_base.scss create mode 100644 lab-yana/app/scss/lib/base/_reset.scss create mode 100644 lab-yana/app/scss/lib/layout/_layout.scss create mode 100644 lab-yana/app/scss/lib/theme/_vars.scss create mode 100644 lab-yana/app/scss/main.scss create mode 100644 lab-yana/app/service/auth-service.js create mode 100644 lab-yana/app/view/home/_home.scss create mode 100644 lab-yana/app/view/home/home-controller.js create mode 100644 lab-yana/app/view/home/home.html create mode 100644 lab-yana/app/view/landing/_landing.scss create mode 100644 lab-yana/app/view/landing/landing-controller.js create mode 100644 lab-yana/app/view/landing/landing.html create mode 100644 lab-yana/karma.config.js create mode 100644 lab-yana/package.json create mode 100644 lab-yana/webpack.config.js diff --git a/lab-yana/.babelrc b/lab-yana/.babelrc new file mode 100644 index 00000000..9d8d5165 --- /dev/null +++ b/lab-yana/.babelrc @@ -0,0 +1 @@ +{ "presets": ["es2015"] } diff --git a/lab-yana/.env b/lab-yana/.env new file mode 100644 index 00000000..c1e5f310 --- /dev/null +++ b/lab-yana/.env @@ -0,0 +1 @@ +API_URL='https://slugram-backend.herokuapp.com' diff --git a/lab-yana/.eslintrc b/lab-yana/.eslintrc new file mode 100644 index 00000000..8dc68078 --- /dev/null +++ b/lab-yana/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/lab-yana/.gitignore b/lab-yana/.gitignore new file mode 100644 index 00000000..20155648 --- /dev/null +++ b/lab-yana/.gitignore @@ -0,0 +1,120 @@ +# Created by https://www.gitignore.io/api/node,vim,osx,macos,linux + +*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 + +# ignore angular build directory +build + +# 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 + + + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### macOS ### +# Icon must end with two \r +# Thumbnails +# Files that might appear in the root of a volume +# Directories potentially created on remote AFP share + + +### 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* + +# End of https://www.gitignore.io/api/node,vim,osx,macos,linux diff --git a/lab-yana/app/component/login/_login.scss b/lab-yana/app/component/login/_login.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/login/login.html b/lab-yana/app/component/login/login.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/login/login.js b/lab-yana/app/component/login/login.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/signup/_signup.scss b/lab-yana/app/component/signup/_signup.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/signup/signup.html b/lab-yana/app/component/signup/signup.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/signup/signup.js b/lab-yana/app/component/signup/signup.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/config/router-config.js b/lab-yana/app/config/router-config.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/scss/lib/base/_base.scss b/lab-yana/app/scss/lib/base/_base.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/scss/lib/base/_reset.scss b/lab-yana/app/scss/lib/base/_reset.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/scss/lib/layout/_layout.scss b/lab-yana/app/scss/lib/layout/_layout.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/scss/lib/theme/_vars.scss b/lab-yana/app/scss/lib/theme/_vars.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/scss/main.scss b/lab-yana/app/scss/main.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/service/auth-service.js b/lab-yana/app/service/auth-service.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/home/_home.scss b/lab-yana/app/view/home/_home.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/landing/_landing.scss b/lab-yana/app/view/landing/_landing.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/landing/landing-controller.js b/lab-yana/app/view/landing/landing-controller.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/view/landing/landing.html b/lab-yana/app/view/landing/landing.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/karma.config.js b/lab-yana/karma.config.js new file mode 100644 index 00000000..b8f5ca3e --- /dev/null +++ b/lab-yana/karma.config.js @@ -0,0 +1,76 @@ +// Karma configuration +// Generated on Wed Mar 22 2017 12:51:00 GMT-0700 (PDT) + +const webpackConfig = require('./webpack.config.js'); +webpackConfig.entry = {}; + +module.exports = function(config) { + config.set({ + + // to wire to webpack + webpack: webpackConfig, + + // 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: [ + 'test/**/*-test.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'] + }, + + + // 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: ['PhantomJS'], + + + // 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-yana/package.json b/lab-yana/package.json new file mode 100644 index 00000000..70a0295b --- /dev/null +++ b/lab-yana/package.json @@ -0,0 +1,46 @@ +{ + "name": "lab-yana", + "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", + "lint": "./node_modules/eslint/bin/eslint.js */*.js", + "test": "./node_modules/karma/bin/karma start --single-run", + "test-watch": "./node_modules/karma/bin/karma start" + }, + "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", + "eslint": "^3.18.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/lab-yana/webpack.config.js b/lab-yana/webpack.config.js new file mode 100644 index 00000000..377e7be4 --- /dev/null +++ b/lab-yana/webpack.config.js @@ -0,0 +1,38 @@ +'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 434cf67cf2cf5a0644eb94a172c498c971a24a08 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 28 Mar 2017 14:03:50 -0700 Subject: [PATCH 02/29] added index.html skeleton and contents to entry.js --- lab-yana/app/entry.js | 37 +++++++++++++++++++++++++++++++++++++ lab-yana/app/index.html | 19 +++++++++++++++++++ lab-yana/app/scss/main.scss | 3 +++ 3 files changed, 59 insertions(+) diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js index e69de29b..dce3e120 100644 --- a/lab-yana/app/entry.js +++ b/lab-yana/app/entry.js @@ -0,0 +1,37 @@ +'use strict'; + +require('./scss/main.scss'); + +const path = require('path'); +const angular = require('angular'); +const pascalcase = require('pascalcase'); +const camelcase = require('camelcase'); +const uiRouter = require('angular-ui-router'); +const ngTouch = require('angular-touch'); +const ngAnimate = require('angular-animate'); + +const 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.controller(name, module); +}); + +context = require.context('./component/', true, /\.js$/), +context.keys().forEach(key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.controller(name, module); +}); diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html index e69de29b..e1a1a009 100644 --- a/lab-yana/app/index.html +++ b/lab-yana/app/index.html @@ -0,0 +1,19 @@ + + + + + + cfgram<title> + </head> + <body> + <header> + + </header> + <main> + <ui-view><ui-view> + </main> + <footer> + + </footer> + </body> +</html> diff --git a/lab-yana/app/scss/main.scss b/lab-yana/app/scss/main.scss index e69de29b..87de0008 100644 --- a/lab-yana/app/scss/main.scss +++ b/lab-yana/app/scss/main.scss @@ -0,0 +1,3 @@ +body { + background-color: yellow; +} From b5fa06ebef62041b6f598f0c7f8f9179bfd34bf9 Mon Sep 17 00:00:00 2001 From: radenska <yana_radenska@yahoo.com> Date: Tue, 28 Mar 2017 14:24:12 -0700 Subject: [PATCH 03/29] added content to landing and home views, no styling yet --- lab-yana/app/config/router-config.js | 28 +++++++++++++++++++ lab-yana/app/view/home/_home.scss | 3 ++ lab-yana/app/view/home/home-controller.js | 9 ++++++ lab-yana/app/view/home/home.html | 3 ++ lab-yana/app/view/landing/_landing.scss | 3 ++ .../app/view/landing/landing-controller.js | 12 ++++++++ lab-yana/app/view/landing/landing.html | 16 +++++++++++ 7 files changed, 74 insertions(+) diff --git a/lab-yana/app/config/router-config.js b/lab-yana/app/config/router-config.js index e69de29b..f7e5188d 100644 --- a/lab-yana/app/config/router-config.js +++ b/lab-yana/app/config/router-config.js @@ -0,0 +1,28 @@ +'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/lab-yana/app/view/home/_home.scss b/lab-yana/app/view/home/_home.scss index e69de29b..6679000d 100644 --- a/lab-yana/app/view/home/_home.scss +++ b/lab-yana/app/view/home/_home.scss @@ -0,0 +1,3 @@ +.home { + color: red; +} diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index e69de29b..dd9d54bf 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/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/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index e69de29b..01825f80 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -0,0 +1,3 @@ +<section class="home"> + <h2>Home Sweet Home</h2> +</section> diff --git a/lab-yana/app/view/landing/_landing.scss b/lab-yana/app/view/landing/_landing.scss index e69de29b..e4d0a421 100644 --- a/lab-yana/app/view/landing/_landing.scss +++ b/lab-yana/app/view/landing/_landing.scss @@ -0,0 +1,3 @@ +.landing { + color: green; +} diff --git a/lab-yana/app/view/landing/landing-controller.js b/lab-yana/app/view/landing/landing-controller.js index e69de29b..bade1abf 100644 --- a/lab-yana/app/view/landing/landing-controller.js +++ b/lab-yana/app/view/landing/landing-controller.js @@ -0,0 +1,12 @@ +'use strict'; + +require('./_landing.scss'); + +module.exports = ['$log', '$location', '$rootScope', 'authService', LandingController]; + +function LandingController($log, $location, authService) { + $log.debug('LandingController'); + + let url = $location.url(); + this.showSignup = url === '/join#signup' || url === '/join'; +} diff --git a/lab-yana/app/view/landing/landing.html b/lab-yana/app/view/landing/landing.html index e69de29b..80dcd088 100644 --- a/lab-yana/app/view/landing/landing.html +++ b/lab-yana/app/view/landing/landing.html @@ -0,0 +1,16 @@ +<section class="landing"> + <div class="join-container" ng-if="landingCtrl.showSignup"> + <div class="join-inner"> + <signup></signup> + <p>already a member?</p> + <a href="/#/join#login">sign in here</a> + </div> + </div> + <div class="join-container" ng-if="!landingCtrl.showSignup"> + <div class="join-inner"> + <login></login> + <p>want to sign up?</p> + <a href="/#/join#signup" ng-click="landingCtrl.showSignup=true">sign up here</a> + </div> + </div> +</section> From 9dfd2e3adcfc942a5362e91d8fbeec2b3c9b1703 Mon Sep 17 00:00:00 2001 From: radenska <yana_radenska@yahoo.com> Date: Tue, 28 Mar 2017 14:54:39 -0700 Subject: [PATCH 04/29] added auth service content --- lab-yana/app/service/auth-service.js | 80 ++++++++++++++++++++++++++++ lab-yana/karma.config.js | 4 +- lab-yana/package.json | 2 +- 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/lab-yana/app/service/auth-service.js b/lab-yana/app/service/auth-service.js index e69de29b..e1c35236 100644 --- a/lab-yana/app/service/auth-service.js +++ b/lab-yana/app/service/auth-service.js @@ -0,0 +1,80 @@ +'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); //if there is already a token, don't bother with the rest of the function + token = $window.localStorage.getItem('token'); //find the token variable in local storage + if (token) return $q.resolve(token); //return the token found + return $q.reject(new Error('token not found')); //in case there is no token var in local storage + }; + + 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(response => { + $log.log('success: ', response.data); + return setToken(response.data); + }) + .catch(err => { + $log.error('failure: ', err.message); + return $q.reject(new Error('signup failed')); + }); + }; + + 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(response => { + $log.log('success', response.data); + return setToken(response.data); + }) + .catch(err => { + $log.error('failure', err.message); + return $q.reject(new Error('login failed')); + }); + }; + service.logout = function() { + $log.debug('authService.logout'); + + $window.localStorage.removeItem('token'); + token = null; + return $q.resolve(); + }; + return service; +} diff --git a/lab-yana/karma.config.js b/lab-yana/karma.config.js index b8f5ca3e..3ae9469c 100644 --- a/lab-yana/karma.config.js +++ b/lab-yana/karma.config.js @@ -72,5 +72,5 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous concurrency: Infinity - }) -} + }); +}; diff --git a/lab-yana/package.json b/lab-yana/package.json index 70a0295b..a2b8a73e 100644 --- a/lab-yana/package.json +++ b/lab-yana/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "./node_modules/webpack/bin/webpack.js", "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", - "lint": "./node_modules/eslint/bin/eslint.js */*.js", + "lint": "./node_modules/eslint/bin/eslint.js ./**/*.js", "test": "./node_modules/karma/bin/karma start --single-run", "test-watch": "./node_modules/karma/bin/karma start" }, From c248d91bdcef6350681cafd69f096a6f32074041 Mon Sep 17 00:00:00 2001 From: radenska <yana_radenska@yahoo.com> Date: Tue, 28 Mar 2017 15:17:33 -0700 Subject: [PATCH 05/29] added content to both login and signup components, no styling --- lab-yana/app/component/login/_login.scss | 3 +++ lab-yana/app/component/login/login.html | 25 ++++++++++++++++++++++ lab-yana/app/component/login/login.js | 23 ++++++++++++++++++++ lab-yana/app/component/signup/_signup.scss | 3 +++ lab-yana/app/component/signup/signup.html | 19 ++++++++++++++++ lab-yana/app/component/signup/signup.js | 23 ++++++++++++++++++++ lab-yana/package.json | 2 +- 7 files changed, 97 insertions(+), 1 deletion(-) diff --git a/lab-yana/app/component/login/_login.scss b/lab-yana/app/component/login/_login.scss index e69de29b..01f5394a 100644 --- a/lab-yana/app/component/login/_login.scss +++ b/lab-yana/app/component/login/_login.scss @@ -0,0 +1,3 @@ +.login { + background-color: orange; +} diff --git a/lab-yana/app/component/login/login.html b/lab-yana/app/component/login/login.html index e69de29b..7fea1055 100644 --- a/lab-yana/app/component/login/login.html +++ b/lab-yana/app/component/login/login.html @@ -0,0 +1,25 @@ +<section class="login"> + <form name="loginForm" ng-submit="loginCtrl.login()" novalidate> + <div ng-class="{ + 'error': loginForm.username.$invalid, + 'success': loginForm.username.$valid + }"> + <input type="text" + name="username" + placeholder="username" + ng-minlength="6" + ng-model="loginCtrl.user.username" required> + </div> + <div ng-class="{ + 'error': loginForm.password.$invalid, + 'success': loginForm.password.$valid + }"> + <input type="password" + name="password" + placeholder="password" + ng-minlength="6" + ng-model="loginCtrl.user.password" required> + </div> + <button class="btn-std">sign in</button> + </form> +</section> diff --git a/lab-yana/app/component/login/login.js b/lab-yana/app/component/login/login.js index e69de29b..74e2d31f 100644 --- a/lab-yana/app/component/login/login.js +++ b/lab-yana/app/component/login/login.js @@ -0,0 +1,23 @@ +'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('LoginController.login'); + + authService.login(this.user) + .then( () => $location.url('/home')); + }; +} diff --git a/lab-yana/app/component/signup/_signup.scss b/lab-yana/app/component/signup/_signup.scss index e69de29b..2a2badf6 100644 --- a/lab-yana/app/component/signup/_signup.scss +++ b/lab-yana/app/component/signup/_signup.scss @@ -0,0 +1,3 @@ +.signup { + background-color: blue; +} diff --git a/lab-yana/app/component/signup/signup.html b/lab-yana/app/component/signup/signup.html index e69de29b..34cdb98a 100644 --- a/lab-yana/app/component/signup/signup.html +++ b/lab-yana/app/component/signup/signup.html @@ -0,0 +1,19 @@ +<section class="signup"> + <form class="signup-form" ng-submit="signupCtrl.sigup(signupCtrl.user)" novalidate> + <input class="input-std" + type="text" + placeholder="username" + ng-minlength="6" + ng-model="signupCtrl.user.username" required> + <input class="input-std" + type="email" + placeholder="email" + ng-model="signupCtrl.user.email"> + <input class="input-std" + type="password" + placeholder="password" + ng-minlength="6" + ng-model="signupCtrl.user.password" required> + <button class="btn-std">sign up</button> + </form> +</section> diff --git a/lab-yana/app/component/signup/signup.js b/lab-yana/app/component/signup/signup.js index e69de29b..ab8c7305 100644 --- a/lab-yana/app/component/signup/signup.js +++ b/lab-yana/app/component/signup/signup.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./_signup.scss'); + +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('SignupController.signup'); + + authService.sigup(user) + .then( () => $location.url('/home')); + }; +} diff --git a/lab-yana/package.json b/lab-yana/package.json index a2b8a73e..b187cb3d 100644 --- a/lab-yana/package.json +++ b/lab-yana/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "./node_modules/webpack/bin/webpack.js", "watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", - "lint": "./node_modules/eslint/bin/eslint.js ./**/*.js", + "lint": "./node_modules/eslint/bin/eslint.js **/*.js", "test": "./node_modules/karma/bin/karma start --single-run", "test-watch": "./node_modules/karma/bin/karma start" }, From 4d8e72a22b09216b81562ad01fc1e072591fa969 Mon Sep 17 00:00:00 2001 From: radenska <yana_radenska@yahoo.com> Date: Tue, 28 Mar 2017 20:41:42 -0700 Subject: [PATCH 06/29] debbuged, now functional (still no styling) --- lab-yana/app/component/login/login.html | 5 ++- lab-yana/app/component/login/login.js | 2 +- lab-yana/app/component/signup/signup.html | 6 ++- lab-yana/app/component/signup/signup.js | 4 +- lab-yana/app/entry.js | 4 +- lab-yana/app/index.html | 2 +- lab-yana/app/scss/lib/base/_base.scss | 1 + lab-yana/app/scss/lib/base/_reset.scss | 48 +++++++++++++++++++++++ lab-yana/app/scss/lib/layout/_layout.scss | 1 + lab-yana/app/scss/main.scss | 4 ++ lab-yana/app/service/auth-service.js | 5 ++- lab-yana/app/view/landing/landing.html | 2 +- 12 files changed, 71 insertions(+), 13 deletions(-) diff --git a/lab-yana/app/component/login/login.html b/lab-yana/app/component/login/login.html index 7fea1055..0b66e13d 100644 --- a/lab-yana/app/component/login/login.html +++ b/lab-yana/app/component/login/login.html @@ -11,13 +11,14 @@ ng-model="loginCtrl.user.username" required> </div> <div ng-class="{ - 'error': loginForm.password.$invalid, + 'error': loginForm.password.$invalid && loginForm.$submitted, 'success': loginForm.password.$valid }"> <input type="password" name="password" + ng-disabled="loginForm.username.$invalid" placeholder="password" - ng-minlength="6" + ng-minlength="8" ng-model="loginCtrl.user.password" required> </div> <button class="btn-std">sign in</button> diff --git a/lab-yana/app/component/login/login.js b/lab-yana/app/component/login/login.js index 74e2d31f..a46719fb 100644 --- a/lab-yana/app/component/login/login.js +++ b/lab-yana/app/component/login/login.js @@ -1,6 +1,6 @@ 'use strict'; -require('./_login/scss'); +require('./_login.scss'); module.exports = { template: require('./login.html'), diff --git a/lab-yana/app/component/signup/signup.html b/lab-yana/app/component/signup/signup.html index 34cdb98a..e34e0d06 100644 --- a/lab-yana/app/component/signup/signup.html +++ b/lab-yana/app/component/signup/signup.html @@ -1,5 +1,7 @@ <section class="signup"> - <form class="signup-form" ng-submit="signupCtrl.sigup(signupCtrl.user)" novalidate> + <form class="signup-form" + ng-submit="signupCtrl.signup(signupCtrl.user)" + novalidate> <input class="input-std" type="text" placeholder="username" @@ -12,7 +14,7 @@ <input class="input-std" type="password" placeholder="password" - ng-minlength="6" + ng-minlength="8" ng-model="signupCtrl.user.password" required> <button class="btn-std">sign up</button> </form> diff --git a/lab-yana/app/component/signup/signup.js b/lab-yana/app/component/signup/signup.js index ab8c7305..27853b91 100644 --- a/lab-yana/app/component/signup/signup.js +++ b/lab-yana/app/component/signup/signup.js @@ -12,12 +12,12 @@ function SignupController($log, $location, authService) { $log.debug('SignupController'); authService.getToken() - .then( () => $location.url('/home')); + .then( () => { $location.url('/home') }); this.signup = function(user) { $log.debug('SignupController.signup'); - authService.sigup(user) + authService.signup(user) .then( () => $location.url('/home')); }; } diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js index dce3e120..e27ae570 100644 --- a/lab-yana/app/entry.js +++ b/lab-yana/app/entry.js @@ -26,12 +26,12 @@ context = require.context('./service/', true, /\.js$/), context.keys().forEach(key => { let name = camelcase(path.basename(key, '.js')); let module = context(key); - cfgram.controller(name, module); + 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.controller(name, module); + cfgram.component(name, module); }); diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html index e1a1a009..6a0a91bf 100644 --- a/lab-yana/app/index.html +++ b/lab-yana/app/index.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>cfgram<title> + <title>cfgram
diff --git a/lab-yana/app/scss/lib/base/_base.scss b/lab-yana/app/scss/lib/base/_base.scss index e69de29b..e420b626 100644 --- a/lab-yana/app/scss/lib/base/_base.scss +++ b/lab-yana/app/scss/lib/base/_base.scss @@ -0,0 +1 @@ +@import '../theme/_vars.scss'; diff --git a/lab-yana/app/scss/lib/base/_reset.scss b/lab-yana/app/scss/lib/base/_reset.scss index e69de29b..ed11813c 100644 --- a/lab-yana/app/scss/lib/base/_reset.scss +++ b/lab-yana/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/lab-yana/app/scss/lib/layout/_layout.scss b/lab-yana/app/scss/lib/layout/_layout.scss index e69de29b..e420b626 100644 --- a/lab-yana/app/scss/lib/layout/_layout.scss +++ b/lab-yana/app/scss/lib/layout/_layout.scss @@ -0,0 +1 @@ +@import '../theme/_vars.scss'; diff --git a/lab-yana/app/scss/main.scss b/lab-yana/app/scss/main.scss index 87de0008..4da60e97 100644 --- a/lab-yana/app/scss/main.scss +++ b/lab-yana/app/scss/main.scss @@ -1,3 +1,7 @@ +@import './lib/base/_reset.scss'; +@import './lib/base/_base.scss'; +@import './lib/layout/_layout.scss'; + body { background-color: yellow; } diff --git a/lab-yana/app/service/auth-service.js b/lab-yana/app/service/auth-service.js index e1c35236..91214fbc 100644 --- a/lab-yana/app/service/auth-service.js +++ b/lab-yana/app/service/auth-service.js @@ -33,7 +33,7 @@ function authService($q, $log, $http, $window) { let config = { headers: { 'Content-Type': 'application/json', - Accept: 'application/json' + 'Accept': 'application/json' } }; @@ -61,7 +61,7 @@ function authService($q, $log, $http, $window) { }; return $http.get(url, config) .then(response => { - $log.log('success', response.data); + $log.log('success:', response.data); return setToken(response.data); }) .catch(err => { @@ -69,6 +69,7 @@ function authService($q, $log, $http, $window) { return $q.reject(new Error('login failed')); }); }; + service.logout = function() { $log.debug('authService.logout'); diff --git a/lab-yana/app/view/landing/landing.html b/lab-yana/app/view/landing/landing.html index 80dcd088..d4e6bf0c 100644 --- a/lab-yana/app/view/landing/landing.html +++ b/lab-yana/app/view/landing/landing.html @@ -3,7 +3,7 @@

already a member?

- sign in here + sign in here
From a789987abfae1b16fc2439b27aa89236de5ff566 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 28 Mar 2017 22:30:05 -0700 Subject: [PATCH 07/29] stying added --- lab-yana/app/component/login/_login.scss | 40 ++++++++++++++++++++- lab-yana/app/component/login/login.html | 5 +-- lab-yana/app/component/signup/_signup.scss | 40 ++++++++++++++++++++- lab-yana/app/component/signup/signup.html | 1 + lab-yana/app/index.html | 5 ++- lab-yana/app/scss/lib/base/_base.scss | 11 ++++++ lab-yana/app/scss/lib/layout/_layout.scss | 35 ++++++++++++++++++ lab-yana/app/scss/lib/theme/_vars.scss | 5 +++ lab-yana/app/scss/main.scss | 4 --- lab-yana/app/view/landing/_landing.scss | 25 ++++++++++++- lab-yana/app/view/landing/landing.html | 4 +-- lab-yana/assets/logo.png | Bin 0 -> 6821 bytes lab-yana/webpack.config.js | 5 +++ 13 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 lab-yana/assets/logo.png diff --git a/lab-yana/app/component/login/_login.scss b/lab-yana/app/component/login/_login.scss index 01f5394a..06a54f44 100644 --- a/lab-yana/app/component/login/_login.scss +++ b/lab-yana/app/component/login/_login.scss @@ -1,3 +1,41 @@ +@import '../../scss/lib/theme/_vars.scss'; + .login { - background-color: orange; + article { + color: $highlightBackground; + font-size: 14px; + padding-top: 30px; + } + form { + margin-right: 3%; + } +} + +.btn-std { + font-size: 14px; + border: 1px solid $highlightBackground; + border-radius: 2px; + padding-right: 45px; + padding-left: 45px; + padding-top: 10px; + padding-bottom: 10px; + margin-top: 14px; + margin-bottom: 10px; + color: $mainBackground; + background-color: $highlightBackground; + display: inline-block; + position: relative; + left: 265px; +} + +.input-std { + border-radius: 2px; + width: 100%; + padding-top: 10px; + padding-bottom: 10px; + padding-left: 10px; + margin-top: 10px; + margin-bottom: 10px; + color: $footerBackground; + border: 0.5px solid $footerBackground; } diff --git a/lab-yana/app/component/login/login.html b/lab-yana/app/component/login/login.html index 0b66e13d..ebbe200d 100644 --- a/lab-yana/app/component/login/login.html +++ b/lab-yana/app/component/login/login.html @@ -1,10 +1,11 @@ diff --git a/lab-yana/assets/logo.png b/lab-yana/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..38a23b2d1d0dc6944768b2f98fae55197b0155b7 GIT binary patch literal 6821 zcmdT}c{r5c+aF9COBpFtb|G1Y?2Iv%LSnK+_H0R(!C1yJwk$^9=iK*sc*8{h1nW6g003~p z&_K_OULODe3}6s5y_Ifr_7c4Ux@#M20{|5%YzI!q=+8nf24=irftd@KuLEf`fx)gB4_v{_YTYH8nMe z+-1n+%QAEc8B~Z*fD>BA2POJ9$UkxP+)yt59=-t{NFSj;xK7T%>-yWy z0FOKW?#T!B54Y$JLjG_d^0IP}|4ohV?7!^$4=uEl@83#)dG&W^&_7V>2!9VZy19Rh zg2_Ywg8vWNzm0>^(baYR-JAlD{uW527fk!lSPL0?JGr}=xjDIpKq3EA;vdRT$RBtA zoBMx{?O#;-;KEqxn*W?A80!boh+hBzub!cvwgsADEvMg%PybZcvDR485{`05c++>4 zr4#LVSW+eAsy?I9x!jfl2{4F@PpN6KZqZABb&jIZ%B;;z+E?Z7@69uA=g^9P#_JUT| z*QeApHSMkK?Cf6tu!M#0`c|qRig|Y#85#YcQmKAb9ND>?QKV#zgHzFjcV|rio1inh znm}Yd2^YPgaMkj%cVqO9!DufaP#egS}&+BxrdzZpXddKN!_`Fiu2@t<*VaVi#_ zyT55Ww15z~sfh{bBYW`;gf1Wk(N=3NIgyk$YAMNiG`XIxI)LZu3BnzAatJ_4G7eW+ z;1pIqD{@D3)8v4sc@XL}&B0W)c+YT=p#b8FcPB+HEpazlVx_ubE|RbO@F zsf|@G7+VfXqYyIoGcq&vKlKu(HNoM@PBOfAl7l=!9;Ma^HF~#oB1IG3c!gUDrJ8U` z``XfQk>_)#U{Cm2bN<06k!+p^lh8q1eD9N-_(z^&F2wrUkB<5--P8Tkji(x<3r$7O zg2mat*H@ik(?`5@h>Y!Sx)V&*p-f~C2TlVjSNoIm+8a*~97u`p%Z66p!WXDCFRtdU zYnMBs!u?_vUIb-DozGV(4>^k@fbxjV{)N1FlrMY8v+{nKY1@+?uZ4Y;+m0wRZKheX zTj|a=lyC1brCG63>xcfD{jaVYq2qB9d;1^DkY*I#>P*QNY}InF?{qq8@1gvb-ZO@r zXMSw=OajyGw~g*O7MLZ_#DRpTzPB_Wwr;GRU6r)9FR|s8lq$C>VI^ieoRo#0;Pup% z15aX^_cL%`feA%=tDvBOVP`QQzVUm))j0KK38B^+7{2H#1zdM{m4i*|6p014f8M6S z1yWBE4(RT_#E{fV5J!V1?9&W5$CH((U%!3{1yUYolH`TmD=YB#ZUP00u%otH#ryTa?6M*${Du^u2e#X~h)axNR$9N8RLy-8gm4tPA3 z_wSf{_O^|EAu|Cz$audRx?f zcqR`Hm%2VD@U!xC0{nc~8e>e#ssipix%;))=iC*tLZX4QYYHo#NlrvP-n^hxWL&9fn z0f6Ks3y+4}?^~B^-`}SU*G?Nz$kWY7QaQzS*HSy*_Pz}o*`3%F5FNaFOJ{fOU;&j* zl>Xh>*(rr%Q@X7@^R3OZ+|Gb@YZ0cy;*o@KfEl?K zGkV|Jvg01v!$2po+%d@cjibgwko_fBvB7vm*}?Idq=i;5;oY-*wGvyLU5~sf>O~nq z&7$ws5_Bo%QP;TZ2vomy79~y?;#?hOn~o@|3jGdU0^dnWfaY+_&&PTH7?l4;%KS5s-DyF z;D%aKHjE|bd>$gt_-&!8>Uj6Cor5C5GfuxRC`z=bVnZH7yTdAN_kuCOnmUo@7a*08-kk$Ra=$b@j? zV^$QWU_~654f67rW7$ox2b1t}Y5{+otU@g5n|<5DqsO|gw@_SXW)?P*oo6H(1;t`X z*_v15Y}?{KNZ=4W$-~WUH)io( zvG!bwg;0j-g`-n7YH<+Lu%1|4d;e6-(P|~(B*Mfbl~=>wpln5_Lbq~o@517Kq91`K zZL7BnD|l)hLKrXC+vWX2K%I_-r97Dmn{v07l^|eS37lp1A3wT!8XWB{;F{Id)wAZh z^5|c(Ak`OXD^fd`olRzpzB*i+X%5?2AN*z|yA)#=PF`IN_myn$%;Iy8tTsL8WEFI%a$~?49>Z%g07@0a8%^QAt?0*unF_*Pqu_ zR;iH2H|zoFox-<9w%YUGO%n$(p<0}&oS8ZO?|$aCQ{CLE z6C~Oyk57MUA-j;`*d$6lF4z&@(lv{}GcV1cn5RDhq)Zp-(_EW5YZrbC;c|1gBs)~o ztYK$gm{nemYLlP7Qb(=TnyBg~q3qpVV`@iy7blaK1b*0XeRo zq1Ahpel=ZgPZ`?|*)RK9;FRqWpS!|;osw>qp#VRj66 zBarK0c6L_yw?jC)vh}9xjHi94)LNI=YkvFu!NSLqkq*~-etJK#4js7If$Tsbvt9b1 zXExm0g?Uc)UEJz*NB4RXZ5;bvgwUjw_P@&D-#kVt_inI`v{{Yl*o9VIwp^)HR}T}cC~?gF0@v>!xd})9og|uchX>oorKG{a zka?Tb9~<{sbKM1&R>i2-KJ-f-@F5Hg8I??hFyKWS z=`}X+X*Q+f-gfO27hr`t=Iv~8>bqmuZ0+TuiLW8Y&OqI<%YIhWYl@A8?|IH_(?veD z=j&6}j3d@RK!PWwY&i@l!F8kj8>4x;`#tX$xq`g`4^SvYxwFejC%jj^!yX|p&ZB9q z>(y?3>ayD`Xvewge)3!%0%RK=yi2QBocCXCSbXY{?W0k=I zoI;LbMWl~@JclU|fmd;Pn-q#?LmIX6WYe0eR5^Px>uY~=U!fEg6}cpe_t@7A%q3A! z1JWvI*IZJrI4R0M!Njkip8R-f*=k&kFP~BSanE@c&RS7Dch&8alXcr<&lF>LDn^x% z=MvQB(sQKD<4hIH-&u0PtgM>{u^9QyGC4l39rpYb;m%xfto)wl)VHNCi{b4HHq{9A zUL(KOiK0WBFJG`D*{2Cfcg?3S>W0cbpN+f8?lcC!8^*5EntozPVz6`B%-Q)g(&-b(#ktaAd|oszFd4bnaAH;krX>ci(z3QbIx6XR8IO-qD>G)Gx)vhlUA_WG_y9QGPrj|GCcwV-%5~(a7pK=;xhQ5MT2fQSr zAA6E3o0Ef15R@vLpu`T1Q)RZTedx^4U`@-`+cJoYLB$Fw{`Guhyv9$G!1U#Y*0M?aBTC1M`nXGGE6a` znI!H*JD0z*9DjxX3rZVvZiI;Mp_Nt6!6ZP*nOvB&bxF-Dw#Jp4&Q<|^ld+-^ z8$~d)!*v9zecPJe@O5yJzIF=l$qF?f?{ACkOLthG_~?P?8hL7?QF|eVOncwtZBDgL zTnSwo91-VRxEd9|DO!{6XD-GGwTd1<+xoqWnb3xxh-Q+h*c{eNWjWlZuDs2Vc&+{O z&~Dbu&gXS)4{@Saj0*}u+yJ+h*J7jmwS|r`y~9<@NCr3{Va>#+AtgwXJtX$9=9P6 zfIhJ0Cc`0w)07W7c{ag0T~&l z4&9h?VPnh!4Gw!TXRZ2GT(RdMJj-*4xSm~qAOHam!lTM29S2V!-ktOMRiXWd`BGu& zNewzWikT5=8XO+()fDWWap@Rgrx!Jv&+OjD3?{j$CTS}h=bB5RmDAg}_xi?M6}O|| zI*eRdZ_bNLL++X0J4SG~n7GCDZKu287(-oyou}XP7rGWEW8apBfKyWY;q^@%WNjhN zXz%68q)$OS4)?;)^6z5{!NqLVuR+%@?xXJZ%yM_Wa2yn zvgMvAANZJN{j4Pd3^I(edT{q*v*2ZfOvno`v`aQqIV8W3q2)0fP+Y}l;^J~$qk}G2 zjQjlxWyj$2Q(Yo0{7G}!F7tl!qUbV%!1<2Bh+L~*jZ)ET_XfI^8utU1Gv{8jtgo$= zVzJl*_fRd^{U`~B&EVFm;^tz3T&Y-VnzB!aygkTQZ-M^XwaHYpOi?1XvE2p!1hIHw zSZ?SoVAz@umTeIx$g+gYYnx}!R&47q*;+9+0Es*m3Zj)U)1#yGP~%e2UV9aTsJ#T^ zaWM#9>8YF)x{Mw7Vvl{&LVlGgx);U zt~42cF%D~fF5qw}-ViDrT?)QkF+6>3x?=#E$OYASwvKarS!ety1|1D|bpM$Rb;Oct zQ>8=CjkwG=eg2_2-sMz@$$5(O4}2Q4khpP9isMJtrDRN_Fy#}%snWZ_ri4_xAsq^9 zt6_+C=@Dt^MSiX1=zaSv(mOG`5UI1VwPfBjG;ci|JZdEn-Be!XI6sshhAu`cm4r#- zDr7PN?Gd%eu%R|K#*!hnht4$+58h@ouQf)C5+2P4-`OYE)){^(RA1p#&6~S*vb=NU z6l3G^OdL~asIX~YM#tlpEbjHyLedL1z3KeGQB|NbnN;L(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/lab-yana/webpack.config.js b/lab-yana/webpack.config.js index 377e7be4..b13d76bc 100644 --- a/lab-yana/webpack.config.js +++ b/lab-yana/webpack.config.js @@ -29,6 +29,11 @@ module.exports = { test: /\.html$/, loader: 'html-loader' }, + { + test: /\.png$/, + loader: 'file-loader', + options: { name: '[path][name].[hash][ext]' } + }, { test: /\.scss$/, loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) From 5f020ad6a49abf6b07bfc1a4b6a282c7cfce61e8 Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 29 Mar 2017 13:19:02 -0700 Subject: [PATCH 08/29] added __DEBUG__ to webpack config and made log config file --- lab-yana/app/config/log-config.js | 7 +++++++ lab-yana/webpack.config.js | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lab-yana/app/config/log-config.js diff --git a/lab-yana/app/config/log-config.js b/lab-yana/app/config/log-config.js new file mode 100644 index 00000000..01068985 --- /dev/null +++ b/lab-yana/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-yana/webpack.config.js b/lab-yana/webpack.config.js index b13d76bc..ca2ca556 100644 --- a/lab-yana/webpack.config.js +++ b/lab-yana/webpack.config.js @@ -5,6 +5,7 @@ require('dotenv').load(); const webpack = require('webpack'); const HTMLPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const production = process.env.NODE_ENV === 'production'; module.exports = { devtool: 'eval', @@ -16,7 +17,10 @@ module.exports = { plugins: [ new HTMLPlugin({ template: `${__dirname}/app/index.html` }), new ExtractTextPlugin('bundle.css'), - new webpack.DefinePlugin({ __API_URL__: JSON.stringify(process.env.API_URL)}) + new webpack.DefinePlugin({ + __API_URL__: JSON.stringify(process.env.API_URL), + __DEBUG__: JSON.stringify(!production) + }) ], module: { rules: [ From 2cf81ef010e44c08df55238abce1b560df27dec1 Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 29 Mar 2017 14:02:36 -0700 Subject: [PATCH 09/29] logout button functioning and styled, moved logo and heading into navbar component, rearranged component folder to include a landing folder containing existing signup and login component folders --- .DS_Store | Bin 0 -> 6148 bytes .../create-gallery/_create-gallery.scss | 0 .../create-gallery/create-gallery.html | 0 .../gallery/create-gallery/create-gallery.js | 0 .../component/{ => landing}/login/_login.scss | 2 +- .../component/{ => landing}/login/login.html | 0 .../component/{ => landing}/login/login.js | 0 .../{ => landing}/signup/_signup.scss | 2 +- .../{ => landing}/signup/signup.html | 0 .../component/{ => landing}/signup/signup.js | 0 lab-yana/app/component/navbar/_navbar.scss | 16 +++++++++ lab-yana/app/component/navbar/navbar.html | 11 ++++++ lab-yana/app/component/navbar/navbar.js | 33 ++++++++++++++++++ lab-yana/app/index.html | 5 +-- npm-debug.log | 24 +++++++++++++ 15 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 .DS_Store create mode 100644 lab-yana/app/component/gallery/create-gallery/_create-gallery.scss create mode 100644 lab-yana/app/component/gallery/create-gallery/create-gallery.html create mode 100644 lab-yana/app/component/gallery/create-gallery/create-gallery.js rename lab-yana/app/component/{ => landing}/login/_login.scss (94%) rename lab-yana/app/component/{ => landing}/login/login.html (100%) rename lab-yana/app/component/{ => landing}/login/login.js (100%) rename lab-yana/app/component/{ => landing}/signup/_signup.scss (94%) rename lab-yana/app/component/{ => landing}/signup/signup.html (100%) rename lab-yana/app/component/{ => landing}/signup/signup.js (100%) create mode 100644 lab-yana/app/component/navbar/_navbar.scss create mode 100644 lab-yana/app/component/navbar/navbar.html create mode 100644 lab-yana/app/component/navbar/navbar.js create mode 100644 npm-debug.log diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b544152529e45ff192e772ac88c14757063aa9a9 GIT binary patch literal 6148 zcmeHKISv9b477n_B^pY~e1L)tmP={{qDT&WWNs>w~+&Q8<{-wH>cCV zHfdCV3Qz$mKn1A4R~5+e+6=#XDi5OqRNx;JuHg$K#o*^3cM=NkLAef z{{sG@|9>TMMFpt9Un!u2`EowPld`sU9%r?-z*lg~xx>vccM1kC$3QQ~SXen8ds5^T Yn`6Hwwt-GZ-0496445u7D)4Is9!7Q*F#rGn literal 0 HcmV?d00001 diff --git a/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss b/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/create-gallery/create-gallery.html b/lab-yana/app/component/gallery/create-gallery/create-gallery.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/create-gallery/create-gallery.js b/lab-yana/app/component/gallery/create-gallery/create-gallery.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/login/_login.scss b/lab-yana/app/component/landing/login/_login.scss similarity index 94% rename from lab-yana/app/component/login/_login.scss rename to lab-yana/app/component/landing/login/_login.scss index 06a54f44..499c8c8a 100644 --- a/lab-yana/app/component/login/_login.scss +++ b/lab-yana/app/component/landing/login/_login.scss @@ -1,4 +1,4 @@ -@import '../../scss/lib/theme/_vars.scss'; +@import '../../../scss/lib/theme/_vars.scss'; .login { article { diff --git a/lab-yana/app/component/login/login.html b/lab-yana/app/component/landing/login/login.html similarity index 100% rename from lab-yana/app/component/login/login.html rename to lab-yana/app/component/landing/login/login.html diff --git a/lab-yana/app/component/login/login.js b/lab-yana/app/component/landing/login/login.js similarity index 100% rename from lab-yana/app/component/login/login.js rename to lab-yana/app/component/landing/login/login.js diff --git a/lab-yana/app/component/signup/_signup.scss b/lab-yana/app/component/landing/signup/_signup.scss similarity index 94% rename from lab-yana/app/component/signup/_signup.scss rename to lab-yana/app/component/landing/signup/_signup.scss index 16d73f1e..09db15e8 100644 --- a/lab-yana/app/component/signup/_signup.scss +++ b/lab-yana/app/component/landing/signup/_signup.scss @@ -1,4 +1,4 @@ -@import '../../scss/lib/theme/_vars.scss'; +@import '../../../scss/lib/theme/_vars.scss'; .signup { article { diff --git a/lab-yana/app/component/signup/signup.html b/lab-yana/app/component/landing/signup/signup.html similarity index 100% rename from lab-yana/app/component/signup/signup.html rename to lab-yana/app/component/landing/signup/signup.html diff --git a/lab-yana/app/component/signup/signup.js b/lab-yana/app/component/landing/signup/signup.js similarity index 100% rename from lab-yana/app/component/signup/signup.js rename to lab-yana/app/component/landing/signup/signup.js diff --git a/lab-yana/app/component/navbar/_navbar.scss b/lab-yana/app/component/navbar/_navbar.scss new file mode 100644 index 00000000..a57a6074 --- /dev/null +++ b/lab-yana/app/component/navbar/_navbar.scss @@ -0,0 +1,16 @@ +@import '../../scss/lib/theme/_vars.scss'; + +.signout { + background-color: $mainBackground; + border: 0.5px solid $mainBackground; + border-radius: 6px; + font-size: 11px; + color: $highlightBackground; + padding-left: 8px; + padding-right: 8px; + padding-top: 1.5px; + padding-bottom: 3px; + position: relative; + left: 360px; + top: -45px; +} diff --git a/lab-yana/app/component/navbar/navbar.html b/lab-yana/app/component/navbar/navbar.html new file mode 100644 index 00000000..5ddc3ae3 --- /dev/null +++ b/lab-yana/app/component/navbar/navbar.html @@ -0,0 +1,11 @@ + diff --git a/lab-yana/app/component/navbar/navbar.js b/lab-yana/app/component/navbar/navbar.js new file mode 100644 index 00000000..37d7d595 --- /dev/null +++ b/lab-yana/app/component/navbar/navbar.js @@ -0,0 +1,33 @@ +'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() { + $log.debug('NavbarController.checkPath'); + let path = $location.path(); + if (path === '/join') this.hideBtn = true; + if (path !== '/join') this.hideBtn = false; + + authService.getToken() + .catch( () => $location.url('/join#login')); //if there is no token, that means user is not signed in, take them to log in screen + }; + + this.checkPath(); + $rootScope.$on('$locationChangeSuccess', () => this.checkPath()) //any time the location changes, check the path to determine whether or not to display the logout button + + this.logout = function () { + $log.debug('NavbarController.logout'); + this.hideBtn = true; + authService.logout() + .then( () => $location.url('/')); //after running the logout method from the auth Service, which removes token from local storage, take user to landing view + }; +} diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html index a7276304..5233c427 100644 --- a/lab-yana/app/index.html +++ b/lab-yana/app/index.html @@ -7,10 +7,7 @@
-
    -
  • -
  • cfgram
  • -
+
diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 00000000..f55bb22e --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,24 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/Users/radenska/.nvm/versions/node/v6.9.5/bin/node', +1 verbose cli '/Users/radenska/.nvm/versions/node/v6.9.5/bin/npm', +1 verbose cli 'run', +1 verbose cli 'lint' ] +2 info using npm@3.10.10 +3 info using node@v6.9.5 +4 verbose config Skipping project config: /Users/radenska/.npmrc. (matches userconfig) +5 verbose stack Error: ENOENT: no such file or directory, open '/Users/radenska/package.json' +5 verbose stack at Error (native) +6 verbose cwd /Users/radenska/codefellows/401/labs/25-angular_auth +7 error Darwin 16.4.0 +8 error argv "/Users/radenska/.nvm/versions/node/v6.9.5/bin/node" "/Users/radenska/.nvm/versions/node/v6.9.5/bin/npm" "run" "lint" +9 error node v6.9.5 +10 error npm v3.10.10 +11 error path /Users/radenska/package.json +12 error code ENOENT +13 error errno -2 +14 error syscall open +15 error enoent ENOENT: no such file or directory, open '/Users/radenska/package.json' +16 error enoent ENOENT: no such file or directory, open '/Users/radenska/package.json' +16 error enoent This is most likely not a problem with npm itself +16 error enoent and is related to npm not being able to find a file. +17 verbose exit [ -2, true ] From c0c782a843de1d28ad521b6791e72c7177dbf2ce Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 29 Mar 2017 14:48:51 -0700 Subject: [PATCH 10/29] created gallery service and create gallery controller, both functional, need styling --- .../create-gallery/create-gallery.html | 14 +++ .../gallery/create-gallery/create-gallery.js | 25 +++++ lab-yana/app/service/gallery-service.js | 92 +++++++++++++++++++ lab-yana/app/view/home/home-controller.js | 16 +++- lab-yana/app/view/home/home.html | 9 +- 5 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 lab-yana/app/service/gallery-service.js diff --git a/lab-yana/app/component/gallery/create-gallery/create-gallery.html b/lab-yana/app/component/gallery/create-gallery/create-gallery.html index e69de29b..95f01049 100644 --- a/lab-yana/app/component/gallery/create-gallery/create-gallery.html +++ b/lab-yana/app/component/gallery/create-gallery/create-gallery.html @@ -0,0 +1,14 @@ + diff --git a/lab-yana/app/component/gallery/create-gallery/create-gallery.js b/lab-yana/app/component/gallery/create-gallery/create-gallery.js index e69de29b..d0625f29 100644 --- a/lab-yana/app/component/gallery/create-gallery/create-gallery.js +++ b/lab-yana/app/component/gallery/create-gallery/create-gallery.js @@ -0,0 +1,25 @@ +'use strict'; + +require('./_create-gallery.scss'); + +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() { + $log.debug('CreateGalleryController.createGallery'); + + galleryService.createGallery(this.gallery) + .then( () => { + this.gallery.name = null; + this.gallery.desc = null; + }); + }; +} diff --git a/lab-yana/app/service/gallery-service.js b/lab-yana/app/service/gallery-service.js new file mode 100644 index 00000000..3a7da46c --- /dev/null +++ b/lab-yana/app/service/gallery-service.js @@ -0,0 +1,92 @@ +'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(response => { + $log.log('gallery created'); + let gallery = response.data; + service.galleries.unshift(gallery); + return gallery; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + } + + service.fetchGalleries = function() { + $log.debug('galleryService.fetchGalleries'); + + return authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + } + }; + return $http.get(url, config) + }) + .then(response => { + $log.log('galleries fetched'); + service.galleries = response.data; + return service.galleries; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deleteGallery = function(galleryID) { + $log.debug('galleryService.deleteGalleries'); + + authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + } + }; + $http.delete(url, config) + .then( () => { + $log.log('gallery removed'); + service.galleries.some((gallery, index) => { + if (gallery._id === galleryID) { + service.galleries.splice(index, 1); + return true; + } + }); + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }); + }; + return service; +} diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index dd9d54bf..2382a297 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -2,8 +2,20 @@ 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() { + $log.debug('HomeController.fetchGalleries'); + + galleryService.fetchGalleries() + .then(galleries => this.galleries = galleries); + }; + + this.fetchGalleries(); + $rootScope.$on('$locationChangeSuccess', () => this.fetchGalleries()); } diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index 01825f80..2ba7e9ec 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -1,3 +1,10 @@
-

Home Sweet Home

+ +
    +
  • + name: {{gallery.name}} + description: {{gallery.desc}} + id: {{gallery._id}} +
  • +
From 23cd493c92728f4ad10cc8d7c2e4b06a73b1717e Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 29 Mar 2017 15:20:53 -0700 Subject: [PATCH 11/29] formatting done, all pretty! (though the scss files are not pretty --- .../create-gallery/_create-gallery.scss | 12 +++ .../create-gallery/create-gallery.html | 1 + .../app/component/landing/signup/_signup.scss | 78 +++++++++---------- lab-yana/app/scss/lib/layout/_layout.scss | 37 +++++++++ lab-yana/app/view/home/_home.scss | 32 +++++++- lab-yana/app/view/home/home.html | 19 +++-- 6 files changed, 130 insertions(+), 49 deletions(-) diff --git a/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss b/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss index e69de29b..27c42e08 100644 --- a/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss +++ b/lab-yana/app/component/gallery/create-gallery/_create-gallery.scss @@ -0,0 +1,12 @@ +@import '../../../scss/lib/theme/_vars.scss'; +// +// .create-gallery { +// article { +// color: $highlightBackground; +// font-size: 14px; +// padding-top: 30px; +// } +// form { +// margin-right: 3%; +// } +// } diff --git a/lab-yana/app/component/gallery/create-gallery/create-gallery.html b/lab-yana/app/component/gallery/create-gallery/create-gallery.html index 95f01049..37eeb33c 100644 --- a/lab-yana/app/component/gallery/create-gallery/create-gallery.html +++ b/lab-yana/app/component/gallery/create-gallery/create-gallery.html @@ -1,4 +1,5 @@
From f17c69bc58a3de94f19016bf2952e346c23776f8 Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 29 Mar 2017 22:33:12 -0700 Subject: [PATCH 14/29] added some code for put, not functional yet --- .../update-gallery/_update-gallery.scss | 0 .../update-gallery/update-gallery.html | 0 .../gallery/update-gallery/update.gallery.js | 8 +++++ lab-yana/app/service/gallery-service.js | 30 +++++++++++++++++++ lab-yana/app/view/home/home-controller.js | 8 ++++- lab-yana/app/view/home/home.html | 5 +++- 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 lab-yana/app/component/gallery/update-gallery/_update-gallery.scss create mode 100644 lab-yana/app/component/gallery/update-gallery/update-gallery.html create mode 100644 lab-yana/app/component/gallery/update-gallery/update.gallery.js diff --git a/lab-yana/app/component/gallery/update-gallery/_update-gallery.scss b/lab-yana/app/component/gallery/update-gallery/_update-gallery.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/update-gallery/update-gallery.html b/lab-yana/app/component/gallery/update-gallery/update-gallery.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/update-gallery/update.gallery.js b/lab-yana/app/component/gallery/update-gallery/update.gallery.js new file mode 100644 index 00000000..b8c2c5d1 --- /dev/null +++ b/lab-yana/app/component/gallery/update-gallery/update.gallery.js @@ -0,0 +1,8 @@ +'use strict'; + +require('./_update-gallery.scss'); + +module.exports = { + template: require('./update-gallery.html'), + controller: +} diff --git a/lab-yana/app/service/gallery-service.js b/lab-yana/app/service/gallery-service.js index 3a7da46c..826091a0 100644 --- a/lab-yana/app/service/gallery-service.js +++ b/lab-yana/app/service/gallery-service.js @@ -88,5 +88,35 @@ function galleryService($q, $log, $http, authService) { }); }); }; + + service.updateGallery = function(update, galleryID) { + $log.debug('galleryService.updateGallery'); + + authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + Accept: 'application/json' + } + }; + return $http.put(url, update, config) + .then(response.data => { + $log.log('gallery updated'); + service.galleries.some((gallery, index) => { + if (gallery._id === galleryID) { + service.galleries[index] = response.data; + return true; + } + }); + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }); + } return service; } diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index 37c2e7a0..0d956cd7 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -23,5 +23,11 @@ function HomeController($log, $rootScope, galleryService) { $log.debug('HomeController.deleteGallery'); galleryService.deleteGallery(galleryID); - } + }; + + this.updateGallery = function(galleryID, update) { + $log.debug('HomeController.updateGallery'); + + galleryService.updateGallery(galleryID, update) + }; } diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index 802b9ac9..39aef3f9 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -6,7 +6,10 @@
  • name:

    {{gallery.name}}

    description:

    {{gallery.desc}}
    - + + + +
  • From 3e3bb311209f8290dabaffc504ab94979c5fa935 Mon Sep 17 00:00:00 2001 From: radenska Date: Thu, 30 Mar 2017 01:39:09 -0700 Subject: [PATCH 15/29] update method works without any weird glitches, finally --- .../update-gallery/_update-gallery.scss | 0 .../update-gallery/update-gallery.html | 0 .../gallery/update-gallery/update.gallery.js | 8 --- lab-yana/app/component/navbar/_navbar.scss | 2 +- lab-yana/app/component/navbar/navbar.html | 2 +- lab-yana/app/service/gallery-service.js | 54 +++++++++---------- lab-yana/app/view/home/_home.scss | 11 ++++ lab-yana/app/view/home/home-controller.js | 11 +++- lab-yana/app/view/home/home.html | 15 +++++- 9 files changed, 62 insertions(+), 41 deletions(-) delete mode 100644 lab-yana/app/component/gallery/update-gallery/_update-gallery.scss delete mode 100644 lab-yana/app/component/gallery/update-gallery/update-gallery.html delete mode 100644 lab-yana/app/component/gallery/update-gallery/update.gallery.js diff --git a/lab-yana/app/component/gallery/update-gallery/_update-gallery.scss b/lab-yana/app/component/gallery/update-gallery/_update-gallery.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/lab-yana/app/component/gallery/update-gallery/update-gallery.html b/lab-yana/app/component/gallery/update-gallery/update-gallery.html deleted file mode 100644 index e69de29b..00000000 diff --git a/lab-yana/app/component/gallery/update-gallery/update.gallery.js b/lab-yana/app/component/gallery/update-gallery/update.gallery.js deleted file mode 100644 index b8c2c5d1..00000000 --- a/lab-yana/app/component/gallery/update-gallery/update.gallery.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -require('./_update-gallery.scss'); - -module.exports = { - template: require('./update-gallery.html'), - controller: -} diff --git a/lab-yana/app/component/navbar/_navbar.scss b/lab-yana/app/component/navbar/_navbar.scss index 80651b24..66f1d82a 100644 --- a/lab-yana/app/component/navbar/_navbar.scss +++ b/lab-yana/app/component/navbar/_navbar.scss @@ -1,6 +1,6 @@ @import '../../scss/lib/theme/_vars.scss'; -.signout { +.smallButt { display: inline-block; background-color: $mainBackground; border: 0.5px solid $mainBackground; diff --git a/lab-yana/app/component/navbar/navbar.html b/lab-yana/app/component/navbar/navbar.html index 5ddc3ae3..2217f5d4 100644 --- a/lab-yana/app/component/navbar/navbar.html +++ b/lab-yana/app/component/navbar/navbar.html @@ -5,7 +5,7 @@ diff --git a/lab-yana/app/service/gallery-service.js b/lab-yana/app/service/gallery-service.js index 826091a0..9d9442e9 100644 --- a/lab-yana/app/service/gallery-service.js +++ b/lab-yana/app/service/gallery-service.js @@ -47,7 +47,7 @@ function galleryService($q, $log, $http, authService) { Accept: 'application/json' } }; - return $http.get(url, config) + return $http.get(url, config); }) .then(response => { $log.log('galleries fetched'); @@ -72,20 +72,20 @@ function galleryService($q, $log, $http, authService) { Accept: 'application/json' } }; - $http.delete(url, config) - .then( () => { - $log.log('gallery removed'); - service.galleries.some((gallery, index) => { - if (gallery._id === galleryID) { - service.galleries.splice(index, 1); - return true; - } - }); - }) - .catch(err => { - $log.error(err.message); - return $q.reject(err); + return $http.delete(url, config); + }) + .then( () => { + $log.log('gallery removed'); + service.galleries.some((gallery, index) => { + if (gallery._id === galleryID) { + service.galleries.splice(index, 1); + return true; + } }); + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); }); }; @@ -102,20 +102,20 @@ function galleryService($q, $log, $http, authService) { Accept: 'application/json' } }; - return $http.put(url, update, config) - .then(response.data => { - $log.log('gallery updated'); - service.galleries.some((gallery, index) => { - if (gallery._id === galleryID) { - service.galleries[index] = response.data; - return true; - } - }); - }) - .catch(err => { - $log.error(err.message); - return $q.reject(err); + return $http.put(url, update, config); + }) + .then(response => { + $log.log('gallery updated'); + service.galleries.some((gallery, index) => { + if (gallery._id === galleryID) { + service.galleries[index] = response.data; + return true; + } }); + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); }); } return service; diff --git a/lab-yana/app/view/home/_home.scss b/lab-yana/app/view/home/_home.scss index 24e4b770..6d23ca41 100644 --- a/lab-yana/app/view/home/_home.scss +++ b/lab-yana/app/view/home/_home.scss @@ -1,5 +1,16 @@ @import '../../scss/lib/theme/_vars.scss'; + +.update-gallery { + width: 95%; + button { + left: 210px; + padding-left: 30px; + padding-right: 30px; + border-radius: 7px; + } +} + .container { width: 94%; margin: auto; diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index 0d956cd7..c582b057 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -25,9 +25,16 @@ function HomeController($log, $rootScope, galleryService) { galleryService.deleteGallery(galleryID); }; - this.updateGallery = function(galleryID, update) { + this.updateGallery = function(galleryID) { $log.debug('HomeController.updateGallery'); - galleryService.updateGallery(galleryID, update) + let update = { + name: this.update.name, + desc: this.update.desc + }; + + this.showUpdate = false; + galleryService.updateGallery(update, galleryID); + }; } diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index 39aef3f9..21d451c1 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -7,8 +7,19 @@

    name:

    {{gallery.name}}

    description:

    {{gallery.desc}}
    - - + + + From 6ea497a9c95725f36ab4d04b868bf076199cb100 Mon Sep 17 00:00:00 2001 From: radenska Date: Thu, 30 Mar 2017 21:59:54 -0700 Subject: [PATCH 16/29] finally done with styling --- .../gallery/edit-gallery/_edit-gallery.scss | 57 +++++++++++++++++++ .../gallery/edit-gallery/edit-gallery.html | 19 +++++++ .../gallery/edit-gallery/edit-gallery.js | 22 +++++++ .../gallery/gallery-item/_gallery-item.scss | 55 ++++++++++++++++++ .../gallery/gallery-item/gallery-item.html | 18 ++++++ .../gallery/gallery-item/gallery-item.js | 23 ++++++++ lab-yana/app/index.html | 4 +- lab-yana/app/service/gallery-service.js | 2 +- lab-yana/app/view/home/home-controller.js | 18 ------ lab-yana/app/view/home/home.html | 20 +------ 10 files changed, 199 insertions(+), 39 deletions(-) create mode 100644 lab-yana/app/component/gallery/edit-gallery/_edit-gallery.scss create mode 100644 lab-yana/app/component/gallery/edit-gallery/edit-gallery.html create mode 100644 lab-yana/app/component/gallery/edit-gallery/edit-gallery.js create mode 100644 lab-yana/app/component/gallery/gallery-item/_gallery-item.scss create mode 100644 lab-yana/app/component/gallery/gallery-item/gallery-item.html create mode 100644 lab-yana/app/component/gallery/gallery-item/gallery-item.js diff --git a/lab-yana/app/component/gallery/edit-gallery/_edit-gallery.scss b/lab-yana/app/component/gallery/edit-gallery/_edit-gallery.scss new file mode 100644 index 00000000..f568c65e --- /dev/null +++ b/lab-yana/app/component/gallery/edit-gallery/_edit-gallery.scss @@ -0,0 +1,57 @@ +@import '../../../scss/lib/theme/_vars.scss'; + +.edit { + margin-top: -15px; + width: 100%; + background-color: $mainBackground; + input { + display: inline-block; + width: 67%; + margin-top: -5px; + color: #696969; + float: left; + font-size: 14px; + border-radius: 8px; + background-color: #B0B0B0; + padding-top: 3px; + padding-bottom: 3px; + margin-left: 5px; + border: 1px solid #606060; + } + + div { + width: 100%; + border-radius: 7px; + background-color: $footerBackground; + padding-bottom: 2px; + padding-top: 1px; + padding-right: 10px; + } + + button { + left: 152px; + font-size: 12px; + border-radius: 7px; + padding-right: 30px; + padding-left: 30px; + padding-top: 5px; + padding-bottom: 5px; + } + fieldset { + text-align: left; + } + fieldset:first-of-type { + input { + margin-top: 9px; + width: 78%; + } + .item-label { + margin-top: 14px; + } + } + .item-label { + font-weight: bold; + display: inline-block; + float: left; + } +} diff --git a/lab-yana/app/component/gallery/edit-gallery/edit-gallery.html b/lab-yana/app/component/gallery/edit-gallery/edit-gallery.html new file mode 100644 index 00000000..7440c2cd --- /dev/null +++ b/lab-yana/app/component/gallery/edit-gallery/edit-gallery.html @@ -0,0 +1,19 @@ +
    + +
    diff --git a/lab-yana/app/component/gallery/edit-gallery/edit-gallery.js b/lab-yana/app/component/gallery/edit-gallery/edit-gallery.js new file mode 100644 index 00000000..835ee4ce --- /dev/null +++ b/lab-yana/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('EditGalleryController.updateGallery'); + + galleryService.updateGallery(this.gallery._id, this.gallery); + }; +} diff --git a/lab-yana/app/component/gallery/gallery-item/_gallery-item.scss b/lab-yana/app/component/gallery/gallery-item/_gallery-item.scss new file mode 100644 index 00000000..e888f3f1 --- /dev/null +++ b/lab-yana/app/component/gallery/gallery-item/_gallery-item.scss @@ -0,0 +1,55 @@ +@import '../../../scss/lib/theme/_vars.scss'; + +.gallery-item { + display: block; + clear: both; + width: 98%; + background-color: $mainBackground; + + .current-item { + display: block; + text-align: left; + color: $highlightBackground; + background-color: $footerBackground; + border-radius: 7px; + padding-bottom: 62px; + span { + font-weight: bold; + display: inline-block; + float: left; + clear: left; + } + p { + display: inline-block; + font-weight: normal; + color: #696969; + float: left; + clear: right; + margin-left: 14px; + } + } + +} +.button-container { + display: block; + background-color: $mainBackground; + margin-top: 15px; + clear: right; + margin-bottom: 70px; + + button:first-of-type { + background-color: $highlightBackground; + color: $mainBackground; + margin-left: 10px; + } + button { + float: right; + font-size: 12px; + border-radius: 7px; + padding-right: 32px; + padding-left: 32px; + padding-top: 6px; + padding-bottom: 6px; + border: none; + } +} diff --git a/lab-yana/app/component/gallery/gallery-item/gallery-item.html b/lab-yana/app/component/gallery/gallery-item/gallery-item.html new file mode 100644 index 00000000..342a61f4 --- /dev/null +++ b/lab-yana/app/component/gallery/gallery-item/gallery-item.html @@ -0,0 +1,18 @@ + diff --git a/lab-yana/app/component/gallery/gallery-item/gallery-item.js b/lab-yana/app/component/gallery/gallery-item/gallery-item.js new file mode 100644 index 00000000..6f174bf2 --- /dev/null +++ b/lab-yana/app/component/gallery/gallery-item/gallery-item.js @@ -0,0 +1,23 @@ +'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.showEdit = false; + this.deleteGallery = function() { + $log.debug('GalleryController.deleteGallery'); + + galleryService.deleteGallery(this.gallery._id); + }; +} diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html index 5233c427..61fe8926 100644 --- a/lab-yana/app/index.html +++ b/lab-yana/app/index.html @@ -9,9 +9,11 @@
    +
    - +
    +
    diff --git a/lab-yana/app/service/gallery-service.js b/lab-yana/app/service/gallery-service.js index 9d9442e9..35154f82 100644 --- a/lab-yana/app/service/gallery-service.js +++ b/lab-yana/app/service/gallery-service.js @@ -89,7 +89,7 @@ function galleryService($q, $log, $http, authService) { }); }; - service.updateGallery = function(update, galleryID) { + service.updateGallery = function(galleryID, update) { $log.debug('galleryService.updateGallery'); authService.getToken() diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index c582b057..cbb1fb11 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -19,22 +19,4 @@ function HomeController($log, $rootScope, galleryService) { this.fetchGalleries(); $rootScope.$on('$locationChangeSuccess', () => this.fetchGalleries()); - this.deleteGallery = function(galleryID) { - $log.debug('HomeController.deleteGallery'); - - galleryService.deleteGallery(galleryID); - }; - - this.updateGallery = function(galleryID) { - $log.debug('HomeController.updateGallery'); - - let update = { - name: this.update.name, - desc: this.update.desc - }; - - this.showUpdate = false; - galleryService.updateGallery(update, galleryID); - - }; } diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index 21d451c1..8dbc49be 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -3,25 +3,7 @@
      Galleries
      -
    • -

      name:

      {{gallery.name}}
      -

      description:

      {{gallery.desc}}
      - - - - - -
    • +
    From 95b80cdff9ea5491275f21c53d5f4cc8028f5a80 Mon Sep 17 00:00:00 2001 From: radenska Date: Mon, 3 Apr 2017 14:00:25 -0700 Subject: [PATCH 17/29] added basic file structure and content to photo service and thumbnail components --- .../_thumbnail-container.scss | 0 .../thumbnail-container.html | 7 ++++ .../thumbnail-container.js | 11 ++++++ .../gallery/thumbnail/_thumbnail.scss | 0 .../gallery/thumbnail/thumbnail.html | 4 ++ .../component/gallery/thumbnail/thumbnail.js | 21 +++++++++++ .../gallery/upload-photo/_upload-photo.scss | 0 .../gallery/upload-photo/upload-photo.html | 0 .../gallery/upload-photo/upload-photo.js | 26 +++++++++++++ lab-yana/app/entry.js | 1 + lab-yana/app/service/photo-service.js | 37 +++++++++++++++++++ lab-yana/package.json | 1 + 12 files changed, 108 insertions(+) create mode 100644 lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss create mode 100644 lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html create mode 100644 lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js create mode 100644 lab-yana/app/component/gallery/thumbnail/_thumbnail.scss create mode 100644 lab-yana/app/component/gallery/thumbnail/thumbnail.html create mode 100644 lab-yana/app/component/gallery/thumbnail/thumbnail.js create mode 100644 lab-yana/app/component/gallery/upload-photo/_upload-photo.scss create mode 100644 lab-yana/app/component/gallery/upload-photo/upload-photo.html create mode 100644 lab-yana/app/component/gallery/upload-photo/upload-photo.js create mode 100644 lab-yana/app/service/photo-service.js diff --git a/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss b/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html new file mode 100644 index 00000000..862fbd8b --- /dev/null +++ b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -0,0 +1,7 @@ +
    +

    {{ThumbnailContainerCtlr.gallery.name}} + +
      + +
    +

    diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js new file mode 100644 index 00000000..ecb42dcb --- /dev/null +++ b/lab-yana/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: 'ThumbnailContainerCtlr', + bindings: { + gallery: '<' + } +}; diff --git a/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss b/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.html b/lab-yana/app/component/gallery/thumbnail/thumbnail.html new file mode 100644 index 00000000..c9a5655a --- /dev/null +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.html @@ -0,0 +1,4 @@ +
  • + {{thumbnailCtrl.photo.desc}} + +
  • diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.js b/lab-yana/app/component/gallery/thumbnail/thumbnail.js new file mode 100644 index 00000000..b32a3e4a --- /dev/null +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.js @@ -0,0 +1,21 @@ +'use strict'; + +require('./_thumbnail.scss'); + +module.exports = { + template: require('./thumbnail.html'), + controller: ['$log', 'photoService', ThumbnailController], + controllerAs: 'thumbnailCtrl', + bindings: { + photo: '<' + } +}; + +function ThumbnailController($q, $log, $updatethingy, authService) { + $log.debug('ThumbnailController'); + + this.deletePhoto = function() { + $log.debug('ThumbnailController.deletePhoto'); + } + +} diff --git a/lab-yana/app/component/gallery/upload-photo/_upload-photo.scss b/lab-yana/app/component/gallery/upload-photo/_upload-photo.scss new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.html b/lab-yana/app/component/gallery/upload-photo/upload-photo.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.js b/lab-yana/app/component/gallery/upload-photo/upload-photo.js new file mode 100644 index 00000000..0699489e --- /dev/null +++ b/lab-yana/app/component/gallery/upload-photo/upload-photo.js @@ -0,0 +1,26 @@ +'use strict'; + +require('./_upload-photo.scss'); + +module.exports = { + template: require('./upload-photo.html'), + controller: ['$log', 'photoService', UploadPhotoController], + controllerAs: 'uploadPhotoCtrl', + bindings: { + gallery: '<' + } +}; +function UploadPhotoController($log, photoService) { + $log.debug('UploadPhotoController'); + + this.photo = {}; + + this.uploadPhoto = function() { + photoService.uploadGalleryPic(this.gallery) + then( () => { + this.photo.name = null; + this.photo.desc = null; + this.photo.file = null; + }); + } +} diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js index e27ae570..64166fba 100644 --- a/lab-yana/app/entry.js +++ b/lab-yana/app/entry.js @@ -9,6 +9,7 @@ const camelcase = require('camelcase'); 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]); diff --git a/lab-yana/app/service/photo-service.js b/lab-yana/app/service/photo-service.js new file mode 100644 index 00000000..d9ac2a58 --- /dev/null +++ b/lab-yana/app/service/photo-service.js @@ -0,0 +1,37 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'Upload', 'authService', photoService]; + +function photoService($q, $log, $http, Upload, authService) { + $log.debug('photoService'); + + let service = {}; + + authService.getToken(token => { + url = `${__API_URL__}/app/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: pidData.file + } + }); + }) + .then(response => { + galleryData.pics.unshift(response.data); + return response.data; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + + return service; +} diff --git a/lab-yana/package.json b/lab-yana/package.json index b187cb3d..d96ac2b3 100644 --- a/lab-yana/package.json +++ b/lab-yana/package.json @@ -31,6 +31,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 00f21733ae0c2bb542a495ae9408c66b18ccb5d8 Mon Sep 17 00:00:00 2001 From: radenska Date: Mon, 3 Apr 2017 15:20:43 -0700 Subject: [PATCH 18/29] added all logic for uploading a photo (no delete or styling yet --- lab-yana/.env | 2 +- .../thumbnail-container.html | 8 +-- .../component/gallery/thumbnail/thumbnail.js | 2 +- .../gallery/upload-photo/upload-photo.html | 16 ++++++ .../gallery/upload-photo/upload-photo.js | 5 +- lab-yana/app/entry.js | 2 +- lab-yana/app/service/photo-service.js | 53 ++++++++++--------- lab-yana/app/view/home/home-controller.js | 6 +++ lab-yana/app/view/home/home.html | 8 ++- 9 files changed, 68 insertions(+), 34 deletions(-) diff --git a/lab-yana/.env b/lab-yana/.env index c1e5f310..2f02e4b0 100644 --- a/lab-yana/.env +++ b/lab-yana/.env @@ -1 +1 @@ -API_URL='https://slugram-backend.herokuapp.com' +API_URL='http://localhost:3003' diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html index 862fbd8b..2e6feb87 100644 --- a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html +++ b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -1,7 +1,7 @@
    -

    {{ThumbnailContainerCtlr.gallery.name}} - -
      - +

      {{ThumbnailContainerCtrl.gallery.name}} + +
        +

    diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.js b/lab-yana/app/component/gallery/thumbnail/thumbnail.js index b32a3e4a..8f9038d3 100644 --- a/lab-yana/app/component/gallery/thumbnail/thumbnail.js +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.js @@ -11,7 +11,7 @@ module.exports = { } }; -function ThumbnailController($q, $log, $updatethingy, authService) { +function ThumbnailController($log, photoService, authService) { $log.debug('ThumbnailController'); this.deletePhoto = function() { diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.html b/lab-yana/app/component/gallery/upload-photo/upload-photo.html index e69de29b..000a945f 100644 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.html +++ b/lab-yana/app/component/gallery/upload-photo/upload-photo.html @@ -0,0 +1,16 @@ + +
    +

    upload a photo

    +
    + + +
    +
    +

    + select a photo to upload +

    + +
    + diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.js b/lab-yana/app/component/gallery/upload-photo/upload-photo.js index 0699489e..e8dad70a 100644 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.js +++ b/lab-yana/app/component/gallery/upload-photo/upload-photo.js @@ -10,17 +10,18 @@ module.exports = { gallery: '<' } }; + function UploadPhotoController($log, photoService) { $log.debug('UploadPhotoController'); this.photo = {}; this.uploadPhoto = function() { - photoService.uploadGalleryPic(this.gallery) + photoService.uploadGalleryPhoto(this.gallery, this.photo) then( () => { this.photo.name = null; this.photo.desc = null; this.photo.file = null; }); - } + }; } diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js index 64166fba..f5d6c71d 100644 --- a/lab-yana/app/entry.js +++ b/lab-yana/app/entry.js @@ -11,7 +11,7 @@ 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 => cfgram.config(context(key))); diff --git a/lab-yana/app/service/photo-service.js b/lab-yana/app/service/photo-service.js index d9ac2a58..ddea123f 100644 --- a/lab-yana/app/service/photo-service.js +++ b/lab-yana/app/service/photo-service.js @@ -7,31 +7,36 @@ function photoService($q, $log, $http, Upload, authService) { let service = {}; - authService.getToken(token => { - url = `${__API_URL__}/app/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: pidData.file - } + service.uploadGalleryPhoto = function(galleryData, photoData) { + $log.debug('photoService.uploadGalleryPhoto'); + + authService.getToken() + .then( token => { + url = `${__API_URL__}/app/gallery/${galleryData._id}/pic`; + let headers = { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + }; + return Upload.upload({ + url, + headers, + method: 'POST', + data: { + name: photoData.name, + desc: photoData.desc, + file: photoData.file + } + }); + }) + .then(response => { + galleryData.photos.unshift(response.data); + return response.data; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); }); - }) - .then(response => { - galleryData.pics.unshift(response.data); - return response.data; - }) - .catch(err => { - $log.error(err.message); - return $q.reject(err); - }); + }; return service; } diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index cbb1fb11..7118429b 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -16,6 +16,12 @@ function HomeController($log, $rootScope, galleryService) { .then(galleries => this.galleries = galleries); }; + this.galleryDeleteDone = function(gallery) { + $log.debug('HomeController.galleryDeleteDone'); + + if (this.currentGallery._id === gallery._id) this.currentGallery = null; + }; + this.fetchGalleries(); $rootScope.$on('$locationChangeSuccess', () => this.fetchGalleries()); diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index 8dbc49be..be45e7a9 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -3,7 +3,13 @@
      Galleries
      - + +
    + From 92744de6ff7953b05462505863561cf2edd4f7da Mon Sep 17 00:00:00 2001 From: radenska Date: Mon, 3 Apr 2017 22:20:41 -0700 Subject: [PATCH 19/29] photos not posting, 500 error I cannot debug --- .../thumbnail-container.html | 6 ++--- .../thumbnail-container.js | 2 +- .../gallery/thumbnail/thumbnail.html | 7 ++--- .../component/gallery/thumbnail/thumbnail.js | 2 +- .../gallery/upload-photo/upload-photo.html | 27 ++++++++++--------- .../gallery/upload-photo/upload-photo.js | 4 ++- lab-yana/app/service/gallery-service.js | 4 +-- lab-yana/app/service/photo-service.js | 6 ++--- lab-yana/app/view/home/home-controller.js | 2 +- lab-yana/app/view/home/home.html | 2 +- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html index 2e6feb87..4a9ab93b 100644 --- a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html +++ b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -1,7 +1,7 @@
    -

    {{ThumbnailContainerCtrl.gallery.name}} +

    {{ThumbnailContainerCtrl.gallery.name}}

    -
      +
      -
    +
    diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js index ecb42dcb..18bf16d4 100644 --- a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js +++ b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.js @@ -4,7 +4,7 @@ require('./_thumbnail-container.scss'); module.exports = { template: require('./thumbnail-container.html'), - controllerAs: 'ThumbnailContainerCtlr', + controllerAs: 'thumbnailContainerCtrl', bindings: { gallery: '<' } diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.html b/lab-yana/app/component/gallery/thumbnail/thumbnail.html index c9a5655a..25164ddb 100644 --- a/lab-yana/app/component/gallery/thumbnail/thumbnail.html +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.html @@ -1,4 +1,5 @@ -
  • - {{thumbnailCtrl.photo.desc}} +
    + {{thumbnailCtrl.photo.desc}} + {{thumbnailCtrl.photo.imageURI}} -
  • + diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.js b/lab-yana/app/component/gallery/thumbnail/thumbnail.js index 8f9038d3..fc513cda 100644 --- a/lab-yana/app/component/gallery/thumbnail/thumbnail.js +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.js @@ -11,7 +11,7 @@ module.exports = { } }; -function ThumbnailController($log, photoService, authService) { +function ThumbnailController($log, photoService) { $log.debug('ThumbnailController'); this.deletePhoto = function() { diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.html b/lab-yana/app/component/gallery/upload-photo/upload-photo.html index 000a945f..edbb74a9 100644 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.html +++ b/lab-yana/app/component/gallery/upload-photo/upload-photo.html @@ -1,16 +1,17 @@ -

    upload a photo

    -
    - - -
    -
    -

    - select a photo to upload -

    - -
    +

    upload a photo

    +
    + + +
    +
    +

    + select a photo to upload +

    + +
    + diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.js b/lab-yana/app/component/gallery/upload-photo/upload-photo.js index e8dad70a..1c6965d5 100644 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.js +++ b/lab-yana/app/component/gallery/upload-photo/upload-photo.js @@ -17,8 +17,10 @@ function UploadPhotoController($log, photoService) { this.photo = {}; this.uploadPhoto = function() { + $log.debug('UploadPhotoController.uploadPhoto'); + photoService.uploadGalleryPhoto(this.gallery, this.photo) - then( () => { + .then( () => { this.photo.name = null; this.photo.desc = null; this.photo.file = null; diff --git a/lab-yana/app/service/gallery-service.js b/lab-yana/app/service/gallery-service.js index 35154f82..eee57d77 100644 --- a/lab-yana/app/service/gallery-service.js +++ b/lab-yana/app/service/gallery-service.js @@ -89,7 +89,7 @@ function galleryService($q, $log, $http, authService) { }); }; - service.updateGallery = function(galleryID, update) { + service.updateGallery = function(galleryID, galleryData) { $log.debug('galleryService.updateGallery'); authService.getToken() @@ -102,7 +102,7 @@ function galleryService($q, $log, $http, authService) { Accept: 'application/json' } }; - return $http.put(url, update, config); + return $http.put(url, galleryData, config); }) .then(response => { $log.log('gallery updated'); diff --git a/lab-yana/app/service/photo-service.js b/lab-yana/app/service/photo-service.js index ddea123f..4594db8a 100644 --- a/lab-yana/app/service/photo-service.js +++ b/lab-yana/app/service/photo-service.js @@ -10,9 +10,9 @@ function photoService($q, $log, $http, Upload, authService) { service.uploadGalleryPhoto = function(galleryData, photoData) { $log.debug('photoService.uploadGalleryPhoto'); - authService.getToken() - .then( token => { - url = `${__API_URL__}/app/gallery/${galleryData._id}/pic`; + return authService.getToken() + .then(token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic`; let headers = { Authorization: `Bearer ${token}`, Accept: 'application/json' diff --git a/lab-yana/app/view/home/home-controller.js b/lab-yana/app/view/home/home-controller.js index 7118429b..d6a32363 100644 --- a/lab-yana/app/view/home/home-controller.js +++ b/lab-yana/app/view/home/home-controller.js @@ -17,7 +17,7 @@ function HomeController($log, $rootScope, galleryService) { }; this.galleryDeleteDone = function(gallery) { - $log.debug('HomeController.galleryDeleteDone'); + $log.debug('HomeController.galleryDeleteDone', gallery); if (this.currentGallery._id === gallery._id) this.currentGallery = null; }; diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index be45e7a9..cfecd07d 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -6,7 +6,7 @@ From 871661d07bb06a78baf0b9be230f2c17f02ac8f2 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 4 Apr 2017 13:07:44 -0700 Subject: [PATCH 20/29] assignment complete, including styling and pic delete --- .../_thumbnail-container.scss | 5 ++ .../thumbnail-container.html | 6 +- .../gallery/thumbnail/_thumbnail.scss | 17 +++++ .../gallery/thumbnail/thumbnail.html | 5 +- .../component/gallery/thumbnail/thumbnail.js | 14 ++-- .../gallery/upload-photo/_upload-photo.scss | 0 .../gallery/upload-photo/upload-photo.html | 17 ----- .../gallery/upload-photo/upload-photo.js | 29 -------- .../gallery/upload-pic/_upload-pic.scss | 35 ++++++++++ .../gallery/upload-pic/upload-pic.html | 17 +++++ .../gallery/upload-pic/upload-pic.js | 29 ++++++++ lab-yana/app/service/photo-service.js | 42 ------------ lab-yana/app/service/pic-service.js | 67 +++++++++++++++++++ lab-yana/package.json | 2 +- 14 files changed, 184 insertions(+), 101 deletions(-) delete mode 100644 lab-yana/app/component/gallery/upload-photo/_upload-photo.scss delete mode 100644 lab-yana/app/component/gallery/upload-photo/upload-photo.html delete mode 100644 lab-yana/app/component/gallery/upload-photo/upload-photo.js create mode 100644 lab-yana/app/component/gallery/upload-pic/_upload-pic.scss create mode 100644 lab-yana/app/component/gallery/upload-pic/upload-pic.html create mode 100644 lab-yana/app/component/gallery/upload-pic/upload-pic.js delete mode 100644 lab-yana/app/service/photo-service.js create mode 100644 lab-yana/app/service/pic-service.js diff --git a/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss b/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss index e69de29b..5a485c76 100644 --- a/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss +++ b/lab-yana/app/component/gallery/thumbnail-container/_thumbnail-container.scss @@ -0,0 +1,5 @@ +.thumbnail-container { + display: block; + margin-top: -20vw; + padding-bottom: 7vw; +} diff --git a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html index 4a9ab93b..9aaec8b3 100644 --- a/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html +++ b/lab-yana/app/component/gallery/thumbnail-container/thumbnail-container.html @@ -1,7 +1,7 @@
    -

    {{ThumbnailContainerCtrl.gallery.name}}

    - +
    {{thumbnailContainerCtrl.gallery.name}}
    +
    - +
    diff --git a/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss b/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss index e69de29b..2ed3c14e 100644 --- a/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss +++ b/lab-yana/app/component/gallery/thumbnail/_thumbnail.scss @@ -0,0 +1,17 @@ +.thumbnail { + img { + margin-top: 2vw; + width: 30vw; + height: 20vw; + margin-left: 6vw; + } + button { + font-size: 12px; + border-radius: 7px; + padding-right: 30px; + padding-left: 30px; + padding-top: 5px; + padding-bottom: 5px; + left: 32vw; + } +} diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.html b/lab-yana/app/component/gallery/thumbnail/thumbnail.html index 25164ddb..11a08aa3 100644 --- a/lab-yana/app/component/gallery/thumbnail/thumbnail.html +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.html @@ -1,5 +1,4 @@
    - {{thumbnailCtrl.photo.desc}} - {{thumbnailCtrl.photo.imageURI}} - + {{thumbnailCtrl.pic.desc}} +
    diff --git a/lab-yana/app/component/gallery/thumbnail/thumbnail.js b/lab-yana/app/component/gallery/thumbnail/thumbnail.js index fc513cda..c8cb4ea7 100644 --- a/lab-yana/app/component/gallery/thumbnail/thumbnail.js +++ b/lab-yana/app/component/gallery/thumbnail/thumbnail.js @@ -4,18 +4,20 @@ require('./_thumbnail.scss'); module.exports = { template: require('./thumbnail.html'), - controller: ['$log', 'photoService', ThumbnailController], + controller: ['$log', 'picService', ThumbnailController], controllerAs: 'thumbnailCtrl', bindings: { - photo: '<' + pic: '<', + gallery: '<' } }; -function ThumbnailController($log, photoService) { +function ThumbnailController($log, picService) { $log.debug('ThumbnailController'); - this.deletePhoto = function() { - $log.debug('ThumbnailController.deletePhoto'); - } + this.deletePic = function() { + $log.debug('ThumbnailController.deletePic'); + picService.deleteGalleryPic(this.gallery, this.pic); + }; } diff --git a/lab-yana/app/component/gallery/upload-photo/_upload-photo.scss b/lab-yana/app/component/gallery/upload-photo/_upload-photo.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.html b/lab-yana/app/component/gallery/upload-photo/upload-photo.html deleted file mode 100644 index edbb74a9..00000000 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.html +++ /dev/null @@ -1,17 +0,0 @@ - -
    -

    upload a photo

    -
    - - -
    -
    -

    - select a photo to upload -

    - -
    -
    - diff --git a/lab-yana/app/component/gallery/upload-photo/upload-photo.js b/lab-yana/app/component/gallery/upload-photo/upload-photo.js deleted file mode 100644 index 1c6965d5..00000000 --- a/lab-yana/app/component/gallery/upload-photo/upload-photo.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -require('./_upload-photo.scss'); - -module.exports = { - template: require('./upload-photo.html'), - controller: ['$log', 'photoService', UploadPhotoController], - controllerAs: 'uploadPhotoCtrl', - bindings: { - gallery: '<' - } -}; - -function UploadPhotoController($log, photoService) { - $log.debug('UploadPhotoController'); - - this.photo = {}; - - this.uploadPhoto = function() { - $log.debug('UploadPhotoController.uploadPhoto'); - - photoService.uploadGalleryPhoto(this.gallery, this.photo) - .then( () => { - this.photo.name = null; - this.photo.desc = null; - this.photo.file = null; - }); - }; -} diff --git a/lab-yana/app/component/gallery/upload-pic/_upload-pic.scss b/lab-yana/app/component/gallery/upload-pic/_upload-pic.scss new file mode 100644 index 00000000..a8c20179 --- /dev/null +++ b/lab-yana/app/component/gallery/upload-pic/_upload-pic.scss @@ -0,0 +1,35 @@ +.upload-pic { + display: block; + div { + article { + margin-top: 0; + text-align: center; + display: inline-block; + } + button { + display: inline-block; + } + float: right; + } + article { + text-decoration: underline; + margin-bottom: 1.3vw; + } + input { + width: 100%; + border-radius: 0.5vw; + padding: 0.7vw; + background-color: #B0B0B0; + color: white; + margin-bottom: 0; + } + button { + font-size: 12px; + border-radius: 7px; + padding-right: 30px; + padding-left: 30px; + padding-top: 5px; + padding-bottom: 5px; + left: 1.5vw; + } +} diff --git a/lab-yana/app/component/gallery/upload-pic/upload-pic.html b/lab-yana/app/component/gallery/upload-pic/upload-pic.html new file mode 100644 index 00000000..bc37bcf4 --- /dev/null +++ b/lab-yana/app/component/gallery/upload-pic/upload-pic.html @@ -0,0 +1,17 @@ +
    +
    +
    upload a new pic:
    +
    + + +
    +
    +
    + select an image to upload +
    + +
    +
    +
    diff --git a/lab-yana/app/component/gallery/upload-pic/upload-pic.js b/lab-yana/app/component/gallery/upload-pic/upload-pic.js new file mode 100644 index 00000000..2e28186a --- /dev/null +++ b/lab-yana/app/component/gallery/upload-pic/upload-pic.js @@ -0,0 +1,29 @@ +'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() { + $log.debug('UploadPicController.uploadPic'); + + picService.uploadGalleryPic(this.gallery, this.pic) + .then( () => { + this.pic.name = null; + this.pic.desc = null; + this.pic.file = null; + }); + }; +} diff --git a/lab-yana/app/service/photo-service.js b/lab-yana/app/service/photo-service.js deleted file mode 100644 index 4594db8a..00000000 --- a/lab-yana/app/service/photo-service.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -module.exports = ['$q', '$log', '$http', 'Upload', 'authService', photoService]; - -function photoService($q, $log, $http, Upload, authService) { - $log.debug('photoService'); - - let service = {}; - - service.uploadGalleryPhoto = function(galleryData, photoData) { - $log.debug('photoService.uploadGalleryPhoto'); - - 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: photoData.name, - desc: photoData.desc, - file: photoData.file - } - }); - }) - .then(response => { - galleryData.photos.unshift(response.data); - return response.data; - }) - .catch(err => { - $log.error(err.message); - return $q.reject(err); - }); - }; - - return service; -} diff --git a/lab-yana/app/service/pic-service.js b/lab-yana/app/service/pic-service.js new file mode 100644 index 00000000..b5c71091 --- /dev/null +++ b/lab-yana/app/service/pic-service.js @@ -0,0 +1,67 @@ +'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('picService.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(response => { + $log.debug('galleryData', galleryData); + galleryData.pics.unshift(response.data); + $log.debug('galleryData.pics', galleryData.pics); + return response.data; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deleteGalleryPic = function(galleryData, picData) { + $log.debug('picService.deleteGalleryPic'); + + 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( () => { + $log.log('photo deleted'); + galleryData.pics.splice(galleryData.pics.indexOf(picData), 1); + return; + }) + .catch(err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + + return service; +} diff --git a/lab-yana/package.json b/lab-yana/package.json index d96ac2b3..efda2da8 100644 --- a/lab-yana/package.json +++ b/lab-yana/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", + "build-watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", "lint": "./node_modules/eslint/bin/eslint.js **/*.js", "test": "./node_modules/karma/bin/karma start --single-run", "test-watch": "./node_modules/karma/bin/karma start" From c8b2f63a48f5f92530357e97310ca7a93682f295 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 4 Apr 2017 13:33:13 -0700 Subject: [PATCH 21/29] added testing framework --- lab-yana/{karma.config.js => karma.conf.js} | 15 +++++++++------ lab-yana/package.json | 7 +++++++ lab-yana/test/example-test.js | 7 +++++++ 3 files changed, 23 insertions(+), 6 deletions(-) rename lab-yana/{karma.config.js => karma.conf.js} (85%) create mode 100644 lab-yana/test/example-test.js diff --git a/lab-yana/karma.config.js b/lab-yana/karma.conf.js similarity index 85% rename from lab-yana/karma.config.js rename to lab-yana/karma.conf.js index 3ae9469c..765179e5 100644 --- a/lab-yana/karma.config.js +++ b/lab-yana/karma.conf.js @@ -1,14 +1,14 @@ // Karma configuration // Generated on Wed Mar 22 2017 12:51:00 GMT-0700 (PDT) -const webpackConfig = require('./webpack.config.js'); -webpackConfig.entry = {}; +const webpack = require('./webpack.config.js'); +delete webpack.entry; module.exports = function(config) { config.set({ // to wire to webpack - webpack: webpackConfig, + webpack, // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -21,7 +21,9 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'test/**/*-test.js' + 'app/entry.js', + 'test/**/*-test.js', + 'node_modules/angular-mocks/angular-mocks.js' ], @@ -33,7 +35,8 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'test/**/*-test.js': ['webpack'] + 'test/**/*-test.js': ['webpack'], + 'app/entry.js': ['webpack'] }, @@ -62,7 +65,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['Chrome'], // Continuous Integration mode diff --git a/lab-yana/package.json b/lab-yana/package.json index efda2da8..128b8521 100644 --- a/lab-yana/package.json +++ b/lab-yana/package.json @@ -42,6 +42,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-yana/test/example-test.js b/lab-yana/test/example-test.js new file mode 100644 index 00000000..7eba6c36 --- /dev/null +++ b/lab-yana/test/example-test.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('Example Test', function() { + it('should pass', () => { + expect(true).toEqual(true); + }); +}); From 190f53f4ed794b1f5ae3306aada3ce94c1042436 Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 4 Apr 2017 14:13:44 -0700 Subject: [PATCH 22/29] added auth get token and create gallery tests --- lab-yana/test/auth-service-test.js | 23 ++++++++++++++++ lab-yana/test/gallery-service-test.js | 38 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 lab-yana/test/auth-service-test.js create mode 100644 lab-yana/test/gallery-service-test.js diff --git a/lab-yana/test/auth-service-test.js b/lab-yana/test/auth-service-test.js new file mode 100644 index 00000000..e29956f5 --- /dev/null +++ b/lab-yana/test/auth-service-test.js @@ -0,0 +1,23 @@ +'use strict'; + +describe('Auth Service', function() { + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, $window, $httpBackend) => { + this.$rootScope = $rootScope; + this.authService = authService; + this.$httpBackend = $httpBackend; + this.$window = $window; + }); + }); + 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(); + }); + }); +}); diff --git a/lab-yana/test/gallery-service-test.js b/lab-yana/test/gallery-service-test.js new file mode 100644 index 00000000..50c3e11c --- /dev/null +++ b/lab-yana/test/gallery-service-test.js @@ -0,0 +1,38 @@ +'use strict'; + +describe('Gallery Service', function() { + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, galleryService, $window, $httpBackend) => { + this.$rootScope = $rootScope; + this.authService = authService; + this.galleryService = galleryService; + this.$httpBackend = $httpBackend; + this.$window = $window; + }); + }); + describe('galleryService.createGallery', () => { + it('should create a new gallery', () => { + let galleryData = { + name: 'example gallery name', + desc: 'example gallery description' + }; + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + this.$httpBackend.expectPOST('http://localhost:3003/api/gallery', galleryData, headers) + .respond(200, { + _id: '42', + username: 'exampleuser', + name: galleryData.name, + desc: galleryData.desc, + pics: [] + }); + this.galleryService.createGallery(galleryData); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); +}); From 86e55fbcab4fb45736ed78be46f477874c998c8a Mon Sep 17 00:00:00 2001 From: radenska Date: Tue, 4 Apr 2017 15:49:43 -0700 Subject: [PATCH 23/29] assignment finished --- lab-yana/test/example-test.js | 7 ---- lab-yana/test/gallery-service-test.js | 48 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 7 deletions(-) delete mode 100644 lab-yana/test/example-test.js diff --git a/lab-yana/test/example-test.js b/lab-yana/test/example-test.js deleted file mode 100644 index 7eba6c36..00000000 --- a/lab-yana/test/example-test.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -describe('Example Test', function() { - it('should pass', () => { - expect(true).toEqual(true); - }); -}); diff --git a/lab-yana/test/gallery-service-test.js b/lab-yana/test/gallery-service-test.js index 50c3e11c..ab7eaaa1 100644 --- a/lab-yana/test/gallery-service-test.js +++ b/lab-yana/test/gallery-service-test.js @@ -35,4 +35,52 @@ describe('Gallery Service', function() { this.$rootScope.$apply(); }); }); + describe('galleryService.fetchGalleries', () => { + it('should get a gallery', () => { + let headers = { + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + this.$httpBackend.expectGET('http://localhost:3003/api/gallery', headers) + .respond(200, { + _id: '42', + username: 'exampleuser', + name: 'example gallery name', + desc: 'example gallery description', + pics: [] + }); + this.$rootScope.$apply(); + }); + }); + describe('galleryService.updateGallery', () => { + it('should update a gallery', () => { + let galleryData = { + name: 'new gallery name', + desc: 'new gallery description' + }; + let config = { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + } + }; + this.$httpBackend.expectPUT('http://localhost:3003/api/gallery/', galleryData, config) + .respond(200, { + _id: '42', + username: 'exampleuser', + name: 'new gallery name', + desc: 'new gallery description', + pics: [] + }); + this.$rootScope.$apply(); + }); + }); + describe('galleryService.deleteGallery', () => { + it('should delete a gallery', () => { + this.$httpBackend.expectDELETE('http://localhost:3003/api/gallery/42') + .respond(204); + this.$rootScope.$apply(); + }); + }); }); From 3ad9073ee62ff5f73fab828f63035b719fb63838 Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 5 Apr 2017 13:48:55 -0700 Subject: [PATCH 24/29] added delete test --- lab-yana/test/auth-service-test.js | 3 +- lab-yana/test/edit-gallery-component-test.js | 7 ++++ lab-yana/test/gallery-item-component-test.js | 0 lab-yana/test/gallery-service-test.js | 43 +------------------- 4 files changed, 10 insertions(+), 43 deletions(-) create mode 100644 lab-yana/test/edit-gallery-component-test.js create mode 100644 lab-yana/test/gallery-item-component-test.js diff --git a/lab-yana/test/auth-service-test.js b/lab-yana/test/auth-service-test.js index e29956f5..24350431 100644 --- a/lab-yana/test/auth-service-test.js +++ b/lab-yana/test/auth-service-test.js @@ -3,10 +3,9 @@ describe('Auth Service', function() { beforeEach(() => { angular.mock.module('cfgram'); - angular.mock.inject(($rootScope, authService, $window, $httpBackend) => { + angular.mock.inject(($rootScope, authService, $window) => { this.$rootScope = $rootScope; this.authService = authService; - this.$httpBackend = $httpBackend; this.$window = $window; }); }); diff --git a/lab-yana/test/edit-gallery-component-test.js b/lab-yana/test/edit-gallery-component-test.js new file mode 100644 index 00000000..a2bf68cf --- /dev/null +++ b/lab-yana/test/edit-gallery-component-test.js @@ -0,0 +1,7 @@ +'use strict'; + +describe('Edit Gallery Component', function() { + beforeEach(() => { + + }); +}); diff --git a/lab-yana/test/gallery-item-component-test.js b/lab-yana/test/gallery-item-component-test.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/test/gallery-service-test.js b/lab-yana/test/gallery-service-test.js index ab7eaaa1..bdd758a2 100644 --- a/lab-yana/test/gallery-service-test.js +++ b/lab-yana/test/gallery-service-test.js @@ -35,51 +35,12 @@ describe('Gallery Service', function() { this.$rootScope.$apply(); }); }); - describe('galleryService.fetchGalleries', () => { - it('should get a gallery', () => { - let headers = { - Accept: 'application/json', - Authorization: 'Bearer test token' - }; - this.$httpBackend.expectGET('http://localhost:3003/api/gallery', headers) - .respond(200, { - _id: '42', - username: 'exampleuser', - name: 'example gallery name', - desc: 'example gallery description', - pics: [] - }); - this.$rootScope.$apply(); - }); - }); - describe('galleryService.updateGallery', () => { - it('should update a gallery', () => { - let galleryData = { - name: 'new gallery name', - desc: 'new gallery description' - }; - let config = { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - Authorization: 'Bearer test token' - } - }; - this.$httpBackend.expectPUT('http://localhost:3003/api/gallery/', galleryData, config) - .respond(200, { - _id: '42', - username: 'exampleuser', - name: 'new gallery name', - desc: 'new gallery description', - pics: [] - }); - this.$rootScope.$apply(); - }); - }); describe('galleryService.deleteGallery', () => { it('should delete a gallery', () => { this.$httpBackend.expectDELETE('http://localhost:3003/api/gallery/42') .respond(204); + this.galleryService.deleteGallery('42'); + expect(this.galleryService.galleries.length).toEqual(0); this.$rootScope.$apply(); }); }); From 60e95a1f61694d3e7cda84e52485a2c131d55107 Mon Sep 17 00:00:00 2001 From: radenska Date: Wed, 5 Apr 2017 17:08:59 -0700 Subject: [PATCH 25/29] this assignment makes no sense --- lab-yana/test/edit-gallery-component-test.js | 43 +++++++++- lab-yana/test/gallery-item-component-test.js | 82 ++++++++++++++++++++ lab-yana/test/gallery-service-test.js | 1 - 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/lab-yana/test/edit-gallery-component-test.js b/lab-yana/test/edit-gallery-component-test.js index a2bf68cf..4aee2e89 100644 --- a/lab-yana/test/edit-gallery-component-test.js +++ b/lab-yana/test/edit-gallery-component-test.js @@ -2,6 +2,47 @@ 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 bindings = { + gallery: { + name: 'test gallery name', + desc: 'test gallery description' + } + }; + let editGalleryCtrl = this.$componentController('editGallery', null, bindings); + expect(editGalleryCtrl.gallery.name).toEqual(bindings.gallery.name); + expect(editGalleryCtrl.gallery.desc).toEqual(bindings.gallery.desc); + this.$rootScope.$apply(); + }); + describe('editGalleryCtrl.updateGallery()', () => { + it('should make a valid PUT request', () => { + let url = 'http://localhost:3003/api/gallery/4242'; + let headers = { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: 'Bearer test token' + }; + let tempGallery = { + _id: '4242', + name: 'updated name', + desc: 'updated desc' + }; + this.$httpBackend.expectPUT(url, tempGallery, headers).respond(200); + + let bindings = { gallery: tempGallery }; + let editGalleryCtrl = this.$componentController('editGallery', null, bindings); + editGalleryCtrl.updateGallery(); + expect(editGalleryCtrl.gallery.name).toEqual('updated name'); + expect(editGalleryCtrl.gallery.desc).toEqual('updated desc'); + this.$rootScope.$apply(); + }); + }) }); diff --git a/lab-yana/test/gallery-item-component-test.js b/lab-yana/test/gallery-item-component-test.js index e69de29b..6ef7f433 100644 --- a/lab-yana/test/gallery-item-component-test.js +++ b/lab-yana/test/gallery-item-component-test.js @@ -0,0 +1,82 @@ +'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 bindings = { + gallery: { + _id: '4242', + name: 'test gallery name', + desc: 'test gallery description', + pics: [], + }, + deleteDone: function(data) { + expect(data.galleryData._id).toEqual('4242'); + } + }; + let galleryItemCtrl = this.$componentController('galleryItem', null, bindings); + galleryItemCtrl.deleteDone({ galleryData: galleryItemCtrl.gallery }); + + this.$rootScope.$apply(); + }); + }); + it('should call deleteDone with gallery after deleteGallery', () => { + let url = 'http://localhost:3003/api/gallery/4242'; + let headers = { + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + let tempGallery = { + _id: '4242', + name: 'test name', + desc: 'test desc' + }; + let bindings = { + gallery: tempGallery, + deleteDone: function(data) { + expect(data.galleryData._id).toEqual('4242'); + } + }; + this.$httpBackend.expectDELETE(url, headers).respond(204); + let galleryItemCtrl = this.$componentController('galleryItem', null, bindings); + // spyOn(galleryItemCtrl, 'deleteDone'); + galleryItemCtrl.deleteGallery('4242'); + // expect(galleryItemCtrl.deleteDone).toHaveBeenCalledWith('4242'); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + describe('galleryItemCtrl.deleteGallery()', () => { + it('should make a valid DELETE request', () => { + let url = 'http://localhost:3003/api/gallery/4242'; + let headers = { + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + let tempGallery = { + _id: '4242', + name: 'test name', + desc: 'test desc' + }; + let bindings = { + gallery: tempGallery, + deleteDone: function(data) { + expect(data.galleryData._id).toEqual('4242'); + } + }; + this.$httpBackend.expectDELETE(url, headers).respond(204); + let galleryItemCtrl = this.$componentController('galleryItem', null, bindings); + galleryItemCtrl.deleteGallery(tempGallery._id) + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); +}); +}); diff --git a/lab-yana/test/gallery-service-test.js b/lab-yana/test/gallery-service-test.js index bdd758a2..193967cb 100644 --- a/lab-yana/test/gallery-service-test.js +++ b/lab-yana/test/gallery-service-test.js @@ -40,7 +40,6 @@ describe('Gallery Service', function() { this.$httpBackend.expectDELETE('http://localhost:3003/api/gallery/42') .respond(204); this.galleryService.deleteGallery('42'); - expect(this.galleryService.galleries.length).toEqual(0); this.$rootScope.$apply(); }); }); From 6c16d2845e11f08b1a7e576710605d7b4597730c Mon Sep 17 00:00:00 2001 From: radenska Date: Thu, 6 Apr 2017 12:24:03 -0700 Subject: [PATCH 26/29] added filter and changed entry.js --- lab-yana/app/directive/social-icons.html | 0 lab-yana/app/directive/social-icons.js | 0 lab-yana/app/entry.js | 14 ++++++++++++++ lab-yana/app/filter/gallery-filter.js | 16 ++++++++++++++++ lab-yana/app/view/home/home.html | 3 ++- 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lab-yana/app/directive/social-icons.html create mode 100644 lab-yana/app/directive/social-icons.js create mode 100644 lab-yana/app/filter/gallery-filter.js diff --git a/lab-yana/app/directive/social-icons.html b/lab-yana/app/directive/social-icons.html new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/directive/social-icons.js b/lab-yana/app/directive/social-icons.js new file mode 100644 index 00000000..e69de29b diff --git a/lab-yana/app/entry.js b/lab-yana/app/entry.js index f5d6c71d..bfc878ae 100644 --- a/lab-yana/app/entry.js +++ b/lab-yana/app/entry.js @@ -36,3 +36,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/lab-yana/app/filter/gallery-filter.js b/lab-yana/app/filter/gallery-filter.js new file mode 100644 index 00000000..17b1d35a --- /dev/null +++ b/lab-yana/app/filter/gallery-filter.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = function() { + return function(galleries, searchTerm) { + let fuzzyRegex = makeFuzzyRegex(searchTerm); + return galleries.filter(gallery => { + return fuzzyRegex.test(gallery.name.toUpperCase()) || fuzzyRegex.test(gallery.desc.toUpperCase()); + }); + }; +}; + +function makeFuzzyRegex(input) { + if (!input) return /.*/; + let fuzzyString = '.*' + input.toUpperCase().split('').join('.*') + '.*'; + return new RegExp(fuzzyString); +} diff --git a/lab-yana/app/view/home/home.html b/lab-yana/app/view/home/home.html index cfecd07d..fb25678c 100644 --- a/lab-yana/app/view/home/home.html +++ b/lab-yana/app/view/home/home.html @@ -1,10 +1,11 @@
    +
    diff --git a/lab-yana/app/directive/social-icons.html b/lab-yana/app/directive/social-icons.html index e69de29b..a2b85992 100644 --- a/lab-yana/app/directive/social-icons.html +++ b/lab-yana/app/directive/social-icons.html @@ -0,0 +1,5 @@ + diff --git a/lab-yana/app/directive/social-icons.js b/lab-yana/app/directive/social-icons.js index e69de29b..cc9f4733 100644 --- a/lab-yana/app/directive/social-icons.js +++ b/lab-yana/app/directive/social-icons.js @@ -0,0 +1,21 @@ +'use strict'; + +require('./_social-icons.scss'); + +module.exports = function() { + return { + restrict: 'EAC', + template: require('./social-icons.html'), + controller: ['$log', SocialIconsController], + bindToController: true, + controllerAs: 'socialIconsCtrl', + scope: { + cssClass: '@' + } + }; +}; + +function SocialIconsController($log) { + $log.debug('SocialIconsController'); + this.icons = ['fb', 'twitter', 'youtube', 'instagram', 'in', 't', 'google-plus']; +} diff --git a/lab-yana/app/index.html b/lab-yana/app/index.html index 61fe8926..e41df85e 100644 --- a/lab-yana/app/index.html +++ b/lab-yana/app/index.html @@ -13,9 +13,9 @@
    - -