Skip to content
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 10 commits into from
Jun 19, 2015

Conversation

fzaninotto
Copy link
Member

Depends on marmelab/admin-config#14

// customize dashboard
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)
        ])
        .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') // template fields don't need a name in dashboard view
                .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)
    )
);
  • add support for new nga.dashboard() syntax
  • Add compatibility layer to make old dashboardView() work
  • clean up dashboard view
  • rename PanelBuilder
  • document new syntax
  • Add example of custom dashboard
  • Fix tests


All HTTP requests made by ng-admin to your REST API are carried out by [Restangular](https://github.com/mgonto/restangular), which is like `$resource` on steroids.

The REST specification doesn't provide enough detail to cover all requirements of an administration GUI. ng-admin makes some assumptions about how your API is designed. All of these assumptions can be overridden by way of [Restangular's request and response interceptors](https://github.com/mgonto/restangular#addresponseinterceptor).
Copy link
Contributor

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.

Copy link
Member Author

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.

@jpetitcolas
Copy link
Contributor

Fine for me, even if there may be a confusion between the collection name, which is sometimes used as a listView in the ReadQueries.getAll method for instance. We should consider (probably in another PR) to homogenize these names.

@fzaninotto
Copy link
Member Author

I'm also not very happy about the addition of a new concept, but this one goes in the right direction (separating data from presentation). listView mixes three concepts: the definition of the collection to fetch (fields, per page, etc.), the presentation (title, filters, etc), and the features (filters, actions). As it's all-or-nothing, I preferred to introduce this collection concept, which is what should be used in every ReadQuery instead of view. But that's, as you said, for another refactoring.

@fzaninotto
Copy link
Member Author

Green!

@fzaninotto fzaninotto changed the title [WIP] Introduce new way to define dashboard datasources [RFR] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto fzaninotto changed the title [RFR] Introduce new way to define dashboard datasources [WIP] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto
Copy link
Member Author

Back to WIP, I discovered a regression in dashboard panels title

@fzaninotto fzaninotto changed the title [WIP] Introduce new way to define dashboard datasources [RFR] Introduce new way to define dashboard datasources Jun 19, 2015
@fzaninotto
Copy link
Member Author

And we're back to RFR.

jpetitcolas added a commit that referenced this pull request Jun 19, 2015
[RFR] Introduce new way to define dashboard datasources
@jpetitcolas jpetitcolas merged commit e4b33a5 into master Jun 19, 2015
@jpetitcolas jpetitcolas deleted the new_dashboard branch June 19, 2015 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants