Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Example for Materializecss and Semantic-ui #30

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions example-admin-materializecss-sidemenu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Admin panel sidemenu example with materializecss (http://materializecss.com/)
============================================================================

This example shows the usage of sidemenu layout and component.

This input file for <a href="http://www.meteorkitchen.com" target="_blank">Meteor Kitchen</a> will build meteor application with user account system and admin panel.

To generate and run application, inside this directory type:

```
meteor-kitchen ./example-admin-materializecss-sidemenu.json ./example-admin-materializecss-sidemenu
cd ./example-admin-materializecss-sidemenu
meteor
```

**JSON** and **YAML** files are the same example in different formats.

Meteor-kitchen natively supports input files written in **JSON**. To use the **YAML** example you'll need to have <a href="https://www.npmjs.com/package/yaml-js" target="_blank">js-yaml</a> converter installed. The following is the most common example of how to accomplish this:

```
npm install -g js-yaml
```

How to use application
----------------------

When you start the application and register, your user account will have role "user" by default and you will not be able to see admin panel.

To make yourself admin, you first need to find your user ID. Open mongo shell and type:

```
db.users.find().pretty()
```

Copy your user id and then type:

```
db.users.update({ _id: "YOUR_USER_ID" }, { $set: { roles: ["admin"] } })
```

Now, you have admin panel in your application and you can manage users.

This example has three user roles:

- `user` can login but cannot access admin panel

- `admin` can access admin panel

- `blocked` user is blocked and cannot login

That's it :)
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
{
"application": {
"title": "Example application",
"frontend": "materialize",
"roles": [ "admin", "user" ],
"default_role": "user",
"send_verification_email": true,

"collections": [
{
"name": "customers"
}
],

"queries": [
{
"name": "admin_users",
"collection": "users",
"filter": {}
},
{
"name": "admin_user",
"collection": "users",
"filter": { "_id": ":userId" },
"find_one": true
},
{
"name": "users_null",
"collection": "users",
"filter": { "_id": null },
"find_one": true
},
{
"name": "current_user_data",
"collection": "users",
"filter": { "_id": "Meteor.userId()" },
"find_one": true
}
],

"public_zone": {
"layout": "sidemenu",
"pages": [
{
"name": "home_public",
"title": "",
"components": [
{
"name": "home_jumbotron",
"title": "Example application",
"type": "jumbotron",
"text": "<b>This is example application built with <a href=\"http://www.meteorkitchen.com\" target=\"_blank\">meteor-kitchen</a> code generator without manual coding.</b><br />It demonstrates simple application with user account system and admin panel.<br />Source code (input file for generator) is <a href=\"https://github.com/perak/kitchen-examples/tree/master/example-admin\" target=\"_blank\">here</a>.",
"button_title": "Continue &raquo;",
"button_route": "login"
}
]
},
{ "name": "login", "template": "login" },
{ "name": "register", "template": "register" },
{ "name": "verify_email", "template": "verify_email", "route_params": ["verifyEmailToken"] },
{ "name": "forgot_password", "template": "forgot_password" },
{ "name": "reset_password", "template": "reset_password", "route_params": ["resetPasswordToken"] }
],

"components": [
{
"name": "left_menu",
"type": "menu",
"template":"sidemenu",
"class": "",
"title": "Left menu",
"dest_selector": "#menu",
"items": [
{ "title": "Home", "route": "home_public","icon_class":"store" }
]
},

{
"name": "right_menu",
"type": "menu",
"template":"sidemenu",
"class": "",
"dest_selector": "#menu",
"title": "Right menu",
"items": [
{ "title": "Register", "route": "register","icon_class":"assignment_ind" },
{ "title": "Login", "route": "login","icon_class":"lock_open" }
]
}
]
},

"private_zone": {
"layout":"sidemenu",
"pages": [
{ "name": "home_private", "title": "Welcome {{userFullName}}!" },


{
"name": "admin",
"roles": ["admin"],
"pages": [
{
"name": "users",
"components": [
{
"name": "view",
"type": "data_view",
"title": "Users",
"text_if_empty": "No users yet",
"query_name": "admin_users",
"query_params": [],

"fields": [
{ "name": "profile.name", "title": "Name"},
{ "name": "profile.email", "title": "E-mail" },
{ "name": "roles", "title": "Role" }
],

"insert_route": "admin.users.insert",

"edit_route": "admin.users.edit",
"edit_route_params": [
{ "name": "userId", "value": "this._id" }
],

"details_route": "admin.users.details",
"details_route_params": [
{ "name": "userId", "value": "this._id" }
]
}
],
"pages": [
{
"name": "details",
"route_params": ["userId"],
"components": [
{
"name": "details_form",
"type": "form",
"mode": "read_only",
"title": "User details",
"query_name": "admin_user",
"query_params": [],
"fields": [
{ "name": "profile.name", "title": "Name"},
{ "name": "profile.email", "title": "E-mail", "type": "email" },
{ "name": "roles", "title": "Role" }
],
"close_route": "admin.users",
"back_route": "admin.users"
}
]
},
{
"name": "insert",
"components": [
{
"name": "insert_form",
"type": "form",
"mode": "insert",
"title": "Add new user",
"submit_route": "admin.users",
"cancel_route": "admin.users",
"query_name": "users_null",
"query_params": [],
"fields": [
{ "name": "profile.name", "title": "Name", "required": true },
{ "name": "profile.email", "title": "E-mail", "type": "email", "required": true },
{ "name": "password", "title": "Password", "input": "password", "required": true }
]
}
]
},
{
"name": "edit",
"route_params": ["userId"],
"components": [
{
"name": "edit_form",
"type": "form",
"mode": "update",
"title": "Edit user",
"submit_route": "admin.users",
"cancel_route": "admin.users",
"query_name": "admin_user",
"query_params": [],
"fields": [
{ "name": "profile.name", "title": "Name", "required": true },
{ "name": "profile.email", "title": "E-mail", "type": "email", "required": true },
{
"name": "roles",
"type": "array",
"title": "Role",
"input": "radio",
"input_items": [
{ "value": "user", "title": "User" },
{ "value": "admin", "title": "Admin" },
{ "value": "blocked", "title": "Blocked" }
]
}
]
}
]
}
]
}

],

"components": [
{
"name": "side_menu",
"type": "menu",
"class": "nav nav-stacked nav-pills",
"items": [
{ "title": "Users", "route": "admin.users" }
]
}
]
},

{
"name": "user_settings",
"roles": ["user", "admin"],
"pages": [
{
"name": "profile",
"components": [
{
"name": "edit_form",
"type": "form",
"mode": "update",
"title": "Edit your profile",
"submit_route": "user_settings.profile",
"query_name": "current_user_data",
"query_params": [],
"fields": [
{ "name": "profile.name", "title": "Name", "required": true },
{ "name": "profile.email", "title": "E-mail", "type": "email", "required": true },
{ "name": "profile.facebook", "title": "Facebook URL" },
{ "name": "profile.google", "title": "Google+ URL" },
{ "name": "profile.twitter", "title": "Twitter ID" },
{ "name": "profile.website", "title": "Website URL" }
]
}
]
},

{ "name": "change_pass", "template": "change_pass" }
],

"components": [
{
"name": "side_menu",
"type": "menu",
"class": "ui vertical menu",
"items": [
{ "title": "Profile", "route": "user_settings.profile" },
{ "title": "Change password", "route": "user_settings.change_pass" }
]
}
]
},

{ "name": "logout", "template": "logout" }
],

"components": [
{
"name": "left_menu",
"type": "menu",
"title": "Left menu",
"template":"sidemenu",
"class": "",
"dest_selector": "#menu",
"items": [
{ "title": "Home", "route": "home_private", "icon_class": "home" }
]
},
{
"name": "right_menu",
"type": "menu",
"title": "Right menu",
"template":"sidemenu",
"class": "",
"dest_selector": "#menu",
"items": [
{ "title": "Admin", "route": "admin", "icon_class": "brightness_auto" },
{ "title": "Settings", "route": "user_settings","icon_class":"settings" },
{ "title": "Logout", "route": "logout","icon_class":"power_settings_new" }
]
}
]
}
}
}
Loading