diff --git a/.gitignore b/.gitignore index 7a1537ba..aa461ff9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea node_modules +bower_components \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 47430c17..79bda212 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,13 @@ before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - - npm install -g grunt-cli@0.1.x karma@0.8.x + - npm install -g gulp karma bower - cd server - npm install --quiet - node server.js & - sleep 3 # give server some time to start - cd ../client - npm install --quiet + - bower install --quiet - script: grunt release + script: gulp diff --git a/README.md b/README.md index 27a8e0cf..d25f1f61 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Purpose -The idea is to **demonstrate how to write a typical, non-trivial CRUD application using AngularJS**. To showcase AngularJS in its most advantageous environment we've set out to write a simplified project management tool supporting teams using the SCRUM methodology. The sample application tries to show best practices when it comes to: folders structure, using modules, testing, communicating with a REST back-end, organizing navigation, addressing security concerns (authentication / authorization). +The idea is to **demonstrate how to write a typical, non-trivial [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) application using AngularJS**. To showcase AngularJS in its most advantageous environment we've set out to write a simplified project management tool supporting teams using the [SCRUM](http://en.wikipedia.org/wiki/Scrum_(software_development)) methodology. The sample application tries to show best practices when it comes to: folders structure, using modules, testing, communicating with a REST back-end, organizing navigation, addressing security concerns (authentication / authorization). This sample application is featured in our [book](http://goo.gl/gKEsIo) where you can find detailed description of the patterns and techniques used to write this code: @@ -19,16 +19,15 @@ We've learned a lot while using and supporting AngularJS on the [mailing list](h * Persistence store: [MongoDB](http://www.mongodb.org/) hosted on [MongoLab](https://mongolab.com/) * Backend: [Node.js](http://nodejs.org/) * Awesome [AngularJS](http://www.angularjs.org/) on the client -* CSS based on [Twitter's bootstrap](http://getbootstrap.com/) +* CSS based on [Bootstrap](http://getbootstrap.com/) ### Build It is a complete project with a build system focused on AngularJS apps and tightly integrated with other tools commonly used in the AngularJS community: -* powered by [Grunt.js](http://gruntjs.com/) +* powered by [gulp.js](http://gulpjs.com/) * test written using [Jasmine](http://jasmine.github.io/) syntax -* test are executed by [Karma Test Runner](http://karma-runner.github.io/0.8/index.html) (integrated with the Grunt.js build) +* test are executed by [Karma Test Runner](http://karma-runner.github.io/) (integrated with the gulp.js build) * build supporting JS, CSS and AngularJS templates minification -* [Twitter's bootstrap](http://getbootstrap.com/) with LESS templates processing integrated into the build * [Travis-CI](https://travis-ci.org/) integration ## Installation @@ -37,14 +36,12 @@ It is a complete project with a build system focused on AngularJS apps and tight You need to install Node.js and then the development tools. Node.js comes with a package manager called [npm](http://npmjs.org) for installing NodeJS applications and libraries. * [Install node.js](http://nodejs.org/download/) (requires node.js version >= 0.8.4) -* Install Grunt-CLI and Karma as global npm modules: +* Install gulp and Karma runner as global npm modules: ``` - npm install -g grunt-cli karma + npm install -g gulp karma ``` -(Note that you may need to uninstall grunt 0.3 globally before installing grunt-cli) - ### Get the Code Either clone this repository or fork it on GitHub and clone your fork: @@ -71,7 +68,7 @@ Our backend application server is a NodeJS application that relies upon some 3rd ### Client App Our client application is a straight HTML/Javascript application but our development process uses a Node.js build tool -[Grunt.js](gruntjs.com). Grunt relies upon some 3rd party libraries that we need to install as local dependencies using npm. +[gulp.js](gulpjs.com). gulp relies upon some 3rd party libraries that we need to install as local dependencies using npm. * Install local dependencies (from the project root folder): @@ -129,12 +126,12 @@ angular.module('app').constant('MONGOLAB_CONFIG', { ``` ### Build the client app -The app made up of a number of javascript, css and html files that need to be merged into a final distribution for running. We use the Grunt build tool to do this. +The app made up of a number of javascript, css and html files that need to be merged into a final distribution for running. We use the gulp build tool to do this. * Build client application: ``` cd client - grunt build + gulp cd .. ``` @@ -163,37 +160,26 @@ testing against browsers that you need to support. ### Folders structure At the top level, the repository is split into a client folder and a server folder. The client folder contains all the client-side AngularJS application. The server folder contains a very basic Express based webserver that delivers and supports the application. Within the client folder you have the following structure: -* `node_modules` contains build tasks for Grunt along with other, user-installed, Node packages +* `node_modules` contains build tasks for gulp along with other, user-installed, Node packages * `dist` contains build results * `src` contains application's sources * `test` contains test sources, configuration and dependencies * `vendor` contains external dependencies for the application ### Default Build -The default grunt task will build (checks the javascript (lint), runs the unit tests (test:unit) and builds distributable files) and run all unit tests: `grunt` (or `grunt.cmd` on Windows). The tests are run by karma and need one or more browsers open to actually run the tests. +The default gulp task will build (checks the javascript (`lint`), runs the unit tests (`test``) and builds distributable files: * `cd client` -* `grunt` -* Open one or more browsers and point them to [http://localhost:8080/__test/]. Once the browsers connect the tests will run and the build will complete. -* If you leave the browsers open at this url then future runs of `grunt` will automatically run the tests against these browsers. +* `gulp` ### Continuous Building -The watch grunt task will monitor the source files and run the default build task every time a file changes: `grunt watch`. +The watch gulp task will monitor the source files and run the default build task every time a file changes: `gulp watch`. ### Build without tests -If for some reason you don't want to run the test but just generate the files - not a good idea(!!) - you can simply run the build task: `grunt build`. - -### Building release code -You can build a release version of the app, with minified files. This task will also run the "end to end" (e2e) tests. -The e2e tests require the server to be started and also one or more browsers open to run the tests. (You can use the same browsers as for the unit tests.) -* `cd client` -* Run `grunt release` -* Open one or more browsers and point them to [http://localhost:8080/__test/]. Once the browsers connect the tests will run and the build will complete. -* If you leave the browsers open at this url then future runs of `grunt` will automatically run the tests against these browsers. +If for some reason you don't want to run the test but just generate the files - not a good idea(!!) - you can simply run the build task: `gulp build`. ### Continuous testing -You can have grunt (karma) continuously watch for file changes and automatically run all the tests on every change, without rebuilding the distribution files. This can make the test run faster when you are doing test driven development and don't need to actually run the application itself. +You can have gulp (karma) continuously watch for file changes and automatically run all the tests on every change, without rebuilding the distribution files. This can make the test run faster when you are doing test driven development and don't need to actually run the application itself. * `cd client` -* Run `grunt test-watch`. -* Open one or more browsers and point them to [http://localhost:8080/__test/]. -* Each time a file changes the tests will be run against each browser. +* Run `gulp tdd`. In the default configuration it will start a new instance of Chrome. +* The task will wait for code changes, re-executing tests on each change. \ No newline at end of file diff --git a/client/bower.json b/client/bower.json new file mode 100644 index 00000000..bfa5d5bb --- /dev/null +++ b/client/bower.json @@ -0,0 +1,27 @@ +{ + "name": "angular-app", + "version": "0.0.0", + "homepage": "https://github.com/angular-app/angular-app", + "authors": [ + "Pawel Kozlowski & Peter Bacon Darwin" + ], + "description": "a simplified project management tool supporting teams using the SCRUM methodology - demonstrating AngularJS", + "license": "MIT", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "angularjs": "~1.3.0", + "angular-route": "~1.3.0", + "angular-mocks": "~1.3.0", + "jquery": "~2.1.1", + "angularjs-mongolab": "*", + "angular-bootstrap": "~0.11.0", + "bootstrap-css": "~3.2.0" + } +} diff --git a/client/gruntFile.js b/client/gruntFile.js deleted file mode 100644 index 3eb736d3..00000000 --- a/client/gruntFile.js +++ /dev/null @@ -1,182 +0,0 @@ -module.exports = function (grunt) { - - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-recess'); - grunt.loadNpmTasks('grunt-karma'); - grunt.loadNpmTasks('grunt-html2js'); - - // Default task. - grunt.registerTask('default', ['jshint','build','karma:unit']); - grunt.registerTask('build', ['clean','html2js','concat','recess:build','copy:assets']); - grunt.registerTask('release', ['clean','html2js','uglify','jshint','karma:unit','concat:index', 'recess:min','copy:assets']); - grunt.registerTask('test-watch', ['karma:watch']); - - // Print a timestamp (useful for when watching) - grunt.registerTask('timestamp', function() { - grunt.log.subhead(Date()); - }); - - var karmaConfig = function(configFile, customOptions) { - var options = { configFile: configFile, keepalive: true }; - var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' }; - return grunt.util._.extend(options, customOptions, travisOptions); - }; - - // Project configuration. - grunt.initConfig({ - distdir: 'dist', - pkg: grunt.file.readJSON('package.json'), - banner: - '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + - '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' + - ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n', - src: { - js: ['src/**/*.js'], - jsTpl: ['<%= distdir %>/templates/**/*.js'], - specs: ['test/**/*.spec.js'], - scenarios: ['test/**/*.scenario.js'], - html: ['src/index.html'], - tpl: { - app: ['src/app/**/*.tpl.html'], - common: ['src/common/**/*.tpl.html'] - }, - less: ['src/less/stylesheet.less'], // recess:build doesn't accept ** in its file patterns - lessWatch: ['src/less/**/*.less'] - }, - clean: ['<%= distdir %>/*'], - copy: { - assets: { - files: [{ dest: '<%= distdir %>', src : '**', expand: true, cwd: 'src/assets/' }] - } - }, - karma: { - unit: { options: karmaConfig('test/config/unit.js') }, - watch: { options: karmaConfig('test/config/unit.js', { singleRun:false, autoWatch: true}) } - }, - html2js: { - app: { - options: { - base: 'src/app' - }, - src: ['<%= src.tpl.app %>'], - dest: '<%= distdir %>/templates/app.js', - module: 'templates.app' - }, - common: { - options: { - base: 'src/common' - }, - src: ['<%= src.tpl.common %>'], - dest: '<%= distdir %>/templates/common.js', - module: 'templates.common' - } - }, - concat:{ - dist:{ - options: { - banner: "<%= banner %>" - }, - src:['<%= src.js %>', '<%= src.jsTpl %>'], - dest:'<%= distdir %>/<%= pkg.name %>.js' - }, - index: { - src: ['src/index.html'], - dest: '<%= distdir %>/index.html', - options: { - process: true - } - }, - angular: { - src:['vendor/angular/angular.js', 'vendor/angular/angular-route.js'], - dest: '<%= distdir %>/angular.js' - }, - mongo: { - src:['vendor/mongolab/*.js'], - dest: '<%= distdir %>/mongolab.js' - }, - bootstrap: { - src:['vendor/angular-ui/bootstrap/*.js'], - dest: '<%= distdir %>/bootstrap.js' - }, - jquery: { - src:['vendor/jquery/*.js'], - dest: '<%= distdir %>/jquery.js' - } - }, - uglify: { - dist:{ - options: { - banner: "<%= banner %>" - }, - src:['<%= src.js %>' ,'<%= src.jsTpl %>'], - dest:'<%= distdir %>/<%= pkg.name %>.js' - }, - angular: { - src:['<%= concat.angular.src %>'], - dest: '<%= distdir %>/angular.js' - }, - mongo: { - src:['vendor/mongolab/*.js'], - dest: '<%= distdir %>/mongolab.js' - }, - bootstrap: { - src:['vendor/angular-ui/bootstrap/*.js'], - dest: '<%= distdir %>/bootstrap.js' - }, - jquery: { - src:['vendor/jquery/*.js'], - dest: '<%= distdir %>/jquery.js' - } - }, - recess: { - build: { - files: { - '<%= distdir %>/<%= pkg.name %>.css': - ['<%= src.less %>'] }, - options: { - compile: true - } - }, - min: { - files: { - '<%= distdir %>/<%= pkg.name %>.css': ['<%= src.less %>'] - }, - options: { - compress: true - } - } - }, - watch:{ - all: { - files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'], - tasks:['default','timestamp'] - }, - build: { - files:['<%= src.js %>', '<%= src.specs %>', '<%= src.lessWatch %>', '<%= src.tpl.app %>', '<%= src.tpl.common %>', '<%= src.html %>'], - tasks:['build','timestamp'] - } - }, - jshint:{ - files:['gruntFile.js', '<%= src.js %>', '<%= src.jsTpl %>', '<%= src.specs %>', '<%= src.scenarios %>'], - options:{ - curly:true, - eqeqeq:true, - immed:true, - latedef:true, - newcap:true, - noarg:true, - sub:true, - boss:true, - eqnull:true, - globals:{} - } - } - }); - -}; diff --git a/client/gulpfile.js b/client/gulpfile.js new file mode 100644 index 00000000..4da7ab79 --- /dev/null +++ b/client/gulpfile.js @@ -0,0 +1,165 @@ +var gulp = require('gulp'); +var templateCache = require('gulp-angular-templatecache'); +var jshint = require('gulp-jshint'); +var concat = require('gulp-concat'); +var uglify = require('gulp-uglify'); +var template = require('gulp-template'); +var header = require('gulp-header'); +var htmlmin = require('gulp-htmlmin'); + +var merge = require('merge-stream'); +var rimraf = require('rimraf'); +var _ = require('lodash'); + +var karma = require('karma').server; + +var package = require('./package.json'); + +var karmaCommonConf = { + browsers: process.env.TRAVIS ? ['SL_Chrome', 'SL_Firefox', 'SL_Safari', 'SL_IE_11'] : ['Chrome'], + customLaunchers: { + 'SL_Chrome': { + base: 'SauceLabs', + browserName: 'chrome', + platform: 'Linux', + version: '36' + }, + 'SL_Firefox': { + base: 'SauceLabs', + browserName: 'firefox', + platform: 'Linux', + version: '31' + }, + 'SL_Safari': { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.9', + version: '7' + }, + 'SL_IE_11': { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 8.1', + version: '11' + } + }, + frameworks: ['jasmine'], + preprocessors: { + 'src/**/*.tpl.html': ['ng-html2js'] + }, + files: [ + 'bower_components/jquery/dist/jquery.js', + 'bower_components/angular/angular.js', + 'bower_components/angular-route/angular-route.js', + 'bower_components/angularjs-mongolab/src/angular-mongolab.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', + 'src/**/*.tpl.html', + 'src/**/*.js', + 'test/unit/**/*.spec.js' + ], + reporters: process.env.TRAVIS ? ['dots', 'saucelabs'] : ['progress'], + ngHtml2JsPreprocessor: { + cacheIdFromPath: function(filepath) { + //cut off src/common/ and src/app/ prefixes, if present + //we do this so in directives we can refer to templates in a way + //that those templates can be served by a web server during dev time + //without any need to bundle them + return filepath.replace('src/common/', '').replace('src/app/', ''); + } + }, + sauceLabs: { + username: 'pkozlowski', + accessKey: '173aa66e-43e6-4e34-b873-9cb037b8ae5c', + testName: 'angular-app tests' + } +}; + + +gulp.task('build-index', function () { + return gulp.src('src/index.html') + .pipe(template({ + pkg: package, + year: new Date() + })) + .pipe(gulp.dest('dist')); +}); + +gulp.task('build-js', function () { + + var now = new Date(); + + var htmlMinOpts = { + collapseWhitespace: true, + conservativeCollapse: true + }; + + return merge( + gulp.src('src/**/*.js'), + gulp.src('src/app/**/*.tpl.html').pipe(htmlmin(htmlMinOpts)).pipe(templateCache({standalone: true, module: 'templates.app'})), + gulp.src('src/common/**/*.tpl.html').pipe(htmlmin(htmlMinOpts)).pipe(templateCache({standalone: true, module: 'templates.common'})) + ).pipe(concat(package.name + '.js')) + .pipe(uglify()) + .pipe(header( + '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= buildDate %>\n' + + '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' + + ' * Copyright (c) <%= copyrightYear %> <%= pkg.author %>;\n' + + ' * Licensed <%= pkg.licenses[0].type %>\n */\n', + { + pkg: package, + buildDate: now, + copyrightYear: now.getFullYear() + })) + .pipe(gulp.dest('dist')); +}); + +gulp.task('copy-static', function () { + return merge( + gulp.src('bower_components/bootstrap-css/css/*.css').pipe(gulp.dest('dist/css')), + gulp.src('bower_components/bootstrap-css/fonts/*').pipe(gulp.dest('dist/fonts')), + merge( + gulp.src('src/assets/**/*.*'), + gulp.src(['bower_components/angular/angular.js', 'bower_components/angular-route/angular-route.js']).pipe(concat('angular.js')), + gulp.src('bower_components/angular-bootstrap/ui-bootstrap-tpls.js'), + gulp.src('bower_components/jquery/dist/jquery.js'), + gulp.src('bower_components/angularjs-mongolab/src/*.js') + ).pipe(gulp.dest('dist')) + ); +}); + +gulp.task('clean', function (done) { + return rimraf('dist', done); +}); + +gulp.task('lint', function () { + return gulp.src(['src/**/*.js', 'test/unit/**/*.js']).pipe(jshint()) + .pipe(jshint.reporter('default')) + .pipe(jshint.reporter('fail')); +}); + +gulp.task('test', function (done) { + karma.start(_.assign({}, karmaCommonConf, {singleRun: true}), done); +}); + +gulp.task('tdd', function (done) { + karma.start(karmaCommonConf, done); +}); + +gulp.task('watch', ['lint', 'build'], function () { + + gulp.watch('src/**/*.js', ['lint', 'build-js']); + gulp.watch('src/**/*.tpl.html', ['build-js']); + gulp.watch('src/index.html', ['build-index']); + gulp.watch('src/assets/**/*.*', ['copy-static']); + +}); + +gulp.task('build', ['copy-static', 'build-index', 'build-js']); +gulp.task('default', ['lint', 'test', 'build']); + +/* +TODO: +- watch shouldn't break on errors +- don't uglify / HTML minifiy during watch +- live-reload + */ \ No newline at end of file diff --git a/client/package.json b/client/package.json index 703954e9..e406d437 100644 --- a/client/package.json +++ b/client/package.json @@ -19,17 +19,23 @@ "engines": { "node": ">= 0.8.4" }, - "dependencies": {}, "devDependencies": { - "grunt": "~0.4.0", - "grunt-recess": "~0.3", - "grunt-contrib-clean": "~0.4.0", - "grunt-contrib-copy": "~0.4.0", - "grunt-contrib-jshint": "~0.2.0", - "grunt-contrib-concat": "~0.1.3", - "grunt-contrib-uglify": "~0.1.1", - "grunt-karma": "~0.4.4", - "grunt-html2js": "~0.1.0", - "grunt-contrib-watch": "~0.3.1" + "lodash": "~2.4.1", + "merge-stream": "~0.1.5", + "rimraf": "~2.2.8", + "karma": "~0.12.17", + "karma-jasmine": "~0.1.5", + "karma-ng-html2js-preprocessor": "~0.1.0", + "karma-chrome-launcher": "~0.1.4", + "karma-firefox-launcher": "~0.1.3", + "karma-sauce-launcher": "~0.2.10", + "gulp": "~3.8.6", + "gulp-angular-templatecache": "~1.2.1", + "gulp-concat": "~2.3.3", + "gulp-uglify": "~0.3.1", + "gulp-jshint": "~1.7.1", + "gulp-template": "~0.1.1", + "gulp-header": "~1.0.5", + "gulp-htmlmin": "~0.1.3" } } diff --git a/client/src/app/admin/projects/admin-projects.js b/client/src/app/admin/projects/admin-projects.js index 3cf50271..7cd21307 100644 --- a/client/src/app/admin/projects/admin-projects.js +++ b/client/src/app/admin/projects/admin-projects.js @@ -45,7 +45,7 @@ angular.module('admin-projects', [ }; $scope.onError = function() { - i18nNotifications.pushForCurrentRoute('crud.project.save.error', 'error'); + i18nNotifications.pushForCurrentRoute('crud.project.save.error', 'danger'); }; }]) diff --git a/client/src/app/admin/projects/projects-edit.tpl.html b/client/src/app/admin/projects/projects-edit.tpl.html index 6c998338..9bcfd0a2 100644 --- a/client/src/app/admin/projects/projects-edit.tpl.html +++ b/client/src/app/admin/projects/projects-edit.tpl.html @@ -1,25 +1,32 @@
Project -
-
- - - - +
+
+
+ + +
+
+ + +
-
- - - - +
+
+ + +
+
+ + +
@@ -32,15 +39,15 @@ - @@ -48,9 +55,9 @@
{{usersLookup[userId].getFullName()}} - +
-
-
+

