Giter VIP home page Giter VIP logo

ng-admin's Introduction

ng-admin Build Status

Join the chat at https://gitter.im/marmelab/ng-admin

Plug me to your RESTFul API to get a complete administration interface (datagrid, filters, complex form widgets, multi-model relationships, dashboard) in no time! Beyond simple CRUD, ng-admin lets you build sophisticated GUIs without getting in your way.

Screencast

This project is now in maintenance mode. We've rebuilt it from scratch with React.js (the new project is called react-admin), and we're putting all our efforts on the React version.

Installation

The current ng-admin version (master) depends on Angular.js 1.6. If you need compatibility with Angular 1.3, use ng-admin 0.9.

Grab ng-admin from your favorite package manager:

npm install ng-admin --save
# or
yarn add ng-admin

With a Module Bundler

ng-admin is fully compatible with Webpack, and should also be compatible with all available major module bundlers. If you use one of them, you just have to add this line:

const myApp = angular.module('myApp', [
    require('ng-admin'),
    // ...
]);

Important note: as we include HTML templates using require to prevent the AJAX request implied by templateUrl, you will need to configure your module bundler to deal with HTML. It can be accomplished with Webpack using the HTML loader:

module.exports = {
    // ...
    module: {
        loaders: [
            // ...
            { test: /\.html$/, loader: 'html' },
        ]
    },
};

If your module bundler also supports SASS or CSS, you can also include stylesheets using:

// SASS version
require('ng-admin/lib/sass/ng-admin.scss');

// CSS version
require('ng-admin/build/ng-admin.min.css');

Using a module bundler, you would also be able to generate the source map for all your JavaScript and stylesheets, helping you to hunt even the most obscure bugs.

Without a Module Bundler

If you don't have a module bundler, don't worry: you can still include ng-admin with a <script> tag:

<link rel="stylesheet" href="node_modules/ng-admin/build/ng-admin.min.css">
<script src="node_modules/ng-admin/build/ng-admin.min.js"></script>

Bootstrapping your Admin

Add the ng-admin.min.css and ng-admin.min.js to the HTML, add a <div ui-view="ng-admin">, and configure the admin:

<!doctype html>
<html lang="en">
  <head>
    <title>My First Admin</title>
    <link rel="stylesheet" href="node_modules/ng-admin/build/ng-admin.min.css">
  </head>
  <body ng-app="myApp">
    <div ui-view="ng-admin"></div>
    <script src="node_modules/ng-admin/build/ng-admin.min.js"></script>
    <script type="text/javascript">
    var myApp = angular.module('myApp', ['ng-admin']);
    myApp.config(['NgAdminConfigurationProvider', function(NgAdminConfigurationProvider) {
        var nga = NgAdminConfigurationProvider;
        // create an admin application
        var admin = nga.application('My First Admin');
        // more configuration here later
        // ...
        // attach the admin application to the DOM and run it
        nga.configure(admin);
    }]);
    </script>
  </body>
</html>

Getting Started

See the Getting Started dedicated chapter for a step-by-step tutorial aimed at beginners.

Usage Examples

  • You can find a simple configuration in the blog admin demo, where the entities are posts, comments, and tags. The remote REST API is simulated in the browser, using FakeRest.
  • The Posters Galore demo (source) is a more complete example of an e-commerce administration, with custom authentication, pages, directives and modules, all well organized via WebPack. The remote REST API is also simulated in the browser, using FakeRest.

Configuration Reference

An administration in ng-admin is made of one application containing several entities. Each entity has up to 5 views, and each view has many fields.

application
 |-header
 |-menu
 |-dashboard
 |-entity[]
    |-creationView
    |-editionView
    |-deletionView
    |-showView
    |-listView
        |-field[]
           |-name
           |-type

See Configuration API Reference dedicated chapter for more details.

Tip: You won't find the related classes in the ng-admin project. In fact, the admin configuration API exists as a standalone, framework-agnostic library, called admin-config. Don't hesitate to browse the source of that library to learn more.

Relationships

