Skip to content

Commit

Permalink
Checksum info is showed up.
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmajchrak committed Dec 27, 2023
1 parent 0a3c5c1 commit f8984c7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 28 deletions.
9 changes: 1 addition & 8 deletions src/app/core/shared/bitstream-checksum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export class BitstreamChecksum extends TypedObject {
*/
static type = BITSTREAM_CHECKSUM;

// /**
// * The object type
// */
/**
* The object type
*/
Expand Down Expand Up @@ -49,13 +46,9 @@ export class BitstreamChecksum extends TypedObject {
_links: {
self: HALLink
};

// getRenderTypes(): (string | GenericConstructor<ListableObject>)[] {
// return [this.constructor as GenericConstructor<ListableObject>];
// }
}

interface CheckSum {
export interface CheckSum {
checkSumAlgorithm: string;
value: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,41 @@
<div class="{{columnSizes.columns[4].buildClasses()}} row-element d-flex align-items-center justify-content-center">
<div class="float-left d-flex align-items-center overflow-hidden">
<span class="text-center">
<i [class]="bitstream.storeNumber === syncStoresNumber ? 'fas fa-check' : 'fas fa-times'"></i>
<i [class]="isBitstreamSynchronized() ? 'fas fa-check' : 'fas fa-times'"></i>
</span>
<div [ngTemplateOutlet]="checksum"></div>
<span class="pl-1">|</span>
<div class="pl-1" [ngTemplateOutlet]="checksum"></div>

</div>
</div>
</ng-template>

<ng-template #checksum>
<div class="hover-container" (mouseenter)="showText = true" (mouseleave)="showText = false">
<!-- <span class="question-mark" *ngIf="!showText">&#63;</span>-->

<!-- <div>-->
<!-- <span class="text-center">-->
<!-- <i [class]="bitstream.storeNumber === syncStoresNumber ? 'fas fa-check' : 'fas fa-times'"></i>-->
<!-- </span>-->
<!-- </div>-->
<span>|</span>
<i class="fas fa-times"></i>
<i class="fas fa-question" placement="top"
<div class="hover-container" (mouseenter)="showText = true" (mouseleave)="showText = false" *ngVar="(checkSum$ | async) as bitstreamChecksum">
<i [class]="checksumsAreEqual(bitstreamChecksum) ? 'fas fa-check' : 'fas fa-times'"></i>
<i class="pl-2 fas fa-info-circle"
triggers="mouseenter:mouseleave"
ngbPopover="Angular ng bootstrap"
popoverTitle="GeeksforGeeks"></i>
[ngbPopover]="checksumPopover"
popoverTitle="Checksums"></i>
</div>
</ng-template>

<ng-template #checksumPopover>
<div *ngVar="(checkSum$ | async) as bitstreamChecksum">
<div>
<div class="font-weight-bold text-decoration-underline">DB</div>
<div>Algorithm: {{bitstreamChecksum.databaseChecksum.checkSumAlgorithm}}</div>
<div>Value: {{ bitstreamChecksum.databaseChecksum.value }}</div>
</div>
<div>
<div class="font-weight-bold text-decoration-underline">Active store</div>
<div>Algorithm: {{bitstreamChecksum.activeStore.checkSumAlgorithm}}</div>
<div>Value: {{ bitstreamChecksum.activeStore.value }}</div>
</div>
<div *ngIf="isBitstreamSynchronized()">
<div class="font-weight-bold text-decoration-underline">Sync store</div>
<div>Algorithm: {{bitstreamChecksum.synchronizedStore.checkSumAlgorithm}}</div>
<div>Value: {{ bitstreamChecksum.synchronizedStore.value }}</div>
</div>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
import { FieldUpdate } from '../../../../core/data/object-updates/field-update.model';
import { FieldChangeType } from '../../../../core/data/object-updates/field-change-type.model';
import { getBitstreamDownloadRoute } from '../../../../app-routing-paths';
import {GetRequest} from '../../../../core/data/request.models';
import {RequestService} from '../../../../core/data/request.service';
import {RemoteDataBuildService} from '../../../../core/cache/builders/remote-data-build.service';
import {BitstreamChecksum} from '../../../../core/shared/bitstream-checksum.model';
import {BitstreamChecksum, CheckSum} from '../../../../core/shared/bitstream-checksum.model';

@Component({
selector: 'ds-item-edit-bitstream',
Expand Down Expand Up @@ -104,11 +103,10 @@ export class ItemEditBitstreamComponent implements OnChanges, OnInit {
getFirstSucceededRemoteData(),
getRemoteDataPayload()
);
this.bitstream.checksum.pipe(
this.checkSum$ = this.bitstream.checksum.pipe(
getFirstCompletedRemoteData(),
getRemoteDataPayload()
).subscribe((checksum) => { console.log('checksum', checksum); });

);
}

/**
Expand Down Expand Up @@ -139,4 +137,23 @@ export class ItemEditBitstreamComponent implements OnChanges, OnInit {
return this.fieldUpdate.changeType >= 0;
}

compareChecksums(checksum1: CheckSum, checksum2: CheckSum): boolean {
return checksum1.value === checksum2.value && checksum1.checkSumAlgorithm === checksum2.checkSumAlgorithm;
}

checksumsAreEqual(bitstreamChecksum: BitstreamChecksum): boolean {
if (this.isBitstreamSynchronized()) {
// Compare DB and Active store checksums
// Compare DB and Synchronized and Active store checksums
return this.compareChecksums(bitstreamChecksum.databaseChecksum, bitstreamChecksum.activeStore) &&
this.compareChecksums(bitstreamChecksum.synchronizedStore, bitstreamChecksum.activeStore);
}
// Compare DB and Active store checksums
return this.compareChecksums(bitstreamChecksum.databaseChecksum, bitstreamChecksum.activeStore);
}

isBitstreamSynchronized() {
return this.bitstream?.storeNumber === SYNCHRONIZED_STORES_NUMBER;
}

}

0 comments on commit f8984c7

Please sign in to comment.