Isolated, customizable admin panel for Meteor
MIT License
An isolated, customizable admin panel for Meteor
Version 0.5.0 has been completely rewritten to take advantage of new Meteor features and is not backwards compatible.
Requires Meteor 1.8 or newer
Pure Admin was designed to not interfere with your app:
On its own, Pure Admin doesn't do much. It mostly creates the UI and provides some api's for other packages or your app to build on top of. It makes very few assumptions about how your app works. For example, overriding the PureAdmin.isAdmin
function removes all dependencies on Mongo.
meteor add zodern:pure-admin
PureAdmin.show()
in your client code, for example in a route handler for /admin
Pure Admin on it's own doesn't do much. You can add packages to extend the functionality.
Available Packages
Ideas for packages
PureAdmin.isAdmin
Returns true if the user is an admin. The function can be overridden before Meteor.startup to use custom logic for deciding who is an admin.
PureAdmin.isAdmin = function(userId) {
return Meteor.users.findOne({_id: userId}).isAdmin || false
}
If you do not set this, it defaults to:
_PureAdmin-Admins
PureAdmin.isAdmin
is made an admin{user: "userIdOfAdmin"}
.PureAdmin.addPage({name: 'pageName', render(utils, props, contentEl) => {}, title(props) => 'title'})
Adds a page. When it is shown, render
is passed:
utils
which is an object with:
renderSvelte(svelteComponent)
Renders a svelte component, passing props
as data, and listening to the goTo
event. A goTo
event can be dispatched instead of calling PureAdmin.goTo
To override the default blank dashboard, add a page named Dashboard
.
PureAdmin.addMenuItem({ name: 'string', section: 'section', page: 'pageName' })
PureAdmin.addMenuItem({ name: 'string', section: 'section', page: 'pageName', pageProps: {} })
PureAdmin.addMenuItem({ name: 'string', section: 'section', url: 'https://website.com' })
Adds a menu item to the side bar. If page
is provided, it is shown when selected with pageProps
. Otherwise, the url in url
is opened in a new tab.
Pages are grouped by section
. Pages without a section are shown together at the top of the list.
PureAdmin.goTo('pageName');
PureAdmin.goTo({page: 'pageName', props: {}});
Shows the page.
PureAdmin.addCss('css string')
Due to the use of shadow DOM, css outside of the the admin panel is not inherited by it. CSS added with addCss
is put inside of a <styled>
element in the shadow dom. Another option is to use inline styles.
PureAdmin.onInit(function () {})
These functions are run when the admin panel is opened. They can be used to dynamically import the files that configure Pure Admin.
PureAdmin.show()
Shows the admin panel
PureAdmin.hide()
Not implemented.
FlowRouter
or with a keyboard shortcut