Angle Docs

AngleBootstrap 4 Admin Template + MVC5

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

It assumes a minimum knowledge of Visual Studio 2017 and Asp.net technology.

- 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

  • Build system based on Gulp

Structure

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

+---Angle
    +---App_Data
    +---App_Start
    +---Content
    |   +---css
    |   +---i18n
    |   +---Images
    |   +---Json
    |   +---sass
    |       +---app
    |       |   +---charts
    |       |   +---common
    |       |   +---elements
    |       |   +---extras
    |       |   +---forms
    |       |   +---layout
    |       |   +---maps
    |       |   +---tables
    |       +---bootstrap
    |       |   +---mixins
    |       |   +---utilities
    |       +---themes
    +---Controllers
    +---Helpers
    +---Models
    +---node_modules
    +---Scripts
    |   +---custom
    |   +---modules
    |       +---charts
    |       +---common
    |       +---elements
    |       +---extras
    |       +---forms
    |       +---maps
    |       +---pages
    |       +---tables
    +---Vendor
    +---Views
        +---Account
        +---Blog
        +---Charts
        +---Dashboard
        +---Ecommerce
        +---Elements
        +---Extras
        +---Forms
        +---Forum
        +---Home
        +---Manage
        +---Maps
        +---Movies
        +---Multilevels
        +---Pages
        +---Shared
        +---Tables
        +---Widgets

Folder Content/

  • sass: here you will find the source SASS files
  • css: compiled stylesheets
  • i18n: Files for translation
  • Json: static json files used for demo
  • Images: images used in the template

Folder Scripts/ you can find the Javascript files sources

Folder Vendor/ contains vendor assets copied from node_modules folder

Build

To run this version you need to have installed the most recent version of Visual Studio 2017.**

You will need also a nodejs enviroment. The build system is based on Gulp

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 :)

Once you have all tools installed

  • Open the project with VS2017 *using the file *Angle.sln
  • Then go to Solution Explorer, right click on dependencies and select "Restore Packages"
  • Wait for the restore to end.
  • Press Ctrl+F5 to show the app on the browser.

Website preview may take some time to run depending on the machine where is executed because VS will compile the app with Gulp in the background and due to this there's some expected latency until the site is visible.

Gulp tasks

The following main tasks will take care of the compilation process

This is the default task, it will compile SASS files, concat JS with sourcemaps and will copy vendor assets listed in file vendor.json into Vendor folder

gulp Debug

This task is used for production build, will do the same like the default task and also will minify all files

gulp Release

We have named the main tasks Debug/Release so is possible to detect when the template is compiled under a certain environment to generate the right files version for such environment. This is configured in file Angle.csproj, using the Target tag.

Building for production

You can build this project for production by deploying like any other VS project.

Issues

If necessary, configure VS to use the node path installed in your system instead of the version that comes with VS, https://www.domstamand.com/synchronizing-node-version-with-your-environment-in-visual-studio-2017/

Usage

Layout

The theme uses a main layout to set the main elements, like Sidebar, Offsidebar, Header, etc. and it's the entry point of the presented structure. Each partial file used is present in the same folder.

Views/Shared/_Layout.cshtml

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="Bootstrap Admin App">
    <meta name="keywords" content="app, responsive, jquery, bootstrap, dashboard, admin">
    <title>Angle - Bootstrap Admin Template</title>
    <!-- =============== VENDOR STYLES ===============-->
    <link href="@Styles.Url("~/Vendor/@fortawesome/fontawesome-free-webfonts/css/fa-brands.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/@fortawesome/fontawesome-free-webfonts/css/fa-regular.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/@fortawesome/fontawesome-free-webfonts/css/fa-solid.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/@fortawesome/fontawesome-free-webfonts/css/fontawesome.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/simple-line-icons/css/simple-line-icons.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/animate.css/animate.css")" rel="stylesheet" />
    <link href="@Styles.Url("~/Vendor/whirl/dist/whirl.css")" rel="stylesheet" />
    <!-- =============== PAGE VENDOR STYLES =============== -->
    @if (IsSectionDefined("Styles"))
    {@RenderSection("Styles", required: false)}
    <!-- =============== BOOTSTRAP STYLES ===============-->
    <link href="@Styles.Url("~/Content/css/bootstrap.css")" rel="stylesheet" type="text/css" id="bscss" />
    <!-- =============== APP STYLES ===============-->
    <link href="@Styles.Url("~/Content/css/app.css")" rel="stylesheet" type="text/css" id="maincss" />
    <link href="@Styles.Url("~/Content/mvc-override.css")" rel="stylesheet" type="text/css" />

