File

device-profile/device-profile.component.ts

Implements

OnInit ProductExperienceEventSource

Metadata

Index

Properties
Methods
Accessors

Constructor

constructor(route: ActivatedRoute, alertService: AlertService, inventoryService: InventoryService, bsModal: BsModalService, repositoryService: RepositoryService)
Parameters :
Name Type Optional
route ActivatedRoute No
alertService AlertService No
inventoryService InventoryService No
bsModal BsModalService No
repositoryService RepositoryService No

Methods

addConfiguration
addConfiguration()
Returns : void
addFirmware
addFirmware()
Returns : void
addSoftware
addSoftware()
Returns : void
getAndAssignRepositoryBinaries
getAndAssignRepositoryBinaries(mos: IManagedObject[])
Parameters :
Name Type Optional
mos IManagedObject[] No
Returns : {}
getRepositoryEntriesWithVersions$
getRepositoryEntriesWithVersions$(searchTerm$: BehaviorSubject, repoType: RepositoryType)
Parameters :
Name Type Optional
searchTerm$ BehaviorSubject<FilterCriteria> No
repoType RepositoryType No
Returns : any
Async ngOnInit
ngOnInit()
Returns : any
removeFirmware
removeFirmware()
Returns : void
removeItem
removeItem(removedItem, category)
Parameters :
Name Optional
removedItem No
category No
Returns : void
Async updateDeviceProfile
updateDeviceProfile(partialDeviceProfile)
Parameters :
Name Optional
partialDeviceProfile No
Returns : any

Properties

DEVICE_TYPE_DISABLED_POPOVER
Default value : gettext( 'Device type cannot be changed on profiles with already defined firmware, software or configuration since they may not be applicable to devices of the new device type.' )
DEVICE_TYPE_POPOVER
Default value : gettext( 'The device profile will be available for assignments on devices of the specified type. Otherwise, it will be available for all device types.' )
deviceProfile
Type : DeviceProfile
PRODUCT_EXPERIENCE
Default value : PRODUCT_EXPERIENCE_DEVICE_PROFILE
productExperienceEvent
Type : ProductExperienceEvent
Default value : { eventName: PRODUCT_EXPERIENCE_DEVICE_PROFILE.EVENTS.REPOSITORY, data: { component: PRODUCT_EXPERIENCE_DEVICE_PROFILE.COMPONENTS.DEVICE_PROFILE } }
profileName
Type : string

Accessors

isDeviceProfileEmpty
getisDeviceProfileEmpty()
<c8y-title>{{ profileName }}</c8y-title>

<c8y-breadcrumb>
  <c8y-breadcrumb-item
    label="{{ 'Management' | translate }}"
    icon="c8y-management"
  ></c8y-breadcrumb-item>
  <c8y-breadcrumb-item
    [icon]="'c8y-device-profile'"
    [label]="'Device profiles' | translate"
    [path]="'device-profiles'"
  ></c8y-breadcrumb-item>
  <c8y-breadcrumb-item label="{{ profileName }}" icon="c8y-device-profile"></c8y-breadcrumb-item>
</c8y-breadcrumb>

