npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sails-hook-crud-admin

v0.2.2

Published

An admin for SailsJS

Downloads

3

Readme

sails-hook-crud-admin

Introduction

Hook Administrator for Sails Js. This is an installable hook that allows you to manage your models data from an admin web interface. From this interface you can perform the CRUD (Create, Read, Update, and Delete) operations on your models. It also includes an interface for managing admin users and their corresponding rights.

Goals

The purpose of this project is to provide a simple admin interface to administrate your models data.

Requirements

Sails 0.12

Getting Started

npm install sails-hook-crud-admin --save

Navigate to http://localhost:1337/administrator/ to access the admin interface.

Login with the credentials username: admin and password access@crud-2018.

alt text

Note: It is adviced to change this password as soon as you can.

Sections of the admin

Login/Signin Section

You get access to the administrator navigating to http://localhost:1337/administrator/ which will take you to the login screen if not logged in.

Login Screen

Models Dashboard

After signing in you are taken to the models dashboard where all your app models names are showed, along with their respective counts.

Models Dashboard

Permissions Dashboard

The permission models dashboard is where all the models related to user, group, access and permissions can be edited. From this dashboard you get access to the create, update and delete users and groups to control the access of your app.

Permissions Dashboard

Model Details

After clicking on one of the model box items in one of the dashboards (models or permissions) you get access to the details of the clicked model. From this screen you can see all the created instances of your model but also you can create, update and remove them.

Model Details Screen

Assets Section

You can get to this section by clicking the Assets options from the header. In this section you can upload your pictures and files, to be later consumed or used in your models. Every asset is categorized by the model it will belong to.

Assets Section

If you want one of your fields to be a picture for example, in the config file you select its renderer property for that field to be picture.

Items manipulation

Creating a new item

From your details of a model it is possible creating new instances of your model. This is pretty straightforward, you only need to click the Create button which is going to open a modal with a form to fill in.

Creating a new item

Updating an existing item

From your details of a model you can also update your existing model instances. This is pretty straightforward, you only need to click the Update button in the row of the desired item which is going to open a modal with a form in it.

Updating an existing item

Removing an existing item

From your details of a model you can also remove your existing model instances. You click the Remove button in the row of the desired item which is going to open a modal to confirm the elimination.

Removing an existing item

Users and Permissions

Adding a new group with rights

Creating a new group with rights is really easy you just need to go to the Permissions Dashboard and from there click the CRUD Group model box. This will take to its details screen where you get access to the create modal.

To create a new group, you give it a name and select the permissions it is going to have.

Assigning permissions is a pretty simple process. You check the actions options for the desired resources. The defined actions are create, update, read, delete, *. The last one (*) means any of the previous actions. The resources are defined based on the existing models of your app plus the CRUD models of the administrator.

Creating Group

Adding a new user

The process of creating a new user is simple. You just go to the Permissions Dashboard and from there click the CRUD User model box. This will take to its details screen where you get access to the create user modal.

To create a new user, you give it a name and select the groups it is going belong to.

Creating User

Configuring the Admin

Customization

To customize things like labels and texts from buttons, and your models you need to create crudAdmin.js file like following and make your desired changes. This file goes under the config directory.

/**
 * Custom configuration
 * (sails.config.crudAdmin)
*/
module.exports.crudAdmin = {
  general: {
    labels: {
      home: 'Inicio',
      actions: 'Acciones',
      createFormTitle: 'Crear item',
      updateFormTitle: 'Actualizar Item',
      removeFormTitle: 'Remover Item',
      createFormMessage: 'Crear un nuevo item',
      updateFormMessage: 'Actualizar un item existente',
      removeFormMessage: 'Esta seguro que lo quiere remover?',
    },
    buttons: {
      update: 'Actualizar',
      create: 'Crear',
      remove: 'Remover',
      seeDetails: 'Ver detalles',
    },
  },
  models: {
    author: {
      valueTemplate: '<%= author.name %>',
      label: 'Autor',
      fields: {
        name: {
          label: 'Nombre',
        },
        books: {
          label: 'Libros',
          valueTemplate: `
            <ul>
              <% _.forEach(books, function(book) { %>
                <li> <%- book.title %> </li>
              <% }); %>
            </ul>
          `
        },
        createdAt: {
          label: 'Creado'
        },
        updatedAt: {
          label: 'Actualizado'
        },
      }
    },
    book: {
      valueTemplate: '<%= book.title %>',
      label: 'Libro',
      fields: {
        title: {
          label: 'Titulo',
        },
        description: {
          renderer: 'textarea',
        },
        picture: {
          valueTemplate: `
            <% if (typeof(picture) !== "undefined") { %>
              <div>
                <img
                  src='<%= picture %>'
                  alt='Book Picture'
                  style="
                    width: 100%;
                    max-width: 100px;
                  "
                />                
              </div>
            <% } %>
          `,
          renderer: 'picture',
        },
        status: {
          label: 'Estado',
        },
        author: {
          label: 'Autor',
          valueTemplate: '<%= author.name %>',
        },
        createdAt: {
          label: 'Creado',
        },
        updatedAt: {
          label: 'Actualizado',
        },
      }
    },
  }
};

Authors

See the list of contributors who participated in this project.

Contributing

Feel free to contribute by make any suggestion to improve the project or by creating your own pull requests.