Angle Docs

AngleBootstrap 4 Admin Template + Vue

Thank you for purchasing Angle - Bootstrap 4 Admin Template + Vue.
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 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.

Important Opening the index.html with a double click (i.e. using file:// protocol) will show you only a blank page because there’s no server that response to the requests made for each view in order to display the app interface.

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 Vue and Bootstrap
  • The environment was created using vue-cli tool
  • Language used: JavaScript, SCSS and HTML
  • Bootstrap support by Bootstrap Vue
  • Supports state management with VUEX

Structure

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

+---public
|   +---img
|   +---locales
|   +---server
|   +---themes
+---src
    +---assets
    +---components
    |   +---Charts
    |   +---Common
    |   +---Layout
    |   +---Maps
    |   +---Tables
    +---store
    |   +---modules
    |   +---plugins
    +---styles
    |   +---app
    |   |   +---charts
    |   |   +---common
    |   |   +---elements
    |   |   +---extras
    |   |   +---forms
    |   |   +---layout
    |   |   +---maps
    |   |   +---tables
    |   +---bootstrap
    |   +---themes
    +---views
        +---Blog
        +---Charts
        +---Dashboard
        +---Ecommerce
        +---Elements
        +---Extras
        +---Forms
        +---Forum
        +---Maps
        +---Pages
        +---Tables
        +---Widgets

This structure is based on the provided by the vue-cli project. There are more files in the structure, we will list the main files in order to describe the application workflow based on the order they are imported.

The application is bootstrapped in file public/index.html, this file will include the main application files compiled.

The application main file is src/main.js and it imports the App module and other global modules, like the router, translation, etc.

The file App.js is where the main App module is defined and is used as the root element that starts the application.

Routes are defined in file router.js that imports all components that are related to views displayed from the sidebar links.

vendor.js imports global dependencies like modernizr, styles, icon fonts, etc.

The store folder is where the application state is defined. See below for more details about the content of this folder.

Components

This folder contains components used in views. The 'views' folder contains component that represent the content displayed for each route. Components in 'views' folder imports and use components from 'components' folder.

Component Description
Charts Components used for the Chart views
Common Common components used by other components
Layout Components used as a base to build the app layout
Maps Components used for the Maps views
Tables Components used for the Tables views

Build

Installing tools

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

Once you have all tools installed

  • Open a console/terminal and run npm install to install application dependencies

  • Finally run npm run serve to start the application development server.

If everything goes fine, you should see the messages in the terminal telling you the application has been compiled and the server is running.

Open your browser and go to http://localhost:8080

Building for production

The following will compile the application for the production:

npm run build

This will generate the compiled files under the folder dist

Check the User Guide online to know more about the vue-cli project.

If your application is not served from the root, before compilation, set the environment variable VUE_BASE_URL and then run compilation.

Example:

If your app is served from http://example.com/some/path then use:

set VUE_BASE_URL=/some/path
npm run build

Usage

Adding new components

You can add new components by adding a new folder in src/components

For example, src/components/MyComp

Then create there a new file named MyComp.vue with the component code.

For example,

<template>
    <div>...</div>
</template>

<script>
    export default {
        ...
    }
</script>

<styles>
    ...
</styles>

Adding new routes

If the component is associated to a route you need to create the component under the 'views' folder.

For a view component you will use a template structure like this:

<template>
    <ContentWrapper>
        ... view content here
    </ContentWrapper>
</template>

You will need now to make the new component accessible to the application by adding a route that loads the component. To do that open routes.js and import the component and add a new route entry following the required structure by Vue Router

import MyComp from '@/views/MyComp/MyComp.vue';
...
export default new Router({
    ...
    routes: [
        ...
        {
            path: '/mycomp',
            component: Mycomp
        },
...

Check other routes in the project to see where to add the route entry correctly.

Finally, you need to add an entry in order to provide a link for the new route created.

To do that, add in src/menu.js a new menu entry with the information for your menu.

Example

const Menu = [
    /* heading elements */
    {
        // text to show
        heading: 'Heading Text',
        // translation key
        translate: 'sidebar.heading.KEY'
    },
    /* menu items elements */
    {
        // text to show
        name: 'Item Text',
        // class name to show icon
        icon: 'icon-class',
        // route path (not used on items with submenu)
        path: 'routepath',
        // translation key
        translate: 'sidebar.item.KEY',
        // shows a Badge right next to the text
        label: { value: 10, color: 'success' },
        // list of submenu items
        submenu: [{
                ... Same format as menu items
            }
    }
    ...

Vendor assets

Vendor assets can be installed using the Node Package Manager (npm). The following command shows how to install a package so it becomes part of the project

npm install package-name --save

If you don't add the --save flag, the package won't be saved as a dependecy in package.json and it will be only available in your local project.

Once the command ends, files will be available in the node_modules folder and ready to be imported into your application code.

If the package is used globally you can import files using the file Vendor.js

To use a package locally in your new component, you can import the files directly into the code in your component file.

Layout classes

Layout can be changed via the following classed applied to the body tag:

Class name Description
.layout-fixed Makes navbars become fixed while the user can scroll only content
.layout-boxed Limits the width of the main wrapper element
.aside-collapsed Condenses the sidebar showing only icons
.aside-collapsed-text Condenses the sidebar showing icons and Text
.aside-toggle used internally for mobiles to hide the sidebar off screen
.offsidebar-open used internally to display the offsidebar component (formally the right sidebar)

Translation

The translation system uses the i18next module.

The file src/i18n.js contains the setup for the module and what it does is to load the translations files located under folder public/locales

This modules simplifies the translation system by loading translate references from a JSON file and replacing the content where the reference has been used.

Example

<small>{{$t("dashboard.WELCOME")}}</small>

Where the i18key values corresponds to an entry in each json file according the current language selected.

Horizontal Menu

To use the horizontal menu in a route, you need to declare that route as a child of the the LayoutHorizontal component, like this

{
    path: '/',
    component: LayoutHorizontal,
    children: [
        // Dashboard
        {
            path: '/dashboardh',
            component: DashboardH
        }
    ]
},

The menu of the horizontal header is declared in file src/components/Layout/HeaderHorizontal.vue and is limited to a few entries for demo purposes only.

RTL

RTL is based on rtlcss plugin using a custom postcss plugin that allows to change the application styles into an RTL representation.

To enable RTL open the file .postcssrc.js and uncommment the line that uses the rtlcss-plugin, like this:

module.exports = {
    plugins: {
        autoprefixer: {},
        // Uncomment this line to enable RTL
        [postcssRtlcssPlugin]: {}
    }
}

The plugin is defined in file postcss-rtlcss-plugin.js and it simply passes the styles content through the rtlcss parser.

Seed Project

This project is an application skeleton. You can use it to quickly bootstrap your VUE projects and dev environment for these projects. The seed app doesn't do much and has most of the feature removed so you can add them as per your needs just following the full-features version as example.

This project is provided in order to start with the template using a different approach. Usually, templates will come with all features working and you need to remove them one by one in the way you don't need them. With the seed project you can start adding custom features and others from the full project to make grow your app. Since the files and structure is the same for the full and seed versions, you can save time using comparison tools that allows to apply changes from full features project into the seed project.

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.

Vuex

We have used Vuex mainly to manage application settings to change the layout options and themes. It's organized using modules so you can easily remove provided modules or add more modules according to your application needs.

Vuex files are placed under src/store folder. In this folder you will find the following files:

+---store
    +---modules
    |   +---setting.js
    |   +---theme.js
    +---plugins
    |   +---setting.js
    |   +---theme.js
    +---index.js

The file index.js is imported into the App.vue file which makes the store parts of the application. Removing that import will remove Vuex from the project automatically.

<script>
    import store from './store/index.js'

    export default {
        name: 'App',
        store
    }
</script>

We have created modules for settings which contains state of the current layout options, like fixed, boxed, sidebar collapsed, and also the toggle for sidebar offcanvas on mobile and the sidebar user block. And for themes, which contains a single state with the current theme selected.

We have also used plugins in order to hook into the vuex lifecycle to change the classes from dom elements (mainly body) and to change active the theme.

The main use of Vuex is done in the Offsidebar component, which provides the demo for layout settings and themes, in file src/components/Layout/Offsidebar.vue.

Persisted states

In order to save the settings selected and the active theme, we have used a Vuex plugin named vuex-persistedstate. This plugin automatically save the entire application state to the browser storage, and restores it when the app loads.

Since not all state are suitable to be saved, we have used a black list that prevent some state to be saved, for example, the state used to toggle the sidebar on mobile. You will the code to do this in file store/index.js and it look like this

createPersistedState({
    reducer: (persistedState) => {
        const stateFilter = JSON.parse(JSON.stringify(persistedState)); // deep clone
        ['offsidebarOpen', 'asideToggled', 'horizontal'] // states which we don't want to persist.
            .forEach(item => delete stateFilter.setting[item])
        return stateFilter
    }
}),

You can see the plugin website here for more options to prevent state saving.