File

repository/firmware/device-tab/firmware-device-tab.component.ts

Metadata

Index

Properties
Methods

Constructor

constructor(route: ActivatedRoute, repository: RepositoryService, inventory: InventoryService, bsModal: BsModalService, gainsightService: GainsightService)
Parameters :
Name Type Optional
route ActivatedRoute No
repository RepositoryService No
inventory InventoryService No
bsModal BsModalService No
gainsightService GainsightService No

Methods

addPatch
addPatch()
Returns : void
getAndAssignRepositoryBinaries
getAndAssignRepositoryBinaries(mos: IManagedObject[])
Parameters :
Name Type Optional
mos IManagedObject[] No
Returns : {}
getRepositoryEntriesWithVersions$
getRepositoryEntriesWithVersions$(searchTerm$: BehaviorSubject)
Parameters :
Name Type Optional
searchTerm$ BehaviorSubject<FilterCriteria> No
Returns : any
getRepositoryEntryWithPatches$
getRepositoryEntryWithPatches$()
Returns : any
installFirmware
installFirmware()
Returns : void
Async loadDevice
loadDevice()
Returns : any
Async ngOnInit
ngOnInit()
Returns : any

Properties

changesInProgress$
Type : Observable<boolean>
Default value : this.changesOperation$.pipe( map(operation => this.isInProgress(operation)) )
changesOperation$
Default value : new BehaviorSubject<IOperation>(null)
device$
Type : BehaviorSubject<IManagedObject>
Default value : new BehaviorSubject( this.route.parent.snapshot.data.contextData )
deviceFirmwareFragment$
Type : Observable<DeviceFirmware>
Default value : this.device$.pipe( map(device => device.c8y_Firmware) )
firmwareBinary$
Type : Observable<IManagedObject>
Default value : this.deviceFirmwareFragment$.pipe( filter(deviceFirmwareFragment => !isEmpty(deviceFirmwareFragment)), switchMap(deviceFirmwareFragment => from( this.repository.getRepositoryBinaryMoByVersion( deviceFirmwareFragment, RepositoryType.FIRMWARE ) ) ), shareReplay(1) )
isEmpty
Default value : isEmpty
patches$
Type : Observable<IManagedObject[]>
Default value : combineLatest( this.firmwareBinary$, this.repositoryEntry$ ).pipe( switchMap(([firmwareBinary, repositoryEntry]) => { if (repositoryEntry && firmwareBinary) { const version: string = this.repository.getBaseVersionFromMO( firmwareBinary as FirmwareBinary ); return from(this.repository.listPatchVersions(repositoryEntry, version)).pipe( map(({ data }) => data) ); } else { return of([]); } }), shareReplay(1) )
PRODUCT_EXPERIENCE
Default value : PRODUCT_EXPERIENCE_REPOSITORY_SHARED
reloading
Default value : false
repositoryEntry$
Type : Observable<IManagedObject>
Default value : this.firmwareBinary$.pipe( switchMap(mo => this.repository.getRepositoryEntryMO$(mo)), shareReplay(1) )
supportsFirmwareOperations$
Type : Observable<boolean>
Default value : this.device$.pipe( map( (device: IManagedObject) => get(device, 'c8y_SupportedOperations', []).indexOf('c8y_Firmware') > -1 ) )
<div class="row">
  <div class="col-lg-12 col-lg-max">
    <div class="card split-view--7-5 m-b-0">
      <div class="d-flex d-col flex-grow split-view__list">
        <div class="card-header separator">
          <div
            class="card-title"
            translate
          >
            Current firmware
          </div>
        </div>
        <div class="inner-scroll">
          <div class="card-block p-t-0 p-b-0">
            <!-- EMPTY STATE -->
            <ng-container *ngIf="isEmpty(deviceFirmwareFragment$ | async); else firmwareBlock">
              <div class="c8y-empty-state text-center">
                <div
                  class="h1 c8y-icon-duocolor"
                  c8yIcon="c8y-firmware"
                ></div>
                <p>
                  <strong translate>No firmware installed.</strong>
                  <br />
                  <small translate>Click below to install firmware into this device.</small>
                </p>
              </div>
            </ng-container>

            <!-- FIRMWARE -->
            <ng-template #firmwareBlock>
              <c8y-list-group class="no-border-last">
                <c8y-li>
                  <c8y-li-icon>
                    <i c8yIcon="c8y-firmware"></i>
                  </c8y-li-icon>

                  <c8y-li-body *ngIf="deviceFirmwareFragment$ | async as deviceFirmwareFragment">
                    <!-- Firmware title -->
                    <p class="text-medium">
                      {{ deviceFirmwareFragment.name }}
                    </p>
                    <!-- Firmware description -->
                    <div *ngIf="repositoryEntry$ | async as repositoryEntry">
                      <span
                        class="text-label-small m-r-4"
                        translate
                      >
                        Description
                      </span>
                      <span>
                        {{ repositoryEntry.description }}
                      </span>
                    </div>

                    <!-- BASE/PATCH VERSION -->
                    <div class="d-flex a-i-baseline">
                      <p
                        class="text-label-small m-r-4"
                        translate
                      >
                        Version
                      </p>
                      <p *ngIf="deviceFirmwareFragment.version; else versionNotSpecified">
                        {{ deviceFirmwareFragment.version }}
                      </p>
                      <ng-template #versionNotSpecified>
                        <p>
                          <em class="text-muted">({{ 'not specified`version`' | translate }})</em>
                        </p>
                      </ng-template>
                    </div>

                    <!-- ADD PATCH -->
                    <button
                      class="btn btn-xs btn-primary"
                      title="{{ 'Patches available' | translate }}"
                      *ngIf="
                        (supportsFirmwareOperations$ | async) && (this.patches$ | async)?.length > 0
                      "
                      (click)="addPatch()"
                      [disabled]="changesInProgress$ | async"
                      c8yProductExperience
                      [actionName]="PRODUCT_EXPERIENCE.FIRMWARE.EVENTS.DEVICE_TAB"
                      [actionData]="{
                        component: PRODUCT_EXPERIENCE.FIRMWARE.COMPONENTS.FIRMWARE_DEVICE_TAB,
                        action:
                          PRODUCT_EXPERIENCE.FIRMWARE.ACTIONS.OPEN_INSTALL_FIRMWARE_PATCH_DIALOG
                      }"
                    >
                      {{ 'Patches available' | translate }}
                    </button>
                  </c8y-li-body>
                </c8y-li>
              </c8y-list-group>
            </ng-template>
          </div>
        </div>
        <div
          class="card-footer separator-top"
          *ngIf="supportsFirmwareOperations$ | async"
        >
          <!-- INSTALL FIRMWARE -->
          <button
            class="btn btn-primary"
            title="{{ 'Install firmware' | translate }}"
            *ngIf="isEmpty(deviceFirmwareFragment$ | async)"
            (click)="installFirmware()"
            c8yProductExperience
            [actionName]="PRODUCT_EXPERIENCE.FIRMWARE.EVENTS.DEVICE_TAB"
            [actionData]="{
              component: PRODUCT_EXPERIENCE.FIRMWARE.COMPONENTS.FIRMWARE_DEVICE_TAB,
              action: PRODUCT_EXPERIENCE.FIRMWARE.ACTIONS.OPEN_INSTALL_FIRMWARE_DIALOG
            }"
          >
            {{ 'Install firmware' | translate }}
          </button>

          <!-- REPLACE FIRMWARE -->
          <button
            class="btn btn-primary"
            title="{{ 'Replace firmware' | translate }}"
            *ngIf="!isEmpty(deviceFirmwareFragment$ | async)"
            (click)="installFirmware()"
            [disabled]="changesInProgress$ | async"
            c8yProductExperience
            [actionName]="PRODUCT_EXPERIENCE.FIRMWARE.EVENTS.DEVICE_TAB"
            [actionData]="{
              component: PRODUCT_EXPERIENCE.FIRMWARE.COMPONENTS.FIRMWARE_DEVICE_TAB,
              action: PRODUCT_EXPERIENCE.FIRMWARE.ACTIONS.OPEN_REPLACE_FIRMWARE_DIALOG
            }"
          >
            {{ 'Replace firmware' | translate }}
          </button>
        </div>
      </div>
      <div class="inner-scroll d-flex d-col bg-level-1 split-view__detail">
        <div class="card-header separator large-padding sticky-top">
          <div
            class="card-title"
            translate
          >
            Firmware changes
          </div>
        </div>
        <div class="flex-grow">
          <fieldset
            class="card-block large-padding bg-level-2 p-0"
            id="operation-block"
            *ngIf="changesOperation$ | async"
          >
            <c8y-operation-details [operation]="changesOperation$ | async"></c8y-operation-details>
          </fieldset>
        </div>
      </div>
    </div>
  </div>
</div>

results matching ""

    No results matching ""