File

core/dashboard/dashboard-child.component.ts

Description

A dashboard child allows to position elements correctly on a grid. The user can then resize and rearrange the elements, as long as they are not frozen.

By setting c8y-dashboard-child-actions and c8y-dashboard-child-title on the element you can add custom actions or a custom title to the current child.

By adding the correct branded classes, you can define the look and feel of the child. By default it is displayed as a card.

Example:

 *   <c8y-dashboard-child
 *     #cpWidget3
 *     [isFrozen]="isFrozen"
 *     [x]="0"
 *     [y]="3"
 *     [width]="4"
 *     [height]="4"
 *     [class]="'card-dashboard panel-content-transparent'"
 *   >
 *     <c8y-dashboard-child-title *ngIf="showTitle">
 *       <span>Transparent!</span>
 *     </c8y-dashboard-child-title>
 *     <c8y-dashboard-child-action>
 *       <a href="" (click)="showTitle = !showTitle; (false)">
 *         <i [c8yIcon]="'heading'"></i> Hide/show title
 *       </a>
 *     </c8y-dashboard-child-action>
 *     <c8y-dashboard-child-action>
 *       <a href="" (click)="cpWidget3.isFrozen = !cpWidget3.isFrozen; (false)">
 *         <i [c8yIcon]="cpWidget3.isFrozen ? 'lock' : 'unlock'"></i> Toggle freeze
 *       </a>
 *     </c8y-dashboard-child-action>
 *     x: {{ cpWidget3.x }}<br />
 *     y: {{ cpWidget3.y }}<br />
 *     width: {{ cpWidget3.width }}<br />
 *     height: {{ cpWidget3.height }}<br />
 *   </c8y-dashboard-child>
 *

Implements

DashboardChildDimension

Metadata

host {
}
selector c8y-dashboard-child
templateUrl ./dashboard-child.component.html

Index

Properties
Methods
Inputs
Outputs
HostBindings
Accessors

Constructor

constructor(dashboard: DashboardComponent, sanitizer: DomSanitizer, element: ElementRef)
Parameters :
Name Type Optional
dashboard DashboardComponent No
sanitizer DomSanitizer No
element ElementRef No

Inputs

class

All classes added to this child

Type : string[] | literal type

Default value : {}

data

The data object can be used as a dataTransfer object for events of the child.

Type : Widget | any

height

The height of the component in grid-rows.

Default value : 1

isFrozen

If a dashboard is frozen, all children cannot be moved or resized.

Default value : false

margin

The margin of the child in pixel.

Default value : 12

useIntersection

The child content is initialized, as soon it is scrolled into viewport

Default value : false

width

The width of the component in grid-columns.

Default value : 1

x

The x position of the child.

y

The y position of the child.

Outputs

changeEnd

An event fired if a child change is ended

$event Type: EventEmitter
changeStart

An event fired if a child change is started (dragging or resizing)

$event Type: EventEmitter

HostBindings

attr.style
attr.style:

nasty workaround for that issue: https://github.com/angular/angular/issues/9343

Methods

dragStarted
dragStarted($event: CdkDragStart)
Parameters :
Name Type Optional
$event CdkDragStart No
Returns : void
ngOnChanges
ngOnChanges()
Returns : void
ngOnInit
ngOnInit()
Returns : void
reset
reset($event?: CdkDragEnd)
Parameters :
Name Type Optional
$event CdkDragEnd Yes
Returns : void
resizeStarted
resizeStarted($event: CdkDragStart)
Parameters :
Name Type Optional
$event CdkDragStart No
Returns : void
setDynamicDimension
setDynamicDimension()
Returns : void

Properties

_pxHeight
_pxHeight: string
Type : string
Default value : '100%'
_pxWidth
_pxWidth: string
Type : string
Default value : '100%'
actions
actions: []
Type : []
Default value : []
Decorators :
@ContentChildren(DashboardChildActionComponent)
changeSubscription
changeSubscription: Subscription
Type : Subscription

The observable subscription which is listen to on changes (drag or resize).

Public dashboard
dashboard: DashboardComponent
Type : DashboardComponent
Decorators :
@Inject(undefined)
dragSource
dragSource: CdkDrag
Type : CdkDrag
Public element
element: ElementRef
Type : ElementRef
intersected
intersected:
Default value : false

An indicator if the child is intersected (that mean visible for the user)

isDragging
isDragging:
Default value : false
isResize
isResize:
Default value : false
klasses
klasses: object
Type : object
Default value : {}

Accessors

pxWidth
setpxWidth(value)

Updates the pixel width of the child (used for resizing)

Parameters :
Name Optional
value No
Returns : void
pxHeight
setpxHeight(value)

Updates the pixel height of the child (used for resizing)

Parameters :
Name Optional
value No
Returns : void
<div cdkDropList>
  <div *ngIf="isResize" class="card-placeholder"></div>
  <div
    [ngClass]="klasses"
    cdkDrag
    [ngStyle]="{ width: _pxWidth, height: _pxHeight }"
    (cdkDragStarted)="dragStarted($event)"
    (cdkDragEnded)="reset($event)"
    [cdkDragDisabled]="isFrozen"
  >
    <div
      class="card-header-actions card-header-grid"
      [ngClass]="{ 'drag-handle': !isFrozen, draggableCursor: !isFrozen }"
      cdkDragHandle
    >
      <ng-content select="c8y-dashboard-child-title"></ng-content>
      <div class="header-actions" *ngIf="!isFrozen && actions.length > 0">
        <div class="optionsBtn dropdown" dropdown container="body" placement="bottom right">
          <a
            title="{{ 'Settings' | translate }}"
            href=""
            class="btnIcon c8y-dropdown"
            (click)="(false)"
            dropdownToggle
          >
            <i [c8yIcon]="'cog'"></i>
          </a>
          <ul
            class="dropdown-menu dropdown-menu-right"
            style="right:-1px;"
            *dropdownMenu
          >
            <ng-container *ngFor="let action of actions">
              <ng-container *ngTemplateOutlet="action.template"></ng-container>
            </ng-container>
          </ul>
        </div>
      </div>
    </div>
    <div class="card-inner-scroll">
      <ng-content></ng-content>
    </div>
    <div
      *ngIf="!isFrozen && !isDragging"
      class="resize-handle"
      cdkDrag
      [cdkDragDisabled]="isFrozen"
      (cdkDragStarted)="resizeStarted($event)"
      (cdkDragEnded)="reset($event)"
    ></div>
    <div class="resize-icon" *ngIf="!isFrozen && !isDragging"></div>

    <div *cdkDragPlaceholder class="card-placeholder"></div>
  </div>
</div>

result-matching ""

    No results matching ""