<div *ngIf="deviceProfile" class="row">
  <div class="col-lg-12 col-lg-max">
    <div class="card card--fullpage" *ngIf="deviceProfile">
      <div class="card-block bg-level-1 flex-no-shrink p-t-24 p-b-24 overflow-visible">
        <div class="content-flex-70">
          <div class="text-center">
            <i class="c8y-icon-duocolor icon-48 c8y-icon c8y-icon-device-profile"></i>
            <p>
              <small class="label label-info">{{ 'Device profile' | translate }}</small>
            </p>
          </div>
          <div class="flex-grow col-10">
            <div class="row">
              <div class="col-md-4">
                <form #editNameForm="ngForm">
                  <c8y-form-group>
                    <label class="control-label" translate>Name</label>
                    <div class="input-group input-group-editable">
                      <input
                        type="text"
                        class="form-control"
                        [(ngModel)]="deviceProfile.name"
                        name="name"
                        placeholder="{{ 'e.g. My device profile' | translate }}"
                        data-cy="device-profile--add-device-profile-name"
                        size="{{ deviceProfile.name?.length || 1 }}"
                        required
                      />
                      <span></span>
                      <div class="input-group-btn">
                        <button
                          class="btn btn-primary"
                          type="button"
                          title="{{ 'Save' | translate }}"
                          data-cy="device-profile--save"
                          (click)="
                            updateDeviceProfile({ name: deviceProfile.name });
                            editNameForm.form.markAsPristine()
                          "
                          [disabled]="editNameForm.form.invalid"
                          c8yProductExperience
                          inherit
                          [actionData]="{ action: PRODUCT_EXPERIENCE.ACTIONS.SAVE }"
                        >
                          {{ 'Save' | translate }}
                        </button>
                      </div>
                    </div>
                  </c8y-form-group>
                </form>
              </div>
              <div class="col-md-4">
                <form #editTypeForm="ngForm">
                  <c8y-form-group>
                    <label class="control-label">
                      {{ 'Device type' | translate }}
                      <button
                        class="btn-help"
                        type="button"
                        [attr.aria-label]="'Help' | translate"
                        [popover]="
                          (DEVICE_TYPE_POPOVER | translate) +
                          (isDeviceProfileEmpty
                            ? ' ' + (DEVICE_TYPE_DISABLED_POPOVER | translate)
                            : '')
                        "
                        triggers="focus"
                        container="body"
                        placement="right"
                      ></button>
                    </label>
                    <div class="input-group input-group-editable">
                      <input
                        type="text"
                        class="form-control"
                        [(ngModel)]="deviceProfile.c8y_Filter.type"
                        data-cy="device-profile--device-type"
                        name="type"
                        placeholder="{{ 'e.g.' | translate }} c8y_Linux"
                        size="{{ deviceProfile.c8y_Filter.type?.length || 14 }}"
                        [disabled]="isDeviceProfileEmpty"
                      />
                      <span></span>
                      <div class="input-group-btn">
                        <button
                          class="btn btn-primary"
                          type="button"
                          title="{{ 'Save' | translate }}"
                          (click)="
                            updateDeviceProfile({
                              c8y_Filter: { type: deviceProfile.c8y_Filter.type }
                            });
                            editTypeForm.form.markAsPristine()
                          "
                          [disabled]="isDeviceProfileEmpty"
                          c8yProductExperience
                          inherit
                          [actionData]="{ action: PRODUCT_EXPERIENCE.ACTIONS.SAVE }"
                        >
                          {{ 'Save' | translate }}
                        </button>
                      </div>
                    </div>
                  </c8y-form-group>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="inner-scroll">
        <div class="card-header separator-top-bottom bg-content sticky-top">
          <div class="card-icon">
            <i [c8yIcon]="'c8y-firmware'" class="c8y-icon-duocolor"></i>
          </div>
          <div class="card-title" translate>Firmware</div>
        </div>
        <div class="card-block p-t-0" *ngIf="deviceProfile.c8y_DeviceProfile.firmware">
          <c8y-list-group>
            <c8y-li>
              <c8y-li-icon>
                <i [c8yIcon]="'c8y-firmware'"></i>
              </c8y-li-icon>
              <c8y-li-body class="content-flex-50 m-l-4">
                <div class="col-6">
                  <span
                    class="text-truncate"
                    title="{{ deviceProfile.c8y_DeviceProfile.firmware.name }}"
                  >
                    {{ deviceProfile.c8y_DeviceProfile.firmware.name }}
                  </span>
                </div>
                <div class="col-5 d-flex a-i-center">
                  <span
                    class="text-truncate"
                    title="{{ deviceProfile.c8y_DeviceProfile.firmware.version }}"
                  >
                    <span class="text-label-small m-r-4" translate>Version</span>
                    {{ deviceProfile.c8y_DeviceProfile.firmware.version }}
                  </span>
                  <button
                    class="btn btn-danger btn-xs visible-xs m-l-auto m-r-8 m-t-8"
                    type="button"
                    title="{{ 'Remove`firmware`' | translate }}"
                    (click)="removeFirmware()"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.FIRMWARE
                    }"
                  >
                    <i c8yIcon="minus-circle"></i>
                    {{ 'Remove`firmware`' | translate }}
                  </button>
                </div>
                <div class="m-l-auto p-r-8 hidden-xs">
                  <button
                    class="btn btn-dot showOnHover text-danger"
                    type="button"
                    [attr.aria-label]="'Remove`firmware`' | translate"
                    tooltip="{{ 'Remove`firmware`' | translate }}"
                    [delay]="500"
                    placement="right"
                    (click)="removeFirmware()"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.FIRMWARE
                    }"
                  >
                    <i c8yIcon="minus-circle"></i>
                  </button>
                </div>
              </c8y-li-body>
            </c8y-li>
          </c8y-list-group>
        </div>
        <div class="card-block p-t-16" *ngIf="!deviceProfile.c8y_DeviceProfile.firmware">
          <c8y-ui-empty-state
            icon="c8y-firmware"
            [horizontal]="true"
            [title]="'No firmware defined.' | translate"
            class="p-t-16 d-block"
          ></c8y-ui-empty-state>
        </div>
        <div class="card-footer p-t-0" *ngIf="!deviceProfile.c8y_DeviceProfile.firmware">
          <button
            class="btn btn-default"
            type="button"
            data-cy="device-profile--Add-firmware-button"
            title="{{ 'Add firmware' | translate }}"
            (click)="addFirmware()"
            c8yProductExperience
            inherit
            [actionData]="{
              action: PRODUCT_EXPERIENCE.ACTIONS.ADD,
              fragment: PRODUCT_EXPERIENCE.FRAGMENTS.FIRMWARE
            }"
          >
            <i c8yIcon="plus-circle"></i>
            {{ 'Add firmware' | translate }}
          </button>
        </div>

        <div class="card-header separator-top-bottom sticky-top bg-component">
          <div class="card-icon">
            <i [c8yIcon]="'c8y-tools'" class="c8y-icon-duocolor"></i>
          </div>
          <div class="card-title" translate>Software</div>
        </div>
        <div class="card-block p-t-0" *ngIf="deviceProfile.c8y_DeviceProfile.software?.length > 0">
          <c8y-list-group>
            <c8y-li *ngFor="let software of deviceProfile.c8y_DeviceProfile.software">
              <c8y-li-icon>
                <i [c8yIcon]="'c8y-tools'"></i>
              </c8y-li-icon>
              <c8y-li-body class="content-flex-50 m-l-4">
                <div class="col-6">
                  <span class="text-truncate-wrap" title="{{ software.name }}">
                    {{ software.name }}
                  </span>
                </div>
                <div class="col-5 d-flex a-i-center">
                  <span class="text-truncate-wrap" title="{{ software.version }}">
                    <span class="text-label-small m-r-8" translate>Version</span>
                    {{ software.version }}
                  </span>
                  <button
                    class="btn btn-danger btn-xs visible-xs m-l-auto m-r-8 m-t-8"
                    type="button"
                    title="{{ 'Remove`software`' | translate }}"
                    ((click)="removeItem(software, 'software')"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.SOFTWARE
                    }"
                  >
                    <i c8yIcon="minus-circle"></i>
                    {{ 'Remove`software`' | translate }}
                  </button>
                </div>
                <div class="m-l-auto p-r-8 hidden-xs">
                  <button
                    class="btn btn-dot showOnHover text-danger"
                    type="button"
                    [attr.aria-label]="'Remove`software`' | translate"
                    tooltip="{{ 'Remove`software`' | translate }}"
                    [delay]="500"
                    placement="right"
                    (click)="removeItem(software, 'software')"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.SOFTWARE
                    }"
                  >
                    <i c8yIcon="minus-circle" data-cy="device-profile--Remove-icon"></i>
                  </button>
                </div>
              </c8y-li-body>
            </c8y-li>
          </c8y-list-group>
        </div>
        <div
          class="card-block p-t-16"
          *ngIf="deviceProfile.c8y_DeviceProfile.software?.length === 0"
        >
          <c8y-ui-empty-state
            icon="c8y-tools"
            [horizontal]="true"
            [title]="'No software defined.' | translate"
          ></c8y-ui-empty-state>
        </div>
        <div class="card-footer p-t-0">
          <button
            class="btn btn-default m-b-0"
            type="button"
            title="{{ 'Add software' | translate }}"
            data-cy="device-profile--Add-software-button"
            (click)="addSoftware()"
            c8yProductExperience
            inherit
            [actionData]="{
              action: PRODUCT_EXPERIENCE.ACTIONS.ADD,
              fragment: PRODUCT_EXPERIENCE.FRAGMENTS.SOFTWARE
            }"
          >
            <i c8yIcon="plus-circle"></i>
            {{ 'Add software' | translate }}
          </button>
        </div>

        <div class="card-header separator-top-bottom bg-component sticky-top">
          <div class="card-icon">
            <i [c8yIcon]="'gears'" class="c8y-icon-duocolor"></i>
          </div>
          <div class="card-title" translate>Configuration</div>
        </div>
        <div
          class="card-block p-t-0"
          *ngIf="deviceProfile.c8y_DeviceProfile.configuration?.length > 0"
        >
          <c8y-list-group>
            <c8y-li *ngFor="let configuration of deviceProfile.c8y_DeviceProfile.configuration">
              <c8y-li-icon>
                <i [c8yIcon]="'gears'"></i>
              </c8y-li-icon>
              <c8y-li-body class="content-flex-50">
                <div class="col-6">
                  <span class="text-truncate" title="{{ configuration.name }}">
                    {{ configuration.name }}
                  </span>
                </div>
                <div class="col-5 d-flex a-i-center">
                  <span class="label label-info">{{ configuration.type }}</span>
                  <button
                    class="btn btn-danger btn-xs visible-xs m-l-auto m-r-8 m-t-8"
                    type="button"
                    title="{{ 'Remove`configuration`' | translate }}"
                    (click)="removeItem(configuration, 'configuration')"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.CONFGIURATION
                    }"
                  >
                    <i c8yIcon="minus-circle"></i>
                    {{ 'Remove`configuration`' | translate }}
                  </button>
                </div>
                <div class="m-l-auto p-r-8 hidden-xs">
                  <button
                    class="btn btn-dot showOnHover text-danger"
                    type="button"
                    [attr.aria-label]="'Remove`configuration`' | translate"
                    tooltip="{{ 'Remove`configuration`' | translate }}"
                    (click)="removeItem(configuration, 'configuration')"
                    [delay]="500"
                    placement="top"
                    c8yProductExperience
                    inherit
                    [actionData]="{
                      action: PRODUCT_EXPERIENCE.ACTIONS.REMOVE,
                      fragment: PRODUCT_EXPERIENCE.FRAGMENTS.CONFGIURATION
                    }"
                  >
                    <i c8yIcon="minus-circle" data-cy="device-profile--Remove-icon"></i>
                  </button>
                </div>
              </c8y-li-body>
            </c8y-li>
          </c8y-list-group>
        </div>
        <div
          class="card-block p-t-16"
          *ngIf="deviceProfile.c8y_DeviceProfile.configuration?.length === 0"
        >
          <c8y-ui-empty-state
            icon="gears"
            [horizontal]="true"
            [title]="'No configuration defined.' | translate"
          ></c8y-ui-empty-state>
        </div>
        <div class="card-footer p-t-0">
          <div class="p-t-8">
            <button
              title="{{ 'Add configuration' | translate }}"
              data-cy="device-profile--Add-configuration-button"
              type="button"
              class="btn btn-default m-b-0"
              (click)="addConfiguration()"
              c8yProductExperience
              inherit
              [actionData]="{
                action: PRODUCT_EXPERIENCE.ACTIONS.ADD,
                fragment: PRODUCT_EXPERIENCE.FRAGMENTS.CONFGIURATION
              }"
            >
              <i c8yIcon="plus-circle"></i>
              {{ 'Add configuration' | translate }}
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

results matching ""

    No results matching ""