Ng-admin supports relationships between entities in read and write views, and provides specialized field types for that: reference, referenced_list, reference_many, and embedded_list. The Relationships Reference chapter describes in more details which field type to use for which case.

Also, the Fields section of the Configuration API Reference chapter has a list of all settings for each of these field types.

Menu Configuration

By default, ng-admin creates a sidebar menu with one entry per entity. If you want to customize this sidebar (labels, icons, order, adding submenus, etc), you have to define menus manually.

See Menus Configuration dedicated chapter.

Dashboard Configuration

The home page of a ng-admin application is called the Dashboard. Use it to show important pieces of information to the end user, such as latest entries, or charts.

See Dashboard Configuration dedicated chapter.

Customizing the API Mapping

All HTTP requests made by ng-admin to your REST API are carried out by 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.

That means you don't need to adapt your API to ng-admin; ng-admin can adapt to any REST API, thanks to the flexibility of Restangular.

See the Customizing the API Mapping dedicated chapter.

Theming

You can override pretty much all the HTML generated by ng-admin, at different levels.

See the Theming dedicated chapter.

Translation

The ng-admin interface uses English as the default language, but supports switching to another language, thanks to angular-translate.

See the Translation dedicated chapter.

Adding Custom Pages

For each entity, ng-admin creates the necessary pages for Creating, Retrieving, Updating, and Deleting (CRUD) this entity. When you need to achieve more specific actions on an entity, you have to add a custom page - for instance a page asking for an email address to send a message to. How can you route to a specific page and display it in the ng-admin layout?

See the Adding Custom Pages dedicated chapter.

Adding Custom Types

When you map a field between a REST API response and ng-admin, you give it a type. This type determines how the data is displayed and edited. It is very easy to customize existing ng-admin types and add new ones.

See the Adding Custom Types dedicated chapter.

Getting Ready For Production

To build the ng-admin source with the dependencies you need, and to get hints about performance boosters, head to the Getting Ready For Production dedicated chapter.

News

Follow the marmelab blog for news about ng-admin (tutorials, plugins, new releases, etc).

You should also watch the ng-admin release page on GitHub for announcements on new releases, and complete changelog.

Support

Ng-admin is an open-source project, with a community getting larger every day. You will get help by asking politely in any the following channels:

Please give as much context as possible, including and admin configuration snippet, and the response from the API you're mapping.

Looking For a Material UI / React.js version?

marmelab/admin-on-rest, by the same team, uses a different architecture but provides a similar service: an admin GUI for REST APIs, this time with React.js, Redux, react-router, and material UI.

Contributing

Your feedback about the usage of ng-admin in your specific context is valuable, don't hesitate to open GitHub Issues for any problem or question you may have.

All contributions are welcome: please send us a Pull Request for any new feature / bug fix in your fork that you consider worth giving back.

Also, if you have some experience with ng-admin, please answer questions from newcomers in any of the support channels (see above).

Installing Dependencies

Install npm dependencies (for tests) by calling the install target:

make install

Running the example app

To test your changes, run the example app, which is bundled with a sample REST api, by calling:

make run

Then, connect to http://localhost:8000/ to browse the admin app. This task uses webpack-dev-server, which means that the browser will reload the page as soon as one file in the source is updated. This makes the blog app our preferred live testing environment.

Testing

ng-admin has unit tests (powered by karma) and end to end tests (powered by protractor). Launch the entire tests suite by calling:

make test

Tip: If you are working on Karma tests, you can prevent from relaunching the whole process by disabling single-run:

./node_modules/.bin/karma start src/javascripts/test/karma.conf.js

Releasing

Before releasing a new version, concatenate and minify the JS and CSS sources into minified scripts with:

make build
git add build
git commit -m 'update built files'
git push origin master
git tag vx.x.x
# create a new tag
git push origin --tags
# publish to npm
npm publish

Tip: Don't commit built files in Pull Requests, it forces rebases on other PRs. The core team will take care of regularly updating these built files.

License

ng-admin is licensed under the MIT Licence, and sponsored by marmelab.

ng-admin's People

Contributors

