Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

thehyve/transmart-base-ui

 
 

Repository files navigation

Build Status codecov.io

TranSMART Glowing Bear

Boilerplate code for tranSMART UI

Demo

http://transmart-gb.thehyve.net

Pre-requisites

Make sure you have npm installed https://docs.npmjs.com/getting-started/installing-node

Usage

Run following from the project root

  • Install tools
$ npm install 
  • Install libs
$ bower install 
  • Launch browser
$ gulp serve

Use More Gulp tasks

  • gulp or gulp build to build an optimized version of your application in /dist
  • gulp serve to launch a browser sync server on your source files
  • gulp serve:dist to launch a server on your optimized application
  • gulp test to launch your unit tests with Karma
  • gulp test:auto to launch your unit tests with Karma in watch mode
  • gulp protractor to launch your e2e tests with Protractor
  • gulp protractor:dist to launch your e2e tests with Protractor on the dist files

More information on the gulp tasks in this README.md.

Configuration for development, testing and production

There are different configurations available for development, testing and production: 'dev', 'test' and 'prod'. Specify your environment by passing a parameter to gulp ('dev' is the default):

  • 'gulp --env dev serve'
  • 'gulp --env test test'
  • 'gulp --env prod build'

Directory structure

Best Practice Recommendations for Angular App Structure

The root directory generated for a app with name gulpAngular :

├──  src/
│   ├──  app/
│   │   ├──  main/
│   │   │   ├──  main.controller.js
│   │   │   ├──  main.controller.spec.js
│   │   │   └──  main.html
│   │   └──  index.js
│   │   └──  index.(css|less|scss)
│   │   └──  vendor.(css|less|scss)
│   ├──  assets/
│   │   └──  images/
│   ├──  components/
│   │   └──  navbar/
│   │   │   ├──  navbar.controller.js
│   │   │   └──  navbar.html
│   ├──  404.html
│   ├──  favico.ico
│   └──  index.html
├──  gulp/
├──  e2e/
├──  bower_components/
├──  nodes_modules/
├──  .bowerrc
├──  .editorconfig
├──  .gitignore
├──  .jshintrc
├──  bower.json
├──  gulpfile.js
├──  karma.conf.js
├──  package.json
├──  protractor.conf.js

Features included in the gulpfile

  • useref : allow configuration of your files in comments of your HTML file
  • ngAnnotate : convert simple injection to complete syntax to be minification proof
  • uglify : optimize all your JavaScript
  • csso : optimize all your CSS
  • rev : add a hash in the file names to prevent browser cache problems
  • watch : watch your source files and recompile them automatically
  • jshint : JavaScript code linter
  • imagemin : all your images will be optimized at build
  • Unit test (karma) : out of the box unit test configuration with karma
  • e2e test (protractor) : out of the box e2e test configuration with protractor
  • browser sync : full-featured development web server with livereload and devices sync
  • angular-templatecache : all HTML partials will be converted to JS to be bundled in the application
  • TODO lazy : don't process files which haven't changed when possible

Server Config

Angular html5mode is enabled to remove hashtag in the typical AngularJS application. For that reason server side rewrites is needed. Following is Apache Rewrites:

<VirtualHost *:80>
    ServerName my-app

    DocumentRoot /path/to/app

    <Directory /path/to/app>
        RewriteEngine on

        # Don't rewrite files or directories
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]

        # Rewrite everything else to index.html to allow html5 state links
        RewriteRule ^ index.html [L]
    </Directory>
</VirtualHost>

If you deploy it to another application server find the configuration here:

https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

Configuring TranSMART Endpoint

TranSMART Endpoints are defined in src/app/config.json

{
    "<environtment label>": {
        "IS_TESTING": <flag to indicate if environtment for testing or not; true/false>,        
        "IDLE_IN_MINUTES": <idle time in minutes, eg: 5>,        
        "MASTER_ENDPOINT_CONFIG": // main endpoint        
        {
            "title": <endpoint title>,
            "url": <transmart backend URL, eg: "http://127.0.0.1/transmart">,
            "apiVersion": <transmart API version, eg: "v1">,
            "isOAuth": <flag to indicate if backend supports oAuth or not; true/false>,
            "isMaster": <flag to indicate if endpoint is master or not; true/false>
        },
        "CONNECTIONS": [
            {
                "title": <endpoint title>,
                "url": <other transmart backend URL, eg: "http://foo.bar/transmart">,
                "apiVersion": <transmart API version, eg: "v1">,
                "isOAuth": <flag to indicate if backend supports oAuth or not; true/false>,
            }
            ...
        ]
    }

When an endpoint is located in different domain from Glowing Bear UI, TranSMART Backend need to enable Cross Origin Resource Sharing (CORS) so that its APIs can be consumed by Glowing Bear UI.

Enabling CORS can be achieved by allowing cross origin resource sharing on application server where TranSMART Backend is deployed or installing Grails CORS plugin in tranSMART Backend (development purpose only).

About

Boilerplate code for tranSMART UI

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 90.4%
  • HTML 6.8%
  • CSS 2.8%