Skip to content

Commit

Permalink
[Issue comixed#20] Moved LibraryAdminPage into the library module.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Mar 24, 2020
1 parent 7f86092 commit 9bb0d5c
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 124 deletions.
4 changes: 0 additions & 4 deletions comixed-frontend/src/app/app.module.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -90,7 +88,6 @@ import { LoggerModule } from '@angular-ru/logger';
AppComponent,
MainPageComponent,
LoginComponent,
LibraryAdminPageComponent,
MainMenuComponent
],
imports: [
Expand Down Expand Up @@ -159,7 +156,6 @@ import { LoggerModule } from '@angular-ru/logger';
}
}),
LoggerModule.forRoot(),
FileSaverModule,
BreadcrumbModule
],
providers: [
Expand Down
7 changes: 0 additions & 7 deletions comixed-frontend/src/app/app.routing.ts
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions comixed-frontend/src/app/library/library-routing.module.ts
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -73,6 +74,11 @@ const routes: Routes = [
path: 'duplicates',
component: DuplicatesPageComponent,
canActivate: [AdminGuard]
},
{
path: 'admin/library',
component: LibraryAdminPageComponent,
canActivate: [AdminGuard]
}
];

Expand Down
33 changes: 20 additions & 13 deletions comixed-frontend/src/app/library/library.module.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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: [
Expand All @@ -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,
Expand All @@ -118,7 +122,9 @@ import { ConsolidateLibraryComponent } from './components/consolidate-library/co
ProgressSpinnerModule,
TooltipModule,
DialogModule,
SidebarModule
SidebarModule,
ButtonModule,
FileSaverModule
],
exports: [CommonModule, ComicsModule, ComicListComponent],
declarations: [
Expand All @@ -140,7 +146,8 @@ import { ConsolidateLibraryComponent } from './components/consolidate-library/co
CollectionDetailsPageComponent,
CollectionPageComponent,
ConvertComicsSettingsComponent,
ConsolidateLibraryComponent
ConsolidateLibraryComponent,
LibraryAdminPageComponent
],
providers: [
LibraryService,
Expand Down
@@ -0,0 +1,69 @@
<div class='ui-g'>
<div class='ui-g-6'>
<p-panel [header]='"library-admin-page.rescan.header" | translate'>
<div class='ui-g'>
<div *ngIf='importCount !== 0'
class='ui-g-12'
[innerHTML]='"library-admin-page.rescan.already-running" | translate'></div>
<div class='ui-g-2'>
<div class='cx-button-box-vertical'>
<button id='cx-rescan-button'
type='button'
pButton
class='cx-selection-button ui-button-success'
[disabled]='importCount !== 0'
[label]='"library-admin-page.rescan.buttons.rescan-library" | translate'
icon='fa fa-refresh'
(click)='rescanLibrary()'></button>
</div>
</div>
<div class='ui-g-10'>
<div class='ui-g'>
<div class='ui-g-12'
[innerHTML]='"library-admin-page.rescan.paragraph1" | translate'></div>
<div class='ui-g-12'
[innerHTML]='"library-admin-page.rescan.paragraph2" | translate'></div>
<div class='ui-g-12'
[innerHTML]='"library-admin-page.rescan.paragraph3" | translate'></div>
</div>
</div>
</div>
</p-panel>
</div>
<div class='ui-g-6'>
<p-panel [header]='"library-admin-page.consolidate.header" | translate'>
<app-consolidate-library></app-consolidate-library>
</p-panel>
</div>
<div class='ui-g-6'>
<p-panel [header]='"library-admin-page.backup.header" | translate'>
<div class='ui-g'>
<div class='ui-g-2'>
<div class='cx-button-box-vertical'>
<button id='cx-export-button'
type='button'
pButton
fileSaver
class='cx-selection-button ui-button-success'
[label]='"library-admin-page.backup.buttons.export-library" | translate'
icon='fa fa-fw fa-step-backward'
[disabled]='importCount !== 0'
[method]='"GET"'
[url]='"/api/admin/data/export"'
[fileName]='"comixed_backup.zip"'></button>
</div>
</div>
<div class='ui-g-10'>
<div class='ui-g'>
<div class='ui-g-12'
[innerHTML]='"library-admin-page.backup.paragraph1" | translate'></div>
<div class='ui-g-12'
[innerHTML]='"library-admin-page.backup.paragraph2" | translate'></div>
</div>
</div>
</div>
</p-panel>
</div>
<div class='ui-g-6'>
</div>
</div>
Expand Up @@ -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<LibraryAdminPageComponent>;
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,
Expand All @@ -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', () => {
Expand All @@ -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();
});
});

Expand All @@ -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();
});
});
});
Expand Down

This file was deleted.

0 comments on commit 9bb0d5c

Please sign in to comment.