UI: Add new fields tag in ota package component
This commit is contained in:
parent
2af3be7827
commit
5a88034645
@ -62,6 +62,7 @@ public class OtaPackageInfo extends SearchTextBasedWithAdditionalInfo<OtaPackage
|
|||||||
this.type = otaPackageInfo.getType();
|
this.type = otaPackageInfo.getType();
|
||||||
this.title = otaPackageInfo.getTitle();
|
this.title = otaPackageInfo.getTitle();
|
||||||
this.version = otaPackageInfo.getVersion();
|
this.version = otaPackageInfo.getVersion();
|
||||||
|
this.tag = otaPackageInfo.getTag();
|
||||||
this.url = otaPackageInfo.getUrl();
|
this.url = otaPackageInfo.getUrl();
|
||||||
this.hasData = otaPackageInfo.isHasData();
|
this.hasData = otaPackageInfo.isHasData();
|
||||||
this.fileName = otaPackageInfo.getFileName();
|
this.fileName = otaPackageInfo.getFileName();
|
||||||
|
|||||||
@ -145,6 +145,7 @@ public class OtaPackageInfoEntity extends BaseSqlEntity<OtaPackageInfo> implemen
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.tag = tag;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
|
|||||||
@ -59,9 +59,10 @@ export class OtaUpdateTableConfigResolve implements Resolve<EntityTableConfig<Ot
|
|||||||
|
|
||||||
this.config.columns.push(
|
this.config.columns.push(
|
||||||
new DateEntityTableColumn<OtaPackageInfo>('createdTime', 'common.created-time', this.datePipe, '150px'),
|
new DateEntityTableColumn<OtaPackageInfo>('createdTime', 'common.created-time', this.datePipe, '150px'),
|
||||||
new EntityTableColumn<OtaPackageInfo>('title', 'ota-update.title', '20%'),
|
new EntityTableColumn<OtaPackageInfo>('title', 'ota-update.title', '15%'),
|
||||||
new EntityTableColumn<OtaPackageInfo>('version', 'ota-update.version', '20%'),
|
new EntityTableColumn<OtaPackageInfo>('version', 'ota-update.version', '15%'),
|
||||||
new EntityTableColumn<OtaPackageInfo>('type', 'ota-update.package-type', '20%', entity => {
|
new EntityTableColumn<OtaPackageInfo>('tag', 'ota-update.version-tag', '15%'),
|
||||||
|
new EntityTableColumn<OtaPackageInfo>('type', 'ota-update.package-type', '15%', entity => {
|
||||||
return this.translate.instant(OtaUpdateTypeTranslationMap.get(entity.type));
|
return this.translate.instant(OtaUpdateTypeTranslationMap.get(entity.type));
|
||||||
}),
|
}),
|
||||||
new EntityTableColumn<OtaPackageInfo>('url', 'ota-update.direct-url', '20%', entity => {
|
new EntityTableColumn<OtaPackageInfo>('url', 'ota-update.direct-url', '20%', entity => {
|
||||||
|
|||||||
@ -74,6 +74,11 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<mat-form-field class="mat-block" fxFlex style="margin-bottom: 8px">
|
||||||
|
<mat-label translate>ota-update.version-tag</mat-label>
|
||||||
|
<input matInput formControlName="tag" type="text" [readonly]="!isAdd">
|
||||||
|
<mat-hint *ngIf="isAdd" translate>ota-update.version-tag-hint</mat-hint>
|
||||||
|
</mat-form-field>
|
||||||
<tb-device-profile-autocomplete
|
<tb-device-profile-autocomplete
|
||||||
formControlName="deviceProfileId"
|
formControlName="deviceProfileId"
|
||||||
required
|
required
|
||||||
@ -94,8 +99,8 @@
|
|||||||
<section *ngIf="isAdd">
|
<section *ngIf="isAdd">
|
||||||
<div class="mat-caption" style="margin: -8px 0 8px;" translate>ota-update.warning-after-save-no-edit</div>
|
<div class="mat-caption" style="margin: -8px 0 8px;" translate>ota-update.warning-after-save-no-edit</div>
|
||||||
<mat-radio-group formControlName="isURL" fxLayoutGap="16px">
|
<mat-radio-group formControlName="isURL" fxLayoutGap="16px">
|
||||||
<mat-radio-button [value]="false">Upload binary file</mat-radio-button>
|
<mat-radio-button [value]="false">{{ "ota-update.upload-binary-file" | translate }}</mat-radio-button>
|
||||||
<mat-radio-button [value]="true">Use external URL</mat-radio-button>
|
<mat-radio-button [value]="true">{{ "ota-update.use-external-url" | translate }}</mat-radio-button>
|
||||||
</mat-radio-group>
|
</mat-radio-group>
|
||||||
</section>
|
</section>
|
||||||
<section *ngIf="!entityForm.get('isURL').value">
|
<section *ngIf="!entityForm.get('isURL').value">
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
///
|
///
|
||||||
|
|
||||||
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { combineLatest, Subject } from 'rxjs';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@core/core.state';
|
import { AppState } from '@core/core.state';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
@ -30,7 +30,7 @@ import {
|
|||||||
OtaUpdateTypeTranslationMap
|
OtaUpdateTypeTranslationMap
|
||||||
} from '@shared/models/ota-package.models';
|
} from '@shared/models/ota-package.models';
|
||||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
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';
|
import { isNotEmptyStr } from '@core/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -56,22 +56,36 @@ export class OtaUpdateComponent extends EntityComponent<OtaPackage> implements O
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
this.entityForm.get('isURL').valueChanges.pipe(
|
if (this.isAdd) {
|
||||||
filter(() => this.isAdd),
|
this.entityForm.get('isURL').valueChanges.pipe(
|
||||||
takeUntil(this.destroy$)
|
takeUntil(this.destroy$)
|
||||||
).subscribe((isURL) => {
|
).subscribe((isURL) => {
|
||||||
if (isURL === false) {
|
if (isURL === false) {
|
||||||
this.entityForm.get('url').clearValidators();
|
this.entityForm.get('url').clearValidators();
|
||||||
this.entityForm.get('file').setValidators(Validators.required);
|
this.entityForm.get('file').setValidators(Validators.required);
|
||||||
this.entityForm.get('url').updateValueAndValidity({emitEvent: false});
|
this.entityForm.get('url').updateValueAndValidity({emitEvent: false});
|
||||||
this.entityForm.get('file').updateValueAndValidity({emitEvent: false});
|
this.entityForm.get('file').updateValueAndValidity({emitEvent: false});
|
||||||
} else {
|
} else {
|
||||||
this.entityForm.get('file').clearValidators();
|
this.entityForm.get('file').clearValidators();
|
||||||
this.entityForm.get('url').setValidators([Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]);
|
this.entityForm.get('url').setValidators([Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]);
|
||||||
this.entityForm.get('file').updateValueAndValidity({emitEvent: false});
|
this.entityForm.get('file').updateValueAndValidity({emitEvent: false});
|
||||||
this.entityForm.get('url').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() {
|
ngOnDestroy() {
|
||||||
@ -92,6 +106,7 @@ export class OtaUpdateComponent extends EntityComponent<OtaPackage> implements O
|
|||||||
const form = this.fb.group({
|
const form = this.fb.group({
|
||||||
title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]],
|
title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]],
|
||||||
version: [entity ? entity.version : '', [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],
|
type: [entity?.type ? entity.type : OtaUpdateType.FIRMWARE, Validators.required],
|
||||||
deviceProfileId: [entity ? entity.deviceProfileId : null, Validators.required],
|
deviceProfileId: [entity ? entity.deviceProfileId : null, Validators.required],
|
||||||
checksumAlgorithm: [entity && entity.checksumAlgorithm ? entity.checksumAlgorithm : ChecksumAlgorithm.SHA256],
|
checksumAlgorithm: [entity && entity.checksumAlgorithm ? entity.checksumAlgorithm : ChecksumAlgorithm.SHA256],
|
||||||
@ -119,6 +134,7 @@ export class OtaUpdateComponent extends EntityComponent<OtaPackage> implements O
|
|||||||
this.entityForm.patchValue({
|
this.entityForm.patchValue({
|
||||||
title: entity.title,
|
title: entity.title,
|
||||||
version: entity.version,
|
version: entity.version,
|
||||||
|
tag: entity.tag,
|
||||||
type: entity.type,
|
type: entity.type,
|
||||||
deviceProfileId: entity.deviceProfileId,
|
deviceProfileId: entity.deviceProfileId,
|
||||||
checksumAlgorithm: entity.checksumAlgorithm,
|
checksumAlgorithm: entity.checksumAlgorithm,
|
||||||
|
|||||||
@ -91,6 +91,7 @@ export interface OtaPackageInfo extends BaseData<OtaPackageId> {
|
|||||||
deviceProfileId?: DeviceProfileId;
|
deviceProfileId?: DeviceProfileId;
|
||||||
title?: string;
|
title?: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
|
tag?: string;
|
||||||
hasData?: boolean;
|
hasData?: boolean;
|
||||||
url?: string;
|
url?: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
|
|||||||
@ -2342,8 +2342,12 @@
|
|||||||
"firmware": "Firmware",
|
"firmware": "Firmware",
|
||||||
"software": "Software"
|
"software": "Software"
|
||||||
},
|
},
|
||||||
|
"upload-binary-file": "Upload binary file",
|
||||||
|
"use-external-url": "Use external URL",
|
||||||
"version": "Version",
|
"version": "Version",
|
||||||
"version-required": "Version is required.",
|
"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."
|
"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": {
|
"position": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user