UI: Fixed in OTA package save checksum config for external URL

This commit is contained in:
Vladyslav Prykhodko 2025-05-30 00:11:19 +03:00
parent a6997cb4a1
commit 39ad13db0f
2 changed files with 24 additions and 21 deletions

View File

@ -36,8 +36,6 @@ import { PageLink } from '@shared/models/page/page-link';
import { OtaUpdateComponent } from '@home/pages/ota-update/ota-update.component'; import { OtaUpdateComponent } from '@home/pages/ota-update/ota-update.component';
import { EntityAction } from '@home/models/entity/entity-component.models'; import { EntityAction } from '@home/models/entity/entity-component.models';
import { FileSizePipe } from '@shared/pipe/file-size.pipe'; import { FileSizePipe } from '@shared/pipe/file-size.pipe';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
@Injectable() @Injectable()
export class OtaUpdateTableConfigResolve { export class OtaUpdateTableConfigResolve {
@ -47,7 +45,6 @@ export class OtaUpdateTableConfigResolve {
constructor(private translate: TranslateService, constructor(private translate: TranslateService,
private datePipe: DatePipe, private datePipe: DatePipe,
private store: Store<AppState>,
private otaPackageService: OtaPackageService, private otaPackageService: OtaPackageService,
private router: Router, private router: Router,
private fileSize: FileSizePipe) { private fileSize: FileSizePipe) {
@ -68,7 +65,9 @@ export class OtaUpdateTableConfigResolve {
}), }),
new EntityTableColumn<OtaPackageInfo>('url', 'ota-update.direct-url', '20%', entity => { new EntityTableColumn<OtaPackageInfo>('url', 'ota-update.direct-url', '20%', entity => {
return entity.url ? (entity.url.length > 20 ? `${entity.url.slice(0, 20)}` : entity.url) : ''; return entity.url ? (entity.url.length > 20 ? `${entity.url.slice(0, 20)}` : entity.url) : '';
}, () => ({}), true, () => ({}), () => undefined, false, }, () => ({
'text-wrap': 'nowrap'
}), true, () => ({}), () => undefined, false,
{ {
name: this.translate.instant('ota-update.copy-direct-url'), name: this.translate.instant('ota-update.copy-direct-url'),
icon: 'content_paste', icon: 'content_paste',
@ -78,7 +77,7 @@ export class OtaUpdateTableConfigResolve {
color: 'rgba(0,0,0,.87)' color: 'rgba(0,0,0,.87)'
}, },
isEnabled: (otaPackage) => !!otaPackage.url, isEnabled: (otaPackage) => !!otaPackage.url,
onAction: ($event, entity) => entity.url, onAction: (_$event, entity) => entity.url,
type: CellActionDescriptorType.COPY_BUTTON type: CellActionDescriptorType.COPY_BUTTON
}), }),
new EntityTableColumn<OtaPackageInfo>('fileName', 'ota-update.file-name', '20%'), new EntityTableColumn<OtaPackageInfo>('fileName', 'ota-update.file-name', '20%'),
@ -86,20 +85,22 @@ export class OtaUpdateTableConfigResolve {
return entity.dataSize ? this.fileSize.transform(entity.dataSize) : ''; return entity.dataSize ? this.fileSize.transform(entity.dataSize) : '';
}), }),
new EntityTableColumn<OtaPackageInfo>('checksum', 'ota-update.checksum', '220px', entity => { new EntityTableColumn<OtaPackageInfo>('checksum', 'ota-update.checksum', '220px', entity => {
return entity.checksum ? this.checksumText(entity) : ''; return entity.checksum ? this.checksumText(entity) : '';
}, () => ({}), true, () => ({}), () => undefined, false, }, () => ({
{ 'text-wrap': 'nowrap'
name: this.translate.instant('ota-update.copy-checksum'), }), true, () => ({}), () => undefined, false,
icon: 'content_paste', {
style: { name: this.translate.instant('ota-update.copy-checksum'),
padding: '4px', icon: 'content_paste',
'font-size': '16px', style: {
color: 'rgba(0,0,0,.87)' padding: '4px',
}, 'font-size': '16px',
isEnabled: (otaPackage) => !!otaPackage.checksum, color: 'rgba(0,0,0,.87)'
onAction: ($event, entity) => entity.checksum, },
type: CellActionDescriptorType.COPY_BUTTON isEnabled: (otaPackage) => !!otaPackage.checksum,
}) onAction: (_$event, entity) => entity.checksum,
type: CellActionDescriptorType.COPY_BUTTON
})
); );
this.config.cellActionDescriptors.push( this.config.cellActionDescriptors.push(
@ -149,7 +150,7 @@ export class OtaUpdateTableConfigResolve {
} }
} }
checksumText(entity): string { checksumText(entity: OtaPackageInfo): string {
let text = `${ChecksumAlgorithmTranslationMap.get(entity.checksumAlgorithm)}: ${entity.checksum}`; let text = `${ChecksumAlgorithmTranslationMap.get(entity.checksumAlgorithm)}: ${entity.checksum}`;
if (text.length > 20) { if (text.length > 20) {
text = `${text.slice(0, 20)}`; text = `${text.slice(0, 20)}`;

View File

@ -185,9 +185,11 @@ export class OtaUpdateComponent extends EntityComponent<OtaPackage> implements O
})); }));
} }
prepareFormValue(formValue: any): any { prepareFormValue(formValue: OtaPackage & {generateChecksum?: boolean}): any {
if (formValue.isURL) { if (formValue.isURL) {
delete formValue.file; delete formValue.file;
delete formValue.checksumAlgorithm;
delete formValue.checksum;
} else { } else {
delete formValue.url; delete formValue.url;
} }