npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

liferay-mobile-sdk-angularjs

v0.4.0

Published

Generate AngularJS services for Liferay SDK Services and Custom Services based on Lifray SDK

Downloads

3

Readme

#Liferay Mobile SDK for AngularJS Liferay Mobile SDK for AngularJS logo

This is an implementation by XTIVIA of the Liferay Mobile SDK for any AngularJS based application. It has been tested in Chrome, Firefox, Safari. It has also been tested in Cordova for Android, iOS and Mac OSX.

##Usage To use this package as part of a front-end application simply add a bower dependency for liferay-mobile-sdk-angularjs.

    bower install --save-dev liferay-mobile-sdk-angularjs

If you require the generation of AngularJS services for custom services developed with the Liferay SDK, a nodejs module has been developed to support creation of the AngularJS services.

    npm install --save-dev liferay-mobile-sdk-angularjs

Signin to remote host

Currently this package supports basic authentication. The following is an example of how to do this in an Angular login controller.

    vm.login = function() {
       vm.authMsg = '';
    
       if(vm.loginForm.$valid) {
           SigninService
               .signin({ authenticationType: SessionService.authenticationTypes.BASIC, credentials: {username: vm.account.email, password: vm.account.password}})
               .then(function(response) {
                   $rootScope.user = response;
                   PortraitService.getPortraitUrlById(response.userId,response.portraitId,true).then(function(url) {
                      $rootScope.user.picture = url;
                      $state.go('app.dashboard');
                   });
               }, function(err) {
                   vm.authMsg = 'Server Request Error';
                   console.log(err);
               });
       }
       else {
         // set as dirty if the user click directly to login so we show the validation messages
         /*jshint -W106*/
         vm.loginForm.account_email.$dirty = true;
         vm.loginForm.account_password.$dirty = true;
       }
     };

In example above the SigninService is the included API for authentication from a single page application to a remote server. It is not required to call this service if the current session on the remote server is already authenticated via another mechanism.

Another portion of the above example calls a service called PortraitService. This is an angular service that uses existing functionality provided by the mobile sdk in conjunction with a custom service created for the application.

    (function() {
        'use strict';
    
        angular
            .module('app.mobile.demo.v62')
            .factory('PortraitService', ['SessionService','$q','SecuremobileviewService', function (SessionService,$q,SecuremobileviewService) {
                var service = {};
    
                service.getPortraitUrlById = function(userId,id,male) {
                    return $q(function(resolve, reject) {
                        if(id===0) {
                            resolve(SessionService.getImageUrlPrefix()+'/user_'+(male?'male':'female')+'_portrait?img_id='+id);
                        } else {
                            SecuremobileviewService.getUserProfileImageUrlWithUserId(userId).then(function(resp) {
                                resolve(SessionService.getImageUrlPrefix()+resp);
                            },function(err) {
                                reject(err);
                            });
                        }
                    });
                };
    
                return service;
            }]);
    })();

The SecuremobileviewService is generated in the same manner as the provided Liferay services. The gulpfile for the example application generates the AngularJS services using the following tasks.

    var builder = require('liferay-mobile-sdk-angularjs')({
     server:'http://liferaydemo.xtivia.com',
     context:'mobile-demo-integration-portlet',
     moduleName: 'app.mobile.demo',
     root: paths.scripts + 'liferay'
    });
    
    gulp.task('clean-liferay',function() {
     return del(['./js/liferay/js/*.js','./js/liferay/json/*.json']);
    });
    
    gulp.task('builder-liferay',['clean-liferay'], function() {
     return builder.generate();
    });