From be8a842c67615568fef9114409fe860ceaae2f6b Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 9 Sep 2015 14:23:25 -0700 Subject: [PATCH] Roughing in user admin --- app/models/user.js | 6 +++++- app/pods/components/x-application/template.hbs | 5 +++++ app/pods/protected/users/index/route.js | 8 ++++++++ app/pods/protected/users/index/template.hbs | 3 +++ app/router.js | 2 ++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/pods/protected/users/index/route.js create mode 100644 app/pods/protected/users/index/template.hbs diff --git a/app/models/user.js b/app/models/user.js index ae851d0..637a5f3 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -7,5 +7,9 @@ export default DS.Model.extend({ role : DS.attr('string'), createdAt: DS.attr('date'), updatedAt: DS.attr('date'), - deletedAt: DS.attr('date') + deletedAt: DS.attr('date'), + + isAdmin: function() { + return this.get('role') === 'A'; + }.property('role'), }); diff --git a/app/pods/components/x-application/template.hbs b/app/pods/components/x-application/template.hbs index 3057eac..f26e0d3 100644 --- a/app/pods/components/x-application/template.hbs +++ b/app/pods/components/x-application/template.hbs @@ -14,6 +14,11 @@ {{#link-to 'protected.characteristics' tagName='li' href=false}} {{link-to 'Characteristics' 'protected.characteristics'}} {{/link-to}} + {{#if session.currentUser.isAdmin}} + {{#link-to 'protected.users' tagName='li' href=false}} + {{link-to 'Users' 'protected.users'}} + {{/link-to}} + {{/if}} {{#link-to 'protected.about' tagName='li' href=false}} {{link-to 'About' 'protected.about'}} {{/link-to}} diff --git a/app/pods/protected/users/index/route.js b/app/pods/protected/users/index/route.js new file mode 100644 index 0000000..81b9562 --- /dev/null +++ b/app/pods/protected/users/index/route.js @@ -0,0 +1,8 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + model: function() { + return this.store.findAll('user'); + }, + +}); diff --git a/app/pods/protected/users/index/template.hbs b/app/pods/protected/users/index/template.hbs new file mode 100644 index 0000000..f3239cb --- /dev/null +++ b/app/pods/protected/users/index/template.hbs @@ -0,0 +1,3 @@ +{{#each model as |user|}} + {{user.email}}
+{{/each}} diff --git a/app/router.js b/app/router.js index 7398db7..6eb5409 100644 --- a/app/router.js +++ b/app/router.js @@ -19,6 +19,8 @@ Router.map(function() { this.route('protected', { path: '/' }, function() { this.route('about'); + this.route('users'); + this.route('compare', function() { this.route('results'); });