Commit 4574f7b7 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

fix: hide checksum option if not managed by backend

parent 07e76def
......@@ -101,96 +101,98 @@
</li>
</ul>
<ng-container *ngIf="formArray.at(i) as formGroup">
<div class="checksum-header-wrapper">
<mat-checkbox *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.isChecksumUser) as fd"
[formControl]="fd"
color="primary"
class="provide-checksums"
>
{{labelTranslateEnum.provideChecksums | translate}}
</mat-checkbox>
<div *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedIsLoadingCounter)?.value > 0 as isLoading"
class="checksum-generated-indicator"
[solidifySpinner]="isLoading"
[solidifySpinnerDiameter]="24"
[solidifySpinnerStrokeWidth]="2"
>
</div>
</div>
<div *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.isChecksumUser)?.value | isTrue"
class="user-checksums"
>
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserMd5) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
<mat-label>MD5</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_MD5"
matInput
<ng-template [ngIf]="checksumUsed | isNonEmptyArray">
<ng-container *ngIf="formArray.at(i) as formGroup">
<div class="checksum-header-wrapper">
<mat-checkbox *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.isChecksumUser) as fd"
[formControl]="fd"
color="primary"
class="provide-checksums"
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedMd5).value"
solidifyTooltipOnEllipsis
{{labelTranslateEnum.provideChecksums | translate}}
</mat-checkbox>
<div *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedIsLoadingCounter)?.value > 0 as isLoading"
class="checksum-generated-indicator"
[solidifySpinner]="isLoading"
[solidifySpinnerDiameter]="24"
[solidifySpinnerStrokeWidth]="2"
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedMd5).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
</div>
</div>
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserSha1) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
<div *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.isChecksumUser)?.value | isTrue"
class="user-checksums"
>
<mat-label>SHA-1</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_SHA1"
matInput
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserMd5) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha1).value"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha1).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
<mat-label>MD5</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_MD5"
matInput
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedMd5).value"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedMd5).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserSha256) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
<mat-label>SHA-256</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_SHA256"
matInput
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha256).value"
solidifyTooltipOnEllipsis
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserSha1) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha256).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
<mat-label>SHA-1</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_SHA1"
matInput
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha1).value"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha1).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserCrc32) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
<mat-label>CRC32</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_CRC32"
matInput
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserSha256) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedCrc32).value"
solidifyTooltipOnEllipsis
<mat-label>SHA-256</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_SHA256"
matInput
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha256).value"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedSha256).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumUserCrc32) as fd"
[appearance]="appearanceInputMaterial"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedCrc32).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
</div>
</ng-container>
<mat-label>CRC32</mat-label>
<input [formControl]="fd"
[required]="formValidationHelper.hasRequiredField(fd)"
[maxLength]="CHECKSUM_LENGTH_CRC32"
matInput
>
<mat-error *ngIf="fd.errors?.mismatch && formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedCrc32).value"
solidifyTooltipOnEllipsis
>
{{labelTranslateEnum.expectedValueX | translate : {value: formValidationHelper.getFormControl(formGroup, formDefinitionChecksum.checksumGeneratedCrc32).value} }}</mat-error>
<mat-error *ngIf="fd.errors?.minlength || fd.errors?.maxlength">{{labelTranslateEnum.theFormatIsNotTheOneExpected | translate}}</mat-error>
</mat-form-field>
</div>
</ng-container>
</ng-template>
</mat-expansion-panel>
</mat-accordion>
......
......@@ -44,6 +44,7 @@ import {
EnumUtil,
FormValidationHelper,
isFalse,
isNonEmptyArray,
isNotNullNorUndefined,
isNotNullNorUndefinedNorWhiteString,
isNullOrUndefined,
......@@ -124,6 +125,10 @@ export class DepositFileUploadDialog extends AbstractDepositFileUploadDialog<Dep
[this.formDefinitionChecksum.checksumGeneratedIsLoadingCounter]: [0, [SolidifyValidator]],
});
if (isNullOrUndefined(this.checksumUsed)) {
return formGroup;
}
if (this.checksumUsed.indexOf(Enums.DataFile.ChecksumAlgoEnum.MD5) !== -1) {
formGroup.addControl(this.formDefinitionChecksum.checksumGeneratedMd5, this._fb.control("", [SolidifyValidator]));
formGroup.addControl(this.formDefinitionChecksum.checksumUserMd5, this._fb.control("", [SolidifyValidator]));
......@@ -339,7 +344,7 @@ export class DepositFileUploadDialog extends AbstractDepositFileUploadDialog<Dep
}
private _computeGeneratedChecksum(formGroup: FormGroup, array: Uint8Array, algo: Enums.DataFile.ChecksumAlgoEnum): void {
if (this.checksumUsed.indexOf(algo) !== -1) {
if (isNonEmptyArray(this.checksumUsed) && this.checksumUsed.indexOf(algo) !== -1) {
const formControlCounter = formGroup.get(this.formDefinitionChecksum.checksumGeneratedIsLoadingCounter);
formControlCounter.setValue(formControlCounter.value + 1);
const checksumFunction = DepositFileUploadDialog._getChecksumFunction(algo);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment