diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java b/common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java index b6a6df3b7e..d50aa70dcb 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/OtaPackageInfo.java @@ -62,6 +62,7 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo implemen this.type = type; this.title = title; this.version = version; + this.tag = tag; this.url = url; this.fileName = fileName; this.contentType = contentType; diff --git a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update-table-config.resolve.ts b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update-table-config.resolve.ts index 0f542bec8a..ef730bf4a6 100644 --- a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update-table-config.resolve.ts +++ b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update-table-config.resolve.ts @@ -59,9 +59,10 @@ export class OtaUpdateTableConfigResolve implements Resolve('createdTime', 'common.created-time', this.datePipe, '150px'), - new EntityTableColumn('title', 'ota-update.title', '20%'), - new EntityTableColumn('version', 'ota-update.version', '20%'), - new EntityTableColumn('type', 'ota-update.package-type', '20%', entity => { + new EntityTableColumn('title', 'ota-update.title', '15%'), + new EntityTableColumn('version', 'ota-update.version', '15%'), + new EntityTableColumn('tag', 'ota-update.version-tag', '15%'), + new EntityTableColumn('type', 'ota-update.package-type', '15%', entity => { return this.translate.instant(OtaUpdateTypeTranslationMap.get(entity.type)); }), new EntityTableColumn('url', 'ota-update.direct-url', '20%', entity => { diff --git a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.html b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.html index be3a2ead31..fa6e0428eb 100644 --- a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.html +++ b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.html @@ -74,6 +74,11 @@ + + ota-update.version-tag + + ota-update.version-tag-hint +
ota-update.warning-after-save-no-edit
- Upload binary file - Use external URL + {{ "ota-update.upload-binary-file" | translate }} + {{ "ota-update.use-external-url" | translate }}
diff --git a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.ts b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.ts index 9fd51302e1..50c2d8bb56 100644 --- a/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.ts +++ b/ui-ngx/src/app/modules/home/pages/ota-update/ota-update.component.ts @@ -15,7 +15,7 @@ /// import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; -import { Subject } from 'rxjs'; +import { combineLatest, Subject } from 'rxjs'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { TranslateService } from '@ngx-translate/core'; @@ -30,7 +30,7 @@ import { OtaUpdateTypeTranslationMap } from '@shared/models/ota-package.models'; import { ActionNotificationShow } from '@core/notification/notification.actions'; -import { filter, takeUntil } from 'rxjs/operators'; +import { filter, startWith, takeUntil } from 'rxjs/operators'; import { isNotEmptyStr } from '@core/utils'; @Component({ @@ -56,22 +56,36 @@ export class OtaUpdateComponent extends EntityComponent implements O ngOnInit() { super.ngOnInit(); - this.entityForm.get('isURL').valueChanges.pipe( - filter(() => this.isAdd), - takeUntil(this.destroy$) - ).subscribe((isURL) => { - if (isURL === false) { - this.entityForm.get('url').clearValidators(); - this.entityForm.get('file').setValidators(Validators.required); - this.entityForm.get('url').updateValueAndValidity({emitEvent: false}); - this.entityForm.get('file').updateValueAndValidity({emitEvent: false}); - } else { - this.entityForm.get('file').clearValidators(); - this.entityForm.get('url').setValidators([Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]); - this.entityForm.get('file').updateValueAndValidity({emitEvent: false}); - this.entityForm.get('url').updateValueAndValidity({emitEvent: false}); - } - }); + if (this.isAdd) { + this.entityForm.get('isURL').valueChanges.pipe( + takeUntil(this.destroy$) + ).subscribe((isURL) => { + if (isURL === false) { + this.entityForm.get('url').clearValidators(); + this.entityForm.get('file').setValidators(Validators.required); + this.entityForm.get('url').updateValueAndValidity({emitEvent: false}); + this.entityForm.get('file').updateValueAndValidity({emitEvent: false}); + } else { + this.entityForm.get('file').clearValidators(); + this.entityForm.get('url').setValidators([Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]); + this.entityForm.get('file').updateValueAndValidity({emitEvent: false}); + this.entityForm.get('url').updateValueAndValidity({emitEvent: false}); + } + }); + combineLatest([ + this.entityForm.get('title').valueChanges.pipe(startWith(''), takeUntil(this.destroy$)), + this.entityForm.get('version').valueChanges.pipe(startWith(''), takeUntil(this.destroy$)) + ]).pipe( + filter(() => this.entityForm.get('tag').pristine), + takeUntil(this.destroy$) + ).subscribe(([title, version]) => { + let tag = `${title} ${version}`.trim(); + if (tag === '') { + tag = ''; + } + this.entityForm.get('tag').patchValue(tag); + }); + } } ngOnDestroy() { @@ -92,6 +106,7 @@ export class OtaUpdateComponent extends EntityComponent implements O const form = this.fb.group({ title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]], version: [entity ? entity.version : '', [Validators.required, Validators.maxLength(255)]], + tag: [entity ? entity.tag : '', [Validators.maxLength(255)]], type: [entity?.type ? entity.type : OtaUpdateType.FIRMWARE, Validators.required], deviceProfileId: [entity ? entity.deviceProfileId : null, Validators.required], checksumAlgorithm: [entity && entity.checksumAlgorithm ? entity.checksumAlgorithm : ChecksumAlgorithm.SHA256], @@ -119,6 +134,7 @@ export class OtaUpdateComponent extends EntityComponent implements O this.entityForm.patchValue({ title: entity.title, version: entity.version, + tag: entity.tag, type: entity.type, deviceProfileId: entity.deviceProfileId, checksumAlgorithm: entity.checksumAlgorithm, diff --git a/ui-ngx/src/app/shared/models/ota-package.models.ts b/ui-ngx/src/app/shared/models/ota-package.models.ts index a27330235a..f91664612a 100644 --- a/ui-ngx/src/app/shared/models/ota-package.models.ts +++ b/ui-ngx/src/app/shared/models/ota-package.models.ts @@ -91,6 +91,7 @@ export interface OtaPackageInfo extends BaseData { deviceProfileId?: DeviceProfileId; title?: string; version?: string; + tag?: string; hasData?: boolean; url?: string; fileName: string; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index c7c9a8302e..2b51a0ef28 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -2342,8 +2342,12 @@ "firmware": "Firmware", "software": "Software" }, + "upload-binary-file": "Upload binary file", + "use-external-url": "Use external URL", "version": "Version", "version-required": "Version is required.", + "version-tag": "Version Tag", + "version-tag-hint": "Custom tag should match the package version reported by your device.", "warning-after-save-no-edit": "Once the package is uploaded, you will not be able to modify title, version, device profile and package type." }, "position": {