Code Monkey home page Code Monkey logo

foundation-angular-admin's Introduction

:: Beta release please be carefull this may contain bugs.. ::

Please feel free to open issues and submit bugs wherever you find them :D

Admin Ui Zurb Foundation and Angular Routers

This is a admin UI built on foundation zurb, angular-meteor, and angular-ui-router

Requirements

You need at the least an accounts package (for login and user management):

  meteor add accounts-password

Feel free to add as many other accounts packages as you desire.

and the roles package (for access definition and privilege separation):

  meteor add alanning:roles

and the collection2 package (for automatic schema validation and management):

meteor add aldeed:collection2

and of course the angular-meteor and angular-ui packages if you want to use the same app structure in your front end stuff, or extend the admin ui:

meteor add urigo:angular
meteor add angularui:angular-ui-router
meteor add urigo:angular-ui-router

Last, but not least, this package:

  meteor  add vimes1984:foundation-angular-admin

Setup!

You need to first require adminui in your angular app like so (typically in client/js/configs/appconfig/appinit/ap.ng.js ):

angular.module('YOURAPPNAME', ['angular-meteor', 'ui.router', 'adminui']);

Ensure that YOURAPPNAME is matched in the templates ( for example: <body ng-app="YOURAPPNAME"> ), and of course - change it to what makes sense for your application.

ROLES

We depend on Alanning's Roles package: https://github.com/alanning/meteor-roles/ and your app will need to as well. So, go ahead and install that first:

  meteor add alanning:roles

Before you are able to see the admin routes, you have to add your user to the super-admin group. Create a user and then add in the following where "id" is your newly created user id, in your SERVER side app code in server/roles.js install roles and run this:

    var SuperAdminUsers = [
      {_id: 'USER_ID_HERE'},
    ];
    Roles.addUsersToRoles(
      SuperAdminUsers,
      ['super-admin']
    );

(we will be changing this requirement soon, so that the first user will be automatically promoted to super user)

You can expand the list of available roles by adding them in your serverside roles.js file like so:

//Super admin users
var contributorUsers = [
  {_id: ''},
];
Roles.addUsersToRoles(
  contributorUsers,
  ['contributors']
);

Site Options

We have a global mongo collection registered to configure site options such as title, logo, Tagline etc etc You can access them in Blaze like so : {{site.sitename}} We currently have registerd:

  • sitename
  • slogan
  • sitedesc again you can extend the scheme on your app by following the examples given below :D

Schema

You can attach additional schema to the user or pages object by adding in:

meteor add aldeed:collection2

to your app, then in your lib/ folder create a file called schema.js and attach the additional schema like so:

var Schemas = {};
Schemas.UserProfile = new SimpleSchema({
  myfield: {
    type: String,
    optional: true
  }
});

Schemas.User = new SimpleSchema({
    profile: {
        type: Schemas.UserProfile,
        optional: true
    }
});

Meteor.users.attachSchema(Schemas.User);

Or to the pages object like so:

var Schemas = {};

Schemas.Page = new SimpleSchema({
    CustomField: {
        type: String,
        label: "Title",
        max: 200
    }
});

Pages.attachSchema(Schemas.Page);

Management

Bugs issues and the such to be tracked via gitub: https://github.com/vimes1984/foundation-angular-admin

Configuration

Angular has been configured to use [[ ]] instead of {{ }} you'd be best of to do the same on the frontend:

angular.module('myApp').config([
  '$interpolateProvider',
  function ($interpolateProvider) {
    $interpolateProvider.startSymbol('[[');
    $interpolateProvider.endSymbol(']]');
  }
]);

You can replace templates in your app by doing the following:

<template name="myadmin">
  <h2>Test</h2>
</template>

then in your Client side app somewhere:

Template.myadmin.replaces("admindashboard");

the default templates can be found in partials/

Templates in use:

  • admindashboard
  • adminmenumain
  • addpage
  • admin
  • editpage
  • edituser
  • pagescollection ( you will probably need to edit this to adapt to your own personal template)
  • pagesingle ( and this one aswell to match your own front end layoput...)

We are using http://docs.meteor.com/#/full/accounts_api so you will need to set up signin/up forms or use something like: https://atmospherejs.com/meteor/accounts-ui ...

To you can place a link to the admin like so:

  <a href="/admin/dashboard">Admin</a>

Adding additional routes

We are defining our route as

$stateProvider
    .state('admin', {
        url: '/admin',
        templateUrl: 'vimes1984_foundation-angular-admin_client/templates/admin.ng.html',
        controller: 'MainCtrl',
        resolve: {
          currentUser: ['$meteor', '$q', function($meteor, $q) {
            return $meteor.requireUser().then(function(user) {
              if(!_.contains(user.roles, 'super-admin')) {
                // fail the promise chain
                return $q.reject('FORBIDDEN');
              }
              // keep the success promise chain
              return user;
            });
          }]
        }

    })

so you can add sub admin pages like this in your routes.js file :

.state('admin.blog', {
  url: '/blog',
  templateUrl: 'path/to/template/blog.ng.html',
  controller: 'blogCtrl',
});

Then define a controller for your new view:

  angular.module('APPNAME').controller('blogCtrl', ['$scope', function($scope){
    //Define your controller here..

  }]);

Example

A fully functional basic example can be found here:

https://github.com/vimes1984/foundation-admin-ui-example

this includes basic templates on the front end with login forms and such...

foundation-angular-admin's People

Contributors

vimes1984 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mauricionr

foundation-angular-admin's Issues

Installation problem on Windows 10

When I try to install the package on Windows 10 I get the following error:

=> Errors while adding packages:

While checking for fourseven:[email protected]:
error: No compatible binary build found for this package. Contact the package author and ask them to publish it for your platform.

"View all pages" needs "add new page" button

When viewing a fresh site created with this tool, and going to the pages collection view, it would be efficient to have an "add new page" immediately available. Especially for the first page.

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.