</head>
<body>
    <div class="wrapper">
        <!-- top navbar-->
        <header class="topnavbar-wrapper">
            @Html.Partial("_TopNavbar")
        </header>
        <!-- sidebar-->
        <aside class="aside-container">
            @Html.Partial("_Sidebar")
        </aside>
        <!-- offsidebar-->
        <aside class="offsidebar d-none">
            @Html.Partial("_Offsidebar")
        </aside>
        <!-- Main section-->
        <section class="section-container">
            <!-- Page content-->
            <div class="content-wrapper">
                @RenderBody()
            </div>
        </section>
        <!-- Page footer-->
        <footer class="footer-container">
            @Html.Partial("_Footer")
        </footer>
    </div>
    @if (IsSectionDefined("BodyArea"))
        {@RenderSection("BodyArea", required: false)}
    <!-- =============== VENDOR SCRIPTS ===============-->
    <script src="@Scripts.Url("~/Vendor/modernizr/modernizr.custom.js")"></script>
    <script src="@Scripts.Url("~/Vendor/jquery/dist/jquery.js")"></script>
    <script src="@Scripts.Url("~/vendor/popper.js/dist/umd/popper.js")"></script>
    <script src="@Scripts.Url("~/Vendor/bootstrap/dist/js/bootstrap.js")"></script>
    <script src="@Scripts.Url("~/Vendor/js-storage/js.storage.js")"></script>
    <script src="@Scripts.Url("~/Vendor/jquery.easing/jquery.easing.js")"></script>
    <script src="@Scripts.Url("~/Vendor/animo/animo.js")"></script>
    <script src="@Scripts.Url("~/Vendor/screenfull/dist/screenfull.js")"></script>
    <script src="@Scripts.Url("~/Vendor/jquery-localize/dist/jquery.localize.js")"></script>
    <!-- =============== PAGE VENDOR SCRIPTS ===============-->
    @RenderSection("scripts", required: false)
    <!-- =============== APP SCRIPTS ===============-->
    <script src="@Scripts.Url("~/Scripts/app.js")"></script>
</body>
</html>

This file app.js is generated by a concat task in the gulpfile.

Similarly, the file app.css is generating by compiling SASS style-sheets with gulp.

The "BodyArea" section can be used to add code directly as a body child, like for example with modasl which needs to be placed outside the layout structure in order to overlap content with the backdrop.

Finally, the @RenderBody() section is where each of the rest of the Views content is placed once the template is served.

Environments

As you can not, we haven't used Bundles to includes application or vendor assets in the template. There's no Bundles declared in BundleConfig.cs and this is due to this project handles environment compilation using Gulp.

Since we use Gulp to compile assets based on the environment, it will automatically compress for production, which means that on a production release the files served will be automatically optimized.

In other words, with this setup it's not required to use Bundles that are optimized for production releases, instead Gulp will automatically build assets depending on the environment.

This approach is more suitable for integrating modern web technologies and also provides a quick and easy method to stay compatible with latest web features. Said that, Bundles are still available and can be used as usual within this project.

Other layouts

The page layout. uses the @RenderBody() to include the page content within the main wrapper, using different layout files you can change how each View is presented, for example for user pages, like login, register, etc, and variants like the horizontal layout.

Angle/Views/Shared/_LayoutPage.cshtml

To enable this layout, you can check the file under the folder VIews/Pages. Basically, they redeclare the layout option with

@{    Layout = "~/Views/Shared/_LayoutPage.cshtml";}

Layout horizontal

This layout is placed in file Angle/Views/Shared/_LayoutHorizontal.cshtml and can be used adding the following at the top of the view

@{    Layout = "~/Views/Shared/_LayoutHorizontal.cshtml";}

The horizontal layout use a different version of the topnavbar because is doesn't have a sidebar and instead it shows the menu entries in the header area.

New vendor assets

To add new third party assets, you can install using npm and the reference in the vendor.json file

  1. npm install something -S

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

    "node_modules/something/some/file.js",
    "node_modules/something/some/file.css",
    "node_modules/something/some/**/*",

    Note that you can use wild-cards when you need for example copy a set of images or fonts files.

  3. Finally, reference the new files in the template. For example,

    @section Scripts {
        <script src="~/Vendor/something/some/file.js"></script>
    }
    @section Styles {
        <link href="~/Vendor/something/some/file.css" rel="stylesheet" />
    }

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" responsible for generating the file modernizr.custom.js under folder node_modules/modernizr. This way we can use modernizr script as if it was a standard package from npm. The configuration of the Modernizr build can be found in file modernizr-config.json

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.

Movies App

The Movies app included only on MVC5 demo and seed project works on Visual Studio 2017 using MVC, Entity Framework, and ASP.NET Scaffolding,

You can create a web application that provides an interface to an existing database table. This demo shows you how to automatically generate code that enables users to display, edit, create, and delete data that resides on the database. The generated code corresponds to the columns in the database table. This demo focuses on using ASP.NET Scaffolding to generate the controllers and views.

We have followed an excellent tutorial by João Eduardo Sousa by adding a few changes to the auto-generated view in order to match the expected markup. We have also copied some steps from the original tutorial to give you a quick reference

Tutorial

STEP 1 - Create class

Add a new class to the project (this class represents a table, and the properties the colums of that table)

Give a name to that class (in my sample I call him MoviesModel)

On the class create the following code:

public class Movie
{
    public int ID { get; set; }
    public string Title { get; set; }
    public DateTime ReleaseDate { get; set; }
    public string Genre { get; set; }
    public decimal Price { get; set; }
}

public class MovieDBContext : DbContext
{
    public DbSet<Movie> Movies { get; set; }
}

Put the class inside the Models folders, just to organize your code.

Note that the class propertie ID is used as primary key

STEP 2 - Create controller with views using Entity Framework

Add new Scaffolded to the project (new item existent on MVC5)

img

Choose option MVC5 Controller with views using Entity Framework

img

Click Add

If you receive an error, it may be because you did not build the project in the previous section. If so, try building the project, and then add the scaffolded item again.

After the code generation process is complete, you will see a new controller and views in your project.

STEP 3 - Controller and Views Generation

a. You will see now the Controller was automatically created with CRUD operations

b. And the Views were also automatically created

img

STEP 4 - Run the application

If everything went fine, you should be able to run the application, but check you have included an entry in the sidebar to link to the new views.

img