From 9bb0d5c0c2f5b9e5098aaecb08df076c1f3d7950 Mon Sep 17 00:00:00 2001 From: "Darryl L. Pierce" Date: Mon, 23 Mar 2020 15:34:20 -0400 Subject: [PATCH] [Issue #20] Moved LibraryAdminPage into the library module. --- comixed-frontend/src/app/app.module.ts | 4 -- comixed-frontend/src/app/app.routing.ts | 7 -- .../src/app/library/library-routing.module.ts | 6 ++ .../src/app/library/library.module.ts | 33 +++++---- .../library-admin-page.component.html | 69 +++++++++++++++++++ .../library-admin-page.component.scss | 0 .../library-admin-page.component.spec.ts | 50 +++++++++----- .../library-admin-page.component.ts | 0 .../library-admin-page.component.html | 56 --------------- comixed-frontend/src/assets/i18n/app-en.json | 26 ------- .../src/assets/i18n/library-en.json | 29 ++++++++ 11 files changed, 156 insertions(+), 124 deletions(-) create mode 100644 comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.html rename comixed-frontend/src/app/{pages/admin => library/pages}/library-admin-page/library-admin-page.component.scss (100%) rename comixed-frontend/src/app/{pages/admin => library/pages}/library-admin-page/library-admin-page.component.spec.ts (69%) rename comixed-frontend/src/app/{pages/admin => library/pages}/library-admin-page/library-admin-page.component.ts (100%) delete mode 100644 comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.html diff --git a/comixed-frontend/src/app/app.module.ts b/comixed-frontend/src/app/app.module.ts index d411352a7..aad640eec 100644 --- a/comixed-frontend/src/app/app.module.ts +++ b/comixed-frontend/src/app/app.module.ts @@ -42,12 +42,10 @@ import { ComicsModule } from 'app/comics/comics.module'; import { LoginComponent } from 'app/components/login/login.component'; import { MainMenuComponent } from 'app/components/main-menu/main-menu.component'; import { LibraryModule } from 'app/library/library.module'; -import { LibraryAdminPageComponent } from 'app/pages/admin/library-admin-page/library-admin-page.component'; import { MainPageComponent } from 'app/pages/main-page/main-page.component'; import { UserService } from 'app/services/user.service'; import { UserModule } from 'app/user/user.module'; import { XhrInterceptor } from 'app/xhr.interceptor'; -import { FileSaverModule } from 'ngx-filesaver'; import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler'; import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader'; import { ConfirmationService, MessageService } from 'primeng/api'; @@ -90,7 +88,6 @@ import { LoggerModule } from '@angular-ru/logger'; AppComponent, MainPageComponent, LoginComponent, - LibraryAdminPageComponent, MainMenuComponent ], imports: [ @@ -159,7 +156,6 @@ import { LoggerModule } from '@angular-ru/logger'; } }), LoggerModule.forRoot(), - FileSaverModule, BreadcrumbModule ], providers: [ diff --git a/comixed-frontend/src/app/app.routing.ts b/comixed-frontend/src/app/app.routing.ts index 42aea2f0a..e4794cd7e 100644 --- a/comixed-frontend/src/app/app.routing.ts +++ b/comixed-frontend/src/app/app.routing.ts @@ -18,20 +18,13 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { AdminGuard } from 'app/user'; import { MainPageComponent } from 'app/pages/main-page/main-page.component'; -import { LibraryAdminPageComponent } from 'app/pages/admin/library-admin-page/library-admin-page.component'; export const routes: Routes = [ { path: 'home', component: MainPageComponent }, - { - path: 'admin/library', - component: LibraryAdminPageComponent, - canActivate: [AdminGuard] - }, { path: '', redirectTo: 'home', diff --git a/comixed-frontend/src/app/library/library-routing.module.ts b/comixed-frontend/src/app/library/library-routing.module.ts index e10219e4d..828a4298a 100644 --- a/comixed-frontend/src/app/library/library-routing.module.ts +++ b/comixed-frontend/src/app/library/library-routing.module.ts @@ -27,6 +27,7 @@ import { MultiComicScrapingPageComponent } from 'app/library/pages/multi-comic-s import { ReadingListPageComponent } from 'app/library/pages/reading-list-page/reading-list-page.component'; import { ReadingListsPageComponent } from 'app/library/pages/reading-lists-page/reading-lists-page.component'; import { AdminGuard, ReaderGuard } from 'app/user'; +import { LibraryAdminPageComponent } from 'app/library/pages/library-admin-page/library-admin-page.component'; const routes: Routes = [ { @@ -73,6 +74,11 @@ const routes: Routes = [ path: 'duplicates', component: DuplicatesPageComponent, canActivate: [AdminGuard] + }, + { + path: 'admin/library', + component: LibraryAdminPageComponent, + canActivate: [AdminGuard] } ]; diff --git a/comixed-frontend/src/app/library/library.module.ts b/comixed-frontend/src/app/library/library.module.ts index cdf573d19..14381c2e3 100644 --- a/comixed-frontend/src/app/library/library.module.ts +++ b/comixed-frontend/src/app/library/library.module.ts @@ -44,9 +44,11 @@ import { DuplicatePagesService } from 'app/library/services/duplicate-pages.serv import { CheckboxModule } from 'primeng/checkbox'; import { ContextMenuModule } from 'primeng/contextmenu'; import { + ButtonModule, DialogModule, ProgressSpinnerModule, - ScrollPanelModule, SidebarModule, + ScrollPanelModule, + SidebarModule, SliderModule, ToolbarModule, TooltipModule @@ -76,6 +78,8 @@ 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'; +import { LibraryAdminPageComponent } from 'app/library/pages/library-admin-page/library-admin-page.component'; +import { FileSaverModule } from 'ngx-filesaver'; @NgModule({ imports: [ @@ -85,24 +89,24 @@ import { ConsolidateLibraryComponent } from './components/consolidate-library/co UserExperienceModule, TranslateModule.forRoot(), StoreModule.forFeature( - fromLibrary.LIBRARY_FEATURE_KEY, - fromLibrary.reducer + fromLibrary.LIBRARY_FEATURE_KEY, + fromLibrary.reducer ), StoreModule.forFeature( - fromSelection.SELECTION_FEATURE_KEY, - fromSelection.reducer + fromSelection.SELECTION_FEATURE_KEY, + fromSelection.reducer ), StoreModule.forFeature( - fromReadingList.READING_LIST_FEATURE_KEY, - fromReadingList.reducer + fromReadingList.READING_LIST_FEATURE_KEY, + fromReadingList.reducer ), StoreModule.forFeature( - fromDupes.DUPLICATE_PAGES_FEATURE_KEY, - fromDupes.reducer + fromDupes.DUPLICATE_PAGES_FEATURE_KEY, + fromDupes.reducer ), StoreModule.forFeature( - fromPublisher.PUBLISHER_FEATURE_KEY, - fromPublisher.reducer + fromPublisher.PUBLISHER_FEATURE_KEY, + fromPublisher.reducer ), EffectsModule.forFeature([ LibraryEffects, @@ -118,7 +122,9 @@ import { ConsolidateLibraryComponent } from './components/consolidate-library/co ProgressSpinnerModule, TooltipModule, DialogModule, - SidebarModule + SidebarModule, + ButtonModule, + FileSaverModule ], exports: [CommonModule, ComicsModule, ComicListComponent], declarations: [ @@ -140,7 +146,8 @@ import { ConsolidateLibraryComponent } from './components/consolidate-library/co CollectionDetailsPageComponent, CollectionPageComponent, ConvertComicsSettingsComponent, - ConsolidateLibraryComponent + ConsolidateLibraryComponent, + LibraryAdminPageComponent ], providers: [ LibraryService, diff --git a/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.html b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.html new file mode 100644 index 000000000..7003221b6 --- /dev/null +++ b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.html @@ -0,0 +1,69 @@ +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.scss b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.scss similarity index 100% rename from comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.scss rename to comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.scss diff --git a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.spec.ts b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.spec.ts similarity index 69% rename from comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.spec.ts rename to comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.spec.ts index 00f639d67..2ed28ae81 100644 --- a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.spec.ts +++ b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.spec.ts @@ -26,27 +26,34 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; -import { MessageService } from 'primeng/api'; +import { ConfirmationService, MessageService } from 'primeng/api'; import { UserService } from 'app/services/user.service'; -import { LibraryModule } from 'app/library/library.module'; import { LibraryAdaptor } from 'app/library'; import { BreadcrumbAdaptor } from 'app/adaptors/breadcrumb.adaptor'; import { RouterTestingModule } from '@angular/router/testing'; import { StoreModule } from '@ngrx/store'; import { EffectsModule } from '@ngrx/effects'; import { LoggerModule } from '@angular-ru/logger'; +import { ConsolidateLibraryComponent } from 'app/library/components/consolidate-library/consolidate-library.component'; +import { CheckboxModule } from 'primeng/checkbox'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { UserModule } from 'app/user/user.module'; +import { ComicsModule } from 'app/comics/comics.module'; describe('LibraryAdminPageComponent', () => { let component: LibraryAdminPageComponent; let fixture: ComponentFixture; - let rescan_button: DebugElement; - let export_button: DebugElement; - let library_adaptor: LibraryAdaptor; + let rescanButton: DebugElement; + let exportButton: DebugElement; + let libraryAdaptor: LibraryAdaptor; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - LibraryModule, + UserModule, + ComicsModule, + FormsModule, + ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule, BrowserAnimationsModule, @@ -57,20 +64,27 @@ describe('LibraryAdminPageComponent', () => { EffectsModule.forRoot([]), FileSaverModule, ButtonModule, - PanelModule + PanelModule, + CheckboxModule ], - declarations: [LibraryAdminPageComponent], - providers: [MessageService, UserService, BreadcrumbAdaptor] + declarations: [LibraryAdminPageComponent, ConsolidateLibraryComponent], + providers: [ + LibraryAdaptor, + MessageService, + UserService, + BreadcrumbAdaptor, + ConfirmationService + ] }).compileComponents(); fixture = TestBed.createComponent(LibraryAdminPageComponent); component = fixture.componentInstance; - library_adaptor = TestBed.get(LibraryAdaptor); + libraryAdaptor = TestBed.get(LibraryAdaptor); fixture.detectChanges(); - rescan_button = fixture.debugElement.query(By.css('#cx-rescan-button')); - export_button = fixture.debugElement.query(By.css('#cx-export-button')); + rescanButton = fixture.debugElement.query(By.css('#cx-rescan-button')); + exportButton = fixture.debugElement.query(By.css('#cx-export-button')); })); it('should create', () => { @@ -84,11 +98,11 @@ describe('LibraryAdminPageComponent', () => { }); it('disables the rescan button', () => { - expect(rescan_button.nativeElement.disabled).toBeTruthy(); + expect(rescanButton.nativeElement.disabled).toBeTruthy(); }); it('disables the backup button', () => { - expect(export_button.nativeElement.disabled).toBeTruthy(); + expect(exportButton.nativeElement.disabled).toBeTruthy(); }); }); @@ -99,22 +113,22 @@ describe('LibraryAdminPageComponent', () => { }); it('enables the rescan button', () => { - expect(rescan_button.nativeElement.disabled).toBeFalsy(); + expect(rescanButton.nativeElement.disabled).toBeFalsy(); }); it('enables the export button', () => { - expect(export_button.nativeElement.disabled).toBeFalsy(); + expect(exportButton.nativeElement.disabled).toBeFalsy(); }); describe('and a rescan is requested', () => { beforeEach(() => { - spyOn(library_adaptor, 'startRescan'); + spyOn(libraryAdaptor, 'startRescan'); component.rescanLibrary(); fixture.detectChanges(); }); it('sends a notice to start a rescan', () => { - expect(library_adaptor.startRescan).toHaveBeenCalled(); + expect(libraryAdaptor.startRescan).toHaveBeenCalled(); }); }); }); diff --git a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.ts b/comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.ts similarity index 100% rename from comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.ts rename to comixed-frontend/src/app/library/pages/library-admin-page/library-admin-page.component.ts diff --git a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.html b/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.html deleted file mode 100644 index fc447dc20..000000000 --- a/comixed-frontend/src/app/pages/admin/library-admin-page/library-admin-page.component.html +++ /dev/null @@ -1,56 +0,0 @@ - -
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
diff --git a/comixed-frontend/src/assets/i18n/app-en.json b/comixed-frontend/src/assets/i18n/app-en.json index bc75f76ed..273a795d5 100644 --- a/comixed-frontend/src/assets/i18n/app-en.json +++ b/comixed-frontend/src/assets/i18n/app-en.json @@ -147,32 +147,6 @@ } } }, - "library-admin-page": { - "rescan": { - "header": "Rescan Library", - "paragraph1": "

Use this button to force rescanning your entire library.

", - "paragraph2": "

The server will re-evaluate each of the comics in your library, updating what it knows about each file.

", - "paragraph3": "

NOTE: While the library is being rescanned, you will not be able to import new comics.

", - "already-running": "

A rescan is current running on the server...

", - "buttons": { - "rescan-library": "Rescan Library" - } - }, - "backup": { - "header": "Library Backup/Restore", - "paragraph1": "

Use this section to download and restore snapshots of your library database.

", - "paragraph2": "

To download the current database content, click on the Export Library button.

", - "buttons": { - "export-library": "Export Library" - } - } - }, - "account-preferences": { - "label": { - "preference-name": "Name", - "preference-value": "Value" - } - }, "user-details": { "label": { "email-address": "Email Address", diff --git a/comixed-frontend/src/assets/i18n/library-en.json b/comixed-frontend/src/assets/i18n/library-en.json index 2f772a33c..292885e43 100644 --- a/comixed-frontend/src/assets/i18n/library-en.json +++ b/comixed-frontend/src/assets/i18n/library-en.json @@ -412,6 +412,35 @@ "message": "Are you sure you want to consolidate the library and {deletePhysicalFiles, select, true{delete} other{not delete}} the comic files?" } }, + "library-admin-page": { + "rescan": { + "header": "Rescan Library", + "paragraph1": "

Use this button to force rescanning your entire library.

", + "paragraph2": "

The server will re-evaluate each of the comics in your library, updating what it knows about each file.

", + "paragraph3": "

NOTE: While the library is being rescanned, you will not be able to import new comics.

", + "already-running": "

A rescan is current running on the server...

", + "buttons": { + "rescan-library": "Rescan Library" + } + }, + "backup": { + "header": "Library Backup/Restore", + "paragraph1": "

Use this section to download and restore snapshots of your library database.

", + "paragraph2": "

To download the current database content, click on the Export Library button.

", + "buttons": { + "export-library": "Export Library" + } + }, + "consolidate": { + "header": "Consolidate Library Files" + } + }, + "account-preferences": { + "label": { + "preference-name": "Name", + "preference-value": "Value" + } + }, "breadcrumb": { "collections": { "root": "Collections",