Angle Docs

AngleBootstrap 4 Admin Template + NetCore + Angular

Thank you for purchasing Angle - Bootstrap 4 Admin Template + NetCore + Angular.
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 and the Angular framework.

For further reference please refer to the Angular documentation included to learn more about it.

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

Structure

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

+---Angle
    +---ClientApp
    |   +---app
    |   |   +---core
    |   |   |   +---menu
    |   |   |   +---settings
    |   |   |   +---themes
    |   |   |   +---translator
    |   |   +---layout
    |   |   |   +---footer
    |   |   |   +---header
    |   |   |   |   +---navsearch
    |   |   |   +---offsidebar
    |   |   |   +---sidebar
    |   |   |       +---userblock
    |   |   +---routes
    |   |   |   +---blog
    |   |   |   |   +---articles
    |   |   |   |   +---articleview
    |   |   |   |   +---list
    |   |   |   |   +---post
    |   |   |   +---charts
    |   |   |   |   +---chartjs
    |   |   |   |   +---flot
    |   |   |   |   +---radial
    |   |   |   +---dashboard
    |   |   |   |   +---dashboardv1
    |   |   |   |   +---dashboardv2
    |   |   |   |   +---dashboardv3
    |   |   |   +---ecommerce
    |   |   |   |   +---checkout
    |   |   |   |   +---orders
    |   |   |   |   +---orderview
    |   |   |   |   +---products
    |   |   |   |   +---productview
    |   |   |   +---elements
    |   |   |   |   +---buttons
    |   |   |   |   +---colors
    |   |   |   |   +---dropdown
    |   |   |   |   +---grid
    |   |   |   |   +---gridmasonry
    |   |   |   |   +---iconsfont
    |   |   |   |   +---iconsweather
    |   |   |   |   +---infinitescroll
    |   |   |   |   +---interaction
    |   |   |   |   +---navtree
    |   |   |   |   +---notification
    |   |   |   |   +---sortable
    |   |   |   |   +---spinners
    |   |   |   |   +---typography
    |   |   |   +---extras
    |   |   |   |   +---bugtracker
    |   |   |   |   +---calendar
    |   |   |   |   +---codeeditor
    |   |   |   |   +---contactdetails
    |   |   |   |   +---contacts
    |   |   |   |   +---faq
    |   |   |   |   +---filemanager
    |   |   |   |   +---followers
    |   |   |   |   +---forum
    |   |   |   |   |   +---forumdiscussion
    |   |   |   |   |   +---forumtopics
    |   |   |   |   +---helpcenter
    |   |   |   |   +---invoice
    |   |   |   |   +---mailbox
    |   |   |   |   |   +---compose
    |   |   |   |   |   +---folder
    |   |   |   |   |   +---view
    |   |   |   |   +---plans
    |   |   |   |   +---profile
    |   |   |   |   +---projects
    |   |   |   |   +---projectsdetails
    |   |   |   |   +---search
    |   |   |   |   +---settings
    |   |   |   |   +---socialboard
    |   |   |   |   +---teamviewer
    |   |   |   |   +---timeline
    |   |   |   |   +---todolist
    |   |   |   |   +---votelinks
    |   |   |   +---forms
    |   |   |   |   +---cropper
    |   |   |   |   +---extended
    |   |   |   |   +---standard
    |   |   |   |   +---upload
    |   |   |   |   +---validation
    |   |   |   +---home
    |   |   |   |   +---home
    |   |   |   +---maps
    |   |   |   |   +---google
    |   |   |   |   +---vector
    |   |   |   +---pages
    |   |   |   |   +---error404
    |   |   |   |   +---error500
    |   |   |   |   +---lock
    |   |   |   |   +---login
    |   |   |   |   +---maintenance
    |   |   |   |   +---recover
    |   |   |   |   +---register
    |   |   |   +---tables
    |   |   |   |   +---angulargrid
    |   |   |   |   +---datatable
    |   |   |   |   +---extended
    |   |   |   |   +---standard
    |   |   |   +---widgets
    |   |   |       +---widgets
    |   |   +---shared
    |   |       +---colors
    |   |       +---directives
    |   |       |   +---checkall
    |   |       |   +---easypiechart
    |   |       |   +---flot
    |   |       |   +---jqcloud
    |   |       |   +---now
    |   |       |   +---scrollable
    |   |       |   +---sparkline
    |   |       |   +---vectormap
    |   |       +---styles
    |   +---dist
    +---Controllers
    +---Views
    |   +---Home
    |   +---Shared
    +---wwwroot
        +---assets
        +---dist
        +---preloader

*ClientApp: *you will find the source Typescripts files and SASS files to customize the app

Controllers/Views: Those folder are standard from Visual Studio project

*wwwroot: *Here you will find public access files like assets and the distribution folder

