File

sub-assets/asset-properties.component.ts

Implements

OnChanges

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(assetTypes: AssetTypesRealtimeService, inventory: InventoryService, inventoryBinary: InventoryBinaryService, alert: AlertService)
Parameters :
Name Type Optional
assetTypes AssetTypesRealtimeService No
inventory InventoryService No
inventoryBinary InventoryBinaryService No
alert AlertService No

Inputs

asset
Type : IManagedObject
properties
Type : IManagedObject[]
Default value : []

Outputs

assetChange
Type : EventEmitter

Methods

Async addOrderDetails
addOrderDetails(properties: any, key: string)
Parameters :
Name Type Optional
properties any No
key string No
Returns : Promise<void>
deleteTitleFromMOJsonSchema
deleteTitleFromMOJsonSchema(mo: IManagedObject)
Parameters :
Name Type Optional
mo IManagedObject No
Returns : void
Async getFileManagedObject
getFileManagedObject(id: string)
Parameters :
Name Type Optional
id string No
Returns : unknown
Async getPropertyDetails
getPropertyDetails(identifier: string)
Parameters :
Name Type Optional
identifier string No
Returns : Promise<IManagedObject>
isFileTypeProperty
isFileTypeProperty(property: any)
Parameters :
Name Type Optional
property any No
Returns : boolean
Async loadAsset
loadAsset()
Returns : any
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
orderComplexProperties
orderComplexProperties(mo: IManagedObject | any)

This method is used to order the complex properties in the order specified by the user in asset properties screen.

Parameters :
Name Type Optional Description
mo IManagedObject | any No
  • Managed object of the complex property associated with the asset (old structure) or properties object (new structure).
Returns : any
Async parseItem
parseItem(mo: IManagedObject | null, properties: unknown, asset: unknown)
Parameters :
Name Type Optional
mo IManagedObject | null No
properties unknown No
asset unknown No
Returns : Promise<AssetPropertiesItem[]>
Async resolveCustomProperties
resolveCustomProperties(managedObjects: IManagedObject[])
Parameters :
Name Type Optional
managedObjects IManagedObject[] No
Returns : unknown
Async save
save(propertyValue: unknown, prop: AssetPropertiesItem)
Parameters :
Name Type Optional
propertyValue unknown No
prop AssetPropertiesItem No
Returns : Promise<void>
toggleEdit
toggleEdit(prop: AssetPropertiesItem)
Parameters :
Name Type Optional
prop AssetPropertiesItem No
Returns : void
transformType
transformType(property: any)
Parameters :
Name Type Optional
property any No
Returns : void

Properties

assetType
Type : IManagedObject
customProperties
Type : AssetPropertiesItem[]
Default value : []
isEdit
Type : unknown
Default value : false
isLoading
Type : unknown
Default value : false
POSITION_PROPERTY_KEY
Type : string
Default value : 'c8y_Position'
<ng-container>
  <div class="card-header bg-inherit separator sticky-top">
    <h1
      class="card-title p-t-4 p-b-4"
      ngNonBindable
      translate
      [translateParams]="{
        label: assetType?.c8y_JsonSchema?.title || assetType?.label || '' | translate
      }"
    >
      {{ label }} properties
    </h1>
  </div>
  <div class="card-block">
    @if (isLoading) {
      <div class="text-center">
        <c8y-loading></c8y-loading>
      </div>
    }

    @if (!isLoading) {
      @for (prop of customProperties; track prop.key) {
        <div
          class="card m-b-8"
          title="{{ prop.description | translate }}"
          [ngClass]="{ 'card-highlight': prop.isEdit }"
        >
          <div
            class="card-block"
            [ngClass]="{ 'p-b-0': prop.isEdit }"
          >
            @if (!prop.isEdit) {
              <div class="d-flex p-b-8 a-i-center">
                <p
                  class="text-medium text-truncate"
                  title="{{ prop?.label | translate }}"
                >
                  {{ prop?.label | translate }}
                </p>
                <button
                  class="btn btn-dot m-l-auto text-12"
                  [attr.aria-label]="'Edit' | translate"
                  tooltip="{{ 'Edit' | translate }}"
                  type="button"
                  [delay]="500"
                  (click)="toggleEdit(prop)"
                >
                  <i c8yIcon="pencil"></i>
                </button>
              </div>
            }
            <c8y-asset-properties-item
              #assetProps
              [file]="prop.file"
              [key]="prop.key"
              [type]="prop.type"
              [value]="prop.value"
              [complex]="prop.complex"
              [isEdit]="prop.isEdit"
              [jsonSchema]="prop.jsonSchema"
            ></c8y-asset-properties-item>
            @if (prop.key === POSITION_PROPERTY_KEY) {
              <div>
                <c8y-asset-location
                  [locationMO]="asset"
                  [isEdit]="prop.isEdit"
                  [form]="assetProps.form"
                ></c8y-asset-location>
              </div>
            }
          </div>
          @if (prop.isEdit) {
            <div class="card-footer p-t-0">
              <button
                class="btn btn-default btn-sm"
                title="{{ 'Cancel' | translate }}"
                type="button"
                (click)="toggleEdit(prop)"
              >
                {{ 'Cancel' | translate }}
              </button>
              <button
                class="btn btn-primary btn-sm"
                title="{{ 'Save' | translate }}"
                type="button"
                [disabled]="!assetProps?.form?.valid || !assetProps?.form?.dirty"
                (click)="save(assetProps.form.value, prop)"
              >
                {{ 'Save' | translate }}
              </button>
            </div>
          }
        </div>
      }
    }
  </div>
</ng-container>

results matching ""

    No results matching ""