Angle Docs

AngleBootstrap 4 Admin Template + Meteor

Thank you for purchasing Angle - Bootstrap 4 Admin Template + Meteor.
If you have any question about this product and beyond the scope of this help file, please feel free to write us using the support button.


Thanks so much!

Introduction

This document aims to explain the best way to work with the product and its components.

All usage reference for Meteor can be found here https://docs.meteor.com/

- All the best and enjoy coding.

Getting started tips

  • Do not start from scratch, use an existing asset and modify it to learn how it works.
  • Explore the sources for ideas and sample code.
  • Use Firebug or Chrome Developer Tools to find bugs on your website. Using one of those tools will help you to save time analyzing the site and finding elements structure, like classes, id or tags
    • Quick tip: open your site with Chrome, press F12 and go to console tab, reload your page and if something goes wrong you will see your page errors in red text.
  • In case of errors, someone might have seen it too, you can try a Google search for a quick fix.

Technologies used

This template is based on the following technologies. Follow the links for each one of them in order to get more information:

  • The project is based on Bootstrap 4

  • Language used: JavaScript, SCSS and raw HTML

  • NPM dependency manager

Structure

Before starting to customize the template, here is the project files organization structure:

+---.meteor
+---client
+---imports
|   +---scripts
|   |   +---modules
|   +---startup
|   |   +---client
|   +---styles
|   |   +---app
|   |   |   +---charts
|   |   |   +---common
|   |   |   +---elements
|   |   |   +---extras
|   |   |   +---forms
|   |   |   +---layout
|   |   |   +---maps
|   |   |   +---tables
|   |   +---bootstrap
|   |   +---themes
|   +---templates
|       +---common
|       +---views
|           +---blog
|           +---charts
|           +---dashboard
|           +---ecommerce
|           +---elements
|           +---extras
|           +---forms
|           +---forum
|           +---maps
|           +---pages
|           +---tables
|           +---widgets
+---localize
|   +---i18n
+---public
    +---font
    +---fonts
    +---img
    +---rickshaw
    +---server
    +---themes
    +---webfonts
  • client: contains the modules loaded into the client side of the application. This folder is loaded by Meteor automatically.

    • The script client/main.js is the entry point of the application, starting at this files all application code is imported like styles, scrtipt, templates, routes and vendor plugins.
  • imports: this folder contains imported files from other parts of the application

    • startup: startup scripts to import the application, define routes and include vendor assets
    • styles: styles used in the template
    • scripts: scripts used in the template
    • templates templates files
  • localize/i18n: translation files

  • public: accessible from the client side. It contains static assets like images, fonts, etc

  • node_modules: contains the vendor assets installed with npm

Build

To run this version you need to have installed Meteor framework.

You will need also a Nodejs enviroment.

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.

Installing tools

The following steps are intended to be an orientation guide, if you are not experienced with this you will need to learn more about it from Google :)

Starting the app

Run the following command in the root folder of the project

npm install

Once above command ends, you should have all dependencies installed. Now you can run the application with the command:

meteor

To specify a port to listen on (instead of the default 3000), use --port [PORT].

To learn more about meteor command, please see here

Open your browser

If everything goes fine, your application should be ready at http://localhost:3000/ (or the port number you have used)

Usage

Layout

The main layout is defined in file imports/templates/common/layout.html

<template name="layout">
      <div class="wrapper">
         <!-- top navbar-->
         {{> topnavbar }}
         <!-- sidebar-->
         {{> sidebar }}
         <!-- offsidebar-->
         {{> offsidebar}}
         <!-- Main section-->
         <section class="section-container">
            <!-- Page content-->
            <div class="content-wrapper">
               {{> yield }}
            </div>
         </section>
         <!-- Page footer-->
         {{> footer }}
      </div>
      {{> yield region="bodyChild" }}
</template>

The yield region="bodyChild" is used to inject from any template a portion of markup directly outside the main wrapper. This is used for modals.

Horizontal layout

This layout is defined in file import/templates/common/layout.horizontal.html

This layout can be enabled using the route configuration like follows

Router.map(function() {
    this.route('dashboardh', function() {
        this.layout('layouth');
        this.render('dashboardh');
    });
});

Pages layout

This a full page layout used mainly for login, register, lock and recover views and is defined in file imports/templates/common/layout-pages.html

This layout can be enabled using the route configuration like follows