aitboudad avatar alexisjanvier avatar armellarcier avatar beevelop avatar braincrumbz avatar brikou avatar djhi avatar dunglas avatar easel avatar escapedcat avatar frankfang avatar fzaninotto avatar gregbiv avatar ihrigb avatar jeromemacias avatar jpetitcolas avatar kenegozi avatar kmaschta avatar luiscoimbra avatar manuquentin avatar marmelab-bot avatar phocea avatar popdaph avatar richardbradley avatar robinbressan avatar schmijos avatar seblours avatar sedy-bot avatar xennis avatar zyhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-admin's Issues

Problem with Edit form (0.3.3)

When i submit edit form, i have this error :
TypeError: Cannot use 'in' operator to search for 'here_the_first_field_of_the_form' in undefined
But entity is updated anyway, submit just block with this error.

Have you got an idea ?
thanks

ng-admin 0.3.2 : label is undefined

I downloaded the app (ver. 0.3.2) yesterday & Configured it but it bugged!

var user = new Entity('users');
 app.addEntity(user); 
user
    .label('Recent Users')   // does not work

angular throws this:

Uncaught Error: [$injector:modulerr] Failed to instantiate module adminApp due to:
TypeError: undefined is not a function
    at http://localhost:3000/config.js:41:8   --> points to where label(..) is defined

If I remove label(..) call, it shows the dashboard correctly.
But when I click the items on left (to list the users), angular again throws:

TypeError: undefined is not a function
    at new a (http://localhost:3000/ng-admin-app/bower_components/ng-admin/build/ng-admin.min.js:9:11646)

In the page, I see this: {{ listController.title }}

Inspecting the above ng-admin.min.js the error points to section: this.entityLabel=this.view.label()

How to get rid of it?

pagination start number?

Hi team,

This is what saw on the demo page. The start pagination number is 0, maybe it's better to change to 1? otherwise 0-10 means 11 entries in current page.
Maybe _start: (page - 1) * maxPerPage + 1 instead of _start: (page - 1) * maxPerPage, ?

snip20140928_2

Thanks

Field type file?

Hi! This project will be very useful for me, really thank you!

I Would like to know if is in your to-do list allow user to upload some kind of file in server or s3 etc etc...

I think this could be very useful :)

Thanks

API auto-discovery ?

Hi there, very good idea to share the missing AngularJS administration !

Did you think about API auto discovery ?
There's a lot of initiatives to make APIs hypermedia, such as:

That could be even more easy than describing the API in a JS file :)

Error handling

How do I handle errors from server? How do I notify ng-admin that a validation error ocurred on the server, after trying to save the model, for example? Maybe a validation that can only occur in the server.
Can I use another validation lib, other than the builtin?

Automated Field label should remove underscores

Currently, when I define a field like new Field('book'), it automatically takes the label "Book", which is good. But, when I define a field like new Field('book_author'), it automatically takes the label "Book_author", which is bad. It forces me to override the label each time I use an underscore name. I'd prefer "Book Author".

Be able to change baseApiUrl for Entity

In some cases we need to use different base api url for different entities.
Live example ( Parse.com ):

api.parse.com/1/users
api.parse.com/1/classes/CustomClass

Do we have this possibility in ng-admin?

cssClass field attribute is static and restricted to form fields

the cssClass() field attribute could be improved in two directions:

  • make it available to column fields (currently, only input fields use it)
  • pass it to ngClass instead of class to allow dynamic class according to elements in the entry.

That would allow to highlight abnormal values in a datagrid simply using CSS...

create field for object key

hello,
the db model i'm using has a 'details' object where specific user details are stored. I couldn't create a field for its items.

creating a field using 'details' as a name would show the json string of it. i tried to create a field with 'details.key', but it didn't work. Any idea?

Posting new entities does not send payload

I have a fresh project with the included config-dist.js and when I save a new entity there is no data in the request payload that goes to the server. I thought it might have just been me, but I tried on the demo at http://ng-admin.marmelab.com/ and saw the same thing, post data does not appear to get sent with the POST request when saving a new entity.

Scroll

  • Fix the double scroll (page & famous grid)
  • Slow down the famous scroll
  • Fix infinite pagination (does not work anymore with the real famous grid)
  • Fix the loader on infinite scroll
  • Bug when we scroll up to fast (?!)

