How To
Documentation
    Learn More

      $twigkit

      Description

      Twigkit factory with methods for accessing the Twigkit API.

      Methods

      • cancelAllResponses()

        Fires an event to cancel the current response being requested from the backend.

        Example

        $twigkit.cancelAllResponses();

      • deleteBookmark(id)

        Sends a request to delete a bookmark to the API.

        Parameters
        ParamTypeDetails
        idstring

        The id of the bookmark to delete.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.deleteBookmark(id);

      • deleteComment(platform, id)

        Sends a request to delete a comment to the API.

        Parameters
        ParamTypeDetails
        platformObject

        The platform object (retrievable from Platform Service).

        idstring

        The id of the comment to delete.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.deleteComment(platform, id);

      • deleteLike(platform, id)

        Sends a request to delete a like to the API.

        Parameters
        ParamTypeDetails
        platformObject

        The platform object (retrievable from Platform Service).

        idstring

        The id of the bookmark to delete.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.deleteLike(platform,id);

      • deleteSavedQuery(id)

        Sends a request to delete a saved query to the API.

        Parameters
        ParamTypeDetails
        idstring

        The id of the saved query to delete.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.deleteSavedQuery(id);

      • deleteTopic(id)

        Sends a request to delete a topic to the API.

        Parameters
        ParamTypeDetails
        idstring

        The id of the topic to delete.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.deleteTopic(id);

      • getComments(platform, target, collection, topic)

        Sends a request to get comments from the API.

        Parameters
        ParamTypeDetails
        platformObject

        The platform object (retrievable from Platform Service).

        target
        (optional)
        string

        Returns all comments that apply to the specified target document.

        collection
        (optional)
        string
        topic
        (optional)
        string
        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.getComments(platform, target);

      • getConstant(defaultValue)

        Gets a constant declared to the lightning module.

        A constant can be added to your application like so

        angular
        .module('lightning').constant('contextPath', 'My Constant Value');
        

        You can then get this value in your controller and apply it to the scope or rootScope (if applied to the rootScope you can use {{$root.myConstant}} in your views.

        angular.module('twigkitLightApp')
        .controller('MainCtrl', ['$scope', '$stateParams','$twigkit', function ($scope, $stateParams,$twigkit) {
          $scope.params = $stateParams;
          $scope.test123 = $twigkit.getConstant('test','No 123 Found Here');
          $rootScope.test = $twigkit.getConstant('test','');
          }]);
        
        Parameters
        ParamTypeDetails
        defaultValuestring

        Value to be returned if context path does not exist.

        Returns
        string

        Returns the constant value.

        Example

        $twigkit.getConstant(defaultValue);

      • getContextPath(defaultValue)

        Gets the context path if it is available.

        Parameters
        ParamTypeDetails
        defaultValue
        (optional)
        string

        Value to be returned if context path does not exist. Defaults to '/'

        Returns
        string

        Returns a string of the context path or the default value.

        Example

        $twigkit.getContextPath(defaultValue);

      • getGraphFacet(query, platform, source-field, target-field, measure, measure-field)

        Gets graph data for a facet

        Parameters
        ParamTypeDetails
        querystring

        The query to use against the platform.

        platformstring

        The name of the platform to use.

        source-fieldstring

        Name of a primary field to facet on (for example "Country"). The values of this facet will define the set of graph nodes with outgoing edges.

        target-fieldstring

        Name of a secondary field to facet on (for example "City"), for every facet value of the primary field. The values of this facet will define the set of graph nodes with incoming edges. For example, say the primary facet (source-field) has values for Country=Germany and Country=France and the secondary facet (target-field) has values for City=Berlin, City=Munich and City=Paris. Then we add graph edges Germany-->Berlin, Germany-->Munich and France-->Paris.

        measure
        (optional)
        string

        Name of a numerical measure that defines the weight of each graph edge. When omitted, this defaults to the counts of the facets defined by the target-field. Some possible measures include "sum", "mean" and "min". (Only applicable if not using data attribute).

        measure-field
        (optional)
        string

        Field to measure, when the "measure" option is specified.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.getGraphFacet('query', 'platform', 'facet');

      • getLikes(options)

        Sends a request to get a likes from the API.

        Parameters
        ParamTypeDetails
        optionsObject

        Object containing options to be sent in the get request. Like target, collection, topic etc.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.getLikes(options);

      • getUser()

        Calls the Twigkit API to return the current user

        To enable this you need to make sure that your security.conf file contains the line webservice-enabled: true

        Your security.conf file can be found in 'resources/conf/security/security.conf'.

        For spring security you will need the following rule to allow access to the user api, if parts of the site are public.

        <intercept-url pattern="/twigkit/api/user" access="isAnonymous() or isAuthenticated()"/>

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.getUser();

      • onCancelAllResponses(callback, scope)

        When the cancel response event is fired the callback function will be called.

        Parameters
        ParamTypeDetails
        callbackFunction

        The function to be called when the cancel event is fired.

        scopeObject

        The $scope object for unsubscribing to the event when the scope is destroyed.

        Example

        $twigkit.onCancelAllResponses(function () {
         console.log('Responses have been cancelled');
        }, $scope);
        $twigkit.cancelAllResponses();
        
      • postLike(platform, id, target, topic, collection)

        Sends a request to create a like to the API.

        Parameters
        ParamTypeDetails
        platformObject

        The platform object (retrievable from Platform Service).

        idstring

        The id of the bookmark to delete.

        targetstring

        A unique identifier for a document that is being bookmarked. Example values: document123 Maximum length: 2083 characters

        topic
        (optional)
        number

        A topic to which the new bookmark should belong.

        collection
        (optional)
        string

        The collection to which the target document belongs.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.postLike(platform, id, target, topic, collection);

      • searchFacet(facet, platform, query, rpp, facetQuery, removeFilters, facetField, wildcard, canceller)

        Calls the Twigkit API to return filters from a specific facet based on the searchQuery.

        Parameters
        ParamTypeDetails
        facetstring

        The name of the facet to search.

        platformObjectstring

        The platform object (retrievable from Platform Service) or the name of the platform.

        queryObject

        The query object.

        rppNumber

        The number of filters to be returned by the API.

        facetQuerystring

        The facet query to use against the API end point.

        removeFilters
        (optional)
        boolean

        Whether to remove the current filters for the facet when performing the search.

        facetField
        (optional)
        string

        If provided this field may be used to create a filter on the facet which may not be the same as the facet name itself.

        wildcard
        (optional)
        string

        Pass the wildcard settings for the request, either left, right, both or none.

        canceller
        (optional)
        Promise

        A promise object ($q.defer()) used to cancel the request by using canceller.promise()

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.searchFacet(facet,platform,query,facetQuery);

      • searchSeriesFacet(query, platform, facet, measure, rpp)

        Gets series data for a facet.

        Parameters
        ParamTypeDetails
        querystring

        The query to use against the platform.

        platformObject

        The platform object (retrievable from Platform Service).

        facetObject

        The facet to search upon.

        measurestring

        What fact to use as an alternative to count as quantitative value for a filter.

        rppNumber

        The number of results to fetch.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.searchSeriesFacet(query, platform, facet);

      • searchSeriesFields(query, platform, fields, rpp)

        Gets series data for a result list.

        Parameters
        ParamTypeDetails
        querystring

        The query to use against the platform.

        platformObject

        The platform object (retrievable from Platform Service).

        fieldsObject

        The facet to fields upon.

        rppNumber

        The number of results to fetch.

        Returns
        HttpPromise

        Returns a promise which will resolve depending on the response from the API.

        Example

        $twigkit.searchSeriesFacet(query, platform, fields);