implemented images maintenance, services + component

This commit is contained in:
X4Lo committed 2024-06-06 03:41:55 +01:00
1 parent ba96f540ca
commit 34766ba8e9
13 files changed
+448 -4

No files matched your search

@@ -0,0 +1,3 @@
.material-symbols-outlined {
vertical-align: middle; /* Aligns the icon vertically with the text */
}
@@ -0,0 +1,98 @@
<div class="container mt-5">
<div class="row">
<!-- Orphan Files Section -->
<div class="col-md-6">
<h3 class="mb-3">
<span class="material-symbols-outlined">variable_remove</span>
Orphan Images
</h3>
<div class="card">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">image</span>
Posters
</h5>
<p class="card-text">{{ orphanFiles.posters }} items</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">abc</span>
Logos
</h5>
<p class="card-text">{{ orphanFiles.logos }} items</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">wallpaper</span>
Backdrops
</h5>
<p class="card-text">{{ orphanFiles.backdrops }} items</p>
</div>
</div>
<div class="card mt-3">
<button class="btn btn-danger" type="button" [disabled]="isLocked1" (click)="removeOrphanFiles()">
<ng-container *ngIf="isLocked1; else elseTemplate">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<span class=""> Removing Orphan Files...</span>
</ng-container>
<ng-template #elseTemplate>
Remove Orphan Images
</ng-template>
</button>
</div>
</div>
<!-- Missing Files Section -->
<div class="col-md-6">
<h3 class="mb-3">
<span class="material-symbols-outlined">scan_delete</span>
Missing Images
</h3>
<div class="card">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">image</span>
Posters
</h5>
<p class="card-text">{{ missingFiles.posters }} items</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">abc</span>
Logos
</h5>
<p class="card-text">{{ missingFiles.logos }} items</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">
<span class="material-symbols-outlined">wallpaper</span>
Backdrops
</h5>
<p class="card-text">{{ missingFiles.backdrops }} items</p>
</div>
</div>
<div class="card mt-3">
<button class="btn btn-danger" type="button" [disabled]="isLocked2" (click)="removeMissingFiles()">
<ng-container *ngIf="isLocked2; else elseTemplate">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<span class=""> Removing Missing Files...</span>
</ng-container>
<ng-template #elseTemplate>
Remove Missing Images
</ng-template>
</button>
</div>
</div>
<div class="alert alert-warning mt-3" role="alert">
<strong>Warning:</strong> Only use the "Remove Orphan/Missing Images" feature if some images are not showing up. If none of the images are appearing, it might be due to an incorrect "User Data Path". Please verify that it is correct in <strong>Settings > Application Settings</strong>.
</div>
</div>
</div>
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SettingsMaintenanceComponent } from './settings-maintenance.component';
describe('SettingsMaintenanceComponent', () => {
let component: SettingsMaintenanceComponent;
let fixture: ComponentFixture<SettingsMaintenanceComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SettingsMaintenanceComponent]
})
.compileComponents();
fixture = TestBed.createComponent(SettingsMaintenanceComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,74 @@
import { Component, OnInit } from '@angular/core';
import { MaintenanceService } from '../../../core/services/maintenance.service';
import { MaintenanceResult } from '../../../shared/models/maintenanceResult.model';
@Component({
selector: 'app-settings-maintenance',
templateUrl: './settings-maintenance.component.html',
styleUrl: './settings-maintenance.component.css',
})
export class SettingsMaintenanceComponent implements OnInit {
orphanFiles: MaintenanceResult = {} as MaintenanceResult;
missingFiles: MaintenanceResult = {} as MaintenanceResult;
isLocked1: boolean = false;
isLocked2: boolean = false;
constructor(private maintenanceService: MaintenanceService) {}
ngOnInit(): void {
this.getMaintenanceStats();
}
getMaintenanceStats(): void {
this.maintenanceService.getOrphanFiles().subscribe({
next: (result) => {
this.orphanFiles = result;
},
error: (error) => {
console.log(`Error getting orphan files stats: `, error);
},
});
this.maintenanceService.getMissingFiles().subscribe({
next: (result) => {
this.missingFiles = result;
},
error: (error) => {
console.log(`Error getting missing files stats: `, error);
},
});
}
removeOrphanFiles(): void {
if (this.isLocked1) return;
this.isLocked1 = true;
this.maintenanceService.deleteOrphanFiles().subscribe({
next: (removed) => {
console.log(`Removed orphan files: `, removed);
this.getMaintenanceStats();
},
error: (error) => {
console.log(`Error deleting orphan files stats: `, error);
},
});
this.isLocked1 = false;
}
removeMissingFiles(): void {
if (this.isLocked2) return;
this.isLocked2 = true;
this.maintenanceService.deleteMissingFiles().subscribe({
next: (removed) => {
console.log(`Removed missing files: `, removed);
this.getMaintenanceStats();
},
error: (error) => {
console.log(`Error deleting missing files stats: `, error);
},
});
this.isLocked2 = false;
}
}
@@ -14,7 +14,7 @@
</div>
</div>
<!-- ? step 1 -->
<!-- ? step 2 -->
<div class="step" data-target="#test-vl-1" (click)="setStep(2)" [ngClass]="{ 'active': step == 2 }">
<div class="step-trigger" role="tab" aria-controls="test-vl-3" aria-selected="true">
<div class="bs-stepper-circle"><i class="material-icons-outlined">key</i></div>
@@ -25,6 +25,17 @@
</div>
</div>
<!-- ? step 3 -->
<div class="step" data-target="#test-vl-1" (click)="setStep(3)" [ngClass]="{ 'active': step == 3 }">
<div class="step-trigger" role="tab" aria-controls="test-vl-3" aria-selected="true">
<div class="bs-stepper-circle"><i class="material-icons-outlined">handyman</i></div>
<div class="">
<h5 class="mb-0 steper-title">Maintenance</h5>
<p class="mb-0 steper-sub-title">Clean up you database</p>
</div>
</div>
</div>
</div>
<!-- ! STEPPER CONTENT -->
@@ -45,6 +56,14 @@
<app-settings-api-keys></app-settings-api-keys>
</div>
<!-- ? step 3 -->
<div id="test-vl-3" class="bs-stepper-pane content fade dstepper-block" [ngClass]="{ 'active': step == 3 }"
*ngIf="step == 3">
<h5 class="mb-1">Maintenance</h5>
<p class="mb-4">Clean up you database</p>
<app-settings-maintenance></app-settings-maintenance>
</div>
</div>
</div>
</div>
@@ -9,6 +9,7 @@ import { SettingsRoutingModule } from './settings-routing.module';
import { SettingsPageComponent } from './settings-page/settings-page.component';
import { SettingsGeneralComponent } from './settings-general/settings-general.component';
import { SettingsApiKeysComponent } from './settings-api-keys/settings-api-keys.component';
import { SettingsMaintenanceComponent } from './settings-maintenance/settings-maintenance.component';
@NgModule({
imports: [
@@ -27,6 +28,7 @@ import { SettingsApiKeysComponent } from './settings-api-keys/settings-api-keys.
SettingsGeneralComponent,
SettingsApiKeysComponent,
SettingsMaintenanceComponent,
],
exports: [],
})