File

core/common/forOf.directive.ts

Description

A directive to iterate over IResultList data from @c8y/client. Depending on the [c8yForLoadMore] a load more button is:

  • auto: Tries to automatically load more data (default maximum 10 iterations; can be
      change with maxIterations settings).
  • show: Shows a load more button for the user to decide
  • none: Doesn't perform any load more action.
  • hidden: Loads more data automatically but with no visible button for the user.

Additional, any rxjs operator pipe can be applied to the [c8yForPipe] input, e.g. to filter the data displayed currently as well as the data loaded by subsequent requests.

Example:

 * <div *c8yFor="let device of devices; loadMore: 'auto'; let i = index; pipe: filterPipe;">
 *  {{ i + 1 }}. {{device.name}}
 * </div>
 *

The above example will list all entities that are applied to devices:

 * this.devices = this.inventoryService.list({ pageSize: 10, fragmentType: 'c8y_IsDevice' })
 *

It will display the first 10 items, if there is more space left on the screen, and there are more than 10 devices, it will automatically load up to 10 pages more. If it still can't fit the screen it will stop and switch to show mode.

A pipe can be applied e.g. for filtering or grouping. This pipe is attached to every follow up request done by the load more component:

 * this.filterPipe = pipe(
 *    map((data: []) => {
 *     return data.filter(
 *      (mo: any) => mo.name && mo.name.toLowerCase().indexOf(value.toLowerCase()) > -1
 *    );
 *  })
 * );
 *

The pipe must be an rxjs pipe and can take any operator.

Metadata

Selector [c8yFor]

Index

Methods
Inputs
Accessors

Constructor

constructor(tpl: TemplateRef, vcr: ViewContainerRef, componentFactoryResolver: ComponentFactoryResolver)
Parameters :
Name Type Optional
tpl TemplateRef<any> No
vcr ViewContainerRef No
componentFactoryResolver ComponentFactoryResolver No

Inputs

c8yForComparator

A comparator function for comparing list items. Used to determine the position at which a new element should be added to the list.

Type : function

c8yForLoadMore

The mode setter:

  • auto: Tries to automatically load more data (default maximum 10 iterations; can be
      change with maxIterations settings).
  • show: Shows a load more button for the user to decide
  • none: Doesn't perform any load more action.
  • hidden: Loads more data automatically but with no visible button for the user.
c8yForMaxIterations

The maximum numbers of iterations to call data from the api.

Type : number

c8yForNotFound

A template to use if no data is found at all (e.g. if you apply a filter pipe).

c8yForOf

The data setter. Must be a response from @c8y/data or an observable. You can pass an observable with null to explicitly clear the list.

c8yForPipe

The pipe setter to attach any rxjs pipe to the current and more loaded data.

c8yForRealtime

A RealtimeService instance.

Methods

ngOnInit
ngOnInit()
Returns : void

Accessors

c8yForOf
setc8yForOf(fetchData)

The data setter. Must be a response from @c8y/data or an observable. You can pass an observable with null to explicitly clear the list.

Parameters :
Name Optional
fetchData No
Returns : void
c8yForLoadMore
setc8yForLoadMore(type)

The mode setter:

  • auto: Tries to automatically load more data (default maximum 10 iterations; can be
      change with maxIterations settings).
  • show: Shows a load more button for the user to decide
  • none: Doesn't perform any load more action.
  • hidden: Loads more data automatically but with no visible button for the user.
Parameters :
Name Optional
type No
Returns : void
c8yForPipe
setc8yForPipe(dataPipe)

The pipe setter to attach any rxjs pipe to the current and more loaded data.

Parameters :
Name Optional
dataPipe No
Returns : void
c8yForNotFound
setc8yForNotFound(notFoundTemplate)

A template to use if no data is found at all (e.g. if you apply a filter pipe).

Parameters :
Name Optional
notFoundTemplate No
Returns : void
c8yForMaxIterations
setc8yForMaxIterations(maxIterations: number)

The maximum numbers of iterations to call data from the api.

Parameters :
Name Type Optional
maxIterations number No
Returns : void
c8yForRealtime
setc8yForRealtime(source)

A RealtimeService instance.

Parameters :
Name Optional
source No
Returns : void
c8yForComparator
setc8yForComparator(comparator: function)

A comparator function for comparing list items. Used to determine the position at which a new element should be added to the list.

Parameters :
Name Type Optional
comparator function No
Returns : void

result-matching ""

    No results matching ""