This repository has been archived by the owner on May 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
ng-admin role-based system #8
Open
akagadovskiy
wants to merge
3
commits into
marmelab:gh-pages
Choose a base branch
from
akagadovskiy:roles-config
base: gh-pages
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function (nga, admin) { | ||
|
||
var categories = admin.getEntity('categories'); | ||
categories.listView() | ||
.fields([ | ||
nga.field('name'), | ||
]) | ||
.batchActions([]) | ||
.listActions(); | ||
return categories; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var moment = require('moment'); | ||
var fromNow = v => moment(v).fromNow(); | ||
|
||
var segments = require('../segments/segments').choices; | ||
|
||
export default function (nga, admin) { | ||
|
||
var customer = admin.getEntity('customers'); | ||
customer.listView() | ||
.title('Visitors') | ||
.fields([ | ||
nga.field('avatar', 'template') | ||
.label('') | ||
.template('<img src="{{ entry.values.avatar }}" width="25" style="margin-top:-5px" />'), | ||
nga.field('last_name', 'template') // use last_name for sorting | ||
.label('Name') | ||
.isDetailLink(true) | ||
.template('{{ entry.values.first_name }} {{ entry.values.last_name }}'), | ||
nga.field('last_seen', 'datetime') | ||
.map(fromNow) | ||
.cssClasses('hidden-xs'), | ||
nga.field('nb_commands', 'template') | ||
.label('Commands') | ||
.template('{{ entry.values.nb_commands ? entry.values.nb_commands : "" }}') | ||
.cssClasses('hidden-xs'), | ||
nga.field('total_spent', 'template') | ||
.template('<div class="amount" ng-if="::entry.values[field.name()]">$<ma-number-column field="::field" value="::entry.values[field.name()]"></ma-number-column></div>') | ||
.cssClasses('hidden-xs text-right'), | ||
nga.field('latest_purchase', 'datetime') | ||
.cssClasses('hidden-xs'), | ||
nga.field('has_newsletter', 'boolean') | ||
.label('Newsletter') | ||
.cssClasses('hidden-xs'), | ||
nga.field('segments', 'template') | ||
.template('<span ng-repeat="group in entry.values.groups track by $index" class="label label-default">{{ group }}</span>') | ||
.cssClasses('hidden-xs'), | ||
]) | ||
.filters([ | ||
nga.field('q', 'template') | ||
.label('') | ||
.pinned(true) | ||
.template('<div class="input-group"><input type="text" ng-model="value" placeholder="Search" class="form-control"></input><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span></div>'), | ||
nga.field('groups', 'choice') | ||
.label('Segment') | ||
.choices(segments), | ||
nga.field('last_seen_gte', 'datetime') | ||
.label('Visited since'), | ||
nga.field('has_ordered', 'boolean'), | ||
nga.field('has_newsletter', 'boolean'), | ||
]) | ||
.sortField('first_seen') | ||
.sortDir('DESC') | ||
.batchActions([]) | ||
.listActions(); | ||
|
||
return customer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
var moment = require('moment'); | ||
var fromNow = v => moment(v).fromNow(); | ||
|
||
export default function (nga, admin, $window) { | ||
|
||
var dashboard = nga.dashboard() | ||
.addCollection(nga.collection(admin.getEntity('customers')) | ||
.name('new_customers') | ||
.title('New customers') | ||
.fields([ | ||
nga.field('avatar', 'template') | ||
.label('') | ||
.template('<img src="{{ entry.values.avatar }}" width="25" />'), | ||
nga.field('last_name', 'template') // use last_name for sorting | ||
.label('Name') | ||
.isDetailLink(true) | ||
.template('{{ entry.values.first_name }} {{ entry.values.last_name }}'), | ||
nga.field('last_seen', 'datetime') | ||
.map(fromNow), | ||
]) | ||
.permanentFilters({ has_ordered: true }) | ||
.sortField('first_seen') | ||
.sortDir('DESC') | ||
.perPage(10) | ||
) | ||
|
||
if ($window.localStorage.getItem('posters_galore_login') == 'admin') { | ||
dashboard.template(` | ||
<div class="row dashboard-starter"></div> | ||
<dashboard-summary></dashboard-summary> | ||
<div class="row dashboard-content"> | ||
<div class="col-lg-6"> | ||
<div class="panel panel-default"> | ||
<ma-dashboard-panel collection="dashboardController.collections.pending_orders" entries="dashboardController.entries.pending_orders"></ma-dashboard-panel> | ||
</div> | ||
</div> | ||
<div class="col-lg-6"> | ||
<div class="panel panel-default"> | ||
<ma-dashboard-panel collection="dashboardController.collections.latest_reviews" entries="dashboardController.entries.latest_reviews"></ma-dashboard-panel> | ||
</div> | ||
<div class="panel panel-default"> | ||
<ma-dashboard-panel collection="dashboardController.collections.new_customers" entries="dashboardController.entries.new_customers"></ma-dashboard-panel> | ||
</div> | ||
</div> | ||
</div> | ||
`); | ||
} else { | ||
dashboard.template(` | ||
<div class="row dashboard-starter"></div> | ||
<dashboard-summary></dashboard-summary> | ||
<div class="row dashboard-content"> | ||
<div class="col-lg-6"> | ||
<div class="panel panel-default"> | ||
<ma-dashboard-panel collection="dashboardController.collections.new_customers" entries="dashboardController.entries.new_customers"></ma-dashboard-panel> | ||
</div> | ||
</div> | ||
</div> | ||
`); | ||
} | ||
return dashboard; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import moment from 'moment'; | ||
import productsEditionTemplate from './productsEditionTemplate.html'; | ||
|
||
var fromNow = v => moment(v).fromNow(); | ||
|
||
export default function (nga, admin) { | ||
|
||
var products = admin.getEntity('products') | ||
.label('Posters'); | ||
products.listView() | ||
.title('All Posters') | ||
.fields([ | ||
nga.field('i', 'template') | ||
.isDetailLink(true) | ||
.label('') | ||
.template('<img src="{{ entry.values.thumbnail }}" class="poster_mini_thumbnail" />'), | ||
nga.field('reference').isDetailLink(true), | ||
nga.field('price', 'amount') | ||
.cssClasses('hidden-xs'), | ||
nga.field('width', 'float') | ||
.format('0.00') | ||
.cssClasses('hidden-xs'), | ||
nga.field('height', 'float') | ||
.format('0.00') | ||
.cssClasses('hidden-xs'), | ||
nga.field('category_id', 'reference') | ||
.label('Category') | ||
.targetEntity(admin.getEntity('categories')) | ||
.targetField(nga.field('name')) | ||
.cssClasses('hidden-xs'), | ||
nga.field('stock', 'number') | ||
.cssClasses('hidden-xs'), | ||
]) | ||
.filters([ | ||
nga.field('q', 'template') | ||
.label('') | ||
.pinned(true) | ||
.template('<div class="input-group"><input type="text" ng-model="value" placeholder="Search" class="form-control"></input><span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span></div>'), | ||
nga.field('category_id', 'reference') | ||
.label('Category') | ||
.targetEntity(admin.getEntity('categories')) | ||
.targetField(nga.field('name')), | ||
nga.field('width_gte', 'number') | ||
.label('Min width'), | ||
nga.field('width_lte', 'number') | ||
.label('Max width'), | ||
nga.field('height_gte', 'number') | ||
.label('Min height'), | ||
nga.field('height_lte', 'number') | ||
.label('Max height'), | ||
nga.field('stock_lte', 'template') | ||
.label('Low stock') | ||
.defaultValue(10) | ||
]) | ||
.batchActions([]) | ||
.listActions(); | ||
|
||
return products; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of duplicating the conf, I'd pass the roles as a parameter to the config function and let it decide how to configure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about creating a provider/wrapper for handling configurations for different roles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying that you shouldn't put the
if
here, but in the config files. Something like:And then, in the config files, decide what to add according to roles.