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

ng-drupal-7-services

v2.2.7

Published

Well structured AngularJS modules mimic the architecture of Drupal Services 3.x. for your next AngularJS / Ionic Drupal Headless / Decoupled project

Downloads

33

Readme

Angular Drupal7 Services

Well structured angular modules mimic the architecture of Drupal Services 3.x

Bower version npm version
Package Quality

Angular Drupal7 Services is a REST client for AngularJS, which allows you to user predefined functions when communication with Drupal's api endpoints.
Unlike the other project focusing on the same topic, Angular Drupal7 Services is precisely organized around the Drupal Services 3.x architecture and naming conventions.

It optionally provides events next to the common used promise approach.

A full set of Drupal's resources is available, and all basic workflow's depending to authentication or helpers for CRUD operations are also provided as a set of extra modules.

##DEMOS Check out the Drupal-API-Explorer for a full demo
Or check out the sample implementation for Ionic-Headless-Drupal

Get Started

(1) Get Angular Drupal7 Services:

  • clone & build this repository
  • download as .zip
  • or via npm: by running $ npm install ng-drupal-7-services from your console
  • or via Bower: by running $ bower install ng-drupal-7-services from your console

(2) Include ng-drupal-7-services.js in your index.html.

(3) Add 'd7-services' to your main module's list of dependencies

API Documentation (!!!in progress!!!)

Quickstart

(1) Insert the ng-drupal-7-services.js bundle into your index.html file.

<!doctype html>
<html ng-app="myApp">
<head>

    <script src="bower_components/angular/angular.min.js"></script>
    <!-- ng-drupal-7-services and it's dependencies-->
    <script src="bower_components/angular-cookies/angular-cookies.min.js"></script>
    <script src="bower_components/ngstorage/ngStorage.js"></script>
    <script src="bower_components/ng-drupal-7-services/dist/ng-drupal-7-services.js"></script>

    <script>
        angular.module('myApp', ['d7-services'])
        .config(function configFunction(DrupalApiConstant) {
                		//configure your drupal instance
                		DrupalApiConstant.drupal_instance = 'http://your.projects.domain/';
                	});
    </script>
    ...
</head>
<body>
    ...
</body>
</html>

(2) Using the services.

angular
    angular.module('myApp')
    .controller('NodeController', ['NodeResource', 'NodeChannel', function(NodeResource, NodeChannel){

        //fire request
         var retrievePromis = NodeResource.retrieve({nid:1});

        //react over promise.then
        retrievePromis.then(function(data) { ... },function(error) { ... });

        //react over event
        //This could happen in another directive/controller too
        NodeChannel.subRetrieveConfirmed($scope, function(data){ ... });
        NodeChannel.subRetrieveFailed($scope, function(error){ ... });

    }]);

##Configuration Basically all configurable options are wrapped in an angular constant. So if you want to change the defaults constant values do so in angulars config phase.

  angular.module('myApp', ['d7-services'])
        .config(function configFunction(DrupalApiConstant) {
           ...
           //your changes here
           ...
        });

API configuration options

Define your drupal instance.

DrupalApiConstant.drupal_instance = 'http://your.projects.domain/';

Override the path to your api. This path is defined in "Edit Resource" under tab "Edit".

DrupalApiConstant.api_endpoint += 'v1/'; // results in "api/v1/";

Override the default response format. (json,jsonp,php,rss,xml,yaml,...) Find a list of profided fromats in "Edit Resource" under tab "Server".

DrupalApiConstant.responseFormat = "application/json";

Override the default public and private folders

DrupalApiConstant.publicFilePath = "new_public/";
DrupalApiConstant.privateFilePath = "new_private/";

Override the Drupals default path to files.

DrupalApiConstant.filesPath = "sites/default/my_files/";

Override the Drupals default image styles path.

DrupalApiConstant.imageStylesPath = "my_styles/";

Override the default image styles and add custom once.

DrupalApiConstant.imageStyles.large = 'modified_large';
DrupalApiConstant.imageStyles.new_style = 'new_style_name';

Override the default language.

DrupalApiConstant.LANGUAGE_NONE = 'und';

###Supported Drupal Modules Here is a list of supported Drupal services 3.x modules:

  • [x] Services 7 Resources | 51 Requests

  • [x] Services Views 1 Resources | 1 Requests

  • [x] Services Menu 1 Resources | 1 Requests

  • [ ] Services Search 2 Resources | 2 Requests

  • [ ] Services Entity 6 Resources | 47 Requests

  • [x] Services Definitions 1 Resources | 1 Requests

  • [x] Geocoder 1 Resources | 2 Requests

  • Drupal Services

    • Comment Resource
      • Retrieve
      • Create
      • Update
      • Delete
      • Index
      • CountAll
      • CountNew
      • Retrieve
    • File Resource
      • Retrieve
      • Create
      • Delete
      • Index
      • Create_raw
    • Node Resource
      • Retrieve
      • Create
      • Update
      • Delete
      • Index
      • Files
      • Comments
      • Attach_file
    • System Resource
      • Connect
      • Get_variable
      • Set_variable
      • Del_variable
    • TaxonomyTerm Resource
      • Retrieve
      • Create
      • Update
      • Delete
      • Index
      • SelectNodes
    • TaxonomyVocabulary Resource
      • Retrieve
      • Create
      • Update
      • Delete
      • Index
      • GetTree -User Resource
      • Retrieve
      • Create
      • Update
      • Delete
      • Index
      • Login
      • Logout
      • Token
      • Request_new_password
      • Register
      • Cancel
      • Password_reset
      • Resend_welcome_email
  • Drupal Services Views

    • Views Resource
      • Retrieve
  • Drupal Geocoder -Views Geocoder

    • Retrieve
    • Index
  • Drupal Services Menu

    • Menu Resource
      • Retrieve
  • Drupal Services Definition

    • Definition Resource
      • Index
  • Extra Resources

    • Authentication service
      • storeTokenData
      • deleteTokenData
      • refreshToken
      • storeSessionData
      • deleteSessionData
      • getConnectionState
      • setConnectionState
      • getCurrentUser
      • setCurrentUser
      • refreshConnection
      • getLastConnectTime

Extra Services

##AccessControl

  • roles
  • accessLevels
  • authorize

Directives

  • accessLevel => show hide elem based on role and acessLevel

Setup for Drupal

  • Start with a fresh Drupal7 installation.

###Services

  • install Drupal Services
  • Go to admin/structure/services/add and create a new endpoint with following settings:
    • machine name: api
    • server: REST
    • path: api
    • debug: unchecked
    • session authentication: checked
  • Then click the edit resources link and open the resources tab. Now every resource you like by check box.
  • Then click Save
  • Click the Server tab
  • For Response formatters check following:
    • json
  • For Request parsing check following:
    • application/json
    • application/x-www-form-urlencoded
    • multipart/form-data (for file upload)
    • text/xml
  • Click Save.
  • Flush all of Drupal's caches.

###Setup for CORS

  • install CORS
  • Go to admin/config/services/cors and paste following into the textarea api/v1*|<mirror>|POST,PUT,GET,DELETE|Content-Type,Authorization,X-CSRF-TOKEN|true

#Links Testing resources on a test server => https://www.drupal.org/node/1447020