Git Product home page Git Product logo

generator-angular-crud's Introduction

generator-angular-crud

generator-angular-crud is a yeoman generator based on the great John Papa's hottowel generator. This generator generates the code using the Angular Style Guide written by John Papa. The generated code is based in a proven structure and conventions for developing Angular applications.

generator-angular-crud allows creating entities and CRUD operations very productively.

Currently, this generator is adapted for working with a Sails backend, although it's very easy to adapt it for working with whatever backend.

The generator allows creating entities automatically in a table form from where you can create, read, update and remove each database record.

Demo Application

You can see a demo application developed with generator-angular-crud at Angular CRUD Demo

Video Tutorial

Angular CRUD

Backend with Sails

At first place, you will have to create your API with Sails. However, when you get a list of records, Sails won't give you information regarding the total records, so you can't paginate properly. For example, if I request this: http://localhost:1337/customer, I get the following information:

[
  {
    code: 'customer 1'
  },
  {
    code: 'customer 2'
  },
  {
    code: 'customer 3'
  }
]

But if I have to paginate I need information regarding the total number of records. So, I have to override the find blueprint. To do this, you have to copy from this project the file sails/api/blueprints/find.js into your ROOT_PROJECT/api/blueprints/find.js. Now, if I request this: http://localhost:1337/customer, I will get the following information:

{
  total: 1000,
  results: [
    {
      code: 'customer 1'
    },
    {
      code: 'customer 2'
    },
    {
      code: 'customer 3'
    }
  ]
}

With this object we have all the information that we need to paginate.

Next steps that you have to do with Sails are:

  • npm install lodash --save
  • update config/models to enable the following parameter: migrate: 'alter'
  • update config/cors to set allRoutes: true and origin: '*'
  • generate your api with sails generate api

Frontend Quickstart

You will need to install generator-angular-crud:

$ npm install -g generator-angular-crud

You have to create a new folder for your project and from this folder you will generate your application:

$ yo angular-crud

Next, you will create a new feature, a customer, for example:

$ yo angular-crud:feature <customer>

This will create an AngularJS application supporting full CRUD functionality.

This subgenerator will create an entity with two properties called 'name' and 'street'. If we want to add new properties to our entity, we need to follow these steps:

  • Add new properties to the angular-formly array properties in src/client/app/feature-name/services/feature-name.form.client.service.js
  • Add new columns for the new properties in the HTML table in src/client/app/feature-name/views/list.html

TODO

  • Improve validation errors returned by the server
  • Websockets to get realtime notifications
  • Adaptors for different backends (Firebase, Backand, ...)
  • Testing

License

MIT

generator-angular-crud's People

Contributors

jlmonteagudo 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

generator-angular-crud's Issues

Use it with any rest CRUD

Hi!

This app sounds very interesting. Since I'm not using Sails, how can I do/adpat it to use it with any rest CRUD interface?

Tanks!

Postgres table names

Do I need to pluralize the resource when using a relational db? Table names as in users, processors, etc.

Problem in method GET

Hello,
I have used angular crud generator in many projects but every time the method GET didn't work ! i got an error on my server :

sans titre

Please help, it is urgent !

Problem with inserting data

It is an amazing tool but when i insert a new customer the only thing which be added in the localDiskDb is :
{
"id": 6,
"createdAt": "2016-02-23T14:08:57.656Z",
"updatedAt": "2016-02-23T14:08:57.656Z"
},
the name , address, state and country are not added i didn't understand why so what shall i do?

How can i present associations between classes

Hello,
if i have an association for example one to many between two classes 'Client' and 'Account'
in the server side in th model Client i put a collection of Account like this :

module.exports = {

attributes: {
name:'string',
lastname:'string',
accounts:{
collection:'Account',
via:'client'
}
}
};

and for the model Account i put a model of Client like this :

module.exports = {

attributes: {
numero:'string',
client:{
model:'Client'
}
}
};

but for the client side what i do ??

please i need help it is urgent !
Thank you

TypeError: actionUtil.populateEach is not a function at findRecords - api\blueprints\find.js:48:22

It is an good script but, Just by clicking on the client module item, sailsjs gives the following error:

error: Sending 500 ("Server Error") response:
TypeError: actionUtil.populateEach is not a function
at findRecords (C:\xampp\htdocs\sails\dq\Server\api\blueprints\find.js:48:22)

My model Cliente.js:
module.exports = {

attributes: {
nombre: {type: 'string'},
name: {type: 'string'},
apellido: {type: 'string'},
identificacion: {type: 'string'},
direccion: {type: 'string'},
municipio: {type: 'string'},
pais: {type: 'string'}
}
};

Problem with nested views??

I am using your project to setup an app with nested views. I have the list page working, but the links to the the detail page doesn't work. It looks like the route is not setup correctly. If I make a "normal" route by taking the dot notation out and correcting the URL/etc everything works fine.

Thoughts?

Remove a feature

Hello, this generator looks good for my project, but I'm wondering how to remove a feature?

If I need to drop a table from my structure, how do I remove the corresponding feature from my app?

Error to run app

im uploading an error file that shows my problem that is basicly

Uncaught TypeError: Cannot read property 'type' of undefined on file api-check.js line 611

am i doing somethig worng?

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.