Skip to content

Feature: admin module #1318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export default class Generator extends Base {
if(this.filters.uirouter) angModules.push("'ui.router'");
if(this.filters.uibootstrap) angModules.push("'ui.bootstrap'");
if(this.filters.auth) {
angModules.unshift(`'${this.scriptAppName}.admin'`);
angModules.unshift(`'${this.scriptAppName}.auth'`);
angModules.push("'validation.match'");
}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"grunt-contrib-jshint": "~0.11.2",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "~0.6.1",<% if (filters.jade) { %>
"grunt-contrib-jade": "^0.15.0",<% } %><% if (filters.less) { %>
"grunt-contrib-jade": "^0.15.0",
"karma-ng-jade2js-preprocessor": "^0.2.0",<% } %><% if (filters.less) { %>
"grunt-contrib-less": "^1.0.0",<% } %><% if(filters.babel) { %>
"karma-babel-preprocessor": "^5.2.1",<% } %>
"grunt-babel": "~5.0.0",
Expand Down Expand Up @@ -95,7 +96,6 @@
"karma-firefox-launcher": "~0.1.6",
"karma-script-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-ng-jade2js-preprocessor": "^0.2.0",
"karma-chrome-launcher": "~0.2.0",
"requirejs": "~2.1.11",
"karma-requirejs": "~0.2.2",
Expand Down
4 changes: 2 additions & 2 deletions app/templates/client/app/admin(auth)/admin(html).html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="container">
<p>The delete user and user index api routes are restricted to users with the 'admin' role.</p>
<ul class="list-group">
<li class="list-group-item" ng-repeat="user in users">
<li class="list-group-item" ng-repeat="user in admin.users">
<strong>{{user.name}}</strong><br>
<span class="text-muted">{{user.email}}</span>
<a ng-click="delete(user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
<a ng-click="admin.delete(user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
</li>
</ul>
</div>
4 changes: 2 additions & 2 deletions app/templates/client/app/admin(auth)/admin(jade).jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ navbar
p
| The delete user and user index api routes are restricted to users with the 'admin' role.
ul.list-group
li.list-group-item(ng-repeat='user in users')
li.list-group-item(ng-repeat='user in admin.users')
strong {{user.name}}
br
span.text-muted {{user.email}}
a.trash(ng-click='delete(user)')
a.trash(ng-click='admin.delete(user)')
span.glyphicon.glyphicon-trash.pull-right
24 changes: 16 additions & 8 deletions app/templates/client/app/admin(auth)/admin.controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
'use strict';

angular.module('<%= scriptAppName %>')
.controller('AdminCtrl', function($scope, $http, Auth, User) {
(function() {

class AdminController {

constructor(User) {
// Use the User $resource to fetch all users
$scope.users = User.query();
this.users = User.query();
}

delete(user) {
user.$remove();
this.users.splice(this.users.indexOf(user), 1);
}
}

angular.module('<%= scriptAppName %>.admin')
.controller('AdminController', AdminController);

$scope.delete = function(user) {
User.remove({ id: user._id });
$scope.users.splice(this.$index, 1);
};
});
})();
7 changes: 7 additions & 0 deletions app/templates/client/app/admin(auth)/admin.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

angular.module('<%= scriptAppName %>.admin', [
'<%= scriptAppName %>.auth'<% if (filters.ngroute) { %>,
'ngRoute'<% } if (filters.uirouter) { %>,
'ui.router'<% } %>
]);
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
'use strict';

angular.module('<%= scriptAppName %>')
angular.module('<%= scriptAppName %>.admin')
<% if (filters.ngroute) { %>.config(function($routeProvider) {
$routeProvider
.when('/admin', {
templateUrl: 'app/admin/admin.html',
controller: 'AdminCtrl',
controller: 'AdminController',
controllerAs: 'admin',
authenticate: 'admin'
});
});<% } %><% if (filters.uirouter) { %>.config(function($stateProvider) {
});<% } if (filters.uirouter) { %>.config(function($stateProvider) {
$stateProvider
.state('admin', {
url: '/admin',
templateUrl: 'app/admin/admin.html',
controller: 'AdminCtrl',
controller: 'AdminController',
controllerAs: 'admin',
authenticate: 'admin'
});
});<% } %>
23 changes: 8 additions & 15 deletions app/templates/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,25 @@ module.exports = function(config) {
// endbower<% if (filters.socketio) { %>
'node_modules/socket.io-client/socket.io.js',<% } %>
'client/app/app.js',
'client/app/**/*.js',
'client/components/**/*.js',
'client/app/**/*.jade',
'client/components/**/*.jade',
'client/app/**/*.html',
'client/components/**/*.html'
'client/{app,components}/**/*.module.js',
'client/{app,components}/**/*.js',
'client/{app,components}/**/*.<%= filters.jade ? '{jade,html}' : 'html' %>'
],

preprocessors: {
'**/*.jade': 'ng-jade2js',
'**/*.html': 'html2js',<% if(filters.babel) { %>
'**/*.html': 'html2js'<% if (filters.jade) { %>,
'**/*.jade': 'ng-jade2js'<% } if (filters.babel) { %>,
'client/{app,components}/**/*.js': 'babel'<% } %>
},

ngHtml2JsPreprocessor: {
stripPrefix: 'client/'
},
},<% if (filters.jade) { %>

ngJade2JsPreprocessor: {
stripPrefix: 'client/'
},
},<% } if (filters.babel) { %>

<% if(filters.babel) { %>
babelPreprocessor: {
options: {
sourceMap: 'inline'
Expand All @@ -55,8 +51,7 @@ module.exports = function(config) {
sourceFileName: function (file) {
return file.originalPath;
}
},
<% } %>
},<% } %>

// list of files / patterns to exclude
exclude: [],
Expand All @@ -80,7 +75,6 @@ module.exports = function(config) {
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
Expand All @@ -91,7 +85,6 @@ module.exports = function(config) {
// - IE (only Windows)
browsers: ['PhantomJS'],


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
Expand Down
3 changes: 2 additions & 1 deletion test/test-file-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ describe('angular-fullstack generator', function () {
'client/app/account/signup/signup.controller.' + script,
'client/app/admin/admin.' + markup,
'client/app/admin/admin.' + stylesheet,
'client/app/admin/admin.' + script,
'client/app/admin/admin.module.' + script,
'client/app/admin/admin.router.' + script,
'client/app/admin/admin.controller.' + script,
'client/components/auth/auth.module.' + script,
'client/components/auth/auth.service.' + script,
Expand Down