Skip to content

Commit

Permalink
Changed importing to use a dialog for loading files [#632]
Browse files Browse the repository at this point in the history
 * Moved all import-related features to the comic-file module.
 * Divided the importing feature into action-specific features.
  • Loading branch information
mcpierce committed May 9, 2021
1 parent 205467d commit ff217ba
Show file tree
Hide file tree
Showing 72 changed files with 1,672 additions and 907 deletions.
2 changes: 1 addition & 1 deletion comixed-web/src/app/app.component.ts
Expand Up @@ -24,7 +24,7 @@ import { getUserPreference, User } from '@app/user';
import { loadCurrentUser } from '@app/user/actions/user.actions';
import { selectBusyState } from '@app/core/selectors/busy.selectors';
import { TranslateService } from '@ngx-translate/core';
import { setImportingComicsState } from '@app/library/actions/comic-import.actions';
import { setImportingComicsState } from '@app/comic-file/actions/comic-import.actions';
import { setPageSize } from '@app/library/actions/display.actions';
import {
PAGE_SIZE_DEFAULT,
Expand Down
2 changes: 2 additions & 0 deletions comixed-web/src/app/app.module.ts
Expand Up @@ -66,6 +66,7 @@ import { MatListModule } from '@angular/material/list';
import { BlockedPagesModule } from '@app/blocked-pages/blocked-pages.module';
import { CollectionsModule } from '@app/collections/collections.module';
import { LastReadModule } from '@app/last-read/last-read.module';
import { ComicFileModule } from '@app/comic-file/comic-file.module';

@NgModule({
declarations: [
Expand All @@ -80,6 +81,7 @@ import { LastReadModule } from '@app/last-read/last-read.module';
AdminModule,
MessagingModule,
UserModule,
ComicFileModule,
LibraryModule,
BlockedPagesModule,
LastReadModule,
Expand Down
1 change: 1 addition & 0 deletions comixed-web/src/app/app.translate.ts
Expand Up @@ -25,6 +25,7 @@ export function HttpLoaderFactory(http: HttpClient): MultiTranslateHttpLoader {
{ prefix: './assets/i18n/', suffix: '/app.json' },
{ prefix: './assets/i18n/', suffix: '/blocked-pages.json' },
{ prefix: './assets/i18n/', suffix: '/collections.json' },
{ prefix: './assets/i18n/', suffix: '/comic-file.json' },
{ prefix: './assets/i18n/', suffix: '/core.json' },
{ prefix: './assets/i18n/', suffix: '/last-read.json' },
{ prefix: './assets/i18n/', suffix: '/library.json' },
Expand Down
@@ -1,6 +1,6 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2020, The ComiXed Project
* Copyright (C) 2021, 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
Expand All @@ -17,41 +17,27 @@
*/

import { createAction, props } from '@ngrx/store';
import { ComicFile } from '@app/library/models/comic-file';
import { ComicFile } from '@app/comic-file';

export const loadComicFiles = createAction(
'[ComicImport] Load comics in a file system',
'[Comic File List] Load comics in a file system',
props<{ directory: string; maximum: number }>()
);

export const comicFilesLoaded = createAction(
'[ComicImport] Loaded comics in a file system',
'[Comic File List] Loaded comics in a file system',
props<{ files: ComicFile[] }>()
);

export const loadComicFilesFailed = createAction(
'[ComicImport] Failed to load comic files in a file system'
'[Comic File List] Failed to load comic files in a file system'
);

export const setComicFilesSelectedState = createAction(
'[ComicImport] Set the selected state on comic files',
'[Comic File List] Set the selected state on comic files',
props<{ files: ComicFile[]; selected: boolean }>()
);

export const clearComicFileSelections = createAction(
'[ComicImport] Clear all selected comic files'
);
export const sendComicFiles = createAction(
'[ComicImport] Begin importing the selected comic files',
props<{
files: ComicFile[];
ignoreMetadata: boolean;
deleteBlockedPages: boolean;
}>()
);
export const comicFilesSent = createAction(
'[ComicImport] Importing comic files has started'
);
export const sendComicFilesFailed = createAction(
'[ComicImport] Failed to begin importing comic files'
);
export const setImportingComicsState = createAction(
'[ComicImport] Explicitly sets the importing state',
props<{ importing: boolean }>()
'[Comic File List] Clear all selected comic files'
);
24 changes: 24 additions & 0 deletions comixed-web/src/app/comic-file/actions/comic-import.actions.ts
@@ -0,0 +1,24 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2020, 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 <http://www.gnu.org/licenses>
*/

import { createAction, props } from '@ngrx/store';

export const setImportingComicsState = createAction(
'[Comic Import] Explicitly sets the importing state',
props<{ importing: boolean }>()
);
@@ -0,0 +1,37 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

import { createAction, props } from '@ngrx/store';
import { ComicFile } from '@app/comic-file';

export const sendComicFiles = createAction(
'[Import Comic Files] Begin importing the selected comic files',
props<{
files: ComicFile[];
ignoreMetadata: boolean;
deleteBlockedPages: boolean;
}>()
);

export const comicFilesSent = createAction(
'[Import Comic Files] Importing comic files has started'
);

export const sendComicFilesFailed = createAction(
'[Import Comic Files] Failed to begin importing comic files'
);
22 changes: 22 additions & 0 deletions comixed-web/src/app/comic-file/comic-file.constants.ts
@@ -0,0 +1,22 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

import { API_ROOT_URL } from '../core';

export const LOAD_COMIC_FILES_URL = `${API_ROOT_URL}/files/contents`;
export const SEND_COMIC_FILES_URL = `${API_ROOT_URL}/files/import`;
49 changes: 49 additions & 0 deletions comixed-web/src/app/comic-file/comic-file.fixtures.ts
@@ -0,0 +1,49 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

import { ComicFile } from './models/comic-file';

export const ROOT_DIRECTORY = '/home/comixedadmin/Documents/comics';

export const COMIC_FILE_1: ComicFile = {
id: 1,
filename: '/Users/comixed/Documents/comics/existing-comic-file.cbz',
baseFilename: 'existing-comic-file',
size: 65535
};

export const COMIC_FILE_2: ComicFile = {
id: 2,
filename: '/Users/comixed/Documents/comics/another-comic-file.cbz',
baseFilename: 'another-comic-file',
size: 32767
};

export const COMIC_FILE_3: ComicFile = {
id: 3,
filename: '/Users/comixed/Documents/comics/this-comic-file.cbz',
baseFilename: 'this-comic-file',
size: 46787
};

export const COMIC_FILE_4: ComicFile = {
id: 4,
filename: '/Users/comixed/Documents/comics/that-comic-file.cbz',
baseFilename: 'that-comic-file',
size: 56213
};
19 changes: 19 additions & 0 deletions comixed-web/src/app/comic-file/comic-file.models.ts
@@ -0,0 +1,19 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

export { ComicFile } from './models/comic-file';
97 changes: 97 additions & 0 deletions comixed-web/src/app/comic-file/comic-file.module.ts
@@ -0,0 +1,97 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ImportComicsPageComponent } from './pages/import-comics-page/import-comics-page.component';
import { ComicFileToolbarComponent } from './components/comic-file-toolbar/comic-file-toolbar.component';
import { ComicFileListComponent } from './components/comic-file-list/comic-file-list.component';
import { ComicFileDetailsComponent } from './components/comic-file-details/comic-file-details.component';
import { ComicFileCoverUrlPipe } from './pipes/comic-file-cover-url.pipe';
import { ComicFileRouting } from './comic-file.routing';
import { StoreModule } from '@ngrx/store';
import {
COMIC_IMPORT_FEATURE_KEY,
reducer as comicImportReducer
} from './reducers/comic-import.reducer';
import { EffectsModule } from '@ngrx/effects';
import { TranslateModule } from '@ngx-translate/core';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTableModule } from '@angular/material/table';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatIconModule } from '@angular/material/icon';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatInputModule } from '@angular/material/input';
import { ComicFileListEffects } from '@app/comic-file/effects/comic-file-list.effects';
import { ImportComicFilesEffects } from '@app/comic-file/effects/import-comic-files.effects';
import {
IMPORT_COMIC_FILES_FEATURE_KEY,
reducer as importComicFilesReducer
} from '@app/comic-file/reducers/import-comic-files.reducer';
import {
COMIC_FILE_LIST_FEATURE_KEY,
reducer as comicFileListReducer
} from '@app/comic-file/reducers/comic-file-list.reducer';
import { ComicFileLookupComponent } from './components/comic-file-lookup/comic-file-lookup.component';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatSortModule } from '@angular/material/sort';
import { MatCardModule } from '@angular/material/card';
import { LibraryModule } from '@app/library/library.module';

@NgModule({
declarations: [
ImportComicsPageComponent,
ComicFileToolbarComponent,
ComicFileListComponent,
ComicFileDetailsComponent,
ComicFileCoverUrlPipe,
ComicFileLookupComponent
],
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
ComicFileRouting,
TranslateModule.forRoot(),
StoreModule.forFeature(COMIC_FILE_LIST_FEATURE_KEY, comicFileListReducer),
StoreModule.forFeature(
IMPORT_COMIC_FILES_FEATURE_KEY,
importComicFilesReducer
),
StoreModule.forFeature(COMIC_IMPORT_FEATURE_KEY, comicImportReducer),
StoreModule.forFeature(COMIC_IMPORT_FEATURE_KEY, comicImportReducer),
EffectsModule.forFeature([ComicFileListEffects, ImportComicFilesEffects]),
MatToolbarModule,
MatTableModule,
MatFormFieldModule,
MatSelectModule,
MatIconModule,
MatInputModule,
MatTooltipModule,
MatButtonModule,
MatCheckboxModule,
MatSortModule,
MatCardModule,
LibraryModule
],
exports: [CommonModule]
})
export class ComicFileModule {}
36 changes: 36 additions & 0 deletions comixed-web/src/app/comic-file/comic-file.routing.ts
@@ -0,0 +1,36 @@
/*
* ComiXed - A digital comic book library management application.
* Copyright (C) 2021, 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 <http://www.gnu.org/licenses>
*/

import { ImportComicsPageComponent } from './pages/import-comics-page/import-comics-page.component';
import { AdminGuard } from '../user';
import { RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';

const routes: Routes = [
{
path: 'library/import',
component: ImportComicsPageComponent,
canActivate: [AdminGuard]
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ComicFileRouting {}

0 comments on commit ff217ba

Please sign in to comment.