sub-assets/asset-properties-item.component.ts
AssetPropertiesItem
OnChanges
| selector | c8y-asset-properties-item |
| imports |
NgClass
FormlyModule
C8yTranslatePipe
DatePipe
|
| templateUrl | ./asset-properties-item.component.html |
Properties |
|
Methods |
|
Inputs |
constructor(alert: AlertService, c8yJsonSchemaService: C8yJSONSchema, filesService: FilesService)
|
||||||||||||
|
Parameters :
|
| complex |
Type : AssetPropertiesItem[]
|
| file |
Type : IManagedObjectBinary
|
| isEdit |
Type : boolean
|
| jsonSchema |
Type : JSONSchema7
|
| key |
Type : string
|
| label |
Type : string
|
| type |
Type : string
|
| value |
Type : any
|
| Async ngOnChanges | ||||||
ngOnChanges(changes: SimpleChanges)
|
||||||
|
Parameters :
Returns :
Promise<void>
|
| fields |
Type : FormlyFieldConfig[]
|
| Public filesService |
Type : FilesService
|
| form |
Type : FormGroup
|
| model |
Type : any
|
| previewImage |
Type : unknown
|
@if (!isEdit) {
@switch (type) {
@case ('date') {
{{ (value | c8yDate: 'fullDate') || ('Undefined' | translate) }}
}
@case ('file') {
@if (file) {
@if (previewImage) {
<img
class="img-responsive"
[src]="previewImage"
/>
}
@if (!previewImage) {
<button
class="btn btn-clean text-truncate p-0"
title="{{ 'Download' | translate }} {{ file.name }}"
type="button"
(click)="filesService.download(file)"
>
{{ file.name }}
</button>
}
} @else {
{{ 'No file attached.' | translate }}
}
}
@case ('object') {
<ul class="list-unstyled c8y-custom-properties">
@for (prop of complex; track prop.key; let i = $index) {
<li
class="p-t-4 p-b-4 d-flex text-nowrap"
[ngClass]="{ 'separator-top-bottom': i === 0, 'separator-bottom': i > 0 }"
>
<label
class="small m-b-0 m-r-8 text-truncate"
title="{{ prop.label | translate }}"
[ngClass]="{ 'a-s-start': prop.file }"
>
{{ prop.label | translate }}
</label>
<span
class="m-l-auto"
[ngStyle]="{
'max-width': prop.file ? '50%' : '100%',
'min-width': '0'
}"
>
<c8y-asset-properties-item
[file]="prop.file"
[key]="prop.key"
[type]="prop.type"
[value]="prop.value"
></c8y-asset-properties-item>
</span>
</li>
}
</ul>
}
@case (type === 'number' || type === 'boolean' ? type : '') {
<p
class="text-truncate"
title="{{ value != null ? value : ('Undefined' | translate) }}"
>
{{ value != null ? value : ('Undefined' | translate) }}
</p>
}
@default {
<p
class="text-truncate"
title="{{ (value | translate) || ('Undefined' | translate) }}"
>
{{ (value | translate) || ('Undefined' | translate) }}
</p>
}
}
}
@if (isEdit) {
<formly-form
[form]="form"
[fields]="fields"
[model]="model"
></formly-form>
}