Code Monkey home page Code Monkey logo

sails-hook-cms's Introduction

Sails admin panel

Join the chat at https://gitter.im/juanpasolano/sails-hook-cms

Beaware: This hook is still in a very early stage and not in a very active development.

Why

The objective of this sails hook is to provide an easy way to create a simple CMS for your model's collections.
The hook reads the models schema to build simple CRUD operations and UI CMS.

Installation

Install using npm i sails-hook-cms and then navigate to http://localhost:1337/admin

Routes

This hooks introduces a couple of routes to your application.

  • http://localhost:1337/admin or home
  • http://localhost:1337/admin/:model A list of items
  • http://localhost:1337/admin/:model/create The form to create a new item
  • http://localhost:1337/admin/:model/edit/:modelId The form to edit an item

Options

I want this hook to work as plug and play. However if you want more control over the CMS I want to be able to provide those configurations to set things up. I decided not to make a config/cms.js file yet since I think the model declaration could serve better for grain control configuraitons.

Having for example a model Book. We can start to modify how its /admin/:model list view renders. In this case we have overrided the model.name with a label Libro and removed the createdAt and updatedAt fields.

module.exports = {
  //Setting this variable will tell the hook how to render
  cms: {
    //You can override the model name with label
    label: "Libro", 
    
    //Sometimes you dont want to put your createdAt and updatedAt
    //so we toggle them in the list view
    createdAt:false, 
    updatedAt:false,
    id:true
  },
  attributes: {
    name: 'string',
    description: 'text',
    danum: 'integer',
    dafloat: 'float',
    dadate: 'date',
    dadatetime: 'datetime',
    dabool: 'boolean',
    darray: 'array',
    dajson: 'json'
  }
};

Intentions

I would like to have a minimal API but still have a decent flexibility.
Any suggestions are welcome on the issues page or in the gitter chat room.

sails-hook-cms's People

Contributors

gitter-badger avatar juanpasolano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sails-hook-cms's Issues

crash on 'edit'

sails 0.12.1
node 5.9.0
windows 10 (also on ubuntu)

clicking edit on a line takes me to the page to edit but immediately crashes server.
very nice looking system by the way!

sails> TypeError: Cannot read property 'id' of undefined
    at $b3 (eval at <anonymous> (C:\aCode\poe\server\node_modules\sails-hook-cms
\node_modules\jade-async\lib\jade.js:98:12), <anonymous>:3:776)
    at eval (eval at <anonymous> (C:\aCode\poe\server\node_modules\sails-hook-cm
s\node_modules\jade-async\lib\jade.js:98:12), <anonymous>:3:2219)
    at C:\aCode\poe\server\node_modules\sails-hook-cms\node_modules\promise\core
.js:33:15
    at flush (C:\aCode\poe\server\node_modules\asap\asap.js:27:13)
    at _combinedTickCallback (node.js:376:9)
    at process._tickDomainCallback (node.js:431:11)

/**
 * Users.js
 */

module.exports = {

  attributes: {
    email:{type:"email"},
    active:{type:"boolean"},
    admin:{type:"boolean"},

  }
};

Missing field type support

Great plugin for sails, i just would love to have support for 3 extra field types:

  • Contenteditable field (Rich text editor)
  • Password field
  • File upload field

Object, Array, Text fields are not supported?

I have some class UnitType

module.exports = {

  attributes: {

    name : {
      type: 'string',
      defaultsTo: "Unnamed"
    },

    onlyMob: {
      type: 'boolean',
      defaultsTo: false
    },

    parent: {
      model: 'UnitType'
    },

    childs: {
      collection: 'UnitType',
      via: 'parent'
    },

    condition: { type: 'object'},

    modification : { type: 'object' },


    description : {
      type: 'text',
      defaultsTo: "Not setted yet."
    }
  }
};

As you see this class have condition, modification, description fields. But none of this fields are not display me in admin panel for create new unit
admin - google chrome 2016-05-17 23 24 12

Categorization and left column

If in the project was created too many models, top menu become too overloaded and ugly to view.

You can creaqte left menu and move models into it. It is always help to create category.
For example:
User, Role, Rules - it could be unite into "user managment" category

In models (or in config/cms.js into model description) can be added special field: cmsCategory, which could be contain name of the category

Run policies before get access

In cms.js need to add special field policies which could contain one policy or array of policies, which must be run before get access into admin panel

