Commit fd8dee0a9d5252d6d65d8bfeef906bf401e3ee61

Authored by Vladyslav_Prykhodko
Committed by Andrew Shvayka
1 parent ca2e08f8

UI: Add firmware type

... ... @@ -361,7 +361,7 @@ export class EntityService {
361 361 break;
362 362 case EntityType.FIRMWARE:
363 363 pageLink.sortOrder.property = 'title';
364   - entitiesObservable = this.firmwareService.getFirmwares(pageLink, true, config);
  364 + entitiesObservable = this.firmwareService.getFirmwares(pageLink, config);
365 365 break;
366 366 }
367 367 return entitiesObservable;
... ...
... ... @@ -20,7 +20,7 @@ import { PageLink } from '@shared/models/page/page-link';
20 20 import { defaultHttpOptionsFromConfig, defaultHttpUploadOptions, RequestConfig } from '@core/http/http-utils';
21 21 import { Observable } from 'rxjs';
22 22 import { PageData } from '@shared/models/page/page-data';
23   -import { Firmware, FirmwareInfo } from '@shared/models/firmware.models';
  23 +import { Firmware, FirmwareInfo, FirmwareType } from '@shared/models/firmware.models';
24 24 import { catchError, map, mergeMap } from 'rxjs/operators';
25 25 import { deepClone, isDefinedAndNotNull } from '@core/utils';
26 26
... ... @@ -34,12 +34,13 @@ export class FirmwareService {
34 34
35 35 }
36 36
37   - public getFirmwares(pageLink: PageLink, hasData?: boolean, config?: RequestConfig): Observable<PageData<FirmwareInfo>> {
38   - let url = `/api/firmwares`;
39   - if (isDefinedAndNotNull(hasData)) {
40   - url += `/${hasData}`;
41   - }
42   - url += `${pageLink.toQuery()}`;
  37 + public getFirmwares(pageLink: PageLink, config?: RequestConfig): Observable<PageData<FirmwareInfo>> {
  38 + return this.http.get<PageData<FirmwareInfo>>(`/api/firmwares${pageLink.toQuery()}`, defaultHttpOptionsFromConfig(config));
  39 + }
  40 +
  41 + public getFirmwaresInfoByDeviceProfileId(pageLink: PageLink, deviceProfileId: string, type: FirmwareType,
  42 + hasData = true, config?: RequestConfig): Observable<PageData<FirmwareInfo>> {
  43 + const url = `/api/firmwares/${deviceProfileId}/${type}/${hasData}${pageLink.toQuery()}`;
43 44 return this.http.get<PageData<FirmwareInfo>>(url, defaultHttpOptionsFromConfig(config));
44 45 }
45 46
... ...
... ... @@ -60,10 +60,6 @@
60 60 {{ 'device-profile.type-required' | translate }}
61 61 </mat-error>
62 62 </mat-form-field>
63   - <tb-firmware-autocomplete
64   - [useFullEntityId]="true"
65   - formControlName="firmwareId">
66   - </tb-firmware-autocomplete>
67 63 <mat-form-field class="mat-block">
68 64 <mat-label translate>device-profile.description</mat-label>
69 65 <textarea matInput formControlName="description" rows="2"></textarea>
... ...
... ... @@ -108,7 +108,6 @@ export class AddDeviceProfileDialogComponent extends
108 108 type: [DeviceProfileType.DEFAULT, [Validators.required]],
109 109 defaultRuleChainId: [null, []],
110 110 defaultQueueName: ['', []],
111   - firmwareId: [null],
112 111 description: ['', []]
113 112 }
114 113 );
... ... @@ -187,7 +186,6 @@ export class AddDeviceProfileDialogComponent extends
187 186 transportType: this.transportConfigFormGroup.get('transportType').value,
188 187 provisionType: deviceProvisionConfiguration.type,
189 188 provisionDeviceKey,
190   - firmwareId: this.deviceProfileDetailsFormGroup.get('firmwareId').value,
191 189 description: this.deviceProfileDetailsFormGroup.get('description').value,
192 190 profileData: {
193 191 configuration: createDeviceProfileConfiguration(DeviceProfileType.DEFAULT),
... ...
... ... @@ -65,8 +65,16 @@
65 65 </tb-queue-type-list>
66 66 <tb-firmware-autocomplete
67 67 [useFullEntityId]="true"
  68 + [type]="firmwareTypes.FIRMWARE"
  69 + [deviceProfileId]="deviceProfileId?.id"
68 70 formControlName="firmwareId">
69 71 </tb-firmware-autocomplete>
  72 + <tb-firmware-autocomplete
  73 + [useFullEntityId]="true"
  74 + [type]="firmwareTypes.SOFTWARE"
  75 + [deviceProfileId]="deviceProfileId?.id"
  76 + formControlName="softwareId">
  77 + </tb-firmware-autocomplete>
70 78 <mat-form-field fxHide class="mat-block">
71 79 <mat-label translate>device-profile.type</mat-label>
72 80 <mat-select formControlName="type" required>
... ...
... ... @@ -40,6 +40,7 @@ import { EntityType } from '@shared/models/entity-type.models';
40 40 import { RuleChainId } from '@shared/models/id/rule-chain-id';
41 41 import { ServiceType } from '@shared/models/queue.models';
42 42 import { EntityId } from '@shared/models/id/entity-id';
  43 +import { FirmwareType } from '@shared/models/firmware.models';
43 44
44 45 @Component({
45 46 selector: 'tb-device-profile',
... ... @@ -69,6 +70,8 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
69 70
70 71 deviceProfileId: EntityId;
71 72
  73 + firmwareTypes = FirmwareType;
  74 +
72 75 constructor(protected store: Store<AppState>,
73 76 protected translate: TranslateService,
74 77 @Optional() @Inject('entity') protected entityValue: DeviceProfile,
... ... @@ -110,6 +113,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
110 113 defaultRuleChainId: [entity && entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null, []],
111 114 defaultQueueName: [entity ? entity.defaultQueueName : '', []],
112 115 firmwareId: [entity ? entity.firmwareId : null],
  116 + softwareId: [entity ? entity.softwareId : null],
113 117 description: [entity ? entity.description : '', []],
114 118 }
115 119 );
... ... @@ -186,6 +190,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
186 190 this.entityForm.patchValue({defaultRuleChainId: entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null}, {emitEvent: false});
187 191 this.entityForm.patchValue({defaultQueueName: entity.defaultQueueName}, {emitEvent: false});
188 192 this.entityForm.patchValue({firmwareId: entity.firmwareId}, {emitEvent: false});
  193 + this.entityForm.patchValue({softwareId: entity.softwareId}, {emitEvent: false});
189 194 this.entityForm.patchValue({description: entity.description}, {emitEvent: false});
190 195 }
191 196
... ...
... ... @@ -48,10 +48,6 @@
48 48 <mat-label translate>device.label</mat-label>
49 49 <input matInput formControlName="label">
50 50 </mat-form-field>
51   - <tb-firmware-autocomplete
52   - [useFullEntityId]="true"
53   - formControlName="firmwareId">
54   - </tb-firmware-autocomplete>
55 51 <mat-form-field class="mat-block" style="padding-bottom: 14px;">
56 52 <mat-label translate>device-profile.transport-type</mat-label>
57 53 <mat-select formControlName="transportType" required>
... ...
... ... @@ -107,7 +107,6 @@ export class DeviceWizardDialogComponent extends
107 107 this.deviceWizardFormGroup = this.fb.group({
108 108 name: ['', Validators.required],
109 109 label: [''],
110   - firmwareId: [null],
111 110 gateway: [false],
112 111 overwriteActivityTime: [false],
113 112 transportType: [DeviceTransportType.DEFAULT, Validators.required],
... ... @@ -313,7 +312,6 @@ export class DeviceWizardDialogComponent extends
313 312 const device = {
314 313 name: this.deviceWizardFormGroup.get('name').value,
315 314 label: this.deviceWizardFormGroup.get('label').value,
316   - firmwareId: this.deviceWizardFormGroup.get('firmwareId').value,
317 315 deviceProfileId: profileId,
318 316 additionalInfo: {
319 317 gateway: this.deviceWizardFormGroup.get('gateway').value,
... ...
... ... @@ -103,8 +103,16 @@
103 103 </mat-form-field>
104 104 <tb-firmware-autocomplete
105 105 [useFullEntityId]="true"
  106 + [type]="firmwareTypes.FIRMWARE"
  107 + [deviceProfileId]="entityForm.get('deviceProfileId').value?.id"
106 108 formControlName="firmwareId">
107 109 </tb-firmware-autocomplete>
  110 + <tb-firmware-autocomplete
  111 + [useFullEntityId]="true"
  112 + [type]="firmwareTypes.SOFTWARE"
  113 + [deviceProfileId]="entityForm.get('deviceProfileId').value?.id"
  114 + formControlName="softwareId">
  115 + </tb-firmware-autocomplete>
108 116 <tb-device-data
109 117 formControlName="deviceData"
110 118 required>
... ...
... ... @@ -34,6 +34,7 @@ import { ActionNotificationShow } from '@core/notification/notification.actions'
34 34 import { TranslateService } from '@ngx-translate/core';
35 35 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
36 36 import { Subject } from 'rxjs';
  37 +import { FirmwareType } from '@shared/models/firmware.models';
37 38
38 39 @Component({
39 40 selector: 'tb-device',
... ... @@ -48,6 +49,8 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
48 49
49 50 deviceScope: 'tenant' | 'customer' | 'customer_user' | 'edge';
50 51
  52 + firmwareTypes = FirmwareType;
  53 +
51 54 constructor(protected store: Store<AppState>,
52 55 protected translate: TranslateService,
53 56 @Inject('entity') protected entityValue: DeviceInfo,
... ... @@ -80,6 +83,7 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
80 83 name: [entity ? entity.name : '', [Validators.required]],
81 84 deviceProfileId: [entity ? entity.deviceProfileId : null, [Validators.required]],
82 85 firmwareId: [entity ? entity.firmwareId : null],
  86 + softwareId: [entity ? entity.softwareId : null],
83 87 label: [entity ? entity.label : ''],
84 88 deviceData: [entity ? entity.deviceData : null, [Validators.required]],
85 89 additionalInfo: this.fb.group(
... ... @@ -94,19 +98,19 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
94 98 }
95 99
96 100 updateForm(entity: DeviceInfo) {
97   - this.entityForm.patchValue({name: entity.name});
98   - this.entityForm.patchValue({deviceProfileId: entity.deviceProfileId});
99   - this.entityForm.patchValue({firmwareId: entity.firmwareId});
100   - this.entityForm.patchValue({label: entity.label});
101   - this.entityForm.patchValue({deviceData: entity.deviceData});
102 101 this.entityForm.patchValue({
103   - additionalInfo:
104   - {
105   - gateway: entity.additionalInfo ? entity.additionalInfo.gateway : false,
106   - overwriteActivityTime: entity.additionalInfo ? entity.additionalInfo.overwriteActivityTime : false
107   - }
  102 + name: entity.name,
  103 + deviceProfileId: entity.deviceProfileId,
  104 + firmwareId: entity.firmwareId,
  105 + softwareId: entity.softwareId,
  106 + label: entity.label,
  107 + deviceData: entity.deviceData,
  108 + additionalInfo: {
  109 + gateway: entity.additionalInfo ? entity.additionalInfo.gateway : false,
  110 + overwriteActivityTime: entity.additionalInfo ? entity.additionalInfo.overwriteActivityTime : false,
  111 + description: entity.additionalInfo ? entity.additionalInfo.description : ''
  112 + }
108 113 });
109   - this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
110 114 }
111 115
112 116
... ... @@ -152,6 +156,10 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> {
152 156 this.entityForm.markAsDirty();
153 157 }
154 158 }
  159 + this.entityForm.patchValue({
  160 + firmwareId: null,
  161 + softwareId: null
  162 + });
155 163 }
156 164 }
157 165 }
... ...
... ... @@ -21,7 +21,12 @@ import {
21 21 EntityTableColumn,
22 22 EntityTableConfig
23 23 } from '@home/models/entity/entities-table-config.models';
24   -import { Firmware, FirmwareInfo } from '@shared/models/firmware.models';
  24 +import {
  25 + ChecksumAlgorithmTranslationMap,
  26 + Firmware,
  27 + FirmwareInfo,
  28 + FirmwareTypeTranslationMap
  29 +} from '@shared/models/firmware.models';
25 30 import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models';
26 31 import { TranslateService } from '@ngx-translate/core';
27 32 import { DatePipe } from '@angular/common';
... ... @@ -49,14 +54,17 @@ export class FirmwareTableConfigResolve implements Resolve<EntityTableConfig<Fir
49 54
50 55 this.config.columns.push(
51 56 new DateEntityTableColumn<FirmwareInfo>('createdTime', 'common.created-time', this.datePipe, '150px'),
52   - new EntityTableColumn<FirmwareInfo>('title', 'firmware.title', '33%'),
53   - new EntityTableColumn<FirmwareInfo>('version', 'firmware.version', '33%'),
54   - new EntityTableColumn<FirmwareInfo>('fileName', 'firmware.file-name', '33%'),
  57 + new EntityTableColumn<FirmwareInfo>('title', 'firmware.title', '25%'),
  58 + new EntityTableColumn<FirmwareInfo>('version', 'firmware.version', '25%'),
  59 + new EntityTableColumn<FirmwareInfo>('type', 'firmware.type', '25%', entity => {
  60 + return this.translate.instant(FirmwareTypeTranslationMap.get(entity.type));
  61 + }),
  62 + new EntityTableColumn<FirmwareInfo>('fileName', 'firmware.file-name', '25%'),
55 63 new EntityTableColumn<FirmwareInfo>('dataSize', 'firmware.file-size', '70px', entity => {
56 64 return this.fileSize.transform(entity.dataSize || 0);
57 65 }),
58 66 new EntityTableColumn<FirmwareInfo>('checksum', 'firmware.checksum', '540px', entity => {
59   - return `${entity.checksumAlgorithm}: ${entity.checksum}`;
  67 + return `${ChecksumAlgorithmTranslationMap.get(entity.checksumAlgorithm)}: ${entity.checksum}`;
60 68 }, () => ({}), false)
61 69 );
62 70
... ...
... ... @@ -67,10 +67,27 @@
67 67 </mat-error>
68 68 </mat-form-field>
69 69 </div>
  70 + <div fxLayout="row" fxLayoutGap.gt-xs="8px" fxLayout.xs="column">
  71 + <mat-form-field fxFlex="45">
  72 + <mat-label translate>firmware.type</mat-label>
  73 + <input *ngIf="!isAdd" matInput type="text" [readonly]="isEdit" [disabled]="!isEdit"
  74 + value="{{ firmwareTypeTranslationMap.get(entityForm.get('type').value) | translate }}">
  75 + <mat-select formControlName="type" required *ngIf="isAdd">
  76 + <mat-option *ngFor="let firmwareType of firmwareTypes" [value]="firmwareType">
  77 + {{ firmwareTypeTranslationMap.get(firmwareType) | translate }}
  78 + </mat-option>
  79 + </mat-select>
  80 + </mat-form-field>
  81 + <tb-device-profile-autocomplete
  82 + formControlName="deviceProfileId" fxFlex
  83 + [editProfileEnabled]="false">
  84 + </tb-device-profile-autocomplete>
  85 + </div>
70 86 <div fxLayout="row" fxLayoutGap.gt-xs="8px" fxLayoutGap.sm="8px" fxLayout.xs="column" fxLayout.md="column">
71 87 <mat-form-field class="mat-block" fxFlex="33">
72 88 <mat-label translate>firmware.checksum-algorithm</mat-label>
73   - <input *ngIf="!isAdd" matInput formControlName="checksumAlgorithm" type="text" [readonly]="isEdit">
  89 + <input *ngIf="!isAdd" matInput type="text" [readonly]="isEdit" [disabled]="!isEdit"
  90 + value="{{ checksumAlgorithmTranslationMap.get(entityForm.get('checksumAlgorithm').value) | translate }}">
74 91 <mat-select formControlName="checksumAlgorithm" *ngIf="isAdd">
75 92 <mat-option [value]=null></mat-option>
76 93 <mat-option *ngFor="let checksumAlgorithm of checksumAlgorithms" [value]="checksumAlgorithm">
... ...
... ... @@ -22,7 +22,13 @@ import { TranslateService } from '@ngx-translate/core';
22 22 import { EntityTableConfig } from '@home/models/entity/entities-table-config.models';
23 23 import { FormBuilder, FormGroup, Validators } from '@angular/forms';
24 24 import { EntityComponent } from '@home/components/entity/entity.component';
25   -import { ChecksumAlgorithm, ChecksumAlgorithmTranslationMap, Firmware } from '@shared/models/firmware.models';
  25 +import {
  26 + ChecksumAlgorithm,
  27 + ChecksumAlgorithmTranslationMap,
  28 + Firmware,
  29 + FirmwareType,
  30 + FirmwareTypeTranslationMap
  31 +} from '@shared/models/firmware.models';
26 32 import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
27 33 import { ActionNotificationShow } from '@core/notification/notification.actions';
28 34
... ... @@ -36,6 +42,8 @@ export class FirmwaresComponent extends EntityComponent<Firmware> implements OnI
36 42
37 43 checksumAlgorithms = Object.values(ChecksumAlgorithm);
38 44 checksumAlgorithmTranslationMap = ChecksumAlgorithmTranslationMap;
  45 + firmwareTypes = Object.values(FirmwareType);
  46 + firmwareTypeTranslationMap = FirmwareTypeTranslationMap;
39 47
40 48 constructor(protected store: Store<AppState>,
41 49 protected translate: TranslateService,
... ... @@ -83,6 +91,8 @@ export class FirmwaresComponent extends EntityComponent<Firmware> implements OnI
83 91 const form = this.fb.group({
84 92 title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]],
85 93 version: [entity ? entity.version : '', [Validators.required, Validators.maxLength(255)]],
  94 + type: [entity?.type ? entity.type : FirmwareType.FIRMWARE, [Validators.required]],
  95 + deviceProfileId: [entity ? entity.deviceProfileId : null],
86 96 checksumAlgorithm: [entity ? entity.checksumAlgorithm : null],
87 97 checksum: [entity ? entity.checksum : '', Validators.maxLength(1020)],
88 98 additionalInfo: this.fb.group(
... ... @@ -105,6 +115,8 @@ export class FirmwaresComponent extends EntityComponent<Firmware> implements OnI
105 115 this.entityForm.patchValue({
106 116 title: entity.title,
107 117 version: entity.version,
  118 + type: entity.type,
  119 + deviceProfileId: entity.deviceProfileId,
108 120 checksumAlgorithm: entity.checksumAlgorithm,
109 121 checksum: entity.checksum,
110 122 fileName: entity.fileName,
... ...
... ... @@ -37,11 +37,11 @@
37 37 <mat-option *ngIf="!(filteredFirmwares | async)?.length" [value]="null" class="tb-not-found">
38 38 <div class="tb-not-found-content" (click)="$event.stopPropagation()">
39 39 <div *ngIf="!textIsNotEmpty(searchText); else searchNotEmpty">
40   - <span translate>firmware.no-firmware-text</span>
  40 + <span>{{ notFoundFirmware | translate }}</span>
41 41 </div>
42 42 <ng-template #searchNotEmpty>
43 43 <span>
44   - {{ translate.get('firmware.no-firmware-matching',
  44 + {{ translate.get(notMatchingFirmware,
45 45 {entity: truncate.transform(searchText, true, 6, &apos;...&apos;)}) | async }}
46 46 </span>
47 47 </ng-template>
... ...
... ... @@ -28,7 +28,7 @@ import { BaseData } from '@shared/models/base-data';
28 28 import { EntityService } from '@core/http/entity.service';
29 29 import { TruncatePipe } from '@shared/pipe/truncate.pipe';
30 30 import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
31   -import { FirmwareInfo } from '@shared/models/firmware.models';
  31 +import { FirmwareInfo, FirmwareType } from '@shared/models/firmware.models';
32 32 import { FirmwareService } from '@core/http/firmware.service';
33 33 import { PageLink } from '@shared/models/page/page-link';
34 34 import { Direction } from '@shared/models/page/sort-order';
... ... @@ -50,6 +50,12 @@ export class FirmwareAutocompleteComponent implements ControlValueAccessor, OnIn
50 50 modelValue: string | null;
51 51
52 52 @Input()
  53 + type = FirmwareType.FIRMWARE;
  54 +
  55 + @Input()
  56 + deviceProfileId: string;
  57 +
  58 + @Input()
53 59 labelText: string;
54 60
55 61 @Input()
... ... @@ -81,6 +87,23 @@ export class FirmwareAutocompleteComponent implements ControlValueAccessor, OnIn
81 87
82 88 private dirty = false;
83 89
  90 + private firmwareTypeTranslation = new Map<FirmwareType, any>(
  91 + [
  92 + [FirmwareType.FIRMWARE, {
  93 + label: 'firmware.firmware',
  94 + required: 'firmware.firmware-required',
  95 + noFound: 'firmware.no-firmware-text',
  96 + noMatching: 'firmware.no-firmware-matching'
  97 + }],
  98 + [FirmwareType.SOFTWARE, {
  99 + label: 'firmware.software',
  100 + required: 'firmware.software-required',
  101 + noFound: 'firmware.no-software-text',
  102 + noMatching: 'firmware.no-software-matching'
  103 + }]
  104 + ]
  105 + );
  106 +
84 107 private propagateChange = (v: any) => { };
85 108
86 109 constructor(private store: Store<AppState>,
... ... @@ -209,7 +232,8 @@ export class FirmwareAutocompleteComponent implements ControlValueAccessor, OnIn
209 232 property: 'title',
210 233 direction: Direction.ASC
211 234 });
212   - return this.firmwareService.getFirmwares(pageLink, true, {ignoreLoading: true}).pipe(
  235 + return this.firmwareService.getFirmwaresInfoByDeviceProfileId(pageLink, this.deviceProfileId, this.type,
  236 + true, {ignoreLoading: true}).pipe(
213 237 map((data) => data && data.data.length ? data.data : null)
214 238 );
215 239 }
... ... @@ -223,11 +247,19 @@ export class FirmwareAutocompleteComponent implements ControlValueAccessor, OnIn
223 247 }
224 248
225 249 get placeholderText(): string {
226   - return this.labelText || 'firmware.firmware';
  250 + return this.labelText || this.firmwareTypeTranslation.get(this.type).label;
227 251 }
228 252
229 253 get requiredErrorText(): string {
230   - return this.requiredText || 'firmware.firmware-required';
  254 + return this.requiredText || this.firmwareTypeTranslation.get(this.type).required;
  255 + }
  256 +
  257 + get notFoundFirmware(): string {
  258 + return this.firmwareTypeTranslation.get(this.type).noFound;
  259 + }
  260 +
  261 + get notMatchingFirmware(): string {
  262 + return this.firmwareTypeTranslation.get(this.type).noMatching;
231 263 }
232 264
233 265 firmwareTitleText(firmware: FirmwareInfo): string {
... ...
... ... @@ -467,6 +467,7 @@ export interface DeviceProfile extends BaseData<DeviceProfileId> {
467 467 defaultRuleChainId?: RuleChainId;
468 468 defaultQueueName?: string;
469 469 firmwareId?: FirmwareId;
  470 + softwareId?: FirmwareId;
470 471 profileData: DeviceProfileData;
471 472 }
472 473
... ... @@ -522,6 +523,7 @@ export interface Device extends BaseData<DeviceId> {
522 523 type: string;
523 524 label: string;
524 525 firmwareId?: FirmwareId;
  526 + softwareId?: FirmwareId;
525 527 deviceProfileId?: DeviceProfileId;
526 528 deviceData?: DeviceData;
527 529 additionalInfo?: any;
... ...
... ... @@ -17,6 +17,7 @@
17 17 import { BaseData } from '@shared/models/base-data';
18 18 import { TenantId } from '@shared/models/id/tenant-id';
19 19 import { FirmwareId } from '@shared/models/id/firmware-id';
  20 +import { DeviceProfileId } from '@shared/models/id/device-profile-id';
20 21
21 22 export enum ChecksumAlgorithm {
22 23 MD5 = 'md5',
... ... @@ -32,14 +33,28 @@ export const ChecksumAlgorithmTranslationMap = new Map<ChecksumAlgorithm, string
32 33 ]
33 34 );
34 35
  36 +export enum FirmwareType {
  37 + FIRMWARE = 'FIRMWARE',
  38 + SOFTWARE = 'SOFTWARE'
  39 +}
  40 +
  41 +export const FirmwareTypeTranslationMap = new Map<FirmwareType, string>(
  42 + [
  43 + [FirmwareType.FIRMWARE, 'firmware.types.firmware'],
  44 + [FirmwareType.SOFTWARE, 'firmware.types.software']
  45 + ]
  46 +);
  47 +
35 48 export interface FirmwareInfo extends BaseData<FirmwareId> {
36 49 tenantId?: TenantId;
  50 + type: FirmwareType;
  51 + deviceProfileId?: DeviceProfileId;
37 52 title?: string;
38 53 version?: string;
39 54 hasData?: boolean;
40 55 fileName: string;
41   - checksum?: ChecksumAlgorithm;
42   - checksumAlgorithm?: string;
  56 + checksum?: string;
  57 + checksumAlgorithm?: ChecksumAlgorithm;
43 58 contentType: string;
44 59 dataSize?: number;
45 60 additionalInfo?: any;
... ...
... ... @@ -1928,6 +1928,8 @@
1928 1928 "idCopiedMessage": "Firmware Id has been copied to clipboard",
1929 1929 "no-firmware-matching": "No firmware matching '{{entity}}' were found.",
1930 1930 "no-firmware-text": "No firmwares found",
  1931 + "no-software-matching": "No sowtware matching '{{entity}}' were found.",
  1932 + "no-software-text": "No software found",
1931 1933 "file-name": "File name",
1932 1934 "file-size": "File size",
1933 1935 "file-size-bytes": "File size in bytes",
... ... @@ -1936,8 +1938,15 @@
1936 1938 "firmware-required": "Firmware is required.",
1937 1939 "search": "Search firmwares",
1938 1940 "selected-firmware": "{ count, plural, 1 {1 firmware} other {# firmwares} } selected",
  1941 + "software": "Software",
  1942 + "software-required": "Software is required.",
1939 1943 "title": "Title",
1940 1944 "title-required": "Title is required.",
  1945 + "type": "Firmware type",
  1946 + "types": {
  1947 + "firmware": "Firmware",
  1948 + "software": "Software"
  1949 + },
1941 1950 "version": "Version",
1942 1951 "version-required": "Version is required.",
1943 1952 "warning-after-save-no-edit": "Once the firmware is saved, it will not be possible to change the title and version fields."
... ...