Allow to override deletion message

When deleting some documents, I got "Delete documents 3?". It would be better to get name of document in this message, something like "Delete document 'Why ng-admin rocks...'?". Passing an extra parameter accepting a callback would be better.

See related source.

And what about replacing this h2 by the form title?

Moreover, it should be at singular form by default (document, not documents).

Sortable results by column

It would be cool to have a way to realtime sort the results by a selected column in both asc/desc way

Ability to override directive templates on a per-entity base

Here is my use case : for one of the entities, I'd like to update the HTML of the datagrid, to add bootstrap classes.

I would like to be able to do this in a fine-grained way:

commentEntity.addView(new ListView('comment-list')
  .templates({
    'datagrid.html': "<table><table-header></table-header></table>"
  })

I would also like to do it for the entire application, so we need some sort of cascading capability:

for each view, for each directive, use the template

  • defined in the view, or
  • defined in the application, or
  • defined in the default directive

This also implies that the templates of ng-admin's directives should be much slower, calling subdirectives that can be, in turn , easily overridden (think Twig blocks).

Paginator does not reflect filtered results

If you use the filter in the top right the paginator does not reflect the filtered results. It seems like this probably should? Screenshot of current behavior is attached.

screen shot 2014-09-16 at 4 17 41 pm

Support for complex entity nesting

It would be nice/cool if you could deep-nest entities in ng-admin when performing a save operation. As an example, with the demo data if I could embed a full tag object inside of the tags[] when I post, rather than just a collection of the ids for the included objects.

Non-number reference fields

Hello,
I am trying to use this to build a quick back-end, but my IDs are alphanumeric strings, not just integers. Is this possible to use these on reference fields?

Thanks in advance!

Allow to filter query for ReferencedList

Actually, ReferencedList, retrieve all referenced entity, and filter them client side.
It would be nice to be able to add a dynamic filter on the request to retrieve only the needed referenced entity.

Remove References Field on Dashboard

Like we can disable on Dashboard a normal Field, using .dashboard(false), there is a method to disable Reference, ReferencedList and ReferenceMany Fields on Dashboard?

Improve usage documentation

Hi.

I must say that the README is not clear enough regarding how to use this backend... A magic tool that allows anyone to build a backend interface in a couple of seconds should deserve an extensive documentation for newcomers, especially since the blog post does not match the current code base (obviously).

I suggest to add the HTML code in the README (my first attempt failed because of a missing Angular directive).

William

Strip tags when displaying wysiwyg content in list

In a previous PR (#122), I fixed the problem of wysiwyg fields being displayed as HTML the wrong way: by displaying the unescaped HTML. This prevents truncation, and exposes the admin user to XSS attacks.

The right way to do it is to display a version of the wysiwyg stripped of HTML tags, equivalent to the result of PHP's trip_tags() function.

How can I make ng-admin work?

Hello all
we must be missing something obvius, I guess. We've been through GitHub readme as well as launch post, but still it's not totally clear to us how to use ng-admin.

If we follow the launch post, it speaks about:

  1. retrieve ng-admin by cloning GitHub repo: is any destination directory ok?
  2. edit lib/config.js file: where is that/should that file be located?
  3. run grunt: from any working directory?

If we go along readme, it speaks about:

  1. retrieve ng-admin with bower: from which directory should we run that command? Is the root directory of a custom web application ok?
  2. concatenate and minify the app with grunt: from which directory? We tried, probably from wrong directory, and we got errors about missing module at ng-admin/src/javascripts/bower_components/almond/almond.js

Side note: we did run npm install from ng-admin cloned repo root directory.

Could you please give us some hint on this? Thanks for your time

bower install fails to resolve dependencies

$ bower install
... (behold the matrix) ...
Unable to find a suitable version for angular, please choose one:
    1) angular#1.2.15 which resolved to 1.2.15 and is required by angular-mocks#1.2.15, angular-scenario#1.2.15
    2) angular#1.2.24 which resolved to 1.2.24 and is required by angular-cookies#1.2.24, angular-resource#1.2.24, angular-route#1.2.24, angular-sanitize#1.2.24
    3) angular#>= 1.0.8 which resolved to 1.2.24 and is required by angular-ui-router#0.2.11
    4) angular#>=1 which resolved to 1.2.24 and is required by angular-bootstrap#0.11.0
    5) angular#~1.2.16 which resolved to 1.2.24 and is required by angular-admin
    6) angular#* which resolved to 1.2.24 and is required by restangular#1.4.0

