diff --git a/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.html b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.html
new file mode 100644
index 000000000..349099e9d
--- /dev/null
+++ b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.html
@@ -0,0 +1,19 @@
+
diff --git a/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.scss b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.spec.ts b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.spec.ts
new file mode 100644
index 000000000..94841e10f
--- /dev/null
+++ b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.spec.ts
@@ -0,0 +1,42 @@
+/*
+ * ComiXed - A digital comic book library management application.
+ * Copyright (C) 2019, The ComiXed Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ConsolidateLibraryComponent } from './consolidate-library.component';
+
+describe('ConsolidateLibraryComponent', () => {
+ let component: ConsolidateLibraryComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ConsolidateLibraryComponent]
+ }).compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ConsolidateLibraryComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.ts b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.ts
new file mode 100644
index 000000000..984a93af3
--- /dev/null
+++ b/comixed-frontend/src/app/library/components/consolidate-library/consolidate-library.component.ts
@@ -0,0 +1,93 @@
+/*
+ * ComiXed - A digital comic book library management application.
+ * Copyright (C) 2019, The ComiXed Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ */
+
+import { Component, OnDestroy, OnInit } from '@angular/core';
+import { FormBuilder, FormGroup } from '@angular/forms';
+import { LoggerService } from '@angular-ru/logger';
+import { LibraryAdaptor } from 'app/library';
+import { Subscription } from 'rxjs';
+import { CONSOLIDATE_DELETE_PHYSICAL_FILES } from 'app/user/models/preferences.constants';
+import { AuthenticationAdaptor } from 'app/user';
+import { ConfirmationService } from 'primeng/api';
+import { TranslateService } from '@ngx-translate/core';
+
+@Component({
+ selector: 'app-consolidate-library',
+ templateUrl: './consolidate-library.component.html',
+ styleUrls: ['./consolidate-library.component.scss']
+})
+export class ConsolidateLibraryComponent implements OnInit, OnDestroy {
+ consolidationForm: FormGroup;
+ consolidatingSubscription: Subscription;
+ consolidating = false;
+ userSubscription: Subscription;
+ user = null;
+
+ constructor(
+ private logger: LoggerService,
+ private formBuilder: FormBuilder,
+ private libraryAdaptor: LibraryAdaptor,
+ private authenticationAdaptor: AuthenticationAdaptor,
+ private confirmationService: ConfirmationService,
+ private translateService: TranslateService
+ ) {
+ this.consolidationForm = this.formBuilder.group({
+ deletePhysicalFiles: ['']
+ });
+ this.consolidatingSubscription = this.libraryAdaptor.consolidating$.subscribe(
+ consolidating => (this.consolidating = consolidating)
+ );
+ this.userSubscription = this.authenticationAdaptor.user$.subscribe(() => {
+ this.consolidationForm.controls['deletePhysicalFiles'].setValue(
+ this.authenticationAdaptor.getPreference(
+ CONSOLIDATE_DELETE_PHYSICAL_FILES
+ ) === '1'
+ );
+ });
+ }
+
+ ngOnInit() {}
+
+ ngOnDestroy() {
+ this.consolidatingSubscription.unsubscribe();
+ }
+
+ consolidateLibrary() {
+ this.confirmationService.confirm({
+ header: this.translateService.instant(
+ 'consolidate-library.confirm.header'
+ ),
+ message: this.translateService.instant(
+ 'consolidate-library.confirm.message',
+ {
+ deletePhysicalFiles: this.consolidationForm.controls['deletePhysicalFiles'].value
+ }
+ ),
+ accept: () => {
+ const deletePhysicalFiles = this.consolidationForm.controls[
+ 'deletePhysicalFiles'
+ ].value;
+ this.authenticationAdaptor.setPreference(
+ CONSOLIDATE_DELETE_PHYSICAL_FILES,
+ deletePhysicalFiles ? '1' : '0'
+ );
+ this.libraryAdaptor.consolidate(deletePhysicalFiles);
+ }
+ });
+ }
+}
diff --git a/comixed-frontend/src/app/library/library.module.ts b/comixed-frontend/src/app/library/library.module.ts
index 8821f63cb..cdf573d19 100644
--- a/comixed-frontend/src/app/library/library.module.ts
+++ b/comixed-frontend/src/app/library/library.module.ts
@@ -75,6 +75,7 @@ import { ConvertComicsSettingsComponent } from './components/convert-comics-sett
import * as fromPublisher from 'app/library/reducers/publisher.reducer';
import { PublisherEffects } from 'app/library/effects/publisher.effects';
import { PublisherAdaptor } from 'app/library/adaptors/publisher.adaptor';
+import { ConsolidateLibraryComponent } from './components/consolidate-library/consolidate-library.component';
@NgModule({
imports: [
@@ -138,7 +139,8 @@ import { PublisherAdaptor } from 'app/library/adaptors/publisher.adaptor';
DuplicatePageListItemComponent,
CollectionDetailsPageComponent,
CollectionPageComponent,
- ConvertComicsSettingsComponent
+ ConvertComicsSettingsComponent,
+ ConsolidateLibraryComponent
],
providers: [
LibraryService,
diff --git a/comixed-frontend/src/app/user/models/preferences.constants.ts b/comixed-frontend/src/app/user/models/preferences.constants.ts
index 31c0ec4b3..7142458c2 100644
--- a/comixed-frontend/src/app/user/models/preferences.constants.ts
+++ b/comixed-frontend/src/app/user/models/preferences.constants.ts
@@ -20,6 +20,8 @@ export const LIBRARY_SORT = 'library.sort-by';
export const LIBRARY_ROWS = 'library.rows';
export const LIBRARY_COVER_SIZE = 'library.cover-size';
export const LIBRARY_CURRENT_TAB = 'library.current-tab';
+export const CONSOLIDATE_DELETE_PHYSICAL_FILES =
+ 'library.consolidate.delete-physical-file';
export const IMPORT_SORT = 'import.sort-by';
export const IMPORT_ROWS = 'import.rows';
diff --git a/comixed-frontend/src/assets/i18n/library-en.json b/comixed-frontend/src/assets/i18n/library-en.json
index 16d866fe7..e1695df54 100644
--- a/comixed-frontend/src/assets/i18n/library-en.json
+++ b/comixed-frontend/src/assets/i18n/library-en.json
@@ -400,6 +400,18 @@
}
}
},
+ "consolidate-library": {
+ "label": {
+ "delete-physical-files": "Delete Physical Files"
+ },
+ "button": {
+ "start": "Start Consolidation"
+ },
+ "confirm": {
+ "header": "Consolidate Library",
+ "message": "Are you sure you want to consolidate the library and {deletePhysicalFiles, select, true{delete} other{not delete}} the comic files?"
+ }
+ },
"breadcrumb": {
"collections": {
"root": "Collections",