├── .gitignore
├── LICENSE
├── README.md
├── generators
├── api
│ ├── index.js
│ └── templates
│ │ ├── index.js
│ │ ├── name.controller.js
│ │ ├── name.controller.spec.js
│ │ ├── name.model.js
│ │ ├── name.model.spec.js
│ │ ├── name.params.js
│ │ └── name.socket(socketio).js
├── apiroute
│ └── index.js
├── app
│ ├── USAGE
│ ├── index.js
│ └── templates
│ │ ├── .bowerrc
│ │ ├── .editorconfig
│ │ ├── .gitignore
│ │ ├── .gitmodules
│ │ ├── .jscsrc
│ │ ├── .jshintrc
│ │ ├── README.md
│ │ ├── bin
│ │ └── server.js
│ │ ├── bower.json
│ │ ├── build.xml
│ │ ├── client
│ │ ├── .jshintrc
│ │ ├── .jshintrc-spec
│ │ ├── app
│ │ │ ├── account(auth)
│ │ │ │ ├── account.js
│ │ │ │ ├── login
│ │ │ │ │ ├── login.controller.js
│ │ │ │ │ ├── login.html
│ │ │ │ │ └── login.scss
│ │ │ │ └── settings
│ │ │ │ │ ├── settings.controller.js
│ │ │ │ │ └── settings.html
│ │ │ ├── admin(auth)
│ │ │ │ ├── admin.controller.js
│ │ │ │ ├── admin.html
│ │ │ │ ├── admin.js
│ │ │ │ ├── admin.scss
│ │ │ │ ├── main
│ │ │ │ │ ├── main.controller.js
│ │ │ │ │ ├── main.controller.spec.js
│ │ │ │ │ ├── main.html
│ │ │ │ │ ├── main.js
│ │ │ │ │ └── main.scss
│ │ │ │ └── user
│ │ │ │ │ ├── create
│ │ │ │ │ ├── create.controller.js
│ │ │ │ │ ├── create.controller.spec.js
│ │ │ │ │ ├── create.html
│ │ │ │ │ ├── create.js
│ │ │ │ │ └── create.scss
│ │ │ │ │ ├── list
│ │ │ │ │ ├── detail
│ │ │ │ │ │ ├── detail.controller.js
│ │ │ │ │ │ ├── detail.controller.spec.js
│ │ │ │ │ │ ├── detail.html
│ │ │ │ │ │ ├── detail.js
│ │ │ │ │ │ └── detail.scss
│ │ │ │ │ ├── edit
│ │ │ │ │ │ ├── edit-password
│ │ │ │ │ │ │ ├── edit-password.controller.js
│ │ │ │ │ │ │ ├── edit-password.html
│ │ │ │ │ │ │ └── edit-password.scss
│ │ │ │ │ │ ├── edit.controller.js
│ │ │ │ │ │ ├── edit.controller.spec.js
│ │ │ │ │ │ ├── edit.html
│ │ │ │ │ │ ├── edit.js
│ │ │ │ │ │ └── edit.scss
│ │ │ │ │ ├── items
│ │ │ │ │ │ ├── items.controller.js
│ │ │ │ │ │ ├── items.controller.spec.js
│ │ │ │ │ │ ├── items.html
│ │ │ │ │ │ ├── items.js
│ │ │ │ │ │ └── items.scss
│ │ │ │ │ ├── list.controller.js
│ │ │ │ │ ├── list.controller.spec.js
│ │ │ │ │ ├── list.html
│ │ │ │ │ ├── list.js
│ │ │ │ │ └── list.scss
│ │ │ │ │ ├── user.controller.js
│ │ │ │ │ ├── user.controller.spec.js
│ │ │ │ │ ├── user.html
│ │ │ │ │ ├── user.js
│ │ │ │ │ └── user.scss
│ │ │ ├── app.controller.js
│ │ │ ├── app.js
│ │ │ ├── clientModelDoc(demo)
│ │ │ │ ├── clientModelDoc.controller.js
│ │ │ │ ├── clientModelDoc.controller.spec.js
│ │ │ │ ├── clientModelDoc.html
│ │ │ │ ├── clientModelDoc.js
│ │ │ │ ├── clientModelDoc.scss
│ │ │ │ ├── clientModelDoc.service.js
│ │ │ │ ├── create
│ │ │ │ │ ├── create.controller.js
│ │ │ │ │ ├── create.controller.spec.js
│ │ │ │ │ ├── create.html
│ │ │ │ │ ├── create.js
│ │ │ │ │ └── create.scss
│ │ │ │ ├── list
│ │ │ │ │ ├── detail
│ │ │ │ │ │ ├── detail.controller.js
│ │ │ │ │ │ ├── detail.controller.spec.js
│ │ │ │ │ │ ├── detail.html
│ │ │ │ │ │ ├── detail.js
│ │ │ │ │ │ └── detail.scss
│ │ │ │ │ ├── edit
│ │ │ │ │ │ ├── edit.controller.js
│ │ │ │ │ │ ├── edit.controller.spec.js
│ │ │ │ │ │ ├── edit.html
│ │ │ │ │ │ ├── edit.js
│ │ │ │ │ │ └── edit.scss
│ │ │ │ │ ├── items
│ │ │ │ │ │ ├── items.controller.js
│ │ │ │ │ │ ├── items.controller.spec.js
│ │ │ │ │ │ ├── items.html
│ │ │ │ │ │ ├── items.js
│ │ │ │ │ │ └── items.scss
│ │ │ │ │ ├── list.controller.js
│ │ │ │ │ ├── list.controller.spec.js
│ │ │ │ │ ├── list.html
│ │ │ │ │ ├── list.js
│ │ │ │ │ └── list.scss
│ │ │ │ └── main
│ │ │ │ │ ├── main.controller.js
│ │ │ │ │ ├── main.controller.spec.js
│ │ │ │ │ ├── main.html
│ │ │ │ │ ├── main.js
│ │ │ │ │ └── main.scss
│ │ │ ├── components
│ │ │ │ ├── auth(auth)
│ │ │ │ │ ├── auth.service.js
│ │ │ │ │ ├── authinterceptor.service.js
│ │ │ │ │ └── user.service.js
│ │ │ │ ├── date-interceptor
│ │ │ │ │ ├── date-interceptor.js
│ │ │ │ │ └── date-interceptor.spec.js
│ │ │ │ ├── io(socketio)
│ │ │ │ │ └── io.service.js
│ │ │ │ ├── list-image
│ │ │ │ │ ├── list-image.directive.js
│ │ │ │ │ └── style.scss
│ │ │ │ ├── lodash
│ │ │ │ │ └── lodash.service.js
│ │ │ │ ├── main-menu
│ │ │ │ │ ├── main-menu.controller.js
│ │ │ │ │ ├── main-menu.controller.spec.js
│ │ │ │ │ ├── main-menu.directive.js
│ │ │ │ │ ├── main-menu.html
│ │ │ │ │ ├── main-menu.js
│ │ │ │ │ ├── main-menu.scss
│ │ │ │ │ ├── main-menu.service.js
│ │ │ │ │ └── main-menu.service.spec.js
│ │ │ │ ├── model-definitions
│ │ │ │ │ ├── model-definitions.service.js
│ │ │ │ │ └── model-definitions.service.spec.js
│ │ │ │ ├── model-input-group
│ │ │ │ │ ├── model-input-group.directive.js
│ │ │ │ │ ├── model-input-group.directive.spec.js
│ │ │ │ │ ├── model-input-group.html
│ │ │ │ │ ├── model-input-group.scss
│ │ │ │ │ └── model-input
│ │ │ │ │ │ ├── input.html
│ │ │ │ │ │ ├── model-input.directive.js
│ │ │ │ │ │ ├── model-input.directive.spec.js
│ │ │ │ │ │ ├── model-input.scss
│ │ │ │ │ │ └── select.html
│ │ │ │ ├── model-view-group
│ │ │ │ │ ├── detail.html
│ │ │ │ │ ├── items-content.html
│ │ │ │ │ ├── items-header.html
│ │ │ │ │ ├── model-view-group.directive.js
│ │ │ │ │ ├── model-view-group.directive.spec.js
│ │ │ │ │ ├── model-view-group.html
│ │ │ │ │ └── model-view-group.scss
│ │ │ │ ├── mongoose-error
│ │ │ │ │ └── mongoose-error.directive.js
│ │ │ │ ├── remote-unique
│ │ │ │ │ ├── remote-unique.directive.js
│ │ │ │ │ └── remote-unique.directive.spec.js
│ │ │ │ ├── repeat-input
│ │ │ │ │ ├── repeat-input-directive.spec.js
│ │ │ │ │ └── repeat-input.directive.js
│ │ │ │ ├── resource
│ │ │ │ │ └── resource.service.js
│ │ │ │ ├── socket(socketio)
│ │ │ │ │ ├── socket.mock.js
│ │ │ │ │ └── socket.service.js
│ │ │ │ ├── toast
│ │ │ │ │ ├── toast.html
│ │ │ │ │ ├── toast.service.js
│ │ │ │ │ └── toast.service.spec.js
│ │ │ │ └── toggle-component
│ │ │ │ │ ├── toggle-component.directive.js
│ │ │ │ │ ├── toggle-component.js
│ │ │ │ │ ├── toggle-component.scss
│ │ │ │ │ ├── toggle-component.service.js
│ │ │ │ │ └── toggle-component.spec.js
│ │ │ └── main
│ │ │ │ ├── main.controller.js
│ │ │ │ ├── main.controller.spec.js
│ │ │ │ ├── main.html
│ │ │ │ ├── main.js
│ │ │ │ └── main.scss
│ │ ├── assets
│ │ │ └── images
│ │ │ │ └── .gitkeep
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ └── styles
│ │ │ ├── app.scss
│ │ │ ├── common.scss
│ │ │ ├── forms.scss
│ │ │ └── sections.scss
│ │ ├── e2e
│ │ ├── login(auth)
│ │ │ └── login.po.js
│ │ └── main
│ │ │ ├── main.po.js
│ │ │ └── main.spec.js
│ │ ├── gulp
│ │ ├── config.js
│ │ └── tasks
│ │ │ ├── build.js
│ │ │ ├── dev.js
│ │ │ ├── reports.js
│ │ │ └── tests.js
│ │ ├── gulpfile.js
│ │ ├── karma.conf.js
│ │ ├── package.json
│ │ ├── protractor.conf.js
│ │ └── server
│ │ ├── .jshintrc
│ │ ├── .jshintrc-spec
│ │ ├── api
│ │ ├── clientModelDoc(demo)
│ │ │ ├── clientModelDoc.controller.js
│ │ │ ├── clientModelDoc.controller.spec.js
│ │ │ ├── clientModelDoc.model.js
│ │ │ ├── clientModelDoc.model.spec.js
│ │ │ ├── clientModelDoc.params.js
│ │ │ ├── clientModelDoc.socket.js
│ │ │ └── index.js
│ │ └── user(auth)
│ │ │ ├── index.js
│ │ │ ├── user.controller.js
│ │ │ ├── user.model.js
│ │ │ ├── user.model.spec.js
│ │ │ └── user.socket(socketio).js
│ │ ├── app.js
│ │ ├── app.spec.js
│ │ ├── config
│ │ ├── env
│ │ │ ├── development.js
│ │ │ ├── production.js
│ │ │ └── test.js
│ │ ├── express.js
│ │ ├── index.js
│ │ ├── mongoose.js
│ │ ├── seed.js
│ │ ├── socketio(socketio).js
│ │ └── testUsers(auth).js
│ │ ├── lib
│ │ ├── auth(auth)
│ │ │ ├── auth.service.js
│ │ │ ├── index.js
│ │ │ ├── local
│ │ │ │ ├── index.js
│ │ │ │ └── passport.js
│ │ │ └── roles.js
│ │ ├── controllers
│ │ │ ├── base.controller.js
│ │ │ ├── crud.controller.js
│ │ │ ├── crud.controller.spec.js
│ │ │ ├── param.controller.js
│ │ │ └── param.controller.spec.js
│ │ ├── middleware
│ │ │ └── index.js
│ │ └── responses
│ │ │ ├── errors.js
│ │ │ ├── index.js
│ │ │ └── ok.js
│ │ ├── routes.js
│ │ └── views
│ │ ├── !404.html
│ │ └── !500.html
├── base.js
├── controller
│ └── index.js
├── decorator
│ └── index.js
├── directive
│ └── index.js
├── factory
│ └── index.js
├── filter
│ └── index.js
├── provider
│ └── index.js
├── resource
│ └── index.js
├── route
│ └── index.js
├── service
│ └── index.js
├── templates
│ ├── apiroute
│ │ ├── create
│ │ │ ├── create.controller.js
│ │ │ ├── create.controller.spec.js
│ │ │ ├── create.html
│ │ │ ├── create.js
│ │ │ └── create.scss
│ │ ├── list
│ │ │ ├── detail
│ │ │ │ ├── detail.controller.js
│ │ │ │ ├── detail.controller.spec.js
│ │ │ │ ├── detail.html
│ │ │ │ ├── detail.js
│ │ │ │ └── detail.scss
│ │ │ ├── edit
│ │ │ │ ├── edit.controller.js
│ │ │ │ ├── edit.controller.spec.js
│ │ │ │ ├── edit.html
│ │ │ │ ├── edit.js
│ │ │ │ └── edit.scss
│ │ │ ├── items
│ │ │ │ ├── items.controller.js
│ │ │ │ ├── items.controller.spec.js
│ │ │ │ ├── items.html
│ │ │ │ ├── items.js
│ │ │ │ └── items.scss
│ │ │ ├── list.controller.js
│ │ │ ├── list.controller.spec.js
│ │ │ ├── list.html
│ │ │ ├── list.js
│ │ │ └── list.scss
│ │ ├── main
│ │ │ ├── main.controller.js
│ │ │ ├── main.controller.spec.js
│ │ │ ├── main.html
│ │ │ ├── main.js
│ │ │ └── main.scss
│ │ ├── name.controller.js
│ │ ├── name.controller.spec.js
│ │ ├── name.html
│ │ ├── name.js
│ │ ├── name.scss
│ │ └── name.service.js
│ ├── controller
│ │ ├── name.controller.js
│ │ └── name.controller.spec.js
│ ├── decorator
│ │ └── name.decorator.js
│ ├── directiveComplex
│ │ ├── name.directive.js
│ │ ├── name.directive.spec.js
│ │ ├── name.html
│ │ └── name.scss
│ ├── directiveSimple
│ │ ├── name.directive.js
│ │ └── name.directive.spec.js
│ ├── factory
│ │ ├── name.service.js
│ │ └── name.service.spec.js
│ ├── filter
│ │ ├── name.filter.js
│ │ └── name.filter.spec.js
│ ├── provider
│ │ ├── name.service.js
│ │ └── name.service.spec.js
│ ├── resource
│ │ └── name.service.js
│ ├── route
│ │ ├── name.controller.js
│ │ ├── name.controller.spec.js
│ │ ├── name.html
│ │ ├── name.js
│ │ └── name.scss
│ └── service
│ │ ├── name.service.js
│ │ └── name.service.spec.js
└── util.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | atlassian-ide-plugin.xml
3 | .idea
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Michael Krone
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/generators/api/templates/name.controller.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for the controller definition of the <%= name %> api.
3 | * The <%= modelName %>Controller is handling <%= route %> requests.
4 | * @module {<%= name %>:controller~<%= modelName %>Controller} <%= name %>:controller
5 | * @requires {@link ParamController}
6 | */
7 | 'use strict';
8 |
9 | module.exports = <%= modelName %>Controller;
10 |
11 | var ParamController = require('../../lib/controllers/param.controller');
12 |
13 | /**
14 | * The <%= modelName %> model instance
15 | * @type {<%= name %>:model~<%= modelName %>}
16 | */
17 | var <%= modelName %> = require('./<%= name %>.model').model;
18 |
19 | /**
20 | * <%= modelName %>Controller constructor
21 | * @classdesc Controller that handles <%= route %> route requests
22 | * for the <%= name %> api.
23 | * Uses the '<%= name %>Id' parameter and the '<%= name %>Param' request property
24 | * to operate with the [main <%= name %> API Model]{@link <%= name %>:model~<%= modelName %>} model.
25 | * @constructor
26 | * @inherits ParamController
27 | * @see <%= name %>:model~<%= modelName %>
28 | */
29 | function <%= modelName %>Controller(router) {
30 | ParamController.call(this, <%= modelName %>, router);
31 |
32 | // modify select only properties
33 | // this.select = ['-__v'];
34 |
35 | // omit properties on update
36 | // this.omit = ['hashedPassword'];
37 |
38 | // populate refs on get
39 | // this.populations = [];
40 |
41 | // property to return (maybe a virtual getter of the model)
42 | // this.defaultReturn = 'profile';
43 | }
44 |
45 | // define properties for the <%= modelName %>Controller here
46 | <%= modelName %>Controller.prototype = {
47 |
48 | /**
49 | * Set our own constructor property for instanceof checks
50 | * @private
51 | */
52 | constructor: <%= modelName %>Controller
53 |
54 | };
55 |
56 | // inherit from ParamController
57 | <%= modelName %>Controller.prototype = Object.create(ParamController.prototype);
58 |
59 |
--------------------------------------------------------------------------------
/generators/api/templates/name.params.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for initializing the <%= name%> api request parameters for <%= route %> routes.
3 | * Export the {@link <%= name %>:Parameters~register<%= modelName %>Params}
4 | * function to register the api routes on the passed express router.
5 | * @module {function} <%= name %>:parameters
6 | * @requires {@link <%= name %>:model}
7 | */
8 | 'use strict';
9 |
10 | // export the function to register all <%= name %> request params
11 | module.exports = register<%= modelName %>Params;
12 |
13 | /**
14 | * Attach request parameters to the given router.
15 | * @param router {express.Router} - The router to attach the parameters to
16 | */
17 | function register<%= modelName %>Params(router) {
18 | // router.param('id', registerParamName);
19 | // add params below
20 | }
21 |
22 | /*
23 | * Register a parameter for <%= route %> requests.
24 | * Add a property to the current request.
25 | * @param {http.IncomingMessage} req - The request message object
26 | * @param {http.ServerResponse} res - The outgoing response object
27 | * @param next {function} - The next handler function to call when done
28 | * @param id {String} - The id parameter parsed from the current request
29 | * @see <%= name %>:model~<%= modelName %>
30 | * @returns {function} This function sets a status of 400 for malformed MongoDB
31 | * id's and a status of 404 if no document has been found for the passed
32 | * parameter. Calls the passed next function when done.
33 |
34 | function registerParamName(req, res, next, id) {
35 | // attach the document to the request
36 | Model.findById(id, function (err, doc) {
37 | if (err) {
38 | return next(err);
39 | }
40 |
41 | if (!doc) {
42 | res.notFound();
43 | return next('route');
44 | }
45 |
46 | req.paramName = doc;
47 | return next();
48 | });
49 | }
50 | */
51 |
52 | // add param functions below
53 |
--------------------------------------------------------------------------------
/generators/api/templates/name.socket(socketio).js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for registering broadcast updates to clients when
3 | * the <%= modelName %> model changes. Exports the
4 | * [register function]{@link <%= name %>:socket~register<%= modelName %>Sockets}
5 | * to register the model schema events on the socket instance.
6 | * @module {function} <%= name %>:socket
7 | * @requires {@link <%= name %>:model}
8 | */
9 | 'use strict';
10 |
11 | /**
12 | * The <%= modelName %> model instance
13 | * @type {<%= name %>:model~<%= modelName %>}
14 | */
15 | var <%= modelName %> = require('./<%= name %>.model').model;
16 |
17 | // export the function to register all socket broadcasts
18 | exports.register = register<%= modelName %>Sockets;
19 |
20 | /**
21 | * Register <%= modelName %> model change events on the passed socket
22 | * @param {socket.io} socket - The socket object to register the <%= modelName %> model events on
23 | */
24 | function register<%= modelName %>Sockets(socket) {
25 | <%= modelName %>.schema.post('save', function (doc) {
26 | onSave(socket, doc);
27 | });
28 |
29 | <%= modelName %>.schema.post('remove', function (doc) {
30 | onRemove(socket, doc);
31 | });
32 | }
33 |
34 | /**
35 | * Emit a <%= modelName %> save event on a socket object: '<%= name %>:save'
36 | * @param {socket.io} socket - The socket object to emit the <%= modelName %> save event on
37 | * @param {MogooseDocument} doc - The saved document that triggered the event
38 | * @param {function} cb - The callback function
39 | */
40 | function onSave(socket, doc, cb) {
41 | socket.emit('<%= name %>:save', doc);
42 | }
43 |
44 | /**
45 | * Emit a <%= modelName %> remove event on a socket object: '<%= name %>:remove'
46 | * @param {socket.io} socket - The socket object to emit the <%= modelName %> remove event on
47 | * @param {MogooseDocument} doc - The removed document that triggered the event
48 | * @param {function} cb - The callback function
49 | */
50 | function onRemove(socket, doc, cb) {
51 | socket.emit('<%= name %>:remove', doc);
52 | }
53 |
--------------------------------------------------------------------------------
/generators/app/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Generators for AngularJS components
3 |
4 | Available Generators:
5 | yo ng-component:route [name]
6 | yo ng-component:directive [name]
7 | yo ng-component:service [name]
8 | yo ng-component:factory [name]
9 | yo ng-component:filter [name]
--------------------------------------------------------------------------------
/generators/app/templates/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "client/bower_components"
3 | }
4 |
--------------------------------------------------------------------------------
/generators/app/templates/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = tab
12 | indent_size = 2
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
--------------------------------------------------------------------------------
/generators/app/templates/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /build
3 | /dist
4 | .idea
5 | .tmp
6 | npm-debug.log
7 | .sass-cache
8 |
--------------------------------------------------------------------------------
/generators/app/templates/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "license"]
2 | path = ./
3 | url = git@git.hi-repo1.instruments.local:gastro-instruments/software-license.git
4 |
--------------------------------------------------------------------------------
/generators/app/templates/.jscsrc:
--------------------------------------------------------------------------------
1 | {
2 | "requireCurlyBraces": [
3 | "if",
4 | "else",
5 | "for",
6 | "while",
7 | "do",
8 | "try",
9 | "catch",
10 | "case",
11 | "default"
12 | ],
13 | "requireSpaceAfterKeywords": [
14 | "if",
15 | "else",
16 | "for",
17 | "while",
18 | "do",
19 | "switch",
20 | "try",
21 | "catch"
22 | ],
23 | "requireSpaceBeforeBinaryOperators": [
24 | "=",
25 | "+",
26 | "-",
27 | "/",
28 | "*",
29 | "==",
30 | "===",
31 | "!=",
32 | "!=="
33 | // etc
34 | ],
35 | "requireSpaceAfterBinaryOperators": [
36 | "=",
37 | ",",
38 | "+",
39 | "-",
40 | "/",
41 | "*",
42 | "==",
43 | "===",
44 | "!=",
45 | "!=="
46 | // etc
47 | ],
48 | "requireSpaceBeforeBlockStatements": true,
49 | "requireParenthesesAroundIIFE": true,
50 | "requireCommaBeforeLineBreak": true,
51 | "requireLineFeedAtFileEnd": true,
52 | "requireCapitalizedConstructors": true,
53 | "requireSpaceAfterLineComment": true,
54 | "disallowEmptyBlocks": true,
55 | "disallowSpaceAfterObjectKeys": true,
56 | "disallowMultipleLineStrings": true,
57 | "disallowTrailingComma": true,
58 | "disallowKeywordsOnNewLine": ["else"],
59 | "disallowNewlineBeforeBlockStatements": true,
60 | "safeContextKeyword": ["that", "self", "vm"],
61 | "validateLineBreaks": "LF",
62 | "validateIndentation": "\t",
63 | "requireSpacesInConditionalExpression": {
64 | "afterTest": true,
65 | "beforeConsequent": true,
66 | "afterConsequent": true,
67 | "beforeAlternate": true
68 | },
69 | "requireSpacesInAnonymousFunctionExpression": {
70 | "beforeOpeningRoundBrace": true,
71 | "beforeOpeningCurlyBrace": true
72 | },
73 | "requireSpacesInNamedFunctionExpression": {
74 | "beforeOpeningCurlyBrace": true
75 | },
76 | "disallowSpacesInNamedFunctionExpression": {
77 | "beforeOpeningRoundBrace": true
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/generators/app/templates/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": true,
3 | "curly": true,
4 | "eqeqeq": true,
5 | "forin": true,
6 | "immed": true,
7 | "latedef": true,
8 | "newcap": true,
9 | "noarg": true,
10 | "noempty": true,
11 | "nonew": true,
12 | "plusplus": true,
13 | "regexp": true,
14 | "undef": true,
15 | "strict": true,
16 | "trailing": true,
17 | "asi": false,
18 | "boss": false,
19 | "debug": false,
20 | "eqnull": false,
21 | "es5": false,
22 | "esnext": false,
23 | "evil": false,
24 | "expr": false,
25 | "funcscope": false,
26 | "globalstrict": true,
27 | "iterator": false,
28 | "lastsemic": false,
29 | "laxbreak": false,
30 | "laxcomma": false,
31 | "loopfunc": false,
32 | "multistr": false,
33 | "onecase": false,
34 | "proto": false,
35 | "regexdash": false,
36 | "node": true,
37 | "esnext": true,
38 | "bitwise": true,
39 | "eqeqeq": true,
40 | "immed": true,
41 | "latedef": "nofunc",
42 | "newcap": true,
43 | "noarg": true,
44 | "regexp": true,
45 | "undef": true,
46 | "smarttabs": true,
47 | "asi": true,
48 | "debug": true,
49 | "scripturl": false,
50 | "smarttabs": false,
51 | "shadow": false,
52 | "sub": false,
53 | "supernew": false,
54 | "validthis": false,
55 | "browser": false,
56 | "devel": false,
57 | "node": true,
58 | "nonstandard": false,
59 | "wsh": false,
60 | "nomen": false,
61 | "onevar": true,
62 | "passfail": false,
63 | "white": true,
64 | "maxerr": 100,
65 | "predef": [],
66 | "indent": " ",
67 | "quotmark": "single"
68 | }
69 |
--------------------------------------------------------------------------------
/generators/app/templates/README.md:
--------------------------------------------------------------------------------
1 | # <%= appname %>
2 |
3 | <%= appname %> application. An application for doing awesome things.
4 |
5 | ### Deploy
6 |
7 | For now:
8 |
9 | ```
10 | NODE_ENV=production gulp build
11 | NODE_ENV=production npm start
12 | ```
13 | and manually seed database with `NODE_ENV=production npm run seed`
14 |
--------------------------------------------------------------------------------
/generators/app/templates/bin/server.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | 'use strict';
3 |
4 | var app = require('../server/app');
5 |
6 | // start sockets for this instance and start server
7 | app.startServer().listen(app.get('port'), app.get('ip'), function serverStarted() {
8 | console.log('<%= appname %> started server on ip %s on port %d, in %s mode',
9 | app.get('ip'), app.get('port'), app.get('env'));
10 | });
11 |
12 | // expose app
13 | exports = module.exports = app;
14 |
--------------------------------------------------------------------------------
/generators/app/templates/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "<%= _.slugify(_.humanize(appname)) %>",
3 | "version": "0.0.1",
4 | "dependencies": {
5 | "angular": ">=1.4.*",
6 | "angular-resource": ">=1.4.*",
7 | "angular-animate": ">=1.4.*",
8 | "angular-cookies": ">=1.4.*",
9 | "angular-sanitize": ">=1.4.*",
10 | "angular-messages": ">=1.4.*",
11 | "angular-ui-router": "latest",
12 | "material-design-icons": ">=1.0.1",
13 | "lodash": "~2.4.1",
14 | "angular-material": "0.8.3",
15 | "angular-socket-io": "~0.6.0",
16 | "angular-i18n": "~1.3.14",
17 | "angular-moment": "~0.9.0"
18 | },
19 | "devDependencies": {
20 | "angular-mocks": ">=1.2.*",
21 | "angular-scenario": ">=1.2.*",
22 | "should": "shouldjs/should.js#~4.4.1"
23 | },
24 | "resolutions": {
25 | "angular": ">=1.4.*",
26 | "angular-animate": ">=1.4.*"
27 | },
28 | "overrides": {
29 | "material-design-icons": {
30 | "main": []
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/generators/app/templates/client/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../.jshintrc",
3 | "browser": true,
4 | "bitwise": true,
5 | "camelcase": true,
6 | "curly": true,
7 | "eqeqeq": true,
8 | "immed": true,
9 | "latedef": true,
10 | "newcap": true,
11 | "noarg": true,
12 | "regexp": true,
13 | "undef": true,
14 | "unused": true,
15 | "strict": true,
16 | "trailing": true,
17 | "smarttabs": true,
18 | "globals": {
19 | "angular": true
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/.jshintrc-spec:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ".jshintrc",
3 | "globals": {
4 | "describe": true,
5 | "before": true,
6 | "after": true,
7 | "beforeEach": true,
8 | "afterEach": true,
9 | "module": true,
10 | "inject": true,
11 | "it": true,
12 | "expect": true,
13 | "browser": true,
14 | "element": true,
15 | "by": true,
16 | "Should": true,
17 | "sinon": true
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/account(auth)/account.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc overview
3 | * @name <%= scriptAppName %>.account
4 | * @description
5 | * The `<%= scriptAppName %>.account` module
6 | *
7 | * @requires ui.router
8 | */
9 |
10 | (function () {
11 | 'use strict';
12 |
13 | // register the route config on the application
14 | angular
15 | .module('<%= scriptAppName %>.account', ['ui.router'])
16 | .config(configAccountRoute);
17 |
18 | // inject configAccountRoute dependencies
19 | configAccountRoute.$inject = ['$stateProvider'];
20 |
21 | // route config function configuring the passed $stateProvider
22 | function configAccountRoute($stateProvider) {
23 | var loginState = {
24 | name: 'login',
25 | url: '/login',
26 | templateUrl: 'app/account/login/login.html',
27 | controller: 'LoginController',
28 | controllerAs: 'login'
29 | };
30 |
31 | $stateProvider.state(loginState);
32 | }
33 |
34 | })();
35 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/account(auth)/login/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Login
4 |
5 |
6 | Use a development seed user to login, e.g. user Admin
with the password password
7 |
8 |
9 | {{login.error.message}}
10 |
11 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/account(auth)/login/login.scss:
--------------------------------------------------------------------------------
1 | #login-content {
2 |
3 | & > * {
4 | max-width: 350px;
5 | }
6 |
7 | form > .md-warn {
8 | padding-bottom: 20px;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/account(auth)/settings/settings.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as SettingsController
5 | angular
6 | .module('<%= scriptAppName %>.account')
7 | .controller('SettingsController', SettingsController);
8 |
9 | // add SettingsController dependencies to inject
10 | SettingsController.$inject = ['User', 'Auth'];
11 |
12 | /**
13 | * SettingsController constructor
14 | *
15 | * @param User
16 | * @param Auth
17 | * @constructor
18 | */
19 | function SettingsController(User, Auth) {
20 | var vm = this;
21 |
22 | // view model bindings
23 | vm.errors = {};
24 | vm.user = {};
25 | vm.message = '';
26 | vm.changePassword = changePassword;
27 | vm.submitted = false;
28 |
29 | function changePassword(form) {
30 | vm.submitted = true;
31 | if (form.$valid) {
32 | Auth
33 | .changePassword(vm.user.oldPassword, vm.user.newPassword)
34 | .then(function () {
35 | vm.message = 'Password successfully changed.';
36 | }).catch(handleError);
37 | }
38 |
39 | function handleError() {
40 | form.password.$setValidity('mongoose', false);
41 | vm.errors.other = 'Incorrect password';
42 | vm.message = '';
43 | }
44 | };
45 | }
46 |
47 | })();
48 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/account(auth)/settings/settings.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Change Password
5 |
6 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/admin.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as AdminController
5 | angular
6 | .module('<%= scriptAppName %>.admin')
7 | .controller('AdminController', AdminController);
8 |
9 | // add AdminController dependencies to inject
10 | // AdminController.$inject = [''];
11 |
12 | /**
13 | * AdminController constructor
14 | */
15 | function AdminController() {
16 | // var vm = this;
17 | }
18 |
19 | })();
20 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/admin.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/admin.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the route config on the application
5 | angular
6 | .module('<%= scriptAppName %>.admin', [
7 | 'ui.router',
8 | '<%= scriptAppName %>.admin.main',
9 | '<%= scriptAppName %>.admin.user',
10 | '<%= scriptAppName %>.mainMenu'
11 | ])
12 | .config(configAdminRoute);
13 |
14 | // inject configAdminRoute dependencies
15 | configAdminRoute.$inject = ['$urlRouterProvider', '$stateProvider'];
16 |
17 | // route config function configuring the passed $stateProvider
18 | function configAdminRoute($urlRouterProvider, $stateProvider) {
19 | var adminState = {
20 | name: 'admin',
21 | url: '/admin',
22 | abstract: true,
23 | templateUrl: 'app/admin/admin.html',
24 | controller: 'AdminController',
25 | controllerAs: 'vm'
26 | };
27 |
28 | $urlRouterProvider.when('/admin', '/admin/');
29 | $stateProvider.state(adminState);
30 | }
31 |
32 | })();
33 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/admin.scss:
--------------------------------------------------------------------------------
1 | #admin-items-content {}
2 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/main/main.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as AdminMainController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.admin.main')
10 | .controller('AdminMainController', AdminMainController);
11 |
12 | // add AdminMainController dependencies to inject
13 | AdminMainController.$inject = ['$state'];
14 |
15 | /**
16 | * AdminMainController constructor
17 | */
18 | function AdminMainController($state) {
19 | var vm = this;
20 | // switch to the list state
21 | vm.showList = showList;
22 |
23 | /**
24 | * Activate the user.list state
25 | */
26 | function showList() {
27 | $state.go('admin.user.list');
28 | }
29 | }
30 |
31 | })();
32 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/main/main.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: AdminMainController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.admin.main'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('AdminMainController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | it('should have an awesome title property', function () {
25 | Should.exist(controller.title);
26 | controller.title.should.equal('user');
27 | });
28 |
29 | it('should have a working doSomething method', function () {
30 | Should.exist(controller.doSomething);
31 | controller.doSomething().should.equal('user - a sublime controller');
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/main/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Administration Section
22 |
23 |
24 | View your list of Users
25 | or create a User .
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/main/main.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.admin.main module
6 | * and configure it.
7 | *
8 | * @requires {ui.router}
9 | */
10 |
11 | angular
12 | .module('<%= scriptAppName %>.admin.main', [
13 | 'ui.router',
14 | '<%= scriptAppName %>.mainMenu'
15 | ])
16 | .config(configAdminMain);
17 |
18 | // inject configAdminMain dependencies
19 | configAdminMain.$inject = ['$stateProvider', 'mainMenuProvider'];
20 |
21 | /**
22 | * Route configuration function configuring the passed $stateProvider.
23 | * Register the user.main state with the list template for the
24 | * 'main' view paired with the UserMainController as 'main'.
25 | *
26 | * @param {$stateProvider} $stateProvider - The state provider to configure
27 | * @param {mainMenuProvider} mainMenuProvider - The service to pass navigation information to
28 | */
29 | function configAdminMain($stateProvider, mainMenuProvider) {
30 | // The main state configuration
31 | var mainState = {
32 | name: 'admin.main',
33 | parent: 'admin',
34 | url: '/',
35 | authenticate: true,
36 | role: 'admin',
37 | views: {
38 | '@admin': {
39 | templateUrl: 'app/admin/main/main.html',
40 | controller: 'AdminMainController',
41 | controllerAs: 'main'
42 | }
43 | }
44 | };
45 |
46 | $stateProvider.state(mainState);
47 |
48 | mainMenuProvider.addMenuItem({
49 | name: 'Administration',
50 | state: mainState.name,
51 | role: 'admin'
52 | });
53 | }
54 |
55 | })();
56 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/main/main.scss:
--------------------------------------------------------------------------------
1 | #admin-main-content {}
2 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/create/create.scss:
--------------------------------------------------------------------------------
1 | #user-create-content {}
2 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/detail/detail.scss:
--------------------------------------------------------------------------------
1 | #user-detail-toolbar {}
2 |
3 | #user-detail-content {}
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/edit/edit-password/edit-password.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 | Set a new password for user {{password.user.name}} .
13 |
14 | After setting a new password the user can only access the
15 | application with the new password.
16 |
17 |
18 |
42 |
43 |
44 |
45 |
46 |
47 | Cancel
48 | Change password
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/edit/edit-password/edit-password.scss:
--------------------------------------------------------------------------------
1 | #admin-user-edit-password {}
2 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/edit/edit.scss:
--------------------------------------------------------------------------------
1 | #user-edit-toolbar {}
2 |
3 | #user-edit-content {}
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/items/items.controller.spec.js:
--------------------------------------------------------------------------------
1 | /* jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Controller: UserItemsController', function () {
5 |
6 | // load the controller's module
7 | beforeEach(module('<%= scriptAppName %>.admin.user.list'));
8 |
9 | var controller;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller) {
13 | controller = $controller('UserItemsController', {
14 | });
15 | }));
16 |
17 | it('object should exist', function () {
18 | Should.exist(controller);
19 | controller.should.be.an.instanceof(Object);
20 | });
21 |
22 | it('should expose a isSelected function', function () {
23 | Should.exist(controller.isSelected);
24 | controller.isSelected.should.be.a.Function;
25 | });
26 |
27 | it('should expose a showInDetails function', function () {
28 | Should.exist(controller.showInDetails);
29 | controller.showInDetails.should.be.a.Function;
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/items/items.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc overview
3 | * @name <%= scriptAppName %>.admin.user.list.items
4 | * @requires ui.router
5 | * @requires components/listImage
6 | *
7 | * @description
8 | * The `<%= scriptAppName %>.admin.user.list.items` module which provides:
9 | *
10 | * - {@link <%= scriptAppName %>.admin.user.list.items.controller:UserItemsController UserItemsController}
11 | */
12 |
13 | (function () {
14 | 'use strict';
15 |
16 | angular
17 | .module('<%= scriptAppName %>.admin.user.list.items', [
18 | 'ui.router',
19 | '<%= scriptAppName %>.listImage'
20 | ]);
21 |
22 | })();
23 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/items/items.scss:
--------------------------------------------------------------------------------
1 | #user-list-content {}
2 | #user-items-content {}
3 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/list.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as UserListController
6 | */
7 | angular
8 | .module('<%= scriptAppName %>.admin.user.list')
9 | .controller('UserListController', UserListController);
10 |
11 | // add UserListController dependencies to inject
12 | UserListController.$inject = ['users', '$state', 'ToggleComponent'<% if(features.socketio) { %>, '$scope', 'socket'<% } %>];
13 |
14 | /**
15 | * UserListController constructor
16 | *
17 | * @param {Array} users - The list of users resolved for this route
18 | * @param {$state} $state - The $state to activate routing states on
19 | * @param {ToggleComponent} ToggleComponent - The toggle component service for switching the detail view
20 | */
21 | function UserListController(users, $state, ToggleComponent <% if(features.socketio) { %>, $scope, socket<% }%>) {
22 | var vm = this;
23 |
24 | // the array of users
25 | vm.users = users;
26 | // toggle detail view
27 | vm.toggleDetails = toggleDetails;<% if(features.socketio) { %>
28 |
29 | // initialize the controller
30 | activate();
31 |
32 | /**
33 | * Register socket updates and unsync on scope $destroy event
34 | */
35 | function activate() {
36 | socket.syncUpdates('user', vm.users);
37 | $scope.$on('$destroy', unsyncUserUpdates);
38 |
39 | function unsyncUserUpdates() {
40 | socket.unsyncUpdates('user');
41 | }
42 | }<% } %>
43 |
44 | /**
45 | * Toggle the detail view
46 | */
47 | function toggleDetails() {
48 | ToggleComponent('user.detailView').toggle();
49 | }
50 | }
51 |
52 | })();
53 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/list.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: UserListController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.admin.user.list'));
7 | beforeEach(module('socketMock'));
8 |
9 | var controller;
10 | var users;
11 | var scope;
12 | var socket;
13 |
14 | // Initialize the controller and a mock scope
15 | beforeEach(inject(function ($controller, $rootScope, _socket_) {
16 | scope = $rootScope.$new();
17 | users = [{name: 'admin'}, {name: 'testuser'}];
18 | socket = _socket_;
19 | controller = $controller('UserListController', {
20 | users: users,
21 | $scope: scope,
22 | socket: socket
23 | });
24 | }));
25 |
26 | it('object should exist', function () {
27 | Should.exist(controller);
28 | controller.should.be.an.instanceof(Object);
29 | });
30 |
31 | it('users should exist', function () {
32 | Should.exist(controller.users);
33 | controller.users.should.be.eql(users);
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/list/list.scss:
--------------------------------------------------------------------------------
1 | #<%= name %>-list-content {}
2 |
3 | #<%= name %>-detail-content {}
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/user.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as UserController
5 | angular
6 | .module('<%= scriptAppName %>.admin.user')
7 | .controller('UserController', UserController);
8 |
9 | // add UserController dependencies to inject
10 | // UserController.$inject = [''];
11 |
12 | /**
13 | * UserController constructor. Main controller for the <%= scriptAppName %>.admin.user
14 | * module.
15 | *
16 | */
17 | function UserController() {
18 | // var vm = this;
19 | }
20 |
21 | })();
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/user.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: UserController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.admin.user'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('UserController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/user.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/user.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.user module
6 | * and configure it.
7 | *
8 | * @requires ngResource
9 | * @requires ui.router
10 | * @requires {<%= scriptAppName %>.admin.user.list}
11 | * @requires {<%= scriptAppName %>.admin.user.create}
12 | */
13 | angular
14 | .module('<%= scriptAppName %>.admin.user', [
15 | 'ngResource',
16 | 'ui.router',
17 | '<%= scriptAppName %>.admin.user.list',
18 | '<%= scriptAppName %>.admin.user.create'
19 | ])
20 | .config(configUserRoutes);
21 |
22 | // inject configUserRoutes dependencies
23 | configUserRoutes.$inject = ['$urlRouterProvider', '$stateProvider'];
24 |
25 | /**
26 | * Route configuration function configuring the passed $stateProvider.
27 | * Register the abstract user state with the user template
28 | * paired with the UserController as 'index'.
29 | * The injectable 'users' is resolved as a list of all users
30 | * and can be injected in all sub controllers.
31 | *
32 | * @param {$urlRouterProvider} $urlRouterProvider - The URL router provider to redirect to the main state
33 | * @param {$stateProvider} $stateProvider - The state provider to configure
34 | */
35 | function configUserRoutes($urlRouterProvider, $stateProvider) {
36 | // The user state configuration
37 | var userState = {
38 | name: 'admin.user',
39 | parent: 'admin',
40 | url: '/user',
41 | abstract: true,
42 | templateUrl: 'app/admin/user/user.html',
43 | controller: 'UserController',
44 | controllerAs: 'index'
45 | };
46 |
47 | $urlRouterProvider.when('/admin/user', '/admin/user/');
48 | $stateProvider.state(userState);
49 | }
50 |
51 | })();
52 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/admin(auth)/user/user.scss:
--------------------------------------------------------------------------------
1 | #user-content {}
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/clientModelDoc.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as ClientModelDocController
5 | angular
6 | .module('<%= scriptAppName %>.clientModelDoc')
7 | .controller('ClientModelDocController', ClientModelDocController);
8 |
9 | /**
10 | * add ClientModelDocController dependencies to inject
11 | * @param {Service} ClientModelDocDefinition The model definition of ClientModelDoc resource
12 | */
13 | ClientModelDocController.$inject = ['ClientModelDocDefinition'];
14 |
15 | /**
16 | * ClientModelDocController constructor. Main controller for the <%= scriptAppName %>.clientModelDoc
17 | * module.
18 | *
19 | * @param {$scope} $scope - The scope to listen for events
20 | * @param {socket.io} socket - The socket to register updates
21 | */
22 | function ClientModelDocController(ClientModelDocDefinition) {
23 | var vm = this;
24 |
25 | vm.clientModelDocDefinition = ClientModelDocDefinition;
26 | }
27 |
28 | })();
29 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/clientModelDoc.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/clientModelDoc.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/clientModelDoc.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.clientModelDoc module
6 | * and configure it.
7 | *
8 | * @requires ui.router
9 | * @requires ngResource
10 | * @requires <%= scriptAppName %>.clientModelDoc.main
11 | * @requires <%= scriptAppName %>.clientModelDoc.list
12 | * @requires <%= scriptAppName %>.clientModelDoc.create
13 | */
14 | angular
15 | .module('<%= scriptAppName %>.clientModelDoc', [
16 | 'ngResource',
17 | 'ui.router',
18 | '<%= scriptAppName %>.clientModelDoc.main',
19 | '<%= scriptAppName %>.clientModelDoc.list',
20 | '<%= scriptAppName %>.clientModelDoc.create'
21 | ])
22 | .config(configClientModelDocRoutes);
23 |
24 | // inject configClientModelDocRoutes dependencies
25 | configClientModelDocRoutes.$inject = ['$urlRouterProvider', '$stateProvider'];
26 |
27 | /**
28 | * Route configuration function configuring the passed $stateProvider.
29 | * Register the abstract clientModelDoc state with the clientModelDoc template
30 | * paired with the ClientModelDocController as 'index'.
31 | * The injectable 'clientModelDocs' is resolved as a list of all clientModelDocs
32 | * and can be injected in all sub controllers.
33 | *
34 | * @param {$stateProvider} $stateProvider - The state provider to configure
35 | */
36 | function configClientModelDocRoutes($urlRouterProvider, $stateProvider) {
37 | // The clientModelDoc state configuration
38 | var clientModelDocState = {
39 | name: 'clientModelDoc',
40 | url: '/client-model-doc',
41 | abstract: true,
42 | templateUrl: 'app/clientModelDoc/clientModelDoc.html',
43 | controller: 'ClientModelDocController',
44 | controllerAs: 'index'
45 | };
46 |
47 | $urlRouterProvider.when('/clientModelDoc', '/clientModelDoc/');
48 | $stateProvider.state(clientModelDocState);
49 | }
50 |
51 | })();
52 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/clientModelDoc.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-content {}
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/create/create.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocCreateController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc.create'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocCreateController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/create/create.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 | Create a new clientModelDoc for your application.
13 |
14 |
15 |
16 |
34 |
35 |
36 |
37 |
38 | Cancel
39 | Create clientModelDoc
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/create/create.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-create-content {
2 | min-width: 450px;
3 | }
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/detail/detail.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the edit controller as ClientModelDocDetailController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.clientModelDoc.list.detail')
10 | .controller('ClientModelDocDetailController', ClientModelDocDetailController);
11 |
12 | // add ClientModelDocDetailController dependencies to inject
13 | ClientModelDocDetailController.$inject = ['$state', 'clientModelDoc'];
14 |
15 | /**
16 | * ClientModelDocDetailController constructor
17 | */
18 | function ClientModelDocDetailController($state, clientModelDoc) {
19 | var vm = this;
20 |
21 | // the current clientModelDoc to display
22 | vm.clientModelDoc = clientModelDoc;
23 | // switch to the edit state
24 | vm.edit = edit;
25 | // switch to the parent state
26 | vm.goBack = goBack
27 |
28 | /**
29 | * Open the edit state with the current clientModelDoc
30 | *
31 | */
32 | function edit() {
33 | $state.go('^.edit', {'id': vm.clientModelDoc._id});
34 | }
35 |
36 | /**
37 | * Return to the parent state
38 | *
39 | */
40 | function goBack() {
41 | $state.go('^');
42 | }
43 | }
44 | })();
45 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/detail/detail.controller.spec.js:
--------------------------------------------------------------------------------
1 | /*jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Controller: ClientModelDocDetailController', function () {
5 |
6 | // load the controller's module
7 | beforeEach(module('<%= scriptAppName %>.list.detail'));
8 |
9 | var controller;
10 | var clientModelDoc;
11 | var stateSpy;
12 |
13 | // Setup some states to test the navigation functions
14 | beforeEach(inject(function ($state) {
15 | stateSpy = sinon.stub($state, 'go');
16 | clientModelDoc = {_id: '1337id', name: 'admin', active: true};
17 | }));
18 |
19 | // Initialize the controller and a mock scope
20 | beforeEach(inject(function ($controller) {
21 | controller = $controller('ClientModelDocDetailController', {
22 | user: user
23 | });
24 | }));
25 |
26 | it('should exist as an object', function () {
27 | Should.exist(controller);
28 | controller.should.be.an.Object;
29 | });
30 |
31 | it('should have a method to navigate to the parent state', function () {
32 | Should.exist(controller.goBack);
33 | controller.goBack.should.be.a.Function;
34 | controller.goBack();
35 | stateSpy.calledOnce.should.be.ok;
36 | stateSpy.withArgs('^').called.should.be.ok;
37 | });
38 |
39 | it('should have a method to navigate to the edit state which is passing the correct id parameter', function () {
40 | Should.exist(controller.edit);
41 | controller.edit.should.be.a.Function;
42 | controller.edit();
43 | stateSpy.calledOnce.should.be.ok;
44 | stateSpy.withArgs('^.edit', {'id': user._id}).called.should.be.ok;
45 | });
46 | });
47 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/detail/detail.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-detail-content {
2 | .detail-info {
3 | md-checkbox[ng-disabled] {
4 | margin: 0;
5 | }
6 | }
7 |
8 | md-switch.no-label .md-label,
9 | md-checkbox[ng-disabled].no-label .md-label {
10 | display: none;
11 | }
12 | }
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/edit/edit.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocEditController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc.edit'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocEditController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/edit/edit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{edit.displayName}}
14 |
15 |
16 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/edit/edit.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-edit-content {}
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/items/items.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as ClientModelDocItemsController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.clientModelDoc.list.items')
10 | .controller('ClientModelDocItemsController', ClientModelDocItemsController);
11 |
12 | // add ClientModelDocItemsController dependencies to inject
13 | ClientModelDocItemsController.$inject = ['$state'];
14 |
15 | /**
16 | * ClientModelDocItemsController constructor
17 | */
18 | function ClientModelDocItemsController($state) {
19 | var vm = this;
20 |
21 | // the selected item id
22 | var curClientModelDocId = null;
23 |
24 | // check if this item is selected
25 | vm.isSelected = isSelected;
26 | // switch to the detail state
27 | vm.showInDetails = showInDetails;
28 |
29 | /**
30 | * Check if the passed item is the current selected item
31 | *
32 | * @param {Object} clientModelDoc - The object to check for selection
33 | */
34 | function isSelected(clientModelDoc) {
35 | return curClientModelDocId === clientModelDoc._id;
36 | }
37 |
38 | /**
39 | * Open the detail state with the selected item
40 | *
41 | * @param {Object} clientModelDoc - The clientModelDoc to edit
42 | */
43 | function showInDetails(clientModelDoc) {
44 | curClientModelDocId = clientModelDoc._id;
45 | $state.go('clientModelDoc.list.detail', {'id': curClientModelDocId});
46 | }
47 | }
48 |
49 | })();
50 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/items/items.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocItemsController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc.items'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocItemsController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/items/items.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.clientModelDoc.list.items module
6 | * @requires ui.router
7 | */
8 |
9 | angular
10 | .module('<%= scriptAppName %>.clientModelDoc.list.items', ['ui.router']);
11 |
12 | })();
13 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/items/items.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-list-content {
2 | #clientModelDoc-items-content {
3 | md-item {
4 |
5 | &.selected {
6 | background: rgba(0, 188, 212, 0.1);
7 | }
8 |
9 | &.list-head {
10 | color: #999;
11 |
12 | md-item-content {
13 | padding-left: 64px;
14 |
15 | * {
16 | font-weight: bold;
17 | }
18 | }
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/list.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as ClientModelDocListController
6 | */
7 | angular
8 | .module('<%= scriptAppName %>.clientModelDoc.list')
9 | .controller('ClientModelDocListController', ClientModelDocListController);
10 |
11 | // add ClientModelDocListController dependencies to inject
12 | ClientModelDocListController.$inject = ['$scope', 'socket', '$state', 'clientModelDocs', 'ToggleComponent'];
13 |
14 | /**
15 | * ClientModelDocListController constructor
16 | *
17 | * @param {Object} $scope - The current scope
18 | * @param {Object} socket - The socket service to register to
19 | * @param {$state} $state - The $state to activate routing states on
20 | * @param {Array} clientModelDocs - The list of clientModelDocs resolved for this route
21 | * @param {Service} ToggleComponent - The service for switching the detail view
22 | */
23 | function ClientModelDocListController($scope, socket, $state, clientModelDocs, ToggleComponent) {
24 | var vm = this;
25 |
26 | // the array of clientModelDocs
27 | vm.clientModelDocs = clientModelDocs;
28 | // toggle detail view
29 | vm.toggleDetails = toggleDetails;
30 |
31 | // initialize the controller
32 | activate();
33 |
34 | /**
35 | * Register socket updates and unsync on scope $destroy event
36 | */
37 | function activate() {
38 | socket.syncUpdates('clientModelDoc', vm.clientModelDocs);
39 | $scope.$on('$destroy', unsyncClientModelDocUpdates);
40 |
41 | function unsyncClientModelDocUpdates() {
42 | socket.unsyncUpdates('clientModelDoc');
43 | }
44 | }
45 |
46 | /**
47 | * Toggle the detail view
48 | */
49 | function toggleDetails() {
50 | ToggleComponent('clientModelDoc.detailView').toggle();
51 | }
52 | }
53 |
54 | })();
55 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/list.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocListController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocListController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/list/list.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-list-content {}
2 |
3 | [md-component-id="clientModelDoc.detailView"] {}
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/main/main.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as ClientModelDocMainController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.clientModelDoc.main')
10 | .controller('ClientModelDocMainController', ClientModelDocMainController);
11 |
12 | // add ClientModelDocMainController dependencies to inject
13 | ClientModelDocMainController.$inject = ['$state'];
14 |
15 | /**
16 | * ClientModelDocMainController constructor
17 | */
18 | function ClientModelDocMainController($state) {
19 | var vm = this;
20 | // switch to the list state
21 | vm.showList = showList;
22 |
23 | /**
24 | * Activate the clientModelDoc.list state
25 | */
26 | function showList() {
27 | $state.go('clientModelDoc.list');
28 | }
29 | }
30 |
31 | })();
32 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/main/main.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: ClientModelDocMainController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.clientModelDoc.main'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('ClientModelDocMainController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/main/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ClientModelDoc Section
22 |
23 | This is the main page of the ClientModelDoc route.
24 |
25 |
26 | View your list of ClientModelDocs
27 | or create a ClientModelDoc .
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/main/main.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.clientModelDoc.main module
6 | * and configure it.
7 | *
8 | * @requires ui.router
9 | * @requires <%= scriptAppName %>.mainMenu
10 | */
11 |
12 | angular
13 | .module('<%= scriptAppName %>.clientModelDoc.main', [
14 | 'ui.router',
15 | '<%= scriptAppName %>.mainMenu'
16 | ])
17 | .config(configClientModelDocMainRoutes);
18 |
19 | // inject configClientModelDocMainRoutes dependencies
20 | configClientModelDocMainRoutes.$inject = ['$stateProvider', 'mainMenuProvider'];
21 |
22 | /**
23 | * Route configuration function configuring the passed $stateProvider.
24 | * Register the clientModelDoc.main state with the list template for the
25 | * 'main' view paired with the ClientModelDocMainController as 'main'.
26 | *
27 | * @param {$stateProvider} $stateProvider - The state provider to configure
28 | * @param {mainMenuProvider} mainMenuProvider - The service to pass navigation information to
29 | */
30 | function configClientModelDocMainRoutes($stateProvider, mainMenuProvider) {
31 | // The main state configuration
32 | var mainState = {
33 | name: 'clientModelDoc.main',
34 | parent: 'clientModelDoc',
35 | url: '/',
36 | authenticate: true,
37 | role: 'admin',
38 | views: {
39 | '@clientModelDoc': {
40 | templateUrl: 'app/clientModelDoc/main/main.html',
41 | controller: 'ClientModelDocMainController',
42 | controllerAs: 'main'
43 | }
44 | }
45 | };
46 |
47 | $stateProvider.state(mainState);
48 |
49 | mainMenuProvider.addMenuItem({
50 | name: 'ClientModelDoc',
51 | state: mainState.name,
52 | role: 'admin'
53 | });
54 | }
55 |
56 | })();
57 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/clientModelDoc(demo)/main/main.scss:
--------------------------------------------------------------------------------
1 | #clientModelDoc-main-content {}
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/date-interceptor/date-interceptor.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 | var validDateFormats = [
4 | 'YYYY-MM-DDTHH:mm:ss.SSSZZ',
5 | 'YYYY-MM-DDTHH:mm:ss',
6 | 'YYYY-MM-DD',
7 | ];
8 |
9 | // register the service as DateInterceptorService
10 | angular
11 | .module('<%= scriptAppName %>')
12 | .constant('DateInterceptor', DateInterceptor);
13 |
14 | // add DateInterceptor dependencies to inject
15 | // DateInterceptor.$inject = [''];
16 |
17 | /**
18 | * DateInterceptor factory constructor
19 | * AngularJS will instantiate a singleton which is
20 | * an object that has the members of this factory
21 | */
22 | function DateInterceptor(input) {
23 | // Ignore things that aren't objects.
24 | if (!angular.isObject(input)) return input;
25 |
26 | for (var key in input) {
27 | if (!input.hasOwnProperty(key)) continue;
28 |
29 | var value = input[key];
30 | if (angular.isString(value)) {
31 | // Check for string properties which look like dates.
32 | validDateFormats.forEach(function(format) {
33 | var dateTime = moment(value, format, true);
34 | if (dateTime.isValid()) {
35 | input[key] = dateTime.toDate();
36 | return;
37 | }
38 | });
39 | } else if (angular.isObject(value)) {
40 | // Recurse into object
41 | DateInterceptor(value);
42 | }
43 |
44 | }
45 | return input;
46 | }
47 |
48 | })();
49 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/date-interceptor/date-interceptor.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Constant: DateInterceptor', function () {
4 |
5 | // load the constant's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate service
9 | var constant;
10 |
11 | beforeEach(inject(function (_DateInterceptor_) {
12 | constant = _DateInterceptor_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(constant);
17 | });
18 |
19 | it('should convert ISO string to date', function () {
20 | var normalString = 'normal string';
21 | var normalObject = {normal: 'object'};
22 |
23 | var now = new Date();
24 | var input = {
25 | str: normalString,
26 | obj: normalObject,
27 | date: now.toISOString(),
28 | nested: {
29 | date: now.toISOString(),
30 | }
31 | };
32 | var output = constant(input);
33 |
34 | output.should.equal(input);
35 | output.str.should.equal(normalString);
36 | output.obj.should.equal(normalObject);
37 |
38 | output.date.should.eql(now);
39 | output.nested.date.should.eql(now);
40 | });
41 |
42 | it('should not convert normal string containing numbers to date', function () {
43 | var normalStringWithNumbers = 'no2r3m4a5l string';
44 |
45 | var input = {
46 | str: normalStringWithNumbers,
47 | };
48 | var output = constant(input);
49 | output.str.should.equal(normalStringWithNumbers);
50 | });
51 |
52 | });
53 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/io(socketio)/io.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | angular
5 | .module('<%= scriptAppName %>.io', [])
6 | .factory('io', IOService);
7 |
8 | // inject IOService dependencies
9 | IOService.$inject = ['$window'];
10 |
11 | /**
12 | *
13 | * IOService constructor
14 | * @param $window
15 | * @returns {*}
16 | * @constructor
17 | */
18 | function IOService($window) {
19 | // remove io from global object
20 | var io = $window.io;
21 | delete $window.io;
22 | return io;
23 | }
24 |
25 | })();
26 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/list-image/list-image.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | angular
5 | .module('<%= scriptAppName %>.listImage', ['<%= scriptAppName %>.lodash'])
6 | .factory('AlphabetColor', AlphabetColor)
7 | .directive('listImage', listImage);
8 |
9 | AlphabetColor.$inject = ['_'];
10 |
11 | function AlphabetColor(_) {
12 | var colors = [
13 | '#f9a43e',
14 | '#59a2be',
15 | '#67bf74',
16 | '#f58559',
17 | '#e4c62e',
18 | '#f16364',
19 | '#2093cd',
20 | '#ad62a7'
21 | ];
22 | var numberOfColors = colors.length;
23 |
24 | return getColor;
25 |
26 | function hashCode(str) {
27 | var hash = 0,
28 | length = str.length,
29 | i, chr;
30 |
31 | if (length === 0) {
32 | return hash;
33 | }
34 |
35 | for (i = 0; i < length; i++) {
36 | chr = str.charCodeAt(i);
37 | hash = ((hash << 5) - hash) + chr;
38 | hash |= 0; // Convert to 32bit integer
39 | }
40 |
41 | return hash;
42 | }
43 |
44 | function getColor(string) {
45 | var color = Math.abs(hashCode(string.charAt(0))) % numberOfColors;
46 | return colors[color];
47 | }
48 | }
49 |
50 | listImage.$inject = ['$mdTheming', 'AlphabetColor'];
51 |
52 | function listImage($mdTheming, AlphabetColor) {
53 | var templateString = [
54 | '',
55 | '{{::firstLetter}} ',
56 | '
'].join('');
57 |
58 | return {
59 | restrict: 'E',
60 |
61 | template: templateString,
62 |
63 | link: function ($scope, element, attrs) {
64 | $mdTheming(element);
65 | $scope.firstLetter = attrs.string.charAt(0);
66 | $scope.bgColor = AlphabetColor($scope.firstLetter);
67 | }
68 | };
69 | }
70 |
71 | })();
72 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/list-image/style.scss:
--------------------------------------------------------------------------------
1 | img.list-image {
2 | border-radius: 30px;
3 | width: 42px;
4 | margin: 8px 16px;
5 | border: 1px solid #eee;
6 | }
7 |
8 | list-image {
9 |
10 | div, img {
11 | border-radius: 30px;
12 | width: 42px;
13 | margin: 8px 16px;
14 | border: none;
15 | color: #fff;
16 |
17 | &.md-light-blue-dark-theme {
18 | color: #000;
19 | border: 1px solid #888;
20 | }
21 |
22 | }
23 |
24 | div {
25 | height: 42px;
26 | text-align: center;
27 | line-height: 42px;
28 |
29 | span {
30 | font-size: 20px;
31 | }
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/lodash/lodash.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as _
5 | angular
6 | .module('<%= scriptAppName %>.lodash', [])
7 | .factory('_', LodashService);
8 |
9 | // add LodashService dependencies to inject
10 | LodashService.$inject = ['$window'];
11 |
12 | /**
13 | * LodashService constructor
14 | *
15 | * @param $window
16 | * @returns {exports._|*}
17 | * @constructor
18 | */
19 | function LodashService($window) {
20 | // remove lodash from global object
21 | var _ = $window._;
22 | delete $window._;
23 |
24 | // mixin functions
25 | _.mixin({'groupFilter': groupFilter});
26 |
27 | return _;
28 |
29 | /**
30 | * Group an array of objects into several arrays by the given
31 | * criteria, each group sorted by groupSort, each group consists
32 | * of items named groupItemsName.
33 | *
34 | * @param data
35 | * @param criteria
36 | * @param groupSort
37 | * @param groupItemsName
38 | * @returns {*}
39 | */
40 | function groupFilter(data, criteria, groupSort, groupItemsName) {
41 | if (!data || !data.length) {
42 | return data;
43 | }
44 |
45 | groupItemsName = groupItemsName || 'items';
46 |
47 | return _
48 | .chain(data)
49 | .sortBy(groupSort)
50 | .groupBy(criteria)
51 | .pairs()
52 | .map(function (currentItem) {
53 | return _.object(_.zip(['key', groupItemsName], currentItem));
54 | })
55 | .sortBy('key')
56 | .value();
57 | }
58 | }
59 |
60 | })();
61 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.controller.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc controller
3 | * @name mainMenu.controller:MainMenuController
4 | * @description
5 | * The controller for the main menu
6 | *
7 | */
8 |
9 | (function () {
10 | 'use strict';
11 |
12 | // register the controller as MainMenuController
13 | angular
14 | .module('<%= scriptAppName %>.mainMenu')
15 | .controller('MainMenuController', MainMenuController);
16 |
17 |
18 | /**
19 | * @ngdoc function
20 | * @name mainMenu.provider:MainMenuController
21 | * @description
22 | * Provider of the {@link mainMenu.controller:MainMenuController MainMenuController}
23 | * @param {Service} $rootScope The rootScope service to use
24 | * @param {Service} mainMenu The mainMenu service to use
25 | * @param {Service} $mdSidenav The mdSidenav service to use
26 | * @param {Service} _ The lodash service to use
27 | * @returns {Service} {@link mainMenu.controller:MainMenuController MainMenuController}
28 | */
29 |
30 | MainMenuController.$inject = ['mainMenu', '$mdSidenav', '_'<% if (features.auth) { %>, 'Auth'<% } %>];
31 |
32 |
33 | function MainMenuController(mainMenu, $mdSidenav, _ <% if (features.auth) { %>, Auth<% } %>) {
34 | var vm = this;
35 |
36 | // view model bindings
37 | vm.sidenavId = 'mainMenu';
38 | vm.items = _.sortBy(mainMenu.getMenu(), 'order');
39 | vm.close = close;<% if (features.auth) { %>
40 | vm.canAccess = canAccess;
41 | vm.logout = logout;<% } %>
42 |
43 | function close() {
44 | return $mdSidenav(vm.sidenavId).close();
45 | }<% if (features.auth) { %>
46 |
47 | /**
48 | * Check if the current user can access the menu item
49 | * @param {Object} menuItem
50 | */
51 | function canAccess(menuItem) {
52 | if (menuItem.role) {
53 | return Auth.hasRole(menuItem.role);
54 | }
55 |
56 | return true;
57 | }
58 |
59 | /**
60 | * Logout the current user
61 | */
62 | function logout() {
63 | vm.close().then(Auth.logout);
64 | }<% } %>
65 | }
66 |
67 | })();
68 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.controller.spec.js:
--------------------------------------------------------------------------------
1 | /* jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Controller: MainMenuController', function () {
5 |
6 | // load the controller's module
7 | beforeEach(module('<%= scriptAppName %>.mainMenu'));
8 |
9 | var controller;
10 | var menuEntry = {name: 'test', state: 'test.main'};
11 | var mainMenuMock = {
12 | getMenu: function () {
13 | return [menuEntry]
14 | }
15 | };
16 | var $mdSidenavMock = function () {
17 | return {
18 | open: function () {},
19 | close: function () {}
20 | }
21 | }
22 |
23 | // Initialize the controller and a mock scope
24 | beforeEach(inject(function ($controller, $rootScope) {
25 | controller = $controller('MainMenuController', {
26 | mainMenu: mainMenuMock,
27 | $mdSidenav: $mdSidenavMock
28 | });
29 | }));
30 |
31 | it('object should exist', function () {
32 | Should.exist(controller);
33 | controller.should.be.an.Object;
34 | });
35 |
36 | it('should have an items property', function () {
37 | Should.exist(controller.items);
38 | controller.items.should.be.an.Array;
39 | controller.items.should.eql([menuEntry]);
40 | });
41 |
42 | });
43 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as MainMenu
5 | angular
6 | .module('<%= scriptAppName %>.mainMenu')
7 | .directive('mainMenu', MainMenu);
8 |
9 | // add MainMenu dependencies to inject
10 | MainMenu.$inject = ['$rootScope', '$mdSidenav', '$document'];
11 |
12 | /**
13 | * MainMenu directive
14 | */
15 | function MainMenu($rootScope, $mdSidenav, $document) {
16 | // directive definition members
17 | var directive = {
18 | link: link,
19 | restrict: 'E',
20 | replace: true,
21 | templateUrl: 'app/components/main-menu/main-menu.html'
22 | };
23 |
24 | return directive;
25 |
26 | // directives link definition
27 | function link(scope, elem, attrs) {
28 | var componentId = attrs.mdComponentId || 'mainMenu';
29 | var mainContentArea = $document[0].querySelector(attrs.mainContent || 'main');
30 |
31 | $rootScope.$on('$locationChangeSuccess', openPage);
32 |
33 | /**
34 | * @ngdoc function
35 | * @name openPage
36 | * @methodOf mainMenu.directive:
37 | * @description
38 | * Open a page
39 | */
40 | function openPage() {
41 | $mdSidenav(componentId)
42 | .close()
43 | .then(mainContentArea.focus());
44 | }
45 | }
46 | }
47 |
48 |
49 | })();
50 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.html:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | {{::<%= appname %>}}
8 |
9 |
10 |
11 | <% if (features.auth) { %>
12 |
13 |
14 | Logout
15 |
16 | <% } %>
17 |
18 |
19 | {{item.name}}
20 |
21 |
22 | {{subItem.name}}
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc overview
3 | * @name mainMenu
4 | * @requires <%= scriptAppName %>.lodash<% if (features.auth) { %>
5 | * @requires <%= scriptAppName %>.auth<% } %>
6 | * @description
7 | * The `<%= scriptAppName %>.mainMenu` module which provides:
8 | *
9 | * - {@link mainMenu.controller:MainMenuController MainMenuController}
10 | * - {@link mainMenu.service:mainMenu mainMenu-service}
11 | */
12 |
13 | (function () {
14 | 'use strict';
15 |
16 | angular.module('<%= scriptAppName %>.mainMenu', [
17 | '<%= scriptAppName %>.lodash'<% if (features.auth) { %>,
18 | '<%= scriptAppName %>.auth'<% } %>
19 | ])
20 |
21 | })();
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.scss:
--------------------------------------------------------------------------------
1 | md-sidenav[md-component-id="mainMenu"] {
2 |
3 | md-toolbar list-image div {
4 | margin: 0 16px 0 0;
5 | }
6 |
7 | ul {
8 | list-style: none;
9 | padding: 0;
10 | }
11 |
12 | li {
13 | margin: 0;
14 | }
15 |
16 | md-content {
17 |
18 | ul > li > ul > li > .md-button {
19 | padding-left: 42px;
20 | }
21 |
22 | .md-button {
23 | display: block;
24 | border-radius: 0;
25 | color: inherit;
26 | cursor: pointer;
27 | font-weight: 400;
28 | line-height: 40px;
29 | margin: 0;
30 | max-height: 40px;
31 | overflow: hidden;
32 | padding: 0px 16px;
33 | text-align: left;
34 | text-decoration: none;
35 | white-space: normal;
36 | width: 100%;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/main-menu/main-menu.service.spec.js:
--------------------------------------------------------------------------------
1 | /* jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Provider: mainMenuProvider', function () {
5 |
6 | // instantiate provider
7 | var provider;
8 |
9 | // dummy menu data for tests
10 | var menuEntry = {name: 'test', state: 'test.main'};
11 | var menuData;
12 |
13 |
14 | // load the provider's module and configure it with help of a dummy module
15 | beforeEach(function () {
16 | menuData = [menuEntry];
17 |
18 | angular.module('config.module', function () {})
19 | .config(['mainMenuProvider', function (_mainMenuProvider_) {
20 | provider = _mainMenuProvider_;
21 | }]);
22 |
23 | module('<%= scriptAppName %>.mainMenu', 'config.module');
24 |
25 | // trigger the injection config.module
26 | inject(function () {});
27 | });
28 |
29 | it('should be defined', function () {
30 | Should.exist(provider);
31 | });
32 |
33 | it('should have a getMenu function which returns an Object', inject(function (mainMenu) {
34 | (mainMenu.getMenu()).should.be.an.Array;
35 | }));
36 |
37 | describe('setMenu method', function () {
38 |
39 | beforeEach(function () {
40 | provider.setMenu(menuData);
41 | });
42 |
43 | it('should set the correct menu Object', inject(function (mainMenu) {
44 | (mainMenu.getMenu()).should.be.an.Array.and.equal(menuData);
45 | }));
46 | });
47 |
48 | describe('addMenuItem method', function () {
49 |
50 | beforeEach(function () {
51 | provider.setMenu(menuData);
52 | provider.addMenuItem(menuEntry);
53 | });
54 |
55 | it('should set the correct menu Object', inject(function (mainMenu) {
56 | (mainMenu.getMenu()).should.be.an.Array.and.eql([menuEntry, menuEntry]);
57 | }));
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-definitions/model-definitions.service.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Factory: ModelDefinitions', function () {
4 |
5 | // load the resource's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate service
9 | var resource;
10 |
11 | beforeEach(inject(function (_ModelDefinitions_) {
12 | resource = _ModelDefinitions_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(resource);
17 | });
18 |
19 | it('should be a resource object', function () {
20 | resource.doSomething().should.equal('model-definitions');
21 | });
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input-group.directive.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: modelInputGroup', function () {
4 |
5 | // load the directive's module and view
6 | beforeEach(module('<%= scriptAppName %>'));
7 | beforeEach(module('app/components/model-input-group/model-input-group.html'));
8 |
9 | var element, scope;
10 |
11 | beforeEach(inject(function ($rootScope, $compile) {
12 | scope = $rootScope.$new();
13 | element = angular.element(' ');
14 | element = $compile(element)(scope);
15 | scope.$apply();
16 | }));
17 |
18 | it('should set the element text', function () {
19 | element.text().should.equal('this is the modelInputGroup directive');
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input-group.html:
--------------------------------------------------------------------------------
1 |
9 |
10 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input-group.scss:
--------------------------------------------------------------------------------
1 | model-input-group {
2 | }
3 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{fieldDef.desc}}*
4 |
5 |
6 |
17 |
18 |
19 |
20 | {{validator.error}}
21 |
22 |
Should be a url
23 |
24 |
25 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input/model-input.directive.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: modelInput', function () {
4 |
5 | // load the directive's module and view
6 | beforeEach(module('<%= scriptAppName %>'));
7 | beforeEach(module('app/components/model-input-group/model-input/model-input.html'));
8 |
9 | var element, scope;
10 |
11 | beforeEach(inject(function ($rootScope, $compile) {
12 | scope = $rootScope.$new();
13 | element = angular.element(' ');
14 | element = $compile(element)(scope);
15 | scope.$apply();
16 | }));
17 |
18 | it('should set the element text', function () {
19 | element.text().should.equal('this is the modelInput directive');
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input/model-input.scss:
--------------------------------------------------------------------------------
1 | .model-input {
2 |
3 | &.select {
4 | padding-left: 2px;
5 | width: 100%;
6 |
7 | md-select {
8 | width: 100%;
9 | }
10 |
11 | md-select-label {
12 | & > span {
13 | margin-left: 2px;
14 | }
15 | }
16 |
17 | md-input-container {
18 | padding-left: 0;
19 | }
20 |
21 | $error-red: rgb(244,67,54);
22 | &.error md-select-label {
23 | color: $error-red;
24 | border-color: $error-red;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-input-group/model-input/select.html:
--------------------------------------------------------------------------------
1 |
23 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/detail.html:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/items-content.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
{{::display(viewModel, propDef)}}
12 |
16 | {{propDef.urlDesc || 'link'}}
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/items-header.html:
--------------------------------------------------------------------------------
1 |
2 |
7 |
{{::propDef.desc}}
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/model-view-group.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the directive as modelViewGroup
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .directive('modelViewGroup', modelViewGroup);
8 |
9 | // add modelViewGroup dependencies to inject
10 | modelViewGroup.$inject = ['$rootScope', 'ModelDefinitions', '$state'];
11 |
12 | /**
13 | * modelViewGroup directive
14 | */
15 | function modelViewGroup($rootScope, ModelDefinitions, $state) {
16 | // directive definition members
17 | var directive = {
18 | scope: {
19 | propDefinitions: '=definitions',
20 | viewModel: '=model',
21 | type: '@',
22 | iconProp: '=?',
23 | template: '=?',
24 | narrowMode: '=?'
25 | },
26 | link: link,
27 | templateUrl: function(element, attrs) {
28 | if (attrs.template) return attrs.template;
29 |
30 | var types = ['detail', 'items-content', 'items-header'];
31 | if (types.indexOf(attrs.type) === -1) {
32 | throw new Error('ModelViewGroup: type should be one of ' + types.join(','));
33 | }
34 | return 'app/components/model-view-group/' + attrs.type + '.html';
35 | },
36 | transclude: true,
37 | replace: true,
38 | restrict: 'EA'
39 | };
40 |
41 | return directive;
42 |
43 | // directives link definition
44 | function link(scope, element, attrs) {
45 | scope.showProp = showProp;
46 | scope.display = ModelDefinitions.display;
47 |
48 | function showProp(propDef) {
49 | return !scope.narrowMode || propDef.displayPriority !== 'low';
50 | }
51 | }
52 | }
53 |
54 | })();
55 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/model-view-group.directive.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: modelViewGroup', function () {
4 |
5 | // load the directive's module and view
6 | beforeEach(module('<%= scriptAppName %>'));
7 | beforeEach(module('app/components/model-view-group/model-view-group.html'));
8 |
9 | var element, scope;
10 |
11 | beforeEach(inject(function ($rootScope, $compile) {
12 | scope = $rootScope.$new();
13 | element = angular.element(' ');
14 | element = $compile(element)(scope);
15 | scope.$apply();
16 | }));
17 |
18 | it('should set the element text', function () {
19 | element.text().should.equal('this is the modelViewGroup directive');
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/model-view-group.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelkrone/generator-material-app/764465d953282f6d86349527e3d62ec97f12a4d1/generators/app/templates/client/app/components/model-view-group/model-view-group.html
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/model-view-group/model-view-group.scss:
--------------------------------------------------------------------------------
1 | model-view-group {
2 | }
3 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/remote-unique/remote-unique.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the directive as remoteUnique
5 | angular
6 | .module('<%= scriptAppName %>.remoteUnique', [])
7 | .directive('remoteUnique', RemoteUnique);
8 |
9 | // add RemoteUnique dependencies to inject
10 | RemoteUnique.$inject = ['$injector'];
11 |
12 | /**
13 | * RemoteUnique directive
14 | */
15 | function RemoteUnique($injector) {
16 | // directive definition members
17 | var directive = {
18 | require: 'ngModel',
19 | restrict: 'A',
20 | link: link
21 | };
22 |
23 | return directive;
24 |
25 | // directives link definition
26 | function link(scope, element, attrs, ctrl) {
27 | if (!attrs.remoteUnique) return;
28 |
29 | var service = $injector.get(attrs.remoteUnique);
30 | var ignore;
31 |
32 | attrs.$observe('remoteUniqueIgnore', function (newValue) {
33 | if (typeof ignore === 'undefined') ignore = newValue;
34 | });
35 |
36 | ctrl.$parsers.unshift(validateRemoteUnique);
37 | ctrl.$formatters.unshift(validateRemoteUnique);
38 |
39 | function validateRemoteUnique(viewValue) {
40 | var criteria = {};
41 |
42 | if (viewValue === ignore) {
43 | ctrl.$setValidity('remote-unique', true);
44 | return viewValue;
45 | }
46 |
47 | criteria[ctrl.$name] = viewValue;
48 |
49 | service.query(criteria, function (result) {
50 | ctrl.$setValidity('remote-unique', viewValue === ignore || !result.length);
51 | });
52 |
53 | return viewValue;
54 | }
55 | }
56 | }
57 | })();
58 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/remote-unique/remote-unique.directive.spec.js:
--------------------------------------------------------------------------------
1 | /*jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Directive: RemoteUnique', function () {
5 |
6 | var element;
7 | var form;
8 | var scope;
9 |
10 | var model;
11 | var serviceSpy;
12 | var serviceResult;
13 | var template = [
14 | ''
17 | ].join('');
18 |
19 | var serviceMock = {
20 | query: function(criteria, cb) {
21 | cb(serviceResult);
22 | }
23 | };
24 |
25 | // load the directive's module
26 | beforeEach(module('<%= scriptAppName %>.remoteUnique'));
27 |
28 | beforeEach(module(function ($provide) {
29 | $provide.value('Service', serviceMock);
30 | }));
31 |
32 | beforeEach(inject(function ($rootScope, $compile) {
33 | serviceSpy = sinon.stub(serviceMock, 'query').returns([1]);
34 |
35 | scope = $rootScope.$new();
36 | scope.model = {value: ''};
37 |
38 | element = angular.element(template);
39 | element = $compile(element)(scope);
40 | scope.$digest();
41 |
42 | form = scope.form;
43 | }));
44 |
45 | afterEach(function () {
46 | serviceMock.query.restore();
47 | });
48 |
49 | it('call the service defined in the attributes with an query object set', function () {
50 | form.valueField.$setViewValue('testval');
51 | serviceSpy.calledOnce.should.be.ok;
52 | serviceSpy.withArgs({valueField: 'testval'}).called.should.be.ok;
53 | });
54 |
55 | });
56 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/repeat-input/repeat-input-directive.spec.js:
--------------------------------------------------------------------------------
1 | /* jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Directive: RepeatInput', function () {
5 |
6 | // load the directive's module
7 | beforeEach(module('<%= scriptAppName %>.repeatInput'));
8 |
9 | var element, scope, form;
10 |
11 | var template = [''].join('');
15 |
16 | beforeEach(inject(function ($rootScope, $compile) {
17 | scope = $rootScope.$new();
18 | element = angular.element(template);
19 | element = $compile(element)(scope);
20 | form = scope.form;
21 | }));
22 |
23 | it('should set the validation invalid the for a wrong repeat value', function () {
24 | form.password.$setViewValue('Passw0rd');
25 | form.verify.$setViewValue('PasswOrd');
26 | form.verify.$invalid.should.be.true;
27 | form.$invalid.should.be.true;
28 | });
29 |
30 | it('should set the validation valid the for a correct repeat value', function () {
31 | form.password.$setViewValue('Passw0rd');
32 | form.verify.$setViewValue('Passw0rd');
33 | form.password.$invalid.should.be.false;
34 | form.verify.$invalid.should.be.false;
35 | form.$valid.should.be.true;
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/repeat-input/repeat-input.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as RepeatInput
5 | angular
6 | .module('<%= scriptAppName %>.repeatInput', [])
7 | .directive('repeatInput', RepeatInput);
8 |
9 | // add RepeatInput dependencies to inject
10 | // RepeatInput.$inject = [''];
11 |
12 | /**
13 | * RepeatInput directive
14 | */
15 | function RepeatInput() {
16 | // directive definition members
17 | var directive = {
18 | link: link,
19 | restrict: 'A',
20 | require: 'ngModel'
21 | };
22 |
23 | return directive;
24 |
25 | // directives link definition
26 | function link(scope, elem, attrs, model) {
27 | if (!attrs.repeatInput) {
28 | return;
29 | }
30 |
31 | scope.$watch(attrs.repeatInput, function (value) {
32 | // Only compare values if the second ctrl has a value.
33 | if (model.$viewValue !== undefined && model.$viewValue !== '') {
34 | model.$setValidity('repeat-input', value === model.$viewValue);
35 | }
36 | });
37 |
38 | model.$parsers.push(function (value) {
39 | // Mute the repeatInput error if the second ctrl is empty.
40 | if (value === undefined || value === '') {
41 | model.$setValidity('repeat-input', true);
42 | return value;
43 | }
44 |
45 | var isValid = value === scope.$eval(attrs.repeatInput);
46 | model.$setValidity('repeat-input', isValid);
47 | return isValid ? value : undefined;
48 | });
49 | }
50 | }
51 |
52 |
53 | })();
54 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/resource/resource.service.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc overview
3 | * @name resource
4 | * @requires lodash
5 | * @description
6 | * The <%= scriptAppName %>.resource module
7 | */
8 |
9 | /**
10 | * @ngdoc service
11 | * @name resource.service:Resource
12 | * @description
13 | * resource.service:Resource
14 | *
15 | */
16 |
17 | (function () {
18 | 'use strict';
19 |
20 | // register the service as Resource
21 | angular
22 | .module('<%= scriptAppName %>.resource', [
23 | 'ngResource',
24 | '<%= scriptAppName %>.lodash'
25 | ])
26 | .factory('Resource', Resource);
27 |
28 |
29 | /**
30 | * @ngdoc function
31 | * @name resource.provider:Resource
32 | * @description
33 | * Provider for the {@link resource.service:Resource Resource-service}
34 | *
35 | * @param {Service} $resource The resource service to use
36 | * @param {Service} _ The _ service to use
37 | * @returns {Function} Resource-factory
38 | */
39 |
40 | Resource.$inject = ['$resource', '_'];
41 |
42 | function Resource($resource, _) {
43 | // default $resource parameter configuration for MongoDB like id's
44 | var defaultParams = {
45 | id: '@_id'
46 | };
47 |
48 | // default $resource option configuration for RESTy PUT requests
49 | var defaultMethods = {
50 | update: {method: 'PUT', isArray: false},
51 | create: {method: 'POST'}
52 | };
53 |
54 | // public API
55 | return createResource;
56 |
57 | /**
58 | * Create a resource with overwritten $save method
59 | *
60 | * @param url
61 | * @param params
62 | * @param methods
63 | * @returns {$resource}
64 | */
65 | function createResource(url, params, methods) {
66 | var resource;
67 |
68 | params = _.defaults({}, params, defaultParams);
69 | methods = _.defaults({}, methods, defaultMethods);
70 | resource = $resource(url, params, methods);
71 |
72 | // overwrite $save to automatically call $create or $update
73 | resource.prototype.$save = function save() {
74 | if (!this._id) {
75 | return this.$create();
76 | }
77 |
78 | return this.$update();
79 | };
80 |
81 | return resource;
82 | }
83 | }
84 |
85 | })();
86 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/socket(socketio)/socket.mock.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | angular.module('socketMock', [])
4 | .factory('socket', function () {
5 | return {
6 | socket: {
7 | connect: function () {},
8 | on: function () {},
9 | emit: function () {},
10 | receive: function () {}
11 | },
12 |
13 | syncUpdates: function () {},
14 | unsyncUpdates: function () {}
15 | };
16 | });
17 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toast/toast.html:
--------------------------------------------------------------------------------
1 |
2 | {{::vm.text}}
3 |
4 |
8 | Show
9 |
10 |
11 | |
12 |
13 | OK
14 |
15 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toast/toast.service.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Service: Toast', function () {
4 |
5 | // load the service's module
6 | beforeEach(module('<%= scriptAppName %>.toast'));
7 |
8 | // instantiate service
9 | var service;
10 |
11 | beforeEach(inject(function (_Toast_) {
12 | service = _Toast_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(service);
17 | });
18 |
19 | it('should expose a show function', function () {
20 | Should.exist(service.show);
21 | });
22 |
23 | it('should expose a hide function', function () {
24 | Should.exist(service.hide);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toggle-component/toggle-component.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * The <%= scriptAppName %>.toggleComponent module
6 | * @module <%= scriptAppName %>.toggleComponent
7 | * @name ToggleComponent
8 | */
9 |
10 | angular
11 | .module('<%= scriptAppName %>.toggleComponent', []);
12 | })();
13 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toggle-component/toggle-component.scss:
--------------------------------------------------------------------------------
1 | [toggle-component] {
2 |
3 | &.toggle-component-locked-open {
4 | display: block;
5 | }
6 |
7 | &.toggle-component-closed {
8 | display: none;
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toggle-component/toggle-component.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the service as ToggleComponent
6 | * @module <%= scriptAppName %>.toggleComponent
7 | * @name ToggleComponent
8 | */
9 |
10 | angular
11 | .module('<%= scriptAppName %>.toggleComponent')
12 | .service('ToggleComponent', ToggleComponentService);
13 |
14 | // add ToggleComponent dependencies to inject
15 | ToggleComponentService.$inject = ['$mdComponentRegistry', '$log', '$q'];
16 |
17 | /**
18 | * ToggleComponent constructor
19 | * AngularJS will instantiate a singleton by calling "new" on this function
20 | *
21 | * @ngdoc controller
22 | * @name ToggleComponentService
23 | * @module <%= scriptAppName %>.toggleComponent
24 | * @returns {Object} The service definition for the ToggleComponent Service
25 | */
26 | function ToggleComponentService($mdComponentRegistry, $log, $q) {
27 | return function (contentHandle) {
28 | var errorMsg = "ToggleComponent '" + contentHandle + "' is not available!";
29 | var instance = $mdComponentRegistry.get(contentHandle);
30 |
31 | if (!instance) {
32 | $log.error('No content-switch found for handle ' + contentHandle);
33 | }
34 |
35 | return {
36 | isOpen: isOpen,
37 | toggle: toggle,
38 | open: open,
39 | close: close
40 | };
41 |
42 | function isOpen() {
43 | return instance && instance.isOpen();
44 | }
45 |
46 | function toggle() {
47 | return instance ? instance.toggle() : $q.reject(errorMsg);
48 | }
49 |
50 | function open() {
51 | return instance ? instance.open() : $q.reject(errorMsg);
52 | }
53 |
54 | function close() {
55 | return instance ? instance.close() : $q.reject(errorMsg);
56 | }
57 | };
58 | }
59 |
60 | })();
61 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/components/toggle-component/toggle-component.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by michael on 12.01.15.
3 | */
4 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/main/main.controller.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @ngdoc controller
3 | * @name <%= scriptAppName %>.main.controller:MainController
4 | * @description
5 | * Controls mainly nothing currently
6 | */
7 |
8 | (function () {
9 | 'use strict';
10 |
11 | // register the controller as MainController
12 | angular
13 | .module('<%= scriptAppName %>.main')
14 | .controller('MainController', MainController);
15 |
16 | /**
17 | * @ngdoc function
18 | * @name <%= scriptAppName %>.main.provider:MainController
19 | * @description
20 | * Provider of the {@link <%= scriptAppName %>.main.controller:MainController MainController}
21 | *
22 | * @param {Service} $scope The scope service to use
23 | * @param {Service} $http The http service to use
24 | */
25 |
26 | // MainController.$inject = [];
27 |
28 | function MainController() {
29 | var vm = this;
30 | }
31 |
32 | })();
33 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/main/main.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: MainController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | var MainController, scope;
9 |
10 | // Initialize the controller and a mock scope
11 | beforeEach(inject(function ($controller, $rootScope) {
12 | scope = $rootScope.$new();
13 | MainController = $controller('MainController', {
14 | $scope: scope
15 | });
16 | }));
17 |
18 | it('should exist', function () {
19 | MainController.should.be.instanceof(Object);
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/main/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= appname %>
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | The awesome <%= appname %> app
17 |
18 | This is version v<%= pkg.version %>
of the awesome <%= appname %> App.
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/main/main.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the route config on the application
5 | angular
6 | .module('<%= scriptAppName %>.main', ['ui.router'])
7 | .config(configMainRoute);
8 |
9 | // inject configMainRoute dependencies
10 | configMainRoute.$inject = ['$stateProvider', 'mainMenuProvider'];
11 |
12 | // route config function configuring the passed $stateProvider
13 | function configMainRoute($stateProvider, mainMenuProvider) {
14 | var mainState = {
15 | name: 'main',
16 | url: '/',
17 | authenticate: true,
18 | templateUrl: 'app/main/main.html',
19 | controller: 'MainController',
20 | controllerAs: 'vm'
21 | };
22 |
23 | $stateProvider.state(mainState);
24 |
25 | mainMenuProvider.addMenuItem({
26 | name: 'Home',
27 | state: mainState.name,
28 | order: 1
29 | });
30 | }
31 |
32 | })();
33 |
--------------------------------------------------------------------------------
/generators/app/templates/client/app/main/main.scss:
--------------------------------------------------------------------------------
1 | .thing-form {
2 | margin: 20px 0;
3 | }
4 |
5 | #banner {
6 | border-bottom: none;
7 | margin-top: -20px;
8 | }
9 |
10 | #banner h1 {
11 | font-size: 60px;
12 | line-height: 1;
13 | letter-spacing: -1px;
14 | }
15 |
16 | .hero-unit {
17 | position: relative;
18 | padding: 30px 15px;
19 | color: #F5F5F5;
20 | text-align: center;
21 | text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
22 | background: #4393B9;
23 | }
24 |
25 | .footer {
26 | text-align: center;
27 | padding: 30px 0;
28 | margin-top: 70px;
29 | border-top: 1px solid #E5E5E5;
30 | }
31 |
--------------------------------------------------------------------------------
/generators/app/templates/client/assets/images/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelkrone/generator-material-app/764465d953282f6d86349527e3d62ec97f12a4d1/generators/app/templates/client/assets/images/.gitkeep
--------------------------------------------------------------------------------
/generators/app/templates/client/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelkrone/generator-material-app/764465d953282f6d86349527e3d62ec97f12a4d1/generators/app/templates/client/favicon.ico
--------------------------------------------------------------------------------
/generators/app/templates/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | <%= name %>
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 | ng-show="app.isLoggedIn()"<% } %>>
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/generators/app/templates/client/styles/app.scss:
--------------------------------------------------------------------------------
1 | // @import 'common';
2 | // @import 'forms';
3 | // @import 'sections';
4 |
5 | @media screen and (max-width: 1200px) {
6 | .hide-in-narrow {
7 | display: none;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/generators/app/templates/client/styles/common.scss:
--------------------------------------------------------------------------------
1 | /**
2 | * App-wide Styles
3 | */
4 |
5 | body {
6 | overflow: hidden;
7 | }
8 |
9 | main {
10 | overflow: auto;
11 | }
12 |
13 | button.md-button {
14 | &.md-fab.fab-overlap {
15 | &[disabled] {
16 | background: #eee;
17 | }
18 | &.md-fab-top-left {
19 | left: 12px;
20 | }
21 | }
22 | }
23 |
24 | md-list {
25 | &.fab-padding {
26 | padding-bottom: 56px;
27 | }
28 |
29 | .list-info {
30 | color: rgba(0, 0, 0, 0.24);
31 | }
32 |
33 | md-item {
34 | &.selected {
35 | background: rgb(227, 242, 253);
36 | }
37 |
38 | &.list-head {
39 | color: #888;
40 |
41 | md-item-content {
42 | padding-left: 64px;
43 | }
44 | }
45 | }
46 | }
47 |
48 | md-dialog {
49 | max-height: 85%;
50 | }
51 |
52 | md-toolbar {
53 | .md-toolbar-tools {
54 | &.toolbar-tools-fab-overlap {
55 | padding-left: 78px;
56 | }
57 | }
58 |
59 | .md-button:not(.md-fab) {
60 | min-width: 1em;
61 | }
62 |
63 | .subtitle {
64 | font-size: .5em;
65 | }
66 |
67 | &.md-tall {
68 | button.md-button {
69 | &.md-fab.fab-overlap {
70 | &.md-fab-top-right,
71 | &.md-fab-top-left {
72 | top: 112px;
73 | }
74 | }
75 | }
76 | }
77 |
78 | &.md-medium-tall {
79 | button.md-button {
80 | &.md-fab.fab-overlap {
81 | &.md-fab-top-right,
82 | &.md-fab-top-left {
83 | top: 72px;
84 | }
85 | &.md-fab-top-left {
86 | left: 12px;
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
93 | md-content[ui-view="detail"] {
94 | background-color: rgb(245, 245, 245);
95 |
96 | md-content, md-tabs {
97 | background-color: rgb(245, 245, 245);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/generators/app/templates/client/styles/forms.scss:
--------------------------------------------------------------------------------
1 |
2 | md-input-container {
3 |
4 | md-select {
5 | -webkit-flex: 1;
6 | -ms-flex: 1;
7 | flex: 1;
8 | -webkit-order: 2;
9 | -ms-flex-order: 2;
10 | order: 2;
11 | display: block;
12 | background: none;
13 | padding: 12px 0 0 0;
14 | // border-bottom: 1px solid lightgray;
15 | line-height: 26px;
16 | -ms-flex-preferred-size: 26px;
17 | border-radius: 0;
18 | margin: 0;
19 |
20 | .md-select-label {
21 | font-size: 14px;
22 | }
23 |
24 | .md-select-icon {
25 | display: none;
26 | }
27 | }
28 |
29 | &.md-input-has-value md-select {
30 | padding: 1px 0px 0px 0px;
31 | border-bottom: none;
32 |
33 | .md-select-icon {
34 | display: block;
35 | }
36 | }
37 | }
38 |
39 | .md-select-label {
40 | font-size: 14px;
41 | }
42 |
--------------------------------------------------------------------------------
/generators/app/templates/client/styles/sections.scss:
--------------------------------------------------------------------------------
1 | .section {
2 | padding: 16px 0 16px 0;
3 |
4 | span {
5 | font-size: 14px;
6 | }
7 |
8 | &.slim {
9 | padding: 4px 0;
10 | }
11 |
12 | .section-title {
13 | color: #888;
14 | margin-bottom: 8px;
15 | font-size: .8em;
16 | text-transform: uppercase;
17 |
18 | &.slim {
19 | margin-bottom: 0;
20 | }
21 | }
22 |
23 | .detail-info {
24 | margin: 8px 0;
25 |
26 | &.slim {
27 | margin: 0;
28 | }
29 |
30 | span[flex]:first-child {
31 | color: #555;
32 | text-overflow: ellipsis;
33 | overflow: hidden;
34 | }
35 |
36 | span[flex]:nth-child(2) {
37 | color: #888;
38 | }
39 |
40 | @media (max-width: 600px) {
41 | span:not(first-child) {
42 | margin-top: 8px;
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/generators/app/templates/e2e/login(auth)/login.po.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by stupid on 16-6-8.
3 | */
4 |
5 | var roles = require('../../server/lib/auth/auth.service').roles;
6 | var users = require('../../server/config/testUsers');
7 |
8 | var LoginPage = function() {
9 | this.login = function(url, role) {
10 | role = role || roles.getMaxRole();
11 | var user = users.getUserByRole(role);
12 | browser.get(url);
13 | element(by.model('login.user.name')).sendKeys(user.name);
14 | element(by.model('login.user.password')).sendKeys(user.password);
15 | element(by.name('login-button')).click();
16 | };
17 | };
18 |
19 | module.exports = new LoginPage();
20 |
--------------------------------------------------------------------------------
/generators/app/templates/e2e/main/main.po.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file uses the Page Object pattern to define the main page for tests
3 | * https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
4 | */
5 |
6 | 'use strict';
7 |
8 | var MainPage = function () {
9 | this.headline = element(by.css('.md-card-content > h2'));
10 | };
11 |
12 | module.exports = new MainPage();
13 |
--------------------------------------------------------------------------------
/generators/app/templates/e2e/main/main.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Main View', function() {
4 | var page;
5 |
6 | beforeEach(function() {
7 | <% if (features.auth) { %>browser.get('/');
8 | <% } else { %>var loginPage = require('../login/login.po');
9 | loginPage.login('/');
10 | <% } %>
11 | page = require('./main.po');
12 | });
13 |
14 | it('should include jumbotron with correct data', function() {
15 | expect(page.headline.getText()).toBe('The awesome <%= appname %> app');
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/generators/app/templates/gulp/tasks/build.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Tasks related to build something or without the app is not usable:
3 | * sass, dist, js annotate, minify, inject ...
4 | */
5 | 'use strict';
6 |
7 | var path = require('path');
8 | var _ = require('lodash');
9 | var gulp = require('gulp');
10 | var gulpif = require('gulp-if');
11 | var inject = require('gulp-inject');
12 | var sass = require('gulp-ruby-sass');
13 | var autoprefixer = require('gulp-autoprefixer');
14 | var minifycss = require('gulp-minify-css');
15 | var concat = require('gulp-concat');
16 | var utils = require('gulp-util');
17 | var angularFilesort = require('gulp-angular-filesort');
18 | var conf = require('../config');
19 |
20 | /**
21 | * inject task
22 | * Auto-inject app and vendor scripts and styles to index html file
23 | */
24 | gulp.task('inject', ['sass'], function () {
25 | var vendorConfig = _.defaults({name: 'vendor'}, conf.options.inject);
26 | return gulp.src(conf.targets.html.path)
27 | .pipe(inject(gulp.src(conf.src.css, {read: false}), conf.options.inject))
28 | .pipe(inject(gulp.src(conf.src.client.js).pipe(angularFilesort()), conf.options.inject))
29 | .pipe(inject(gulp.src(conf.src.client.bower, {read: false}), vendorConfig))
30 | .pipe(gulp.dest(conf.targets.html.dir));
31 | });
32 |
33 | /**
34 | * sass task
35 | * Compile scss files from the project into app/styles/app.css
36 | */
37 | gulp.task('sass', function () {
38 | var css = gulp.src(conf.src.styles)
39 | .pipe(sass(conf.options.sass))
40 | .pipe(autoprefixer(conf.options.autoprefixer))
41 | .pipe(gulpif(process.env.NODE_ENV === 'production', minifycss()))
42 | .on('error', utils.log);
43 |
44 | return css.pipe(concat(conf.targets.css.file))
45 | .pipe(gulp.dest(conf.targets.css.dir))
46 | .on('error', utils.log);
47 | });
48 |
49 | gulp.task('build', ['inject']);
50 |
--------------------------------------------------------------------------------
/generators/app/templates/gulp/tasks/dev.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Tasks related to development:
3 | * watch, ...
4 | */
5 | 'use strict';
6 |
7 | var gulp = require('gulp');
8 | var path = require('path');
9 | var utils = require('gulp-util');
10 | var mocha = require('gulp-mocha');
11 | var browserSync = require('browser-sync');
12 | var reload = browserSync.reload;
13 | var conf = require('../config');
14 |
15 | /**
16 | * browser-sync task task
17 | * Start the browser-sync server
18 | */
19 | // browser-sync task for starting the server.
20 | gulp.task('browser-sync', function() {
21 | browserSync(conf.options.browserSync);
22 | });
23 |
24 | /**
25 | * watch task`
26 | * Watch on javascript files, tests and sass files
27 | */
28 | gulp.task('watch', ['build', 'browser-sync'], function () {
29 | require(path.join(conf.dirs.root, 'bin/server.js'));
30 | gulp.watch(conf.src.js, ['test', reload]);
31 | gulp.watch(conf.src.styles, ['sass', reload]);
32 | gulp.watch(conf.src.html, reload);
33 | gulp.watch(conf.src.css, reload);
34 | });
35 |
--------------------------------------------------------------------------------
/generators/app/templates/gulpfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Usage
3 | * gulp [task] --env development
4 | */
5 | 'use strict';
6 |
7 | var gulp = require('gulp');
8 | var del = require('del');
9 | var minimist = require('minimist');
10 | var requireDir = require('require-dir');
11 | var conf = require('./gulp/config');
12 |
13 | // all known options that can be passed by --option
14 | // and their defaults
15 | var knownOptions = {
16 | string: ['env'],
17 | default: {
18 | env: process.env.NODE_ENV || 'test'
19 | }
20 | };
21 |
22 | // parse optional arguments and set environment variables
23 | var options = minimist(process.argv.slice(2), knownOptions);
24 | process.env.NODE_ENV = options.env;
25 |
26 | // include tasks
27 | requireDir('./gulp/tasks');
28 |
29 | /**
30 | * Default task definitions
31 | */
32 |
33 | /**
34 | * Clean task
35 | * Removes the dist and build directories
36 | */
37 | gulp.task('clean', function () {
38 | return del([conf.dirs.dist, conf.dirs.build]);
39 | });
40 |
41 | /**
42 | * Grouped task definitions
43 | */
44 | gulp.task('default', ['build']);
45 |
--------------------------------------------------------------------------------
/generators/app/templates/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration
2 |
3 | var conf = require('./gulp/config');
4 |
5 | module.exports = function(config) {
6 | config.set({
7 |
8 | basePath: conf.options.karma.basePath,
9 |
10 | // frameworks to use
11 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12 | frameworks: ['mocha'],
13 |
14 | // spec and mock files, test runner and index.html
15 | files: conf.options.karma.files,
16 |
17 | // // list of files to exclude
18 | // exclude: [
19 | // 'app/**/*.spec.js'
20 | // ],
21 |
22 | // preprocess matching files before serving them to the browser
23 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
24 | preprocessors: {
25 | },
26 |
27 |
28 | // test results reporter to use
29 | // possible values: 'dots', 'progress'
30 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter
31 | reporters: ['progress', 'coverage'],
32 |
33 |
34 | // configure the reporter
35 | coverageReporter: {
36 | type : 'html',
37 | dir : 'build/coverage/client'
38 | },
39 |
40 | // web server port
41 | port: 9654,
42 |
43 |
44 | // enable / disable colors in the output (reporters and logs)
45 | colors: true,
46 |
47 |
48 | // level of logging
49 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
50 | logLevel: config.LOG_INFO,
51 |
52 |
53 | // enable / disable watching file and executing tests whenever any file changes
54 | autoWatch: true,
55 |
56 |
57 | // start these browsers
58 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
59 | browsers: ['PhantomJS']
60 |
61 | // Continuous Integration mode
62 | // if true, Karma captures browsers, runs the tests and exits
63 | // ,singleRun: false
64 | });
65 | };
66 |
--------------------------------------------------------------------------------
/generators/app/templates/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration
2 | // https://github.com/angular/protractor/blob/master/referenceConf.js
3 |
4 | 'use strict';
5 |
6 | var conf = require('./gulp/config');
7 |
8 | exports.config = {
9 |
10 | // The timeout for each script run on the browser. This should be longer
11 | // than the maximum time your application needs to stabilize between tasks.
12 | allScriptsTimeout: 110000,
13 |
14 | // A base URL for your application under test. Calls to protractor.get()
15 | // with relative paths will be prepended with this.
16 | baseUrl: 'http://localhost:' + (process.env.PORT || '9001'),
17 |
18 | // list of files / patterns to load in the browser
19 | specs: conf.src.client.bower
20 | .concat(conf.src.client.js)
21 | .concat('e2e/**/*.spec.js'),
22 |
23 | // Patterns to exclude.
24 | exclude: [],
25 |
26 | // ----- Capabilities to be passed to the webdriver instance ----
27 | //
28 | // For a full list of available capabilities, see
29 | // https://code.google.com/p/selenium/wiki/DesiredCapabilities
30 | // and
31 | // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
32 | capabilities: {
33 | 'browserName': 'chrome'
34 | },
35 |
36 | // If true, use direct connect to get the wd
37 | // Tests for browsers other than chrome or firefox will not run.
38 | directConnect: true,
39 |
40 | // ----- The test framework -----
41 | //
42 | // Jasmine and Cucumber are fully supported as a test and assertion framework.
43 | // Mocha has limited beta support. You will need to include your own
44 | // assertion framework if working with mocha.
45 | framework: 'jasmine',
46 |
47 | // ----- Options to be passed to minijasminenode -----
48 | //
49 | // See the full list at https://github.com/juliemr/minijasminenode
50 | jasmineNodeOpts: {
51 | defaultTimeoutInterval: 30000,
52 | isVerbose: true
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/generators/app/templates/server/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../.jshintrc",
3 | "node": true,
4 | "esnext": true,
5 | "bitwise": true,
6 | "eqeqeq": true,
7 | "immed": true,
8 | "latedef": "nofunc",
9 | "newcap": true,
10 | "noarg": true,
11 | "regexp": true,
12 | "undef": true,
13 | "smarttabs": true,
14 | "asi": true,
15 | "debug": true
16 | }
17 |
--------------------------------------------------------------------------------
/generators/app/templates/server/.jshintrc-spec:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ".jshintrc",
3 | "expr": true,
4 | "globals": {
5 | "describe": true,
6 | "it": true,
7 | "before": true,
8 | "beforeEach": true,
9 | "after": true,
10 | "afterEach": true,
11 | "browser": true,
12 | "expect": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/generators/app/templates/server/api/clientModelDoc(demo)/clientModelDoc.controller.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for the controller definition of the clientModelDoc api.
3 | * The ClientModelDocController is handling /api/client-model-docs requests.
4 | * @module {clientModelDoc:controller~ClientModelDocController} clientModelDoc:controller
5 | * @requires {@link ParamController}
6 | */
7 | 'use strict';
8 |
9 | module.exports = ClientModelDocController;
10 |
11 | var ParamController = require('../../lib/controllers/param.controller');
12 |
13 | /**
14 | * The ClientModelDoc model instance
15 | * @type {clientModelDoc:model~ClientModelDoc}
16 | */
17 | var ClientModelDoc = require('./clientModelDoc.model').model;
18 |
19 | /**
20 | * ClientModelDocController constructor
21 | * @classdesc Controller that handles /api/client-model-docs route requests
22 | * for the clientModelDoc api.
23 | * Uses the 'clientModelDocId' parameter and the 'clientModelDocParam' request property
24 | * to operate with the [main clientModelDoc API Model]{@link clientModelDoc:model~ClientModelDoc} model.
25 | * @constructor
26 | * @inherits ParamController
27 | * @see clientModelDoc:model~ClientModelDoc
28 | */
29 | function ClientModelDocController(router) {
30 | ParamController.call(this, ClientModelDoc, router);
31 |
32 | // modify select only properties
33 | // this.select = ['-__v'];
34 |
35 | // omit properties on update
36 | // this.omit = ['hashedPassword'];
37 |
38 | // populate refs on get
39 | this.populations = ['user', 'rootUser', 'anyTypeRef'];
40 |
41 | // property to return (maybe a virtual getter of the model)
42 | // this.defaultReturn = 'profile';
43 | }
44 |
45 | // define properties for the ClientModelDocController here
46 | ClientModelDocController.prototype = {
47 |
48 | /**
49 | * Set our own constructor property for instanceof checks
50 | * @private
51 | */
52 | constructor: ClientModelDocController
53 |
54 | };
55 |
56 | // inherit from ParamController
57 | ClientModelDocController.prototype = Object.create(ParamController.prototype);
58 |
59 |
--------------------------------------------------------------------------------
/generators/app/templates/server/api/clientModelDoc(demo)/clientModelDoc.params.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for initializing the clientModelDoc api request parameters for /api/client-model-docs routes.
3 | * Export the {@link clientModelDoc:Parameters~registerClientModelDocParams}
4 | * function to register the api routes on the passed express router.
5 | * @module {function} clientModelDoc:parameters
6 | * @requires {@link clientModelDoc:model}
7 | */
8 | 'use strict';
9 |
10 | // export the function to register all clientModelDoc request params
11 | module.exports = registerClientModelDocParams;
12 |
13 | /**
14 | * Attach request parameters to the given router.
15 | * @param router {express.Router} - The router to attach the parameters to
16 | */
17 | function registerClientModelDocParams(router) {
18 | // router.param('id', registerParamName);
19 | // add params below
20 | }
21 |
22 | /*
23 | * Register a parameter for /api/client-model-docs requests.
24 | * Add a property to the current request.
25 | * @param {http.IncomingMessage} req - The request message object
26 | * @param {http.ServerResponse} res - The outgoing response object
27 | * @param next {function} - The next handler function to call when done
28 | * @param id {String} - The id parameter parsed from the current request
29 | * @see clientModelDoc:model~ClientModelDoc
30 | * @returns {function} This function sets a status of 400 for malformed MongoDB
31 | * id's and a status of 404 if no document has been found for the passed
32 | * parameter. Calls the passed next function when done.
33 |
34 | function registerParamName(req, res, next, id) {
35 | // attach the document to the request
36 | Model.findById(id, function (err, doc) {
37 | if (err) {
38 | return next(err);
39 | }
40 |
41 | if (!doc) {
42 | res.notFound();
43 | return next('route');
44 | }
45 |
46 | req.paramName = doc;
47 | return next();
48 | });
49 | }
50 | */
51 |
52 | // add param functions below
53 |
--------------------------------------------------------------------------------
/generators/app/templates/server/api/clientModelDoc(demo)/clientModelDoc.socket.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for registering broadcast updates to clients when
3 | * the ClientModelDoc model changes. Exports the
4 | * [register function]{@link clientModelDoc:socket~registerClientModelDocSockets}
5 | * to register the model schema events on the socket instance.
6 | * @module {function} clientModelDoc:socket
7 | * @requires {@link clientModelDoc:model}
8 | */
9 | 'use strict';
10 |
11 | /**
12 | * The ClientModelDoc model instance
13 | * @type {clientModelDoc:model~ClientModelDoc}
14 | */
15 | var ClientModelDoc = require('./clientModelDoc.model').model;
16 |
17 | // export the function to register all socket broadcasts
18 | exports.register = registerClientModelDocSockets;
19 |
20 | /**
21 | * Register ClientModelDoc model change events on the passed socket
22 | * @param {socket.io} socket - The socket object to register the ClientModelDoc model events on
23 | */
24 | function registerClientModelDocSockets(socket) {
25 | ClientModelDoc.schema.post('save', function (doc) {
26 | onSave(socket, doc);
27 | });
28 |
29 | ClientModelDoc.schema.post('remove', function (doc) {
30 | onRemove(socket, doc);
31 | });
32 | }
33 |
34 | /**
35 | * Emit a ClientModelDoc save event on a socket object: 'clientModelDoc:save'
36 | * @param {socket.io} socket - The socket object to emit the ClientModelDoc save event on
37 | * @param {MogooseDocument} doc - The saved document that triggered the event
38 | * @param {function} cb - The callback function
39 | */
40 | function onSave(socket, doc, cb) {
41 | socket.emit('clientModelDoc:save', doc);
42 | }
43 |
44 | /**
45 | * Emit a ClientModelDoc remove event on a socket object: 'clientModelDoc:remove'
46 | * @param {socket.io} socket - The socket object to emit the ClientModelDoc remove event on
47 | * @param {MogooseDocument} doc - The removed document that triggered the event
48 | * @param {function} cb - The callback function
49 | */
50 | function onRemove(socket, doc, cb) {
51 | socket.emit('clientModelDoc:remove', doc);
52 | }
53 |
--------------------------------------------------------------------------------
/generators/app/templates/server/api/user(auth)/user.socket(socketio).js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for registering broadcast updates to clients when
3 | * the User model changes. Exports the Exports the
4 | * [register function]{@link user:socket~registerUserSockets}
5 | * to register the model schema events on the socket instance.
6 | * @module {function} user:socket
7 | * @requires {@link user:model~User}
8 | */
9 | 'use strict';
10 |
11 | /**
12 | * The User model instance
13 | * @type {user:model~User}
14 | */
15 | var User = require('./user.model').model;
16 |
17 | // export the function to register all socket broadcasts
18 | exports.register = registerUserSockets;
19 |
20 | /**
21 | * Register User model change events on the passed socket
22 | * @param {socket.io} socket - The socket object to register the User model events on
23 | */
24 | function registerUserSockets(socket) {
25 | User.schema.post('save', function (doc) {
26 | onSave(socket, doc);
27 | });
28 |
29 | User.schema.post('remove', function (doc) {
30 | onRemove(socket, doc);
31 | });
32 | }
33 |
34 | /**
35 | * Emit a User save event on a socket object: 'user:save'
36 | * @param {socket.io} socket - The socket object to emit the User save event on
37 | * @param {MogooseDocument} doc - The saved document that triggered the event
38 | * @param {function} cb - The callback function
39 | */
40 | function onSave(socket, doc, cb) {
41 | socket.emit('user:save', doc);
42 | }
43 |
44 | /**
45 | * Emit a User remove event on a socket object: 'user:remove'
46 | * @param {socket.io} socket - The socket object to emit the User remove event on
47 | * @param {MogooseDocument} doc - The removed document that triggered the event
48 | * @param {function} cb - The callback function
49 | */
50 | function onRemove(socket, doc, cb) {
51 | socket.emit('user:remove', doc);
52 | }
53 |
--------------------------------------------------------------------------------
/generators/app/templates/server/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Main application file
3 | */
4 | 'use strict';
5 |
6 | // Set default node environment to development
7 | process.env.NODE_ENV = process.env.NODE_ENV || 'development';
8 |
9 | var express = require('express');
10 | var socketio = require('socket.io');
11 | var config = require('./config/index');
12 | var socketConfig = require('./config/socketio');
13 | var db = require('./config/mongoose');
14 | var app = express();
15 |
16 | // Expose app
17 | exports = module.exports = app;
18 |
19 | // expose the function to start the server instance
20 | app.startServer = startServer;
21 | app.serverShutdown = serverShutdown;
22 |
23 | // Setup Express
24 | require('./config/express')(app);
25 |
26 | // Setup Routes
27 | require('./routes')(app);
28 |
29 | // register the shutdown handler to close the database connection on interrupt signals
30 | process
31 | .on('SIGINT', serverShutdown)
32 | .on('SIGTERM', serverShutdown);
33 |
34 | /**
35 | * Create an express http server and return it
36 | * Config the socketio service to use this server
37 | * @api private
38 | * @return {}
39 | */
40 | function startServer() {
41 | var server = require('http').createServer(app);
42 | var socket = socketio(server, {
43 | serveClient: true,
44 | path: '/socket.io-client'
45 | });
46 | // Setup SocketIO
47 | socketConfig(socket);
48 | return server;
49 | }
50 |
51 | /**
52 | * Shutdown handler
53 | * Closes the database connection on iterrupt and exits the process
54 | * @api private
55 | */
56 | function serverShutdown() {
57 | db.connection.close(function connectionClose() {
58 | console.log('Database connection disconnected through app termination');
59 | process.exit(0);
60 | });
61 | }
62 |
--------------------------------------------------------------------------------
/generators/app/templates/server/app.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /* jshint unused:false */
3 |
4 | var mongoose = require('mongoose');
5 | var should = require('should');
6 | var app = require('./app');
7 | var request = require('supertest');
8 |
9 | describe('App', function () {
10 |
11 | it('should expose a function to start the server', function (done) {
12 | app.startServer.should.be.a.Function;
13 | (app.startServer()).should.be.an.Object;
14 | request(app)
15 | .get('/')
16 | .expect(200)
17 | .expect('Content-Type', /html/)
18 | .end(done);
19 | });
20 |
21 | it('should initiate a mongodb connection via mongoose', function () {
22 | var connection = mongoose.connections[0];
23 | connection.should.be.instanceof(mongoose.Connection);
24 | });
25 |
26 | it('should return the index file for any not api route', function (done) {
27 | request(app)
28 | .get('/this/route/will/never/exist')
29 | .expect(200)
30 | .expect('Content-Type', /html/)
31 | .end(done);
32 | });
33 |
34 | it('should return with status 404 for an uncovered api route.', function (done) {
35 | request(app)
36 | .get('/api/this/route/will/never/exist')
37 | .expect(404)
38 | .end(done);
39 | });
40 |
41 | it('should expose a function to down the server', function () {
42 | app.serverShutdown.should.be.a.Function;
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/env/development.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | process.env.DATABASE_NAME = process.env.DATABASE_NAME || '<%= appname %>-dev';
4 |
5 | module.exports = {
6 |
7 | mongo: {
8 | uri: 'mongodb://localhost/' + process.env.DATABASE_NAME
9 | },
10 |
11 | seedDB: true
12 | };
13 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/env/production.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | process.env.DATABASE_NAME = process.env.DATABASE_NAME || '<%= appname %>';
4 | process.env.MONGO_URI = process.env.MONGO_URI ||
5 | ('mongodb://localhost/' + process.env.DATABASE_NAME);
6 |
7 | module.exports = {
8 |
9 | ip: process.env.ip || undefined,
10 |
11 | port: process.env.PORT || 8080,
12 |
13 | publicDir: 'client',
14 |
15 | mongo: {
16 | uri: process.env.MONGO_URI,
17 | options: process.env.MONGO_OPTIONS && JSON.parse(process.env.MONGO_OPTIONS)
18 | },
19 |
20 | seedDB: true
21 | };
22 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/env/test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | process.env.DATABASE_NAME = process.env.DATABASE_NAME || '<%= appname %>-test';
4 |
5 | module.exports = {
6 |
7 | mongo: {
8 | uri: 'mongodb://localhost/' + process.env.DATABASE_NAME
9 | },
10 |
11 | seedDB: true
12 | };
13 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/express.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This module loads and initializes the express configuration
3 | * depending on the 'NODE_ENV' environment variable.
4 | * @module {function} config:express
5 | * @requires {@link config}
6 | */
7 | 'use strict';
8 |
9 | var express = require('express');
10 | var path = require('path');
11 | var morgan = require('morgan');
12 | var compression = require('compression');
13 | var bodyParser = require('body-parser');
14 | var cookieParser = require('cookie-parser');
15 | var methodOverride = require('method-override');
16 | var favicon = require('serve-favicon');
17 | var errorHandler = require('errorhandler');
18 | var passport = require('passport');
19 | var config = require('./index');
20 |
21 | // export the express configuration function
22 | module.exports = initExpress;
23 |
24 | /**
25 | * Configure the express application by adding middleware and setting application
26 | * variables.
27 | * @param {express.app} app - The express application instance to configure
28 | */
29 | function initExpress(app) {
30 | var env = app.get('env');
31 | var publicDir = path.join(config.root, config.publicDir);
32 |
33 | app.set('ip', config.ip);
34 | app.set('port', config.port);
35 |
36 | app.set('views', config.root + '/server/views');
37 | app.engine('html', require('ejs').renderFile);
38 | app.set('view engine', 'html');
39 |
40 | app.use(compression());
41 | app.use(bodyParser.urlencoded({ extended: false }));
42 | app.use(bodyParser.json());
43 | app.use(methodOverride());
44 | app.use(cookieParser());
45 | app.use(passport.initialize());
46 | app.use(favicon(path.join(publicDir, 'favicon.ico')));
47 |
48 | if ('production' === env) {
49 | app.use(express.static(publicDir));
50 | app.set('appPath', publicDir);
51 | app.use(morgan('tiny'));
52 | }
53 |
54 | if ('development' === env || 'test' === env) {
55 | app.use(express.static(path.join(config.root, '.tmp')));
56 | app.use(express.static(publicDir));
57 | app.set('appPath', publicDir);
58 | app.use(morgan('dev'));
59 | // Error handler - has to be last
60 | app.use(errorHandler());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This module loads the application configuration depending on the
3 | * 'NODE_ENV' environment variable.
4 | * @module {Object} config
5 | * @property {String} env - The environment used in the application
6 | * @property {String} root - The application root path
7 | * @property {String} publicDir - The path to public sources
8 | * @property {String} ip - IP address used to bind the application server
9 | * @property {String} port - The port used to bind the application server
10 | * @property {Object} secrets - Holding the session secret used to sign the user session
11 | * @property {Array} userRoles - Array of available user role names
12 | * @property {Object} mongo - Configuration that is passed to mongoose to establish a connection
13 | */
14 | 'use strict';
15 |
16 | var _ = require('lodash');
17 | var path = require('path');
18 |
19 | /**
20 | * Load environment configuration
21 | */
22 |
23 | var common = {
24 | env: process.env.NODE_ENV,
25 |
26 | root: path.normalize(__dirname + '/../..'),
27 |
28 | publicDir: 'client',
29 |
30 | ip: '0.0.0.0',
31 |
32 | port: process.env.PORT || 9001,
33 |
34 | // Secret for session, you will want to change this and make it an environment variable
35 | secrets: {
36 | session: process.env.SESSION_SECRET || 'my-<%= appname %>-secret'
37 | },
38 |
39 | // List of user roles
40 | userRoles: ['user', 'admin', 'root'],
41 |
42 | // options passed to create mongo connections
43 | mongo: {
44 | options: {
45 | db: {
46 | safe: true
47 | },
48 | server: {
49 | socketOptions: {
50 | keepAlive: 1,
51 | connectTimeoutMS: 10000
52 | }
53 | },
54 | replset: {
55 | socketOptions: {
56 | keepAlive: 1,
57 | connectTimeoutMS: 10000
58 | }
59 | }
60 | }
61 | }
62 | };
63 |
64 | module.exports = _.merge(
65 | common,
66 | require('./env/' + (process.env.NODE_ENV || 'development') + '.js') || {});
67 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/mongoose.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Connect to the database and add connection handlers
3 | * @module {MongooseConnection} config:mongoose
4 | * @requires {@link config}
5 | */
6 | 'use strict';
7 |
8 | var mongoose = require('mongoose');
9 | var config = require('./index');
10 | var seed = require('./seed');
11 | var env = process.env.NODE_ENV || 'development';
12 |
13 | // connect to mongodb
14 | var connection = mongoose.connect(config.mongo.uri, config.mongo.options);
15 |
16 | /**
17 | * The initialized Mongoose connection object
18 | * @type {MongooseConnection}
19 | */
20 | module.exports = connection;
21 |
22 | // reconnect if connection is disconnected or disconnecting
23 | // throw any errors that occur while reconnecting
24 | if (connection.state === 0 || connection.state === 3) {
25 | connection.open(function connectionReconnect(err) {
26 | if (err) {
27 | console.error('Error while reinitializing the database connection: %s', err);
28 | throw err; // throw error to stop application launch
29 | }
30 | console.log('Database Connection reopened');
31 | });
32 | }
33 |
34 | // register global database error handler
35 | mongoose.connection.on('error', function connectionError(err) {
36 | console.error('Database Error: ', err);
37 | });
38 |
39 | // register the connection handler once only
40 | mongoose.connection.once('open', function connectionOpen() {
41 | console.log('Database connection open');
42 | // Populate DB with sample data
43 | if (config.seedDB) {
44 | // module.parent === null means current command runs this script directly
45 | // Represents 'npm run seed'
46 | if (env !== 'production' || module.parent === null) {
47 | seed(env, done);
48 | }
49 |
50 | function done(err) {
51 | if (err) {
52 | console.log('There was an error while populating seed data');
53 | } else {
54 | console.log('All seed data populated successfully');
55 | }
56 |
57 | if (module.parent === null) {
58 | // this script has been called by cli, exit after population
59 | process.exit(err ? 1 : 0);
60 | }
61 | }
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/generators/app/templates/server/config/testUsers(auth).js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by stupid on 16-6-8.
3 | */
4 | var users = [{
5 | provider: 'local',
6 | role: 'user',
7 | name: 'Test User',
8 | password: 'password',
9 | active: true
10 | }, {
11 | provider: 'local',
12 | role: 'admin',
13 | name: 'Admin',
14 | password: 'password',
15 | active: true
16 | }, {
17 | provider: 'local',
18 | role: 'root',
19 | name: 'Root',
20 | password: 'password',
21 | active: true
22 | }];
23 |
24 | users.getUserByRole = function(role) {
25 | var i;
26 | for (i = 0; i < users.length; i++) {
27 | if (users[i].role === role) break;
28 | }
29 | return users[i];
30 | };
31 |
32 | module.exports = users;
33 |
--------------------------------------------------------------------------------
/generators/app/templates/server/lib/auth(auth)/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for registering authentication middleware.
3 | * Registers the local authentication provider by default.
4 | * @module {express.Router} auth
5 | * @requires {@link user:model}
6 | * @requires {@link auth:local}
7 | * @requires {@link auth:local:passport}
8 | */
9 | 'use strict';
10 |
11 | var router = require('express').Router();
12 | var config = require('../../config/');
13 |
14 | /**
15 | * The authentication model: User
16 | * @type {user:model~User}
17 | */
18 | var User = require('../../api/user/user.model').model;
19 |
20 | // export the configures express router
21 | module.exports = router;
22 |
23 | // Passport Configuration
24 | require('./local/passport').setup(User, config);
25 |
26 | // apply authentication routes for the providers
27 | router.use('/local', require('./local/index'));
28 |
29 |
--------------------------------------------------------------------------------
/generators/app/templates/server/lib/auth(auth)/local/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for registering local authentication middleware.
3 | * Configures the Passport service to use the local authentication
4 | * mechanism.
5 | * @module {express.Router} auth:local
6 | * @requires {@link auth:service}
7 | */
8 | 'use strict';
9 |
10 | var _ = require('lodash');
11 | var router = require('express').Router();
12 | var passport = require('passport');
13 | var auth = require('../auth.service.js');
14 |
15 | // export the configured express router
16 | module.exports = router;
17 |
18 | // register auth routes
19 | router.post('/', authenticate);
20 |
21 | /**
22 | * Authenticate a request and sign a token.
23 | * @param {http.IncomingMessage} req - The request message object
24 | * @param {http.ServerResponse} res - The outgoing response object
25 | * @param {function} next - The next handler callback
26 | * @return {http.ServerResponse} The result of calling the
27 | * [callback function]{@link auth:local~authCallback}
28 | */
29 | function authenticate(req, res, next) {
30 | var callback = _.bind(authCallback, {req: req, res: res});
31 | passport.authenticate('local', callback)(req, res, next)
32 | }
33 |
34 | /**
35 | * Authentication callback function. Called from passport.authenticate in
36 | * {@link auth:local~authenticate}. The request and response objects are available
37 | * as this.req and this.res.
38 | * @param {Error|String} err - The error that occurred while authenticating the user
39 | * @param {user:model~User} user - The user object to authenticate
40 | * @param {Error|Object} info - Additional information, treated as error
41 | * @return {http.ServerResponse} A response object with the signed token
42 | * as the 'token' property.
43 | */
44 | function authCallback(err, user, info) {
45 | // jshint validthis: true
46 | var error = err || info;
47 | if (error) {
48 | return this.res.unauthorized(error);
49 | }
50 |
51 | if (!user) {
52 | return this.res.notFound('Error, please try again.');
53 | }
54 |
55 | var token = auth.signToken(user._id, user.role);
56 | this.res.ok({token: token});
57 | }
58 |
--------------------------------------------------------------------------------
/generators/app/templates/server/lib/auth(auth)/roles.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module for defining methods for handling acl roles.
3 | * @module {Object} auth:roles
4 | * @requires {@link config}
5 | */
6 | 'use strict';
7 |
8 | var config = require('../../config/');
9 |
10 | /**
11 | * The array of user roles
12 | * @type {Array}
13 | */
14 | var roles = config.userRoles;
15 |
16 | // export the user role utility methods
17 | module.exports = {
18 | /**
19 | * Return the name of the highest role
20 | * @type {function}
21 | * @see auth:roles~getMaxRole
22 | */
23 | getMaxRole: getMaxRole,
24 |
25 | /**
26 | * Check role access
27 | * @type {function}
28 | * @see auth:roles~hasRole
29 | */
30 | hasRole: hasRole,
31 |
32 | /**
33 | * Check root access
34 | * @type {function}
35 | * @see auth:roles~isRoot
36 | */
37 | isRoot: isRoot
38 | };
39 |
40 |
41 | /**
42 | * Return the name of the highest role in the user role array.
43 | * @returns {String} The name of the role which is the last element in the user role array.
44 | */
45 | function getMaxRole() {
46 | return roles[roles.length - 1];
47 | }
48 |
49 | /**
50 | * Check if a user has at least the same role as the given one
51 | * @param {String} role - The role of the user who requests access
52 | * @param {String} checkRole - The role to check for
53 | */
54 | function hasRole(role, checkRole) {
55 | return roles.indexOf(role) >= roles.indexOf(checkRole);
56 | }
57 |
58 | /**
59 | * Check if a role is the maximum available role.
60 | * Result equals hasRole(role, getMaxRole()).
61 | * @param {String} role - The role of the user who claims to be root
62 | */
63 | function isRoot(role) {
64 | return roles.indexOf(role) === roles.length - 1;
65 | }
66 |
--------------------------------------------------------------------------------
/generators/app/templates/server/lib/controllers/base.controller.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var _ = require('lodash');
4 |
5 | exports = module.exports = BaseController;
6 |
7 | /**
8 | * Mother of all controller constructors
9 | * @classdesc This class can serves as a base class for other classes
10 | * in this application. It does bind all methods to its instance to
11 | * make sure they work in the right context.
12 | * @constructor
13 | */
14 | function BaseController() {
15 | _.bindAll(this);
16 | }
17 |
--------------------------------------------------------------------------------
/generators/app/templates/server/lib/responses/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Extend responses with the following methods:
3 | * 200, 201, 204, 400, 401, 403, 404, 422, 500, 501, sendData, ok, created,
4 | * noContent, badRequest, unauthorized, forbidden, notFound, unprocessableEntity,
5 | * handleError, notImplemented, serverError
6 | * @module {Object} responses
7 | * @requires {@link responses:ok}
8 | * @requires {@link responses:errors}
9 | */
10 | 'use strict';
11 |
12 | var _ = require('lodash');
13 | var ok = require('./ok');
14 | var errors = require('./errors');
15 |
16 | // export all available reponse methods
17 | module.exports = _.assign({sendData: sendData}, ok, errors);
18 |
19 | /**
20 | * Default response output handler
21 | * @param {mixed} data - The data that should be send to the client
22 | * @param {Object|String} options - Response configuration object or view template name
23 | * @return A Response with the given status set, a rendered view if a view template has
24 | * been provided in the options paramter.
25 | */
26 | function sendData(data, options) {
27 | // jshint validthis: true
28 | var req = this.req;
29 | var res = this.res;
30 |
31 | // headers already sent, nothing to do here
32 | if (res.headersSent) {
33 | return;
34 | }
35 |
36 | // If appropriate, serve data as JSON
37 | if (req.xhr || req.accepts('application/json')) {
38 | return res.json(data);
39 | }
40 |
41 | // if a template string is given as the options param
42 | // use it to render a view
43 | var viewFilePath = (typeof options === 'string') ? options : options.view;
44 |
45 | // try to render the given template, fall back to json
46 | // if an error occurs while rendering the view file
47 | if (viewFilePath && req.accepts('html')) {
48 | res.render(viewFilePath, data, function (err, result) {
49 | if (err) {
50 | return res.json(data);
51 | }
52 | return res.send(result);
53 | });
54 | }
55 |
56 | return res.json(data);
57 | }
58 |
--------------------------------------------------------------------------------
/generators/app/templates/server/routes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Main application routes
3 | * All responses are routed through the middleware.extendResponse middleware.
4 | * POST, PUT, PATCH and DELETE requests are
5 | * routed through the middleware.removeReservedSchemaKeywords middleware.
6 | */
7 |
8 | 'use strict';
9 |
10 | var path = require('path');
11 | var middleware = require('./lib/middleware');
12 |
13 | module.exports = function (app) {
14 |
15 | // extend response with custom methods
16 | app.use(middleware.extendResponse);
17 |
18 | // default CUD middleware
19 | app
20 | .put(middleware.removeReservedSchemaKeywords)
21 | .patch(middleware.removeReservedSchemaKeywords)
22 | .delete(middleware.removeReservedSchemaKeywords)
23 | .post(middleware.removeReservedSchemaKeywords);
24 |
25 | // Insert routes below<%if (features.auth) { %>
26 | app.use('/api/users', require('./api/user'));
27 | app.use('/auth', require('./lib/auth'));<%}%><%if (features.demo) { %>
28 | app.use('/api/clientModelDocs', require('./api/clientModelDoc'));<%}%>
29 |
30 | // All undefined asset or api routes should return a 404
31 | app.route('/:url(api|auth|components|app|bower_components|assets)/*')
32 | .get(function invalidRoute(req, res) { return res.notFound(); });
33 |
34 | // All other routes should redirect to the index.html
35 | app.route('/*')
36 | .get(function getIndexFile(req, res) {
37 | res.sendFile(path.resolve(app.get('appPath') + '/index.html'));
38 | });
39 |
40 | // register the default error handler
41 | app.use(middleware.defaultErrorHandler);
42 | };
43 |
--------------------------------------------------------------------------------
/generators/app/templates/server/views/!500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Error
9 | <%= data %>
10 |
11 |
12 |
--------------------------------------------------------------------------------
/generators/base.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var util = require('util');
4 | var path = require('path');
5 | var yeoman = require('yeoman-generator');
6 | var angularUtils = require('./util.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | yeoman.generators.NamedBase.apply(this, arguments);
10 |
11 | try {
12 | this.appname = require(path.join(process.cwd(), 'bower.json')).name;
13 | } catch (e) {
14 | this.appname = path.basename(process.cwd());
15 | }
16 | this.appname = this._.slugify(this._.humanize(this.appname));
17 | this.scriptAppName = this._.camelize(this.appname) + angularUtils.appName(this);
18 |
19 | this.classedName = this._.classify(this.name);
20 | this.modelName = this.classedName;
21 | this.cameledName = this.classedName[0].toLowerCase() + this.classedName.substr(1);
22 | this.moduleName = this.name;
23 | this.dashedName = this.name.replace(/\./g, '-');
24 |
25 | this.features = this.config.get('features');
26 | this.angularModules = this.config.get('angularModules');
27 | this.sourceRoot(path.join(__dirname, '/templates'));
28 |
29 | this.hasFilter = function (filter) {
30 | return this.config.get('features')[filter];
31 | }.bind(this);
32 |
33 | if (typeof this.env.options.appPath === 'undefined') {
34 | try {
35 | this.env.options.appPath = require(path.join(process.cwd(), 'bower.json')).appPath;
36 | } catch (e) {
37 | }
38 | this.env.options.appPath = this.env.options.appPath || 'app';
39 | }
40 |
41 | this.sourceRoot(path.join(__dirname, '/templates'));
42 | };
43 |
44 | util.inherits(Generator, yeoman.generators.NamedBase);
45 |
--------------------------------------------------------------------------------
/generators/controller/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this controller?',
21 | default: self.config.get('routeDirectory')
22 | }
23 | ];
24 |
25 | this.prompt(prompts, function (props) {
26 | this.dir = path.join(props.dir, this.name);
27 | done();
28 | }.bind(this));
29 | };
30 |
31 | Generator.prototype.createFiles = function createFiles() {
32 | ngUtil.copyTemplates(this, 'controller');
33 | };
34 |
--------------------------------------------------------------------------------
/generators/decorator/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this decorator?',
21 | default: self.config.get('serviceDirectory')
22 | },
23 | {
24 | name: 'serviceToDecorate',
25 | message: 'What is the name of the service you would you like to decorate?'
26 | }
27 | ];
28 |
29 | this.prompt(prompts, function (props) {
30 | this.dir = path.join(props.dir, this.name);
31 | this.serviceToDecorate = props.serviceToDecorate;
32 | done();
33 | }.bind(this));
34 | };
35 |
36 | Generator.prototype.createFiles = function createFiles() {
37 | ngUtil.copyTemplates(this, 'decorator');
38 | };
39 |
--------------------------------------------------------------------------------
/generators/directive/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 |
18 | var prompts = [
19 | {
20 | name: 'dir',
21 | message: 'Where would you like to create this directive?',
22 | default: self.config.get('directiveDirectory')
23 | },
24 | {
25 | type: 'confirm',
26 | name: 'complex',
27 | message: 'Does this directive need an external html file?',
28 | default: true
29 | }
30 | ];
31 |
32 | this.prompt(prompts, function (props) {
33 | this.dir = path.join(props.dir, this.name);
34 | this.complex = props.complex;
35 | done();
36 | }.bind(this));
37 | };
38 |
39 | Generator.prototype.createFiles = function createFiles() {
40 | var configName = 'directiveSimpleTemplates';
41 | var templateDir = path.join(this.sourceRoot(), 'directiveSimple');
42 | if (this.complex) {
43 | configName = 'directiveComplexTemplates';
44 | templateDir = path.join(this.sourceRoot(), 'directiveComplex');
45 | }
46 |
47 | var basePath = this.config.get('basePath') || '';
48 | this.htmlUrl = ngUtil.relativeUrl(basePath, path.join(this.dir, this.name + '.html'));
49 | ngUtil.copyTemplates(this, 'directive', templateDir, configName);
50 | };
51 |
--------------------------------------------------------------------------------
/generators/factory/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this factory?',
21 | default: self.config.get('serviceDirectory')
22 | }
23 | ];
24 |
25 | this.prompt(prompts, function (props) {
26 | this.dir = path.join(props.dir, this.name);
27 | done();
28 | }.bind(this));
29 | };
30 |
31 | Generator.prototype.createFiles = function createFiles() {
32 | ngUtil.copyTemplates(this, 'factory');
33 | };
34 |
--------------------------------------------------------------------------------
/generators/filter/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this filter?',
21 | default: self.config.get('filterDirectory')
22 | }
23 | ];
24 |
25 | this.prompt(prompts, function (props) {
26 | this.dir = path.join(props.dir, this.name);
27 | done();
28 | }.bind(this));
29 | };
30 |
31 | Generator.prototype.createFiles = function createFiles() {
32 | ngUtil.copyTemplates(this, 'filter');
33 | };
34 |
--------------------------------------------------------------------------------
/generators/provider/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this provider?',
21 | default: self.config.get('serviceDirectory')
22 | }
23 | ];
24 |
25 | this.prompt(prompts, function (props) {
26 | this.dir = path.join(props.dir, this.name);
27 | done();
28 | }.bind(this));
29 | };
30 |
31 | Generator.prototype.createFiles = function createFiles() {
32 | ngUtil.copyTemplates(this, 'provider');
33 | };
34 |
--------------------------------------------------------------------------------
/generators/resource/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var name = this.name;
17 |
18 | var done = this.async();
19 | var prompts = [
20 | {
21 | name: 'dir',
22 | message: 'Where would you like to create this resource?',
23 | default: self.config.get('componentsDirectory')
24 | },
25 | {
26 | name: 'apiUrl',
27 | message: 'What shall the API url of your resource be?',
28 | default: '/api/' + name + (self.config.get('pluralizeRoutes') ? 's' : '')
29 | },
30 | {
31 | type: 'confirm',
32 | name: 'useOriginalResource',
33 | message: 'Shall I use the original AngularJS resource?',
34 | default: false
35 | },
36 | ];
37 |
38 | this.prompt(prompts, function (props) {
39 | this.dir = props.dir;
40 | this.apiURL = props.apiUrl;
41 | this.features.useOriginalResource = props.useOriginalResource;
42 | done();
43 | }.bind(this));
44 | };
45 |
46 | Generator.prototype.createFiles = function createFiles() {
47 | ngUtil.copyTemplates(this, 'resource');
48 | };
49 |
--------------------------------------------------------------------------------
/generators/service/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var path = require('path');
3 | var yeoman = require('yeoman-generator');
4 | var util = require('util');
5 | var ngUtil = require('../util');
6 | var BaseGenerator = require('../base.js');
7 |
8 | var Generator = module.exports = function Generator() {
9 | BaseGenerator.apply(this, arguments);
10 | };
11 |
12 | util.inherits(Generator, BaseGenerator);
13 |
14 | Generator.prototype.askFor = function askFor() {
15 | var self = this;
16 | var done = this.async();
17 | var prompts = [
18 | {
19 | name: 'dir',
20 | message: 'Where would you like to create this service?',
21 | default: self.config.get('serviceDirectory')
22 | }
23 | ];
24 |
25 | this.prompt(prompts, function (props) {
26 | this.dir = path.join(props.dir, this.name);
27 | done();
28 | }.bind(this));
29 | };
30 |
31 | Generator.prototype.createFiles = function createFiles() {
32 | ngUtil.copyTemplates(this, 'service');
33 | };
34 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/create/create.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>CreateController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>.create'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>CreateController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/create/create.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 | Create a new <%= cameledName %> for your application.
13 |
14 |
15 |
16 |
34 |
35 |
36 |
37 |
38 | Cancel
39 | Create <%= cameledName %>
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/create/create.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-create-dialog {
2 | min-width: 450px;
3 | }
4 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/detail/detail.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the edit controller as <%= classedName %>DetailController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.<%= moduleName %>.list.detail')
10 | .controller('<%= classedName %>DetailController', <%= classedName %>DetailController);
11 |
12 | // add <%= classedName %>DetailController dependencies to inject
13 | <%= classedName %>DetailController.$inject = ['$state', '<%= cameledName %>'];
14 |
15 | /**
16 | * <%= classedName %>DetailController constructor
17 | */
18 | function <%= classedName %>DetailController($state, <%= cameledName %>) {
19 | var vm = this;
20 |
21 | // the current <%= cameledName %> to display
22 | vm.<%= cameledName %> = <%= cameledName %>;
23 | // switch to the edit state
24 | vm.edit = edit;
25 | // switch to the parent state
26 | vm.goBack = goBack
27 |
28 | /**
29 | * Open the edit state with the current <%= cameledName %>
30 | *
31 | */
32 | function edit() {
33 | $state.go('^.edit', {'id': vm.<%= cameledName %>._id});
34 | }
35 |
36 | /**
37 | * Return to the parent state
38 | *
39 | */
40 | function goBack() {
41 | $state.go('^');
42 | }
43 | }
44 | })();
45 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/detail/detail.controller.spec.js:
--------------------------------------------------------------------------------
1 | /*jshint -W030 */
2 | 'use strict';
3 |
4 | describe('Controller: <%= classedName %>DetailController', function () {
5 |
6 | // load the controller's module
7 | beforeEach(module('<%= scriptAppName %>.list.detail'));
8 |
9 | var controller;
10 | var <%= cameledName %>;
11 | var stateSpy;
12 |
13 | // Setup some states to test the navigation functions
14 | beforeEach(inject(function ($state) {
15 | stateSpy = sinon.stub($state, 'go');
16 | <%= cameledName %> = {_id: '1337id', name: 'admin', active: true};
17 | }));
18 |
19 | // Initialize the controller and a mock scope
20 | beforeEach(inject(function ($controller) {
21 | controller = $controller('<%= classedName %>DetailController', {
22 | user: user
23 | });
24 | }));
25 |
26 | it('should exist as an object', function () {
27 | Should.exist(controller);
28 | controller.should.be.an.Object;
29 | });
30 |
31 | it('should have a method to navigate to the parent state', function () {
32 | Should.exist(controller.goBack);
33 | controller.goBack.should.be.a.Function;
34 | controller.goBack();
35 | stateSpy.calledOnce.should.be.ok;
36 | stateSpy.withArgs('^').called.should.be.ok;
37 | });
38 |
39 | it('should have a method to navigate to the edit state which is passing the correct id parameter', function () {
40 | Should.exist(controller.edit);
41 | controller.edit.should.be.a.Function;
42 | controller.edit();
43 | stateSpy.calledOnce.should.be.ok;
44 | stateSpy.withArgs('^.edit', {'id': user._id}).called.should.be.ok;
45 | });
46 | });
47 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/detail/detail.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-detail-content {
2 | .detail-info {
3 | md-checkbox[ng-disabled] {
4 | margin: 0;
5 | }
6 | }
7 |
8 | md-switch.no-label .md-label,
9 | md-checkbox[ng-disabled].no-label .md-label {
10 | display: none;
11 | }
12 | }
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/edit/edit.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>EditController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>.edit'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>EditController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/edit/edit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | {{edit.displayName}}
14 |
15 |
16 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/edit/edit.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-edit-content {}
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/items/items.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as <%= classedName %>ItemsController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.<%= moduleName %>.list.items')
10 | .controller('<%= classedName %>ItemsController', <%= classedName %>ItemsController);
11 |
12 | // add <%= classedName %>ItemsController dependencies to inject
13 | <%= classedName %>ItemsController.$inject = ['$state'];
14 |
15 | /**
16 | * <%= classedName %>ItemsController constructor
17 | */
18 | function <%= classedName %>ItemsController($state) {
19 | var vm = this;
20 |
21 | // the selected item id
22 | var cur<%= classedName %>Id = null;
23 |
24 | // check if this item is selected
25 | vm.isSelected = isSelected;
26 | // switch to the detail state
27 | vm.showInDetails = showInDetails;
28 |
29 | /**
30 | * Check if the passed item is the current selected item
31 | *
32 | * @param {Object} <%= cameledName %> - The object to check for selection
33 | */
34 | function isSelected(<%= cameledName %>) {
35 | return cur<%= classedName %>Id === <%= cameledName %>._id;
36 | }
37 |
38 | /**
39 | * Open the detail state with the selected item
40 | *
41 | * @param {Object} <%= cameledName %> - The <%= cameledName %> to edit
42 | */
43 | function showInDetails(<%= cameledName %>) {
44 | cur<%= classedName %>Id = <%= cameledName %>._id;
45 | $state.go('<%= moduleName %>.list.detail', {'id': cur<%= classedName %>Id});
46 | }
47 | }
48 |
49 | })();
50 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/items/items.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>ItemsController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>.items'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>ItemsController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/items/items.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.<%= moduleName %>.list.items module
6 | * @requires ui.router
7 | */
8 |
9 | angular
10 | .module('<%= scriptAppName %>.<%= moduleName %>.list.items', ['ui.router']);
11 |
12 | })();
13 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/items/items.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-list-content {
2 | #<%= dashedName %>-items-content {
3 | md-item {
4 |
5 | &.selected {
6 | background: rgba(0, 188, 212, 0.1);
7 | }
8 |
9 | &.list-head {
10 | color: #999;
11 |
12 | md-item-content {
13 | padding-left: 64px;
14 |
15 | * {
16 | font-weight: bold;
17 | }
18 | }
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/list.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as <%= classedName %>ListController
6 | */
7 | angular
8 | .module('<%= scriptAppName %>.<%= moduleName %>.list')
9 | .controller('<%= classedName %>ListController', <%= classedName %>ListController);
10 |
11 | // add <%= classedName %>ListController dependencies to inject
12 | <%= classedName %>ListController.$inject = [<% if(features.socketio) { %>'$scope', 'socket', <% } %>'$state', '<%= cameledName %>s', 'ToggleComponent'];
13 |
14 | /**
15 | * <%= classedName %>ListController constructor
16 | *<% if(features.socketio) { %>
17 | * @param {Object} $scope - The current scope
18 | * @param {Object} socket - The socket service to register to<% }%>
19 | * @param {$state} $state - The $state to activate routing states on
20 | * @param {Array} <%= cameledName %>s - The list of <%= cameledName %>s resolved for this route
21 | * @param {Service} ToggleComponent - The service for switching the detail view
22 | */
23 | function <%= classedName %>ListController(<% if(features.socketio) { %>$scope, socket, <% }%>$state, <%= cameledName %>s, ToggleComponent) {
24 | var vm = this;
25 |
26 | // the array of <%= cameledName %>s
27 | vm.<%= cameledName %>s = <%= cameledName %>s;
28 | // toggle detail view
29 | vm.toggleDetails = toggleDetails;<% if(features.socketio) { %>
30 |
31 | // initialize the controller
32 | activate();
33 |
34 | /**
35 | * Register socket updates and unsync on scope $destroy event
36 | */
37 | function activate() {
38 | socket.syncUpdates('<%= syncUpdateUrl %>', vm.<%= cameledName %>s);
39 | $scope.$on('$destroy', unsync<%= classedName %>Updates);
40 |
41 | function unsync<%= classedName %>Updates() {
42 | socket.unsyncUpdates('<%= cameledName %>');
43 | }
44 | }<% } %>
45 |
46 | /**
47 | * Toggle the detail view
48 | */
49 | function toggleDetails() {
50 | ToggleComponent('<%= moduleName %>.detailView').toggle();
51 | }
52 | }
53 |
54 | })();
55 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/list.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>ListController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>ListController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/list/list.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-list-content {}
2 |
3 | [md-component-id="<%= moduleName %>.detailView"] {}
--------------------------------------------------------------------------------
/generators/templates/apiroute/main/main.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Register the list controller as <%= classedName %>MainController
6 | */
7 |
8 | angular
9 | .module('<%= scriptAppName %>.<%= moduleName %>.main')
10 | .controller('<%= classedName %>MainController', <%= classedName %>MainController);
11 |
12 | // add <%= classedName %>MainController dependencies to inject
13 | <%= classedName %>MainController.$inject = ['$state'];
14 |
15 | /**
16 | * <%= classedName %>MainController constructor
17 | */
18 | function <%= classedName %>MainController($state) {
19 | var vm = this;
20 | // switch to the list state
21 | vm.showList = showList;
22 |
23 | /**
24 | * Activate the <%= moduleName %>.list state
25 | */
26 | function showList() {
27 | $state.go('<%= moduleName %>.list');
28 | }
29 | }
30 |
31 | })();
32 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/main/main.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>MainController', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>.main'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>MainController', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/main/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | <%= menuItem %> Section
22 |
23 | This is the main page of the <%= menuItem %> route.
24 |
25 |
26 | View your list of <%= modelName %>s
27 | or create a <%= modelName %> .
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/main/main.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.<%= moduleName %>.main module
6 | * and configure it.
7 | *
8 | * @requires ui.router
9 | * @requires <%= scriptAppName %>.mainMenu
10 | */
11 |
12 | angular
13 | .module('<%= scriptAppName %>.<%= moduleName %>.main', [
14 | 'ui.router',
15 | '<%= scriptAppName %>.mainMenu'
16 | ])
17 | .config(config<%= classedName %>MainRoutes);
18 |
19 | // inject config<%= classedName %>MainRoutes dependencies
20 | config<%= classedName %>MainRoutes.$inject = ['$stateProvider', 'mainMenuProvider'];
21 |
22 | /**
23 | * Route configuration function configuring the passed $stateProvider.
24 | * Register the <%= moduleName %>.main state with the list template for the
25 | * 'main' view paired with the <%= classedName %>MainController as 'main'.
26 | *
27 | * @param {$stateProvider} $stateProvider - The state provider to configure
28 | * @param {mainMenuProvider} mainMenuProvider - The service to pass navigation information to
29 | */
30 | function config<%= classedName %>MainRoutes($stateProvider, mainMenuProvider) {
31 | // The main state configuration
32 | var mainState = {
33 | name: '<%= moduleName %>.main',
34 | parent: '<%= moduleName %>',
35 | url: '/',<% if (secure) {%>
36 | authenticate: true,
37 | role: '<%= role %>',<%}%>
38 | views: {
39 | '@<%= moduleName %>': {
40 | templateUrl: '<%= mainHtmlUrl %>',
41 | controller: '<%= classedName %>MainController',
42 | controllerAs: 'main'
43 | }
44 | }
45 | };
46 |
47 | $stateProvider.state(mainState);
48 |
49 | mainMenuProvider.addMenuItem({
50 | name: '<%= menuItem %>',
51 | state: mainState.name<% if (secure) {%>,
52 | role: '<%= role %>'<%}%>
53 | });
54 | }
55 |
56 | })();
57 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/main/main.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-main-content {}
--------------------------------------------------------------------------------
/generators/templates/apiroute/name.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as <%= classedName %>Controller
5 | angular
6 | .module('<%= scriptAppName %>.<%= moduleName %>')
7 | .controller('<%= classedName %>Controller', <%= classedName %>Controller);
8 |
9 | /**
10 | * add <%= classedName %>Controller dependencies to inject
11 | * @param {Service} <%= modelName %>Definition The model definition of <%= modelName %> resource
12 | */
13 | <%= classedName %>Controller.$inject = ['<%= modelName %>Definition', '$state', '$scope'];
14 |
15 | /**
16 | * <%= classedName %>Controller constructor. Main controller for the <%= scriptAppName %>.<%= moduleName %>
17 | * module.
18 | *
19 | * @param {$scope} $scope - The scope to listen for events<% if(features.socketio) { %>
20 | * @param {socket.io} socket - The socket to register updates<% } %>
21 | */
22 | function <%= classedName %>Controller(<%= modelName %>Definition, $state, $scope) {
23 | var vm = this;
24 |
25 | vm.<%= cameledName %>Definition = <%= modelName %>Definition;
26 | vm.inDetailState = $state.current.name.endsWith('.detail');
27 |
28 | $scope.$on('$stateChangeStart', function updateInDetailState(event, toState) {
29 | vm.inDetailState = toState.name.endsWith('.detail');
30 | });
31 | }
32 |
33 | })();
34 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/name.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>Controller', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>Controller', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/name.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/name.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.<%= moduleName %> module
6 | * and configure it.
7 | *
8 | * @requires ui.router
9 | * @requires ngResource
10 | * @requires <%= scriptAppName %>.<%= moduleName %>.main
11 | * @requires <%= scriptAppName %>.<%= moduleName %>.list
12 | * @requires <%= scriptAppName %>.<%= moduleName %>.create
13 | */
14 | angular
15 | .module('<%= scriptAppName %>.<%= moduleName %>', [
16 | 'ngResource',
17 | 'ui.router',
18 | '<%= scriptAppName %>.<%= moduleName %>.main',
19 | '<%= scriptAppName %>.<%= moduleName %>.list',
20 | '<%= scriptAppName %>.<%= moduleName %>.create'
21 | ])
22 | .config(config<%= classedName %>Routes);
23 |
24 | // inject config<%= classedName %>Routes dependencies
25 | config<%= classedName %>Routes.$inject = ['$urlRouterProvider', '$stateProvider'];
26 |
27 | /**
28 | * Route configuration function configuring the passed $stateProvider.
29 | * Register the abstract <%= moduleName %> state with the <%= moduleName %> template
30 | * paired with the <%= classedName %>Controller as 'index'.
31 | * The injectable '<%= cameledName %>s' is resolved as a list of all <%= cameledName %>s
32 | * and can be injected in all sub controllers.
33 | *
34 | * @param {$stateProvider} $stateProvider - The state provider to configure
35 | */
36 | function config<%= classedName %>Routes($urlRouterProvider, $stateProvider) {
37 | // The <%= moduleName %> state configuration
38 | var <%= cameledName %>State = {
39 | name: '<%= name %>',<% if (isSubRoute && ancestors.length) { %>
40 | parent: '<%= ancestors.join('.') %>',<% } %>
41 | url: '<%= route %>',
42 | abstract: true,
43 | templateUrl: '<%= htmlUrl %>',
44 | controller: '<%= classedName %>Controller',
45 | controllerAs: 'index'
46 | };
47 |
48 | $urlRouterProvider.when('/<%= slashedName %>', '/<%= slashedName %>/');
49 | $stateProvider.state(<%= cameledName %>State);
50 | }
51 |
52 | })();
53 |
--------------------------------------------------------------------------------
/generators/templates/apiroute/name.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-content {}
--------------------------------------------------------------------------------
/generators/templates/controller/name.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as <%= classedName %>Controller
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .controller('<%= classedName %>Controller', <%= classedName %>Controller);
8 |
9 | // add <%= classedName %>Controller dependencies to inject
10 | <%= classedName %>Controller.$inject = [];
11 |
12 | /**
13 | * <%= classedName %>Controller constructor
14 | */
15 | function <%= classedName %>Controller() {
16 | var vm = this;
17 |
18 | // view model bindings
19 | vm.title = '<%= name %>';
20 | vm.doSomething = doSomething;
21 |
22 | // view model implementations
23 | function doSomething() {
24 | return [vm.title, 'a sublime controller'].join(' - ');
25 | }
26 | }
27 |
28 | })();
29 |
--------------------------------------------------------------------------------
/generators/templates/controller/name.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>Controller', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>Controller', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | it('should have an awesome title property', function () {
25 | Should.exist(controller.title);
26 | controller.title.should.equal('<%= name %>');
27 | });
28 |
29 | it('should have a working doSomething method', function () {
30 | Should.exist(controller.doSomething);
31 | controller.doSomething().should.equal('<%= name %> - a sublime controller');
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/generators/templates/decorator/name.decorator.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the decorator config
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .config(<%= name %>Config);
8 |
9 | // add <%= name %>Config dependencies to inject
10 | <%= name %>Config.$inject = ['$provide'];
11 |
12 | // the config function to decorate the service
13 | function <%= name %>Config($provide) {
14 | $provide.decorator('<%= serviceToDecorate %>', <%= classedName %>Decorator);
15 | }
16 |
17 | // add <%= classedName %> dependencies to inject
18 | <%= classedName %>Decorator.$inject = ['$delegate'];
19 |
20 | /**
21 | * <%= classedName %>Decorator constructor
22 | */
23 | function <%= classedName %>Decorator($delegate) {
24 | // factory members
25 | var name = '<%= name %>';
26 |
27 | // public API
28 | return function <%= classedName %>DecoratorFunction() {
29 | // apply decorations to $delegate
30 | $delegate.getName = function getDelegatedName() {
31 | return name;
32 | };
33 |
34 | return $delegate;
35 | }
36 | }
37 |
38 | })();
39 |
--------------------------------------------------------------------------------
/generators/templates/directiveComplex/name.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the directive as <%= cameledName %>
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .directive('<%= cameledName %>', <%= cameledName %>);
8 |
9 | // add <%= cameledName %> dependencies to inject
10 | // <%= cameledName %>.$inject = [''];
11 |
12 | /**
13 | * <%= cameledName %> directive
14 | */
15 | function <%= cameledName %>() {
16 | // directive definition members
17 | var directive = {
18 | link: link,
19 | templateUrl: '<%= htmlUrl %>',
20 | restrict: 'EA'
21 | };
22 |
23 | return directive;
24 |
25 | // directives link definition
26 | function link(scope, element, attrs) {
27 | element.text('this is the <%= cameledName%> directive');
28 | }
29 | }
30 |
31 | })();
32 |
--------------------------------------------------------------------------------
/generators/templates/directiveComplex/name.directive.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: <%= cameledName %>', function () {
4 |
5 | // load the directive's module and view
6 | beforeEach(module('<%= scriptAppName %>'));
7 | beforeEach(module('<%= htmlUrl %>'));
8 |
9 | var element, scope;
10 |
11 | beforeEach(inject(function ($rootScope, $compile) {
12 | scope = $rootScope.$new();
13 | element = angular.element('<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>');
14 | element = $compile(element)(scope);
15 | scope.$apply();
16 | }));
17 |
18 | it('should set the element text', function () {
19 | element.text().should.equal('this is the <%= cameledName %> directive');
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/generators/templates/directiveComplex/name.html:
--------------------------------------------------------------------------------
1 | this is the <%= cameledName %> directive
--------------------------------------------------------------------------------
/generators/templates/directiveComplex/name.scss:
--------------------------------------------------------------------------------
1 | <%= _.dasherize(name) %> {
2 | }
3 |
--------------------------------------------------------------------------------
/generators/templates/directiveSimple/name.directive.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= cameledName %>
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .directive('<%= _.camelize(name) %>', <%= cameledName %>);
8 |
9 | // add <%= cameledName %> dependencies to inject
10 | // <%= cameledName %>.$inject = [''];
11 |
12 | /**
13 | * <%= cameledName %> directive
14 | */
15 | function <%= cameledName %>() {
16 | // directive definition members
17 | var directive = {
18 | link: link,
19 | restrict: 'EA'
20 | };
21 |
22 | return directive;
23 |
24 | // directives link definition
25 | function link(scope, element, attrs) {
26 | element.text('this is the <%= cameledName %> directive');
27 | }
28 | }
29 |
30 | })();
31 |
--------------------------------------------------------------------------------
/generators/templates/directiveSimple/name.directive.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Directive: <%= cameledName %>', function () {
4 |
5 | // load the directive's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | var element, scope;
9 |
10 | beforeEach(inject(function ($rootScope, $compile) {
11 | scope = $rootScope.$new();
12 | element = angular.element('<<%= _.dasherize(name) %>><%= _.dasherize(name) %>>');
13 | element = $compile(element)(scope);
14 | }));
15 |
16 | it('should set the element text', function () {
17 | element.text().should.equal('this is the <%= cameledName %> directive');
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/generators/templates/factory/name.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= classedName %>Service
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .factory('<%= classedName %>', <%= classedName %>);
8 |
9 | // add <%= classedName %> dependencies to inject
10 | // <%= classedName %>.$inject = [''];
11 |
12 | /**
13 | * <%= classedName %> factory constructor
14 | * AngularJS will instantiate a singleton which is
15 | * an object that has the members of this factory
16 | */
17 | function <%= classedName %>() {
18 | // factory members
19 | var name = '<%= name %>';
20 |
21 | // public API
22 | return {
23 | name: name,
24 | doSomething: doSomething
25 | };
26 |
27 | // factory function definitions
28 | function doSomething() {
29 | return name;
30 | }
31 | }
32 |
33 | })();
34 |
--------------------------------------------------------------------------------
/generators/templates/factory/name.service.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Factory: <%= classedName %>', function () {
4 |
5 | // load the resource's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate service
9 | var resource;
10 |
11 | beforeEach(inject(function (_<%= classedName %>_) {
12 | resource = _<%= classedName %>_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(resource);
17 | });
18 |
19 | it('should be a resource object', function () {
20 | resource.doSomething().should.equal('<%= name %>');
21 | });
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/generators/templates/filter/name.filter.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= classedName %>Service
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .filter('<%= classedName %>', <%= classedName %>);
8 |
9 | // add <%= classedName %> dependencies to inject
10 | // <%= classedName %>.$inject = [''];
11 |
12 | /**
13 | * <%= classedName %> filter constructor
14 | */
15 | function <%= classedName %>() {
16 | return function (input) {
17 | return '<%= classedName %> filter: ' + input;
18 | };
19 | }
20 |
21 | })();
22 |
--------------------------------------------------------------------------------
/generators/templates/filter/name.filter.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Filter: <%= classedName %>', function () {
4 |
5 | // load the filter's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // initialize a new instance of the filter before each test
9 | var <%= classedName %>;
10 | beforeEach(inject(function ($filter) {
11 | <%= classedName %> = $filter('<%= classedName %>');
12 | }));
13 |
14 | it('should be defined', function () {
15 | Should.exist(<%= classedName %>);
16 | });
17 |
18 | it('should return the input prefixed with "<%= classedName %> filter"', function () {
19 | var text = '<%= scriptAppName %>';
20 | <%= classedName %>(text).should.equal('<%= classedName %> filter: ' + text)
21 | });
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/generators/templates/provider/name.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= classedName %>Service
5 | angular.module('<%= scriptAppName %>')
6 | .provider('<%= classedName %>', <%= classedName %>Provider);
7 |
8 | /**
9 | * <%= classedName %>Provider definition
10 | * AngularJS will instantiate a singleton which is
11 | * the object resulting from the $get method call
12 | * However, providers can be configured in the config
13 | * phase of your angular application
14 | */
15 | function <%= classedName %>Provider() {
16 | // factory members
17 | var name = '<%= name %>';
18 |
19 | // public configuration API
20 | this.setName = function setName(s) {
21 | name = s;
22 | };
23 |
24 | // a private constructor
25 | function <%= classedName %>() {
26 | this.greet = function () {
27 | return name;
28 | };
29 | }
30 |
31 | // Method for instantiating
32 | this.$get = [/*['injects'] ,*/ function <%= name %>Factory(/* injectts */) {
33 | return new <%= classedName %>();
34 | }];
35 | }
36 |
37 | })();
38 |
--------------------------------------------------------------------------------
/generators/templates/provider/name.service.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Factory: <%= cameledName %>', function () {
4 |
5 | // load the provider's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate provider
9 | var provider;
10 |
11 | beforeEach(inject(function (_<%= classedName %>_) {
12 | provider = _<%= classedName %>_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(provider);
17 | });
18 |
19 | it('should expose a working doSomething function', function () {
20 | Should.exist(provider.doSomething);
21 | provider.doSomething().should.equal('<%= name %>');
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/generators/templates/resource/name.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= classedName %>
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .factory('<%= classedName %>', <%= classedName %>);
8 |
9 | // add <%= classedName %> dependencies to inject
10 | <% if (features.useOriginalResource) { %><%= classedName %>.$inject = ['$resource'];<% } else { %><%= classedName %>.$inject = ['Resource'];<% } %>
11 |
12 | /**
13 | * <%= classedName %> resource constructor
14 | */
15 | function <%= classedName %>($resource) {
16 | // factory members
17 | var apiURL = '<%= apiURL%>';
18 | // public API
19 | <% if (features.useOriginalResource) { %>return $resource(apiURL + '/:id/:controller', {id: '@_id'});<% } else { %>return $resource(apiURL + '/:id/:controller');<% } %>
20 | }
21 |
22 | })();
23 |
--------------------------------------------------------------------------------
/generators/templates/route/name.controller.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the controller as <%= classedName %>Controller
5 | angular
6 | .module('<%= scriptAppName %>.<%= moduleName %>')
7 | .controller('<%= classedName %>Controller', <%= classedName %>Controller);
8 |
9 | // add <%= classedName %>Controller dependencies to inject
10 | // <%= classedName %>Controller.$inject = ['$scope'];
11 |
12 | /**
13 | * <%= classedName %>Controller constructor
14 | */
15 | function <%= classedName %>Controller() {
16 | var vm = this;
17 |
18 | // view model bindings
19 | vm.title = '<%= name %>';
20 | vm.doSomething = doSomething;
21 |
22 | // view model implementations
23 | function doSomething() {
24 | return [vm.title, 'a sublime controller'].join(' - ');
25 | }
26 | }
27 |
28 | })();
29 |
--------------------------------------------------------------------------------
/generators/templates/route/name.controller.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Controller: <%= classedName %>Controller', function () {
4 |
5 | // load the controller's module
6 | beforeEach(module('<%= scriptAppName %>.<%= moduleName %>'));
7 |
8 | var controller;
9 | var scope;
10 |
11 | // Initialize the controller and a mock scope
12 | beforeEach(inject(function ($controller, $rootScope) {
13 | scope = $rootScope.$new();
14 | controller = $controller('<%= classedName %>Controller', {
15 | // $scope: scope
16 | });
17 | }));
18 |
19 | it('object should exist', function () {
20 | Should.exist(controller);
21 | controller.should.be.an.instanceof(Object);
22 | });
23 |
24 | it('should have an awesome title property', function () {
25 | Should.exist(controller.title);
26 | controller.title.should.equal('<%= name %>');
27 | });
28 |
29 | it('should have a working doSomething method', function () {
30 | Should.exist(controller.doSomething);
31 | controller.doSomething().should.equal('<%= name %> - a sublime controller');
32 | });
33 | });
34 |
--------------------------------------------------------------------------------
/generators/templates/route/name.html:
--------------------------------------------------------------------------------
1 | <% if(autoRoute) { %><% } else {%>
4 | This is the <%= name %> view.
5 | My controller can do something: "{{ vm.doSomething() }}"
6 |
<% }%>
7 |
--------------------------------------------------------------------------------
/generators/templates/route/name.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | /**
5 | * Introduce the <%= scriptAppName %>.<%= moduleName %> module
6 | * and configure it.
7 | *
8 | * @requires ui.router<% children.forEach(function(child) { %>
9 | * @requires <%= scriptAppName %>.<%= child %><% }); %>
10 | */
11 | angular
12 | .module('<%= scriptAppName %>.<%= moduleName %>', [<% children.forEach(function(child) { %>
13 | '<%= scriptAppName %>.<%= child %>',<% }); %>
14 | 'ui.router'
15 | ])
16 | .config(config<%= classedName %>Route);
17 |
18 | // inject config<%= classedName %>Route dependencies
19 | config<%= classedName %>Route.$inject = ['$stateProvider'];
20 |
21 | // route config function configuring the passed $stateProvider
22 | function config<%= classedName %>Route($stateProvider) {
23 | $stateProvider
24 | .state('<%= name %>', {
25 | url: '<%= route %>',<% if (isSubRoute && ancestors.length) { %>
26 | parent: '<%= ancestors.join('.') %>',<% } %><% if(autoRoute) { %>
27 | abstract: true,<% } %>
28 | templateUrl: '<%= htmlUrl %>',
29 | controller: '<%= classedName %>Controller',
30 | controllerAs: 'vm'
31 | });
32 | }
33 |
34 | })();
35 |
--------------------------------------------------------------------------------
/generators/templates/route/name.scss:
--------------------------------------------------------------------------------
1 | #<%= dashedName %>-content {}
2 |
--------------------------------------------------------------------------------
/generators/templates/service/name.service.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | 'use strict';
3 |
4 | // register the service as <%= classedName %>Service
5 | angular
6 | .module('<%= scriptAppName %>')
7 | .service('<%= classedName %>', <%= classedName %>);
8 |
9 | // add <%= classedName %> dependencies to inject
10 | // <%= classedName %>.$inject = [''];
11 |
12 | /**
13 | * <%= classedName %> constructor
14 | * AngularJS will instantiate a singleton by calling "new" on this function
15 | * @returns {Object} The service definition for the <%= classedName %> Service
16 | */
17 | function <%= classedName %>() {
18 |
19 | return {
20 | doSomething: doSomething
21 | };
22 |
23 | // define instance methods
24 | function doSomething () {
25 | return '<%= name %>';
26 | }
27 | }
28 |
29 | })();
30 |
--------------------------------------------------------------------------------
/generators/templates/service/name.service.spec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | describe('Service: <%= classedName %>', function () {
4 |
5 | // load the service's module
6 | beforeEach(module('<%= scriptAppName %>'));
7 |
8 | // instantiate service
9 | var service;
10 |
11 | beforeEach(inject(function (_<%= classedName %>_) {
12 | service = _<%= classedName %>_;
13 | }));
14 |
15 | it('should be defined', function () {
16 | Should.exist(service);
17 | });
18 |
19 | it('should expose a working doSomething function', function () {
20 | Should.exist(service.doSomething);
21 | service.doSomething().should.equal('<%= name %>');
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generator-material-app",
3 | "version": "0.1.5",
4 | "description": "Generates a material web application with AngularJS, Express and Mongoose",
5 | "repository": "https://github.com/michaelkrone/generator-material-app.git",
6 | "keywords": [
7 | "yeoman-generator"
8 | ],
9 | "dependencies": {
10 | "async": "^0.9.0",
11 | "yeoman-generator": "^0.17.7"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------