-
Notifications
You must be signed in to change notification settings - Fork 724
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
[RFR] Introduce new way to define dashboard datasources #509
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
92b8607
Introduce new way to define dashboard datasources
fzaninotto 5356efc
Add doc
fzaninotto c145cb5
deprecate dashboardView()
fzaninotto 795627d
Simplify panel markup
fzaninotto 733a3ee
move PanelBuilder logic to routing
fzaninotto 09cfad6
Simplify dashboard configuration
fzaninotto 45e421f
push admin-config version requirement
fzaninotto 204b5da
Fix tests
fzaninotto c9b84c8
Code review
fzaninotto a4187de
Fix dashboard panel title when dashboard is undefined
fzaninotto 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
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 |
---|---|---|
|
@@ -20,3 +20,56 @@ The `Field.identifier(true)` does not exist anymore. Instead, you must specify t | |
+ entity.identifier(nga.field('id')) | ||
``` | ||
|
||
## `dashboardView()` is deprecated, use `admin.dashboard()` instead | ||
|
||
To let developers customize the admin dashboard at will, ng-admin 0.8 decouples the dashboard data and presentation. You can setup the dashboard datasources and template on a new member of ythe admin class, `dahboard()`: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
|
||
```js | ||
admin.dashboard(nga.dashboard() | ||
.addCollection(name, collection) | ||
.addCollection(name, collection) | ||
.addCollection(name, collection) | ||
.template(templateString) | ||
); | ||
``` | ||
|
||
This is the preferred way to customize dashboard panel position, title, and to customize the fields displayed in each panel. Configure a collection just like you would like to configure a `listView`. For instance: | ||
|
||
```js | ||
admin.dashboard(nga.dashboard() | ||
.addCollection('posts', nga.collection(post) | ||
.title('Recent posts') | ||
.perPage(5) // limit the panel to the 5 latest posts | ||
.fields([ | ||
nga.field('title').isDetailLink(true).map(truncate) | ||
]) | ||
.sortField('id') | ||
.sortOrder('DESC') | ||
.order(1) | ||
) | ||
.addCollection('comments', nga.collection(comment) | ||
.title('Last comments') | ||
.perPage(5) | ||
.fields([ | ||
nga.field('id'), | ||
nga.field('body', 'wysiwyg').label('Comment').stripTags(true).map(truncate), | ||
nga.field(null, 'template').label('').template('<post-link entry="entry"></post-link>') // you can use custom directives, too | ||
]) | ||
.order(2) | ||
) | ||
.addCollection('tags', nga.collection(tag) | ||
.title('Recent tags') | ||
.perPage(10) | ||
.fields([ | ||
nga.field('id'), | ||
nga.field('name'), | ||
nga.field('published', 'boolean').label('Is published ?') | ||
]) | ||
.order(3) | ||
) | ||
); | ||
``` | ||
|
||
See the [Dashboard Configuration](doc/Dashboard.md) dedicated chapter for more details. | ||
|
||
Calls to `dashboardView()` are still supported in ng-admin 0.8, but will raise an error in future versions. |
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.
I would also add a few words about Restangular element transformers.
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 refer to the extensive documentation chapter about API Mapping two lines down, I think it's enough.