• Search form is empty!

  • Showing posts with label service. Show all posts
    Showing posts with label service. Show all posts

    utilityService

    http://robertdunaway.github.io

    The Mashup is a learning tool that also serves as a bootstrap project for line-of-business applications.

    http://mashupjs.github.io

    The utilityService provides general utility functions to modules.

    Purpose

    Every application needs utility functions. In an effort to modularize the Mashup, general functions that can be reused are placed into utility modules.
    Utility modules begin with “utility_“.

    Two examples of utility modules are:
    - utility_LogHelper.js
    - utility_UtcDateService.js

    An application can easily have 20 or 30 module utilities and a controller might need five or six of them. To reduce dependency injection complexity, all utilities are exposed by the utility module hosted in the utilityService.

    utilityService

    Here is an example of what the utilityService looks like when exposing only two other modules.
    
    /*global mashupApp:false */
    
    mashupApp.service('utility', function (utility_UtcDateService, utility_LogHelper) {
    
        //---------------------------------------------------------------------
        // INSTRUCTIONS for 'utility' usage.
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        // Keeps like utility groups together in their own modules then reference 
        // them here and use this general utility class throughout the project.
        // This will allow for more modular, testable, code while keeping the 
        // number of dependency injected modules to minimum.
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
    
        //---------------------------------------------------------------------
        // Provides access to the utility_UtcDateService functions.
        // For converting to and from local and UTC dates.
        //---------------------------------------------------------------------
        var utcMilToLocalMil = utility_UtcDateService.utcMilToLocalMil;
        var localMilToUtcMil = utility_UtcDateService.localMilToUtcMil;
        var localDateToUtcDate = utility_UtcDateService.localDateToUtcDate;
        var utcDateToLocalDate = utility_UtcDateService.utcDateToLocalDate;
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
    
    
        var getLogObject = utility_LogHelper.getLogObject;
    
        return {
            //---------------------------------------------------------------------
            // Provides access to the utility_UtcDateService functions.
            // For converting to and from local and UTC dates.
            //---------------------------------------------------------------------
            localDateToUtcDate: localDateToUtcDate,
            utcDateToLocalDate: utcDateToLocalDate,
            localMilToUtcMil: localMilToUtcMil,
            utcMilToLocalMil: utcMilToLocalMil,
            //---------------------------------------------------------------------
            //---------------------------------------------------------------------
    
            getLogObject: getLogObject
        };
    });
    
    

    sessionService

    http://robertdunaway.github.io 

    The Mashup is a learning tool that also serves as a bootstrap project for line-of-business applications.

    The sessionService shares session information between modules.

    Purpose

    A great way to share information between modules, in Angular, is via services.

    The sessionService provides, to modules, any information they need about the user, environment, and any other session specific data modules might need.

    userSession

    Exposed by the sessionService, the userSession holds whatever information is returned by the AuthN/AuthR system chosen. The expected properties are not defined but rather inherited by whatever system is providing AuthN/AuthR services.

    var userSession = {};
     
    When this user information is retrieved by the application, the setUserSession function is called.

    The sessionService is not tasked with retrieving this information but only holding it for modules to consume.

    envSession

    Environment information is exposed by the sessionService via envSession.

    Retrieving environment information doesn’t require external access to databases or WebApi(s) so the separation of responsibilities is not too badly abused when the sessionService retrieves environmental information on its own.

    envSession is a good candidate for being modularized by a utlity_ module.

    Some user/environment session properties include:
    • browser: “Chrome 38.0.2125.101”
    • deviceType: “desktop”
    • osName: “Windows”
    • battery level
    • battery status
    • userId: “user name”
    • ADDomain
    • AuthenticationType
    • IsAnonymous
    • IsAuthenticated
    • Groups[]
    • Roles[]
    • Privileges[]
    • ActiveStatus
    • FirstName
    • LastName
    • FullName
    • Email
    • CreatedDateTime
    • CreatedBy
    • UpdatedDateTime
    • UpdatedBy
    More properties can be added as needed.