Router.map(function() {
    this.route('login', function() {
        this.render('login');
        this.layout('layoutPages');
    });
    ...

Styles

All styles are based on SCSS as a preprocessor and all files can be found under imports/styles folder

The main two files that imports the entire application are both are included in file imports/startup/client/index.js

bootstrap.scss
app.scss

Themes

Themes can be easily added directly into the file app.scss at the bottom in order to override default colors

Available options

@import "themes/theme-a.scss"
@import "themes/theme-b.scss"
@import "themes/theme-c.scss"
@import "themes/theme-d.scss"
@import "themes/theme-e.scss"
@import "themes/theme-f.scss"
@import "themes/theme-g.scss"
@import "themes/theme-h.scss"

Theme selector

The themes selector used in the right sidebar (offsidebar) uses a custom plugin. This plugin looks for an attribute to receive the path to a css stylesheet to be injected into the head section of the page.

In the demo, we link to the files under the /public/themes folder which contains the predefined theme colors already compiled in order to inject directly into the browser.

<label data-load-css="themes/theme-a.css">

Note that referencing SCSS files will not work in this case.

If you plan to use only one theme, use the above approach @importing the theme-*.scss directly into app.scss

Scripts

Scripts are divided into Template scripts and Global scripts

Global scripts are located under folder imports/scripts/modules and all of them contains functions that can be used across the entire application. Most of them are initialization functions that must be called to attach a behavior to certain elements. For example

import initSlimsSroll from '/imports/scripts/modules/slimscroll.js';
initSlimsSroll();

Template scripts are used to load a JavaScript every time a view is rendered. All this files can be found under the client/templates folder and they are named with the same name used for the view that affects.

This script uses the rendered event provided by meteor Templates object.

Template.blogArticleView.onRendered(function() {

    // Chosen select
    if ($.fn.chosen)
        $('.chosen-select').chosen();

    // Wysiwyg editor
    if ($.fn.wysiwyg)
        $('.wysiwyg').wysiwyg();

})

Vendor

All third party plugins are manage via npm using the package.json included in the root folder of the project. Then, necessary files are imported in file imports/startup/client/vendor.js you can add edit or remove path from there in order to customize the necessary vendor assets for your project.

About Rickshaw

There's a known issue related with the standard minify system of Meteor and rickshaw. The plugin requires to ignore the name change (mangle) of a variable ($super), this can not be configured in Meteor but is possible to use another technique to load rickshaw outside the meteor minifier system. The solution used for the issue mentioned is to place rickshaw.js under folder /public/rickshaw and then load it using jQuery. This code is present in file imports/templates/views/charts/rickshaw.js

// when template is ready, load rickshaw
Template.chartRickshaw.onRendered(LoadRickshaw);

// when rickshaw was loaded, start the plugin
function LoadRickshaw() {
    $.getScript('rickshaw/rickshaw.js', StartRickshawCharts);
}

function StartRickshawCharts() { ... }

Styles are still loaded globally in imports/startup/client/vendor.js Rickshaw also requires d3, which is included in the template using the atmosphere package d3js:d3

New vendor assets

To add new third party assets, you can install using npm:

  1. npm install something -S

    • Flag "-S" is to save the dependency in package.json
  2. Edit imports/startup/client/vendor.js and add the paths of files you want to use

    Note that you don't need to specify the node_modules folder

    import 'something';
    // or
    import 'something/some/file.css';
    import 'something/some/file.js';

Modernizr

Modernizr build is generated after the command npm install ends. Specifically, using the postinstall script in package.json which at the same time executes the "modernizr" scripts responsible for generating the file modernizr.js under folder public/ The configuration of the Modernizr build can be found in file modernizr-config.json

Public assets

All public assets like fonts, images, etc should be placed under the public folder. Any file under this folder is served like if it was under the root folder so for example, to serve an image you don't need to add public to the paths, just used the form

<img src="img/bg1.jpg" alt="" class="img-thumbnail img-responsive" />

Translation

Translation system uses the package tap:i18n

This package is configured using a file in the root folder of the project with the following information

{
    "helper_name": "_",
    "supported_languages": null,
    "i18n_files_route": "/localize/i18n/",
    "cdn_path": null
}

The files used for translation are placed in folder localize/i18n

To include a translated text in the markup you need to reference the json path for the string using the "helper_name" indicated in the configuration file (in this case the underscore) and a Blaze template expression. For example

<small>{{_"dashboard.WELCOME"}}</small>

This nonresponse to a JSON configuration like follows

{
  "dashboard": {
    "WELCOME": "Welcome to Angle !"
  },
....
}

jQuery and Wrapper script

Starting from version 4.1, this template doesn't need jQuery as a mandatory dependency for core files, this means it is only required when using jQuery based plugins for some features included.
Seed project versions no more include jQuery by default..

The wrapper.js (~ 7k minified) is a new script introduced to emulate some specific jQuery functions used in the template. This made possible to significantly cut the refactoring changes in the code, keeping it readable in a jQuery way and avoiding extra bytes, mainly when loops are repeatedly used to work with multiple elements.

Important The Wrapper script is NOT a replacement for jQuery. All methods were designed for an adequate and specific use and they don't do a deep validation on the arguments provided. It's suggested NOT to use this library extensively. Instead, use pure JS or you might even need jQuery.

Routes

Routes are defined in the script imports/startup/client/routes.js and uses the Iron Router package

Dahsboard routes example

// Dashboard
Router.map(function(){
    this.route('dashboardv1', function(){
        this.render('dashboardv1');
    });
    this.route('dashboardv2', function(){
        this.render('dashboardv2');
    });
    this.route('dashboardv3', function(){
        this.render('dashboardv3');
    });
});

Default route

A default route can be defined with the following script

Router.route('/', function () {
    Router.go('dashboardv1');
});    

Different layout

To use a different template layout for a view just setup the layout property when defining the route

This example renders a view using the Horizontal layout.

Router.map(function(){
    this.route('dashboardh', function(){
        this.layout('layouth');
        this.render('dashboardh');
    });
});