File

operations/stepper-bulk-type-software/select-software-step.component.ts

Metadata

Index

Properties
Methods
Outputs

Constructor

constructor(repositoryService: RepositoryService, translate: TranslateService)
Parameters :
Name Type Optional
repositoryService RepositoryService No
translate TranslateService No

Outputs

software
Type : EventEmitter<ISelectedSoftware>

Methods

emitSoftware
emitSoftware(undefined)
Parameters :
Name Optional
No
Returns : void
getBaseVersionsCount$
getBaseVersionsCount$(software: IManagedObject)
Decorators :
@memoize(undefined)
Parameters :
Name Type Optional
software IManagedObject No
Returns : Observable<number>
getDeviceTypeTitle
getDeviceTypeTitle(software: IManagedObject)
Parameters :
Name Type Optional
software IManagedObject No
Returns : string
getVersions
getVersions(software: IManagedObject)
Decorators :
@memoize(undefined)
Parameters :
Name Type Optional
software IManagedObject No
Returns : any
loadDeviceTypes
loadDeviceTypes()
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
resetSelection
resetSelection()
Returns : void
selectSoftware
selectSoftware(undefined)
Parameters :
Name Optional
No
Returns : void

Properties

deviceType$
Type : BehaviorSubject<string>
Default value : new BehaviorSubject('')
deviceTypes
Type : []
Default value : []
isLegacy
Default value : this.repositoryService.isLegacyEntry.bind(this.repositoryService)
Readonly NO_DEVICE_TYPE_AVAILABLE
Default value : gettext('No device type available')
radioButtons
Type : QueryList<ListItemRadioComponent>
Decorators :
@ViewChildren(ListItemRadioComponent)
selectedDeviceType
Type : object
Default value : { name: '' }
software$
Type : Observable<IResultList<IManagedObject>>
Default value : combineLatest( this.textFilter$, this.deviceType$, this.softwareTypeFilter$ ).pipe( switchMap(([name, deviceType, softwareType]) => this.getSoftware(name, deviceType, softwareType) ), shareReplay(1) )
softwareTypeFilter$
Type : BehaviorSubject<string>
Default value : new BehaviorSubject('')
textFilter$
Type : BehaviorSubject<string>
Default value : new BehaviorSubject('')
<c8y-select-step-frame
  [header]="'Select software' | translate"
  [noResults]="
    ((textFilter$ | async)?.length ||
      (deviceType$ | async)?.length ||
      (softwareTypeFilter$ | async)?.length) &&
    (software$ | async)?.data.length === 0
  "
