diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..c13c5f62 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/.env b/.env new file mode 100644 index 00000000..fb40bb2b --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +API_URL='https://slugram-backend.herokuapp.com' + diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..5c4b8b70 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,218 @@ +{ + // http://eslint.org/docs/rules/ + //taken from https://gist.github.com/cletusw/e01a85e399ab563b1236 + + "ecmaFeatures": { + "binaryLiterals": false, // enable binary literals + "blockBindings": false, // enable let and const (aka block bindings) + "defaultParams": false, // enable default function parameters + "forOf": false, // enable for-of loops + "generators": false, // enable generators + "objectLiteralComputedProperties": false, // enable computed object literal property names + "objectLiteralDuplicateProperties": false, // enable duplicate object literal properties in strict mode + "objectLiteralShorthandMethods": false, // enable object literal shorthand methods + "objectLiteralShorthandProperties": false, // enable object literal shorthand properties + "octalLiterals": false, // enable octal literals + "regexUFlag": false, // enable the regular expression u flag + "regexYFlag": false, // enable the regular expression y flag + "templateStrings": false, // enable template strings + "unicodeCodePointEscapes": false, // enable code point escapes + "jsx": false // enable JSX + }, + + "env": { + "browser": false, // browser global variables. + "node": false, // Node.js global variables and Node.js-specific rules. + "amd": false, // defines require() and define() as global variables as per the amd spec. + "mocha": false, // adds all of the Mocha testing global variables. + "jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0. + "phantomjs": false, // phantomjs global variables. + "jquery": false, // jquery global variables. + "prototypejs": false, // prototypejs global variables. + "shelljs": false, // shelljs global variables. + }, + + "globals": { + // e.g. "angular": true + }, + + "plugins": [ + // e.g. "react" (must run `npm install eslint-plugin-react` first) + ], + + "rules": { + ////////// Possible Errors ////////// + + "no-comma-dangle": 0, // disallow trailing commas in object literals + "no-cond-assign": 0, // disallow assignment in conditional expressions + "no-console": 0, // disallow use of console (off by default in the node environment) + "no-constant-condition": 0, // disallow use of constant expressions in conditions + "no-control-regex": 0, // disallow control characters in regular expressions + "no-debugger": 0, // disallow use of debugger + "no-dupe-keys": 0, // disallow duplicate keys when creating object literals + "no-empty": 0, // disallow empty statements + "no-empty-class": 0, // disallow the use of empty character classes in regular expressions + "no-ex-assign": 0, // disallow assigning to the exception in a catch block + "no-extra-boolean-cast": 0, // disallow double-negation boolean casts in a boolean context + "no-extra-parens": 0, // disallow unnecessary parentheses (off by default) + "no-extra-semi": 0, // disallow unnecessary semicolons + "no-func-assign": 0, // disallow overwriting functions written as function declarations + "no-inner-declarations": 0, // disallow function or variable declarations in nested blocks + "no-invalid-regexp": 0, // disallow invalid regular expression strings in the RegExp constructor + "no-irregular-whitespace": 0, // disallow irregular whitespace outside of strings and comments + "no-negated-in-lhs": 0, // disallow negation of the left operand of an in expression + "no-obj-calls": 0, // disallow the use of object properties of the global object (Math and JSON) as functions + "no-regex-spaces": 0, // disallow multiple spaces in a regular expression literal + "no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default) + "no-sparse-arrays": 0, // disallow sparse arrays + "no-unreachable": 0, // disallow unreachable statements after a return, throw, continue, or break statement + "use-isnan": 0, // disallow comparisons with the value NaN + "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default) + "valid-typeof": 0, // Ensure that the results of typeof are compared against a valid string + + + ////////// Best Practices ////////// + + "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default) + "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default) + "consistent-return": 0, // require return statements to either always or never specify values + "curly": 0, // specify curly brace conventions for all control statements + "default-case": 0, // require default case in switch statements (off by default) + "dot-notation": 0, // encourages use of dot notation whenever possible + "eqeqeq": 0, // require the use of === and !== + "guard-for-in": 0, // make sure for-in loops have an if statement (off by default) + "no-alert": 0, // disallow the use of alert, confirm, and prompt + "no-caller": 0, // disallow use of arguments.caller or arguments.callee + "no-div-regex": 0, // disallow division operators explicitly at beginning of regular expression (off by default) + "no-else-return": 0, // disallow else after a return in an if (off by default) + "no-empty-label": 0, // disallow use of labels for anything other then loops and switches + "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default) + "no-eval": 0, // disallow use of eval() + "no-extend-native": 0, // disallow adding to native types + "no-extra-bind": 0, // disallow unnecessary function binding + "no-fallthrough": 0, // disallow fallthrough of case statements + "no-floating-decimal": 0, // disallow the use of leading or trailing decimal points in numeric literals (off by default) + "no-implied-eval": 0, // disallow use of eval()-like methods + "no-iterator": 0, // disallow usage of __iterator__ property + "no-labels": 0, // disallow use of labeled statements + "no-lone-blocks": 0, // disallow unnecessary nested blocks + "no-loop-func": 0, // disallow creation of functions within loops + "no-multi-spaces": 0, // disallow use of multiple spaces + "no-multi-str": 0, // disallow use of multiline strings + "no-native-reassign": 0, // disallow reassignments of native objects + "no-new": 0, // disallow use of new operator when not part of the assignment or comparison + "no-new-func": 0, // disallow use of new operator for Function object + "no-new-wrappers": 0, // disallows creating new instances of String, Number, and Boolean + "no-octal": 0, // disallow use of octal literals + "no-octal-escape": 0, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; + "no-process-env": 0, // disallow use of process.env (off by default) + "no-proto": 0, // disallow usage of __proto__ property + "no-redeclare": 0, // disallow declaring the same variable more then once + "no-return-assign": 0, // disallow use of assignment in return statement + "no-script-url": 0, // disallow use of javascript: urls. + "no-self-compare": 0, // disallow comparisons where both sides are exactly the same (off by default) + "no-sequences": 0, // disallow use of comma operator + "no-unused-expressions": 0, // disallow usage of expressions in statement position + "no-void": 0, // disallow use of void operator (off by default) + "no-warning-comments": 0, // disallow usage of configurable warning terms in comments, e.g. TODO or FIXME (off by default) + "no-with": 0, // disallow use of the with statement + "radix": 0, // require use of the second argument for parseInt() (off by default) + "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default) + "wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default) + "yoda": 0, // require or disallow Yoda conditions + + + ////////// Strict Mode ////////// + + "global-strict": 0, // (deprecated) require or disallow the "use strict" pragma in the global scope (off by default in the node environment) + "no-extra-strict": 0, // (deprecated) disallow unnecessary use of "use strict"; when already in strict mode + "strict": 0, // controls location of Use Strict Directives + + + ////////// Variables ////////// + + "no-catch-shadow": 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) + "no-delete-var": 0, // disallow deletion of variables + "no-label-var": 0, // disallow labels that share a name with a variable + "no-shadow": 0, // disallow declaration of variables already declared in the outer scope + "no-shadow-restricted-names": 0, // disallow shadowing of names such as arguments + "no-undef": 0, // disallow use of undeclared variables unless mentioned in a /*global */ block + "no-undef-init": 0, // disallow use of undefined when initializing variables + "no-undefined": 0, // disallow use of undefined variable (off by default) + "no-unused-vars": 0, // disallow declaration of variables that are not used in the code + "no-use-before-define": 0, // disallow use of variables before they are defined + + + ////////// Node.js ////////// + + "handle-callback-err": 0, // enforces error handling in callbacks (off by default) (on by default in the node environment) + "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) + "no-new-require": 0, // disallow use of new operator with the require function (off by default) (on by default in the node environment) + "no-path-concat": 0, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) + "no-process-exit": 0, // disallow process.exit() (on by default in the node environment) + "no-restricted-modules": 0, // restrict usage of specified node modules (off by default) + "no-sync": 0, // disallow use of synchronous methods (off by default) + + + ////////// Stylistic Issues ////////// + + "brace-style": 0, // enforce one true brace style (off by default) + "camelcase": 0, // require camel case names + "comma-spacing": 0, // enforce spacing before and after comma + "comma-style": 0, // enforce one true comma style (off by default) + "consistent-this": 0, // enforces consistent naming when capturing the current execution context (off by default) + "eol-last": 0, // enforce newline at the end of file, with no multiple empty lines + "func-names": 0, // require function expressions to have a name (off by default) + "func-style": 0, // enforces use of function declarations or expressions (off by default) + "key-spacing": 0, // enforces spacing between keys and values in object literal properties + "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default) + "new-cap": 0, // require a capital letter for constructors + "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments + "no-array-constructor": 0, // disallow use of the Array constructor + "no-inline-comments": 0, // disallow comments inline after code (off by default) + "no-lonely-if": 0, // disallow if as the only statement in an else block (off by default) + "no-mixed-spaces-and-tabs": 0, // disallow mixed spaces and tabs for indentation + "no-multiple-empty-lines": 0, // disallow multiple empty lines (off by default) + "no-nested-ternary": 0, // disallow nested ternary expressions (off by default) + "no-new-object": 0, // disallow use of the Object constructor + "no-space-before-semi": 0, // disallow space before semicolon + "no-spaced-func": 0, // disallow space between function identifier and application + "no-ternary": 0, // disallow the use of ternary operators (off by default) + "no-trailing-spaces": 0, // disallow trailing whitespace at the end of lines + "no-underscore-dangle": 0, // disallow dangling underscores in identifiers + "no-wrap-func": 0, // disallow wrapping of non-IIFE statements in parens + "one-var": 0, // allow just one var statement per function (off by default) + "operator-assignment": 0, // require assignment operator shorthand where possible or prohibit it entirely (off by default) + "padded-blocks": 0, // enforce padding within blocks (off by default) + "quote-props": 0, // require quotes around object literal property names (off by default) + "quotes": 0, // specify whether double or single quotes should be used + "semi": 0, // require or disallow use of semicolons instead of ASI + "sort-vars": 0, // sort variables within the same declaration block (off by default) + "space-after-function-name": 0, // require a space after function names (off by default) + "space-after-keywords": 0, // require a space after certain keywords (off by default) + "space-before-blocks": 0, // require or disallow space before blocks (off by default) + "space-in-brackets": 0, // require or disallow spaces inside brackets (off by default) + "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default) + "space-infix-ops": 0, // require spaces around operators + "space-return-throw-case": 0, // require a space after return, throw, and case + "space-unary-ops": 0, // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default) + "spaced-line-comment": 0, // require or disallow a space immediately following the // in a line comment (off by default) + "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default) + + + ////////// ECMAScript 6 ////////// + + "no-var": 0, // require let or const instead of var (off by default) + "generator-star": 0, // enforce the position of the * in generator functions (off by default) + + + ////////// Legacy ////////// + + "max-depth": 0, // specify the maximum depth that blocks can be nested (off by default) + "max-len": 0, // specify the maximum length of a line in your program (off by default) + "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default) + "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default) + "no-bitwise": 0, // disallow use of bitwise operators (off by default) + "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default) + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6621ff4c --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# Created by https://www.gitignore.io/api/node + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +#Build Directory +build/ + +# End of https://www.gitignore.io/api/node diff --git a/app/component/gallery/create-gallery/_create-gallery.scss b/app/component/gallery/create-gallery/_create-gallery.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/component/gallery/create-gallery/_create-gallery.scss @@ -0,0 +1 @@ + diff --git a/app/component/gallery/create-gallery/create-gallery.html b/app/component/gallery/create-gallery/create-gallery.html new file mode 100644 index 00000000..310df324 --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.html @@ -0,0 +1,20 @@ + diff --git a/app/component/gallery/create-gallery/create-gallery.js b/app/component/gallery/create-gallery/create-gallery.js new file mode 100644 index 00000000..986ac8e4 --- /dev/null +++ b/app/component/gallery/create-gallery/create-gallery.js @@ -0,0 +1,22 @@ +'use strict'; + + +module.exports = { + template: require('./create-gallery.html'), + controller: ['$log', 'galleryService', CreateGalleryController], + controllerAs: 'createGalleryCtrl' +}; + +function CreateGalleryController($log, galleryService) { + $log.debug('CreateGalleryController'); + + this.gallery = {}; + + this.createGallery = function() { + galleryService.createGallery(this.gallery) + .then( () => { + this.gallery.name = null; + this.gallery.desc = null; + }); + }; +}; diff --git a/app/component/gallery/edit-gallery/_edit-gallery.scss b/app/component/gallery/edit-gallery/_edit-gallery.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/component/gallery/edit-gallery/_edit-gallery.scss @@ -0,0 +1 @@ + diff --git a/app/component/gallery/edit-gallery/edit-gallery.html b/app/component/gallery/edit-gallery/edit-gallery.html new file mode 100644 index 00000000..a7efeaf8 --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.html @@ -0,0 +1,26 @@ +
+ +
+ +
diff --git a/app/component/gallery/edit-gallery/edit-gallery.js b/app/component/gallery/edit-gallery/edit-gallery.js new file mode 100644 index 00000000..2564a90e --- /dev/null +++ b/app/component/gallery/edit-gallery/edit-gallery.js @@ -0,0 +1,21 @@ +'use strict'; + +require('./_edit-gallery.scss'); + +module.exports = { + template: require('./edit-gallery.html'), + controller: ['$log', 'galleryService', EditGalleryController], + controllerAs: 'editGalleryCtrl', + bindings: { + gallery: '<' + } +}; + +function EditGalleryController($log, galleryService) { + $log.debug('EditGalleryController'); + + this.updateGallery = function() { + $log.debug('editGalleryCtrl.updateGallery'); + galleryService.updateGallery(this.gallery._id, this.gallery); + }; +}; diff --git a/app/component/gallery/gallery-item/_gallery-item.scss b/app/component/gallery/gallery-item/_gallery-item.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/component/gallery/gallery-item/_gallery-item.scss @@ -0,0 +1 @@ + diff --git a/app/component/gallery/gallery-item/gallery-item.html b/app/component/gallery/gallery-item/gallery-item.html new file mode 100644 index 00000000..69587e02 --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.html @@ -0,0 +1,24 @@ + diff --git a/app/component/gallery/gallery-item/gallery-item.js b/app/component/gallery/gallery-item/gallery-item.js new file mode 100644 index 00000000..18453222 --- /dev/null +++ b/app/component/gallery/gallery-item/gallery-item.js @@ -0,0 +1,22 @@ +'use strict'; + +require('./_gallery-item.scss'); + +module.exports = { + template: require('./gallery-item.html'), + controller: ['$log', 'galleryService', GalleryItemController], + controllerAs: 'galleryItemCtrl', + bindings: { + gallery: '<' + } +}; + +function GalleryItemController($log, galleryService) { + $log.debug('GalleryItemController'); + + this.showEditGallery = false; + + this.deleteGallery = function() { + galleryService.deleteGallery(this.gallery._id); + }; +}; diff --git a/app/component/landing/login/_login.scss b/app/component/landing/login/_login.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/component/landing/login/_login.scss @@ -0,0 +1 @@ + diff --git a/app/component/landing/login/login.html b/app/component/landing/login/login.html new file mode 100644 index 00000000..48f40868 --- /dev/null +++ b/app/component/landing/login/login.html @@ -0,0 +1,35 @@ +
+ +
+
+ +
+ +
+ +
+ + +
+
diff --git a/app/component/landing/login/login.js b/app/component/landing/login/login.js new file mode 100644 index 00000000..dec7c927 --- /dev/null +++ b/app/component/landing/login/login.js @@ -0,0 +1,27 @@ +'use strict'; + +require('./_login.scss'); + +module.exports = { + template: require('./login.html'), + controller: ['$log', '$location', 'authService', LoginController], + controllerAs: 'loginCtrl' +}; + +function LoginController($log, $location, authService) { + $log.debug('LoginController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.login = function() { + $log.debug('loginCtrl.login'); + + authService.login(this.user) + .then( () => { + $location.url('/home'); + }); + }; +}; diff --git a/app/component/landing/signup/_signup.scss b/app/component/landing/signup/_signup.scss new file mode 100644 index 00000000..44156dc7 --- /dev/null +++ b/app/component/landing/signup/_signup.scss @@ -0,0 +1,5 @@ +// input { +// padding: 3% 5%; +// position: absolute; +// right: 2% +// }; diff --git a/app/component/landing/signup/signup.html b/app/component/landing/signup/signup.html new file mode 100644 index 00000000..44bc8764 --- /dev/null +++ b/app/component/landing/signup/signup.html @@ -0,0 +1,25 @@ +
+
+ + + + + + + + +
+
diff --git a/app/component/landing/signup/signup.js b/app/component/landing/signup/signup.js new file mode 100644 index 00000000..b5923714 --- /dev/null +++ b/app/component/landing/signup/signup.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = { + template: require('./signup.html'), + controller: ['$log', '$location', 'authService', SignupController], + controllerAs: 'signupCtrl' +}; + +function SignupController($log, $location, authService) { + $log.debug('SignupController'); + + authService.getToken() + .then( () => { + $location.url('/home'); + }); + + this.signup = function(user) { + $log.debug('signupCtrl.signup'); + + authService.signup(user) + .then( () => { + $location.url('/home') + }); + }; +}; diff --git a/app/component/navbar/_navbar.scss b/app/component/navbar/_navbar.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/component/navbar/_navbar.scss @@ -0,0 +1 @@ + diff --git a/app/component/navbar/navbar.html b/app/component/navbar/navbar.html new file mode 100644 index 00000000..986f5951 --- /dev/null +++ b/app/component/navbar/navbar.html @@ -0,0 +1,12 @@ + + diff --git a/app/component/navbar/navbar.js b/app/component/navbar/navbar.js new file mode 100644 index 00000000..3f4fa068 --- /dev/null +++ b/app/component/navbar/navbar.js @@ -0,0 +1,43 @@ +'use strict'; + +require('./_navbar.scss'); + +module.exports = { + template: require('./navbar.html'), + controller: ['$log', '$location', '$rootScope', 'authService', NavbarController], + controllerAs: 'navbarCtrl' +}; + +function NavbarController($log, $location, $rootScope, authService) { + $log.debug('NavbarController'); + + this.checkPath = function() { + let path = $location.path(); + if (path === '/join') { + this.hideButtons = true; + }; + + if (path !== '/join') { + this.hideButtons = false; + authService.getToken() + .catch( () => { + $location.url('/join#login'); + }); + }; + }; + + this.checkPath(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.checkPath(); + }); + + this.logout = function() { + $log.log('navbarCtrl.logout'); + this.hideButtons = true; + authService.logout() + .then( () => { + $location.url('/'); + }); + }; +}; diff --git a/app/component/thumbnail-container/_thumbnail-container.scss b/app/component/thumbnail-container/_thumbnail-container.scss new file mode 100644 index 00000000..e69de29b diff --git a/app/component/thumbnail-container/thumbnail-container.html b/app/component/thumbnail-container/thumbnail-container.html new file mode 100644 index 00000000..1ea8a7c4 --- /dev/null +++ b/app/component/thumbnail-container/thumbnail-container.html @@ -0,0 +1,8 @@ +
+

{{ thumbnailContainerCtrl.gallery.name }}

+ + +
+ +
+
diff --git a/app/component/thumbnail-container/thumbnail-container.js b/app/component/thumbnail-container/thumbnail-container.js new file mode 100644 index 00000000..18bf16d4 --- /dev/null +++ b/app/component/thumbnail-container/thumbnail-container.js @@ -0,0 +1,11 @@ +'use strict'; + +require('./_thumbnail-container.scss'); + +module.exports = { + template: require('./thumbnail-container.html'), + controllerAs: 'thumbnailContainerCtrl', + bindings: { + gallery: '<' + } +}; diff --git a/app/component/thumbnail/_thumbnail.scss b/app/component/thumbnail/_thumbnail.scss new file mode 100644 index 00000000..ee30d229 --- /dev/null +++ b/app/component/thumbnail/_thumbnail.scss @@ -0,0 +1,22 @@ +$brand1 : #5a5d63; + +.clearfix{ + clear:both; +}; +img{ + position: relative; + width: 90%; + bottom: 0%; + margin-right: 5%; + +}; +#idherpes{ + position: absolute; + float: left; + padding: 1.5% 4%; + margin-left: 80%; + bottom: -32%; + background-color: $brand1; + color: white; + border-radius: 3px; +}; diff --git a/app/component/thumbnail/thumbnail.html b/app/component/thumbnail/thumbnail.html new file mode 100644 index 00000000..908be1d1 --- /dev/null +++ b/app/component/thumbnail/thumbnail.html @@ -0,0 +1,9 @@ +
+ {{ thumbnailCtrl.pic.desc }} + +
+ + +
+
+ delete diff --git a/app/component/thumbnail/thumbnail.js b/app/component/thumbnail/thumbnail.js new file mode 100644 index 00000000..ce238277 --- /dev/null +++ b/app/component/thumbnail/thumbnail.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./_thumbnail.scss'); + +module.exports = { + template: require('./thumbnail.html'), + controller: ['$log', 'picService', ThumbnailController], + controllerAs: 'thumbnailCtrl', + bindings: { + pic: '<', + gallery: '<' + } +}; + +function ThumbnailController($log, picService) { + $log.debug('ThumbnailController'); + + this.deletePic = function() { + $log.debug('thumbnailCtrl.deletePic'); + +picService.deleteGalleryPic(this.gallery, this.pic); + }; +} diff --git a/app/component/upload-pic/_upload-pic.scss b/app/component/upload-pic/_upload-pic.scss new file mode 100644 index 00000000..1d79cafe --- /dev/null +++ b/app/component/upload-pic/_upload-pic.scss @@ -0,0 +1,61 @@ +$brand1 : #5a5d63; +$brand2 : #aaacaf; +$brand3 : white; +$footer: #727882; + +//spacing +$gtter : 30px; +$btnpad : 3%; +$radius : 3px; +h2{ + margin-bottom: 5%; +}; +h3{ + position: relative; + top: 5%; + float: left; + left: 3%; + text-decoration: underline; + +}; + +.input-pic{ + // outline: $footer; + width: 80%; + display: block; + position: relative; + float: left; + margin-left: 3%; + margin-top: 2%; + padding: 2% 5%; + background-color: $footer; + border-style: none; + border-radius: 3px; +}; + +::-webkit-input-placeholder { /* Chrome/Opera/Safari */ + color: white; +}; + +p{ + display: inline-block; + position: relative; + top: 15%; + float: left; + left: 14%; + color: black; + text-decoration: underline; + &:hover{ + cursor: pointer; + } +}; +// .input-pic{ +// padding: 2% 8%; +// margin: 2%; +// margin-right: 10%; +// width: 80%; + +// display: flex; +// flex-direction: column; +// justify-content: center; +// }; diff --git a/app/component/upload-pic/upload-pic.html b/app/component/upload-pic/upload-pic.html new file mode 100644 index 00000000..cbea6ba5 --- /dev/null +++ b/app/component/upload-pic/upload-pic.html @@ -0,0 +1,30 @@ +
+
+

Some Gallery Name

+ +
+ +

upload a new pic:

+
+
+ + +
+ +
+ +
+

+ select an image to upload +

+
+ +
+ +
+ +
diff --git a/app/component/upload-pic/upload-pic.js b/app/component/upload-pic/upload-pic.js new file mode 100644 index 00000000..bd5f7987 --- /dev/null +++ b/app/component/upload-pic/upload-pic.js @@ -0,0 +1,28 @@ +'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() { + console.log('this.pic', this.pic); + picService.uploadGalleryPic(this.gallery, this.pic) + .then( () => { + this.pic.name = null; + this.pic.desc = null; + this.pic.file = null; + }); + }; +}; diff --git a/app/config/log-config.js b/app/config/log-config.js new file mode 100644 index 00000000..2c237451 --- /dev/null +++ b/app/config/log-config.js @@ -0,0 +1,8 @@ + +'use strict'; + +module.exports = ['$logProvider', logConfig]; + +function logConfig($logProvider) { + $logProvider.debugEnabled(__DEBUG__); +}; diff --git a/app/config/router-config.js b/app/config/router-config.js new file mode 100644 index 00000000..20a0dba4 --- /dev/null +++ b/app/config/router-config.js @@ -0,0 +1,30 @@ +'use strict'; + +module.exports = ['$stateProvider', '$urlRouterProvider', routerConfig]; + +function routerConfig($stateProvider, $urlRouterProvider) { + $urlRouterProvider.when('', '/join#signup'); + $urlRouterProvider.when('/', '/join#signup'); + $urlRouterProvider.when('/signup', '/join#signup'); + $urlRouterProvider.when('/login', '/join#login'); + +let states = [ + { + name: 'home', + url: '/home', + template: require('../view/home/home.html'), + controller: 'HomeController', + controllerAs: 'homeCtrl' + }, + { + name: 'landing', + url: '/join', + template: require('../view/landing/landing.html'), + controller: 'LandingController', + controllerAs: 'landingCtrl' + } +]; +states.forEach( state => { + $stateProvider.state(state); +}); +}; diff --git a/app/directive/social-icons.js b/app/directive/social-icons.js new file mode 100644 index 00000000..9d380b12 --- /dev/null +++ b/app/directive/social-icons.js @@ -0,0 +1,34 @@ +'use strict'; + +module.exports = function() { + return { + restrict: 'EAC', + template: require('./socialmedia-icons.html'), + controller: ['$log', SocialIconsController], + bindToController: true, + controllerAs: 'socialIconsCtrl', + scope: { + tester: '@' + } + }; +}; + +function SocialIconsController(icons) { + // $log.log(this); + // this.gotohell = 'whyohwhy?@!!!!!!!!!!!!!!!!!!!!!!!!!'; + this.icons = [ + { + name: 'evernote', + url: 'http://www.evernote.com' + }, + { + name: 'dribble', + url: 'http://www.dribble.com' + }, + { + name: 'instagram', + url: 'http://www.instagram.com' + } + ]; + } + \ No newline at end of file diff --git a/app/directive/social-media-icons-15.png b/app/directive/social-media-icons-15.png new file mode 100644 index 00000000..8a7b4bba Binary files /dev/null and b/app/directive/social-media-icons-15.png differ diff --git a/app/directive/socialmedia-icons.html b/app/directive/socialmedia-icons.html new file mode 100644 index 00000000..e71a5380 --- /dev/null +++ b/app/directive/socialmedia-icons.html @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/app/entry.js b/app/entry.js new file mode 100644 index 00000000..4ad936ba --- /dev/null +++ b/app/entry.js @@ -0,0 +1,55 @@ +'use strict'; + +require('./scss/main.scss'); + +const path = require('path'); +const angular = require('angular'); +const camelcase = require('camelcase'); +const pascalcase = require('pascalcase'); +const uiRouter = require('angular-ui-router'); +const ngTouch = require('angular-touch'); +const ngAnimate = require('angular-animate'); +const uiBootstrap = require('angular-ui-bootstrap'); +const ngFileUpload = require('ng-file-upload'); + +const cfgram = angular.module('cfgram', [ngTouch, ngAnimate, uiRouter, uiBootstrap, ngFileUpload]); + +let context = require.context('./config/', true, /\.js$/); +context.keys().forEach( key => { + cfgram.config(context(key)); +}); + +context = require.context('./view/', true, /\.js$/); +context.keys().forEach( key => { + let name = pascalcase(path.basename(key, '.js')); + let module = context(key); + cfgram.controller(name, module); +}); + +context = require.context('./service/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.service(name, module); +}); + +context = require.context('./component/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.component(name, module); +}); + +context = require.context('./filter/', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.filter(name, module); +}); + +context = require.context('./directive', true, /\.js$/); +context.keys().forEach( key => { + let name = camelcase(path.basename(key, '.js')); + let module = context(key); + cfgram.directive(name, module); +}); \ No newline at end of file diff --git a/app/filter/gallery-search.js b/app/filter/gallery-search.js new file mode 100644 index 00000000..773cc665 --- /dev/null +++ b/app/filter/gallery-search.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = function() { + return function (galleries, searchTerm) { + let fuzzyRegex = generateFuzzyRegex(searchTerm); + + return galleries.filter(gallery => { + return fuzzyRegex.test(gallery.name.toUpperCase()); + }); + }; +}; + +function generateFuzzyRegex(input) { + if(!input) return /.*/; + let fuzzyString = '.*'+input.toUpperCase().split('').join('.*')+'.*'; + return new RegExp(fuzzyString); +}; \ No newline at end of file diff --git a/app/index.html b/app/index.html new file mode 100644 index 00000000..b14ea520 --- /dev/null +++ b/app/index.html @@ -0,0 +1,25 @@ + + + + + + cfgram + + + + +
+ +
+ +
+ +
+ + + + + diff --git a/app/scss/lib/_base.scss b/app/scss/lib/_base.scss new file mode 100644 index 00000000..6f34e5c4 --- /dev/null +++ b/app/scss/lib/_base.scss @@ -0,0 +1,178 @@ + + +header{ + height: 10vw; + width: 100%; + background-color: $brand1; +}; + +.input-std{ + padding: 2% 8%; + margin: 2%; + margin-right: 10%; + width: 80%; + display: flex; + flex-direction: column; + justify-content: center; +}; +.clearfix{ + clear: both; +}; +.btn-std{ + padding: 1% 3%; + border-radius: $radius; + background-color: $brand1; + color: white; + border: none; + float: right; + margin-right: 2%; +}; +a,p{ + display: inline-block; + float: right; + left: 52%; + right: 2%; + color: $brand1; +}; +a{ + text-decoration: none; + color: black; +}; + +body { + background-color: $brand2; + height: 65%; +}; + +footer { + background-color: $footer; + height: 8vw; + width: 100%; + position: fixed; + bottom: 0%; +}; +///editing/// +label{ + position: relative; + left: 2%; + top: 2%; + padding: 2%; + font-family: helvetica; +}; + +.btn-std{ + padding: 1% 4%; + border-radius: 15%; + background-color: $brand1; + color: white; + font-size: 95%; + border: none; + float: right; + margin-right: 5%; + margin-top: -10%; +}; + +.btn-edit{ + padding: 1% 4%; + border-radius: 15%; + font-size: 95%; + border: none; + width: 5%; + display: inline-block; + position: relative; + float: right; + right: 3%; +}; +#edit{ + background-color: $brand1; + color: white; + +}; +#delete{ + background-color: #c4c9d1; + color: black; + +}; + +//navbar +img{ + position: absolute; + top: 2%; + left: 4%; +}; + +h1{ + color: white; + font-size: 165%; + display: inline-block;; + order: 1; + position: absolute; + margin-top: 3%; + // bottom: 3%; + left: 9%; +}; + + #sign{ + background-color: $brand2; + color: black; + font-size: 95%; + border-radius: 2px; + outline: none; + position: absolute; + float: right; + right: 2%; + margin-top: 3%; + }; + + //edit gallery + .input-std{ + outline: black solid 1px; + padding: 2% 8%; + margin: 2%; + margin-right: 10%; + width: 80%; + display: flex; + flex-direction: column; + justify-content: center; + }; + .clearfix{ + margin: 5%; + padding: 2%; + clear: both; + }; + + h2{ + font-family: helvetica; + font-size: 85%; + margin-left: 2%; + }; + .edit-gallery{ + background-color: $footer; + padding: 2% 2%; + margin: 2%; + width: 80%; + display: flex; + flex-direction: column; + justify-content: center; + border-radius: 3%; + }; +span{ + background-color: $footer; + padding: 2% 2%; + margin: 2%; + width: 80%; + display: flex; + flex-direction: column; + justify-content: center; + border-radius: 3%; +}; +.tooltip.top .tooltip-inner .tooltip{ + background-color:red; +} +social icons +.evernote { + background: url('/social-media-icons-15.png') no-repeat 75.12% 6%; + background-size: 350px 136px; + width: 37px; + height: 36px; +}; \ No newline at end of file diff --git a/app/scss/lib/_reset.scss b/app/scss/lib/_reset.scss new file mode 100644 index 00000000..d9f27b5a --- /dev/null +++ b/app/scss/lib/_reset.scss @@ -0,0 +1,48 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/app/scss/lib/_vars.scss b/app/scss/lib/_vars.scss new file mode 100644 index 00000000..8c8c853b --- /dev/null +++ b/app/scss/lib/_vars.scss @@ -0,0 +1,14 @@ +//colors + +$brand1 : #5a5d63; +$brand2 : #aaacaf; +$brand3 : white; +$footer: #727882; + +//spacing +$gtter : 30px; +$btnpad : 3%; +$radius : 3px; + +//font +@import url('https://fonts.googleapis.com/css?family=Montserrat'); diff --git a/app/scss/lib/bootstrap/_custom-bootstrap-vars.scss b/app/scss/lib/bootstrap/_custom-bootstrap-vars.scss new file mode 100644 index 00000000..14029fee --- /dev/null +++ b/app/scss/lib/bootstrap/_custom-bootstrap-vars.scss @@ -0,0 +1,10 @@ +$app-primary: #a7f7fa; +$app-secondary: #7fa7af; +$app-disabled: #abeaeb; +$app-active: #fa7fa7; +$app-success: #a7ff7a; +$app-error: #ff7a7a; +$app-warn: #ffa77a; +$app-info: #7aa7ff; +$app-white: #fff; +$app-black: #000; \ No newline at end of file diff --git a/app/scss/lib/bootstrap/_custom-bootstrap.scss b/app/scss/lib/bootstrap/_custom-bootstrap.scss new file mode 100644 index 00000000..af414cba --- /dev/null +++ b/app/scss/lib/bootstrap/_custom-bootstrap.scss @@ -0,0 +1,50 @@ +@import "custom-bootstrap-vars"; + +@import "~bootstrap-sass/assets/stylesheets/bootstrap/mixins"; + +// Reset and dependencies +@import "~bootstrap-sass/assets/stylesheets/bootstrap/normalize"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/print"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/glyphicons"; + +// Core CSS +@import "~bootstrap-sass/assets/stylesheets/bootstrap/scaffolding"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/type"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/code"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/grid"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/tables"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/forms"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/buttons"; + +// Components +@import "~bootstrap-sass/assets/stylesheets/bootstrap/component-animations"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/dropdowns"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/button-groups"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/input-groups"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/navs"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/navbar"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/breadcrumbs"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/pagination"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/pager"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/labels"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/badges"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/jumbotron"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/thumbnails"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/alerts"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/progress-bars"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/media"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/list-group"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/panels"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/responsive-embed"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/wells"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/close"; + +// Components w/ JavaScript +@import "~bootstrap-sass/assets/stylesheets/bootstrap/modals"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/tooltip"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/popovers"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/carousel"; + +// Utility classes +@import "~bootstrap-sass/assets/stylesheets/bootstrap/utilities"; +@import "~bootstrap-sass/assets/stylesheets/bootstrap/responsive-utilities"; \ No newline at end of file diff --git a/app/scss/main.scss b/app/scss/main.scss new file mode 100644 index 00000000..d9cd6ed0 --- /dev/null +++ b/app/scss/main.scss @@ -0,0 +1,7 @@ +@import '/lib/reset'; +@import '/lib/vars'; +@import '/lib/base'; + +// body { +// background-color: hotpink; +// } diff --git a/app/service/auth-service.js b/app/service/auth-service.js new file mode 100644 index 00000000..01a86e85 --- /dev/null +++ b/app/service/auth-service.js @@ -0,0 +1,88 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', '$window', authService]; + +function authService($q, $log, $http, $window) { + $log.debug('authService'); + + let service = {}; + let token = null; + + function setToken(_token) { + $log.debug('authService.setToken'); + + if (! _token) { + return $q.reject(new Error('no token')); + }; + + $window.localStorage.setItem('token', _token); + token = _token; + return $q.resolve(token); + } + + service.getToken = function() { + $log.debug('authService.getToken'); + if (token) { + return $q.resolve(token); + }; + + token = $window.localStorage.getItem('token'); + if (token) return $q.resolve(token); + return $q.reject(new Error('token not found')); + }; + + service.signup = function(user) { + $log.debug('authService.signup'); + + let url = `${__API_URL__}/api/signup`; + let config = { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }; + + return $http.post(url, user, config) + .then( res => { + $log.log('success:', res.data); + return setToken(res.data); + }) + .catch( err => { + $log.error('failure:', err.message); + return $q.reject(err); + }); + }; + + service.logout = function() { + $log.debug('authService.logout'); + + $window.localStorage.removeItem('token'); + token = null; + return $q.resolve(); + }; + + service.login = function(user) { + $log.debug('authService.login'); + + let url = `${__API_URL__}/api/login`; + let base64 = $window.btoa(`${user.username}:${user.password}`); + let config = { + headers: { + Accept: 'application/json', + Authorization: `Basic ${base64}` + } + }; + + return $http.get(url, config) + .then( res => { + $log.log('success', res.data); + return setToken(res.data); + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + return service; +}; \ No newline at end of file diff --git a/app/service/gallery-service.js b/app/service/gallery-service.js new file mode 100644 index 00000000..c5fb3f24 --- /dev/null +++ b/app/service/gallery-service.js @@ -0,0 +1,145 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'authService', galleryService]; + +function galleryService($q, $log, $http, authService) { + $log.debug('galleryService'); + + let service = {}; + service.galleries = []; + + service.createGallery = function(gallery) { + $log.debug('galleryService.createGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.post(url, gallery, config); + }) + .then( res => { + $log.log('gallery created'); + let gallery = res.data; + service.galleries.unshift(gallery); + return gallery; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deleteGalleries = function(galleryID) { + $log.debug('galleryService.deleteGalleries'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + }; + + // TODO: create $http.delete request + }); + }; + + service.fetchGalleries = function() { + $log.debug('galleryService.fetchGalleries'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}` + } + }; + + return $http.get(url, config); + }) + .then( res => { + $log.log('galleries retrieved'); + service.galleries = res.data; + return service.galleries; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.updateGallery = function(galleryID, galleryData) { + $log.debug('galleryService.updateGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Accept: 'application/json', + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json' + } + }; + + return $http.put(url, galleryData, config); + }) + .then( res => { + for (let i=0; i < service.galleries.length; i++) { + let current = service.galleries[i]; + if (current._id === galleryID) { + service.galleries[i] = res.data; + break; + }; + }; + + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + service.deleteGallery = function(galleryID) { + $log.debug('galleryService.deleteGallery'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryID}`; + let config = { + headers: { + Authorization: `Bearer ${token}` + } + }; + + return $http.delete(url, config); + }) + .then( res => { + for (let i=0; i { + $log.error(err.message); + return $q.reject(err); + }); + }; + + return service; +}; diff --git a/app/service/pic-service.js b/app/service/pic-service.js new file mode 100644 index 00000000..35755bf5 --- /dev/null +++ b/app/service/pic-service.js @@ -0,0 +1,66 @@ +'use strict'; + +module.exports = ['$q', '$log', '$http', 'Upload', 'authService', picService]; + +function picService($q, $log, $http, Upload, authService) { + $log.debug('picService'); + + let service = {}; + + service.uploadGalleryPic = function(galleryData, picData) { + $log.debug('service.uploadGalleryPic'); + + return authService.getToken() + .then( token => { + let url = `${__API_URL__}/api/gallery/${galleryData._id}/pic`; + let headers = { + Authorization: `Bearer ${token}`, + Accept: 'application/json' + }; + + return Upload.upload({ + url, + headers, + method: 'POST', + data: { + name: picData.name, + desc: picData.desc, + file: picData.file + } + }); + }) + .then( res => { + galleryData.pics.unshift(res.data); + return res.data; + }) + .catch( err => { + $log.error(err.message); + return $q.reject(err); + }); + }; + + 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/app/view/home/_home.scss b/app/view/home/_home.scss new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/app/view/home/_home.scss @@ -0,0 +1 @@ + diff --git a/app/view/home/home-controller.js b/app/view/home/home-controller.js new file mode 100644 index 00000000..24cacec9 --- /dev/null +++ b/app/view/home/home-controller.js @@ -0,0 +1,31 @@ +'use strict'; + +require('./_home.scss'); + +module.exports = ['$log', '$rootScope', 'galleryService', HomeController]; + +function HomeController($log, $rootScope, galleryService) { + $log.debug('HomeController'); + + this.galleries = []; + + this.fetchGalleries = function() { + galleryService.fetchGalleries() + .then( galleries => { + this.galleries = galleries; + this.currentGallery = galleries[0]; + }); + }; + + this.galleryDeleteDone = function(gallery) { + if (this.currentGallery._id === gallery._id) { + this.currentGallery = null; + } + }; + + this.fetchGalleries(); + + $rootScope.$on('$locationChangeSuccess', () => { + this.fetchGalleries(); + }); +}; diff --git a/app/view/home/home.html b/app/view/home/home.html new file mode 100644 index 00000000..be453f08 --- /dev/null +++ b/app/view/home/home.html @@ -0,0 +1,26 @@ +
+ + + + + +

Galleries

+ +
    +
  • + + +
  • + +
+ + + + +
diff --git a/app/view/landing/_landing.scss b/app/view/landing/_landing.scss new file mode 100644 index 00000000..77932a8f --- /dev/null +++ b/app/view/landing/_landing.scss @@ -0,0 +1 @@ +@import url('https://fonts.googleapis.com/css?family=Montserrat'); diff --git a/app/view/landing/landing-controller.js b/app/view/landing/landing-controller.js new file mode 100644 index 00000000..cdec477a --- /dev/null +++ b/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) { + let url = $location.url(); + this.showSignup = url === '/join#signup' || url === '/join'; +}; diff --git a/app/view/landing/landing.html b/app/view/landing/landing.html new file mode 100644 index 00000000..73d5135d --- /dev/null +++ b/app/view/landing/landing.html @@ -0,0 +1,40 @@ +
+
+
+ +

already a member?

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

want to sign up?

+ + sign up here. + +
+
+ +
+
+ +

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+
+
+
diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..3b81ccac --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,75 @@ +// Karma configuration +// Generated on Tue Apr 04 2017 10:16:51 GMT-0700 (PDT) +const webpack = require('./webpack.config.js'); +delete webpack.entry; + +module.exports = function(config) { + config.set({ + webpack, + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'app/entry.js', + 'test/**/*-test.js', + 'node_modules/angular-mocks/angular-mocks.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'test/**/*-test.js': ['webpack'], + 'app/entry.js': ['webpack'] + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['mocha'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }) +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..2d108525 --- /dev/null +++ b/package.json @@ -0,0 +1,66 @@ +{ + "name": "cfgram-auth", + "version": "1.0.0", + "description": "![cf](https://i.imgur.com/7v5ASc8.png) Lab 25 - Client Side Auth ======", + "main": "index.js", + "scripts": { + "start": "node server.js", + "heroku-postbuild": "webpack -p --progress", + "build": "./node_modules/webpack/bin/webpack.js", + "build-watch": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot", + "test": "./node_modules/karma/bin/karma start --single-run", + "test-watch": "./node_modules/karma/bin/karma start" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/darms/25-angular_auth.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/darms/25-angular_auth/issues" + }, + "homepage": "https://github.com/darms/25-angular_auth#readme", + "dependencies": { + "angular": "^1.6.3", + "angular-animate": "^1.6.3", + "angular-route": "^1.6.4", + "angular-touch": "^1.6.3", + "angular-ui-bootstrap": "^2.5.0", + "angular-ui-router": "^0.4.2", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", + "babel-preset-es2015": "^6.24.0", + "bootstrap-sass": "^3.3.7", + "camelcase": "^4.0.0", + "clean-webpack-plugin": "^0.1.16", + "css-loader": "^0.27.3", + "dotenv": "^4.0.0", + "express": "^4.15.2", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.10.1", + "html-loader": "^0.4.5", + "html-webpack-plugin": "^2.28.0", + "image-webpack-loader": "^3.3.0", + "ng-file-upload": "^12.2.13", + "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": { + "angular-mocks": "^1.6.4", + "jasmine-core": "^2.5.2", + "karma": "^1.6.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/server.js b/server.js new file mode 100644 index 00000000..32568df7 --- /dev/null +++ b/server.js @@ -0,0 +1,11 @@ +'use strict'; + +const express = require('express'); +const app = express(); +const PORT = process.env.PORT || 8080; + +app.use(express.static(`${__dirname}/build`)); + +app.listen(PORT, function() { + console.log('server up:', PORT); +}); \ No newline at end of file diff --git a/test/auth-service-test.js b/test/auth-service-test.js new file mode 100644 index 00000000..1f099c79 --- /dev/null +++ b/test/auth-service-test.js @@ -0,0 +1,31 @@ +'use strict'; + +describe('Auth Service', function() { + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, $window, $httpBackend) => { + this.$window = $window; + this.$rootScope = $rootScope; + this.authService = authService; + this.$httpBackend = $httpBackend; + }); + }); + + describe('authService.getToken', () => { + it('should return a token', () => { + this.authService.token = null; + this.$window.localStorage.setItem('token', 'test token'); + + this.authService.getToken() + .then( token => { + expect(token).toEqual('test token'); + }) + .catch( err => { + expect(err).toEqual(null); + }); + + this.$rootScope.$apply(); + }); + }); +}); \ No newline at end of file diff --git a/test/edit-gallery-component-test.js b/test/edit-gallery-component-test.js new file mode 100644 index 00000000..e69de29b diff --git a/test/gallery-item-component-test.js b/test/gallery-item-component-test.js new file mode 100644 index 00000000..0ca7c672 --- /dev/null +++ b/test/gallery-item-component-test.js @@ -0,0 +1,61 @@ +'use strict'; + +describe('Edit Gallery Component', function() { + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, $componentController, $httpBackend, authService) => { + this.$rootScope = $rootScope; + this.$componentController = $componentController; + this.$httpBackend = $httpBackend; + this.authService = authService; + + }) + }); + + it('should contain the proper component bindings', () => { + let mockBindings = { + gallery: { + name: 'test gallery name', + desc: 'test gallery description' + } + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + expect(editGalleryCtrl.gallery.name).toEqual(mockBindings.gallery.name); + expect(editGalleryCtrl.gallery.desc).toEqual(mockBindings.gallery.desc); + + this.$rootScope.$apply(); + }) + + describe('editGalleryCtrl.updateGallery()', () => { + it('should make a valid PUT request', () => { + let headers = { + 'Accept': 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPUT(url, { + _id: '12345', + name: 'updated name', + desc: 'updated description' + }, headers).respond(200); + + let mockBindings = { + gallery: { + _id: '12345', + name: 'updated name', + desc: 'updated description' + }, + }; + + let editGalleryCtrl = this.$componentController('editGallery', null, mockBindings); + editGalleryCtrl.gallery.name = 'updated name'; + editGalleryCtrl.gallery.desc = 'updated description'; + editGalleryCtrl.updateGallery(); + + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); +}); \ No newline at end of file diff --git a/test/gallery-service-test.js b/test/gallery-service-test.js new file mode 100644 index 00000000..e2ffba6d --- /dev/null +++ b/test/gallery-service-test.js @@ -0,0 +1,68 @@ +'use strict'; + +// var angular = require('angular'); +// angular.module('myMod', [ +// require('angular-animate'), +// require('angular-mocks/ngMock'), +// require('angular-mocks/ngAnimateMock') +// ]); + +describe('Gallery Service', function() { + + beforeEach(() => { + angular.mock.module('cfgram'); + angular.mock.inject(($rootScope, authService, galleryService, $window, $httpBackend) => { + this.$window = $window; + this.$rootScope = $rootScope; + this.authService = authService; + this.galleryService = galleryService; + this.$httpBackend = $httpBackend; + }); + }); + + describe('galleryService.createGallery', () => { + it('should create a new gallery', () => { + let galleryData = { + name: 'example gallery', + desc: 'example description' + }; + + let headers = { + 'Content-Type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test token' + }; + + this.$httpBackend.expectPOST('https://slugram-backend.herokuapp.com/api/gallery', galleryData, headers) + .respond(200, { + _id: '1234', + username: 'testuser', + name: galleryData.name, + desc: galleryData.desc, + pics: [] + }); + + this.galleryService.createGallery(galleryData); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); + +describe('galleryService.deleteGallery', () => { + it('should delete a gallery', () => { + let headers = { + Authorization: 'Bearer test token', + Accept: 'application/json, text/plain, */*' + }; + + let galleryID = 'galleryid'; + + this.$httpBackend.expectDELETE(`https://slugram-backend.herokuapp.com/api/gallery/${galleryID}`, headers) + .respond(204); + + this.galleryService.deleteGallery(galleryID); + this.$httpBackend.flush(); + this.$rootScope.$apply(); + }); + }); +}); \ No newline at end of file diff --git a/test/pic-service-test.js b/test/pic-service-test.js new file mode 100644 index 00000000..865fd6bc --- /dev/null +++ b/test/pic-service-test.js @@ -0,0 +1,6 @@ +// 'use strict'; + +// describe('Pic Service', function() { + +// beforeEach +// }) \ No newline at end of file diff --git a/travis.yml b/travis.yml new file mode 100644 index 00000000..aa7fcde8 --- /dev/null +++ b/travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: +- 'stable' +sudo: required +before_script: npm i +script: + -npm run test \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..c1babef4 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,53 @@ +'use strict'; + +const dotenv = require('dotenv'); +const webpack = require('webpack'); +const HTMLPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); + +const production = process.env.NODE_ENV === 'production'; + +dotenv.load(); + +module.exports = { + devtool: 'eval', + entry: `${__dirname}/app/entry.js`, + output: { + filename: 'bundle.js', + path: `${__dirname}/build` + }, + plugins: [ + new HTMLPlugin({ + template: `${__dirname}/app/index.html` + }), + new ExtractTextPlugin('bundle.css'), + new webpack.DefinePlugin({ + __API_URL__: JSON.stringify(process.env.API_URL), + __DEBUG__: JSON.stringify(!production) + }) + ], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + { + test: /\.html$/, + loader: 'html-loader' + }, + { + test: /\.scss$/, + loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) + }, + { + test: /\.(gif|png|jpe?g|svg)$/i, + loaders: [ + 'file-loader?hash=sha512&digest=hex&name=[hash].[ext]', + 'image-webpack-loader?bypassOnDebug' + ] + }, + ] + } +}; \ No newline at end of file diff --git a/wireframes/assets/social-media-icons-7.png b/wireframes/assets/social-media-icons-7.png new file mode 100644 index 00000000..b08c549a Binary files /dev/null and b/wireframes/assets/social-media-icons-7.png differ