File

user-roles/roles-asset-tree/roles-asset-tree.component.ts

Implements

OnInit OnChanges

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(c8yUserInventoryRoles: Ng1UserInventoryRolesService, c8yRoles: Ng1RolesService)
Parameters :
Name Type Optional
c8yUserInventoryRoles Ng1UserInventoryRolesService No
c8yRoles Ng1RolesService No

Inputs

assignedRoles
Type : any
expandGroups
Type : any
ownerAssignedRoles
Type : any
pageSize
Type : any
paginationOffset
Type : any
searchFilter
Type : any
user
Type : any

Outputs

onChangeItemCount
Type : EventEmitter
onChangeRoles
Type : EventEmitter

Methods

filterAsset
filterAsset(asset)
Parameters :
Name Optional
asset No
Returns : any
getInventoryInheritedRoles
getInventoryInheritedRoles(flatTree, assignedRoles)
Parameters :
Name Optional
flatTree No
assignedRoles No
Returns : any
loadAssetTree
loadAssetTree()
Returns : any
loadChildren
loadChildren(mo)
Parameters :
Name Optional
mo No
Returns : void
loadInventoryRoles
loadInventoryRoles()
Returns : void
ngOnChanges
ngOnChanges(changes)
Parameters :
Name Optional
changes No
Returns : void
ngOnInit
ngOnInit()
Returns : void
onApply
onApply(ev, managedObjectId)
Parameters :
Name Optional
ev No
managedObjectId No
Returns : any
setInheritedRoles
setInheritedRoles()
Returns : void
updateTree
updateTree()
Returns : void

Properties

Public c8yRoles
Type : Ng1RolesService
Decorators :
@Optional()
Public c8yUserInventoryRoles
Type : Ng1UserInventoryRolesService
Decorators :
@Optional()
clickToOpenTitle
Default value : gettext('Click to fetch subgroups')
collapseAriaLabel
Default value : gettext('Collapse')
expandAriaLabel
Default value : gettext('Expand')
flatAssetTree
flatAssetTree$
Default value : combineLatest([this.searchTermSubject, this.flatTreeSubject]).pipe( map(([searchTerm, flatTree]) => { return flatTree .filter(group => group.name.toLowerCase().includes(searchTerm.toLowerCase())) .filter(this.filterAsset.bind(this)); }), tap(flatTree => { this.onChangeItemCount.emit(flatTree.length); }) )
flatTreeSubject
Default value : new BehaviorSubject<IIdentified[]>([])
inheritedRoles
inventoryRoles
loadingAssetTree
manySubgroupsTitle
Default value : gettext('Subgroups: {{ count }}')
noSubgroupTitle
Default value : gettext('No subgroups')
oneSubgroupTitle
Default value : gettext('Subgroup: 1')
ownerAllAssignedRoles
rootGroups
searchTermSubject
Default value : new BehaviorSubject<string>('')
<div class="c8y-list__group m-b-0 no-border-last">
  <div
    class="c8y-list__item"
    *ngFor="
      let asset of flatAssetTree$ | async | slice: paginationOffset:paginationOffset + pageSize
    "
  >
    <div
      class="c8y-list__item__block"
      [title]="
        (asset._subGroups && asset.isOpened
          ? asset._subGroups.length
            ? asset._subGroups.length > 1
              ? manySubgroupsTitle
              : oneSubgroupTitle
            : noSubgroupTitle
          : clickToOpenTitle
        ) | translate: { count: asset._subGroups?.length }
      "
    >
      <div [ngStyle]="{ 'padding-left': asset._depth * 8 + 'px' }"></div>
      <div class="c8y-list__item__icon m-t-4 p-l-0">
        <button
          class="btn-clean"
          [attr.aria-label]="(!asset.isOpened ? expandAriaLabel : collapseAriaLabel) | translate"
          type="button"
          (click)="loadChildren(asset)"
        >
          <i
            class="c8y-icon-duocolor"
            c8yIcon="c8y-group"
            *ngIf="!asset.isOpened"
          ></i>
          <i
            class="c8y-icon-duocolor"
            c8yIcon="c8y-group-open"
            *ngIf="asset.isOpened"
          ></i>
        </button>
      </div>
      <div class="c8y-list__item__body">
        <div class="d-flex a-i-center">
          <div class="col-sm-7 p-l-0 col-xs-12">
            <button
              class="btn-clean"
              type="button"
              (click)="loadChildren(asset)"
            >
              <span
                class="text-truncate"
                [ngStyle]="{ cursor: 'pointer' }"
                title="{{ asset.name }}"
              >
                {{ asset.name }}
              </span>
            </button>
          </div>
          <div class="p-t-8 col-xs-12 visible-xs"></div>
          <div class="col-sm-5 p-l-0 col-xs-12 p-r-0">
            <div class="d-flex">
              <div class="flex-grow form-group-sm max-width-100">
                <c8y-inventory-role-selector-upgraded
                  [ownerAllowedRoles]="
                    ownerAllAssignedRoles ? ownerAllAssignedRoles[asset.id] : undefined
                  "
                  [inheritedRoles]="inheritedRoles ? inheritedRoles[asset.id] : undefined"
                  [assignedRoles]="assignedRoles ? assignedRoles[asset.id] : undefined"
                  [inventoryRoles]="inventoryRoles"
                  (onApply)="onApply($event, asset.id)"
                  (click)="$event.stopPropagation()"
                ></c8y-inventory-role-selector-upgraded>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <c8y-ui-empty-state
    [icon]="'search'"
    [title]="'No matching group found among the expanded groups.' | translate"
    [subtitle]="'Try to expand more groups or to refine your search term.' | translate"
    *ngIf="searchFilter && !(flatAssetTree$ | async).length"
    [horizontal]="false"
  ></c8y-ui-empty-state>
</div>

results matching ""

    No results matching ""