>
  <div filters class="row">
    <div class="col-md-4 m-b-xs-8 m-b-sm-8">
      <div class="input-group input-group-search">
        <input
          type="search"
          class="form-control"
          title="{{ 'Filter software…' | translate }}"
          placeholder="{{ 'Filter software…' | translate }}"
          [ngModel]="textFilter$ | async"
          (ngModelChange)="textFilter$.next($event)"
        />
        <span class="input-group-addon">
          <i c8yIcon="filter" *ngIf="(textFilter$ | async).length === 0"></i>
          <i
            c8yIcon="times"
            class="text-muted"
            *ngIf="(textFilter$ | async).length > 0"
            (click)="textFilter$.next('')"
          ></i>
        </span>
      </div>
    </div>
    <div class="col-md-4 m-b-xs-8 m-b-sm-8">
      <c8y-form-group class="m-0">
        <c8y-typeahead
          name="deviceType"
          [(ngModel)]="selectedDeviceType"
          placeholder="{{ 'Type to filter device types…' | translate }}"
          (onSearch)="deviceType$.next($event)"
          [allowFreeEntries]="false"
        >
          <c8y-li
            class="p-l-8 p-r-8 c8y-list__item--link"
            (click)="selectedDeviceType = { name: '' }; deviceType$.next('')"
            [active]="!selectedDeviceType?.name"
          >
            <span>{{ 'All device types' | translate }}</span>
          </c8y-li>
          <c8y-li
            *ngFor="let deviceType of deviceTypes"
            class="p-l-8 p-r-8 c8y-list__item--link"
            (click)="selectedDeviceType = deviceType; deviceType$.next(deviceType.name)"
            [active]="selectedDeviceType === deviceType"
          >
            <c8y-highlight [text]="deviceType.name" [pattern]="deviceType$ | async"></c8y-highlight>
          </c8y-li>
        </c8y-typeahead>
        <c8y-messages>
          <c8y-message
            name="notExisting"
            [text]="'Select one of the existing device types.' | translate"
          ></c8y-message>
        </c8y-messages>
      </c8y-form-group>
    </div>
    <div class="col-md-4">
      <c8y-form-group class="m-0">
        <c8y-software-type
          [required]="false"
          [emitResultsOnly]="true"
          [showBtnInNotFoundMessage]="false"
          [allowFreeEntries]="false"
          [placeholder]="'Type to filter software types…' | translate"
          [showClearSelectionOption]="true"
          (onSelectSoftware)="softwareTypeFilter$.next($event?.softwareType)"
        ></c8y-software-type>
        <c8y-messages>
          <c8y-message
            name="notExisting"
            [text]="'Select one of the existing device types.' | translate"
          ></c8y-message>
        </c8y-messages>
      </c8y-form-group>
    </div>
  </div>
  <c8y-li header class="hidden-sm hidden-xs m-r-8 m-l-8">
    <c8y-li-icon><i class="p-l-24"></i></c8y-li-icon>
    <c8y-li-body class="content-flex-40 p-r-32">
      <div class="col-5">
        <span class="text-truncate" title=" {{ 'Name' | translate }} ">
          {{ 'Name' | translate }}
        </span>
      </div>
      <div class="col-2">
        <span class="text-truncate" title="{{ 'Device type' | translate }}">
          {{ 'Device type' | translate }}
        </span>
      </div>
      <div class="col-3">
        <span class="text-truncate" title="{{ 'Software type' | translate }}">
          {{ 'Software type' | translate }}
        </span>
      </div>
      <div class="col-2">
        <span class="text-truncate" title="{{ 'Versions' | translate }}">
          {{ 'Versions' | translate }}
        </span>
      </div>
    </c8y-li-body>
  </c8y-li>
  <c8y-list-group list [ngClass]="{ 'dd-low': (software$ | async)?.data.length < 10 }">
    <c8y-li *c8yFor="let software of software$ | async; loadMore: 'auto'">
      <c8y-li-icon>
        <i c8yIcon="c8y-tools"></i>
      </c8y-li-icon>
      <c8y-li-body class="content-flex-40">
        <div class="col-5 m-b-xs-8">
          <div class="text-truncate" title="{{ software.name }}">
            <c8y-highlight [text]="software.name" [pattern]="textFilter$ | async"></c8y-highlight>
          </div>
        </div>
        <div class="col-2 m-b-xs-8">
          <div
            class="text-truncate"
            title="{{ 'Device type' | translate }}: {{ getDeviceTypeTitle(software) }}"
          >
            <span class="text-label-small m-r-8 visible-xs visible-sm" translate>
              Device type
            </span>
            <span *ngIf="software.c8y_Filter?.type; else noType">
              {{ software.c8y_Filter?.type }}
            </span>
            <ng-template #noType>
              <small>
                <em class="text-muted" translate>Undefined`device type`</em>
              </small>
            </ng-template>
          </div>
        </div>
        <div class="col-3 m-b-xs-8">
          <span class="text-label-small m-r-8 visible-xs visible-sm" translate>
            Software type
          </span>
          <span *ngIf="software.softwareType; else emptyText" class="label label-info">
            {{ software.softwareType }}
          </span>
          <ng-template #emptyText>
            <small class="text-muted">
              <em translate>Undefined`software type`</em>
            </small>
          </ng-template>
        </div>
        <div class="col-2">
          <span *ngIf="isLegacy(software)" class="label label-warning flex-item-right-sm">
            <span translate>Legacy</span>
          </span>
          <span *ngIf="!isLegacy(software)">
            <span *ngIf="(getBaseVersionsCount$(software) | async) === null">
              <span class="label label-info">
                <i c8yIcon="circle-o-notch" class="icon-spin"></i>
              </span>
            </span>
            <span *ngIf="(getBaseVersionsCount$(software) | async) !== null">
              <span [ngPlural]="getBaseVersionsCount$(software) | async">
                <ng-template ngPluralCase="=1">
                  <span class="text-label-small m-r-8 visible-xs visible-sm" translate>
                    version
                  </span>
                  <span class="badge badge-info flex-item-right-sm"> 1 </span>
                </ng-template>
                <ng-template ngPluralCase="other">
                  <span class="text-label-small m-r-8 visible-xs visible-sm" translate>
                    versions
                  </span>
                  <span class="badge badge-info flex-item-right-sm">
                    {{ getBaseVersionsCount$(software) | async }}
                  </span>
                </ng-template>
              </span>
            </span>
          </span>
        </div>
      </c8y-li-body>
      <c8y-li-collapse>
        <c8y-list-group>
          <c8y-li *c8yFor="let option of getVersions(software) | async">
            <c8y-li-radio
              [name]="software.id"
              (onSelect)="selectSoftware({ option: option, software: software })"
            ></c8y-li-radio>
            <c8y-li-body class="content-flex-40 p-r-16">
              <div class="col-4">
                {{ option.c8y_Software.version }}
              </div>
              <div class="col-5">
                <div class="text-truncate" title="{{ option.c8y_Software.url }}">
                  <span class="text-label-small m-r-4" translate> File </span>
                  <span>{{ option.c8y_Software.url }}</span>
                </div>
              </div>
              <div class="col-3 d-flex" *ngIf="option.id === software.selectedId">
                <div class="c8y-select-wrapper d-inline-block m-l-auto" style="margin: -4px 0">
                  <select
                    id="action"
                    class="form-control input-sm"
                    [(ngModel)]="option.action"
                    (change)="emitSoftware({ option: option, software: software })"
                  >
                    <option [ngValue]="'install'">
                      {{ 'Install/update`software`' | translate }}
                    </option>
                    <option [ngValue]="'delete'">{{ 'Remove`software`' | translate }}</option>
                  </select>
                  <span></span>
                </div>
              </div>
            </c8y-li-body>
          </c8y-li>
        </c8y-list-group>
      </c8y-li-collapse>
    </c8y-li>
  </c8y-list-group>
</c8y-select-step-frame>

results matching ""

    No results matching ""