Add overview for repository metadata
Signed-off-by: Trivernis <trivernis@protonmail.com>pull/4/head
parent
25786f9d3c
commit
86412b7039
@ -0,0 +1,22 @@
|
|||||||
|
<mat-toolbar>
|
||||||
|
<span class="repository-name">{{repository.name}}</span>
|
||||||
|
<button class="button-close-repository" mat-flat-button color="primary" (click)="this.closeRepository()">Close</button>
|
||||||
|
</mat-toolbar>
|
||||||
|
<div class="details-content" fxLayout="row">
|
||||||
|
<div class="repository-metadata" fxFlex="50%">
|
||||||
|
<h1>Stats</h1>
|
||||||
|
<app-metadata-entry *ngIf="repository.path" attributeName="Path" [value]="repository.path"></app-metadata-entry>
|
||||||
|
<app-metadata-entry *ngIf="repository.address" attributeName="Address" [value]="repository.address"></app-metadata-entry>
|
||||||
|
<ng-container *ngIf="metadata">
|
||||||
|
<app-metadata-entry attributeName="Daemon Version" [value]="metadata.version"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="File Count" [value]="metadata.file_count.toString()"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Tag Count" [value]="metadata.tag_count.toString()"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Namespace Count" [value]="metadata.namespace_count.toString()"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Mapping Count" [value]="metadata.mapping_count.toString()"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Total Size" [value]="formatByteSize(metadata.total_size)"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="File Folder Size" [value]="formatByteSize(metadata.file_size)"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Thumbnail Folder Size" [value]="formatByteSize(metadata.thumbnail_size)"></app-metadata-entry>
|
||||||
|
<app-metadata-entry attributeName="Database File Size" [value]="formatByteSize(metadata.database_size)"></app-metadata-entry>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,9 @@
|
|||||||
|
.repository-name {
|
||||||
|
text-align: center;
|
||||||
|
align-self: center;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-close-repository {
|
||||||
|
float: right
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { RepositoryDetailsViewComponent } from './repository-details-view.component';
|
||||||
|
|
||||||
|
describe('RepositoryDetailsViewComponent', () => {
|
||||||
|
let component: RepositoryDetailsViewComponent;
|
||||||
|
let fixture: ComponentFixture<RepositoryDetailsViewComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ RepositoryDetailsViewComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(RepositoryDetailsViewComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
Component,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnInit,
|
||||||
|
SimpleChanges
|
||||||
|
} from "@angular/core";
|
||||||
|
import {Repository} from "../../../../models/Repository";
|
||||||
|
import {
|
||||||
|
RepositoryService
|
||||||
|
} from "../../../../services/repository/repository.service";
|
||||||
|
import {RepositoryMetadata} from "../../../../models/RepositoryMetadata";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-repository-details-view",
|
||||||
|
templateUrl: "./repository-details-view.component.html",
|
||||||
|
styleUrls: ["./repository-details-view.component.scss"]
|
||||||
|
})
|
||||||
|
export class RepositoryDetailsViewComponent implements OnInit, OnChanges {
|
||||||
|
@Input() repository!: Repository;
|
||||||
|
|
||||||
|
public metadata?: RepositoryMetadata;
|
||||||
|
|
||||||
|
constructor(private repoService: RepositoryService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ngOnInit() {
|
||||||
|
this.metadata = await this.repoService.getRepositoryMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (changes["repository"]) {
|
||||||
|
this.metadata = await this.repoService.getRepositoryMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async closeRepository() {
|
||||||
|
if (this.repository?.local) {
|
||||||
|
await this.repoService.closeSelectedRepository();
|
||||||
|
} else {
|
||||||
|
await this.repoService.disconnectSelectedRepository();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public formatByteSize(size: number): string {
|
||||||
|
const kib = 1024;
|
||||||
|
const mib = kib ** 2;
|
||||||
|
const gib = kib ** 3;
|
||||||
|
const tib = kib ** 4;
|
||||||
|
|
||||||
|
if (size >= tib) {
|
||||||
|
return (size / tib).toFixed(2) + " TiB";
|
||||||
|
} else if (size >= gib) {
|
||||||
|
return (size / gib).toFixed(2) + " GiB";
|
||||||
|
} else if (size >= mib) {
|
||||||
|
return (size / mib).toFixed(2) + " MiB";
|
||||||
|
} else if (size >= kib) {
|
||||||
|
return (size / kib).toFixed(2) + " KiB";
|
||||||
|
} else {
|
||||||
|
return size + " B"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
export type RepositoryMetadata = {
|
||||||
|
version: string,
|
||||||
|
file_count: number,
|
||||||
|
tag_count: number,
|
||||||
|
namespace_count: number,
|
||||||
|
mapping_count: number,
|
||||||
|
hash_count: number,
|
||||||
|
total_size: number,
|
||||||
|
file_size: number,
|
||||||
|
database_size: number,
|
||||||
|
thumbnail_size: number,
|
||||||
|
};
|
Loading…
Reference in New Issue