From bffc1227c39887b4dc0acb5b35552e7bfd42f1c4 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 06:55:47 +0100 Subject: [PATCH 01/11] add: update modal for entry seen --- backend/routes/entry.routes.js | 9 +- backend/server.js | 6 +- backend/services/entryService.js | 5 +- .../app/core/services/entry-seen.service.ts | 10 ++ .../entry/entry-page/entry-page.component.css | 62 ++++++--- .../entry-page/entry-page.component.html | 67 +++++++-- .../entry/entry-page/entry-page.component.ts | 128 ++++++++++++------ .../modals/seen-modal/seen-modal.component.ts | 2 +- 8 files changed, 208 insertions(+), 81 deletions(-) diff --git a/backend/routes/entry.routes.js b/backend/routes/entry.routes.js index a477b75..d097ff9 100644 --- a/backend/routes/entry.routes.js +++ b/backend/routes/entry.routes.js @@ -65,13 +65,15 @@ entryRouter.get('/:id', async (req, res) => { attributes: [] // Do not fetch any attributes from the join table } } + ], + order: [ + [{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list ] }); if (!entry) { // ! entry not found res.status(404).json({ message: 'Entry not found' }); } - const entryData = entry.get({ plain: true }); const genres = entryData.genres.map(genre => genre.name); @@ -172,7 +174,10 @@ entryRouter.put('/:id', async (req, res) => { if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' }); const updatedEntry = await Entry.findByPk(id, { - include: includes + include: includes, + order: [ + [{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list + ] }); const entryData = updatedEntry.get({ plain: true }); diff --git a/backend/server.js b/backend/server.js index 47a6df5..830e49d 100644 --- a/backend/server.js +++ b/backend/server.js @@ -63,12 +63,12 @@ app.use(errorHandler); app.use('/killer', killerRouter); // Start the server - +const doUpdate = false; console.log(`Syncing database schema...`); sequelize // .sync({force: true}) // will drop all tables and recreate them. - // .sync({ alter: true }) // will attempt to automatically alter tables to fit the model definitions. - .sync() + .sync({ alter: doUpdate }) // will attempt to automatically alter tables to fit the model definitions. + // .sync() .then((result) => { console.log(`Database schema synced...`); initializeData(); diff --git a/backend/services/entryService.js b/backend/services/entryService.js index 309106c..1d7e362 100644 --- a/backend/services/entryService.js +++ b/backend/services/entryService.js @@ -515,7 +515,10 @@ async function refrechEntry(entryId) { if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' }); const updatedEntry = await Entry.findByPk(entryId, { - include: includes + include: includes, + order: [ + [{ model: EntrySeen, as: 'entrySeen' }, 'date_seen', 'DESC'] // Order the entry-seen list + ] }); const entryData = updatedEntry.get({ plain: true }); diff --git a/frontend/src/app/core/services/entry-seen.service.ts b/frontend/src/app/core/services/entry-seen.service.ts index 62b2666..92a1852 100644 --- a/frontend/src/app/core/services/entry-seen.service.ts +++ b/frontend/src/app/core/services/entry-seen.service.ts @@ -22,6 +22,16 @@ export class EntrySeenService { ); } + updateEntrySeen(entrySeen: EntrySeen) { + return this.http.put( + `${this.backend_apiUrl}/${this.apiAction}/${entrySeen.id}`, + { + date_seen: entrySeen.date_seen, + seen_with: entrySeen.seen_with, + } + ); + } + // get entry seen by entry id getEntrySeenById(id: string) { return this.http.get( diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.css b/frontend/src/app/features/entry/entry-page/entry-page.component.css index 47be8ba..50f55ee 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.css +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.css @@ -15,7 +15,7 @@ } .background-wrapper::after { - content: ''; + content: ""; position: absolute; top: 0; left: 0; @@ -25,13 +25,17 @@ z-index: 2; } -[data-bs-theme=dark] .background-wrapper::after { +[data-bs-theme="dark"] .background-wrapper::after { background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 60%, #181c1f 100%); } .content-wrapper { color: #212529; - background: linear-gradient(to bottom, rgba(255, 255, 255, 0.461) 10%, #eff1f3 100%); + background: linear-gradient( + to bottom, + rgba(255, 255, 255, 0.461) 10%, + #eff1f3 100% + ); backdrop-filter: blur(10px); padding: 20px; @@ -40,17 +44,15 @@ /* box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); */ } -[data-bs-theme=dark] .content-wrapper { +[data-bs-theme="dark"] .content-wrapper { color: #a7acb1; - background: linear-gradient(to bottom, rgba(33, - 37, - 41, - 0.7) 50%, #181c1f 100%); + background: linear-gradient( + to bottom, + rgba(33, 37, 41, 0.7) 50%, + #181c1f 100% + ); - background-color: rgba(33, - 37, - 41, - 0.7); + background-color: rgba(33, 37, 41, 0.7); border: 1px solid #181c1f; } @@ -79,7 +81,6 @@ margin: 10px 0; } - .side-info .list-group-item { background-color: rgba(255, 255, 255, 0.461) !important; background-color: transparent !important; @@ -96,7 +97,7 @@ font-size: 2.9rem !important; } -[data-bs-theme=dark] .title { +[data-bs-theme="dark"] .title { color: white; } @@ -105,7 +106,7 @@ font-size: 2rem; } -[data-bs-theme=dark] .right-col .entry-actions span { +[data-bs-theme="dark"] .right-col .entry-actions span { color: white; } @@ -158,9 +159,28 @@ } .faved { - font-variation-settings: - 'FILL' 1, - 'wght' 400, - 'GRAD' 0, - 'opsz' 24 -} \ No newline at end of file + font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; +} + +.info-item { + color: var(--shz-blue-default); +} + +.info-card { + background-color: transparent; + margin-bottom: 0; +} + +hr { + color: #ffffff; +} +.info-card hr { + margin-top: 5px; +} + +.info-card .accordion .accordion-item, +.info-card .accordion .accordion-header, +.info-card .accordion .accordion-header .accordion-button { + background-color: transparent; + border-radius: 0; +} diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.html b/frontend/src/app/features/entry/entry-page/entry-page.component.html index 3e8a0de..d0c517e 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.html +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.html @@ -14,7 +14,7 @@ -
    + -
    - -
    +
--> +
-
Watch History
+
Info

+
  • + Premiere: + {{this.entry.release_date | dateFormat:'MMM dd, yyyy'}} +
  • +
  • + Next Episode: + {{nextEpisode}} +
  • +
  • + Status: + {{status}} +
  • + +
    + +
  • + First Seen: + {{entry.date_first_seen | dateFormat:'MMM dd, yyyy'}} +
  • +
  • + Last Seen: + {{entry.date_last_seen | dateFormat:'MMM dd, yyyy'}} +
  • +
    +
    + +
    +
    +
    Rating
    +
    +
  • + TMDB Rating: + {{entry.entryRating.tmdb_rating | floatFormat:1}}/10 +
  • +
  • + IMDB Rating: + {{entry.entryRating.imdb_rating | floatFormat:1}}/10 +
  • +
  • + Rotten Romatoes: + {{entry.entryRating.rotten_tomatoes_rating | floatFormat:1}}/10 +
  • +
    +
    + + +
    +
    +
    Watch History
    +
    @@ -61,7 +108,11 @@ delete_forever - + +
    diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.ts b/frontend/src/app/features/entry/entry-page/entry-page.component.ts index dda9eee..d86bbf9 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.ts +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.ts @@ -18,6 +18,7 @@ import { EpisodeSeenService } from '../../../core/services/episode-seen.service' import { SeasonService } from '../../../core/services/season.service'; import { LibraryService } from '../../../core/services/library.service'; import { ToastrService } from 'ngx-toastr'; +import { EntrySeen } from '../../../shared/models/entrySeen.model'; @Component({ selector: 'app-entry-page', @@ -125,51 +126,6 @@ export class EntryPageComponent implements OnInit { this.getEpisodesSeenHistory(); } - openEntrySeenModal() { - if (!this.entry) return; - - const dialogRef = this.dialog.open(SeenModalComponent, { - width: '360px', - }); - - dialogRef.afterClosed().subscribe((result) => { - if (result) { - // console.log('Seen dialog closed with:', result); - - if (result.watchDate == '') { - // TODO show no was passed date notification - return; - } - - let watchDate = result.watchDate; - let watchedWith = result.watchedWith.split('\n').join(', '); - - this.entrySeenService - .createEntrySeen(this.entry.id.toString(), watchDate, watchedWith) - .subscribe({ - next: (entrySeen) => { - if (entrySeen) { - // TODO show confirm notification - // console.log(`EntrySeen Added`, entrySeen); - this.entry.entrySeen.push(entrySeen); - - if (this.entry.watchlist) { - this.libraryService.refrechEntries().subscribe(); - } - } - }, - error: (error) => { - console.error('Error adding entrySeen:', error); - }, - }); - - // TODO show notification - } else { - // console.log('Seen dialog was cancelled'); - } - }); - } - onRatingChange(event: Event) { this.entryRatingsService .updateEntryRatings(this.entry.entryRating) @@ -187,6 +143,88 @@ export class EntryPageComponent implements OnInit { }); } + // ! ENTRY SEEN + openEntrySeenModal(entrySeen: EntrySeen = {} as EntrySeen) { + if (!this.entry) return; + + let oldData = {} as { watchDate: Date; watchedWith: string }; + if (entrySeen.id) { + oldData.watchDate = entrySeen.date_seen; + oldData.watchedWith = entrySeen.seen_with; + } + const dialogRef = this.dialog.open(SeenModalComponent, { + width: '360px', + data: oldData.watchDate ? oldData : {}, + }); + + dialogRef.afterClosed().subscribe((result) => { + if (result) { + if (result.watchDate == '') { + // TODO show no was passed date notification + return; + } + + let watchDate = result.watchDate; + let watchedWith = result.watchedWith.split('\n').join(', '); + + if (entrySeen.id) { + const es = { + id: entrySeen.id, + date_seen: watchDate, + seen_with: watchedWith, + } as EntrySeen; + + // * Update + this.entrySeenService.updateEntrySeen(es).subscribe({ + next: (updatedEntrySeen) => { + if (updatedEntrySeen) { + // TODO show confirm notification + // ? replace the entry-seen object with the updated one + for (let i = 0; i < this.entry.entrySeen.length; i++) { + if (this.entry.entrySeen[i].id == updatedEntrySeen.id) + this.entry.entrySeen[i] = updatedEntrySeen; + } + } + }, + error: (error) => { + console.error('Error adding entrySeen:', error); + }, + }); + } else { + // * Create + this.entrySeenService + .createEntrySeen(this.entry.id.toString(), watchDate, watchedWith) + .subscribe({ + next: (entrySeen) => { + if (entrySeen) { + // TODO show confirm notification + this.entry.entrySeen.push(entrySeen); + + // ? if the entry was in watch list creating and entry-seen would have removed it + // ? from the watchlist, so now we need to refrech libraryService in order to + // ? update the watchlist page + if (this.entry.watchlist) { + this.libraryService.refrechEntries().subscribe(); + } + } + }, + error: (error) => { + console.error('Error adding entrySeen:', error); + }, + }); + } + + // TODO show notification + } else { + // console.log('Seen dialog was cancelled'); + } + }); + } + + editEntrySeen(entrySeen: EntrySeen) { + this.openEntrySeenModal(entrySeen); + } + removeEntrySeen(id: number) { const dialogRef = this.dialog.open(ConfirmModalComponent, { width: '400px', diff --git a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts index 0711366..343f621 100644 --- a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts +++ b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts @@ -43,7 +43,7 @@ export class SeenModalComponent implements OnInit { ) {} ngOnInit(): void { - if (this.data == null) { + if (this.data.watchDate == null) { // ? no initial data was passed: populate date field with current date this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US'); } else { From d6245fa7683e472a96788602c136ea76362e0aea Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 06:56:11 +0100 Subject: [PATCH 02/11] changed the collections list to a card grid --- .../userCollections-list-item.component.css | 22 +++++++++++++++---- .../userCollections-list-item.component.html | 17 +++++++------- .../userCollections-page.component.css | 6 +++++ .../userCollections-page.component.html | 13 +++++++---- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.css b/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.css index bf9ed8f..b99a0bd 100644 --- a/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.css +++ b/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.css @@ -6,15 +6,29 @@ font-size: 20px; } -.list-line { +.collection-card { border-radius: 1px; - padding: 2px; + padding: 5px; + min-height: 225px; + margin: 10px 10px; +} +.card-coat{ + height: 100%; + border-radius: 5px; + cursor: pointer; } -.list-line:hover { +.card-coat:hover { background-color: var(--shz-light-bgh); } -:host-context([data-bs-theme="dark"]) .list-line:hover { +:host-context([data-bs-theme="dark"]) .card-coat:hover { background-color: var(--shz-dark-bgh); +} + +#poster { + border-radius: 5px; + min-height: 225px; + height: 225px; + object-fit:cover; } \ No newline at end of file diff --git a/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.html b/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.html index bb0f6c4..146f456 100644 --- a/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.html +++ b/frontend/src/app/features/collections/user-collections/userCollection-list-item/userCollections-list-item.component.html @@ -1,11 +1,10 @@ -
    - List poster -
    -
    {{list.name}}
    -

    Created: {{getCreatedDate() | dateFormat}}

    -

    Contains: {{list.userCollectionEntries.length}} title(s)

    +
    +
    + List poster +
    +
    {{list.name}}
    + + +
    -
    \ No newline at end of file diff --git a/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.css b/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.css index e69de29..de3f200 100644 --- a/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.css +++ b/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.css @@ -0,0 +1,6 @@ +.collections-container{ + display: grid; + grid-template-columns: repeat(auto-fill, + minmax(150px, 2fr)); + gap: 20px; +} \ No newline at end of file diff --git a/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.html b/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.html index b6bd068..cfcd084 100644 --- a/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.html +++ b/frontend/src/app/features/collections/user-collections/userCollections-page/userCollections-page.component.html @@ -30,14 +30,19 @@
    -
    + +
    + +
    + + -
    -
    +
    --> +
    From ca7e3fa4890912bf66c3846e22799c50b795b046 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 07:09:18 +0100 Subject: [PATCH 03/11] minor entry page styles update --- .../entry/entry-page/entry-page.component.css | 3 - .../entry-page/entry-page.component.html | 113 +++++++++--------- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.css b/frontend/src/app/features/entry/entry-page/entry-page.component.css index 50f55ee..d366943 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.css +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.css @@ -171,9 +171,6 @@ margin-bottom: 0; } -hr { - color: #ffffff; -} .info-card hr { margin-top: 5px; } diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.html b/frontend/src/app/features/entry/entry-page/entry-page.component.html index d0c517e..c1631f3 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.html +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.html @@ -33,7 +33,7 @@ dateFormat:'MMM dd, yyyy'}} --> -
    +
    Info

    @@ -63,7 +63,7 @@
    -
    +
    Rating

    @@ -123,7 +123,6 @@
    -
    @@ -164,14 +163,18 @@
    - -

    {{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}}

    - -

    {{this.entry.original_title}}

    -

    {{this.entry.tagline}}

    -

    {{this.entry.storyline}}

    +
    + +

    + {{this.entry.original_title}} • + {{this.entry.release_date | dateFormat:'yyyy'}} • {{genres}} +

    + +

    {{this.entry.tagline}}

    +

    {{this.entry.storyline}}

    +

    Seasons

    @@ -200,57 +203,59 @@ -

    Watch History

    - - - - - - - - - - - - - - - - - +
    +
    SeasonEpisodeDate SeenSeen WithAction
    {{ item.season_number == 0 ? 'Special' : 'Season '+ item.season_number }}{{ item.episode_number }}{{ item.date_seen | dateFormat:'MMM dd, yyyy' }}{{ item.seen_with }} - -
    + + + + + + + + + + + + + + + + - - -
    SeasonEpisodeDate SeenSeen WithAction
    {{ item.season_number == 0 ? 'Special' : 'Season '+ item.season_number }}{{ item.episode_number }}{{ item.date_seen | dateFormat:'MMM dd, yyyy' }}{{ item.seen_with }} + +
    + + + -
    - +
    + +
    +
    From 728dae4e59ec06fd0576f639a730883dded27105 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 07:23:13 +0100 Subject: [PATCH 04/11] renamed search component to search-page --- frontend/src/app/app-routing.module.ts | 4 ++-- frontend/src/app/app.module.ts | 4 ++-- .../search-page.component.css} | 0 .../search-page.component.html} | 0 .../search-page/search-page.component.spec.ts | 21 +++++++++++++++++++ .../search-page.component.ts} | 8 +++---- .../discover/search/search.component.spec.ts | 21 ------------------- .../modals/seen-modal/seen-modal.component.ts | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) rename frontend/src/app/features/discover/{search/search.component.css => search-page/search-page.component.css} (100%) rename frontend/src/app/features/discover/{search/search.component.html => search-page/search-page.component.html} (100%) create mode 100644 frontend/src/app/features/discover/search-page/search-page.component.spec.ts rename frontend/src/app/features/discover/{search/search.component.ts => search-page/search-page.component.ts} (93%) delete mode 100644 frontend/src/app/features/discover/search/search.component.spec.ts diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 4a068b9..4dd199f 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { HomeComponent } from './features/home/home.component'; -import { SearchComponent } from './features/discover/search/search.component'; +import { SearchPageComponent } from './features/discover/search-page/search-page.component'; import { TrendingComponent } from './features/discover/trending/trending.component'; import { PopularComponent } from './features/discover/popular/popular.component'; import { LibraryComponent } from './features/library/library.component'; @@ -12,7 +12,7 @@ import { SettingsComponent } from './features/settings/settings.component'; const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomeComponent }, - { path: 'search', component: SearchComponent }, + { path: 'search', component: SearchPageComponent }, { path: 'popular', component: PopularComponent }, { path: 'trending', component: TrendingComponent }, diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index f7c9833..8f9984b 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -14,7 +14,7 @@ import { CommonModule, DatePipe } from '@angular/common'; import { HomeComponent } from './features/home/home.component'; import { PopularComponent } from './features/discover/popular/popular.component'; import { TrendingComponent } from './features/discover/trending/trending.component'; -import { SearchComponent } from './features/discover/search/search.component'; +import { SearchPageComponent } from './features/discover/search-page/search-page.component'; import { LibraryComponent } from './features/library/library.component'; import { DynamicEntryListComponent } from './shared/components/lists/dynamic-entry-list/dynamic-entry-list.component'; @@ -53,7 +53,7 @@ import { ToastrModule } from 'ngx-toastr'; HomeComponent, PopularComponent, TrendingComponent, - SearchComponent, + SearchPageComponent, LibraryComponent, FavoritComponent, WatchlistComponent, diff --git a/frontend/src/app/features/discover/search/search.component.css b/frontend/src/app/features/discover/search-page/search-page.component.css similarity index 100% rename from frontend/src/app/features/discover/search/search.component.css rename to frontend/src/app/features/discover/search-page/search-page.component.css diff --git a/frontend/src/app/features/discover/search/search.component.html b/frontend/src/app/features/discover/search-page/search-page.component.html similarity index 100% rename from frontend/src/app/features/discover/search/search.component.html rename to frontend/src/app/features/discover/search-page/search-page.component.html diff --git a/frontend/src/app/features/discover/search-page/search-page.component.spec.ts b/frontend/src/app/features/discover/search-page/search-page.component.spec.ts new file mode 100644 index 0000000..b203dc7 --- /dev/null +++ b/frontend/src/app/features/discover/search-page/search-page.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SearchPageComponent } from './search-page.component'; + +describe('SearchPageComponent', () => { + let component: SearchPageComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [SearchPageComponent] + }); + fixture = TestBed.createComponent(SearchPageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/features/discover/search/search.component.ts b/frontend/src/app/features/discover/search-page/search-page.component.ts similarity index 93% rename from frontend/src/app/features/discover/search/search.component.ts rename to frontend/src/app/features/discover/search-page/search-page.component.ts index d77c4a5..27b34e8 100644 --- a/frontend/src/app/features/discover/search/search.component.ts +++ b/frontend/src/app/features/discover/search-page/search-page.component.ts @@ -5,11 +5,11 @@ import { FormControl } from '@angular/forms'; import { debounceTime, distinctUntilChanged } from 'rxjs'; @Component({ - selector: 'app-search', - templateUrl: './search.component.html', - styleUrls: ['./search.component.css'], + selector: 'app-search-page', + templateUrl: './search-page.component.html', + styleUrls: ['./search-page.component.css'], }) -export class SearchComponent implements OnInit { +export class SearchPageComponent implements OnInit { entryType: boolean = true; entries: Entry[] = []; isSearchLocked: boolean = false; diff --git a/frontend/src/app/features/discover/search/search.component.spec.ts b/frontend/src/app/features/discover/search/search.component.spec.ts deleted file mode 100644 index 94a4cfa..0000000 --- a/frontend/src/app/features/discover/search/search.component.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { SearchComponent } from './search.component'; - -describe('SearchComponent', () => { - let component: SearchComponent; - let fixture: ComponentFixture; - - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [SearchComponent] - }); - fixture = TestBed.createComponent(SearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts index 343f621..bd1fa41 100644 --- a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts +++ b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.ts @@ -43,7 +43,7 @@ export class SeenModalComponent implements OnInit { ) {} ngOnInit(): void { - if (this.data.watchDate == null) { + if (!this.data || !this.data.watchDate) { // ? no initial data was passed: populate date field with current date this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US'); } else { From 29d6e3f503bfec1049097c31e0a0276330c7341c Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 17:03:38 +0100 Subject: [PATCH 05/11] Add specific episode-seen --- backend/routes/entry.routes.js | 50 ++++++- backend/routes/season.routes.js | 11 +- .../src/app/core/services/season.service.ts | 6 + .../entry-page/entry-page.component.html | 14 +- .../entry/entry-page/entry-page.component.ts | 46 +++++- .../episode-seen-modal.component.css | 0 .../episode-seen-modal.component.html | 43 ++++++ .../episode-seen-modal.component.spec.ts | 23 +++ .../episode-seen-modal.component.ts | 133 ++++++++++++++++++ .../seen-modal/seen-modal.component.html | 1 - frontend/src/app/shared/shared.module.ts | 4 +- frontend/src/assets/sass/main.css | 6 +- frontend/src/assets/sass/main.scss | 8 +- 13 files changed, 323 insertions(+), 22 deletions(-) create mode 100644 frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.css create mode 100644 frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.html create mode 100644 frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.spec.ts create mode 100644 frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.ts diff --git a/backend/routes/entry.routes.js b/backend/routes/entry.routes.js index d097ff9..6be0be5 100644 --- a/backend/routes/entry.routes.js +++ b/backend/routes/entry.routes.js @@ -1,15 +1,18 @@ const express = require('express'); +const entryRouter = express.Router(); + const { fetchEntryData } = require('../services/tmdbService'); +const { saveEntry, refrechEntry } = require('../services/entryService'); +const { bulkImportMovies, bulkImportTmdb, bulkImportEpisodes } = require('../services/importerService'); + const Entry = require('../models/Entry'); const EntryId = require('../models/EntryId'); const EntryRating = require('../models/EntryRating'); const Genre = require('../models/Genre'); const EntrySeen = require('../models/EntrySeen'); -const { saveEntry, refrechEntry } = require('../services/entryService'); const Season = require('../models/Season'); -const { bulkImportMovies, bulkImportTmdb, bulkImportEpisodes } = require('../services/importerService'); const Media = require('../models/Media'); -const entryRouter = express.Router(); +const Episode = require('../models/Episode'); // ! /entries // * GET - ALL ENTRIES @@ -85,6 +88,47 @@ entryRouter.get('/:id', async (req, res) => { console.log(error); } }); + +// * GET - Get seasons of an entry +entryRouter.get('/:id/seasons', async (req, res) => { + try { + const { id } = req.params; + + if (id == null) { // ! entry id not provided + res.status(404).json({ message: 'Entry id not provided' }); + } + + const entry = await Entry.findByPk(id); + + if (!entry) { + res.status(404).json({ message: 'Entry not found' }); + } + + const seasons = await Season.findAll({ + where: { + entry_id: id + }, + attributes: ['id', 'season_number'], + include: [ + { model: Episode, as: 'episodes', attributes: ['id', 'episode_number'], } + ], + order: [ + ['season_number', 'ASC'], + [{ model: Episode, as: 'episodes' }, 'episode_number', 'ASC'], + ] + }) + + if (seasons.length == 0) { // ! no content + res.status(404).json({ message: 'No seasons' }); + } + + res.status(200).json(seasons); + } catch (error) { + res.status(500).json({ error: error.message }); + console.log(error); + } +}); + // ! POST // * POST - CREATE ENTRY entryRouter.post('/', async (req, res) => { diff --git a/backend/routes/season.routes.js b/backend/routes/season.routes.js index f52fd77..2a1e8fd 100644 --- a/backend/routes/season.routes.js +++ b/backend/routes/season.routes.js @@ -4,7 +4,7 @@ const Episode = require('../models/Episode'); const seasonRouter = express.Router(); // ! /seasons -// POST /seasons - Create a new season +// * POST - Create a new season seasonRouter.post('/', async (req, res) => { try { const season = await Season.create(req.body); @@ -14,7 +14,7 @@ seasonRouter.post('/', async (req, res) => { } }); -// GET /seasons - Retrieve all seasons +// * GET - Retrieve all seasons seasonRouter.get('/', async (req, res) => { try { const seasons = await Season.findAll(); @@ -24,7 +24,7 @@ seasonRouter.get('/', async (req, res) => { } }); -// GET /seasons/:id - Retrieve a specific season by id +// * GET - Retrieve a specific season by id seasonRouter.get('/:id', async (req, res) => { try { const season = await Season.findByPk(req.params.id, { @@ -44,6 +44,7 @@ seasonRouter.get('/:id', async (req, res) => { } }); +// * GET - Retrieve episodes of a season seasonRouter.get('/:id/episodes', async (req, res) => { try { const episodes = await Episode.findAll({ @@ -62,7 +63,7 @@ seasonRouter.get('/:id/episodes', async (req, res) => { } }); -// PUT /seasons/:id - Update a season +// * PUT - Update a season seasonRouter.put('/:id', async (req, res) => { try { const [updated] = await Season.update(req.body, { @@ -79,7 +80,7 @@ seasonRouter.put('/:id', async (req, res) => { } }); -// DELETE /seasons/:id - Delete a season +// * DELETE - Delete a season seasonRouter.delete('/:id', async (req, res) => { try { const deleted = await Season.destroy({ diff --git a/frontend/src/app/core/services/season.service.ts b/frontend/src/app/core/services/season.service.ts index 1a234f5..a6ed3e0 100644 --- a/frontend/src/app/core/services/season.service.ts +++ b/frontend/src/app/core/services/season.service.ts @@ -31,4 +31,10 @@ export class SeasonService { `${this.backend_apiUrl}/${this.apiAction}/${id}/episodes` ); } + + getSeasonsWithEpisodesByEntryId(entryId: number) { + return this.http.get( + `${this.backend_apiUrl}/entries/${entryId}/seasons` + ); + } } diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.html b/frontend/src/app/features/entry/entry-page/entry-page.component.html index c1631f3..9afe859 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.html +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.html @@ -204,7 +204,19 @@

    Collections

    -->
    -

    Watch History

    +
    +

    Watch History

    + +
    +
    diff --git a/frontend/src/app/features/entry/entry-page/entry-page.component.ts b/frontend/src/app/features/entry/entry-page/entry-page.component.ts index d86bbf9..27261e2 100644 --- a/frontend/src/app/features/entry/entry-page/entry-page.component.ts +++ b/frontend/src/app/features/entry/entry-page/entry-page.component.ts @@ -19,6 +19,7 @@ import { SeasonService } from '../../../core/services/season.service'; import { LibraryService } from '../../../core/services/library.service'; import { ToastrService } from 'ngx-toastr'; import { EntrySeen } from '../../../shared/models/entrySeen.model'; +import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component'; @Component({ selector: 'app-entry-page', @@ -397,6 +398,45 @@ export class EntryPageComponent implements OnInit { this.seenHistoryToShow = temp.slice(startIndex, endIndex); } + addEpisodeSeen() { + if (!this.entry) return; + + const dialogRef = this.dialog.open(EpisodeSeenModalComponent, { + width: '360px', + data: { + entryId: this.entry.id, + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + // ? if an episode-seen was created then refresh the watch history table + if (result && result.created) { + // ? call this function to fetch the new episode-seen history + this.getEpisodesSeenHistory(); + + // ? Updating the episodes seen progress bar in the season card + // ? by fetching a new updated episodes list + this.entry.seasons.forEach(async (season) => { + if (season.season_number == result.season_number) { + this.seasonService.getSeasonEpisodes(season.id).subscribe({ + next: (episodes) => { + // console.log( + // `Loaded Season ${season.season_number} Episodes (${episodes.length})` + // ); + season.episodes = episodes; + }, + error: (error) => { + console.log(`Couldn't fetch season episodes data:`, error); + // TODO show notification + season.episodes = []; + }, + }); + } + }); + } + }); + } + editEpisodeSeen(episodeSeen: EpisodeSeenDto) { if (episodeSeen == null) return; @@ -456,11 +496,11 @@ export class EntryPageComponent implements OnInit { this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({ next: () => { // console.log(`Episode seen deleted.`); - // call this function to fetch the new episode-seen history + // ? call this function to fetch the new episode-seen history this.getEpisodesSeenHistory(); - // trying to update the episodes seen progress bar in the season card - // by fetching a new updated episodes list + // ? Updating the episodes seen progress bar in the season card + // ? by fetching a new updated episodes list this.entry.seasons.forEach(async (season) => { if (season.season_number == episodeSeen.season_number) { this.seasonService.getSeasonEpisodes(season.id).subscribe({ diff --git a/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.css b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.css new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.html b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.html new file mode 100644 index 0000000..dc57a97 --- /dev/null +++ b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.html @@ -0,0 +1,43 @@ +
    + +
    +
    +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    + + +
    +
    + +
    +
    \ No newline at end of file diff --git a/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.spec.ts b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.spec.ts new file mode 100644 index 0000000..d990ed3 --- /dev/null +++ b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EpisodeSeenModalComponent } from './episode-seen-modal.component'; + +describe('EpisodeSeenModalComponent', () => { + let component: EpisodeSeenModalComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [EpisodeSeenModalComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(EpisodeSeenModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.ts b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.ts new file mode 100644 index 0000000..c4385d2 --- /dev/null +++ b/frontend/src/app/shared/components/modals/episode-seen-modal/episode-seen-modal.component.ts @@ -0,0 +1,133 @@ +import { Component, Inject } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; + +import { + trigger, + state, + style, + transition, + animate, +} from '@angular/animations'; +import { formatDate } from '@angular/common'; +import flatpickr from 'flatpickr'; +import { Season } from '../../../models/season.model'; +import { SeasonService } from '../../../../core/services/season.service'; +import { Episode } from '../../../models/episode.models'; +import { EpisodeSeenService } from '../../../../core/services/episode-seen.service'; + +@Component({ + selector: 'app-episode-seen-modal', + templateUrl: './episode-seen-modal.component.html', + styleUrl: './episode-seen-modal.component.css', + animations: [ + trigger('fadeInOut', [ + state('in', style({ opacity: 1 })), + transition(':enter', [style({ opacity: 0 }), animate(600)]), + transition(':leave', [animate(600, style({ opacity: 0 }))]), + ]), + trigger('scaleInOut', [ + transition(':enter', [ + state('in', style({ opacity: 1 })), + style({ transform: 'scale(0)' }), + animate('200ms ease-in-out', style({ transform: 'scale(1)' })), + ]), + transition(':leave', [ + animate('200ms ease-in-out', style({ transform: 'scale(0)' })), + ]), + ]), + ], +}) +export class EpisodeSeenModalComponent { + public entryId: number = 0; + public watchDate: string = ''; + public watchedWith: string = ''; + public seasons: Season[] = []; + + public selectedSeason: Season | null = {} as Season; + public selectedEpisode: Episode | null = {} as Episode; + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any, + private seasonsService: SeasonService, + private episodeSeenService: EpisodeSeenService + ) {} + + ngOnInit(): void { + if (!this.data.entryId) return; + this.entryId = this.data.entryId; + + this.seasonsService + .getSeasonsWithEpisodesByEntryId(this.data.entryId) + .subscribe({ + next: (seasons) => { + this.seasons = seasons; + }, + error: (error) => { + console.log(`Error gettings seasons: `, error); + }, + }); + + flatpickr('#myDatepicker', { + inline: true, + defaultDate: this.watchDate, + altInput: true, + allowInput: false, + altFormat: 'F j, Y', + dateFormat: 'Y-m-d', + }); + } + + onSeasonChange(event: any): void { + this.selectedEpisode = null; + } + + onConfirm(): void { + if (!this.selectedSeason) { + return; + } + + if (!this.selectedEpisode) { + return; + } + + if (!this.watchDate) { + return; + } + + const date_seen = new Date(this.watchDate); + const seen_with = this.watchedWith.split('\n').join(', '); + + this.episodeSeenService + .createEpisodeSeen( + this.entryId, + this.selectedEpisode?.id, + date_seen, + seen_with + ) + .subscribe({ + next: (episodeSeen) => { + if (episodeSeen) { + return this.dialogRef.close({ + created: true, + // ? returning the season number so it can be used to refrech the- + // ? season card progress bar in the entry page + season_number: this.selectedSeason?.season_number, + }); + } + }, + error: (error) => { + console.log(`Episode seen create error: `, error); + // TODO show notification + }, + }); + + this.dialogRef.close({ + created: false, + }); + } + + onClose(): void { + this.dialogRef.close(); + } +} diff --git a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.html b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.html index b13cf3c..a62b8d3 100644 --- a/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.html +++ b/frontend/src/app/shared/components/modals/seen-modal/seen-modal.component.html @@ -2,7 +2,6 @@
    diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts index 5ffdfc6..6ea2d31 100644 --- a/frontend/src/app/shared/shared.module.ts +++ b/frontend/src/app/shared/shared.module.ts @@ -1,7 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; - // * modals import { SeenModalComponent } from './components/modals/seen-modal/seen-modal.component'; import { ConfirmModalComponent } from './components/modals/confirm-modal/confirm-modal.component'; @@ -14,6 +13,7 @@ import { RatingModule } from 'ngx-bootstrap/rating'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CollectionEditModalComponent } from '../features/collections/user-collection-info/collection-edit-modal/collection-edit-modal.component'; import { FloatFormatPipe } from './pipes/float-format/float-format.pipe'; +import { EpisodeSeenModalComponent } from './components/modals/episode-seen-modal/episode-seen-modal.component'; @NgModule({ imports: [ @@ -33,7 +33,7 @@ import { FloatFormatPipe } from './pipes/float-format/float-format.pipe'; SeenModalComponent, CollectionEditModalComponent, ConfirmModalComponent, - + EpisodeSeenModalComponent, ], exports: [ // * pipes diff --git a/frontend/src/assets/sass/main.css b/frontend/src/assets/sass/main.css index 5bad7a5..9fbb737 100644 --- a/frontend/src/assets/sass/main.css +++ b/frontend/src/assets/sass/main.css @@ -62,7 +62,7 @@ input::placeholder { /*header*/ .top-header .navbar { background-color: #ffffff; - height: 70px; + height: 50px; position: fixed; left: 70px; right: 0; @@ -165,7 +165,7 @@ input::placeholder { } .top-header .navbar .nav-item { - height: 70px; + height: 50px; display: flex; align-items: center; } @@ -531,7 +531,7 @@ footer { height: calc(100vh - 70px); /* overflow: hidden; */ - margin-top: 70px; + margin-top: 50px; margin-left: 70px; } diff --git a/frontend/src/assets/sass/main.scss b/frontend/src/assets/sass/main.scss index af379be..84fb8b6 100644 --- a/frontend/src/assets/sass/main.scss +++ b/frontend/src/assets/sass/main.scss @@ -114,7 +114,7 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 .top-header { .navbar { background-color: $headerbg; - height: 70px; + height: 50px; position: fixed; // border-bottom: 1px solid var(--bs-border-color); left: 260px; @@ -220,7 +220,7 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 } .nav-item { - height: 70px; + height: 50px; display: flex; align-items: center; @@ -437,7 +437,7 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 align-items: center; justify-content: start; width: 260px; - height: 70px; + height: 50px; padding: 0 1rem; gap: 0.5rem; // border-bottom: 1px solid var(--bs-border-color); @@ -751,7 +751,7 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 /* main content */ .main-wrapper { - margin-top: 70px; + margin-top: 50px; padding-bottom: 20px; margin-left: 260px; transition: ease-out 0.3s; From 6c30218a51687df09a080c94c9de26044cd27340 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 17:36:05 +0100 Subject: [PATCH 06/11] fix: a few library filter bugs --- .../features/library/library.component.html | 6 ++-- .../app/features/library/library.component.ts | 30 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/features/library/library.component.html b/frontend/src/app/features/library/library.component.html index bcc86da..6c8bae7 100644 --- a/frontend/src/app/features/library/library.component.html +++ b/frontend/src/app/features/library/library.component.html @@ -50,7 +50,7 @@
    + [(ngModel)]="filterCriteria.matchAll" (click)="onFilterChange()" >
    @@ -102,7 +102,7 @@
    Total entries {{entriesCount}}
    -
    +
    • Previous @@ -125,7 +125,7 @@ -
      +
      • Previous diff --git a/frontend/src/app/features/library/library.component.ts b/frontend/src/app/features/library/library.component.ts index 752e799..27d8a46 100644 --- a/frontend/src/app/features/library/library.component.ts +++ b/frontend/src/app/features/library/library.component.ts @@ -105,6 +105,7 @@ export class LibraryComponent implements OnInit, AfterViewInit { }); } + // ! FILTER getQueryParameters() { this.route.queryParams.subscribe((params) => { this.currentPage = params['page'] ? parseInt(params['page'], 10) : 1; @@ -133,46 +134,38 @@ export class LibraryComponent implements OnInit, AfterViewInit { setQueryParameters() { let params = { page: this.currentPage } as LibraryQueryParams; + // ? title if (this.filterCriteria.title?.trim() != '') { params.title = this.filterCriteria.title?.trim(); - } else { - delete params.title; } + // ? years if (this.filterCriteria.years?.length) { params.years = this.filterCriteria.years.join(','); - } else { - delete params.years; } - + // ? genres if (this.filterCriteria.genres?.length) { params.genres = this.filterCriteria.genres.join(','); - } else { - delete params.genres; } + // ? type if (this.filterCriteria.type != 0) { params.type = this.filterCriteria.type; - } else { - delete params.type; } + // ? favorit if (this.filterCriteria.favorit != false) { params.favorit = this.filterCriteria.favorit; - } else { - delete params.favorit; } + // ? hidden if (this.filterCriteria.hidden != false) { params.hidden = this.filterCriteria.hidden; - } else { - delete params.hidden; } + // ? matchAll if (this.filterCriteria.matchAll != true) { params.matchAll = this.filterCriteria.matchAll; - } else { - delete params.matchAll; } this.router.navigate([], { @@ -182,7 +175,6 @@ export class LibraryComponent implements OnInit, AfterViewInit { }); } - // ! FILTER ngAfterViewInit() { $('#year-select') .select2({ @@ -244,14 +236,14 @@ export class LibraryComponent implements OnInit, AfterViewInit { const formattedTitle = this.filterCriteria.title?.toLowerCase().trim() || ''; temp = await this.entries.filter((entry) => { - // Type check + // * Type check let filterType = this.filterCriteria.type - 1 == 0 ? false : true; if (this.filterCriteria.type != 0 && filterType != entry.is_tvseries) { return false; // Skip entry if the type does not match, unless type is 'all' (0) } - // Hidden check - // skip hidden if show hidden is not check + // * Hidden check + // ? skip hidden if show hidden is not checked if (!this.filterCriteria.hidden && entry.hidden) { return false; } From c9c7a920121d97030f005e91fac352c6021d8ad1 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 17:41:54 +0100 Subject: [PATCH 07/11] fix: perfect scrollbar not scrolling to top after changing page --- frontend/src/app/app.component.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 8f665bb..c0a7f2a 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,4 +1,7 @@ import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; +import { filter } from 'rxjs'; + import PerfectScrollbar from 'perfect-scrollbar'; @Component({ @@ -7,12 +10,25 @@ import PerfectScrollbar from 'perfect-scrollbar'; styleUrl: './app.component.css', }) export class AppComponent implements AfterViewInit { + title = 'ShowZ'; + @ViewChild('scrollContainer', { static: true }) scrollContainer!: ElementRef; private ps!: PerfectScrollbar; - title = 'ShowZ'; + constructor(private router: Router) {} ngAfterViewInit() { this.ps = new PerfectScrollbar(this.scrollContainer.nativeElement); + + this.router.events + .pipe(filter(event => event instanceof NavigationEnd)) + .subscribe(() => { + this.scrollToTop(); + }); + } + + scrollToTop() { + this.scrollContainer.nativeElement.scrollTop = 0; + this.ps.update(); } } From 8958ead2101325a7baa8adde17dc8adfd4987f48 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Tue, 4 Jun 2024 02:26:18 +0100 Subject: [PATCH 08/11] started using environment variables --- .../core/services/entry-ratings.service.ts | 6 +++--- .../app/core/services/entry-seen.service.ts | 3 ++- .../src/app/core/services/entry.service.ts | 4 ++-- .../app/core/services/episode-seen.service.ts | 3 ++- .../src/app/core/services/episode.service.ts | 3 ++- .../src/app/core/services/importer.service.ts | 3 ++- .../src/app/core/services/library.service.ts | 19 ++++++++++++------- .../src/app/core/services/season.service.ts | 3 ++- .../src/app/core/services/tmdb.service.ts | 8 +++----- .../core/services/userCollection.service.ts | 3 ++- frontend/src/environments/environment.prod.ts | 6 ++++++ frontend/src/environments/environment.ts | 6 ++++++ 12 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 frontend/src/environments/environment.prod.ts create mode 100644 frontend/src/environments/environment.ts diff --git a/frontend/src/app/core/services/entry-ratings.service.ts b/frontend/src/app/core/services/entry-ratings.service.ts index c413250..438c406 100644 --- a/frontend/src/app/core/services/entry-ratings.service.ts +++ b/frontend/src/app/core/services/entry-ratings.service.ts @@ -1,13 +1,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { EntrySeen } from '../../shared/models/entrySeen.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntryRatingsService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entry-ratings'; constructor(private http: HttpClient) {} @@ -16,7 +16,7 @@ export class EntryRatingsService { return this.http.put( `${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`, { - entryR: entryRatings + entryR: entryRatings, } ); } diff --git a/frontend/src/app/core/services/entry-seen.service.ts b/frontend/src/app/core/services/entry-seen.service.ts index 92a1852..412e3a3 100644 --- a/frontend/src/app/core/services/entry-seen.service.ts +++ b/frontend/src/app/core/services/entry-seen.service.ts @@ -1,12 +1,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EntrySeen } from '../../shared/models/entrySeen.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntrySeenService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entry-seen'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/entry.service.ts b/frontend/src/app/core/services/entry.service.ts index 59ec2b1..e9cf206 100644 --- a/frontend/src/app/core/services/entry.service.ts +++ b/frontend/src/app/core/services/entry.service.ts @@ -4,13 +4,13 @@ import { Observable, map } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; -// import { environment } from '../../../environments/environment'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntryService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entries'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/episode-seen.service.ts b/frontend/src/app/core/services/episode-seen.service.ts index 7a8a726..e0d72ff 100644 --- a/frontend/src/app/core/services/episode-seen.service.ts +++ b/frontend/src/app/core/services/episode-seen.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EpisodeSeen } from '../../shared/models/episodeSeen.model'; import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EpisodeSeenService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'episode-seen'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/episode.service.ts b/frontend/src/app/core/services/episode.service.ts index 08d2b84..0403219 100644 --- a/frontend/src/app/core/services/episode.service.ts +++ b/frontend/src/app/core/services/episode.service.ts @@ -1,11 +1,12 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EpisodeService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'episodes'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/importer.service.ts b/frontend/src/app/core/services/importer.service.ts index 67c5a96..cdde7ff 100644 --- a/frontend/src/app/core/services/importer.service.ts +++ b/frontend/src/app/core/services/importer.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model'; import { HttpClient } from '@angular/common/http'; import { Entry } from '../../shared/models/entry.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class ImporterService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entries'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/library.service.ts b/frontend/src/app/core/services/library.service.ts index d5cecfd..b34033e 100644 --- a/frontend/src/app/core/services/library.service.ts +++ b/frontend/src/app/core/services/library.service.ts @@ -5,6 +5,7 @@ import { catchError, switchMap, tap } from 'rxjs/operators'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', @@ -13,7 +14,8 @@ export class LibraryService implements OnInit { private libraryEntriesSubject = new ReplaySubject(1); private entriesLoaded = false; - private backend_apiUrl = ' http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; + private apiAction = 'entries'; constructor(private http: HttpClient) {} @@ -48,7 +50,7 @@ export class LibraryService implements OnInit { } private fetchAllEntries(forceFetch: boolean = false): Observable { - const endPoint = `${this.backend_apiUrl}/entries`; + const endPoint = `${this.backend_apiUrl}/${this.apiAction}`; // If data is already loaded and not force fetching, immediately return the cached observable. if (this.entriesLoaded && !forceFetch) { @@ -80,10 +82,13 @@ export class LibraryService implements OnInit { if (existingEntry) { return of(existingEntry); } else { - return this.http.post(`${this.backend_apiUrl}/entries`, { - tmdb_id: tmdb_id, - is_tvserie: is_tvserie, - }); + return this.http.post( + `${this.backend_apiUrl}/${this.apiAction}`, + { + tmdb_id: tmdb_id, + is_tvserie: is_tvserie, + } + ); } }) ); @@ -91,7 +96,7 @@ export class LibraryService implements OnInit { deleteEntry(id: number): Observable { // Directly attempt to delete the entry without fetching all entries first. - return this.http.delete(`${this.backend_apiUrl}/entries/${id}`); + return this.http.delete(`${this.backend_apiUrl}/${this.apiAction}/${id}`); } isInLibrary(tmdb_id: string): Observable { diff --git a/frontend/src/app/core/services/season.service.ts b/frontend/src/app/core/services/season.service.ts index a6ed3e0..b5f9d0e 100644 --- a/frontend/src/app/core/services/season.service.ts +++ b/frontend/src/app/core/services/season.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Season } from '../../shared/models/season.model'; import { Episode } from '../../shared/models/episode.models'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class SeasonService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'seasons'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/tmdb.service.ts b/frontend/src/app/core/services/tmdb.service.ts index 30cbf6c..2e1f7d0 100644 --- a/frontend/src/app/core/services/tmdb.service.ts +++ b/frontend/src/app/core/services/tmdb.service.ts @@ -4,6 +4,7 @@ import { Observable, from, map, of, switchMap, toArray } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', @@ -14,8 +15,8 @@ export class TmdbService { constructor(private http: HttpClient) {} // private apiUrl = environment.apiBaseUrl; - private tmdb_apiUrl = 'https://api.themoviedb.org/3'; - private tmdb_apiKey = '5323ef3dc430df54dcb9e58c37fd22bb'; + private tmdb_apiUrl = environment.TMDB_API_URL; + private tmdb_apiKey = environment.TMDB_API_KEY; fetchdata(endPoint: string): Observable { if (this.cach[endPoint]) { @@ -34,9 +35,6 @@ export class TmdbService { getEntriesUsingEndPoint(endPoint: string): Observable { return this.fetchdata(endPoint).pipe( - // map((response) => - // response.results.map((movie: any) => this.adaptMovieToEntry(movie)) - // ) map((response) => { // Check if the data is from cache and has `exist` property if (response.exist) { diff --git a/frontend/src/app/core/services/userCollection.service.ts b/frontend/src/app/core/services/userCollection.service.ts index ca913c3..5647c77 100644 --- a/frontend/src/app/core/services/userCollection.service.ts +++ b/frontend/src/app/core/services/userCollection.service.ts @@ -4,12 +4,13 @@ import { Observable } from 'rxjs'; import { UserCollection } from '../../shared/models/userCollection.model'; import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model'; import { Entry } from '../../shared/models/entry.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class UserCollectionService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'user-collections'; constructor(private http: HttpClient) {} diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts new file mode 100644 index 0000000..57ee8c7 --- /dev/null +++ b/frontend/src/environments/environment.prod.ts @@ -0,0 +1,6 @@ +export const environment = { + production: true, + API_URL: 'http://localhost:4000/api/v1', + TMDB_API_URL: 'https://api.themoviedb.org/3', + TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb', +}; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts new file mode 100644 index 0000000..11a37d4 --- /dev/null +++ b/frontend/src/environments/environment.ts @@ -0,0 +1,6 @@ +export const environment = { + production: false, + API_URL: 'http://localhost:4000/api/v1', + TMDB_API_URL: 'https://api.themoviedb.org/3', + TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb', +}; From b872cd0733dca58bec23c03f3dc57a0dc72c8881 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 5 Jun 2024 00:14:48 +0100 Subject: [PATCH 09/11] fixed electron build + implemented dynamic settings + custom user data folder --- .gitignore | 6 ++ angular.json | 14 +++-- backend/middleware/errorHandler.js | 3 + backend/routes/routes.js | 3 + backend/routes/settings.routes.js | 33 +++++++++++ backend/server.js | 67 +++++++++++++-------- backend/services/logService.js | 31 ++++++++++ backend/services/settingsService.js | 61 +++++++++++++++++++ frontend/src/app/app.component.ts | 2 +- frontend/src/index.html | 2 +- main.js | 90 +++++++++++++++++++---------- package-lock.json | 4 +- package.json | 42 +++++++------- preload.js | 9 +++ 14 files changed, 286 insertions(+), 81 deletions(-) create mode 100644 backend/routes/settings.routes.js create mode 100644 backend/services/logService.js create mode 100644 backend/services/settingsService.js create mode 100644 preload.js diff --git a/.gitignore b/.gitignore index c1f23f0..af97261 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,14 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. +# ! me +settings.json +sequelize.log +showy.log + # Compiled output /dist /dist_exe +/dist_electron /uploads /tmp /out-tsc diff --git a/angular.json b/angular.json index deaaa2e..da8f68f 100644 --- a/angular.json +++ b/angular.json @@ -13,7 +13,7 @@ "build": { "builder": "@angular-devkit/build-angular:application", "options": { - "outputPath": "dist/show-z", + "outputPath": "dist/showy", "index": "frontend/src/index.html", "browser": "frontend/src/main.ts", "polyfills": ["zone.js"], @@ -21,13 +21,14 @@ "assets": ["frontend/src/favicon.ico", "frontend/src/assets"], "styles": [ "frontend/src/styles.css", - + "frontend/src/assets/plugins/select2/css/select2.min.css", "frontend/src/assets/plugins/select2/css/select2-bootstrap4.css", "frontend/src/assets/css/bootstrap.min.css", "frontend/src/assets/css/bootstrap-extended.css", + "frontend/src/assets/plugins/bs-stepper/css/bs-stepper.css", "frontend/src/assets/plugins/metismenu/metisMenu.min.css", "frontend/src/assets/plugins/metismenu/mm-vertical.css", "frontend/src/assets/plugins/simplebar/css/simplebar.css", @@ -37,7 +38,6 @@ "frontend/src/assets/sass/semi-dark.css", "frontend/src/assets/sass/dark-theme.css", - "frontend/src/assets/sass/bordered-theme.css", "node_modules/ngx-toastr/toastr.css", @@ -58,7 +58,7 @@ "frontend/src/assets/plugins/select2/js/select2.min.js", "frontend/src/assets/plugins/select2/js/select2-custom.js", - + "node_modules/flatpickr/dist/flatpickr.min.js", "frontend/src/assets/js/index.js", @@ -67,6 +67,12 @@ }, "configurations": { "production": { + "fileReplacements": [ + { + "replace": "frontend/src/environments/environment.ts", + "with": "frontend/src/environments/environment.prod.ts" + } + ], "budgets": [ { "type": "initial", diff --git a/backend/middleware/errorHandler.js b/backend/middleware/errorHandler.js index 9494b4e..9d4b78e 100644 --- a/backend/middleware/errorHandler.js +++ b/backend/middleware/errorHandler.js @@ -1,11 +1,14 @@ const CustomError = require('../errors/CustomError'); +const { logToFile } = require('../services/logService'); module.exports = (err, req, res, next) => { if (err instanceof CustomError) { res.status(err.statusCode()).json({ message: err.message }); + logToFile(`Error (${err.statusCode()}) ${err.message}`) } else { console.log(`📌 Error: `, err) + logToFile(`Error (500) ${err}`) res.status(500).json({ message: 'Internal server error' }); } }; \ No newline at end of file diff --git a/backend/routes/routes.js b/backend/routes/routes.js index 70f6fcf..14eced0 100644 --- a/backend/routes/routes.js +++ b/backend/routes/routes.js @@ -6,6 +6,7 @@ const entryRouter = require('./entry.routes'); const entryRatingsRouter = require('./entry-ratings.routes'); const seasonRouter = require('./season.routes'); const episodeSeenRouter = require('./episode-seen.routes'); +const settingsRouter = require('./settings.routes'); const router = express.Router(); @@ -18,4 +19,6 @@ router.use('/entry-ratings', entryRatingsRouter); router.use('/seasons', seasonRouter); router.use('/episode-seen', episodeSeenRouter); +router.use('/settings', settingsRouter); + module.exports = router; \ No newline at end of file diff --git a/backend/routes/settings.routes.js b/backend/routes/settings.routes.js new file mode 100644 index 0000000..2e6ed11 --- /dev/null +++ b/backend/routes/settings.routes.js @@ -0,0 +1,33 @@ +const express = require('express'); +const { updateSettings, getSettings } = require('../services/settingsService'); +const settingsRouter = express.Router(); + +const settingsFileFormat = { + "dataFolderPath": "", + "tmdbApiUrl": "", + "tmdbApiKey": "", + "frontPort": "", + "backPort": "", + "portableMode": "", +}; + +// ! /settings +settingsRouter.put('/', async (req, res) => { + const settings = req.body; + + updateSettings(settings); + + res.status(200).send(getSettings()); +}); + +settingsRouter.get('/', (req, res) => { + try { + const settings = getSettings(); + + res.status(200).json(settings); + } catch (err) { + res.status(500).send('Error retrieving settings'); + } +}); + +module.exports = settingsRouter; diff --git a/backend/server.js b/backend/server.js index 830e49d..391d333 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,22 +1,30 @@ -// server.js const express = require('express'); const bodyParser = require('body-parser'); const routes = require('./routes/routes.js'); const sequelize = require('./db/database.js'); const path = require('path'); +const fs = require('fs'); const app = express(); -const PORT = process.env.PORT || 4000; + const relations = require('./db/relations.js'); const sequelizeHooks = require('./db/sequelizeHooks.js'); -const { initializeGenres, initializeData } = require('./db/dataInitializer.js'); +const { initializeData } = require('./db/dataInitializer.js'); const killerRouter = require('./routes/killer.routes.js'); +const errorHandler = require('./middleware/errorHandler'); +const { getSettings } = require('./services/settingsService.js'); +const { logToFile } = require('./services/logService.js'); -// Middleware +// ? variables +let settings = getSettings() +const PORT = settings["backPort"] || 4000; +const parrentProcess = JSON.parse(process.env.PARENT_PROCESS || '{}'); + +// ? Middleware app.use(bodyParser.json()); // for parsing application/json app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded -// CORS Middleware to allow requests from any origin +// * CORS Middleware to allow requests from any origin app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header( @@ -30,52 +38,65 @@ app.use((req, res, next) => { next(); }); -// ? Routes -// * media access route -app.use('/api/v1/media/:category/:type', (req, res, next) => { +// ? Routes : media access routes +app.use('/api/v1/media/:category/:type/:file', (req, res, next) => { const category = req.params.category; const type = req.params.type; + const file = req.params.file; if (!['entries', 'collections', 'franchises'].includes(category)) { return res.status(404).send('Not Found'); } - if (!['backdrops', 'posters', 'others'].includes(type)) { + if (!['backdrops', 'posters', 'logos', 'others'].includes(type)) { return res.status(404).send('Not Found'); } - const options = { - fallthrough: false, // ! Important: don't call next middleware if file isn't found - }; + const settings = getSettings(); + const dataPath = settings.userDataPath; - express.static(path.join(__dirname, '..', `uploads/${category}/${type}`), options)(req, res, next); + const mediaPath = path.join(dataPath, 'images', category, type); + // const mediaPath = path.join(__dirname, '..', `data/images/${category}/${type}`); + const filePath = path.join(mediaPath, file); + logToFile(filePath) + fs.access(filePath, fs.constants.F_OK, (err) => { + if (err) { + return res.status(404).send('Not Found'); + } + + const options = { + fallthrough: false, // ! Important: don't call next middleware if file isn't found + }; + + // express.static(filePath, options)(req, res, next); + // Serve the file using fs.createReadStream + const stream = fs.createReadStream(filePath); + stream.pipe(res); + }); }); -// * other api routes +// ? other api routes app.use('/api/v1', routes); - -// ! Error handling middleware -const errorHandler = require('./middleware/errorHandler'); +// ? Error handling middleware app.use(errorHandler); -// ! KILLER ROUTE: used to crash the backend +// ? KILLER ROUTE: used to crash the backend app.use('/killer', killerRouter); -// Start the server +// * Start the server const doUpdate = false; +const doForce = false; console.log(`Syncing database schema...`); sequelize // .sync({force: true}) // will drop all tables and recreate them. .sync({ alter: doUpdate }) // will attempt to automatically alter tables to fit the model definitions. - // .sync() .then((result) => { - console.log(`Database schema synced...`); + console.log(`Database schema synced.`); initializeData(); app.listen(PORT, () => { - //const Entry = require("./models/Entry.js") - console.log(`Backend server running on http://localhost:${PORT}`); + console.log(`Backend server running on http://localhost:${PORT}/`); }); }) .catch(err => { diff --git a/backend/services/logService.js b/backend/services/logService.js new file mode 100644 index 0000000..5290a57 --- /dev/null +++ b/backend/services/logService.js @@ -0,0 +1,31 @@ +// logService.js +const fs = require('fs'); +const util = require('util'); + +// Convert fs.writeFile to a promise-based function +const writeFile = util.promisify(fs.writeFile); + +// Ensure the log file exists and is accessible +const logFilePath = 'showy.log'; +fs.open(logFilePath, 'a', (err, fd) => { + if (err) { + console.error("Failed to open log file:", err); + } else { + fs.close(fd, (err) => { + if (err) console.error("Failed to close log file:", err); + }); + } +}); + +// Asynchronous function to append a message to the log file +async function logToFile(message) { + try { + await writeFile(logFilePath, `${message}\n`, { flag: 'a' }); + } catch (err) { + console.error("Failed to write to log file:", err); + } +} + +module.exports = { + logToFile, +}; \ No newline at end of file diff --git a/backend/services/settingsService.js b/backend/services/settingsService.js new file mode 100644 index 0000000..e14ff20 --- /dev/null +++ b/backend/services/settingsService.js @@ -0,0 +1,61 @@ +const fs = require('fs'); +const path = require('path'); +const parrentProcess = JSON.parse(process.env.PARENT_PROCESS || '{}'); + +let userDataPath = ''; +const defaultSettings = { + userDataPath: '', + tmdbApiUrl: '', + tmdbApiKey: '', + frontPort: '', + backPort: '', + portableMode: '', +}; + +function getUserDataPath() { + // return parrentProcess.electron_path || path.join(__dirname, '..', '..', 'data'); + return path.join(__dirname, '..', '..'); +} + +function getSettingsFilePath() { + return path.join(getUserDataPath(), 'settings.json'); +} + +function getSettings() { + const settingsFilePath = getSettingsFilePath(); + + try { + const settingsData = fs.readFileSync(settingsFilePath); + // console.log(`Loaded settings file.`); + return JSON.parse(settingsData); + } catch (err) { + console.error('Error reading settings file:', err); + console.log('Creating default settings file...'); + + let newSettingsFile = { ...defaultSettings }; + + let defaultDataPath = path.join(getUserDataPath(), 'data') + + newSettingsFile.userDataPath = defaultDataPath; + newSettingsFile.backPort = 4000; + + fs.mkdirSync(defaultDataPath, { recursive: true }); + fs.writeFileSync(settingsFilePath, JSON.stringify(newSettingsFile, null, 2)); + console.log('Default settings file created.'); + + return defaultSettings; + } +} + +function updateSettings(newSettings) { + const settingsFilePath = getSettingsFilePath(); + + let updatedSettings = { ...userDataPath, ...newSettings }; + fs.mkdirSync(newSettings.userDataPath, { recursive: true }); // making sure the newly set data path is created before saving the new config + fs.writeFileSync(settingsFilePath, JSON.stringify(updatedSettings, null, 2)); +} + +module.exports = { + getSettings, + updateSettings +}; \ No newline at end of file diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index c0a7f2a..d5e84d5 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -10,7 +10,7 @@ import PerfectScrollbar from 'perfect-scrollbar'; styleUrl: './app.component.css', }) export class AppComponent implements AfterViewInit { - title = 'ShowZ'; + title = 'Showy'; @ViewChild('scrollContainer', { static: true }) scrollContainer!: ElementRef; private ps!: PerfectScrollbar; diff --git a/frontend/src/index.html b/frontend/src/index.html index a88c5cf..770e491 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -3,7 +3,7 @@ - ShowZ + Showy diff --git a/main.js b/main.js index d3b3864..70dd6ea 100644 --- a/main.js +++ b/main.js @@ -3,42 +3,17 @@ const { app, BrowserWindow } = require('electron'); const path = require('path'); const url = require('url'); +let expressProcess; let win; -function createWindow() { - win = new BrowserWindow({ - width: 1200, - height: 720, - webPreferences: { - nodeIntegration: true - } - }); - win.loadURL( - url.format({ - pathname: path.join(__dirname, 'dist\\show-z\\browser\\index.html'), - protocol: 'file:', - slashes: true - }) - ); - - win.on('closed', () => { - win = null; - }); -} // app.on('ready', createWindow); - app.on('ready', () => { - // Start the Express server - const expressProcess = spawn('node', ['backend/server.js']); - expressProcess.stdout.on('data', (data) => { - console.log(`Express stdout: ${data}`); - }); - expressProcess.stderr.on('data', (data) => { - console.error(`Express stderr: ${data}`); - }); + // ! Start the Express server loop + startExpressServer(); + createMediaFolders(); // Start the Electron app createWindow(); @@ -55,3 +30,60 @@ app.on('activate', () => { createWindow(); } }); + +const { dialog, ipcMain } = require('electron'); +const { createMediaFolders } = require('./backend/services/mediaService'); + +ipcMain.on('select-dirs', async (event, arg) => { + const result = await dialog.showOpenDialog(mainWindow, { + properties: ['openDirectory'] + }) + console.log('directories selected', result.filePaths) +}) + +function startExpressServer() { + let parrentProcess = { + "electron_path": app.getPath('userData') + } + // Start the Express server + expressProcess = spawn('node', ['backend/server.js'], { env: { PARENT_PROCESS: JSON.stringify(parrentProcess) } }); + expressProcess.stdout.on('data', (data) => { + console.log(`Express stdout: ${data}`); + }); + expressProcess.stderr.on('data', (data) => { + console.error(`Express stderr: ${data}`); + }); + + // Restart the server if it crashes + expressProcess.on('exit', (code, signal) => { + console.log(`Express process exited with code ${code} and signal ${signal}. Restarting...`); + startExpressServer(); + }); +} + +function createWindow() { + win = new BrowserWindow({ + width: 1200, + height: 720, + webPreferences: { + preload: path.join(__dirname, 'preload.js'), + nodeIntegration: true, + enableRemoteModule: false, + contextIsolation: true, + sandbox: true + } + }); + + + win.loadURL( + url.format({ + pathname: path.join(__dirname, 'dist', 'showy', 'browser', 'index.html'), + protocol: 'file:', + slashes: true + }) + ); + + win.on('closed', () => { + win = null; + }); +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5c1bea2..2660428 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "show-z", + "name": "showy", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "show-z", + "name": "showy", "version": "0.0.0", "dependencies": { "@angular/animations": "^17.0.0", diff --git a/package.json b/package.json index 84e5bee..36d4878 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,34 @@ { - "name": "show-z", + "name": "showy", "author": "X4Lo", "description": "Movies & Tv-Series Tracking library", "version": "0.0.0", "main": "main.js", "scripts": { - "ng": "ng", - "start:backend": "nodemon backend/server.js", - "start:frontend": "ng serve", - "electron build": "ng build --configuration=production --base-href ./ && copyfiles backend/**/* dist/show-z && electron .", - "build": "ng build", + "Backend": "nodemon backend/server.js", + "Frontend": "ng serve", + "build-and-copy": "ng build --configuration production --base-href ./ && copyfiles backend/**/* dist/showy", "watch": "ng build --watch --configuration development", - "test": "ng test", - "electron-build": "npm-run-all -s electron-build:*", + "electron-build:all": "ng build --configuration=production --base-href ./ && copyfiles backend/**/* dist/showy && electron . && electron-builder", "electron-build:ng": "ng build --configuration=production --base-href ./", - "electron-build:copy": "copyfiles backend/**/* dist/show-z", + "electron-build:copy": "copyfiles backend/**/* dist/showy", "electron-build:electron": "electron .", - "electron-build:exe": "electron-builder" + "electron-build:exe": "electron-builder", + "electron-copy-be": "copyfiles backend/**/* dist_electron/win-unpacked" }, + "build": { + "appId": "xalo.showy", + "productName": "Showy", + "win": { + "target": "nsis", + "icon": "frontend/to/icon.ico" + }, + "directories": { + "output": "dist_electron" + } + }, + "portable": true, + "singleInstance": false, "private": true, "dependencies": { "@angular/animations": "^17.0.0", @@ -64,16 +75,5 @@ "karma-jasmine-html-reporter": "~2.1.0", "nodemon": "^3.1.0", "typescript": "~5.2.2" - }, - "build": { - "appId": "xalo.showy", - "productName": "Showy", - "win": { - "target": "nsis", - "icon": "frontend/to/icon.ico" - }, - "directories": { - "output": "dist_exe" - } } } diff --git a/preload.js b/preload.js new file mode 100644 index 0000000..a8d3ff3 --- /dev/null +++ b/preload.js @@ -0,0 +1,9 @@ +const { ipcRenderer } = require('electron') + +process.once('loaded', () => { + window.addEventListener('message', evt => { + if (evt.data.type === 'select-dirs') { + ipcRenderer.send('select-dirs') + } + }) +}) \ No newline at end of file From c3294a1ab93d3cee72e65984d900000edf2e8242 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 5 Jun 2024 00:15:36 +0100 Subject: [PATCH 10/11] add settings page + config settings --- frontend/src/app/app-routing.module.ts | 10 ++- frontend/src/app/app.module.ts | 2 - .../src/app/core/services/settings.service.ts | 25 +++++++ .../settings-api-keys.component.css} | 0 .../settings-api-keys.component.html | 1 + .../settings-api-keys.component.spec.ts | 23 ++++++ .../settings-api-keys.component.ts | 10 +++ .../settings-general.component.css | 11 +++ .../settings-general.component.html | 65 +++++++++++++++++ .../settings-general.component.spec.ts} | 12 ++-- .../settings-general.component.ts | 72 +++++++++++++++++++ .../settings-page/settings-page.component.css | 0 .../settings-page.component.html | 51 +++++++++++++ .../settings-page/settings-page.component.ts | 30 ++++++++ .../settings/settings-routing.module.ts | 17 +++++ .../features/settings/settings.component.html | 4 -- .../features/settings/settings.component.ts | 10 --- .../app/features/settings/settings.module.ts | 33 +++++++++ .../src/app/shared/models/settings.model.ts | 8 +++ 19 files changed, 359 insertions(+), 25 deletions(-) create mode 100644 frontend/src/app/core/services/settings.service.ts rename frontend/src/app/features/settings/{settings.component.css => settings-api-keys/settings-api-keys.component.css} (100%) create mode 100644 frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.html create mode 100644 frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.spec.ts create mode 100644 frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.ts create mode 100644 frontend/src/app/features/settings/settings-general/settings-general.component.css create mode 100644 frontend/src/app/features/settings/settings-general/settings-general.component.html rename frontend/src/app/features/settings/{settings.component.spec.ts => settings-general/settings-general.component.spec.ts} (50%) create mode 100644 frontend/src/app/features/settings/settings-general/settings-general.component.ts create mode 100644 frontend/src/app/features/settings/settings-page/settings-page.component.css create mode 100644 frontend/src/app/features/settings/settings-page/settings-page.component.html create mode 100644 frontend/src/app/features/settings/settings-page/settings-page.component.ts create mode 100644 frontend/src/app/features/settings/settings-routing.module.ts delete mode 100644 frontend/src/app/features/settings/settings.component.html delete mode 100644 frontend/src/app/features/settings/settings.component.ts create mode 100644 frontend/src/app/features/settings/settings.module.ts create mode 100644 frontend/src/app/shared/models/settings.model.ts diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 4dd199f..f8b6c53 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -7,7 +7,6 @@ import { PopularComponent } from './features/discover/popular/popular.component' import { LibraryComponent } from './features/library/library.component'; import { FavoritComponent } from './features/favorit/favorit.component'; import { WatchlistComponent } from './features/watchlist/watchlist.component'; -import { SettingsComponent } from './features/settings/settings.component'; const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, @@ -19,8 +18,13 @@ const routes: Routes = [ { path: 'library', component: LibraryComponent }, { path: 'favorit', component: FavoritComponent }, { path: 'watchlist', component: WatchlistComponent }, - { path: 'settings', component: SettingsComponent }, - // { path: 'entry', component: LibraryComponent }, + { + path: 'settings', + loadChildren: () => + import('./features/settings/settings.module').then( + (m) => m.SettingsModule + ), + }, { path: 'entries', loadChildren: () => diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 8f9984b..2efae5e 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -23,7 +23,6 @@ import { MainCardComponent } from './shared/components/cards/main-card/main-card import { FavoritComponent } from './features/favorit/favorit.component'; import { WatchlistComponent } from './features/watchlist/watchlist.component'; import { SharedModule } from './shared/shared.module'; -import { SettingsComponent } from './features/settings/settings.component'; import { ToastrModule } from 'ngx-toastr'; @NgModule({ @@ -57,7 +56,6 @@ import { ToastrModule } from 'ngx-toastr'; LibraryComponent, FavoritComponent, WatchlistComponent, - SettingsComponent, // ? temp shared components MainCardComponent, diff --git a/frontend/src/app/core/services/settings.service.ts b/frontend/src/app/core/services/settings.service.ts new file mode 100644 index 0000000..d115295 --- /dev/null +++ b/frontend/src/app/core/services/settings.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../environments/environment.prod'; +import { Settings } from '../../shared/models/settings.model'; + +@Injectable({ + providedIn: 'root', +}) +export class SettingsService { + private backend_apiUrl = environment.API_URL; + private apiAction = 'settings'; + + constructor(private http: HttpClient) {} + + getSettings() { + return this.http.get(`${this.backend_apiUrl}/${this.apiAction}`); + } + + updateSettings(settings: Settings) { + return this.http.put( + `${this.backend_apiUrl}/${this.apiAction}`, + settings + ); + } +} diff --git a/frontend/src/app/features/settings/settings.component.css b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.css similarity index 100% rename from frontend/src/app/features/settings/settings.component.css rename to frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.css diff --git a/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.html b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.html new file mode 100644 index 0000000..50fe84e --- /dev/null +++ b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.html @@ -0,0 +1 @@ +

        settings-api-keys works!

        diff --git a/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.spec.ts b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.spec.ts new file mode 100644 index 0000000..9531a51 --- /dev/null +++ b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SettingsApiKeysComponent } from './settings-api-keys.component'; + +describe('SettingsApiKeysComponent', () => { + let component: SettingsApiKeysComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SettingsApiKeysComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SettingsApiKeysComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.ts b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.ts new file mode 100644 index 0000000..f032b48 --- /dev/null +++ b/frontend/src/app/features/settings/settings-api-keys/settings-api-keys.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-settings-api-keys', + templateUrl: './settings-api-keys.component.html', + styleUrl: './settings-api-keys.component.css' +}) +export class SettingsApiKeysComponent { + +} diff --git a/frontend/src/app/features/settings/settings-general/settings-general.component.css b/frontend/src/app/features/settings/settings-general/settings-general.component.css new file mode 100644 index 0000000..9c3817d --- /dev/null +++ b/frontend/src/app/features/settings/settings-general/settings-general.component.css @@ -0,0 +1,11 @@ +.form-group { + margin-bottom: 1rem; +} + +.is-invalid { + border-color: #dc3545; +} + +.invalid-feedback { + display: block; +} \ No newline at end of file diff --git a/frontend/src/app/features/settings/settings-general/settings-general.component.html b/frontend/src/app/features/settings/settings-general/settings-general.component.html new file mode 100644 index 0000000..c23e888 --- /dev/null +++ b/frontend/src/app/features/settings/settings-general/settings-general.component.html @@ -0,0 +1,65 @@ + +
        + + +
        + User Data Path is required. +
        +
        + +
        + + +
        + TMDB API URL is required. +
        +
        + +
        + + +
        + TMDB API Key is required. +
        +
        + +
        + + +
        + Front Port is required and must be a number. +
        +
        + +
        + + +
        + Back Port is required and must be a number. +
        +
        + +
        + + +
        + Portable Mode is required. +
        +
        + + + + + \ No newline at end of file diff --git a/frontend/src/app/features/settings/settings.component.spec.ts b/frontend/src/app/features/settings/settings-general/settings-general.component.spec.ts similarity index 50% rename from frontend/src/app/features/settings/settings.component.spec.ts rename to frontend/src/app/features/settings/settings-general/settings-general.component.spec.ts index b0f7d8f..f2804b1 100644 --- a/frontend/src/app/features/settings/settings.component.spec.ts +++ b/frontend/src/app/features/settings/settings-general/settings-general.component.spec.ts @@ -1,18 +1,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { SettingsComponent } from './settings.component'; +import { SettingsGeneralComponent } from './settings-general.component'; -describe('SettingsComponent', () => { - let component: SettingsComponent; - let fixture: ComponentFixture; +describe('SettingsGeneralComponent', () => { + let component: SettingsGeneralComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [SettingsComponent] + imports: [SettingsGeneralComponent] }) .compileComponents(); - fixture = TestBed.createComponent(SettingsComponent); + fixture = TestBed.createComponent(SettingsGeneralComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/frontend/src/app/features/settings/settings-general/settings-general.component.ts b/frontend/src/app/features/settings/settings-general/settings-general.component.ts new file mode 100644 index 0000000..cb1ddf9 --- /dev/null +++ b/frontend/src/app/features/settings/settings-general/settings-general.component.ts @@ -0,0 +1,72 @@ +import { Component, OnInit } from '@angular/core'; +import { Settings } from '../../../shared/models/settings.model'; +import { SettingsService } from '../../../core/services/settings.service'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; + +@Component({ + selector: 'app-settings-general', + templateUrl: './settings-general.component.html', + styleUrl: './settings-general.component.css', +}) +export class SettingsGeneralComponent implements OnInit { + settings: Settings = {} as Settings; + settingsForm!: FormGroup; + + constructor( + private settingsService: SettingsService, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.settingsForm = this.fb.group({ + userDataPath: [this.settings.userDataPath], + tmdbApiUrl: [this.settings.tmdbApiUrl], + tmdbApiKey: [this.settings.tmdbApiKey, Validators.required], + frontPort: [this.settings.frontPort, Validators.pattern('^[0-9]{4,5}$')], + backPort: [ + this.settings.backPort, + [Validators.required, Validators.pattern('^[0-9]{4,5}$')], + ], + portableMode: [this.settings.portableMode], + }); + + this.settingsService.getSettings().subscribe({ + next: (s) => { + this.settings = s; + + // Update the form with fetched settings + this.settingsForm.patchValue({ + userDataPath: this.settings.userDataPath, + tmdbApiUrl: this.settings.tmdbApiUrl, + tmdbApiKey: this.settings.tmdbApiKey, + frontPort: this.settings.frontPort, + backPort: this.settings.backPort, + portableMode: this.settings.portableMode, + }); + }, + error: (error) => { + console.log(`Error getting settings...`); + }, + }); + } + + get f() { + return this.settingsForm.controls; + } + + onSubmit(): void { + if (this.settingsForm.valid) { + const settings: Settings = this.settingsForm.value; + this.settingsService.updateSettings(settings).subscribe({ + next: (s) => { + // TODO: SHOW SUCCESS TOAST + console.log(`Settings updated: `); + }, + error: (error) => { + // TODO: SHOW ERROR TOAST + console.log(`Error updating settings: `, error); + }, + }); + } + } +} diff --git a/frontend/src/app/features/settings/settings-page/settings-page.component.css b/frontend/src/app/features/settings/settings-page/settings-page.component.css new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/app/features/settings/settings-page/settings-page.component.html b/frontend/src/app/features/settings/settings-page/settings-page.component.html new file mode 100644 index 0000000..caab0d0 --- /dev/null +++ b/frontend/src/app/features/settings/settings-page/settings-page.component.html @@ -0,0 +1,51 @@ +
        +
        +
        + +
        + +
        + +
        + + +
        + +
        + +
        + + +
        + +
        +
        Application Settings
        +

        General application settings

        + +
        + + +
        +
        API keys
        +

        Setup your API keys

        + +
        + +
        +
        +
        +
        \ No newline at end of file diff --git a/frontend/src/app/features/settings/settings-page/settings-page.component.ts b/frontend/src/app/features/settings/settings-page/settings-page.component.ts new file mode 100644 index 0000000..4f47e64 --- /dev/null +++ b/frontend/src/app/features/settings/settings-page/settings-page.component.ts @@ -0,0 +1,30 @@ +import { AfterViewInit, ChangeDetectorRef, Component } from '@angular/core'; + +@Component({ + selector: 'app-settings-page', + templateUrl: './settings-page.component.html', + styleUrl: './settings-page.component.css', +}) +export class SettingsPageComponent implements AfterViewInit { + // stepper!: Stepper; + step: number = 1; + + constructor(private cdRef: ChangeDetectorRef) {} + + ngAfterViewInit() { + // const stepperElement = document.querySelector('#settingsStepper'); + // if (stepperElement) { + // this.stepper = new Stepper(stepperElement, { + // linear: false, + // animation: true, + // }); + // this.cdRef.detectChanges(); + // } else { + // console.error('Stepper element not found!'); + // } + } + + setStep(step: number) { + this.step = step; + } +} diff --git a/frontend/src/app/features/settings/settings-routing.module.ts b/frontend/src/app/features/settings/settings-routing.module.ts new file mode 100644 index 0000000..e6488f7 --- /dev/null +++ b/frontend/src/app/features/settings/settings-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { SettingsPageComponent } from './settings-page/settings-page.component'; + +// ! /user-collections +const routes: Routes = [ + { + path: '', + component: SettingsPageComponent, + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class SettingsRoutingModule {} diff --git a/frontend/src/app/features/settings/settings.component.html b/frontend/src/app/features/settings/settings.component.html deleted file mode 100644 index 92c9dc3..0000000 --- a/frontend/src/app/features/settings/settings.component.html +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/frontend/src/app/features/settings/settings.component.ts b/frontend/src/app/features/settings/settings.component.ts deleted file mode 100644 index 985b43e..0000000 --- a/frontend/src/app/features/settings/settings.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-settings', - templateUrl: './settings.component.html', - styleUrl: './settings.component.css', -}) -export class SettingsComponent { - constructor() {} -} diff --git a/frontend/src/app/features/settings/settings.module.ts b/frontend/src/app/features/settings/settings.module.ts new file mode 100644 index 0000000..343c971 --- /dev/null +++ b/frontend/src/app/features/settings/settings.module.ts @@ -0,0 +1,33 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { SharedModule } from '../../shared/shared.module'; + +import { DragDropModule } from '@angular/cdk/drag-drop'; + +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +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'; + +@NgModule({ + imports: [ + CommonModule, + SharedModule, + + FormsModule, + ReactiveFormsModule, + + SettingsRoutingModule, + + DragDropModule, + ], + declarations: [ + SettingsPageComponent, + + SettingsGeneralComponent, + SettingsApiKeysComponent, + ], + exports: [], +}) +export class SettingsModule {} diff --git a/frontend/src/app/shared/models/settings.model.ts b/frontend/src/app/shared/models/settings.model.ts new file mode 100644 index 0000000..4fbe058 --- /dev/null +++ b/frontend/src/app/shared/models/settings.model.ts @@ -0,0 +1,8 @@ +export interface Settings { + userDataPath: string; + tmdbApiUrl: string; + tmdbApiKey: string; + frontPort: number; + backPort: number; + portableMode: string; +} From 3076406b587c672ef83d967971fba90c0dc56441 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Wed, 5 Jun 2024 00:16:39 +0100 Subject: [PATCH 11/11] add logo to collection list + minor changes --- .../components/navbar/navbar.component.html | 24 +++++++++--------- .../components/sidebar/sidebar.component.css | 3 ++- .../components/sidebar/sidebar.component.html | 2 +- .../collection-table-line.component.html | 2 +- .../collection-table-line.component.ts | 22 ++++++++++++++++ .../src/app/features/home/home.component.html | 4 +-- .../src/app/features/home/home.component.ts | 2 +- .../cards/main-card/main-card.component.html | 6 ++--- .../confirm-modal/confirm-modal.component.ts | 3 +-- .../pipes/date-format/date-format.pipe.ts | 8 ------ .../assets/images/default/default-logo.png | Bin 0 -> 7484 bytes frontend/src/assets/sass/main.css | 2 +- frontend/src/assets/sass/main.scss | 6 ++--- 13 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 frontend/src/assets/images/default/default-logo.png diff --git a/frontend/src/app/core/components/navbar/navbar.component.html b/frontend/src/app/core/components/navbar/navbar.component.html index 7a709fb..0d81417 100644 --- a/frontend/src/app/core/components/navbar/navbar.component.html +++ b/frontend/src/app/core/components/navbar/navbar.component.html @@ -580,19 +580,19 @@
      - person_outlineProfile - local_barSetting - dashboardDashboard - account_balanceEarning - cloud_downloadDownloads + + person_outlineProfile + + local_barSetting + + dashboardDashboard + + account_balanceEarning + + cloud_downloadDownloads - power_settings_newLogout + + power_settings_newLogout
    diff --git a/frontend/src/app/core/components/sidebar/sidebar.component.css b/frontend/src/app/core/components/sidebar/sidebar.component.css index 871ff7f..635fdff 100644 --- a/frontend/src/app/core/components/sidebar/sidebar.component.css +++ b/frontend/src/app/core/components/sidebar/sidebar.component.css @@ -8,7 +8,8 @@ a { } .sidebar-wrapper .sidebar-header .logo-img { - width: 48px; + height: 40px; + width: 40px; } .sidebar-wrapper .sidebar-header, diff --git a/frontend/src/app/core/components/sidebar/sidebar.component.html b/frontend/src/app/core/components/sidebar/sidebar.component.html index 0959083..fc582e0 100644 --- a/frontend/src/app/core/components/sidebar/sidebar.component.html +++ b/frontend/src/app/core/components/sidebar/sidebar.component.html @@ -7,7 +7,7 @@
    -
    ShowzY
    +
    Showy
    @@ -319,7 +319,7 @@

    Tv-Series

    {{this.watchCount.seriesTotal}}

    -

    24.9%267.35 USD

    +
    diff --git a/frontend/src/app/features/home/home.component.ts b/frontend/src/app/features/home/home.component.ts index c24547b..9c6d051 100644 --- a/frontend/src/app/features/home/home.component.ts +++ b/frontend/src/app/features/home/home.component.ts @@ -3,7 +3,7 @@ import ApexCharts from 'apexcharts'; import { EntrySeenService } from '../../core/services/entry-seen.service'; import { LibraryService } from '../../core/services/library.service'; import { EpisodeSeenService } from '../../core/services/episode-seen.service'; -import { Observable, forkJoin } from 'rxjs'; +import { forkJoin } from 'rxjs'; @Component({ selector: 'app-home-page', diff --git a/frontend/src/app/shared/components/cards/main-card/main-card.component.html b/frontend/src/app/shared/components/cards/main-card/main-card.component.html index 8c246b7..d7e6a41 100644 --- a/frontend/src/app/shared/components/cards/main-card/main-card.component.html +++ b/frontend/src/app/shared/components/cards/main-card/main-card.component.html @@ -1,6 +1,6 @@
    - Movie Poster + Movie Poster
    @@ -37,8 +37,8 @@
    -
    - +
    +

    {{ entry.title }}

    diff --git a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts index acebd4f..37c3971 100644 --- a/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts +++ b/frontend/src/app/shared/components/modals/confirm-modal/confirm-modal.component.ts @@ -1,6 +1,5 @@ -import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { FormBuilder } from '@angular/forms'; @Component({ selector: 'app-confirm-modal', diff --git a/frontend/src/app/shared/pipes/date-format/date-format.pipe.ts b/frontend/src/app/shared/pipes/date-format/date-format.pipe.ts index 62271f2..33f09a2 100644 --- a/frontend/src/app/shared/pipes/date-format/date-format.pipe.ts +++ b/frontend/src/app/shared/pipes/date-format/date-format.pipe.ts @@ -5,14 +5,6 @@ import { format } from 'date-fns'; name: 'dateFormat', }) export class DateFormatPipe implements PipeTransform { - // transform(value: string): string { - // if (!value) return ''; - - // const date = new Date(value); - // const formatter = new Intl.DateTimeFormat('en-US', { month: 'long', day: '2-digit', year: 'numeric' }); - // return formatter.format(date); - // } - transform( value: Date | string | number, formatString: string = 'yyyy-MM-dd' diff --git a/frontend/src/assets/images/default/default-logo.png b/frontend/src/assets/images/default/default-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..aebb1a84b89b42417229e586f165d85cf3eede9b GIT binary patch literal 7484 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 literal 0 HcmV?d00001 diff --git a/frontend/src/assets/sass/main.css b/frontend/src/assets/sass/main.css index 9fbb737..818042c 100644 --- a/frontend/src/assets/sass/main.css +++ b/frontend/src/assets/sass/main.css @@ -528,7 +528,7 @@ footer { .main-wrapper { position: relative; - height: calc(100vh - 70px); + height: calc(100vh - 50px); /* overflow: hidden; */ margin-top: 50px; diff --git a/frontend/src/assets/sass/main.scss b/frontend/src/assets/sass/main.scss index 84fb8b6..f940d07 100644 --- a/frontend/src/assets/sass/main.scss +++ b/frontend/src/assets/sass/main.scss @@ -475,10 +475,10 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 $border-color_1: initial; .sidebar-nav { - margin-top: 70px; + margin-top: 50px; height: 100%; background-color: #ffffff; - height: calc(100% - 140px); + height: calc(100% - 70px); ul { padding: 10px; @@ -647,7 +647,7 @@ $dropdownAnimation: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) 0s normal forwards 1 } } -@media screen and (min-width: 1199px) { +@media screen and (min-width: 199px) { body.toggled { .sidebar-wrapper { &:hover {