Prefix the choice with ! to persist it to bower.json

Add Custom Element

Can we possible to add custom element on ListView, like a select for maxperpage ?
I have seen that it's possible to addField() to ListView but this function add it on all rows logicaly.
Maybe an addElement() function could be cool, to customize as we like your API instead of insert it in ng-admin.js

How to install with "yo angular"

I've scaffolded a project with yo angular, but I'm seeing some problems maybe other have already solved.:

  1. On bower install, I have to chose different versions - maybe the module's bower.json isn't up to date?
  2. It seems the js and css files aren't injected into index.html as other plugins does (see the index.html)
  3. It's un clear if for <div ui-view>, I need to bower install ui-router?

My goal is to integrate ng-admin with Drupal's RESTful module

Is it possible to nest collection list results?

Is there a way to allow for the collection returned by a collection request to be nested under a "results" property? Something akin to this:

{
  "results": []
}

Rather than just

[]

For the response?

Thanks for your help!

Allow to override the sidebar icon for each entity

The ideal would be to allow something like a menuTemplate() call in the DashboardView:

new DashboardView('book-dashboard')
  .menuTemplate('<a ng-click="sidebarController.displayList(entity, $event)"><span class="glyphicon glyphicon-pencil"></span> Books</a>')

Or does it make sense to introduce yet another view for the menu?

Edit view in row list (with collapse bootstrap)

I was working on this spec for my project, but since last update it's break. Submit button doesn't work.
Have you done some changes on routes ? I need to call another state in listView ?

Question: How do I...

I have ng-admin up and running using json-server running a copy of my data extracted to json. I'm trying to determine how to make this work with two lookup tables that are linked. That is, I have a, for example, DocumentType table that's a simple ID and Description table. I also have a DocumentSubType table that, as well as having the ID and Description fields, links back to the DocumentType table via a field named, appropriately, docTypeId. What I would like to see when looking at the list of DocumentSubTypes is the Id, Description, and DocumentType_Description. Also, when editing a DocumentSubType, I would like to see the docTypeId handled as a dropdown that displays the DocumentType Descriptions. I've tried using the Reference field type in my config, but I'm not getting the expected results. How would I go about getting this to work like I would like it to?

As a separate, but related question: In order to create new records in a table, does ng-admin only work if the ID field of a table is named 'Id" Or can the Id field be named something like 'DocSubTypeId'?

How to ignore Hateoas

My RESTful response is wrapped inside a data array.

local_d7_dev_api_v1_articles_-2

Is there a way to configure ng-admin to look into that array, thus skip Hateoas related properties?

Empty dashboard view.

Before, when no dasboard view was specified for a given entity, no list appeared on the dashboard for that entity. This allowed to have concise dashboard with only the more interesting entity.
Now we get empty list :
capture du 2014-11-20 11 13 45

Typo in readme.md

In Configuration section, where it says "will allows you" it should be "will allow you".

Also, in same section, it would be nice to break this long line of code, which causes a horizontal scrollbar in code block:

app.config(function(NgAdminConfigurationProvider, Application, Entity, Field, Reference, ReferencedList, ReferenceMany) {

Last bit: is the term edition, used in body text and in code, intended? Or could that be something like:

  • Edit form in body text
  • Editable in code

(Side note: we choose not to do a PR for this, hope that's ok.)

Refactor Fields to make them portable

Currently, a call to view.addField(field) internally calls field.setView(view). Not only is this bidirectional relationship a not-so-good practice, it also prevents the reuse of fields.

We need to refactor the way fields interact with view to avoid the dependency of field to view, and meake them portable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.