It allows check user authorization or user rights or do some other things assumed by developers which must to be done before getting access to admin panel

Promise is not defined

It seems that the module q its missing from the project. Also it seems to be missing the require in the file jade_helpers.js (I know it because I already fixed it in my project).

/home/cristian/IdeaProjects/sails+backbone/node_modules/sails-hook-cms/node_modules/jade-async/node_modules/promise/node_modules/asap/asap.js:45
                throw e;
                      ^
ReferenceError: Promise is not defined
  at Object.form.getElement (/home/cristian/IdeaProjects/sails+backbone/node_modules/sails-hook-cms/jade-helpers.js:93:19)
  at eval (<anonymous>:2:881)
  at $b4 (<anonymous>:2:937)
  at /home/cristian/IdeaProjects/sails+backbone/node_modules/sails-hook-cms/node_modules/jade-async/lib/runtime.js:195:33
  at /home/cristian/IdeaProjects/sails+backbone/node_modules/sails-hook-cms/node_modules/jade-async/node_modules/promise/index.js:18:19
  at flush (/home/cristian/IdeaProjects/sails+backbone/node_modules/sails-hook-cms/node_modules/jade-async/node_modules/promise/node_modules/asap/asap.js:27:13)
  at process._tickDomainCallback (node.js:459:13)

item edit/add error

While using the sails hook with sails 0.12.x, i am getting the following error:

sails-hook-cms/node_modules/asap/asap.js:45
throw e;
^

TypeError: Cannot read property 'id' of undefined
at $b3 (eval at exports.compile (/home/sailap/blog-api/node_modules/sails-hook-cms/node_modules/jade-async/lib/jade.js:98:12), :3:777)
at eval (eval at exports.compile (/home/sailap/blog-api/node_modules/sails-hook-cms/node_modules/jade-async/lib/jade.js:98:12), :3:2219)
at /home/sailap/blog-api/node_modules/sails-hook-cms/node_modules/promise/core.js:33:15
at flush (/home/sailap/blog-api/node_modules/sails-hook-cms/node_modules/asap/asap.js:27:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Getting more done in GitHub with ZenHub

Hola! @juanpasolano has created a ZenHub account for the juanpasolano organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.


How do I use ZenHub?

To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.

What can ZenHub do?

ZenHub adds a series of enhancements directly inside the GitHub UI:

  • Real-time, customizable task boards for GitHub issues;
  • Multi-Repository burndown charts, estimates, and velocity tracking based on GitHub Milestones;
  • Personal to-do lists and task prioritization;
  • Time-saving shortcuts – like a quick repo switcher, a “Move issue” button, and much more.

Add ZenHub to GitHub

Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @juanpasolano.

ZenHub Board

Importing objects from file

it's no so hard how it can be imaginate.

  • You open flie chosing form and chose file, delimeter, naming from first row, etc
  • System load first string from file if it is exists, and try to parse for the columns (get column counts and example for each column)
  • Show mapping form view
  1. first column - column numbers from file
  2. second column - example value from file (first or second row from file)
  3. third column - selector by model fields (post.text, post.name, post.id, etc.) plus unique or primary keys from connected models (post.author.id, post.author.name, etc.)
  • try to importing data from file by mapping

Mapping form could have some different view
first column - model fields (post.text, post.name, post.id, etc.) plus unique or primary keys from connected models (post.author.id, post.author.name, etc.)
second column - column numbers from file + example value from file (first or second row from file)

Hidding models in admin pannel

Some models in project must be hidden even in admin pannel.
The easest way for it

  1. add
    module.exports = { cms: false, ... }
  2. add checking special field in config/cms.js
    module.exports = { models: { modelName: false, modelName2: { field1: false, field2: false } } }

Second way is needed when models was created in node modules, which was included from npm/

Add marks for fields in view

Sometimes you should create an object and system deny to do that.
In form for creating object all fields must have to view all properties (like required, unique, etc.) for understanding reason to deny.

Although it can be more helpful before denying, because it help to understand how should be filled object fields.

For the first result could be enough add only name and value for all properties ater field name in view.
Boolean properties could be previewed only by their names
For example: (properties must have less size and color like #AAAAAA)
Username (required, unique, minlenght: 6)
Email (required, unique, mask: '/w.@w./.w{2,3}', example: '[email protected]')

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.