- +
\ No newline at end of file diff --git a/client/src/app/admin/projects/projects-list.tpl.html b/client/src/app/admin/projects/projects-list.tpl.html index be15fa34..06cabbff 100644 --- a/client/src/app/admin/projects/projects-list.tpl.html +++ b/client/src/app/admin/projects/projects-list.tpl.html @@ -13,5 +13,5 @@
- +
diff --git a/client/src/app/admin/users/admin-users-edit.js b/client/src/app/admin/users/admin-users-edit.js index 88c310b6..b28d0206 100644 --- a/client/src/app/admin/users/admin-users-edit.js +++ b/client/src/app/admin/users/admin-users-edit.js @@ -16,7 +16,7 @@ angular.module('admin-users-edit',[ }; $scope.onError = function() { - i18nNotifications.pushForCurrentRoute('crud.user.save.error', 'error'); + i18nNotifications.pushForCurrentRoute('crud.user.save.error', 'danger'); }; $scope.onRemove = function(user) { diff --git a/client/src/app/admin/users/admin-users-list.js b/client/src/app/admin/users/admin-users-list.js index 577d6b04..06201286 100644 --- a/client/src/app/admin/users/admin-users-list.js +++ b/client/src/app/admin/users/admin-users-list.js @@ -14,12 +14,12 @@ angular.module('admin-users-list', [ $event.stopPropagation(); // Remove this user - user.$remove(function() { + user.$remove().then(function() { // It is gone from the DB so we can remove it from the local list too $scope.users.splice($index,1); i18nNotifications.pushForCurrentRoute('crud.user.remove.success', 'success', {id : user.$id()}); }, function() { - i18nNotifications.pushForCurrentRoute('crud.user.remove.error', 'error', {id : user.$id()}); + i18nNotifications.pushForCurrentRoute('crud.user.remove.error', 'danger', {id : user.$id()}); }); }; }]); diff --git a/client/src/app/admin/users/users-edit.tpl.html b/client/src/app/admin/users/users-edit.tpl.html index 55d4acde..16043388 100644 --- a/client/src/app/admin/users/users-edit.tpl.html +++ b/client/src/app/admin/users/users-edit.tpl.html @@ -1,24 +1,24 @@
User - + - + This field is required. Please enter a valid email address. This email address is not available - please enter another. - + This field is required. - + This field is required. - + This field is required. Passwords do not match. - + This field is required. Passwords do not match. diff --git a/client/src/app/admin/users/users-list.tpl.html b/client/src/app/admin/users/users-list.tpl.html index b35954cd..4d1186d2 100644 --- a/client/src/app/admin/users/users-list.tpl.html +++ b/client/src/app/admin/users/users-list.tpl.html @@ -18,5 +18,5 @@
- +
diff --git a/client/src/app/app.js b/client/src/app/app.js index 3e630dcf..3a485850 100644 --- a/client/src/app/app.js +++ b/client/src/app/app.js @@ -10,11 +10,12 @@ angular.module('app', [ 'security', 'directives.crud', 'templates.app', - 'templates.common']); + 'templates.common', + 'ui.bootstrap.tpls']); angular.module('app').constant('MONGOLAB_CONFIG', { - baseUrl: '/databases/', - dbName: 'ascrum' + BASE_URL: '/databases/', + DB_NAME: 'ascrum' }); //TODO: move those messages to a separate module @@ -44,7 +45,7 @@ angular.module('app').run(['security', function(security) { security.requestCurrentUser(); }]); -angular.module('app').controller('AppCtrl', ['$scope', 'i18nNotifications', 'localizedMessages', function($scope, i18nNotifications) { +angular.module('app').controller('AppCtrl', ['$scope', 'i18nNotifications', 'localizedMessages', function($scope, i18nNotifications, localizedMessages) { $scope.notifications = i18nNotifications; diff --git a/client/src/app/dashboard/dashboard.tpl.html b/client/src/app/dashboard/dashboard.tpl.html index 20b71544..27985420 100644 --- a/client/src/app/dashboard/dashboard.tpl.html +++ b/client/src/app/dashboard/dashboard.tpl.html @@ -6,10 +6,10 @@

My tasks

- - - - + + + + diff --git a/client/src/app/header.tpl.html b/client/src/app/header.tpl.html index fde2165c..993f6b5f 100644 --- a/client/src/app/header.tpl.html +++ b/client/src/app/header.tpl.html @@ -1,25 +1,30 @@ -
NameEstimationRemainingToolsNameEstimationRemainingTools
- +
\ No newline at end of file diff --git a/client/src/app/projects/projects-list.tpl.html b/client/src/app/projects/projects-list.tpl.html index 3e56f7e3..b496e36f 100644 --- a/client/src/app/projects/projects-list.tpl.html +++ b/client/src/app/projects/projects-list.tpl.html @@ -1,10 +1,10 @@ - - - - + + + + diff --git a/client/src/app/projects/sprints/sprints-edit.tpl.html b/client/src/app/projects/sprints/sprints-edit.tpl.html index e8a26c8c..bb37c9f2 100644 --- a/client/src/app/projects/sprints/sprints-edit.tpl.html +++ b/client/src/app/projects/sprints/sprints-edit.tpl.html @@ -2,32 +2,40 @@

Sprint


-
-
- - - - +
+
+
+ + +
+
+ + +
-
- - - - +
+
+ + +
+
+ + +

Sprint backlog


-
-
+
+
NameDescriptionMy Role(s)ToolsNameDescriptionMy Role(s)Tools
- - - + + + @@ -36,7 +44,7 @@

Sprint backlog

@@ -51,14 +59,14 @@

Sprint backlog

NameEstimationToolsNameEstimationTools
{{productBacklogLookup[sprintBacklogItem].estimation}} -
-
+
- - - + + + @@ -68,7 +76,7 @@

Sprint backlog

diff --git a/client/src/app/projects/sprints/sprints-list.tpl.html b/client/src/app/projects/sprints/sprints-list.tpl.html index 6d25cc0e..83e53559 100644 --- a/client/src/app/projects/sprints/sprints-list.tpl.html +++ b/client/src/app/projects/sprints/sprints-list.tpl.html @@ -15,7 +15,7 @@ @@ -24,5 +24,5 @@
NameEstimationToolsNameEstimationTools
{{productBacklogItem.estimation}} -
{{sprint.end}} ACTIVE - +
- +
\ No newline at end of file diff --git a/client/src/app/projects/sprints/tasks/tasks-edit.tpl.html b/client/src/app/projects/sprints/tasks/tasks-edit.tpl.html index c0c4d12b..72ac391c 100644 --- a/client/src/app/projects/sprints/tasks/tasks-edit.tpl.html +++ b/client/src/app/projects/sprints/tasks/tasks-edit.tpl.html @@ -1,24 +1,37 @@
-
+
-
- - - - - - +
+
+ + +
+
+ + +
+
+ + +
-
- - - - - - - - +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
diff --git a/client/src/app/projects/sprints/tasks/tasks-list.tpl.html b/client/src/app/projects/sprints/tasks/tasks-list.tpl.html index 6102cfa3..b6baf3b3 100644 --- a/client/src/app/projects/sprints/tasks/tasks-list.tpl.html +++ b/client/src/app/projects/sprints/tasks/tasks-list.tpl.html @@ -1,10 +1,10 @@ - - - - + + + + @@ -20,5 +20,5 @@
NameEstimationRemainingToolsNameEstimationRemainingTools
- +
\ No newline at end of file diff --git a/client/src/app/projects/sprints/tasks/tasks.js b/client/src/app/projects/sprints/tasks/tasks.js index 60458156..cb338853 100644 --- a/client/src/app/projects/sprints/tasks/tasks.js +++ b/client/src/app/projects/sprints/tasks/tasks.js @@ -5,14 +5,14 @@ angular.module('tasks', ['resources.tasks', 'services.crud']) var sprintBacklogItems = ['Sprints', 'ProductBacklog', '$route', function (Sprints, ProductBacklog, $route) { var sprintPromise = Sprints.getById($route.current.params.sprintId); return sprintPromise.then(function (sprint) { - return ProductBacklog.getByIds(sprint.sprintBacklog); + return ProductBacklog.getByObjectIds(sprint.sprintBacklog); }); }]; var teamMembers = ['Projects', 'Users', '$route', function (Projects, Users, $route) { var projectPromise = Projects.getById($route.current.params.projectId); return projectPromise.then(function(project){ - return Users.getByIds(project.teamMembers); + return Users.getByObjectIds(project.teamMembers); }); }]; diff --git a/client/src/assets/img/glyphicons-halflings-white.png b/client/src/assets/img/glyphicons-halflings-white.png deleted file mode 100644 index 3bf6484a..00000000 Binary files a/client/src/assets/img/glyphicons-halflings-white.png and /dev/null differ diff --git a/client/src/assets/img/glyphicons-halflings.png b/client/src/assets/img/glyphicons-halflings.png deleted file mode 100644 index a9969993..00000000 Binary files a/client/src/assets/img/glyphicons-halflings.png and /dev/null differ diff --git a/client/src/common/directives/crud/edit.js b/client/src/common/directives/crud/edit.js index 21b4317f..9089cda2 100644 --- a/client/src/common/directives/crud/edit.js +++ b/client/src/common/directives/crud/edit.js @@ -54,7 +54,7 @@ angular.module('directives.crud.edit', []) // The following functions should be triggered by elements on the form // - e.g. ng-click="save()" scope.save = function() { - resource.$saveOrUpdate(onSave, onSave, onError, onError); + resource.$saveOrUpdate().then(onSave, onError); }; scope.revertChanges = function() { resource = angular.copy(original); @@ -63,7 +63,7 @@ angular.module('directives.crud.edit', []) }; scope.remove = function() { if(resource.$id()) { - resource.$remove(onRemove, onError); + resource.$remove().then(onRemove, onError); } else { onRemove(); } diff --git a/client/src/common/directives/modal.js b/client/src/common/directives/modal.js deleted file mode 100644 index 80495d7c..00000000 --- a/client/src/common/directives/modal.js +++ /dev/null @@ -1,75 +0,0 @@ -angular.module('directives.modal', []).directive('modal', ['$parse',function($parse) { - var backdropEl; - var body = angular.element(document.getElementsByTagName('body')[0]); - var defaultOpts = { - backdrop: true, - escape: true - }; - return { - restrict: 'ECA', - link: function(scope, elm, attrs) { - var opts = angular.extend(defaultOpts, scope.$eval(attrs.uiOptions || attrs.bsOptions || attrs.options)); - var shownExpr = attrs.modal || attrs.show; - var setClosed; - - if (attrs.close) { - setClosed = function() { - scope.$apply(attrs.close); - }; - } else { - setClosed = function() { - scope.$apply(function() { - $parse(shownExpr).assign(scope, false); - }); - }; - } - elm.addClass('modal'); - - if (opts.backdrop && !backdropEl) { - backdropEl = angular.element(''); - backdropEl.css('display','none'); - body.append(backdropEl); - } - - function setShown(shown) { - scope.$apply(function() { - model.assign(scope, shown); - }); - } - - function escapeClose(evt) { - if (evt.which === 27) { setClosed(); } - } - function clickClose() { - setClosed(); - } - - function close() { - if (opts.escape) { body.unbind('keyup', escapeClose); } - if (opts.backdrop) { - backdropEl.css('display', 'none').removeClass('in'); - backdropEl.unbind('click', clickClose); - } - elm.css('display', 'none').removeClass('in'); - body.removeClass('modal-open'); - } - function open() { - if (opts.escape) { body.bind('keyup', escapeClose); } - if (opts.backdrop) { - backdropEl.css('display', 'block').addClass('in'); - backdropEl.bind('click', clickClose); - } - elm.css('display', 'block').addClass('in'); - body.addClass('modal-open'); - } - - scope.$watch(shownExpr, function(isShown, oldShown) { - if (isShown) { - open(); - } else { - close(); - } - }); - } - }; -}]); diff --git a/client/src/common/resources/backlog.js b/client/src/common/resources/backlog.js index 98770b00..b31bf646 100644 --- a/client/src/common/resources/backlog.js +++ b/client/src/common/resources/backlog.js @@ -1,6 +1,6 @@ -angular.module('resources.productbacklog', ['mongolabResource']); -angular.module('resources.productbacklog').factory('ProductBacklog', ['mongolabResource', function (mongolabResource) { - var ProductBacklog = mongolabResource('productbacklog'); +angular.module('resources.productbacklog', ['mongolabResourceHttp']); +angular.module('resources.productbacklog').factory('ProductBacklog', ['$mongolabResourceHttp', function ($mongolabResourceHttp) { + var ProductBacklog = $mongolabResourceHttp('productbacklog'); ProductBacklog.forProject = function (projectId) { return ProductBacklog.query({projectId:projectId}); diff --git a/client/src/common/resources/projects.js b/client/src/common/resources/projects.js index 998cd3cb..a35a3e5a 100644 --- a/client/src/common/resources/projects.js +++ b/client/src/common/resources/projects.js @@ -1,7 +1,7 @@ -angular.module('resources.projects', ['mongolabResource']); -angular.module('resources.projects').factory('Projects', ['mongolabResource', function ($mongolabResource) { +angular.module('resources.projects', ['mongolabResourceHttp']); +angular.module('resources.projects').factory('Projects', ['$mongolabResourceHttp', function ($mongolabResourceHttp) { - var Projects = $mongolabResource('projects'); + var Projects = $mongolabResourceHttp('projects'); Projects.forUser = function(userId, successcb, errorcb) { //TODO: get projects for this user only (!) diff --git a/client/src/common/resources/sprints.js b/client/src/common/resources/sprints.js index 6d3fb827..6bd987eb 100644 --- a/client/src/common/resources/sprints.js +++ b/client/src/common/resources/sprints.js @@ -1,7 +1,7 @@ -angular.module('resources.sprints', ['mongolabResource']); -angular.module('resources.sprints').factory('Sprints', ['mongolabResource', function (mongolabResource) { +angular.module('resources.sprints', ['mongolabResourceHttp']); +angular.module('resources.sprints').factory('Sprints', ['$mongolabResourceHttp', function ($mongolabResourceHttp) { - var Sprints = mongolabResource('sprints'); + var Sprints = $mongolabResourceHttp('sprints'); Sprints.forProject = function (projectId) { return Sprints.query({projectId:projectId}); }; diff --git a/client/src/common/resources/tasks.js b/client/src/common/resources/tasks.js index aeb8f7c5..8d2f679f 100644 --- a/client/src/common/resources/tasks.js +++ b/client/src/common/resources/tasks.js @@ -1,7 +1,7 @@ -angular.module('resources.tasks', ['mongolabResource']); -angular.module('resources.tasks').factory('Tasks', ['mongolabResource', function (mongolabResource) { +angular.module('resources.tasks', ['mongolabResourceHttp']); +angular.module('resources.tasks').factory('Tasks', ['$mongolabResourceHttp', function ($mongolabResourceHttp) { - var Tasks = mongolabResource('tasks'); + var Tasks = $mongolabResourceHttp('tasks'); Tasks.statesEnum = ['TODO', 'IN_DEV', 'BLOCKED', 'IN_TEST', 'DONE']; diff --git a/client/src/common/resources/users.js b/client/src/common/resources/users.js index 047b1647..40784c4f 100644 --- a/client/src/common/resources/users.js +++ b/client/src/common/resources/users.js @@ -1,7 +1,7 @@ -angular.module('resources.users', ['mongolabResource']); -angular.module('resources.users').factory('Users', ['mongolabResource', function (mongoResource) { +angular.module('resources.users', ['mongolabResourceHttp']); +angular.module('resources.users').factory('Users', ['$mongolabResourceHttp', function ($mongolabResourceHttp) { - var userResource = mongoResource('users'); + var userResource = $mongolabResourceHttp('users'); userResource.prototype.getFullName = function () { return this.lastName + " " + this.firstName + " (" + this.email + ")"; }; diff --git a/client/src/common/security/interceptor.js b/client/src/common/security/interceptor.js index 3c7ec2f0..936a3b2f 100644 --- a/client/src/common/security/interceptor.js +++ b/client/src/common/security/interceptor.js @@ -1,23 +1,22 @@ angular.module('security.interceptor', ['security.retryQueue']) // This http interceptor listens for authentication failures -.factory('securityInterceptor', ['$injector', 'securityRetryQueue', function($injector, queue) { - return function(promise) { - // Intercept failed requests - return promise.then(null, function(originalResponse) { +.factory('securityInterceptor', ['$injector', '$q', 'securityRetryQueue', function($injector, $q, queue) { + return { + responseError: function(originalResponse) { if(originalResponse.status === 401) { // The request bounced because it was not authorized - add a new request to the retry queue - promise = queue.pushRetryFn('unauthorized-server', function retryRequest() { + return queue.pushRetryFn('unauthorized-server', function retryRequest() { // We must use $injector to get the $http service to prevent circular dependency return $injector.get('$http')(originalResponse.config); }); } - return promise; - }); + return $q.reject(originalResponse); + } }; }]) // We have to add the interceptor to the queue as a string because the interceptor depends upon service instances that are not available in the config block. .config(['$httpProvider', function($httpProvider) { - $httpProvider.responseInterceptors.push('securityInterceptor'); + $httpProvider.interceptors.push('securityInterceptor'); }]); \ No newline at end of file diff --git a/client/src/common/security/login/form.tpl.html b/client/src/common/security/login/form.tpl.html index d7186365..8a4645df 100644 --- a/client/src/common/security/login/form.tpl.html +++ b/client/src/common/security/login/form.tpl.html @@ -6,7 +6,7 @@

Sign in

{{authReason}}
-
+
{{authError}}
Please enter your login details
@@ -17,7 +17,7 @@

Sign in

diff --git a/client/src/common/security/login/toolbar.tpl.html b/client/src/common/security/login/toolbar.tpl.html index 1a1501da..90edf99f 100644 --- a/client/src/common/security/login/toolbar.tpl.html +++ b/client/src/common/security/login/toolbar.tpl.html @@ -1,16 +1,11 @@ -