Build

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

You can downdload runtime and sdk dependencies from Netcore Website

Make sure also to download latest .Net framework version.

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

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 dependecies 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 webpack in the background and due to this there's some expected latency until the site is visible..

Building for production

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

You can also use the following command (in the root folder of the project, where the .sln file exists) to build the project in release mode:

dotnet publish -f netcoreapp2.0 -c Release

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/

Problems loading scripts: sometimes the compilation process exceeds the time the browser waits and throws error loading files. If this happens, try reloading the page with cache refresh

Reference

We have used this links as a started guide to build the current project

- Official docs:

https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html#!#prereq3

- Guide to implement Angular2 template:

http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/

- Angular2 Template for VS:

https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ASPNETCoreTemplatePack

Usage

Layout

The theme uses a main layout to start the application and then all views are managed by Angular framework

Views/Shared/_Layout.cshtml

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>@ViewData["Title"] - Angle</title>
        <base href="/" />
        <link rel="stylesheet" href="~/preloader/preloader.css" asp-append-version="true" />
        <link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
    </head>
    <body>

        @RenderBody()

        @RenderSection("scripts", required: false)

    </body>
</html>

Views/Home/Index.cshtml

@{
    ViewData["Title"] = "App";
}

<app-root></app-root>

<div class="preloader">
    <div class="preloader-progress">
        <div class="preloader-progress-bar"></div>
    </div>
</div>

<script src="~/dist/vendor.js" asp-append-version="true"></script>
<script src="~/preloader/preloader.js" asp-append-version="true"></script>

@section scripts {
    <script src="~/dist/main-client.js" asp-append-version="true"></script>
}

This last file is what includes all files to be served as the main index of the application.

Polyfills

Polyfills are declared in file ClientApp/app/polyfills.ts Use this file to import anything necessary according to your application needs to make it work in the browser. The current imported assets are the requried to run Angular application and for es6 and IE. As you can see, this file is already included in the template.

Vendor Assets

Vendor assets are declared in the following files:

  • ClientApp/app/vendor.ts (3rd party scripts)
  • ClientApp/app/vendor.scss (3rd party styles)

Use those files to import all your 3rd party related dependencies. Webpack will automatically include them into the application.

Webapck Commands

Wepack configuration is defined in one single file, webpack.config.js. In package.json we have included two script to run webpack manually when necessary. Manually execution could be useful when you need to debug some errors that are not visible on browser console and you need a command line output.

The following commands run the same location, where package.json exists:

This command will compile the application and will generate the vendor and polyfills files, all for development.

$ npm run compile-app

This command is the same but for production environment, the production environment is configured to compile the code using the AOT compiler with scripts and styles minification

$ npm run compile-app-prod

The application is compiled in file main-client.js and lazyloaded bundle are the numerated files. All files are generated in *wwwroot/dist *folder.

Testing

Testing is based in Karma/Jasmine and can be executed using the following command in the project folder (where package.json exists)

> npm run test

Such command will start Karma and will executed all test files named *.spec.ts under the folder ClientApp/ As a convention (as used in @angular/cli) all *.spec.ts files should be placed in the same location where the component file, that is being tested, resides.

We used the following files to configure the test execution:

  • karma.conf.js: karma configuration
  • webpack.text.js: webpack configuration file for testing
  • spec.bundle.js: setup file for testing enviroment

Example test file can be located in: ClientApp/app/routes/home/home/home.component.spec.ts This contains a minimum testing code to show access to markup and component instance. More advanced testing can be performed according to your application needs. You can include more information in the Official Angular guide: here

Preloader

The preloader files can be found in folder wwwroot/preloader/

It's enabled by adding the following markup to the index file like follows

<div class="preloader">
    <div class="preloader-progress">
        <div class="preloader-progress-bar"></div>
    </div>
</div>

*Background color *

Background color can be changed be editing class .preloader in file wwwroot/preloader/preloader.scss

Image logo

To generate the loading effect with text we use two images that are the same but one fully colored and the other with a little opacity.

Both images can be found and replaced in the following paths

wwwroot/assets/img/preloader/preloader.empty.png
wwwroot/assets/img/preloader/preloader.full.png

If you change this images, try to respect the original size. Otherwise, you will need to change a bit of the css to make the expected size matches with the real one.

Note: While the preloader is included within the structure of the application, it works independently and is even required independently because it must be available from as soon as possible to show the loading screen while the application is starting.

Creating the preloader PSD

  1. Create a psd with a canvas size of 190x60
  2. Add your custom text, for example in color white, and leave the background layer transparent. Save it as png with transparency and name it preloader.full.png. The font used is "Open Sans" 45px.
  3. Duplicate the above PSD file, open and set 30% opacity to the Text layer. Save it as png with transparency and name it preloader.empty.png

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.